From e585187b248f48b3c6e9247b49fa07c6565d65e5 Mon Sep 17 00:00:00 2001 From: maximius Date: Sat, 17 Oct 2009 15:51:44 -0700 Subject: *Backed out changeset 3be01fb200a5 --HG-- branch : trunk --- COPYING | 53 + README | 10 + THANKS | 5 + dep/ACE_wrappers/README | 61 + dep/ACE_wrappers/VERSION | 3 + dep/ACE_wrappers/ace/ACE.cpp | 431 +++ dep/ACE_wrappers/ace/ACE.h | 144 + dep/ACE_wrappers/ace/ACE.inl | 34 + dep/ACE_wrappers/ace/ACE_crc32.cpp | 18 + dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp | 18 + dep/ACE_wrappers/ace/ACE_export.h | 9 + dep/ACE_wrappers/ace/ARGV.h | 46 + dep/ACE_wrappers/ace/ARGV.inl | 20 + dep/ACE_wrappers/ace/ATM_Acceptor.cpp | 45 + dep/ACE_wrappers/ace/ATM_Acceptor.h | 26 + dep/ACE_wrappers/ace/ATM_Acceptor.inl | 6 + dep/ACE_wrappers/ace/ATM_Addr.cpp | 79 + dep/ACE_wrappers/ace/ATM_Addr.h | 36 + dep/ACE_wrappers/ace/ATM_Addr.inl | 4 + dep/ACE_wrappers/ace/ATM_Connector.cpp | 22 + dep/ACE_wrappers/ace/ATM_Connector.h | 21 + dep/ACE_wrappers/ace/ATM_Connector.inl | 15 + dep/ACE_wrappers/ace/ATM_Params.cpp | 9 + dep/ACE_wrappers/ace/ATM_Params.h | 50 + dep/ACE_wrappers/ace/ATM_Params.inl | 28 + dep/ACE_wrappers/ace/ATM_QoS.cpp | 93 + dep/ACE_wrappers/ace/ATM_QoS.h | 21 + dep/ACE_wrappers/ace/ATM_QoS.inl | 5 + dep/ACE_wrappers/ace/ATM_Stream.cpp | 42 + dep/ACE_wrappers/ace/ATM_Stream.h | 24 + dep/ACE_wrappers/ace/ATM_Stream.inl | 13 + dep/ACE_wrappers/ace/Acceptor.h | 111 + dep/ACE_wrappers/ace/Activation_Queue.cpp | 20 + dep/ACE_wrappers/ace/Activation_Queue.h | 33 + dep/ACE_wrappers/ace/Activation_Queue.inl | 6 + dep/ACE_wrappers/ace/Active_Map_Manager.cpp | 3 + dep/ACE_wrappers/ace/Active_Map_Manager.h | 26 + dep/ACE_wrappers/ace/Active_Map_Manager.inl | 15 + dep/ACE_wrappers/ace/Active_Map_Manager_T.h | 45 + dep/ACE_wrappers/ace/Active_Map_Manager_T.inl | 60 + dep/ACE_wrappers/ace/Addr.cpp | 17 + dep/ACE_wrappers/ace/Addr.h | 29 + dep/ACE_wrappers/ace/Addr.inl | 14 + dep/ACE_wrappers/ace/Arg_Shifter.h | 35 + dep/ACE_wrappers/ace/Argv_Type_Converter.cpp | 27 + dep/ACE_wrappers/ace/Argv_Type_Converter.h | 32 + dep/ACE_wrappers/ace/Argv_Type_Converter.inl | 8 + dep/ACE_wrappers/ace/Array.h | 5 + dep/ACE_wrappers/ace/Array_Base.h | 53 + dep/ACE_wrappers/ace/Array_Base.inl | 23 + dep/ACE_wrappers/ace/Array_Map.h | 48 + dep/ACE_wrappers/ace/Array_Map.inl | 20 + dep/ACE_wrappers/ace/Assert.cpp | 7 + dep/ACE_wrappers/ace/Assert.h | 9 + dep/ACE_wrappers/ace/Asynch_Acceptor.h | 44 + dep/ACE_wrappers/ace/Asynch_Connector.h | 31 + dep/ACE_wrappers/ace/Asynch_IO.cpp | 209 ++ dep/ACE_wrappers/ace/Asynch_IO.h | 252 ++ dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp | 32 + dep/ACE_wrappers/ace/Asynch_IO_Impl.h | 109 + dep/ACE_wrappers/ace/Asynch_IO_Impl.inl | 18 + dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp | 27 + dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h | 18 + dep/ACE_wrappers/ace/Atomic_Op.cpp | 26 + dep/ACE_wrappers/ace/Atomic_Op.h | 67 + dep/ACE_wrappers/ace/Atomic_Op.inl | 44 + dep/ACE_wrappers/ace/Atomic_Op_Sparc.c | 18 + dep/ACE_wrappers/ace/Atomic_Op_Sparc.h | 3 + dep/ACE_wrappers/ace/Atomic_Op_T.h | 80 + dep/ACE_wrappers/ace/Atomic_Op_T.inl | 45 + dep/ACE_wrappers/ace/Auto_Event.cpp | 8 + dep/ACE_wrappers/ace/Auto_Event.h | 14 + dep/ACE_wrappers/ace/Auto_Event.inl | 3 + dep/ACE_wrappers/ace/Auto_Functor.h | 31 + dep/ACE_wrappers/ace/Auto_Functor.inl | 21 + dep/ACE_wrappers/ace/Auto_IncDec_T.h | 19 + dep/ACE_wrappers/ace/Auto_IncDec_T.inl | 6 + dep/ACE_wrappers/ace/Auto_Ptr.h | 41 + dep/ACE_wrappers/ace/Auto_Ptr.inl | 25 + dep/ACE_wrappers/ace/Barrier.cpp | 36 + dep/ACE_wrappers/ace/Barrier.h | 41 + dep/ACE_wrappers/ace/Barrier.inl | 5 + dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp | 24 + dep/ACE_wrappers/ace/Base_Thread_Adapter.h | 37 + dep/ACE_wrappers/ace/Base_Thread_Adapter.inl | 7 + dep/ACE_wrappers/ace/Based_Pointer_Repository.cpp | 21 + dep/ACE_wrappers/ace/Based_Pointer_Repository.h | 22 + dep/ACE_wrappers/ace/Based_Pointer_T.h | 40 + dep/ACE_wrappers/ace/Based_Pointer_T.inl | 21 + dep/ACE_wrappers/ace/Basic_Stats.cpp | 14 + dep/ACE_wrappers/ace/Basic_Stats.h | 18 + dep/ACE_wrappers/ace/Basic_Stats.inl | 7 + dep/ACE_wrappers/ace/Basic_Types.cpp | 13 + dep/ACE_wrappers/ace/Basic_Types.h | 103 + dep/ACE_wrappers/ace/Basic_Types.inl | 172 + dep/ACE_wrappers/ace/Bound_Ptr.h | 83 + dep/ACE_wrappers/ace/Bound_Ptr.inl | 80 + dep/ACE_wrappers/ace/CDR_Base.cpp | 95 + dep/ACE_wrappers/ace/CDR_Base.h | 45 + dep/ACE_wrappers/ace/CDR_Base.inl | 16 + dep/ACE_wrappers/ace/CDR_Size.cpp | 30 + dep/ACE_wrappers/ace/CDR_Size.h | 36 + dep/ACE_wrappers/ace/CDR_Size.inl | 57 + dep/ACE_wrappers/ace/CDR_Stream.cpp | 235 ++ dep/ACE_wrappers/ace/CDR_Stream.h | 191 ++ dep/ACE_wrappers/ace/CDR_Stream.inl | 245 ++ dep/ACE_wrappers/ace/CE_Screen_Output.h | 30 + dep/ACE_wrappers/ace/CORBA_macros.h | 96 + dep/ACE_wrappers/ace/Cache_Map_Manager_T.h | 93 + dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl | 37 + dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h | 45 + dep/ACE_wrappers/ace/Caching_Strategies_T.h | 129 + dep/ACE_wrappers/ace/Caching_Strategies_T.inl | 84 + dep/ACE_wrappers/ace/Caching_Utility_T.h | 69 + dep/ACE_wrappers/ace/Capabilities.cpp | 54 + dep/ACE_wrappers/ace/Capabilities.h | 47 + dep/ACE_wrappers/ace/Capabilities.inl | 9 + dep/ACE_wrappers/ace/Cleanup.cpp | 33 + dep/ACE_wrappers/ace/Cleanup.h | 28 + dep/ACE_wrappers/ace/Cleanup.inl | 3 + dep/ACE_wrappers/ace/Cleanup_Strategies_T.h | 24 + dep/ACE_wrappers/ace/Codecs.cpp | 32 + dep/ACE_wrappers/ace/Codecs.h | 26 + dep/ACE_wrappers/ace/Codeset_IBM1047.cpp | 51 + dep/ACE_wrappers/ace/Codeset_IBM1047.h | 20 + dep/ACE_wrappers/ace/Codeset_Registry.cpp | 12 + dep/ACE_wrappers/ace/Codeset_Registry.h | 16 + dep/ACE_wrappers/ace/Codeset_Registry.inl | 6 + dep/ACE_wrappers/ace/Codeset_Registry_db.cpp | 5 + dep/ACE_wrappers/ace/Codeset_Symbols.h | 3 + .../ace/Condition_Recursive_Thread_Mutex.cpp | 21 + .../ace/Condition_Recursive_Thread_Mutex.h | 26 + dep/ACE_wrappers/ace/Condition_T.h | 31 + dep/ACE_wrappers/ace/Condition_T.inl | 10 + dep/ACE_wrappers/ace/Condition_Thread_Mutex.cpp | 20 + dep/ACE_wrappers/ace/Condition_Thread_Mutex.h | 37 + dep/ACE_wrappers/ace/Condition_Thread_Mutex.inl | 13 + dep/ACE_wrappers/ace/Configuration.cpp | 310 ++ dep/ACE_wrappers/ace/Configuration.h | 140 + dep/ACE_wrappers/ace/Configuration.inl | 3 + .../ace/Configuration_Import_Export.cpp | 48 + dep/ACE_wrappers/ace/Configuration_Import_Export.h | 27 + .../ace/Connection_Recycling_Strategy.cpp | 4 + .../ace/Connection_Recycling_Strategy.h | 16 + dep/ACE_wrappers/ace/Connector.h | 91 + dep/ACE_wrappers/ace/Containers.cpp | 4 + dep/ACE_wrappers/ace/Containers.h | 18 + dep/ACE_wrappers/ace/Containers.inl | 4 + dep/ACE_wrappers/ace/Containers_T.h | 344 ++ dep/ACE_wrappers/ace/Containers_T.inl | 77 + dep/ACE_wrappers/ace/Copy_Disabled.cpp | 5 + dep/ACE_wrappers/ace/Copy_Disabled.h | 12 + dep/ACE_wrappers/ace/Countdown_Time.cpp | 10 + dep/ACE_wrappers/ace/Countdown_Time.h | 20 + dep/ACE_wrappers/ace/DEV.cpp | 12 + dep/ACE_wrappers/ace/DEV.h | 16 + dep/ACE_wrappers/ace/DEV.inl | 3 + dep/ACE_wrappers/ace/DEV_Addr.cpp | 27 + dep/ACE_wrappers/ace/DEV_Addr.h | 25 + dep/ACE_wrappers/ace/DEV_Addr.inl | 14 + dep/ACE_wrappers/ace/DEV_Connector.cpp | 11 + dep/ACE_wrappers/ace/DEV_Connector.h | 15 + dep/ACE_wrappers/ace/DEV_Connector.inl | 5 + dep/ACE_wrappers/ace/DEV_IO.cpp | 25 + dep/ACE_wrappers/ace/DEV_IO.h | 33 + dep/ACE_wrappers/ace/DEV_IO.inl | 19 + dep/ACE_wrappers/ace/DLL.cpp | 58 + dep/ACE_wrappers/ace/DLL.h | 30 + dep/ACE_wrappers/ace/DLL_Manager.cpp | 110 + dep/ACE_wrappers/ace/DLL_Manager.h | 55 + dep/ACE_wrappers/ace/Date_Time.cpp | 3 + dep/ACE_wrappers/ace/Date_Time.h | 31 + dep/ACE_wrappers/ace/Date_Time.inl | 26 + dep/ACE_wrappers/ace/Default_Constants.h | 104 + dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp | 511 +++ dep/ACE_wrappers/ace/Dev_Poll_Reactor.h | 219 ++ dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl | 43 + dep/ACE_wrappers/ace/Dirent.cpp | 2 + dep/ACE_wrappers/ace/Dirent.h | 20 + dep/ACE_wrappers/ace/Dirent.inl | 17 + dep/ACE_wrappers/ace/Dirent_Selector.cpp | 12 + dep/ACE_wrappers/ace/Dirent_Selector.h | 17 + dep/ACE_wrappers/ace/Dirent_Selector.inl | 4 + dep/ACE_wrappers/ace/Dump.cpp | 24 + dep/ACE_wrappers/ace/Dump.h | 27 + dep/ACE_wrappers/ace/Dump_T.h | 14 + dep/ACE_wrappers/ace/Dynamic.cpp | 8 + dep/ACE_wrappers/ace/Dynamic.h | 15 + dep/ACE_wrappers/ace/Dynamic.inl | 6 + dep/ACE_wrappers/ace/Dynamic_Message_Strategy.cpp | 35 + dep/ACE_wrappers/ace/Dynamic_Message_Strategy.h | 43 + dep/ACE_wrappers/ace/Dynamic_Message_Strategy.inl | 10 + dep/ACE_wrappers/ace/Dynamic_Service.h | 21 + dep/ACE_wrappers/ace/Dynamic_Service.inl | 8 + dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp | 19 + dep/ACE_wrappers/ace/Dynamic_Service_Base.h | 16 + .../ace/Dynamic_Service_Dependency.cpp | 7 + dep/ACE_wrappers/ace/Dynamic_Service_Dependency.h | 12 + dep/ACE_wrappers/ace/Encoding_Converter.cpp | 3 + dep/ACE_wrappers/ace/Encoding_Converter.h | 13 + .../ace/Encoding_Converter_Factory.cpp | 8 + dep/ACE_wrappers/ace/Encoding_Converter_Factory.h | 12 + dep/ACE_wrappers/ace/Env_Value_T.h | 33 + dep/ACE_wrappers/ace/Env_Value_T.inl | 9 + dep/ACE_wrappers/ace/Event.cpp | 15 + dep/ACE_wrappers/ace/Event.h | 24 + dep/ACE_wrappers/ace/Event.inl | 4 + dep/ACE_wrappers/ace/Event_Handler.cpp | 75 + dep/ACE_wrappers/ace/Event_Handler.h | 74 + dep/ACE_wrappers/ace/Event_Handler.inl | 3 + dep/ACE_wrappers/ace/Event_Handler_T.h | 40 + dep/ACE_wrappers/ace/Event_Handler_T.inl | 21 + dep/ACE_wrappers/ace/Exception_Macros.h | 9 + dep/ACE_wrappers/ace/FIFO.cpp | 16 + dep/ACE_wrappers/ace/FIFO.h | 18 + dep/ACE_wrappers/ace/FIFO.inl | 5 + dep/ACE_wrappers/ace/FIFO_Recv.cpp | 15 + dep/ACE_wrappers/ace/FIFO_Recv.h | 20 + dep/ACE_wrappers/ace/FIFO_Recv.inl | 5 + dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp | 14 + dep/ACE_wrappers/ace/FIFO_Recv_Msg.h | 18 + dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl | 17 + dep/ACE_wrappers/ace/FIFO_Send.cpp | 10 + dep/ACE_wrappers/ace/FIFO_Send.h | 18 + dep/ACE_wrappers/ace/FIFO_Send.inl | 5 + dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp | 15 + dep/ACE_wrappers/ace/FIFO_Send_Msg.h | 19 + dep/ACE_wrappers/ace/FIFO_Send_Msg.inl | 8 + dep/ACE_wrappers/ace/FILE.cpp | 34 + dep/ACE_wrappers/ace/FILE.h | 29 + dep/ACE_wrappers/ace/FILE.inl | 3 + dep/ACE_wrappers/ace/FILE_Addr.cpp | 22 + dep/ACE_wrappers/ace/FILE_Addr.h | 23 + dep/ACE_wrappers/ace/FILE_Addr.inl | 9 + dep/ACE_wrappers/ace/FILE_Connector.cpp | 18 + dep/ACE_wrappers/ace/FILE_Connector.h | 15 + dep/ACE_wrappers/ace/FILE_Connector.inl | 5 + dep/ACE_wrappers/ace/FILE_IO.cpp | 25 + dep/ACE_wrappers/ace/FILE_IO.h | 37 + dep/ACE_wrappers/ace/FILE_IO.inl | 24 + dep/ACE_wrappers/ace/File_Lock.cpp | 13 + dep/ACE_wrappers/ace/File_Lock.h | 30 + dep/ACE_wrappers/ace/File_Lock.inl | 15 + dep/ACE_wrappers/ace/Filecache.cpp | 113 + dep/ACE_wrappers/ace/Filecache.h | 71 + dep/ACE_wrappers/ace/Flag_Manip.cpp | 18 + dep/ACE_wrappers/ace/Flag_Manip.h | 14 + dep/ACE_wrappers/ace/Flag_Manip.inl | 5 + dep/ACE_wrappers/ace/Framework_Component.cpp | 53 + dep/ACE_wrappers/ace/Framework_Component.h | 48 + dep/ACE_wrappers/ace/Framework_Component.inl | 7 + dep/ACE_wrappers/ace/Framework_Component_T.h | 13 + dep/ACE_wrappers/ace/Free_List.h | 31 + dep/ACE_wrappers/ace/Functor.cpp | 6 + dep/ACE_wrappers/ace/Functor.h | 53 + dep/ACE_wrappers/ace/Functor.inl | 45 + dep/ACE_wrappers/ace/Functor_String.cpp | 2 + dep/ACE_wrappers/ace/Functor_String.h | 18 + dep/ACE_wrappers/ace/Functor_String.inl | 10 + dep/ACE_wrappers/ace/Functor_T.h | 22 + dep/ACE_wrappers/ace/Functor_T.inl | 6 + dep/ACE_wrappers/ace/Future.h | 70 + dep/ACE_wrappers/ace/Future_Set.h | 28 + dep/ACE_wrappers/ace/Get_Opt.cpp | 71 + dep/ACE_wrappers/ace/Get_Opt.h | 64 + dep/ACE_wrappers/ace/Get_Opt.inl | 10 + dep/ACE_wrappers/ace/Global_Macros.h | 99 + dep/ACE_wrappers/ace/Guard_T.h | 88 + dep/ACE_wrappers/ace/Guard_T.inl | 26 + dep/ACE_wrappers/ace/Handle_Gobbler.h | 15 + dep/ACE_wrappers/ace/Handle_Gobbler.inl | 15 + dep/ACE_wrappers/ace/Handle_Ops.cpp | 10 + dep/ACE_wrappers/ace/Handle_Ops.h | 12 + dep/ACE_wrappers/ace/Handle_Set.cpp | 80 + dep/ACE_wrappers/ace/Handle_Set.h | 49 + dep/ACE_wrappers/ace/Handle_Set.inl | 34 + dep/ACE_wrappers/ace/Hash_Cache_Map_Manager_T.h | 36 + dep/ACE_wrappers/ace/Hash_Cache_Map_Manager_T.inl | 11 + dep/ACE_wrappers/ace/Hash_Map_Manager.h | 8 + dep/ACE_wrappers/ace/Hash_Map_Manager_T.h | 231 ++ dep/ACE_wrappers/ace/Hash_Map_Manager_T.inl | 211 ++ dep/ACE_wrappers/ace/Hash_Map_With_Allocator_T.h | 20 + dep/ACE_wrappers/ace/Hash_Map_With_Allocator_T.inl | 10 + dep/ACE_wrappers/ace/Hash_Multi_Map_Manager_T.h | 182 ++ dep/ACE_wrappers/ace/Hash_Multi_Map_Manager_T.inl | 181 ++ dep/ACE_wrappers/ace/Hashable.cpp | 9 + dep/ACE_wrappers/ace/Hashable.h | 18 + dep/ACE_wrappers/ace/Hashable.inl | 3 + dep/ACE_wrappers/ace/High_Res_Timer.cpp | 73 + dep/ACE_wrappers/ace/High_Res_Timer.h | 44 + dep/ACE_wrappers/ace/High_Res_Timer.inl | 22 + dep/ACE_wrappers/ace/ICMP_Socket.cpp | 31 + dep/ACE_wrappers/ace/ICMP_Socket.h | 27 + dep/ACE_wrappers/ace/INET_Addr.cpp | 135 + dep/ACE_wrappers/ace/INET_Addr.h | 69 + dep/ACE_wrappers/ace/INET_Addr.inl | 30 + dep/ACE_wrappers/ace/IOStream.cpp | 117 + dep/ACE_wrappers/ace/IOStream.h | 67 + dep/ACE_wrappers/ace/IOStream_T.h | 36 + dep/ACE_wrappers/ace/IOStream_T.inl | 19 + dep/ACE_wrappers/ace/IO_Cntl_Msg.cpp | 15 + dep/ACE_wrappers/ace/IO_Cntl_Msg.h | 28 + dep/ACE_wrappers/ace/IO_Cntl_Msg.inl | 11 + dep/ACE_wrappers/ace/IO_SAP.cpp | 17 + dep/ACE_wrappers/ace/IO_SAP.h | 21 + dep/ACE_wrappers/ace/IO_SAP.inl | 10 + dep/ACE_wrappers/ace/IPC_SAP.cpp | 18 + dep/ACE_wrappers/ace/IPC_SAP.h | 22 + dep/ACE_wrappers/ace/IPC_SAP.inl | 9 + dep/ACE_wrappers/ace/If_Then_Else.h | 11 + dep/ACE_wrappers/ace/Init_ACE.cpp | 10 + dep/ACE_wrappers/ace/Init_ACE.h | 13 + dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.h | 39 + dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.inl | 25 + dep/ACE_wrappers/ace/Intrusive_List.h | 27 + dep/ACE_wrappers/ace/Intrusive_List.inl | 8 + dep/ACE_wrappers/ace/Intrusive_List_Node.h | 13 + dep/ACE_wrappers/ace/Intrusive_List_Node.inl | 6 + dep/ACE_wrappers/ace/LOCK_SOCK_Acceptor.h | 12 + dep/ACE_wrappers/ace/LSOCK.cpp | 27 + dep/ACE_wrappers/ace/LSOCK.h | 21 + dep/ACE_wrappers/ace/LSOCK.inl | 10 + dep/ACE_wrappers/ace/LSOCK_Acceptor.cpp | 29 + dep/ACE_wrappers/ace/LSOCK_Acceptor.h | 20 + dep/ACE_wrappers/ace/LSOCK_CODgram.cpp | 14 + dep/ACE_wrappers/ace/LSOCK_CODgram.h | 17 + dep/ACE_wrappers/ace/LSOCK_CODgram.inl | 6 + dep/ACE_wrappers/ace/LSOCK_Connector.cpp | 12 + dep/ACE_wrappers/ace/LSOCK_Connector.h | 16 + dep/ACE_wrappers/ace/LSOCK_Connector.inl | 3 + dep/ACE_wrappers/ace/LSOCK_Dgram.cpp | 16 + dep/ACE_wrappers/ace/LSOCK_Dgram.h | 17 + dep/ACE_wrappers/ace/LSOCK_Dgram.inl | 4 + dep/ACE_wrappers/ace/LSOCK_Stream.cpp | 26 + dep/ACE_wrappers/ace/LSOCK_Stream.h | 19 + dep/ACE_wrappers/ace/LSOCK_Stream.inl | 5 + dep/ACE_wrappers/ace/Lib_Find.cpp | 104 + dep/ACE_wrappers/ace/Lib_Find.h | 19 + dep/ACE_wrappers/ace/Local_Memory_Pool.cpp | 25 + dep/ACE_wrappers/ace/Local_Memory_Pool.h | 27 + dep/ACE_wrappers/ace/Local_Name_Space.cpp | 25 + dep/ACE_wrappers/ace/Local_Name_Space.h | 33 + dep/ACE_wrappers/ace/Local_Name_Space_T.h | 46 + dep/ACE_wrappers/ace/Local_Tokens.cpp | 240 ++ dep/ACE_wrappers/ace/Local_Tokens.h | 203 ++ dep/ACE_wrappers/ace/Local_Tokens.inl | 51 + dep/ACE_wrappers/ace/Lock.cpp | 18 + dep/ACE_wrappers/ace/Lock.h | 24 + dep/ACE_wrappers/ace/Lock.inl | 3 + dep/ACE_wrappers/ace/Lock_Adapter_T.h | 26 + dep/ACE_wrappers/ace/Lock_Adapter_T.inl | 3 + dep/ACE_wrappers/ace/Log_Msg.cpp | 301 ++ dep/ACE_wrappers/ace/Log_Msg.h | 127 + dep/ACE_wrappers/ace/Log_Msg.inl | 35 + dep/ACE_wrappers/ace/Log_Msg_Backend.cpp | 5 + dep/ACE_wrappers/ace/Log_Msg_Backend.h | 14 + dep/ACE_wrappers/ace/Log_Msg_Callback.cpp | 4 + dep/ACE_wrappers/ace/Log_Msg_Callback.h | 10 + dep/ACE_wrappers/ace/Log_Msg_IPC.cpp | 19 + dep/ACE_wrappers/ace/Log_Msg_IPC.h | 14 + dep/ACE_wrappers/ace/Log_Msg_NT_Event_Log.cpp | 22 + dep/ACE_wrappers/ace/Log_Msg_NT_Event_Log.h | 17 + dep/ACE_wrappers/ace/Log_Msg_UNIX_Syslog.cpp | 33 + dep/ACE_wrappers/ace/Log_Msg_UNIX_Syslog.h | 18 + dep/ACE_wrappers/ace/Log_Priority.h | 21 + dep/ACE_wrappers/ace/Log_Record.cpp | 48 + dep/ACE_wrappers/ace/Log_Record.h | 50 + dep/ACE_wrappers/ace/Log_Record.inl | 17 + dep/ACE_wrappers/ace/Logging_Strategy.cpp | 68 + dep/ACE_wrappers/ace/Logging_Strategy.h | 32 + dep/ACE_wrappers/ace/MEM_Acceptor.cpp | 44 + dep/ACE_wrappers/ace/MEM_Acceptor.h | 36 + dep/ACE_wrappers/ace/MEM_Acceptor.inl | 14 + dep/ACE_wrappers/ace/MEM_Addr.cpp | 35 + dep/ACE_wrappers/ace/MEM_Addr.h | 40 + dep/ACE_wrappers/ace/MEM_Addr.inl | 24 + dep/ACE_wrappers/ace/MEM_Connector.cpp | 25 + dep/ACE_wrappers/ace/MEM_Connector.h | 23 + dep/ACE_wrappers/ace/MEM_Connector.inl | 7 + dep/ACE_wrappers/ace/MEM_IO.cpp | 86 + dep/ACE_wrappers/ace/MEM_IO.h | 52 + dep/ACE_wrappers/ace/MEM_IO.inl | 50 + dep/ACE_wrappers/ace/MEM_SAP.cpp | 24 + dep/ACE_wrappers/ace/MEM_SAP.h | 40 + dep/ACE_wrappers/ace/MEM_SAP.inl | 12 + dep/ACE_wrappers/ace/MEM_Stream.cpp | 12 + dep/ACE_wrappers/ace/MEM_Stream.h | 31 + dep/ACE_wrappers/ace/MEM_Stream.inl | 21 + dep/ACE_wrappers/ace/MMAP_Memory_Pool.cpp | 85 + dep/ACE_wrappers/ace/MMAP_Memory_Pool.h | 66 + dep/ACE_wrappers/ace/MMAP_Memory_Pool.inl | 4 + dep/ACE_wrappers/ace/Malloc.cpp | 27 + dep/ACE_wrappers/ace/Malloc.h | 66 + dep/ACE_wrappers/ace/Malloc.inl | 5 + dep/ACE_wrappers/ace/Malloc_Allocator.cpp | 62 + dep/ACE_wrappers/ace/Malloc_Allocator.h | 21 + dep/ACE_wrappers/ace/Malloc_Allocator.inl | 3 + dep/ACE_wrappers/ace/Malloc_Base.h | 38 + dep/ACE_wrappers/ace/Malloc_T.h | 149 + dep/ACE_wrappers/ace/Malloc_T.inl | 27 + dep/ACE_wrappers/ace/Managed_Object.h | 26 + dep/ACE_wrappers/ace/Managed_Object.inl | 4 + dep/ACE_wrappers/ace/Manual_Event.cpp | 8 + dep/ACE_wrappers/ace/Manual_Event.h | 14 + dep/ACE_wrappers/ace/Manual_Event.inl | 3 + dep/ACE_wrappers/ace/Map.h | 8 + dep/ACE_wrappers/ace/Map_Manager.h | 157 + dep/ACE_wrappers/ace/Map_Manager.inl | 137 + dep/ACE_wrappers/ace/Map_T.h | 326 ++ dep/ACE_wrappers/ace/Map_T.inl | 66 + dep/ACE_wrappers/ace/Mem_Map.cpp | 47 + dep/ACE_wrappers/ace/Mem_Map.h | 51 + dep/ACE_wrappers/ace/Mem_Map.inl | 46 + dep/ACE_wrappers/ace/Memory_Pool.h | 6 + dep/ACE_wrappers/ace/Message_Block.cpp | 170 + dep/ACE_wrappers/ace/Message_Block.h | 147 + dep/ACE_wrappers/ace/Message_Block.inl | 72 + dep/ACE_wrappers/ace/Message_Block_T.h | 16 + dep/ACE_wrappers/ace/Message_Block_T.inl | 4 + dep/ACE_wrappers/ace/Message_Queue.cpp | 8 + dep/ACE_wrappers/ace/Message_Queue.h | 47 + dep/ACE_wrappers/ace/Message_Queue.inl | 3 + dep/ACE_wrappers/ace/Message_Queue_NT.cpp | 28 + dep/ACE_wrappers/ace/Message_Queue_NT.h | 45 + dep/ACE_wrappers/ace/Message_Queue_NT.inl | 23 + dep/ACE_wrappers/ace/Message_Queue_T.h | 209 ++ dep/ACE_wrappers/ace/Message_Queue_Vx.cpp | 63 + dep/ACE_wrappers/ace/Message_Queue_Vx.h | 52 + dep/ACE_wrappers/ace/Message_Queue_Vx.inl | 5 + dep/ACE_wrappers/ace/Method_Object.h | 8 + dep/ACE_wrappers/ace/Method_Request.cpp | 7 + dep/ACE_wrappers/ace/Method_Request.h | 18 + dep/ACE_wrappers/ace/Metrics_Cache.h | 20 + dep/ACE_wrappers/ace/Metrics_Cache_T.h | 60 + dep/ACE_wrappers/ace/Metrics_Cache_T.inl | 30 + dep/ACE_wrappers/ace/Min_Max.h | 13 + dep/ACE_wrappers/ace/Module.h | 43 + dep/ACE_wrappers/ace/Module.inl | 11 + dep/ACE_wrappers/ace/Monitor_Admin.cpp | 19 + dep/ACE_wrappers/ace/Monitor_Admin.h | 20 + dep/ACE_wrappers/ace/Monitor_Admin_Manager.cpp | 10 + dep/ACE_wrappers/ace/Monitor_Admin_Manager.h | 17 + dep/ACE_wrappers/ace/Monitor_Base.cpp | 71 + dep/ACE_wrappers/ace/Monitor_Base.h | 42 + dep/ACE_wrappers/ace/Monitor_Base.inl | 9 + dep/ACE_wrappers/ace/Monitor_Control_Action.cpp | 12 + dep/ACE_wrappers/ace/Monitor_Control_Action.h | 14 + dep/ACE_wrappers/ace/Monitor_Control_Types.cpp | 16 + dep/ACE_wrappers/ace/Monitor_Control_Types.h | 23 + dep/ACE_wrappers/ace/Monitor_Point_Registry.cpp | 38 + dep/ACE_wrappers/ace/Monitor_Point_Registry.h | 25 + dep/ACE_wrappers/ace/Monitor_Size.cpp | 12 + dep/ACE_wrappers/ace/Monitor_Size.h | 15 + dep/ACE_wrappers/ace/Msg_WFMO_Reactor.cpp | 16 + dep/ACE_wrappers/ace/Msg_WFMO_Reactor.h | 19 + dep/ACE_wrappers/ace/Msg_WFMO_Reactor.inl | 8 + dep/ACE_wrappers/ace/Multihomed_INET_Addr.cpp | 55 + dep/ACE_wrappers/ace/Multihomed_INET_Addr.h | 33 + dep/ACE_wrappers/ace/Multihomed_INET_Addr.inl | 3 + dep/ACE_wrappers/ace/Mutex.cpp | 15 + dep/ACE_wrappers/ace/Mutex.h | 36 + dep/ACE_wrappers/ace/Mutex.inl | 15 + dep/ACE_wrappers/ace/NT_Service.cpp | 99 + dep/ACE_wrappers/ace/NT_Service.h | 62 + dep/ACE_wrappers/ace/NT_Service.inl | 9 + dep/ACE_wrappers/ace/Name_Proxy.cpp | 33 + dep/ACE_wrappers/ace/Name_Proxy.h | 22 + dep/ACE_wrappers/ace/Name_Request_Reply.cpp | 90 + dep/ACE_wrappers/ace/Name_Request_Reply.h | 59 + dep/ACE_wrappers/ace/Name_Space.cpp | 12 + dep/ACE_wrappers/ace/Name_Space.h | 35 + dep/ACE_wrappers/ace/Naming_Context.cpp | 87 + dep/ACE_wrappers/ace/Naming_Context.h | 81 + dep/ACE_wrappers/ace/Naming_Context.inl | 6 + dep/ACE_wrappers/ace/Netlink_Addr.cpp | 16 + dep/ACE_wrappers/ace/Netlink_Addr.h | 24 + dep/ACE_wrappers/ace/Netlink_Addr.inl | 12 + dep/ACE_wrappers/ace/Node.h | 15 + dep/ACE_wrappers/ace/Notification_Queue.cpp | 51 + dep/ACE_wrappers/ace/Notification_Queue.h | 26 + dep/ACE_wrappers/ace/Notification_Queue.inl | 8 + dep/ACE_wrappers/ace/Notification_Strategy.cpp | 6 + dep/ACE_wrappers/ace/Notification_Strategy.h | 17 + dep/ACE_wrappers/ace/Notification_Strategy.inl | 6 + dep/ACE_wrappers/ace/Null_Barrier.h | 12 + dep/ACE_wrappers/ace/Null_Condition.h | 20 + dep/ACE_wrappers/ace/Null_Mutex.h | 40 + dep/ACE_wrappers/ace/Null_Semaphore.h | 22 + dep/ACE_wrappers/ace/Numeric_Limits.h | 41 + dep/ACE_wrappers/ace/OS.h | 58 + dep/ACE_wrappers/ace/OS.inl | 17 + dep/ACE_wrappers/ace/OS_Dirent.h | 7 + dep/ACE_wrappers/ace/OS_Errno.cpp | 11 + dep/ACE_wrappers/ace/OS_Errno.h | 18 + dep/ACE_wrappers/ace/OS_Errno.inl | 9 + dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.cpp | 3 + dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.h | 18 + dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.inl | 3 + dep/ACE_wrappers/ace/OS_Memory.h | 31 + dep/ACE_wrappers/ace/OS_NS_Thread.cpp | 512 +++ dep/ACE_wrappers/ace/OS_NS_Thread.inl | 311 ++ dep/ACE_wrappers/ace/OS_NS_arpa_inet.cpp | 7 + dep/ACE_wrappers/ace/OS_NS_arpa_inet.h | 18 + dep/ACE_wrappers/ace/OS_NS_arpa_inet.inl | 17 + dep/ACE_wrappers/ace/OS_NS_ctype.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_ctype.h | 31 + dep/ACE_wrappers/ace/OS_NS_ctype.inl | 18 + dep/ACE_wrappers/ace/OS_NS_dirent.cpp | 40 + dep/ACE_wrappers/ace/OS_NS_dirent.h | 30 + dep/ACE_wrappers/ace/OS_NS_dirent.inl | 18 + dep/ACE_wrappers/ace/OS_NS_dlfcn.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_dlfcn.h | 17 + dep/ACE_wrappers/ace/OS_NS_dlfcn.inl | 33 + dep/ACE_wrappers/ace/OS_NS_errno.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_errno.h | 22 + dep/ACE_wrappers/ace/OS_NS_errno.inl | 13 + dep/ACE_wrappers/ace/OS_NS_fcntl.cpp | 34 + dep/ACE_wrappers/ace/OS_NS_fcntl.h | 16 + dep/ACE_wrappers/ace/OS_NS_fcntl.inl | 4 + dep/ACE_wrappers/ace/OS_NS_macros.h | 21 + dep/ACE_wrappers/ace/OS_NS_math.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_math.h | 23 + dep/ACE_wrappers/ace/OS_NS_math.inl | 7 + dep/ACE_wrappers/ace/OS_NS_netdb.cpp | 88 + dep/ACE_wrappers/ace/OS_NS_netdb.h | 29 + dep/ACE_wrappers/ace/OS_NS_netdb.inl | 57 + dep/ACE_wrappers/ace/OS_NS_poll.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_poll.h | 16 + dep/ACE_wrappers/ace/OS_NS_poll.inl | 7 + dep/ACE_wrappers/ace/OS_NS_pwd.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_pwd.h | 20 + dep/ACE_wrappers/ace/OS_NS_pwd.inl | 11 + dep/ACE_wrappers/ace/OS_NS_regex.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_regex.h | 15 + dep/ACE_wrappers/ace/OS_NS_regex.inl | 7 + dep/ACE_wrappers/ace/OS_NS_signal.cpp | 6 + dep/ACE_wrappers/ace/OS_NS_signal.h | 35 + dep/ACE_wrappers/ace/OS_NS_signal.inl | 19 + dep/ACE_wrappers/ace/OS_NS_stdio.cpp | 52 + dep/ACE_wrappers/ace/OS_NS_stdio.h | 101 + dep/ACE_wrappers/ace/OS_NS_stdio.inl | 113 + dep/ACE_wrappers/ace/OS_NS_stdlib.cpp | 102 + dep/ACE_wrappers/ace/OS_NS_stdlib.h | 70 + dep/ACE_wrappers/ace/OS_NS_stdlib.inl | 50 + dep/ACE_wrappers/ace/OS_NS_string.cpp | 52 + dep/ACE_wrappers/ace/OS_NS_string.h | 85 + dep/ACE_wrappers/ace/OS_NS_string.inl | 56 + dep/ACE_wrappers/ace/OS_NS_strings.cpp | 15 + dep/ACE_wrappers/ace/OS_NS_strings.h | 20 + dep/ACE_wrappers/ace/OS_NS_strings.inl | 7 + dep/ACE_wrappers/ace/OS_NS_stropts.cpp | 23 + dep/ACE_wrappers/ace/OS_NS_stropts.h | 31 + dep/ACE_wrappers/ace/OS_NS_stropts.inl | 21 + dep/ACE_wrappers/ace/OS_NS_sys_mman.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_sys_mman.h | 20 + dep/ACE_wrappers/ace/OS_NS_sys_mman.inl | 28 + dep/ACE_wrappers/ace/OS_NS_sys_msg.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_sys_msg.h | 17 + dep/ACE_wrappers/ace/OS_NS_sys_msg.inl | 11 + dep/ACE_wrappers/ace/OS_NS_sys_resource.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_sys_resource.h | 16 + dep/ACE_wrappers/ace/OS_NS_sys_resource.inl | 12 + dep/ACE_wrappers/ace/OS_NS_sys_select.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_sys_select.h | 17 + dep/ACE_wrappers/ace/OS_NS_sys_select.inl | 6 + dep/ACE_wrappers/ace/OS_NS_sys_sendfile.cpp | 12 + dep/ACE_wrappers/ace/OS_NS_sys_sendfile.h | 15 + dep/ACE_wrappers/ace/OS_NS_sys_sendfile.inl | 4 + dep/ACE_wrappers/ace/OS_NS_sys_shm.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_sys_shm.h | 17 + dep/ACE_wrappers/ace/OS_NS_sys_shm.inl | 11 + dep/ACE_wrappers/ace/OS_NS_sys_socket.cpp | 17 + dep/ACE_wrappers/ace/OS_NS_sys_socket.h | 50 + dep/ACE_wrappers/ace/OS_NS_sys_socket.inl | 81 + dep/ACE_wrappers/ace/OS_NS_sys_stat.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_sys_stat.h | 27 + dep/ACE_wrappers/ace/OS_NS_sys_stat.inl | 26 + dep/ACE_wrappers/ace/OS_NS_sys_time.cpp | 4 + dep/ACE_wrappers/ace/OS_NS_sys_time.h | 14 + dep/ACE_wrappers/ace/OS_NS_sys_time.inl | 14 + dep/ACE_wrappers/ace/OS_NS_sys_uio.cpp | 26 + dep/ACE_wrappers/ace/OS_NS_sys_uio.h | 17 + dep/ACE_wrappers/ace/OS_NS_sys_uio.inl | 5 + dep/ACE_wrappers/ace/OS_NS_sys_utsname.cpp | 19 + dep/ACE_wrappers/ace/OS_NS_sys_utsname.h | 14 + dep/ACE_wrappers/ace/OS_NS_sys_wait.cpp | 3 + dep/ACE_wrappers/ace/OS_NS_sys_wait.h | 16 + dep/ACE_wrappers/ace/OS_NS_sys_wait.inl | 12 + dep/ACE_wrappers/ace/OS_NS_time.cpp | 96 + dep/ACE_wrappers/ace/OS_NS_time.h | 46 + dep/ACE_wrappers/ace/OS_NS_time.inl | 52 +- dep/ACE_wrappers/ace/OS_NS_unistd.cpp | 140 + dep/ACE_wrappers/ace/OS_NS_unistd.h | 88 + dep/ACE_wrappers/ace/OS_NS_unistd.inl | 93 + dep/ACE_wrappers/ace/OS_NS_wchar.cpp | 57 + dep/ACE_wrappers/ace/OS_NS_wchar.h | 37 + dep/ACE_wrappers/ace/OS_NS_wchar.inl | 16 + dep/ACE_wrappers/ace/OS_QoS.cpp | 51 + dep/ACE_wrappers/ace/OS_QoS.h | 86 + dep/ACE_wrappers/ace/OS_String.h | 5 + dep/ACE_wrappers/ace/OS_TLI.cpp | 3 + dep/ACE_wrappers/ace/OS_TLI.h | 46 + dep/ACE_wrappers/ace/OS_TLI.inl | 53 + dep/ACE_wrappers/ace/OS_Thread_Adapter.cpp | 25 + dep/ACE_wrappers/ace/OS_Thread_Adapter.h | 13 + dep/ACE_wrappers/ace/OS_main.cpp | 28 + dep/ACE_wrappers/ace/OS_main.h | 49 + dep/ACE_wrappers/ace/Obchunk.cpp | 9 + dep/ACE_wrappers/ace/Obchunk.h | 17 + dep/ACE_wrappers/ace/Obchunk.inl | 3 + dep/ACE_wrappers/ace/Object_Manager.cpp | 124 + dep/ACE_wrappers/ace/Object_Manager.h | 62 + dep/ACE_wrappers/ace/Object_Manager.inl | 5 + dep/ACE_wrappers/ace/Object_Manager_Base.cpp | 67 + dep/ACE_wrappers/ace/Object_Manager_Base.h | 45 + dep/ACE_wrappers/ace/Obstack.h | 8 + dep/ACE_wrappers/ace/Obstack_T.h | 29 + dep/ACE_wrappers/ace/Obstack_T.inl | 4 + dep/ACE_wrappers/ace/PI_Malloc.cpp | 25 + dep/ACE_wrappers/ace/PI_Malloc.h | 49 + dep/ACE_wrappers/ace/PI_Malloc.inl | 7 + dep/ACE_wrappers/ace/POSIX_Asynch_IO.cpp | 392 +++ dep/ACE_wrappers/ace/POSIX_Asynch_IO.h | 210 ++ dep/ACE_wrappers/ace/POSIX_CB_Proactor.cpp | 35 + dep/ACE_wrappers/ace/POSIX_CB_Proactor.h | 22 + dep/ACE_wrappers/ace/POSIX_Proactor.cpp | 328 ++ dep/ACE_wrappers/ace/POSIX_Proactor.h | 113 + dep/ACE_wrappers/ace/POSIX_Proactor.inl | 3 + dep/ACE_wrappers/ace/Pagefile_Memory_Pool.cpp | 50 + dep/ACE_wrappers/ace/Pagefile_Memory_Pool.h | 44 + dep/ACE_wrappers/ace/Pagefile_Memory_Pool.inl | 11 + dep/ACE_wrappers/ace/Pair.h | 8 + dep/ACE_wrappers/ace/Pair_T.h | 29 + dep/ACE_wrappers/ace/Pair_T.inl | 15 + dep/ACE_wrappers/ace/Parse_Node.cpp | 156 + dep/ACE_wrappers/ace/Parse_Node.h | 101 + dep/ACE_wrappers/ace/Ping_Socket.cpp | 61 + dep/ACE_wrappers/ace/Ping_Socket.h | 36 + dep/ACE_wrappers/ace/Ping_Socket.inl | 3 + dep/ACE_wrappers/ace/Pipe.cpp | 49 + dep/ACE_wrappers/ace/Pipe.h | 39 + dep/ACE_wrappers/ace/Pipe.inl | 22 + dep/ACE_wrappers/ace/Priority_Reactor.cpp | 40 + dep/ACE_wrappers/ace/Priority_Reactor.h | 21 + dep/ACE_wrappers/ace/Proactor.cpp | 170 + dep/ACE_wrappers/ace/Proactor.h | 123 + dep/ACE_wrappers/ace/Proactor.inl | 20 + dep/ACE_wrappers/ace/Proactor_Impl.cpp | 7 + dep/ACE_wrappers/ace/Proactor_Impl.h | 41 + dep/ACE_wrappers/ace/Process.cpp | 158 + dep/ACE_wrappers/ace/Process.h | 121 + dep/ACE_wrappers/ace/Process.inl | 56 + dep/ACE_wrappers/ace/Process_Manager.cpp | 187 ++ dep/ACE_wrappers/ace/Process_Manager.h | 65 + dep/ACE_wrappers/ace/Process_Manager.inl | 3 + dep/ACE_wrappers/ace/Process_Mutex.cpp | 10 + dep/ACE_wrappers/ace/Process_Mutex.h | 32 + dep/ACE_wrappers/ace/Process_Mutex.inl | 13 + dep/ACE_wrappers/ace/Process_Semaphore.cpp | 18 + dep/ACE_wrappers/ace/Process_Semaphore.h | 27 + dep/ACE_wrappers/ace/Process_Semaphore.inl | 12 + dep/ACE_wrappers/ace/Profile_Timer.cpp | 77 + dep/ACE_wrappers/ace/Profile_Timer.h | 34 + dep/ACE_wrappers/ace/Profile_Timer.inl | 26 + dep/ACE_wrappers/ace/RB_Tree.h | 180 ++ dep/ACE_wrappers/ace/RB_Tree.inl | 218 ++ dep/ACE_wrappers/ace/RW_Mutex.cpp | 12 + dep/ACE_wrappers/ace/RW_Mutex.h | 30 + dep/ACE_wrappers/ace/RW_Mutex.inl | 12 + dep/ACE_wrappers/ace/RW_Process_Mutex.cpp | 12 + dep/ACE_wrappers/ace/RW_Process_Mutex.h | 26 + dep/ACE_wrappers/ace/RW_Process_Mutex.inl | 12 + dep/ACE_wrappers/ace/RW_Thread_Mutex.cpp | 11 + dep/ACE_wrappers/ace/RW_Thread_Mutex.h | 16 + dep/ACE_wrappers/ace/RW_Thread_Mutex.inl | 4 + dep/ACE_wrappers/ace/Reactor.cpp | 85 + dep/ACE_wrappers/ace/Reactor.h | 116 + dep/ACE_wrappers/ace/Reactor.inl | 84 + dep/ACE_wrappers/ace/Reactor_Impl.cpp | 5 + dep/ACE_wrappers/ace/Reactor_Impl.h | 95 + .../ace/Reactor_Notification_Strategy.cpp | 8 + .../ace/Reactor_Notification_Strategy.h | 16 + .../ace/Reactor_Notification_Strategy.inl | 4 + dep/ACE_wrappers/ace/Reactor_Timer_Interface.cpp | 5 + dep/ACE_wrappers/ace/Reactor_Timer_Interface.h | 17 + dep/ACE_wrappers/ace/Reactor_Token_T.h | 15 + dep/ACE_wrappers/ace/Read_Buffer.cpp | 32 + dep/ACE_wrappers/ace/Read_Buffer.h | 29 + dep/ACE_wrappers/ace/Read_Buffer.inl | 7 + dep/ACE_wrappers/ace/Recursive_Thread_Mutex.cpp | 17 + dep/ACE_wrappers/ace/Recursive_Thread_Mutex.h | 34 + dep/ACE_wrappers/ace/Recursive_Thread_Mutex.inl | 15 + dep/ACE_wrappers/ace/Recyclable.cpp | 6 + dep/ACE_wrappers/ace/Recyclable.h | 20 + dep/ACE_wrappers/ace/Recyclable.inl | 4 + dep/ACE_wrappers/ace/Refcountable.h | 8 + dep/ACE_wrappers/ace/Refcountable_T.h | 16 + dep/ACE_wrappers/ace/Refcountable_T.inl | 6 + dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.h | 45 + dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.inl | 29 + dep/ACE_wrappers/ace/Registry.cpp | 130 + dep/ACE_wrappers/ace/Registry.h | 116 + dep/ACE_wrappers/ace/Registry_Name_Space.cpp | 44 + dep/ACE_wrappers/ace/Registry_Name_Space.h | 29 + dep/ACE_wrappers/ace/Remote_Name_Space.cpp | 44 + dep/ACE_wrappers/ace/Remote_Name_Space.h | 28 + dep/ACE_wrappers/ace/Remote_Tokens.cpp | 81 + dep/ACE_wrappers/ace/Remote_Tokens.h | 56 + dep/ACE_wrappers/ace/Remote_Tokens.inl | 10 + dep/ACE_wrappers/ace/Reverse_Lock_T.h | 27 + dep/ACE_wrappers/ace/Reverse_Lock_T.inl | 4 + dep/ACE_wrappers/ace/Rtems_init.c | 43 + dep/ACE_wrappers/ace/SOCK.cpp | 29 + dep/ACE_wrappers/ace/SOCK.h | 25 + dep/ACE_wrappers/ace/SOCK.inl | 7 + dep/ACE_wrappers/ace/SOCK_Acceptor.cpp | 53 + dep/ACE_wrappers/ace/SOCK_Acceptor.h | 25 + dep/ACE_wrappers/ace/SOCK_Acceptor.inl | 3 + dep/ACE_wrappers/ace/SOCK_CODgram.cpp | 16 + dep/ACE_wrappers/ace/SOCK_CODgram.h | 17 + dep/ACE_wrappers/ace/SOCK_CODgram.inl | 4 + dep/ACE_wrappers/ace/SOCK_Connector.cpp | 37 + dep/ACE_wrappers/ace/SOCK_Connector.h | 24 + dep/ACE_wrappers/ace/SOCK_Connector.inl | 7 + dep/ACE_wrappers/ace/SOCK_Dgram.cpp | 85 + dep/ACE_wrappers/ace/SOCK_Dgram.h | 36 + dep/ACE_wrappers/ace/SOCK_Dgram.inl | 21 + dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.cpp | 64 + dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.h | 28 + dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.inl | 8 + dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.cpp | 133 + dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.h | 40 + dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.inl | 8 + dep/ACE_wrappers/ace/SOCK_IO.cpp | 26 + dep/ACE_wrappers/ace/SOCK_IO.h | 27 + dep/ACE_wrappers/ace/SOCK_IO.inl | 14 + dep/ACE_wrappers/ace/SOCK_Netlink.cpp | 22 + dep/ACE_wrappers/ace/SOCK_Netlink.h | 19 + dep/ACE_wrappers/ace/SOCK_Netlink.inl | 8 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.cpp | 75 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.h | 33 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.inl | 3 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.cpp | 56 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.h | 34 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.inl | 18 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.cpp | 54 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.h | 29 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.inl | 7 + dep/ACE_wrappers/ace/SOCK_Stream.cpp | 9 + dep/ACE_wrappers/ace/SOCK_Stream.h | 29 + dep/ACE_wrappers/ace/SOCK_Stream.inl | 18 + dep/ACE_wrappers/ace/SPIPE.cpp | 18 + dep/ACE_wrappers/ace/SPIPE.h | 19 + dep/ACE_wrappers/ace/SPIPE.inl | 3 + dep/ACE_wrappers/ace/SPIPE_Acceptor.cpp | 47 + dep/ACE_wrappers/ace/SPIPE_Acceptor.h | 22 + dep/ACE_wrappers/ace/SPIPE_Addr.cpp | 32 + dep/ACE_wrappers/ace/SPIPE_Addr.h | 33 + dep/ACE_wrappers/ace/SPIPE_Addr.inl | 13 + dep/ACE_wrappers/ace/SPIPE_Connector.cpp | 23 + dep/ACE_wrappers/ace/SPIPE_Connector.h | 15 + dep/ACE_wrappers/ace/SPIPE_Connector.inl | 3 + dep/ACE_wrappers/ace/SPIPE_Stream.cpp | 19 + dep/ACE_wrappers/ace/SPIPE_Stream.h | 36 + dep/ACE_wrappers/ace/SPIPE_Stream.inl | 31 + dep/ACE_wrappers/ace/SString.cpp | 95 + dep/ACE_wrappers/ace/SString.h | 87 + dep/ACE_wrappers/ace/SString.inl | 54 + dep/ACE_wrappers/ace/SStringfwd.h | 14 + dep/ACE_wrappers/ace/SUN_Proactor.cpp | 60 + dep/ACE_wrappers/ace/SUN_Proactor.h | 22 + dep/ACE_wrappers/ace/SV_Message.cpp | 7 + dep/ACE_wrappers/ace/SV_Message.h | 17 + dep/ACE_wrappers/ace/SV_Message.inl | 7 + dep/ACE_wrappers/ace/SV_Message_Queue.cpp | 10 + dep/ACE_wrappers/ace/SV_Message_Queue.h | 24 + dep/ACE_wrappers/ace/SV_Message_Queue.inl | 13 + dep/ACE_wrappers/ace/SV_Semaphore_Complex.cpp | 45 + dep/ACE_wrappers/ace/SV_Semaphore_Complex.h | 27 + dep/ACE_wrappers/ace/SV_Semaphore_Complex.inl | 13 + dep/ACE_wrappers/ace/SV_Semaphore_Simple.cpp | 37 + dep/ACE_wrappers/ace/SV_Semaphore_Simple.h | 37 + dep/ACE_wrappers/ace/SV_Semaphore_Simple.inl | 22 + dep/ACE_wrappers/ace/SV_Shared_Memory.cpp | 15 + dep/ACE_wrappers/ace/SV_Shared_Memory.h | 29 + dep/ACE_wrappers/ace/SV_Shared_Memory.inl | 20 + dep/ACE_wrappers/ace/Sample_History.cpp | 12 + dep/ACE_wrappers/ace/Sample_History.h | 20 + dep/ACE_wrappers/ace/Sample_History.inl | 6 + dep/ACE_wrappers/ace/Sbrk_Memory_Pool.cpp | 25 + dep/ACE_wrappers/ace/Sbrk_Memory_Pool.h | 26 + dep/ACE_wrappers/ace/Sched_Params.cpp | 27 + dep/ACE_wrappers/ace/Sched_Params.h | 35 + dep/ACE_wrappers/ace/Sched_Params.inl | 21 + dep/ACE_wrappers/ace/Select_Reactor.h | 13 + dep/ACE_wrappers/ace/Select_Reactor_Base.cpp | 178 ++ dep/ACE_wrappers/ace/Select_Reactor_Base.h | 118 + dep/ACE_wrappers/ace/Select_Reactor_Base.inl | 22 + dep/ACE_wrappers/ace/Select_Reactor_T.h | 120 + dep/ACE_wrappers/ace/Select_Reactor_T.inl | 38 + dep/ACE_wrappers/ace/Semaphore.cpp | 12 + dep/ACE_wrappers/ace/Semaphore.h | 30 + dep/ACE_wrappers/ace/Semaphore.inl | 19 + dep/ACE_wrappers/ace/Service_Config.cpp | 102 + dep/ACE_wrappers/ace/Service_Config.h | 98 + dep/ACE_wrappers/ace/Service_Config.inl | 27 + dep/ACE_wrappers/ace/Service_Gestalt.cpp | 191 ++ dep/ACE_wrappers/ace/Service_Gestalt.h | 76 + dep/ACE_wrappers/ace/Service_Gestalt.inl | 13 + dep/ACE_wrappers/ace/Service_Manager.cpp | 76 + dep/ACE_wrappers/ace/Service_Manager.h | 25 + dep/ACE_wrappers/ace/Service_Object.cpp | 32 + dep/ACE_wrappers/ace/Service_Object.h | 40 + dep/ACE_wrappers/ace/Service_Object.inl | 13 + dep/ACE_wrappers/ace/Service_Repository.cpp | 100 + dep/ACE_wrappers/ace/Service_Repository.h | 58 + dep/ACE_wrappers/ace/Service_Repository.inl | 10 + dep/ACE_wrappers/ace/Service_Templates.h | 5 + dep/ACE_wrappers/ace/Service_Types.cpp | 88 + dep/ACE_wrappers/ace/Service_Types.h | 42 + dep/ACE_wrappers/ace/Service_Types.inl | 7 + dep/ACE_wrappers/ace/Shared_Memory.cpp | 5 + dep/ACE_wrappers/ace/Shared_Memory.h | 12 + dep/ACE_wrappers/ace/Shared_Memory_MM.cpp | 22 + dep/ACE_wrappers/ace/Shared_Memory_MM.h | 24 + dep/ACE_wrappers/ace/Shared_Memory_MM.inl | 6 + dep/ACE_wrappers/ace/Shared_Memory_Pool.cpp | 75 + dep/ACE_wrappers/ace/Shared_Memory_Pool.h | 46 + dep/ACE_wrappers/ace/Shared_Memory_SV.cpp | 17 + dep/ACE_wrappers/ace/Shared_Memory_SV.h | 21 + dep/ACE_wrappers/ace/Shared_Memory_SV.inl | 6 + dep/ACE_wrappers/ace/Shared_Object.cpp | 14 + dep/ACE_wrappers/ace/Shared_Object.h | 17 + dep/ACE_wrappers/ace/Shared_Object.inl | 3 + dep/ACE_wrappers/ace/Sig_Adapter.cpp | 13 + dep/ACE_wrappers/ace/Sig_Adapter.h | 18 + dep/ACE_wrappers/ace/Sig_Handler.cpp | 108 + dep/ACE_wrappers/ace/Sig_Handler.h | 38 + dep/ACE_wrappers/ace/Sig_Handler.inl | 2 + dep/ACE_wrappers/ace/Signal.cpp | 38 + dep/ACE_wrappers/ace/Signal.h | 57 + dep/ACE_wrappers/ace/Signal.inl | 36 + dep/ACE_wrappers/ace/Singleton.h | 50 + dep/ACE_wrappers/ace/Singleton.inl | 9 + dep/ACE_wrappers/ace/Sock_Connect.cpp | 220 ++ dep/ACE_wrappers/ace/Sock_Connect.h | 20 + dep/ACE_wrappers/ace/Stack_Trace.cpp | 112 + dep/ACE_wrappers/ace/Stack_Trace.h | 13 + dep/ACE_wrappers/ace/Static_Object_Lock.h | 19 + dep/ACE_wrappers/ace/Stats.cpp | 55 + dep/ACE_wrappers/ace/Stats.h | 44 + dep/ACE_wrappers/ace/Stats.inl | 15 + dep/ACE_wrappers/ace/Strategies.h | 6 + dep/ACE_wrappers/ace/Strategies_T.h | 210 ++ dep/ACE_wrappers/ace/Strategies_T.inl | 28 + dep/ACE_wrappers/ace/Stream.h | 52 + dep/ACE_wrappers/ace/Stream.inl | 8 + dep/ACE_wrappers/ace/Stream_Modules.h | 29 + dep/ACE_wrappers/ace/String_Base.h | 72 + dep/ACE_wrappers/ace/String_Base.inl | 27 + dep/ACE_wrappers/ace/String_Base_Const.cpp | 4 + dep/ACE_wrappers/ace/String_Base_Const.h | 12 + dep/ACE_wrappers/ace/Svc_Conf.h | 25 + dep/ACE_wrappers/ace/Svc_Conf_Lexer.cpp | 58 + dep/ACE_wrappers/ace/Svc_Conf_Lexer.h | 13 + dep/ACE_wrappers/ace/Svc_Conf_Param.h | 31 + dep/ACE_wrappers/ace/Svc_Conf_Token_Table.h | 11 + dep/ACE_wrappers/ace/Svc_Conf_Tokens.h | 6 + dep/ACE_wrappers/ace/Svc_Conf_y.cpp | 309 ++ dep/ACE_wrappers/ace/Svc_Handler.h | 65 + dep/ACE_wrappers/ace/Synch.h | 11 + dep/ACE_wrappers/ace/Synch_Options.cpp | 21 + dep/ACE_wrappers/ace/Synch_Options.h | 29 + dep/ACE_wrappers/ace/Synch_T.h | 9 + dep/ACE_wrappers/ace/Synch_Traits.h | 24 + dep/ACE_wrappers/ace/System_Time.cpp | 21 + dep/ACE_wrappers/ace/System_Time.h | 22 + dep/ACE_wrappers/ace/TLI.cpp | 37 + dep/ACE_wrappers/ace/TLI.h | 25 + dep/ACE_wrappers/ace/TLI.inl | 8 + dep/ACE_wrappers/ace/TLI_Acceptor.cpp | 77 + dep/ACE_wrappers/ace/TLI_Acceptor.h | 26 + dep/ACE_wrappers/ace/TLI_Connector.cpp | 39 + dep/ACE_wrappers/ace/TLI_Connector.h | 17 + dep/ACE_wrappers/ace/TLI_Connector.inl | 4 + dep/ACE_wrappers/ace/TLI_Stream.cpp | 38 + dep/ACE_wrappers/ace/TLI_Stream.h | 32 + dep/ACE_wrappers/ace/TLI_Stream.inl | 5 + dep/ACE_wrappers/ace/TP_Reactor.cpp | 131 + dep/ACE_wrappers/ace/TP_Reactor.h | 57 + dep/ACE_wrappers/ace/TP_Reactor.inl | 18 + dep/ACE_wrappers/ace/TSS_Adapter.cpp | 7 + dep/ACE_wrappers/ace/TSS_Adapter.h | 12 + dep/ACE_wrappers/ace/TSS_T.h | 33 + dep/ACE_wrappers/ace/TSS_T.inl | 11 +- dep/ACE_wrappers/ace/TTY_IO.cpp | 55 + dep/ACE_wrappers/ace/TTY_IO.h | 12 + dep/ACE_wrappers/ace/Task.cpp | 46 + dep/ACE_wrappers/ace/Task.h | 44 + dep/ACE_wrappers/ace/Task.inl | 13 + dep/ACE_wrappers/ace/Task_Ex_T.h | 42 + dep/ACE_wrappers/ace/Task_Ex_T.inl | 15 + dep/ACE_wrappers/ace/Task_T.h | 43 + dep/ACE_wrappers/ace/Task_T.inl | 15 + dep/ACE_wrappers/ace/Test_and_Set.h | 15 + dep/ACE_wrappers/ace/Thread.cpp | 15 + dep/ACE_wrappers/ace/Thread.h | 41 + dep/ACE_wrappers/ace/Thread.inl | 45 + dep/ACE_wrappers/ace/Thread_Adapter.cpp | 34 + dep/ACE_wrappers/ace/Thread_Adapter.h | 20 + dep/ACE_wrappers/ace/Thread_Adapter.inl | 3 + dep/ACE_wrappers/ace/Thread_Control.cpp | 19 + dep/ACE_wrappers/ace/Thread_Control.h | 21 + dep/ACE_wrappers/ace/Thread_Control.inl | 10 + dep/ACE_wrappers/ace/Thread_Exit.cpp | 29 + dep/ACE_wrappers/ace/Thread_Exit.h | 22 + dep/ACE_wrappers/ace/Thread_Hook.cpp | 8 + dep/ACE_wrappers/ace/Thread_Hook.h | 14 + dep/ACE_wrappers/ace/Thread_Manager.cpp | 355 ++ dep/ACE_wrappers/ace/Thread_Manager.h | 181 ++ dep/ACE_wrappers/ace/Thread_Manager.inl | 44 + dep/ACE_wrappers/ace/Thread_Mutex.cpp | 14 + dep/ACE_wrappers/ace/Thread_Mutex.h | 30 + dep/ACE_wrappers/ace/Thread_Mutex.inl | 14 + dep/ACE_wrappers/ace/Thread_Semaphore.cpp | 13 + dep/ACE_wrappers/ace/Thread_Semaphore.h | 18 + dep/ACE_wrappers/ace/Thread_Semaphore.inl | 3 + dep/ACE_wrappers/ace/Throughput_Stats.cpp | 29 + dep/ACE_wrappers/ace/Throughput_Stats.h | 16 + dep/ACE_wrappers/ace/Time_Value.cpp | 40 + dep/ACE_wrappers/ace/Time_Value.h | 74 + dep/ACE_wrappers/ace/Time_Value.inl | 69 + dep/ACE_wrappers/ace/Timeprobe.cpp | 6 + dep/ACE_wrappers/ace/Timeprobe.h | 40 + dep/ACE_wrappers/ace/Timeprobe.inl | 3 + dep/ACE_wrappers/ace/Timeprobe_T.h | 50 + dep/ACE_wrappers/ace/Timer_Hash.h | 17 + dep/ACE_wrappers/ace/Timer_Hash_T.h | 63 + dep/ACE_wrappers/ace/Timer_Heap.h | 10 + dep/ACE_wrappers/ace/Timer_Heap_T.h | 59 + dep/ACE_wrappers/ace/Timer_List.h | 10 + dep/ACE_wrappers/ace/Timer_List_T.h | 43 + dep/ACE_wrappers/ace/Timer_Queue.h | 13 + dep/ACE_wrappers/ace/Timer_Queue_Adapters.h | 52 + dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl | 5 + dep/ACE_wrappers/ace/Timer_Queue_T.h | 107 + dep/ACE_wrappers/ace/Timer_Queue_T.inl | 30 + dep/ACE_wrappers/ace/Timer_Queuefwd.h | 11 + dep/ACE_wrappers/ace/Timer_Wheel.h | 10 + dep/ACE_wrappers/ace/Timer_Wheel_T.h | 41 + dep/ACE_wrappers/ace/Token.cpp | 96 + dep/ACE_wrappers/ace/Token.h | 81 + dep/ACE_wrappers/ace/Token.inl | 30 + dep/ACE_wrappers/ace/Token_Collection.cpp | 45 + dep/ACE_wrappers/ace/Token_Collection.h | 39 + dep/ACE_wrappers/ace/Token_Collection.inl | 5 + dep/ACE_wrappers/ace/Token_Invariants.cpp | 61 + dep/ACE_wrappers/ace/Token_Invariants.h | 55 + dep/ACE_wrappers/ace/Token_Manager.cpp | 44 + dep/ACE_wrappers/ace/Token_Manager.h | 32 + dep/ACE_wrappers/ace/Token_Manager.inl | 6 + dep/ACE_wrappers/ace/Token_Request_Reply.cpp | 34 + dep/ACE_wrappers/ace/Token_Request_Reply.h | 63 + dep/ACE_wrappers/ace/Token_Request_Reply.inl | 35 + dep/ACE_wrappers/ace/Trace.cpp | 27 + dep/ACE_wrappers/ace/Trace.h | 23 + dep/ACE_wrappers/ace/Truncate.h | 128 + dep/ACE_wrappers/ace/Typed_SV_Message.h | 27 + dep/ACE_wrappers/ace/Typed_SV_Message.inl | 14 + dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h | 20 + dep/ACE_wrappers/ace/Typed_SV_Message_Queue.inl | 15 + dep/ACE_wrappers/ace/UNIX_Addr.cpp | 32 + dep/ACE_wrappers/ace/UNIX_Addr.h | 33 + dep/ACE_wrappers/ace/UNIX_Addr.inl | 13 + dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp | 28 + dep/ACE_wrappers/ace/UPIPE_Acceptor.h | 23 + dep/ACE_wrappers/ace/UPIPE_Acceptor.inl | 3 + dep/ACE_wrappers/ace/UPIPE_Addr.h | 10 + dep/ACE_wrappers/ace/UPIPE_Connector.cpp | 20 + dep/ACE_wrappers/ace/UPIPE_Connector.h | 18 + dep/ACE_wrappers/ace/UPIPE_Connector.inl | 4 + dep/ACE_wrappers/ace/UPIPE_Stream.cpp | 42 + dep/ACE_wrappers/ace/UPIPE_Stream.h | 35 + dep/ACE_wrappers/ace/UPIPE_Stream.inl | 3 + dep/ACE_wrappers/ace/UTF16_Encoding_Converter.cpp | 37 + dep/ACE_wrappers/ace/UTF16_Encoding_Converter.h | 18 + dep/ACE_wrappers/ace/UTF16_Encoding_Converter.inl | 10 + dep/ACE_wrappers/ace/UTF32_Encoding_Converter.cpp | 28 + dep/ACE_wrappers/ace/UTF32_Encoding_Converter.h | 13 + dep/ACE_wrappers/ace/UTF8_Encoding_Converter.cpp | 12 + dep/ACE_wrappers/ace/UTF8_Encoding_Converter.h | 14 + dep/ACE_wrappers/ace/UUID.cpp | 71 + dep/ACE_wrappers/ace/UUID.h | 58 + dep/ACE_wrappers/ace/UUID.inl | 28 + dep/ACE_wrappers/ace/Unbounded_Queue.h | 59 + dep/ACE_wrappers/ace/Unbounded_Queue.inl | 5 + dep/ACE_wrappers/ace/Unbounded_Set.h | 21 + dep/ACE_wrappers/ace/Unbounded_Set.inl | 11 +- dep/ACE_wrappers/ace/Unbounded_Set_Ex.h | 72 + dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl | 5 + dep/ACE_wrappers/ace/Value_Ptr.h | 33 + dep/ACE_wrappers/ace/Vector_T.h | 45 + dep/ACE_wrappers/ace/Vector_T.inl | 19 + dep/ACE_wrappers/ace/Version.h | 1 + dep/ACE_wrappers/ace/Versioned_Namespace.h | 11 + dep/ACE_wrappers/ace/WFMO_Reactor.cpp | 386 +++ dep/ACE_wrappers/ace/WFMO_Reactor.h | 240 ++ dep/ACE_wrappers/ace/WFMO_Reactor.inl | 193 ++ dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp | 579 ++++ dep/ACE_wrappers/ace/WIN32_Asynch_IO.h | 355 ++ dep/ACE_wrappers/ace/WIN32_Proactor.cpp | 88 + dep/ACE_wrappers/ace/WIN32_Proactor.h | 52 + dep/ACE_wrappers/ace/XML_Svc_Conf.cpp | 6 + dep/ACE_wrappers/ace/XML_Svc_Conf.h | 16 + dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp | 15 + dep/ACE_wrappers/ace/XTI_ATM_Mcast.h | 19 + dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl | 5 + dep/ACE_wrappers/ace/ace.rc | 2 + dep/ACE_wrappers/ace/ace_wchar.cpp | 5 + dep/ACE_wrappers/ace/ace_wchar.h | 49 + dep/ACE_wrappers/ace/ace_wchar.inl | 25 + dep/ACE_wrappers/ace/checked_iterator.h | 5 + dep/ACE_wrappers/ace/config-WinCE.h | 48 + dep/ACE_wrappers/ace/config-aix-5.x.h | 68 + dep/ACE_wrappers/ace/config-all.h | 17 + dep/ACE_wrappers/ace/config-borland-common.h | 8 + dep/ACE_wrappers/ace/config-cray.h | 67 + dep/ACE_wrappers/ace/config-cxx-common.h | 13 + dep/ACE_wrappers/ace/config-cygwin32.h | 51 + dep/ACE_wrappers/ace/config-doxygen.h | 27 + dep/ACE_wrappers/ace/config-freebsd.h | 67 + dep/ACE_wrappers/ace/config-g++-common.h | 20 + dep/ACE_wrappers/ace/config-ghs-common.h | 9 + dep/ACE_wrappers/ace/config-hpux-11.00.h | 102 + dep/ACE_wrappers/ace/config-icc-common.h | 16 + dep/ACE_wrappers/ace/config-integritySCA.h | 33 + dep/ACE_wrappers/ace/config-irix6.5.x-sgic++.h | 5 + dep/ACE_wrappers/ace/config-irix6.x-common.h | 67 + dep/ACE_wrappers/ace/config-irix6.x-g++.h | 6 + dep/ACE_wrappers/ace/config-irix6.x-sgic++.h | 8 + dep/ACE_wrappers/ace/config-linux-common.h | 86 + dep/ACE_wrappers/ace/config-linux.h | 18 + dep/ACE_wrappers/ace/config-lite.h | 25 + dep/ACE_wrappers/ace/config-lynxos.h | 18 + dep/ACE_wrappers/ace/config-macosx-leopard.h | 60 + dep/ACE_wrappers/ace/config-macosx-panther.h | 53 + dep/ACE_wrappers/ace/config-macosx-tiger.h | 58 + dep/ACE_wrappers/ace/config-macosx.h | 54 + dep/ACE_wrappers/ace/config-macros.h | 85 + dep/ACE_wrappers/ace/config-minimal.h | 9 + dep/ACE_wrappers/ace/config-mvs.h | 16 + dep/ACE_wrappers/ace/config-netbsd.h | 14 + dep/ACE_wrappers/ace/config-openbsd.h | 65 + dep/ACE_wrappers/ace/config-openvms.h | 28 + dep/ACE_wrappers/ace/config-pharlap.h | 15 + dep/ACE_wrappers/ace/config-posix-nonetworking.h | 8 + dep/ACE_wrappers/ace/config-posix.h | 11 + dep/ACE_wrappers/ace/config-qnx-neutrino.h | 9 + dep/ACE_wrappers/ace/config-qnx-rtp-62x.h | 7 + dep/ACE_wrappers/ace/config-qnx-rtp-common.h | 8 + dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h | 13 + dep/ACE_wrappers/ace/config-qnx-rtp.h | 2 + dep/ACE_wrappers/ace/config-rtems.h | 19 + dep/ACE_wrappers/ace/config-sco-5.0.0-nothread.h | 4 + dep/ACE_wrappers/ace/config-sco-5.0.0.h | 26 + dep/ACE_wrappers/ace/config-suncc-common.h | 9 + dep/ACE_wrappers/ace/config-sunos5.10.h | 13 + dep/ACE_wrappers/ace/config-sunos5.11.h | 5 + dep/ACE_wrappers/ace/config-sunos5.4-g++.h | 55 + dep/ACE_wrappers/ace/config-sunos5.4-sunc++-4.x.h | 59 + dep/ACE_wrappers/ace/config-sunos5.5.h | 91 + dep/ACE_wrappers/ace/config-sunos5.6.h | 19 + dep/ACE_wrappers/ace/config-sunos5.7.h | 21 + dep/ACE_wrappers/ace/config-sunos5.8.h | 11 + dep/ACE_wrappers/ace/config-sunos5.9.h | 6 + dep/ACE_wrappers/ace/config-tandem-nsk-mips-v2.h | 107 + dep/ACE_wrappers/ace/config-tandem-nsk-mips-v3.h | 125 + dep/ACE_wrappers/ace/config-tandem.h | 45 + dep/ACE_wrappers/ace/config-tru64.h | 22 + dep/ACE_wrappers/ace/config-unixware-7.1.0.h | 120 + dep/ACE_wrappers/ace/config-unixware-7.1.0.udk.h | 130 + dep/ACE_wrappers/ace/config-visualage.h | 4 + dep/ACE_wrappers/ace/config-vxworks.h | 6 + dep/ACE_wrappers/ace/config-vxworks5.x.h | 36 + dep/ACE_wrappers/ace/config-vxworks6.2.h | 29 + dep/ACE_wrappers/ace/config-vxworks6.3.h | 25 + dep/ACE_wrappers/ace/config-vxworks6.4.h | 26 + dep/ACE_wrappers/ace/config-vxworks6.5.h | 7 + dep/ACE_wrappers/ace/config-vxworks6.6.h | 8 + dep/ACE_wrappers/ace/config-win32-borland.h | 22 + dep/ACE_wrappers/ace/config-win32-common.h | 97 + dep/ACE_wrappers/ace/config-win32-dmc.h | 15 + dep/ACE_wrappers/ace/config-win32-ghs.h | 15 + dep/ACE_wrappers/ace/config-win32-interix.h | 14 + dep/ACE_wrappers/ace/config-win32-mingw.h | 17 + dep/ACE_wrappers/ace/config-win32-msvc-7.h | 29 + dep/ACE_wrappers/ace/config-win32-msvc-8.h | 32 + dep/ACE_wrappers/ace/config-win32-msvc-9.h | 32 + dep/ACE_wrappers/ace/config-win32-msvc.h | 19 + dep/ACE_wrappers/ace/config-win32.h | 16 + dep/ACE_wrappers/ace/gethrtime.cpp | 10 + dep/ACE_wrappers/ace/iosfwd.h | 18 + dep/ACE_wrappers/ace/os_include/arpa/os_inet.h | 14 + dep/ACE_wrappers/ace/os_include/net/os_if.h | 16 + dep/ACE_wrappers/ace/os_include/netinet/os_in.h | 33 + dep/ACE_wrappers/ace/os_include/netinet/os_tcp.h | 10 + dep/ACE_wrappers/ace/os_include/os_aio.h | 11 + dep/ACE_wrappers/ace/os_include/os_assert.h | 10 + dep/ACE_wrappers/ace/os_include/os_byteswap.h | 9 + dep/ACE_wrappers/ace/os_include/os_complex.h | 9 + dep/ACE_wrappers/ace/os_include/os_cpio.h | 9 + dep/ACE_wrappers/ace/os_include/os_ctype.h | 10 + dep/ACE_wrappers/ace/os_include/os_dirent.h | 22 + dep/ACE_wrappers/ace/os_include/os_dlfcn.h | 16 + dep/ACE_wrappers/ace/os_include/os_errno.h | 26 + dep/ACE_wrappers/ace/os_include/os_fcntl.h | 18 + dep/ACE_wrappers/ace/os_include/os_fenv.h | 9 + dep/ACE_wrappers/ace/os_include/os_float.h | 9 + dep/ACE_wrappers/ace/os_include/os_fmtmsg.h | 9 + dep/ACE_wrappers/ace/os_include/os_fnmatch.h | 9 + dep/ACE_wrappers/ace/os_include/os_ftw.h | 10 + dep/ACE_wrappers/ace/os_include/os_glob.h | 9 + dep/ACE_wrappers/ace/os_include/os_grp.h | 10 + dep/ACE_wrappers/ace/os_include/os_iconv.h | 10 + dep/ACE_wrappers/ace/os_include/os_intrin.h | 12 + dep/ACE_wrappers/ace/os_include/os_inttypes.h | 11 + dep/ACE_wrappers/ace/os_include/os_iso646.h | 9 + dep/ACE_wrappers/ace/os_include/os_kstat.h | 10 + dep/ACE_wrappers/ace/os_include/os_langinfo.h | 10 + dep/ACE_wrappers/ace/os_include/os_libgen.h | 9 + dep/ACE_wrappers/ace/os_include/os_local.h | 10 + dep/ACE_wrappers/ace/os_include/os_math.h | 10 + dep/ACE_wrappers/ace/os_include/os_monetary.h | 10 + dep/ACE_wrappers/ace/os_include/os_mqueue.h | 10 + dep/ACE_wrappers/ace/os_include/os_ndbm.h | 10 + dep/ACE_wrappers/ace/os_include/os_netdb.h | 16 + dep/ACE_wrappers/ace/os_include/os_nl_types.h | 9 + dep/ACE_wrappers/ace/os_include/os_pdh.h | 10 + dep/ACE_wrappers/ace/os_include/os_pdhmsg.h | 9 + dep/ACE_wrappers/ace/os_include/os_poll.h | 9 + dep/ACE_wrappers/ace/os_include/os_pthread.h | 49 + dep/ACE_wrappers/ace/os_include/os_pwd.h | 12 + dep/ACE_wrappers/ace/os_include/os_regex.h | 11 + dep/ACE_wrappers/ace/os_include/os_sched.h | 11 + dep/ACE_wrappers/ace/os_include/os_search.h | 10 + dep/ACE_wrappers/ace/os_include/os_semaphore.h | 16 + dep/ACE_wrappers/ace/os_include/os_setjmp.h | 9 + dep/ACE_wrappers/ace/os_include/os_signal.h | 41 + dep/ACE_wrappers/ace/os_include/os_spawn.h | 10 + dep/ACE_wrappers/ace/os_include/os_stdarg.h | 10 + dep/ACE_wrappers/ace/os_include/os_stdbool.h | 9 + dep/ACE_wrappers/ace/os_include/os_stddef.h | 15 + dep/ACE_wrappers/ace/os_include/os_stdint.h | 26 + dep/ACE_wrappers/ace/os_include/os_stdio.h | 14 + dep/ACE_wrappers/ace/os_include/os_stdlib.h | 17 + dep/ACE_wrappers/ace/os_include/os_string.h | 14 + dep/ACE_wrappers/ace/os_include/os_strings.h | 12 + dep/ACE_wrappers/ace/os_include/os_stropts.h | 22 + dep/ACE_wrappers/ace/os_include/os_syslog.h | 9 + dep/ACE_wrappers/ace/os_include/os_tar.h | 9 + dep/ACE_wrappers/ace/os_include/os_termios.h | 10 + dep/ACE_wrappers/ace/os_include/os_tgmath.h | 10 + dep/ACE_wrappers/ace/os_include/os_time.h | 19 + dep/ACE_wrappers/ace/os_include/os_trace.h | 10 + dep/ACE_wrappers/ace/os_include/os_ucontext.h | 11 + dep/ACE_wrappers/ace/os_include/os_ulimit.h | 9 + dep/ACE_wrappers/ace/os_include/os_unistd.h | 34 + dep/ACE_wrappers/ace/os_include/os_utime.h | 10 + dep/ACE_wrappers/ace/os_include/os_utmpx.h | 10 + dep/ACE_wrappers/ace/os_include/os_wchar.h | 10 + dep/ACE_wrappers/ace/os_include/os_wctype.h | 10 + dep/ACE_wrappers/ace/os_include/os_wordexp.h | 10 + dep/ACE_wrappers/ace/os_include/sys/os_ipc.h | 17 + dep/ACE_wrappers/ace/os_include/sys/os_loadavg.h | 9 + dep/ACE_wrappers/ace/os_include/sys/os_mman.h | 20 + dep/ACE_wrappers/ace/os_include/sys/os_msg.h | 12 + dep/ACE_wrappers/ace/os_include/sys/os_pstat.h | 9 + dep/ACE_wrappers/ace/os_include/sys/os_resource.h | 19 + dep/ACE_wrappers/ace/os_include/sys/os_select.h | 12 + dep/ACE_wrappers/ace/os_include/sys/os_sem.h | 19 + dep/ACE_wrappers/ace/os_include/sys/os_shm.h | 11 + dep/ACE_wrappers/ace/os_include/sys/os_socket.h | 60 + dep/ACE_wrappers/ace/os_include/sys/os_stat.h | 28 + dep/ACE_wrappers/ace/os_include/sys/os_statvfs.h | 9 + dep/ACE_wrappers/ace/os_include/sys/os_sysctl.h | 9 + dep/ACE_wrappers/ace/os_include/sys/os_sysinfo.h | 9 + dep/ACE_wrappers/ace/os_include/sys/os_time.h | 12 + dep/ACE_wrappers/ace/os_include/sys/os_timeb.h | 11 + dep/ACE_wrappers/ace/os_include/sys/os_times.h | 10 + dep/ACE_wrappers/ace/os_include/sys/os_types.h | 28 + dep/ACE_wrappers/ace/os_include/sys/os_uio.h | 16 + dep/ACE_wrappers/ace/os_include/sys/os_un.h | 11 + dep/ACE_wrappers/ace/os_include/sys/os_utsname.h | 9 + dep/ACE_wrappers/ace/os_include/sys/os_wait.h | 20 + dep/ACE_wrappers/ace/post.h | 2 + dep/ACE_wrappers/ace/pre.h | 2 + dep/ACE_wrappers/ace/streams.h | 25 + dep/ACE_wrappers/ace/svc_export.h | 8 + dep/include/g3dlite/G3D/AABox.h | 50 + dep/include/g3dlite/G3D/Array.h | 176 + dep/include/g3dlite/G3D/Box.h | 49 + dep/include/g3dlite/G3D/CollisionDetection.h | 182 ++ dep/include/g3dlite/G3D/CoordinateFrame.h | 78 + dep/include/g3dlite/G3D/Crypto.h | 13 + dep/include/g3dlite/G3D/GCamera.h | 48 + dep/include/g3dlite/G3D/Line.h | 22 + dep/include/g3dlite/G3D/Matrix3.h | 60 + dep/include/g3dlite/G3D/Plane.h | 32 + dep/include/g3dlite/G3D/Quat.h | 75 + dep/include/g3dlite/G3D/Quat.inl | 12 +- dep/include/g3dlite/G3D/Ray.h | 67 + dep/include/g3dlite/G3D/RegistryUtil.h | 24 + dep/include/g3dlite/G3D/Sphere.h | 29 + dep/include/g3dlite/G3D/System.h | 30 + dep/include/g3dlite/G3D/Table.h | 113 + dep/include/g3dlite/G3D/Triangle.h | 32 + dep/include/g3dlite/G3D/Vector2.h | 95 + dep/include/g3dlite/G3D/Vector2.inl | 7 +- dep/include/g3dlite/G3D/Vector2int16.h | 17 + dep/include/g3dlite/G3D/Vector3.h | 81 + dep/include/g3dlite/G3D/Vector3.inl | 53 +- dep/include/g3dlite/G3D/Vector3int16.h | 11 + dep/include/g3dlite/G3D/Vector4.h | 46 + dep/include/g3dlite/G3D/Vector4.inl | 43 +- dep/include/g3dlite/G3D/debug.h | 3 + dep/include/g3dlite/G3D/format.h | 11 + dep/include/g3dlite/G3D/g3dmath.h | 108 + dep/include/g3dlite/G3D/g3dmath.inl | 55 + dep/include/g3dlite/G3D/platform.h | 51 + dep/include/g3dlite/G3D/stringutils.h | 26 + dep/include/mersennetwister/MersenneTwister.h | 51 + dep/include/sockets/Base64.h | 17 + dep/include/sockets/Exception.h | 16 + dep/include/sockets/File.h | 19 + dep/include/sockets/IFile.h | 17 + dep/include/sockets/ISocketHandler.h | 32 + dep/include/sockets/Ipv4Address.h | 17 + dep/include/sockets/Ipv6Address.h | 18 + dep/include/sockets/ListenSocket.h | 30 + dep/include/sockets/Lock.h | 12 + dep/include/sockets/Mutex.h | 11 + dep/include/sockets/Parse.h | 16 + dep/include/sockets/ResolvServer.h | 15 + dep/include/sockets/ResolvSocket.h | 19 + dep/include/sockets/SctpSocket.h | 22 + dep/include/sockets/Socket.h | 95 + dep/include/sockets/SocketAddress.h | 20 + dep/include/sockets/SocketHandler.h | 40 + dep/include/sockets/StdLog.h | 14 + dep/include/sockets/StdoutLog.h | 12 + dep/include/sockets/StreamSocket.h | 32 + dep/include/sockets/TcpSocket.h | 43 + dep/include/sockets/Thread.h | 16 + dep/include/sockets/UdpSocket.h | 25 + dep/include/sockets/Utility.h | 29 + dep/include/sockets/socket_include.h | 60 +- dep/include/sockets/sockets-config.h | 19 + dep/src/g3dlite/AABox.cpp | 58 + dep/src/g3dlite/Box.cpp | 83 +- dep/src/g3dlite/Crypto.cpp | 17 + dep/src/g3dlite/Matrix3.cpp | 295 ++ dep/src/g3dlite/Plane.cpp | 23 + dep/src/g3dlite/System.cpp | 135 + dep/src/g3dlite/Triangle.cpp | 28 + dep/src/g3dlite/Vector3.cpp | 75 + dep/src/g3dlite/Vector4.cpp | 22 + dep/src/g3dlite/format.cpp | 46 + dep/src/sockets/Base64.cpp | 23 + dep/src/sockets/Exception.cpp | 9 + dep/src/sockets/Ipv4Address.cpp | 27 + dep/src/sockets/Ipv6Address.cpp | 30 + dep/src/sockets/Lock.cpp | 11 + dep/src/sockets/Mutex.cpp | 12 + dep/src/sockets/Parse.cpp | 36 + dep/src/sockets/ResolvServer.cpp | 16 + dep/src/sockets/ResolvSocket.cpp | 21 + dep/src/sockets/Socket.cpp | 186 ++ dep/src/sockets/SocketHandler.cpp | 59 + dep/src/sockets/StdoutLog.cpp | 14 + dep/src/sockets/StreamSocket.cpp | 26 + dep/src/sockets/TcpSocket.cpp | 91 + dep/src/sockets/Thread.cpp | 21 + dep/src/sockets/UdpSocket.cpp | 59 + dep/src/sockets/Utility.cpp | 50 + dep/src/sockets/socket_include.cpp | 9 + dep/src/zlib/adler32.c | 15 + dep/src/zlib/compress.c | 11 + dep/src/zlib/crc32.c | 56 + dep/src/zlib/crc32.h | 1 + dep/src/zlib/deflate.c | 186 ++ dep/src/zlib/deflate.h | 59 + dep/src/zlib/example.c | 98 + dep/src/zlib/gzio.c | 124 + dep/src/zlib/infback.c | 50 + dep/src/zlib/inffast.c | 17 + dep/src/zlib/inffast.h | 2 + dep/src/zlib/inffixed.h | 3 + dep/src/zlib/inflate.c | 81 + dep/src/zlib/inflate.h | 7 + dep/src/zlib/inftrees.c | 34 + dep/src/zlib/inftrees.h | 6 + dep/src/zlib/trees.c | 149 + dep/src/zlib/trees.h | 7 + dep/src/zlib/uncompr.c | 10 + dep/src/zlib/zconf.h | 29 + dep/src/zlib/zlib.h | 206 ++ dep/src/zlib/zutil.c | 43 + dep/src/zlib/zutil.h | 38 + src/bindings/scripts/ScriptMgr.cpp | 113 +- src/bindings/scripts/ScriptMgr.h | 13 + src/bindings/scripts/base/escort_ai.cpp | 88 +- src/bindings/scripts/base/escort_ai.h | 29 + src/bindings/scripts/base/follower_ai.cpp | 69 +- src/bindings/scripts/base/follower_ai.h | 21 + src/bindings/scripts/base/guard_ai.cpp | 31 + src/bindings/scripts/base/guard_ai.h | 13 + src/bindings/scripts/base/simple_ai.cpp | 42 + src/bindings/scripts/base/simple_ai.h | 17 + src/bindings/scripts/include/precompiled.cpp | 1 + src/bindings/scripts/include/precompiled.h | 4 + src/bindings/scripts/include/sc_creature.cpp | 147 +- src/bindings/scripts/include/sc_creature.h | 63 + src/bindings/scripts/include/sc_gossip.h | 24 + src/bindings/scripts/include/sc_instance.h | 5 + .../scripts/scripts/custom/npc_acherus_taxi.cpp | 11 +- .../scripts/custom/npc_wyrmresttempel_taxi.cpp | 26 + src/bindings/scripts/scripts/custom/on_events.cpp | 22 + .../scripts/eastern_kingdoms/alterac_mountains.cpp | 4 + .../scripts/eastern_kingdoms/arathi_highlands.cpp | 18 + .../blackrock_depths/blackrock_depths.cpp | 156 +- .../blackrock_depths/boss_ambassador_flamelash.cpp | 14 + .../blackrock_depths/boss_anubshiah.cpp | 15 + .../boss_emperor_dagran_thaurissan.cpp | 16 + .../blackrock_depths/boss_general_angerforge.cpp | 18 + .../blackrock_depths/boss_gorosh_the_dervish.cpp | 12 + .../blackrock_depths/boss_grizzle.cpp | 14 + .../boss_high_interrogator_gerstahn.cpp | 14 + .../blackrock_depths/boss_magmus.cpp | 12 + .../blackrock_depths/boss_moira_bronzebeard.cpp | 13 + .../blackrock_depths/boss_tomb_of_seven.cpp | 34 + .../blackrock_depths/def_blackrock_depths.h | 7 + .../blackrock_depths/instance_blackrock_depths.cpp | 48 +- .../blackrock_spire/boss_drakkisath.cpp | 14 + .../eastern_kingdoms/blackrock_spire/boss_gyth.cpp | 24 + .../blackrock_spire/boss_halycon.cpp | 14 + .../blackrock_spire/boss_highlord_omokk.cpp | 17 + .../blackrock_spire/boss_mother_smolderweb.cpp | 13 + .../blackrock_spire/boss_overlord_wyrmthalak.cpp | 18 + .../blackrock_spire/boss_pyroguard_emberseer.cpp | 13 + .../blackrock_spire/boss_quartermaster_zigris.cpp | 12 + .../blackrock_spire/boss_rend_blackhand.cpp | 13 + .../boss_shadow_hunter_voshgajin.cpp | 14 + .../blackrock_spire/boss_the_beast.cpp | 13 + .../blackrock_spire/boss_warmaster_voone.cpp | 16 + .../blackwing_lair/boss_broodlord_lashlayer.cpp | 17 + .../blackwing_lair/boss_chromaggus.cpp | 42 +- .../blackwing_lair/boss_ebonroc.cpp | 14 + .../blackwing_lair/boss_firemaw.cpp | 14 + .../blackwing_lair/boss_flamegor.cpp | 15 + .../blackwing_lair/boss_nefarian.cpp | 30 + .../blackwing_lair/boss_razorgore.cpp | 21 + .../blackwing_lair/boss_vaelastrasz.cpp | 36 + .../blackwing_lair/boss_victor_nefarius.cpp | 47 + .../blackwing_lair/instance_blackwing_lair.cpp | 2 + .../scripts/eastern_kingdoms/blasted_lands.cpp | 25 + .../scripts/eastern_kingdoms/boss_kruul.cpp | 25 + .../scripts/eastern_kingdoms/burning_steppes.cpp | 17 + .../eastern_kingdoms/deadmines/deadmines.cpp | 29 + .../eastern_kingdoms/deadmines/def_deadmines.h | 3 + .../scripts/eastern_kingdoms/dun_morogh.cpp | 15 + .../scripts/scripts/eastern_kingdoms/duskwood.cpp | 15 + .../eastern_kingdoms/eastern_plaguelands.cpp | 33 + .../scripts/eastern_kingdoms/elwynn_forest.cpp | 15 + .../scripts/eastern_kingdoms/eversong_woods.cpp | 135 +- .../scripts/eastern_kingdoms/ghostlands.cpp | 40 + .../scripts/eastern_kingdoms/hinterlands.cpp | 57 +- .../scripts/scripts/eastern_kingdoms/ironforge.cpp | 11 + .../scripts/eastern_kingdoms/isle_of_queldanas.cpp | 25 + .../eastern_kingdoms/karazhan/boss_curator.cpp | 32 + .../karazhan/boss_maiden_of_virtue.cpp | 26 + .../eastern_kingdoms/karazhan/boss_midnight.cpp | 41 +- .../eastern_kingdoms/karazhan/boss_moroes.cpp | 164 +- .../eastern_kingdoms/karazhan/boss_netherspite.cpp | 54 +- .../eastern_kingdoms/karazhan/boss_nightbane.cpp | 66 + .../karazhan/boss_prince_malchezaar.cpp | 120 +- .../karazhan/boss_shade_of_aran.cpp | 97 +- .../karazhan/boss_terestian_illhoof.cpp | 82 +- .../eastern_kingdoms/karazhan/bosses_opera.cpp | 277 ++ .../eastern_kingdoms/karazhan/def_karazhan.h | 7 + .../karazhan/instance_karazhan.cpp | 38 +- .../scripts/eastern_kingdoms/karazhan/karazhan.cpp | 100 +- .../scripts/eastern_kingdoms/loch_modan.cpp | 13 + .../magisters_terrace/boss_felblood_kaelthas.cpp | 119 +- .../magisters_terrace/boss_priestess_delrissa.cpp | 247 +- .../magisters_terrace/boss_selin_fireheart.cpp | 67 +- .../magisters_terrace/boss_vexallus.cpp | 41 + .../magisters_terrace/def_magisters_terrace.h | 7 + .../instance_magisters_terrace.cpp | 29 +- .../magisters_terrace/magisters_terrace.cpp | 32 +- .../molten_core/boss_baron_geddon.cpp | 17 + .../eastern_kingdoms/molten_core/boss_garr.cpp | 25 + .../eastern_kingdoms/molten_core/boss_gehennas.cpp | 14 + .../eastern_kingdoms/molten_core/boss_golemagg.cpp | 30 + .../eastern_kingdoms/molten_core/boss_lucifron.cpp | 13 + .../eastern_kingdoms/molten_core/boss_magmadar.cpp | 16 + .../molten_core/boss_majordomo_executus.cpp | 23 + .../eastern_kingdoms/molten_core/boss_ragnaros.cpp | 49 +- .../eastern_kingdoms/molten_core/boss_shazzrah.cpp | 18 + .../molten_core/boss_sulfuron_harbinger.cpp | 37 + .../eastern_kingdoms/molten_core/def_molten_core.h | 2 + .../molten_core/instance_molten_core.cpp | 43 + .../eastern_kingdoms/molten_core/molten_core.cpp | 14 + .../eastern_kingdoms/scarlet_enclave/chapter1.cpp | 149 +- .../eastern_kingdoms/scarlet_enclave/chapter2.cpp | 86 +- .../eastern_kingdoms/scarlet_enclave/chapter5.cpp | 233 +- .../scarlet_enclave/the_scarlet_enclave.cpp | 13 + .../scarlet_monastery/boss_arcanist_doan.cpp | 20 + .../boss_azshir_the_sleepless.cpp | 15 + .../scarlet_monastery/boss_bloodmage_thalnos.cpp | 18 + .../scarlet_monastery/boss_headless_horseman.cpp | 91 +- .../scarlet_monastery/boss_herod.cpp | 28 +- .../boss_high_inquisitor_fairbanks.cpp | 20 + .../scarlet_monastery/boss_houndmaster_loksey.cpp | 12 + .../scarlet_monastery/boss_interrogator_vishas.cpp | 19 + .../boss_mograine_and_whitemane.cpp | 69 + .../scarlet_monastery/boss_scorn.cpp | 14 + .../scarlet_monastery/def_scarlet_monastery.h | 4 + .../instance_scarlet_monastery.cpp | 22 +- .../scholomance/boss_darkmaster_gandling.cpp | 22 + .../scholomance/boss_death_knight_darkreaver.cpp | 8 + .../scholomance/boss_doctor_theolen_krastinov.cpp | 17 + .../scholomance/boss_illucia_barov.cpp | 17 + .../scholomance/boss_instructor_malicia.cpp | 20 + .../scholomance/boss_jandice_barov.cpp | 34 +- .../eastern_kingdoms/scholomance/boss_kormok.cpp | 17 + .../scholomance/boss_lord_alexei_barov.cpp | 16 + .../scholomance/boss_lorekeeper_polkelt.cpp | 16 + .../scholomance/boss_ras_frostwhisper.cpp | 18 + .../scholomance/boss_the_ravenian.cpp | 17 + .../eastern_kingdoms/scholomance/boss_vectus.cpp | 15 + .../eastern_kingdoms/scholomance/def_scholomance.h | 2 + .../scholomance/instance_scholomance.cpp | 18 +- .../scripts/eastern_kingdoms/searing_gorge.cpp | 30 + .../shadowfang_keep/def_shadowfang_keep.h | 2 + .../shadowfang_keep/instance_shadowfang_keep.cpp | 33 +- .../shadowfang_keep/shadowfang_keep.cpp | 21 + .../scripts/eastern_kingdoms/silvermoon_city.cpp | 15 + .../scripts/eastern_kingdoms/silverpine_forest.cpp | 34 + .../scripts/eastern_kingdoms/stormwind_city.cpp | 48 + .../eastern_kingdoms/stranglethorn_vale.cpp | 17 + .../stratholme/boss_baron_rivendare.cpp | 32 +- .../stratholme/boss_baroness_anastari.cpp | 16 + .../stratholme/boss_cannon_master_willey.cpp | 16 + .../stratholme/boss_dathrohan_balnazzar.cpp | 32 + .../stratholme/boss_magistrate_barthilas.cpp | 20 + .../stratholme/boss_maleki_the_pallid.cpp | 15 + .../stratholme/boss_nerubenkan.cpp | 17 + .../stratholme/boss_order_of_silver_hand.cpp | 19 + .../stratholme/boss_postmaster_malown.cpp | 17 + .../stratholme/boss_ramstein_the_gorger.cpp | 18 +- .../stratholme/boss_timmy_the_cruel.cpp | 12 + .../eastern_kingdoms/stratholme/def_stratholme.h | 5 + .../stratholme/instance_stratholme.cpp | 56 +- .../eastern_kingdoms/stratholme/stratholme.cpp | 49 +- .../sunken_temple/def_sunken_temple.h | 3 + .../sunken_temple/instance_sunken_temple.cpp | 17 + .../sunken_temple/sunken_temple.cpp | 9 + .../sunwell_plateau/boss_brutallus.cpp | 41 + .../sunwell_plateau/boss_eredar_twins.cpp | 91 +- .../sunwell_plateau/boss_felmyst.cpp | 60 +- .../sunwell_plateau/boss_kalecgos.cpp | 101 +- .../sunwell_plateau/boss_kiljaeden.cpp | 201 +- .../eastern_kingdoms/sunwell_plateau/boss_muru.cpp | 108 +- .../sunwell_plateau/def_sunwell_plateau.h | 5 + .../sunwell_plateau/instance_sunwell_plateau.cpp | 36 +- .../sunwell_plateau/sunwell_plateau.cpp | 9 + .../scripts/eastern_kingdoms/tirisfal_glades.cpp | 36 + .../eastern_kingdoms/uldaman/boss_archaedas.cpp | 88 + .../eastern_kingdoms/uldaman/boss_ironaya.cpp | 19 + .../eastern_kingdoms/uldaman/instance_uldaman.cpp | 57 +- .../scripts/eastern_kingdoms/uldaman/uldaman.cpp | 27 + .../scripts/scripts/eastern_kingdoms/undercity.cpp | 42 +- .../eastern_kingdoms/western_plaguelands.cpp | 29 + .../scripts/scripts/eastern_kingdoms/westfall.cpp | 41 + .../scripts/scripts/eastern_kingdoms/wetlands.cpp | 33 +- .../eastern_kingdoms/zulaman/boss_akilzon.cpp | 67 +- .../eastern_kingdoms/zulaman/boss_halazzi.cpp | 55 + .../eastern_kingdoms/zulaman/boss_hexlord.cpp | 165 +- .../eastern_kingdoms/zulaman/boss_janalai.cpp | 122 +- .../eastern_kingdoms/zulaman/boss_nalorakk.cpp | 64 +- .../eastern_kingdoms/zulaman/boss_zuljin.cpp | 89 +- .../scripts/eastern_kingdoms/zulaman/def_zulaman.h | 3 + .../eastern_kingdoms/zulaman/instance_zulaman.cpp | 39 +- .../scripts/eastern_kingdoms/zulaman/zulaman.cpp | 28 +- .../eastern_kingdoms/zulgurub/boss_arlokk.cpp | 51 + .../eastern_kingdoms/zulgurub/boss_gahzranka.cpp | 13 + .../eastern_kingdoms/zulgurub/boss_grilek.cpp | 16 + .../eastern_kingdoms/zulgurub/boss_hakkar.cpp | 34 + .../eastern_kingdoms/zulgurub/boss_hazzarah.cpp | 17 +- .../eastern_kingdoms/zulgurub/boss_jeklik.cpp | 49 + .../eastern_kingdoms/zulgurub/boss_jindo.cpp | 45 + .../eastern_kingdoms/zulgurub/boss_mandokir.cpp | 50 +- .../eastern_kingdoms/zulgurub/boss_marli.cpp | 43 + .../eastern_kingdoms/zulgurub/boss_renataki.cpp | 28 + .../eastern_kingdoms/zulgurub/boss_thekal.cpp | 90 + .../eastern_kingdoms/zulgurub/boss_venoxis.cpp | 29 +- .../eastern_kingdoms/zulgurub/boss_wushoolay.cpp | 13 + .../eastern_kingdoms/zulgurub/def_zulgurub.h | 5 + .../zulgurub/instance_zulgurub.cpp | 21 + .../scripts/scripts/examples/example_creature.cpp | 35 + .../scripts/scripts/examples/example_escort.cpp | 28 + .../scripts/examples/example_gossip_codebox.cpp | 15 + .../scripts/scripts/examples/example_misc.cpp | 10 + .../scripts/scripts/kalimdor/ashenvale.cpp | 42 + src/bindings/scripts/scripts/kalimdor/azshara.cpp | 70 + .../scripts/scripts/kalimdor/azuremyst_isle.cpp | 117 +- .../blackfathom_depths/def_blackfathom_deeps.h | 4 + .../instance_blackfathom_deeps.cpp | 22 + .../scripts/scripts/kalimdor/bloodmyst_isle.cpp | 20 + .../scripts/scripts/kalimdor/boss_azuregos.cpp | 20 + .../culling_of_stratholme/boss_epoch.cpp | 14 + .../culling_of_stratholme/boss_mal_ganis.cpp | 16 + .../culling_of_stratholme/boss_meathook.cpp | 27 +- .../culling_of_stratholme/boss_salramm.cpp | 20 + .../def_culling_of_stratholme.h | 1 + .../instance_culling_of_stratholme.cpp | 3 + .../caverns_of_time/dark_portal/boss_aeonus.cpp | 21 + .../dark_portal/boss_chrono_lord_deja.cpp | 22 + .../caverns_of_time/dark_portal/boss_temporus.cpp | 23 + .../caverns_of_time/dark_portal/dark_portal.cpp | 81 +- .../caverns_of_time/dark_portal/def_dark_portal.h | 7 + .../dark_portal/instance_dark_portal.cpp | 62 +- .../caverns_of_time/hyjal/boss_anetheron.cpp | 42 +- .../caverns_of_time/hyjal/boss_archimonde.cpp | 99 +- .../caverns_of_time/hyjal/boss_azgalor.cpp | 43 + .../caverns_of_time/hyjal/boss_kazrogal.cpp | 24 +- .../hyjal/boss_rage_winterchill.cpp | 21 + .../kalimdor/caverns_of_time/hyjal/def_hyjal.h | 4 + .../kalimdor/caverns_of_time/hyjal/hyjal.cpp | 37 + .../kalimdor/caverns_of_time/hyjal/hyjalAI.cpp | 157 +- .../kalimdor/caverns_of_time/hyjal/hyjalAI.h | 37 + .../kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp | 205 +- .../kalimdor/caverns_of_time/hyjal/hyjal_trash.h | 10 +- .../caverns_of_time/hyjal/instance_hyjal.cpp | 47 +- .../old_hillsbrad/boss_captain_skarloc.cpp | 22 + .../old_hillsbrad/boss_epoch_hunter.cpp | 23 + .../old_hillsbrad/boss_leutenant_drake.cpp | 29 + .../old_hillsbrad/def_old_hillsbrad.h | 2 + .../old_hillsbrad/instance_old_hillsbrad.cpp | 31 +- .../old_hillsbrad/old_hillsbrad.cpp | 83 +- .../scripts/scripts/kalimdor/darkshore.cpp | 67 + src/bindings/scripts/scripts/kalimdor/desolace.cpp | 30 + .../scripts/scripts/kalimdor/dustwallow_marsh.cpp | 65 + src/bindings/scripts/scripts/kalimdor/felwood.cpp | 13 + src/bindings/scripts/scripts/kalimdor/feralas.cpp | 31 + .../kalimdor/maraudon/boss_celebras_the_cursed.cpp | 14 + .../scripts/kalimdor/maraudon/boss_landslide.cpp | 13 + .../scripts/kalimdor/maraudon/boss_noxxion.cpp | 16 + .../kalimdor/maraudon/boss_princess_theradras.cpp | 15 + .../scripts/scripts/kalimdor/moonglade.cpp | 59 +- src/bindings/scripts/scripts/kalimdor/mulgore.cpp | 43 + .../scripts/kalimdor/onyxias_lair/boss_onyxia.cpp | 55 +- .../scripts/scripts/kalimdor/orgrimmar.cpp | 42 + .../boss_amnennar_the_coldbringer.cpp | 19 + .../kalimdor/razorfen_downs/razorfen_downs.cpp | 14 + .../kalimdor/razorfen_kraul/def_razorfen_kraul.h | 4 +- .../razorfen_kraul/instance_razorfen_kraul.cpp | 18 +- .../kalimdor/razorfen_kraul/razorfen_kraul.cpp | 27 + .../kalimdor/ruins_of_ahnqiraj/boss_ayamiss.cpp | 15 + .../kalimdor/ruins_of_ahnqiraj/boss_buru.cpp | 3 + .../kalimdor/ruins_of_ahnqiraj/boss_kurinnaxx.cpp | 13 + .../kalimdor/ruins_of_ahnqiraj/boss_moam.cpp | 17 + .../kalimdor/ruins_of_ahnqiraj/boss_ossirian.cpp | 6 + .../kalimdor/ruins_of_ahnqiraj/boss_rajaxx.cpp | 7 + .../instance_ruins_of_ahnqiraj.cpp | 2 + src/bindings/scripts/scripts/kalimdor/silithus.cpp | 118 +- .../scripts/kalimdor/stonetalon_mountains.cpp | 29 + src/bindings/scripts/scripts/kalimdor/tanaris.cpp | 101 + .../scripts/scripts/kalimdor/teldrassil.cpp | 19 + .../kalimdor/temple_of_ahnqiraj/boss_bug_trio.cpp | 57 +- .../kalimdor/temple_of_ahnqiraj/boss_cthun.cpp | 271 +- .../kalimdor/temple_of_ahnqiraj/boss_fankriss.cpp | 21 + .../kalimdor/temple_of_ahnqiraj/boss_huhuran.cpp | 21 + .../kalimdor/temple_of_ahnqiraj/boss_ouro.cpp | 24 + .../kalimdor/temple_of_ahnqiraj/boss_sartura.cpp | 45 + .../kalimdor/temple_of_ahnqiraj/boss_skeram.cpp | 41 + .../temple_of_ahnqiraj/boss_twinemperors.cpp | 85 +- .../kalimdor/temple_of_ahnqiraj/boss_viscidus.cpp | 4 + .../temple_of_ahnqiraj/def_temple_of_ahnqiraj.h | 3 + .../instance_temple_of_ahnqiraj.cpp | 26 + .../temple_of_ahnqiraj/mob_anubisath_sentinel.cpp | 43 +- .../scripts/scripts/kalimdor/the_barrens.cpp | 104 +- .../scripts/scripts/kalimdor/thousand_needles.cpp | 68 +- .../scripts/scripts/kalimdor/thunder_bluff.cpp | 22 + .../scripts/scripts/kalimdor/ungoro_crater.cpp | 53 + .../kalimdor/wailing_caverns/def_wailing_caverns.h | 6 +- .../wailing_caverns/instance_wailing_caverns.cpp | 27 +- .../kalimdor/wailing_caverns/wailing_caverns.cpp | 29 +- .../scripts/scripts/kalimdor/winterspring.cpp | 29 + .../scripts/kalimdor/zulfarrak/zulfarrak.cpp | 48 + .../azjol_nerub/ahnkahet/boss_amanitar.cpp | 44 + .../azjol_nerub/ahnkahet/boss_elder_nadox.cpp | 51 +- .../azjol_nerub/ahnkahet/boss_herald_volazj.cpp | 28 +- .../ahnkahet/boss_jedoga_shadowseeker.cpp | 14 + .../azjol_nerub/ahnkahet/boss_prince_taldaram.cpp | 59 +- .../northrend/azjol_nerub/ahnkahet/def_ahnkahet.h | 5 + .../azjol_nerub/ahnkahet/instance_ahnkahet.cpp | 85 +- .../azjol_nerub/azjol_nerub/boss_anubarak.cpp | 15 + .../azjol_nerub/azjol_nerub/boss_hadronox.cpp | 20 + .../azjol_nerub/boss_krikthir_the_gatewatcher.cpp | 106 +- .../azjol_nerub/azjol_nerub/def_azjol_nerub.h | 3 + .../azjol_nerub/instance_azjol_nerub.cpp | 39 +- .../scripts/scripts/northrend/borean_tundra.cpp | 86 + .../scripts/scripts/northrend/dragonblight.cpp | 12 + .../northrend/draktharon_keep/boss_dred.cpp | 12 + .../northrend/draktharon_keep/boss_novos.cpp | 31 +- .../northrend/draktharon_keep/boss_tharon_ja.cpp | 14 + .../northrend/draktharon_keep/boss_trollgore.cpp | 12 + .../draktharon_keep/instance_drak_tharon_keep.cpp | 34 +- .../scripts/scripts/northrend/grizzly_hills.cpp | 17 + .../northrend/gundrak/boss_drakkari_colossus.cpp | 63 + .../scripts/scripts/northrend/gundrak/boss_eck.cpp | 19 + .../scripts/northrend/gundrak/boss_gal_darah.cpp | 28 + .../scripts/northrend/gundrak/boss_moorabi.cpp | 31 +- .../scripts/northrend/gundrak/boss_slad_ran.cpp | 49 +- .../scripts/northrend/gundrak/def_gundrak.h | 3 + .../scripts/northrend/gundrak/instance_gundrak.cpp | 47 +- .../scripts/scripts/northrend/howling_fjord.cpp | 29 + .../scripts/scripts/northrend/icecrown.cpp | 14 + .../northrend/naxxramas/boss_anubrekhan.cpp | 21 + .../scripts/northrend/naxxramas/boss_faerlina.cpp | 17 + .../northrend/naxxramas/boss_four_horsemen.cpp | 22 +- .../scripts/northrend/naxxramas/boss_gluth.cpp | 23 +- .../scripts/northrend/naxxramas/boss_gothik.cpp | 57 +- .../scripts/northrend/naxxramas/boss_grobbulus.cpp | 20 + .../scripts/northrend/naxxramas/boss_heigan.cpp | 21 + .../scripts/northrend/naxxramas/boss_kelthuzad.cpp | 35 +- .../scripts/northrend/naxxramas/boss_loatheb.cpp | 12 + .../scripts/northrend/naxxramas/boss_maexxna.cpp | 19 +- .../scripts/northrend/naxxramas/boss_noth.cpp | 26 +- .../scripts/northrend/naxxramas/boss_patchwerk.cpp | 27 +- .../scripts/northrend/naxxramas/boss_razuvious.cpp | 16 + .../scripts/northrend/naxxramas/boss_sapphiron.cpp | 60 +- .../scripts/northrend/naxxramas/boss_thaddius.cpp | 21 + .../scripts/northrend/naxxramas/def_naxxramas.h | 5 + .../northrend/naxxramas/instance_naxxramas.cpp | 36 +- .../nexus/eye_of_eternity/boss_malygos.cpp | 16 + .../nexus/eye_of_eternity/def_eye_of_eternity.h | 1 + .../eye_of_eternity/instance_eye_of_eternity.cpp | 3 + .../northrend/nexus/nexus/boss_anomalus.cpp | 46 +- .../northrend/nexus/nexus/boss_keristrasza.cpp | 48 +- .../northrend/nexus/nexus/boss_magus_telestra.cpp | 43 +- .../scripts/northrend/nexus/nexus/boss_ormorok.cpp | 39 + .../northrend/nexus/nexus/commander_kolurg.cpp | 9 + .../northrend/nexus/nexus/commander_stoutbeard.cpp | 9 + .../scripts/northrend/nexus/nexus/def_nexus.h | 4 + .../northrend/nexus/nexus/instance_nexus.cpp | 30 +- .../scripts/northrend/nexus/oculus/boss_drakos.cpp | 9 + .../scripts/northrend/nexus/oculus/boss_eregos.cpp | 18 + .../scripts/northrend/nexus/oculus/boss_urom.cpp | 9 + .../scripts/northrend/nexus/oculus/boss_varos.cpp | 9 + .../scripts/northrend/nexus/oculus/def_oculus.h | 1 + .../northrend/nexus/oculus/instance_oculus.cpp | 3 + .../northrend/obsidian_sanctum/boss_sartharion.cpp | 199 ++ .../obsidian_sanctum/def_obsidian_sanctum.h | 4 + .../obsidian_sanctum/instance_obsidian_sanctum.cpp | 13 + .../scripts/scripts/northrend/sholazar_basin.cpp | 46 + .../scripts/scripts/northrend/storm_peaks.cpp | 29 + .../ulduar/halls_of_lightning/boss_bjarngrim.cpp | 73 +- .../ulduar/halls_of_lightning/boss_ionar.cpp | 80 +- .../ulduar/halls_of_lightning/boss_loken.cpp | 45 +- .../ulduar/halls_of_lightning/boss_volkhan.cpp | 99 +- .../halls_of_lightning/def_halls_of_lightning.h | 7 + .../instance_halls_of_lightning.cpp | 18 + .../ulduar/halls_of_stone/boss_krystallus.cpp | 24 + .../ulduar/halls_of_stone/boss_maiden_of_grief.cpp | 31 +- .../ulduar/halls_of_stone/boss_sjonnir.cpp | 52 +- .../ulduar/halls_of_stone/halls_of_stone.cpp | 55 +- .../halls_of_stone/instance_halls_of_stone.cpp | 38 +- .../northrend/ulduar/ulduar/boss_algalon.cpp | 1 + .../ulduar/ulduar/boss_assembly_of_iron.cpp | 81 +- .../northrend/ulduar/ulduar/boss_auriaya.cpp | 16 + .../ulduar/ulduar/boss_flame_leviathan.cpp | 59 + .../scripts/northrend/ulduar/ulduar/boss_freya.cpp | 17 + .../northrend/ulduar/ulduar/boss_general_vezax.cpp | 1 + .../scripts/northrend/ulduar/ulduar/boss_hodir.cpp | 17 + .../scripts/northrend/ulduar/ulduar/boss_ignis.cpp | 17 + .../northrend/ulduar/ulduar/boss_kologarn.cpp | 18 + .../northrend/ulduar/ulduar/boss_mimiron.cpp | 1 + .../northrend/ulduar/ulduar/boss_razorscale.cpp | 55 +- .../northrend/ulduar/ulduar/boss_thorim.cpp | 17 + .../scripts/northrend/ulduar/ulduar/boss_xt002.cpp | 18 + .../northrend/ulduar/ulduar/boss_yoggsaron.cpp | 1 + .../scripts/northrend/ulduar/ulduar/def_ulduar.h | 6 + .../northrend/ulduar/ulduar/instance_ulduar.cpp | 41 +- .../northrend/ulduar/ulduar/ulduar_teleporter.cpp | 10 + .../utgarde_keep/boss_ingvar_the_plunderer.cpp | 69 + .../utgarde_keep/utgarde_keep/boss_keleseth.cpp | 61 +- .../utgarde_keep/boss_skarvald_dalronn.cpp | 56 + .../utgarde_keep/utgarde_keep/def_utgarde_keep.h | 5 + .../utgarde_keep/instance_utgarde_keep.cpp | 52 +- .../utgarde_keep/utgarde_keep/utgarde_keep.cpp | 20 +- .../utgarde_pinnacle/boss_palehoof.cpp | 102 + .../utgarde_keep/utgarde_pinnacle/boss_skadi.cpp | 38 +- .../utgarde_keep/utgarde_pinnacle/boss_svala.cpp | 51 + .../utgarde_keep/utgarde_pinnacle/boss_ymiron.cpp | 54 +- .../utgarde_keep/utgarde_pinnacle/def_pinnacle.h | 4 + .../utgarde_pinnacle/instance_pinnacle.cpp | 40 +- .../northrend/vault_of_archavon/boss_archavon.cpp | 33 +- .../northrend/vault_of_archavon/boss_emalon.cpp | 53 +- .../vault_of_archavon/def_vault_of_archavon.h | 1 + .../instance_vault_of_archavon.cpp | 26 +- .../northrend/violet_hold/boss_cyanigosa.cpp | 23 + .../scripts/northrend/violet_hold/boss_erekem.cpp | 37 + .../scripts/northrend/violet_hold/boss_ichoron.cpp | 19 + .../northrend/violet_hold/boss_lavanthor.cpp | 18 + .../scripts/northrend/violet_hold/boss_moragg.cpp | 16 + .../scripts/northrend/violet_hold/boss_xevozz.cpp | 16 + .../scripts/northrend/violet_hold/boss_zuramat.cpp | 18 + .../northrend/violet_hold/def_violet_hold.h | 3 + .../northrend/violet_hold/instance_violet_hold.cpp | 41 +- .../scripts/northrend/violet_hold/violet_hold.cpp | 15 + .../scripts/scripts/northrend/wintergrasp.cpp | 12 + src/bindings/scripts/scripts/northrend/zuldrak.cpp | 43 + .../auchenai_crypts/boss_exarch_maladaar.cpp | 65 + .../boss_shirrak_the_dead_watcher.cpp | 34 +- .../mana_tombs/boss_nexusprince_shaffar.cpp | 69 +- .../auchindoun/mana_tombs/boss_pandemonius.cpp | 22 + .../sethekk_halls/boss_darkweaver_syth.cpp | 94 + .../sethekk_halls/boss_tailonking_ikiss.cpp | 38 + .../auchindoun/sethekk_halls/def_sethekk_halls.h | 2 + .../sethekk_halls/instance_sethekk_halls.cpp | 11 + .../shadow_labyrinth/boss_ambassador_hellmaw.cpp | 30 + .../boss_blackheart_the_inciter.cpp | 27 +- .../shadow_labyrinth/boss_grandmaster_vorpil.cpp | 43 +- .../auchindoun/shadow_labyrinth/boss_murmur.cpp | 29 +- .../shadow_labyrinth/def_shadow_labyrinth.h | 2 + .../shadow_labyrinth/instance_shadow_labyrinth.cpp | 42 +- .../scripts/outland/black_temple/black_temple.cpp | 12 + .../outland/black_temple/boss_bloodboil.cpp | 52 +- .../scripts/outland/black_temple/boss_illidan.cpp | 275 +- .../outland/black_temple/boss_mother_shahraz.cpp | 46 +- .../black_temple/boss_reliquary_of_souls.cpp | 99 +- .../outland/black_temple/boss_shade_of_akama.cpp | 118 +- .../scripts/outland/black_temple/boss_supremus.cpp | 42 +- .../outland/black_temple/boss_teron_gorefiend.cpp | 80 +- .../outland/black_temple/boss_warlord_najentus.cpp | 31 +- .../outland/black_temple/def_black_temple.h | 3 + .../outland/black_temple/illidari_council.cpp | 153 +- .../outland/black_temple/instance_black_temple.cpp | 41 +- .../scripts/outland/blades_edge_mountains.cpp | 69 + .../scripts/outland/boss_doomlord_kazzak.cpp | 25 + .../scripts/scripts/outland/boss_doomwalker.cpp | 31 + .../serpent_shrine/boss_fathomlord_karathress.cpp | 119 +- .../serpent_shrine/boss_hydross_the_unstable.cpp | 52 +- .../serpent_shrine/boss_lady_vashj.cpp | 155 +- .../serpent_shrine/boss_leotheras_the_blind.cpp | 120 +- .../serpent_shrine/boss_lurker_below.cpp | 78 +- .../serpent_shrine/boss_morogrim_tidewalker.cpp | 55 +- .../serpent_shrine/def_serpent_shrine.h | 1 + .../serpent_shrine/instance_serpent_shrine.cpp | 44 +- .../steam_vault/boss_hydromancer_thespia.cpp | 33 + .../steam_vault/boss_mekgineer_steamrigger.cpp | 46 + .../steam_vault/boss_warlord_kalithresh.cpp | 36 + .../steam_vault/def_steam_vault.h | 3 + .../steam_vault/instance_steam_vault.cpp | 38 +- .../coilfang_resevoir/underbog/boss_hungarfen.cpp | 27 + .../underbog/boss_the_black_stalker.cpp | 22 +- .../scripts/outland/gruuls_lair/boss_gruul.cpp | 40 + .../outland/gruuls_lair/boss_high_king_maulgar.cpp | 139 +- .../scripts/outland/gruuls_lair/def_gruuls_lair.h | 3 + .../outland/gruuls_lair/instance_gruuls_lair.cpp | 30 +- .../blood_furnace/boss_broggok.cpp | 20 + .../blood_furnace/boss_kelidan_the_breaker.cpp | 65 +- .../blood_furnace/boss_the_maker.cpp | 28 + .../blood_furnace/def_blood_furnace.h | 2 + .../blood_furnace/instance_blood_furnace.cpp | 36 +- .../hellfire_ramparts/boss_omor_the_unscarred.cpp | 30 + .../hellfire_ramparts/boss_vazruden_the_herald.cpp | 53 + .../boss_watchkeeper_gargolmar.cpp | 25 + .../hellfire_ramparts/def_hellfire_ramparts.h | 4 + .../instance_hellfire_ramparts.cpp | 11 + .../magtheridons_lair/boss_magtheridon.cpp | 93 +- .../magtheridons_lair/def_magtheridons_lair.h | 2 + .../instance_magtheridons_lair.cpp | 35 +- .../shattered_halls/boss_nethekurse.cpp | 68 + .../shattered_halls/boss_warbringer_omrogg.cpp | 74 + .../boss_warchief_kargath_bladefist.cpp | 44 +- .../shattered_halls/def_shattered_halls.h | 3 + .../shattered_halls/instance_shattered_halls.cpp | 15 + .../scripts/scripts/outland/hellfire_peninsula.cpp | 79 + src/bindings/scripts/scripts/outland/nagrand.cpp | 138 + .../scripts/scripts/outland/netherstorm.cpp | 122 + .../scripts/scripts/outland/shadowmoon_valley.cpp | 293 +- .../scripts/scripts/outland/shattrath_city.cpp | 96 + .../outland/tempest_keep/arcatraz/arcatraz.cpp | 65 + .../arcatraz/boss_harbinger_skyriss.cpp | 53 + .../outland/tempest_keep/arcatraz/def_arcatraz.h | 2 + .../tempest_keep/arcatraz/instance_arcatraz.cpp | 33 +- .../botanica/boss_high_botanist_freywinn.cpp | 36 +- .../outland/tempest_keep/botanica/boss_laj.cpp | 23 + .../tempest_keep/botanica/boss_warp_splinter.cpp | 40 +- .../outland/tempest_keep/the_eye/boss_alar.cpp | 60 +- .../tempest_keep/the_eye/boss_astromancer.cpp | 75 +- .../outland/tempest_keep/the_eye/boss_kaelthas.cpp | 266 +- .../tempest_keep/the_eye/boss_void_reaver.cpp | 35 +- .../outland/tempest_keep/the_eye/def_the_eye.h | 2 + .../tempest_keep/the_eye/instance_the_eye.cpp | 25 +- .../outland/tempest_keep/the_eye/the_eye.cpp | 18 + .../the_mechanar/boss_gatewatcher_gyrokill.cpp | 4 + .../the_mechanar/boss_gatewatcher_ironhand.cpp | 20 + .../the_mechanar/boss_nethermancer_sepethrea.cpp | 41 + .../the_mechanar/boss_pathaleon_the_calculator.cpp | 42 +- .../tempest_keep/the_mechanar/def_mechanar.h | 1 + .../the_mechanar/instance_mechanar.cpp | 16 +- .../scripts/scripts/outland/terokkar_forest.cpp | 105 +- .../scripts/scripts/outland/zangarmarsh.cpp | 62 + .../scripts/scripts/world/areatrigger_scripts.cpp | 15 + .../scripts/scripts/world/boss_emeriss.cpp | 19 + src/bindings/scripts/scripts/world/boss_lethon.cpp | 2 + src/bindings/scripts/scripts/world/boss_taerar.cpp | 44 +- .../scripts/scripts/world/boss_ysondre.cpp | 37 +- src/bindings/scripts/scripts/world/go_scripts.cpp | 116 + src/bindings/scripts/scripts/world/guards.cpp | 215 ++ .../scripts/scripts/world/item_scripts.cpp | 38 + .../scripts/scripts/world/mob_generic_creature.cpp | 41 + .../scripts/scripts/world/npc_innkeeper.cpp | 12 + .../scripts/scripts/world/npc_professions.cpp | 119 +- src/bindings/scripts/scripts/world/npc_taxi.cpp | 15 + .../scripts/scripts/world/npcs_special.cpp | 297 +- src/bindings/scripts/system/ScriptLoader.cpp | 23 + src/bindings/scripts/system/ScriptLoader.h | 3 + src/bindings/scripts/system/system.cpp | 47 + src/bindings/scripts/system/system.h | 24 + src/bindings/scripts/trinityscripts.rc | 9 + src/framework/Dynamic/FactoryHolder.h | 7 + src/framework/Dynamic/ObjectRegistry.h | 13 + src/framework/GameSystem/Grid.h | 22 + src/framework/GameSystem/GridLoader.h | 6 + src/framework/GameSystem/GridRefManager.h | 6 + src/framework/GameSystem/GridReference.h | 4 + src/framework/GameSystem/NGrid.h | 26 + src/framework/GameSystem/TypeContainer.h | 18 + src/framework/GameSystem/TypeContainerFunctions.h | 26 + src/framework/GameSystem/TypeContainerVisitor.h | 19 + src/framework/Network/SocketDefines.h | 7 + src/framework/Platform/CompilerDefs.h | 6 + src/framework/Platform/Define.h | 20 + src/framework/Policies/CreationPolicy.h | 9 + src/framework/Policies/ObjectLifeTime.cpp | 3 + src/framework/Policies/ObjectLifeTime.h | 8 + src/framework/Policies/Singleton.h | 9 + src/framework/Policies/SingletonImp.h | 10 + src/framework/Policies/ThreadingModel.h | 23 + src/framework/Utilities/ByteConverter.h | 10 + src/framework/Utilities/Callback.h | 35 + .../Utilities/CountedReference/Reference.h | 17 + .../Utilities/CountedReference/ReferenceHolder.h | 3 + .../Utilities/CountedReference/ReferenceImpl.h | 13 + src/framework/Utilities/EventProcessor.cpp | 13 + src/framework/Utilities/EventProcessor.h | 13 + src/framework/Utilities/LinkedList.h | 42 + .../Utilities/LinkedReference/RefManager.h | 7 + .../Utilities/LinkedReference/Reference.h | 15 + src/framework/Utilities/TypeList.h | 5 + src/framework/Utilities/UnorderedMap.h | 7 + src/game/AccountMgr.cpp | 51 + src/game/AccountMgr.h | 10 + src/game/AchievementMgr.cpp | 264 ++ src/game/AchievementMgr.h | 38 + src/game/AnimalRandomMovementGenerator.h | 2 + src/game/ArenaTeam.cpp | 90 + src/game/ArenaTeam.h | 37 + src/game/ArenaTeamHandler.cpp | 85 + src/game/AuctionHouseBot.cpp | 172 + src/game/AuctionHouseBot.h | 34 + src/game/AuctionHouseHandler.cpp | 99 + src/game/AuctionHouseMgr.cpp | 114 + src/game/AuctionHouseMgr.h | 33 + src/game/Bag.cpp | 43 + src/game/Bag.h | 15 + src/game/BattleGround.cpp | 258 ++ src/game/BattleGround.h | 88 + src/game/BattleGroundAA.cpp | 14 + src/game/BattleGroundAA.h | 6 + src/game/BattleGroundAB.cpp | 82 + src/game/BattleGroundAB.h | 37 + src/game/BattleGroundAV.cpp | 93 + src/game/BattleGroundAV.h | 111 + src/game/BattleGroundBE.cpp | 36 + src/game/BattleGroundBE.h | 9 + src/game/BattleGroundDS.cpp | 14 + src/game/BattleGroundDS.h | 6 + src/game/BattleGroundEY.cpp | 120 + src/game/BattleGroundEY.h | 43 + src/game/BattleGroundHandler.cpp | 106 + src/game/BattleGroundMgr.cpp | 201 ++ src/game/BattleGroundMgr.h | 44 + src/game/BattleGroundNA.cpp | 30 + src/game/BattleGroundNA.h | 8 + src/game/BattleGroundRL.cpp | 30 + src/game/BattleGroundRL.h | 8 + src/game/BattleGroundRV.cpp | 14 + src/game/BattleGroundRV.h | 6 + src/game/BattleGroundSA.cpp | 15 + src/game/BattleGroundSA.h | 9 + src/game/BattleGroundWS.cpp | 80 + src/game/BattleGroundWS.h | 23 + src/game/Calendar.h | 3 + src/game/CalendarHandler.cpp | 40 + src/game/Cell.h | 25 + src/game/CellImpl.h | 36 + src/game/Channel.cpp | 155 +- src/game/Channel.h | 22 + src/game/ChannelHandler.cpp | 59 + src/game/ChannelMgr.cpp | 17 + src/game/ChannelMgr.h | 9 + src/game/CharacterHandler.cpp | 246 ++ src/game/Chat.cpp | 312 +- src/game/Chat.h | 83 + src/game/ChatHandler.cpp | 120 + src/game/CombatAI.cpp | 40 + src/game/CombatAI.h | 14 + src/game/CombatHandler.cpp | 15 + src/game/ConfusedMovementGenerator.cpp | 27 +- src/game/ConfusedMovementGenerator.h | 7 + src/game/Corpse.cpp | 48 + src/game/Corpse.h | 18 + src/game/Creature.cpp | 419 ++- src/game/Creature.h | 128 + src/game/CreatureAI.cpp | 23 + src/game/CreatureAI.h | 51 +- src/game/CreatureAIFactory.h | 7 + src/game/CreatureAIImpl.h | 60 + src/game/CreatureAIRegistry.cpp | 3 + src/game/CreatureAIRegistry.h | 2 + src/game/CreatureAISelector.cpp | 15 + src/game/CreatureAISelector.h | 3 + src/game/CreatureEventAI.cpp | 171 + src/game/CreatureEventAI.h | 41 + src/game/CreatureEventAIMgr.cpp | 73 +- src/game/CreatureEventAIMgr.h | 7 + src/game/CreatureGroups.cpp | 48 +- src/game/CreatureGroups.h | 21 +- src/game/DBCEnums.h | 22 + src/game/DBCStores.cpp | 109 + src/game/DBCStores.h | 16 + src/game/DBCStructure.h | 183 ++ src/game/DBCfmt.h | 3 + src/game/Debugcmds.cpp | 178 ++ src/game/DestinationHolder.cpp | 1 + src/game/DestinationHolder.h | 9 + src/game/DestinationHolderImp.h | 24 + src/game/DuelHandler.cpp | 15 + src/game/DynamicObject.cpp | 24 + src/game/DynamicObject.h | 8 + src/game/FleeingMovementGenerator.cpp | 51 + src/game/FleeingMovementGenerator.h | 13 + src/game/FollowerRefManager.h | 5 + src/game/FollowerReference.cpp | 4 + src/game/FollowerReference.h | 4 + src/game/Formulas.h | 13 + src/game/GameEventMgr.cpp | 235 ++ src/game/GameEventMgr.h | 15 + src/game/GameObject.cpp | 241 +- src/game/GameObject.h | 54 + src/game/GlobalEvents.cpp | 11 + src/game/GlobalEvents.h | 3 + src/game/GossipDef.cpp | 130 + src/game/GossipDef.h | 35 + src/game/GridDefines.h | 35 + src/game/GridNotifiers.cpp | 35 + src/game/GridNotifiers.h | 192 ++ src/game/GridNotifiersImpl.h | 112 + src/game/GridStates.cpp | 5 + src/game/GridStates.h | 11 + src/game/Group.cpp | 238 ++ src/game/Group.h | 55 + src/game/GroupHandler.cpp | 152 + src/game/GroupRefManager.h | 4 + src/game/GroupReference.cpp | 4 + src/game/GroupReference.h | 4 + src/game/GuardAI.cpp | 19 + src/game/GuardAI.h | 9 + src/game/Guild.cpp | 401 +++ src/game/Guild.h | 59 + src/game/GuildHandler.cpp | 278 ++ src/game/HomeMovementGenerator.cpp | 14 + src/game/HomeMovementGenerator.h | 10 + src/game/HostilRefManager.cpp | 20 + src/game/HostilRefManager.h | 14 + src/game/IdleMovementGenerator.cpp | 19 +- src/game/IdleMovementGenerator.h | 14 + src/game/InstanceData.cpp | 42 +- src/game/InstanceData.h | 35 + src/game/InstanceSaveMgr.cpp | 76 + src/game/InstanceSaveMgr.h | 25 + src/game/Item.cpp | 159 +- src/game/Item.h | 39 + src/game/ItemEnchantmentMgr.cpp | 30 + src/game/ItemEnchantmentMgr.h | 3 + src/game/ItemHandler.cpp | 214 ++ src/game/ItemPrototype.h | 68 + src/game/LFGHandler.cpp | 88 + src/game/Language.h | 84 + src/game/Level0.cpp | 45 + src/game/Level1.cpp | 495 +++ src/game/Level2.cpp | 796 ++++- src/game/Level3.cpp | 1130 +++++++ src/game/LootHandler.cpp | 85 + src/game/LootMgr.cpp | 191 ++ src/game/LootMgr.h | 64 + src/game/Mail.cpp | 150 + src/game/Mail.h | 23 + src/game/Map.cpp | 518 +++ src/game/Map.h | 123 + src/game/MapInstanced.cpp | 35 + src/game/MapInstanced.h | 14 + src/game/MapManager.cpp | 50 + src/game/MapManager.h | 29 + src/game/MapRefManager.h | 6 + src/game/MapReference.h | 3 + src/game/MiscHandler.cpp | 302 +- src/game/MotionMaster.cpp | 67 + src/game/MotionMaster.h | 24 + src/game/MovementGenerator.cpp | 2 + src/game/MovementGenerator.h | 15 + src/game/MovementHandler.cpp | 108 +- src/game/NPCHandler.cpp | 169 + src/game/NPCHandler.h | 11 + src/game/Object.cpp | 338 +- src/game/Object.h | 116 + src/game/ObjectAccessor.cpp | 74 + src/game/ObjectAccessor.h | 51 + src/game/ObjectDefines.h | 13 + src/game/ObjectGridLoader.cpp | 47 + src/game/ObjectGridLoader.h | 20 + src/game/ObjectMgr.cpp | 1463 ++++++++- src/game/ObjectMgr.h | 169 +- src/game/Opcodes.cpp | 3 + src/game/Opcodes.h | 10 + src/game/OutdoorPvP.cpp | 84 + src/game/OutdoorPvP.h | 53 + src/game/OutdoorPvPEP.cpp | 73 + src/game/OutdoorPvPEP.h | 37 + src/game/OutdoorPvPHP.cpp | 28 + src/game/OutdoorPvPHP.h | 22 + src/game/OutdoorPvPImpl.h | 3 + src/game/OutdoorPvPMgr.cpp | 26 + src/game/OutdoorPvPMgr.h | 15 + src/game/OutdoorPvPNA.cpp | 55 + src/game/OutdoorPvPNA.h | 41 + src/game/OutdoorPvPSI.cpp | 13 + src/game/OutdoorPvPSI.h | 14 + src/game/OutdoorPvPTF.cpp | 34 + src/game/OutdoorPvPTF.h | 19 + src/game/OutdoorPvPZM.cpp | 35 + src/game/OutdoorPvPZM.h | 27 + src/game/PassiveAI.h | 16 + src/game/Path.h | 10 + src/game/Pet.cpp | 302 +- src/game/Pet.h | 45 + src/game/PetAI.cpp | 75 + src/game/PetAI.h | 12 + src/game/PetHandler.cpp | 122 + src/game/PetitionsHandler.cpp | 132 + src/game/Player.cpp | 3380 +++++++++++++++++++- src/game/Player.h | 402 ++- src/game/PlayerDump.cpp | 101 + src/game/PlayerDump.h | 19 + src/game/PointMovementGenerator.cpp | 14 + src/game/PointMovementGenerator.h | 10 + src/game/PoolHandler.cpp | 84 + src/game/PoolHandler.h | 11 + src/game/QueryHandler.cpp | 54 + src/game/QuestDef.cpp | 32 + src/game/QuestDef.h | 29 + src/game/QuestHandler.cpp | 100 + src/game/RandomMovementGenerator.cpp | 31 + src/game/RandomMovementGenerator.h | 5 + src/game/ReactorAI.cpp | 7 + src/game/ReactorAI.h | 7 + src/game/ReputationMgr.cpp | 102 +- src/game/ReputationMgr.h | 22 + src/game/ScriptCalls.cpp | 14 + src/game/ScriptCalls.h | 11 + src/game/SharedDefines.h | 131 + src/game/SkillDiscovery.cpp | 44 + src/game/SkillDiscovery.h | 4 + src/game/SkillExtraItems.cpp | 28 + src/game/SkillExtraItems.h | 3 + src/game/SkillHandler.cpp | 15 + src/game/SocialMgr.cpp | 48 + src/game/SocialMgr.h | 15 + src/game/Spell.cpp | 875 ++++- src/game/Spell.h | 100 + src/game/SpellAuraDefines.h | 5 + src/game/SpellAuras.cpp | 753 ++++- src/game/SpellAuras.h | 48 +- src/game/SpellEffects.cpp | 862 ++++- src/game/SpellHandler.cpp | 111 +- src/game/SpellMgr.cpp | 500 ++- src/game/SpellMgr.h | 187 ++ src/game/StatSystem.cpp | 175 + src/game/TargetedMovementGenerator.cpp | 33 + src/game/TargetedMovementGenerator.h | 11 + src/game/TaxiHandler.cpp | 56 + src/game/TemporarySummon.cpp | 52 + src/game/TemporarySummon.h | 10 + src/game/ThreatManager.cpp | 84 + src/game/ThreatManager.h | 64 + src/game/TicketHandler.cpp | 27 +- src/game/Totem.cpp | 23 +- src/game/Totem.h | 8 + src/game/TotemAI.cpp | 17 + src/game/TotemAI.h | 8 + src/game/TradeHandler.cpp | 83 + src/game/Transports.cpp | 96 + src/game/Transports.h | 17 + src/game/Traveller.h | 19 + src/game/Unit.cpp | 1801 ++++++++++- src/game/Unit.h | 274 +- src/game/UnitAI.cpp | 40 + src/game/UnitAI.h | 19 + src/game/UnitEvents.h | 36 + src/game/UpdateData.cpp | 26 + src/game/UpdateData.h | 9 + src/game/UpdateFields.h | 10 + src/game/UpdateMask.h | 23 + src/game/Vehicle.cpp | 47 +- src/game/Vehicle.h | 13 + src/game/VoiceChatHandler.cpp | 4 + src/game/WaypointManager.cpp | 32 + src/game/WaypointManager.h | 10 + src/game/WaypointMovementGenerator.cpp | 93 + src/game/WaypointMovementGenerator.h | 18 + src/game/Weather.cpp | 37 + src/game/Weather.h | 7 + src/game/Wintergrasp.cpp | 153 + src/game/Wintergrasp.h | 50 + src/game/World.cpp | 423 ++- src/game/World.h | 76 +- src/game/WorldLog.cpp | 18 + src/game/WorldLog.h | 10 + src/game/WorldSession.cpp | 135 +- src/game/WorldSession.h | 119 + src/game/WorldSocket.cpp | 204 +- src/game/WorldSocket.h | 48 + src/game/WorldSocketMgr.cpp | 80 + src/game/WorldSocketMgr.h | 17 + src/game/ZoneScript.h | 12 +- src/game/pchdef.h | 1 + src/shared/Auth/AuthCrypt.cpp | 17 + src/shared/Auth/AuthCrypt.h | 7 + src/shared/Auth/BigNumber.cpp | 39 + src/shared/Auth/BigNumber.h | 15 + src/shared/Auth/Hmac.cpp | 8 + src/shared/Auth/Hmac.h | 5 + src/shared/Auth/SARC4.cpp | 6 + src/shared/Auth/SARC4.h | 3 + src/shared/Auth/Sha1.cpp | 9 + src/shared/Auth/Sha1.h | 9 + src/shared/ByteBuffer.h | 88 + src/shared/Common.cpp | 4 + src/shared/Common.h | 32 + src/shared/Config/Config.cpp | 14 + src/shared/Config/Config.h | 9 + src/shared/Config/ConfigEnv.h | 4 + src/shared/Config/dotconfpp/dotconfpp.cpp | 76 + src/shared/Config/dotconfpp/dotconfpp.h | 18 + src/shared/Config/dotconfpp/mempool.cpp | 15 + src/shared/Config/dotconfpp/mempool.h | 10 + src/shared/Database/DBCFileLoader.cpp | 42 + src/shared/Database/DBCFileLoader.h | 12 + src/shared/Database/DBCStore.h | 24 + src/shared/Database/Database.cpp | 42 + src/shared/Database/Database.h | 22 + src/shared/Database/DatabaseEnv.h | 6 + src/shared/Database/DatabaseImpl.h | 27 + src/shared/Database/DatabaseMysql.cpp | 70 + src/shared/Database/DatabaseMysql.h | 14 + src/shared/Database/Field.cpp | 10 + src/shared/Database/Field.h | 10 + src/shared/Database/MySQLDelayThread.h | 3 + src/shared/Database/QueryResult.h | 15 + src/shared/Database/QueryResultMysql.cpp | 15 + src/shared/Database/QueryResultMysql.h | 8 + src/shared/Database/SQLStorage.cpp | 8 + src/shared/Database/SQLStorage.h | 19 + src/shared/Database/SQLStorageImpl.h | 20 + src/shared/Database/SqlDelayThread.cpp | 6 + src/shared/Database/SqlDelayThread.h | 8 + src/shared/Database/SqlOperations.cpp | 26 + src/shared/Database/SqlOperations.h | 15 + src/shared/Errors.h | 7 + src/shared/LockedQueue.h | 18 + src/shared/Log.cpp | 166 + src/shared/Log.h | 28 +- src/shared/ProgressBar.cpp | 8 + src/shared/ProgressBar.h | 5 + src/shared/ServiceWin32.cpp | 41 + src/shared/ServiceWin32.h | 3 + src/shared/SystemConfig.h | 7 + src/shared/Threading.cpp | 53 +- src/shared/Threading.h | 19 + src/shared/Timer.h | 12 + src/shared/Util.cpp | 74 + src/shared/Util.h | 72 + src/shared/WheatyExceptionReport.cpp | 131 + src/shared/WheatyExceptionReport.h | 18 + src/shared/WorldPacket.h | 6 + src/shared/vmap/AABSPTree.h | 288 ++ src/shared/vmap/BaseModel.cpp | 17 + src/shared/vmap/BaseModel.h | 24 + src/shared/vmap/CoordModelMapping.cpp | 25 + src/shared/vmap/CoordModelMapping.h | 27 + src/shared/vmap/DebugCmdLogger.cpp | 10 + src/shared/vmap/DebugCmdLogger.h | 14 + src/shared/vmap/IVMapManager.h | 18 + src/shared/vmap/ManagedModelContainer.cpp | 6 + src/shared/vmap/ManagedModelContainer.h | 7 + src/shared/vmap/ModelContainer.cpp | 66 + src/shared/vmap/ModelContainer.h | 29 + src/shared/vmap/NodeValueAccess.h | 7 + src/shared/vmap/ShortBox.h | 21 + src/shared/vmap/ShortVector.h | 15 + src/shared/vmap/SubModel.cpp | 41 + src/shared/vmap/SubModel.h | 19 + src/shared/vmap/TileAssembler.cpp | 87 + src/shared/vmap/TileAssembler.h | 13 + src/shared/vmap/TreeNode.cpp | 5 + src/shared/vmap/TreeNode.h | 34 + src/shared/vmap/VMapDefinitions.h | 4 + src/shared/vmap/VMapFactory.cpp | 12 + src/shared/vmap/VMapFactory.h | 7 + src/shared/vmap/VMapManager.cpp | 60 + src/shared/vmap/VMapManager.h | 29 + src/shared/vmap/VMapTools.h | 20 + src/tools/genrevision/genrevision.cpp | 58 + src/trinitycore/CliRunnable.cpp | 66 + src/trinitycore/CliRunnable.h | 3 + src/trinitycore/Main.cpp | 18 + src/trinitycore/Master.cpp | 87 +- src/trinitycore/Master.h | 8 + src/trinitycore/RASocket.cpp | 42 + src/trinitycore/RASocket.h | 12 + src/trinitycore/TrinityCore.rc | 9 + src/trinitycore/WorldRunnable.cpp | 18 + src/trinitycore/WorldRunnable.h | 3 + src/trinitycore/resource.h | 1 + src/trinityrealm/AuthCodes.h | 7 + src/trinityrealm/AuthSocket.cpp | 163 + src/trinityrealm/AuthSocket.h | 15 + src/trinityrealm/Main.cpp | 48 + src/trinityrealm/RealmList.cpp | 19 + src/trinityrealm/RealmList.h | 10 + src/trinityrealm/TrinityRealm.rc | 9 + 2257 files changed, 103850 insertions(+), 748 deletions(-) diff --git a/COPYING b/COPYING index 6290e6487d6..bee9f8d231f 100644 --- a/COPYING +++ b/COPYING @@ -1,10 +1,13 @@ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 + Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + Preamble + The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free @@ -14,40 +17,48 @@ Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, @@ -57,12 +68,14 @@ that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate @@ -70,18 +83,23 @@ copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an @@ -102,31 +120,38 @@ distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any @@ -137,6 +162,7 @@ anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as @@ -150,6 +176,7 @@ void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are @@ -158,6 +185,7 @@ modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to @@ -165,6 +193,7 @@ these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -177,10 +206,12 @@ license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the @@ -191,6 +222,7 @@ through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. @@ -201,10 +233,12 @@ may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions @@ -212,6 +246,7 @@ either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free @@ -219,7 +254,9 @@ Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + NO WARRANTY + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES @@ -229,6 +266,7 @@ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, @@ -238,48 +276,63 @@ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs + If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + Copyright (C) + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Also add information on how to contact you by electronic and paper mail. + If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + , 1 April 1989 Ty Coon, President of Vice + This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the diff --git a/README b/README index 2b294b6cc25..4263f79f7ff 100644 --- a/README +++ b/README @@ -1,16 +1,21 @@ = TrinityCore -- General information = + Copyright (C) TrinityCore (http://www.trinitycore.org) + Trinity Core is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + In addition, as a special exception, the Trinity Core project gives permission to link the code of its release of Trinity Core with the OpenSSL project's "OpenSSL" library (or with modified versions of @@ -20,14 +25,19 @@ Copyright (C) TrinityCore (http://www.trinitycore.org) modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. + TrinityCore is a World of Warcraft game server emulator. It is derived from MaNGOS, the Massive Network Game Object Server, and is based on the code of that project. + For further information on the TrinityCore project, please visit our project website at http://www.trinitycore.org. + API documentation can be obtained by running the "make doc" command inside the doc directory. + SQL files to create the database can be found in the sql directory. Files to update your database from an older revision/version can be found in the sql/updates directory. + See the INSTALL.linux file for installation instructions on Linux. diff --git a/THANKS b/THANKS index 4df3c2c154d..840a818d3f9 100644 --- a/THANKS +++ b/THANKS @@ -1,13 +1,18 @@ = TrinityCore -- Thanks/credits file = + TrinityCore is a derivation/rewrite of MaNGOS, which was originally written by Team Python and the WoW Daemon Team. Many people further helped Trinity Core by submitting bug reports, code patches, and suggestions. Thanks to the community! + Special thanks should go out to the WowwoW team. We have gained help from them many times in the creation of this project. Keep up the good work guys. + Thanks to the ScriptDev2 team (http://www.scriptdev2.com) for scripts. + Thanks to the WCell team (especially Ralek) for research on realm reconnect sequence, item scaling stats algorithm, gameobject rotation issues. + Thanks go out to the following people for various patches/code (listed in the order they were added): w12x, dythzer, XEQT, death420, balrok, TOM_RUS, runningnak3d, Seline, KingPin, raczman, bogie, Neo2003, NoFantasy, Derex, diff --git a/dep/ACE_wrappers/README b/dep/ACE_wrappers/README index f560fdda82c..1b46d7fd6f4 100644 --- a/dep/ACE_wrappers/README +++ b/dep/ACE_wrappers/README @@ -1,11 +1,18 @@ 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++ @@ -15,12 +22,14 @@ 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 @@ -29,83 +38,115 @@ 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 @@ -114,25 +155,36 @@ contains the source code, test drivers, and example applications 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 @@ -140,22 +192,31 @@ 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/VERSION b/dep/ACE_wrappers/VERSION index 5b1b3ee8ea6..0c1423ad06d 100644 --- a/dep/ACE_wrappers/VERSION +++ b/dep/ACE_wrappers/VERSION @@ -1,8 +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.cpp b/dep/ACE_wrappers/ace/ACE.cpp index 2f1fa64ba4e..7ccf15ed341 100644 --- a/dep/ACE_wrappers/ace/ACE.cpp +++ b/dep/ACE_wrappers/ace/ACE.cpp @@ -1,5 +1,7 @@ // $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" @@ -22,35 +24,45 @@ #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) { @@ -92,21 +104,25 @@ ACE::out_of_handles (int error) 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) { @@ -116,6 +132,7 @@ ACE::compiler_name (void) return ACE_TEXT (""); #endif } + u_int ACE::compiler_major_version (void) { @@ -125,6 +142,7 @@ ACE::compiler_major_version (void) return 0; #endif } + u_int ACE::compiler_minor_version (void) { @@ -134,6 +152,7 @@ ACE::compiler_minor_version (void) return 0; #endif } + u_int ACE::compiler_beta_version (void) { @@ -143,17 +162,20 @@ ACE::compiler_beta_version (void) 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, @@ -180,6 +202,7 @@ ACE::select (int width, } return result; } + int ACE::select (int width, ACE_Handle_Set &readfds, @@ -190,12 +213,14 @@ ACE::select (int width, 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) { @@ -208,6 +233,7 @@ ACE::terminate_process (pid_t pid) ::OpenProcess (PROCESS_TERMINATE, FALSE, // New handle is not inheritable. pid); + if (process_handle == ACE_INVALID_HANDLE || process_handle == 0) return -1; @@ -224,6 +250,7 @@ ACE::terminate_process (pid_t pid) return ACE_OS::kill (pid, 9); #endif /* ACE_HAS_PHARLAP */ } + int ACE::process_active (pid_t pid) { @@ -248,11 +275,13 @@ ACE::process_active (pid_t pid) &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) { @@ -261,110 +290,142 @@ ACE::execname (const ACE_TCHAR *old_name) 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 @@ -374,12 +435,14 @@ ACE::dirname (const ACE_TCHAR *pathname, ACE_TCHAR delim) 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, @@ -403,7 +466,9 @@ ACE::recv (ACE_HANDLE handle, } } } + #if defined (ACE_HAS_TLI) + ssize_t ACE::t_rcv (ACE_HANDLE handle, void *buf, @@ -427,7 +492,9 @@ ACE::t_rcv (ACE_HANDLE handle, } } } + #endif /* ACE_HAS_TLI */ + ssize_t ACE::recv (ACE_HANDLE handle, void *buf, @@ -449,6 +516,7 @@ ACE::recv (ACE_HANDLE handle, } } } + ssize_t ACE::recvmsg (ACE_HANDLE handle, struct msghdr *msg, @@ -470,6 +538,7 @@ ACE::recvmsg (ACE_HANDLE handle, } } } + ssize_t ACE::recvfrom (ACE_HANDLE handle, char *buf, @@ -495,6 +564,7 @@ ACE::recvfrom (ACE_HANDLE handle, } } } + ssize_t ACE::recv_n_i (ACE_HANDLE handle, void *buf, @@ -505,6 +575,7 @@ ACE::recv_n_i (ACE_HANDLE handle, size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; ssize_t n; + for (bytes_transferred = 0; bytes_transferred < len; bytes_transferred += n) @@ -517,6 +588,7 @@ ACE::recv_n_i (ACE_HANDLE handle, // Check EOF. if (n == 0) return 0; + // Check for other errors. if (n == -1) { @@ -525,6 +597,7 @@ ACE::recv_n_i (ACE_HANDLE handle, { // Wait for the blocking to subside. int const result = ACE::handle_read_ready (handle, 0); + // Did select() succeed? if (result != -1) { @@ -533,12 +606,15 @@ ACE::recv_n_i (ACE_HANDLE handle, 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, @@ -552,8 +628,10 @@ ACE::recv_n_i (ACE_HANDLE handle, 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) @@ -565,6 +643,7 @@ ACE::recv_n_i (ACE_HANDLE handle, static_cast (buf) + bytes_transferred, len - bytes_transferred, flags); + // Check for errors. if (n == 0 || n == -1) @@ -576,6 +655,7 @@ ACE::recv_n_i (ACE_HANDLE handle, // Wait upto for the blocking to subside. int rtn = ACE::handle_read_ready (handle, timeout); + // Did select() succeed? if (rtn != -1) { @@ -585,6 +665,7 @@ ACE::recv_n_i (ACE_HANDLE handle, continue; } } + // Wait in select() timed out or other data transfer or // select() failures. error = 1; @@ -592,13 +673,17 @@ ACE::recv_n_i (ACE_HANDLE handle, 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, @@ -609,6 +694,7 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; ssize_t n; + for (bytes_transferred = 0; bytes_transferred < len; bytes_transferred += n) @@ -621,6 +707,7 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, // Check EOF. if (n == 0) return 0; + // Check for other errors. if (n == -1) { @@ -630,6 +717,7 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, // Wait for the blocking to subside. int result = ACE::handle_read_ready (handle, 0); + // Did select() succeed? if (result != -1) { @@ -638,12 +726,15 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, continue; } } + // Other data transfer or select() failures. return -1; } } + return bytes_transferred; } + ssize_t ACE::t_rcv_n_i (ACE_HANDLE handle, void *buf, @@ -657,8 +748,10 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, 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) @@ -670,6 +763,7 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, (char *) buf + bytes_transferred, len - bytes_transferred, flags); + // Check for errors. if (n == 0 || n == -1) @@ -681,6 +775,7 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, // Wait upto for the blocking to subside. int rtn = ACE::handle_read_ready (handle, timeout); + // Did select() succeed? if (rtn != -1) { @@ -690,6 +785,7 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, continue; } } + // Wait in select() timed out or other data transfer or // select() failures. error = 1; @@ -697,13 +793,17 @@ ACE::t_rcv_n_i (ACE_HANDLE handle, 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, @@ -713,6 +813,7 @@ ACE::recv_n_i (ACE_HANDLE handle, size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; ssize_t n; + for (bytes_transferred = 0; bytes_transferred < len; bytes_transferred += n) @@ -735,6 +836,7 @@ ACE::recv_n_i (ACE_HANDLE handle, // Wait for the blocking to subside. int result = ACE::handle_read_ready (handle, 0); + // Did select() succeed? if (result != -1) { @@ -743,12 +845,15 @@ ACE::recv_n_i (ACE_HANDLE handle, 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, @@ -761,8 +866,10 @@ ACE::recv_n_i (ACE_HANDLE handle, 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) @@ -773,6 +880,7 @@ ACE::recv_n_i (ACE_HANDLE handle, n = ACE::recv_i (handle, static_cast (buf) + bytes_transferred, len - bytes_transferred); + // Check for errors. if (n == 0 || n == -1) @@ -784,6 +892,7 @@ ACE::recv_n_i (ACE_HANDLE handle, // Wait upto for the blocking to subside. int rtn = ACE::handle_read_ready (handle, timeout); + // Did select() succeed? if (rtn != -1) { @@ -793,6 +902,7 @@ ACE::recv_n_i (ACE_HANDLE handle, continue; } } + // Wait in select() timed out or other data transfer or // select() failures. error = 1; @@ -800,17 +910,21 @@ ACE::recv_n_i (ACE_HANDLE handle, 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, ...) { @@ -824,12 +938,15 @@ ACE::recv (ACE_HANDLE handle, size_t n, ...) 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; @@ -837,6 +954,7 @@ ACE::recv (ACE_HANDLE handle, size_t n, ...) va_end (argp); return result; } + ssize_t ACE::recvv (ACE_HANDLE handle, iovec *iov, @@ -858,6 +976,7 @@ ACE::recvv (ACE_HANDLE handle, } } } + ssize_t ACE::recvv_n_i (ACE_HANDLE handle, iovec *iov, @@ -867,6 +986,7 @@ ACE::recvv_n_i (ACE_HANDLE handle, size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; bytes_transferred = 0; + for (int s = 0; s < iovcnt; ) @@ -878,6 +998,7 @@ ACE::recvv_n_i (ACE_HANDLE handle, // Check EOF. if (n == 0) return 0; + // Check for other errors. if (n == -1) { @@ -887,6 +1008,7 @@ ACE::recvv_n_i (ACE_HANDLE handle, // Wait for the blocking to subside. int result = ACE::handle_read_ready (handle, 0); + // Did select() succeed? if (result != -1) { @@ -895,14 +1017,17 @@ ACE::recvv_n_i (ACE_HANDLE handle, 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); @@ -910,8 +1035,10 @@ ACE::recvv_n_i (ACE_HANDLE handle, 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, @@ -924,8 +1051,10 @@ ACE::recvv_n_i (ACE_HANDLE handle, 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; ) @@ -936,6 +1065,7 @@ ACE::recvv_n_i (ACE_HANDLE handle, ssize_t n = ACE_OS::recvv (handle, iov + s, iovcnt - s); + // Check for errors. if (n == 0 || n == -1) @@ -947,6 +1077,7 @@ ACE::recvv_n_i (ACE_HANDLE handle, // Wait upto for the blocking to subside. int rtn = ACE::handle_read_ready (handle, timeout); + // Did select() succeed? if (rtn != -1) { @@ -956,17 +1087,20 @@ ACE::recvv_n_i (ACE_HANDLE handle, 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); @@ -974,7 +1108,9 @@ ACE::recvv_n_i (ACE_HANDLE handle, iov[s].iov_len = iov[s].iov_len - n; } } + ACE::restore_non_blocking_mode (handle, val); + if (error) { return result; @@ -984,6 +1120,7 @@ ACE::recvv_n_i (ACE_HANDLE handle, return ACE_Utils::truncate_cast (bytes_transferred); } } + ssize_t ACE::recv_n (ACE_HANDLE handle, ACE_Message_Block *message_block, @@ -993,30 +1130,37 @@ ACE::recv_n (ACE_HANDLE handle, 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 @@ -1024,47 +1168,59 @@ ACE::recv_n (ACE_HANDLE handle, 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, @@ -1087,7 +1243,9 @@ ACE::send (ACE_HANDLE handle, } } } + #if defined (ACE_HAS_TLI) + ssize_t ACE::t_snd (ACE_HANDLE handle, const void *buf, @@ -1110,7 +1268,9 @@ ACE::t_snd (ACE_HANDLE handle, } } } + #endif /* ACE_HAS_TLI */ + ssize_t ACE::send (ACE_HANDLE handle, const void *buf, @@ -1132,6 +1292,7 @@ ACE::send (ACE_HANDLE handle, } } } + ssize_t ACE::sendmsg (ACE_HANDLE handle, const struct msghdr *msg, @@ -1153,6 +1314,7 @@ ACE::sendmsg (ACE_HANDLE handle, } } } + ssize_t ACE::sendto (ACE_HANDLE handle, const char *buf, @@ -1178,6 +1340,7 @@ ACE::sendto (ACE_HANDLE handle, } } } + ssize_t ACE::send_n_i (ACE_HANDLE handle, const void *buf, @@ -1188,6 +1351,7 @@ ACE::send_n_i (ACE_HANDLE handle, size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; ssize_t n; + for (bytes_transferred = 0; bytes_transferred < len; bytes_transferred += n) @@ -1200,6 +1364,7 @@ ACE::send_n_i (ACE_HANDLE handle, // Check EOF. if (n == 0) return 0; + // Check for other errors. if (n == -1) { @@ -1213,6 +1378,7 @@ ACE::send_n_i (ACE_HANDLE handle, // Wait for the blocking to subside. int result = ACE::handle_write_ready (handle, 0); + // Did select() succeed? if (result != -1) { @@ -1221,12 +1387,15 @@ ACE::send_n_i (ACE_HANDLE handle, 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, @@ -1240,8 +1409,10 @@ ACE::send_n_i (ACE_HANDLE handle, 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) @@ -1253,6 +1424,7 @@ ACE::send_n_i (ACE_HANDLE handle, (char *) buf + bytes_transferred, len - bytes_transferred, flags); + // Check for errors. if (n == 0 || n == -1) @@ -1264,6 +1436,7 @@ ACE::send_n_i (ACE_HANDLE handle, // Wait upto for the blocking to subside. int rtn = ACE::handle_write_ready (handle, timeout); + // Did select() succeed? if (rtn != -1) { @@ -1273,6 +1446,7 @@ ACE::send_n_i (ACE_HANDLE handle, continue; } } + // Wait in select() timed out or other data transfer or // select() failures. error = 1; @@ -1280,7 +1454,9 @@ ACE::send_n_i (ACE_HANDLE handle, break; } } + ACE::restore_non_blocking_mode (handle, val); + if (error) { return result; @@ -1290,7 +1466,9 @@ ACE::send_n_i (ACE_HANDLE handle, 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, @@ -1301,6 +1479,7 @@ ACE::t_snd_n_i (ACE_HANDLE handle, size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; ssize_t n; + for (bytes_transferred = 0; bytes_transferred < len; bytes_transferred += n) @@ -1313,6 +1492,7 @@ ACE::t_snd_n_i (ACE_HANDLE handle, // Check EOF. if (n == 0) return 0; + // Check for other errors. if (n == -1) { @@ -1322,6 +1502,7 @@ ACE::t_snd_n_i (ACE_HANDLE handle, // Wait for the blocking to subside. int result = ACE::handle_write_ready (handle, 0); + // Did select() succeed? if (result != -1) { @@ -1330,12 +1511,15 @@ ACE::t_snd_n_i (ACE_HANDLE handle, 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, @@ -1349,8 +1533,10 @@ ACE::t_snd_n_i (ACE_HANDLE handle, 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) @@ -1362,6 +1548,7 @@ ACE::t_snd_n_i (ACE_HANDLE handle, (char *) buf + bytes_transferred, len - bytes_transferred, flags); + // Check for errors. if (n == 0 || n == -1) @@ -1373,6 +1560,7 @@ ACE::t_snd_n_i (ACE_HANDLE handle, // Wait upto for the blocking to subside. int rtn = ACE::handle_write_ready (handle, timeout); + // Did select() succeed? if (rtn != -1) { @@ -1382,6 +1570,7 @@ ACE::t_snd_n_i (ACE_HANDLE handle, continue; } } + // Wait in select() timed out or other data transfer or // select() failures. error = 1; @@ -1389,13 +1578,17 @@ ACE::t_snd_n_i (ACE_HANDLE handle, 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, @@ -1405,6 +1598,7 @@ ACE::send_n_i (ACE_HANDLE handle, size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; ssize_t n; + for (bytes_transferred = 0; bytes_transferred < len; bytes_transferred += n) @@ -1418,6 +1612,7 @@ ACE::send_n_i (ACE_HANDLE handle, { return 0; } + // Check for other errors. if (n == -1) { @@ -1427,6 +1622,7 @@ ACE::send_n_i (ACE_HANDLE handle, // Wait for the blocking to subside. int result = ACE::handle_write_ready (handle, 0); + // Did select() succeed? if (result != -1) { @@ -1435,12 +1631,15 @@ ACE::send_n_i (ACE_HANDLE handle, 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, @@ -1453,8 +1652,10 @@ ACE::send_n_i (ACE_HANDLE handle, 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) @@ -1465,6 +1666,7 @@ ACE::send_n_i (ACE_HANDLE handle, n = ACE::send_i (handle, (char *) buf + bytes_transferred, len - bytes_transferred); + // Check for errors. if (n == 0 || n == -1) @@ -1476,6 +1678,7 @@ ACE::send_n_i (ACE_HANDLE handle, // Wait upto for the blocking to subside. int rtn = ACE::handle_write_ready (handle, timeout); + // Did select() succeed? if (rtn != -1) { @@ -1485,6 +1688,7 @@ ACE::send_n_i (ACE_HANDLE handle, continue; } } + // Wait in select() timed out or other data transfer or // select() failures. error = 1; @@ -1492,7 +1696,9 @@ ACE::send_n_i (ACE_HANDLE handle, break; } } + ACE::restore_non_blocking_mode (handle, val); + if (error) { return result; @@ -1502,10 +1708,12 @@ ACE::send_n_i (ACE_HANDLE handle, 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, ...) { @@ -1519,12 +1727,15 @@ ACE::send (ACE_HANDLE handle, size_t n, ...) 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; @@ -1532,6 +1743,7 @@ ACE::send (ACE_HANDLE handle, size_t n, ...) va_end (argp); return result; } + ssize_t ACE::sendv (ACE_HANDLE handle, const iovec *iov, @@ -1553,6 +1765,7 @@ ACE::sendv (ACE_HANDLE handle, } } } + ssize_t ACE::sendv_n_i (ACE_HANDLE handle, const iovec *i, @@ -1562,7 +1775,9 @@ ACE::sendv_n_i (ACE_HANDLE handle, 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; ) @@ -1574,6 +1789,7 @@ ACE::sendv_n_i (ACE_HANDLE handle, // Check EOF. if (n == 0) return 0; + // Check for other errors. if (n == -1) { @@ -1583,6 +1799,7 @@ ACE::sendv_n_i (ACE_HANDLE handle, // Wait for the blocking to subside. int result = ACE::handle_write_ready (handle, 0); + // Did select() succeed? if (result != -1) { @@ -1591,14 +1808,17 @@ ACE::sendv_n_i (ACE_HANDLE handle, 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); @@ -1606,8 +1826,10 @@ ACE::sendv_n_i (ACE_HANDLE handle, 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, @@ -1620,9 +1842,12 @@ ACE::sendv_n_i (ACE_HANDLE handle, 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; ) @@ -1633,6 +1858,7 @@ ACE::sendv_n_i (ACE_HANDLE handle, ssize_t n = ACE_OS::sendv (handle, iov + s, iovcnt - s); + // Check for errors. if (n == 0 || n == -1) @@ -1644,6 +1870,7 @@ ACE::sendv_n_i (ACE_HANDLE handle, // Wait upto for the blocking to subside. int rtn = ACE::handle_write_ready (handle, timeout); + // Did select() succeed? if (rtn != -1) { @@ -1653,17 +1880,20 @@ ACE::sendv_n_i (ACE_HANDLE handle, 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); @@ -1671,7 +1901,9 @@ ACE::sendv_n_i (ACE_HANDLE handle, iov[s].iov_len = iov[s].iov_len - n; } } + ACE::restore_non_blocking_mode (handle, val); + if (error) { return result; @@ -1681,6 +1913,7 @@ ACE::sendv_n_i (ACE_HANDLE handle, return ACE_Utils::truncate_cast (bytes_transferred); } } + ssize_t ACE::write_n (ACE_HANDLE handle, const ACE_Message_Block *message_block, @@ -1689,30 +1922,37 @@ ACE::write_n (ACE_HANDLE handle, 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 @@ -1720,43 +1960,55 @@ ACE::write_n (ACE_HANDLE handle, 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, @@ -1766,30 +2018,37 @@ ACE::send_n (ACE_HANDLE handle, 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 @@ -1797,47 +2056,59 @@ ACE::send_n (ACE_HANDLE handle, 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, @@ -1847,6 +2118,7 @@ ACE::readv_n (ACE_HANDLE handle, size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; bytes_transferred = 0; + for (int s = 0; s < iovcnt; ) @@ -1854,13 +2126,16 @@ ACE::readv_n (ACE_HANDLE handle, 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); @@ -1868,8 +2143,10 @@ ACE::readv_n (ACE_HANDLE handle, 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, @@ -1879,7 +2156,9 @@ ACE::writev_n (ACE_HANDLE handle, 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; ) @@ -1887,15 +2166,18 @@ ACE::writev_n (ACE_HANDLE handle, 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); @@ -1903,8 +2185,10 @@ ACE::writev_n (ACE_HANDLE handle, 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, @@ -1915,14 +2199,18 @@ ACE::handle_ready (ACE_HANDLE handle, #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) @@ -1937,7 +2225,9 @@ ACE::handle_ready (ACE_HANDLE handle, 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. @@ -1952,6 +2242,7 @@ ACE::handle_ready (ACE_HANDLE handle, return result; } } + int ACE::enter_recv_timedwait (ACE_HANDLE handle, const ACE_Time_Value *timeout, @@ -1959,12 +2250,16 @@ ACE::enter_recv_timedwait (ACE_HANDLE handle, { 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, @@ -1972,12 +2267,16 @@ ACE::enter_send_timedwait (ACE_HANDLE handle, { 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) @@ -1985,11 +2284,13 @@ ACE::record_and_set_non_blocking_mode (ACE_HANDLE handle, // 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) @@ -2005,9 +2306,11 @@ ACE::restore_non_blocking_mode (ACE_HANDLE handle, } } + // 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, @@ -2015,17 +2318,23 @@ ACE::format_hexdump (const char *buffer, 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] @@ -2041,13 +2350,17 @@ ACE::format_hexdump (const char *buffer, } 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++) @@ -2065,6 +2378,7 @@ ACE::format_hexdump (const char *buffer, } textver[i] = ACE_OS::ace_isprint (c) ? c : '.'; } + for (i = size % 16; i < 16; i++) { ACE_OS::sprintf (obuf, @@ -2078,6 +2392,7 @@ ACE::format_hexdump (const char *buffer, } textver[i] = ' '; } + textver[i] = 0; ACE_OS::sprintf (obuf, ACE_TEXT (" %s\n"), @@ -2085,20 +2400,24 @@ ACE::format_hexdump (const char *buffer, } 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. @@ -2112,6 +2431,7 @@ ACE::timestamp (ACE_TCHAR date_and_time[], ACE_TEXT ("Fri"), ACE_TEXT ("Sat") }; + static const ACE_TCHAR *month_name[] = { ACE_TEXT ("Jan"), @@ -2127,8 +2447,10 @@ ACE::timestamp (ACE_TCHAR date_and_time[], 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], @@ -2144,6 +2466,7 @@ ACE::timestamp (ACE_TCHAR date_and_time[], 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)); @@ -2172,48 +2495,64 @@ ACE::timestamp (ACE_TCHAR date_and_time[], 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, @@ -2222,7 +2561,9 @@ ACE::handle_timed_complete (ACE_HANDLE h, 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, @@ -2231,6 +2572,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, 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). @@ -2240,6 +2582,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, 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 @@ -2247,6 +2590,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, // 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. @@ -2257,17 +2601,20 @@ ACE::handle_timed_complete (ACE_HANDLE h, } #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 @@ -2281,6 +2628,7 @@ ACE::handle_timed_complete (ACE_HANDLE 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) @@ -2292,6 +2640,7 @@ ACE::handle_timed_complete (ACE_HANDLE h, { h = ACE_INVALID_HANDLE; } + if (sock_err != 0 || known_failure) { h = ACE_INVALID_HANDLE; @@ -2299,9 +2648,11 @@ ACE::handle_timed_complete (ACE_HANDLE h, } #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. @@ -2317,13 +2668,16 @@ ACE::handle_timed_complete (ACE_HANDLE h, } #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, @@ -2333,21 +2687,29 @@ ACE::handle_timed_accept (ACE_HANDLE listener, // 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) @@ -2361,6 +2723,7 @@ ACE::handle_timed_accept (ACE_HANDLE listener, rd_handle, 0, 0, timeout); #endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ + switch (n) { case -1: @@ -2388,8 +2751,10 @@ ACE::handle_timed_accept (ACE_HANDLE listener, } } } + // 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, @@ -2398,44 +2763,58 @@ ACE::daemonize (const ACE_TCHAR pathname[], 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) @@ -2452,6 +2831,7 @@ ACE::fork (const ACE_TCHAR *program_name, // // 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) { @@ -2466,10 +2846,12 @@ ACE::fork (const ACE_TCHAR *program_name, 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))) { @@ -2482,9 +2864,11 @@ ACE::fork (const ACE_TCHAR *program_name, else // child didn't call exit(); perhaps it received a signal? errno = EINTR; + return -1; } } + int ACE::max_handles (void) { @@ -2501,6 +2885,7 @@ ACE::max_handles (void) // 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) @@ -2511,10 +2896,12 @@ ACE::max_handles (void) 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) @@ -2522,17 +2909,22 @@ ACE::set_handle_limit (int new_limit, 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; @@ -2564,8 +2956,10 @@ ACE::set_handle_limit (int new_limit, return 0; #endif /* ACE_LACKS_RLIMIT */ } + return 0; } + // Euclid's greatest common divisor algorithm. u_long ACE::gcd (u_long x, u_long y) @@ -2576,9 +2970,11 @@ ACE::gcd (u_long x, u_long 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) @@ -2593,8 +2989,10 @@ ACE::minimum_frame_size (u_long period1, u_long 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) { @@ -2620,6 +3018,7 @@ ACE::minimum_frame_size (u_long period1, u_long period2) } } + u_long ACE::is_prime (const u_long n, const u_long min_factor, @@ -2631,13 +3030,16 @@ ACE::is_prime (const u_long n, ++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: @@ -2783,6 +3185,7 @@ ACE::sock_error (int error) ACE_NOTSUP_RETURN (0); #endif /* ACE_WIN32 */ } + bool ACE::is_sock_error (int error) { @@ -2841,35 +3244,43 @@ ACE::is_sock_error (int 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 ( @@ -2878,35 +3289,43 @@ ACE::strndup (const wchar_t *str, size_t n) 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], @@ -2914,22 +3333,27 @@ ACE::strnnew (const wchar_t *str, size_t n) 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) { @@ -2944,6 +3368,7 @@ ACE::strnew (const char *s) else return ACE_OS::strcpy (t, s); } + #if defined (ACE_HAS_WCHAR) wchar_t * ACE::strnew (const wchar_t *s) @@ -2960,12 +3385,14 @@ ACE::strnew (const wchar_t *s) 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) { @@ -2973,6 +3400,7 @@ ACE::wild_match(const char* str, const char* pat, bool case_sensitive) return true; if (pat == 0 || str == 0) return false; + bool star = false; const char* s = str; const char* p = pat; @@ -2983,6 +3411,7 @@ ACE::wild_match(const char* str, const char* pat, bool case_sensitive) star = true; pat = p; while (*++pat == '*') {} + if (*pat == '\0') return true; p = pat; @@ -3007,8 +3436,10 @@ ACE::wild_match(const char* str, const char* pat, bool case_sensitive) } 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 index 15c05da00de..ea7a3fa02e4 100644 --- a/dep/ACE_wrappers/ace/ACE.h +++ b/dep/ACE_wrappers/ace/ACE.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file ACE.h @@ -15,13 +16,18 @@ * @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" @@ -29,16 +35,20 @@ #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 * @@ -53,26 +63,35 @@ 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 * @@ -127,21 +146,27 @@ namespace ACE 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, @@ -149,6 +174,7 @@ namespace ACE struct sockaddr *addr, int *addrlen, const ACE_Time_Value *timeout = 0); + ACE_NAMESPACE_INLINE_FUNCTION ssize_t recv_n (ACE_HANDLE handle, void *buf, @@ -156,7 +182,9 @@ namespace ACE 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, @@ -164,13 +192,16 @@ namespace ACE 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 @@ -182,40 +213,50 @@ namespace ACE * @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, @@ -223,6 +264,7 @@ namespace ACE 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, @@ -230,7 +272,9 @@ namespace ACE 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, @@ -238,25 +282,31 @@ namespace ACE 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. @@ -264,32 +314,39 @@ namespace ACE 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 @@ -298,6 +355,7 @@ namespace ACE 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 @@ -308,6 +366,7 @@ namespace ACE 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 @@ -316,12 +375,14 @@ namespace ACE */ 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) /** @@ -332,28 +393,40 @@ namespace ACE */ 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, @@ -371,6 +444,7 @@ namespace ACE * 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 @@ -379,6 +453,7 @@ namespace ACE 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 @@ -388,6 +463,7 @@ namespace ACE 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 @@ -402,6 +478,7 @@ namespace ACE 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; @@ -414,6 +491,7 @@ namespace ACE 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 @@ -424,47 +502,63 @@ namespace ACE 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 @@ -476,23 +570,28 @@ namespace ACE 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 @@ -502,6 +601,7 @@ namespace ACE * 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 @@ -513,169 +613,213 @@ namespace ACE 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 index 0df84c2c08c..f800ac80a32 100644 --- a/dep/ACE_wrappers/ace/ACE.inl +++ b/dep/ACE_wrappers/ace/ACE.inl @@ -1,14 +1,18 @@ // -*- 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, @@ -20,6 +24,7 @@ ACE::read_n (ACE_HANDLE handle, len, bytes_transferred); } + ACE_INLINE ssize_t ACE::write_n (ACE_HANDLE handle, const void *buf, @@ -31,6 +36,7 @@ ACE::write_n (ACE_HANDLE handle, len, bytes_transferred); } + ACE_INLINE ssize_t ACE::recv_n (ACE_HANDLE handle, void *buf, @@ -53,7 +59,9 @@ ACE::recv_n (ACE_HANDLE handle, timeout, bytes_transferred); } + #if defined (ACE_HAS_TLI) + ACE_INLINE ssize_t ACE::t_rcv_n (ACE_HANDLE handle, void *buf, @@ -76,7 +84,9 @@ ACE::t_rcv_n (ACE_HANDLE handle, timeout, bytes_transferred); } + #endif /* ACE_HAS_TLI */ + ACE_INLINE ssize_t ACE::recv_n (ACE_HANDLE handle, void *buf, @@ -96,6 +106,7 @@ ACE::recv_n (ACE_HANDLE handle, timeout, bytes_transferred); } + ACE_INLINE ssize_t ACE::recvv_n (ACE_HANDLE handle, iovec *iov, @@ -115,6 +126,7 @@ ACE::recvv_n (ACE_HANDLE handle, timeout, bytes_transferred); } + ACE_INLINE ssize_t ACE::send_n (ACE_HANDLE handle, const void *buf, @@ -137,7 +149,9 @@ ACE::send_n (ACE_HANDLE handle, timeout, bytes_transferred); } + #if defined (ACE_HAS_TLI) + ACE_INLINE ssize_t ACE::t_snd_n (ACE_HANDLE handle, const void *buf, @@ -160,7 +174,9 @@ ACE::t_snd_n (ACE_HANDLE handle, timeout, bytes_transferred); } + #endif /* ACE_HAS_TLI */ + ACE_INLINE ssize_t ACE::send_n (ACE_HANDLE handle, const void *buf, @@ -180,6 +196,7 @@ ACE::send_n (ACE_HANDLE handle, timeout, bytes_transferred); } + ACE_INLINE ssize_t ACE::sendv_n (ACE_HANDLE handle, const iovec *iov, @@ -199,6 +216,7 @@ ACE::sendv_n (ACE_HANDLE handle, timeout, bytes_transferred); } + ACE_INLINE ssize_t ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len) { @@ -208,6 +226,7 @@ ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len) 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) { @@ -217,6 +236,7 @@ ACE::recv_i (ACE_HANDLE handle, void *buf, size_t len) 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) @@ -227,6 +247,7 @@ ACE::handle_read_ready (ACE_HANDLE handle, 0, 0); } + ACE_INLINE int ACE::handle_write_ready (ACE_HANDLE handle, const ACE_Time_Value *timeout) @@ -237,6 +258,7 @@ ACE::handle_write_ready (ACE_HANDLE handle, 1, 0); } + ACE_INLINE int ACE::handle_exception_ready (ACE_HANDLE handle, const ACE_Time_Value *timeout) @@ -247,11 +269,13 @@ ACE::handle_exception_ready (ACE_HANDLE handle, 0, 1); } + ACE_INLINE void ACE::strdelete (char *s) { delete [] s; } + #if defined (ACE_HAS_WCHAR) ACE_INLINE void ACE::strdelete (wchar_t *s) @@ -259,6 +283,7 @@ ACE::strdelete (wchar_t *s) delete [] s; } #endif /* ACE_HAS_WCHAR */ + ACE_INLINE void ACE::unique_name (const void *object, ACE_TCHAR *name, @@ -266,14 +291,18 @@ ACE::unique_name (const void *object, { 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) { @@ -287,9 +316,11 @@ ACE::nibble2hex (u_int n) #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) { @@ -300,8 +331,10 @@ ACE::map_errno (int error) return EAGAIN; // Same as UNIX errno EWOULDBLOCK. } #endif /* ACE_WIN32 */ + return error; } + ACE_INLINE u_char ACE::hex2byte (ACE_TCHAR c) { @@ -312,5 +345,6 @@ ACE::hex2byte (ACE_TCHAR c) 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 index 9439f5641f3..e29a6426187 100644 --- a/dep/ACE_wrappers/ace/ACE_crc32.cpp +++ b/dep/ACE_wrappers/ace/ACE_crc32.cpp @@ -1,9 +1,12 @@ // $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 { /*****************************************************************/ @@ -25,6 +28,7 @@ namespace /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ /* */ /*****************************************************************/ + const ACE_UINT32 crc_table[] = { 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, @@ -92,29 +96,37 @@ namespace 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; @@ -122,12 +134,15 @@ ACE::crc32 (const void *buffer, size_t len, ACE_UINT32 crc) { 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, @@ -136,9 +151,12 @@ ACE::crc32 (const iovec *iov, int len, ACE_UINT32 crc) ++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 index 58ec401d004..4e9b4a2f98e 100644 --- a/dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp +++ b/dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp @@ -1,8 +1,11 @@ // $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 { /*****************************************************************/ @@ -24,6 +27,7 @@ namespace /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ /* */ /*****************************************************************/ + const ACE_UINT16 crc_table[] = { 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, @@ -59,29 +63,37 @@ namespace 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; @@ -89,12 +101,15 @@ ACE::crc_ccitt (const void *buffer, size_t len, ACE_UINT16 crc) { 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, @@ -103,9 +118,12 @@ ACE::crc_ccitt (const iovec *iov, int len, ACE_UINT16 crc) ++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 index 94708a2f38b..60e79b01f1f 100644 --- a/dep/ACE_wrappers/ace/ACE_export.h +++ b/dep/ACE_wrappers/ace/ACE_export.h @@ -4,10 +4,14 @@ // 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 */ @@ -16,6 +20,7 @@ # 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) @@ -37,12 +42,14 @@ # 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) || \ @@ -63,6 +70,8 @@ # define ACE_INLINE_TEMPLATE_FUNCTION # endif #endif + #endif /* ACE_EXPORT_H */ + // End of auto generated file. diff --git a/dep/ACE_wrappers/ace/ARGV.h b/dep/ACE_wrappers/ace/ARGV.h index 3d98f53909d..c2995a451f2 100644 --- a/dep/ACE_wrappers/ace/ARGV.h +++ b/dep/ACE_wrappers/ace/ARGV.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file ARGV.h @@ -9,17 +10,23 @@ * @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 * @@ -32,6 +39,7 @@ public: // = Initialization and termination. /// Initialize a ACE_ARGV_Queue_Entry_T. ACE_ARGV_Queue_Entry_T (void); + /** * Initialize a ACE_ARGV_Queue_Entry_T. * @@ -42,24 +50,31 @@ public: */ 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 * @@ -97,6 +112,7 @@ public: */ 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 @@ -123,6 +139,7 @@ public: 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 @@ -145,6 +162,7 @@ public: 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. * @@ -167,14 +185,17 @@ public: 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. @@ -189,25 +210,32 @@ public: * @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. * @@ -226,6 +254,7 @@ public: * - 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. * @@ -245,44 +274,61 @@ public: * - 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 index 07e598eb57c..fdc5b13d7c3 100644 --- a/dep/ACE_wrappers/ace/ARGV.inl +++ b/dep/ACE_wrappers/ace/ARGV.inl @@ -1,8 +1,11 @@ /* -*- 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), @@ -10,6 +13,7 @@ ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (void) { // No-op } + template ACE_INLINE ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg, bool quote_arg) @@ -18,6 +22,7 @@ ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *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_), @@ -25,11 +30,13 @@ ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_ { // 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 @@ -42,43 +49,56 @@ ACE_ARGV_T::argc (void) const (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 index 39a37a63c5f..0a58b7f3b1f 100644 --- a/dep/ACE_wrappers/ace/ATM_Acceptor.cpp +++ b/dep/ACE_wrappers/ace/ATM_Acceptor.cpp @@ -1,36 +1,49 @@ // $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, @@ -44,17 +57,21 @@ ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr) ::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) { @@ -63,12 +80,15 @@ ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr) 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, @@ -87,9 +107,12 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, 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, @@ -101,7 +124,9 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, ::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; @@ -111,6 +136,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, 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), @@ -118,6 +144,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, 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) @@ -125,14 +152,17 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, 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 (), @@ -147,6 +177,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, errno); return (ACE_INVALID_HANDLE); } + ((ACE_SOCK_Acceptor *)this) -> set_handle (handle); if (ACE_OS::setsockopt (handle, SOL_ATM, @@ -156,8 +187,10 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, 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); @@ -170,6 +203,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, 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)), @@ -189,6 +223,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, errno); return -1; } + return 0; #else ACE_UNUSED_ARG (remote_sap); @@ -196,6 +231,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, 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, @@ -208,6 +244,7 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap, 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, @@ -222,19 +259,24 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap, 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, @@ -242,6 +284,7 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap, sizeof (accept_qos)) < 0) { ACE_OS::printf ("Acceptor (accept): error setting Qos"); } + return (acceptor_.accept (new_sap.get_stream (), remote_addr, timeout, @@ -258,8 +301,10 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap, 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 index dc18425f25e..900cec098c5 100644 --- a/dep/ACE_wrappers/ace/ATM_Acceptor.h +++ b/dep/ACE_wrappers/ace/ATM_Acceptor.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file ATM_Acceptor.h @@ -9,20 +10,27 @@ */ //============================================================================= + #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 @@ -34,10 +42,13 @@ 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 * @@ -48,22 +59,29 @@ class ACE_Time_Value; */ 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." @@ -74,24 +92,32 @@ public: 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 index e1b38a713f7..fa60c4ad89a 100644 --- a/dep/ACE_wrappers/ace/ATM_Acceptor.inl +++ b/dep/ACE_wrappers/ace/ATM_Acceptor.inl @@ -1,8 +1,10 @@ // -*- 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 { @@ -10,12 +12,14 @@ ACE_ATM_Acceptor::dump (void) const 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 @@ -23,6 +27,7 @@ ACE_ATM_Acceptor::ACE_ATM_Acceptor (const ACE_Addr &remote_sap, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_ATM_Acceptor::ACE_ATM_Acceptor"))); } + ACE_INLINE int ACE_ATM_Acceptor::close (void) @@ -33,5 +38,6 @@ ACE_ATM_Acceptor::close (void) 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 index 8e09eb9d355..8b4781c5e80 100644 --- a/dep/ACE_wrappers/ace/ATM_Addr.cpp +++ b/dep/ACE_wrappers/ace/ATM_Addr.cpp @@ -1,17 +1,26 @@ // $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. @@ -33,7 +42,9 @@ 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, @@ -50,7 +61,9 @@ ACE_ATM_Addr::ACE_ATM_Addr (u_char selector) 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) @@ -71,6 +84,7 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap, 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) @@ -86,6 +100,7 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ATM_Addr *sap, 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) @@ -100,16 +115,20 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ACE_TCHAR sap[], 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) { @@ -119,16 +138,22 @@ ACE_ATM_Addr::init (u_char selector) // 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); @@ -141,6 +166,7 @@ ACE_ATM_Addr::init (u_char selector) 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; @@ -157,30 +183,38 @@ ACE_ATM_Addr::init (u_char selector) 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) @@ -189,31 +223,39 @@ ACE_ATM_Addr::set (const ATM_Addr *sap, 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) @@ -225,6 +267,7 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[]) #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) { @@ -253,11 +296,14 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[]) 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; @@ -272,13 +318,16 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[]) 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) { @@ -287,6 +336,7 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[]) return -1; } } + if (WSALookupServiceEnd (hLookup) == SOCKET_ERROR) { ACE_OS::printf ("Error : WSALookupServiceEnd failed! %d \n", ::WSAGetLastError ()); @@ -298,6 +348,7 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[]) errno = EINVAL; return -1; } + if (text2atm ((ACE_TCHAR *)sap, (struct sockaddr *)& (atm_addr_.sockaddratmsvc), sizeof (atm_addr_.sockaddratmsvc), @@ -309,18 +360,23 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[]) } #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; @@ -330,25 +386,32 @@ ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[], 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]; @@ -365,6 +428,7 @@ ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[], else ACE_OS::strcpy (addr, buffer); + return 0; #else ACE_UNUSED_ARG (addr); @@ -372,21 +436,26 @@ ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[], 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) @@ -398,18 +467,23 @@ ACE_ATM_Addr::set_addr (void *addr, int 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), @@ -425,12 +499,15 @@ ACE_ATM_Addr::operator == (const ACE_ATM_Addr &sap) const 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"), @@ -439,6 +516,8 @@ ACE_ATM_Addr::dump (void) const 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 index 594ceddce2f..c111aa44843 100644 --- a/dep/ACE_wrappers/ace/ATM_Addr.h +++ b/dep/ACE_wrappers/ace/ATM_Addr.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file ATM_Addr.h @@ -8,16 +9,22 @@ * @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; @@ -28,9 +35,12 @@ 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 { @@ -40,6 +50,7 @@ typedef struct _linux_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 * @@ -53,12 +64,15 @@ public: 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 @@ -66,6 +80,7 @@ public: */ 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., @@ -74,15 +89,19 @@ public: */ 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 @@ -90,6 +109,7 @@ public: */ int set (const ATM_Addr *, u_char selector = DEFAULT_SELECTOR); + /** * Initializes an ACE_ATM_Addr from the which can be * "atm-address" (e.g., @@ -98,6 +118,7 @@ public: */ 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., @@ -105,6 +126,7 @@ public: * (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 @@ -114,6 +136,7 @@ public: */ 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 @@ -122,40 +145,53 @@ public: * 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 index 4aa694a21bf..55f43d6613a 100644 --- a/dep/ACE_wrappers/ace/ATM_Addr.inl +++ b/dep/ACE_wrappers/ace/ATM_Addr.inl @@ -1,7 +1,9 @@ // -*- 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 { @@ -16,6 +18,7 @@ ACE_ATM_Addr::get_selector (void) const 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) { @@ -30,4 +33,5 @@ ACE_ATM_Addr::set_selector (u_char selector) 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 index ad466ed20f2..7d68ed88bd2 100644 --- a/dep/ACE_wrappers/ace/ATM_Connector.cpp +++ b/dep/ACE_wrappers/ace/ATM_Connector.cpp @@ -1,22 +1,31 @@ // 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, @@ -45,23 +54,29 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream, #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); @@ -69,10 +84,12 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream, 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, @@ -90,13 +107,16 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream, 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); @@ -111,7 +131,9 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream, 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 index f45d5c5521f..e8657e91a23 100644 --- a/dep/ACE_wrappers/ace/ATM_Connector.h +++ b/dep/ACE_wrappers/ace/ATM_Connector.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file ATM_Connector.h @@ -8,17 +9,23 @@ * @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 @@ -31,8 +38,10 @@ 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 * @@ -45,6 +54,7 @@ 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 @@ -74,6 +84,7 @@ public: 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 @@ -104,6 +115,7 @@ public: 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 @@ -113,6 +125,7 @@ public: 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 @@ -121,23 +134,31 @@ public: 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 index 85d61406bde..0b89cbf0828 100644 --- a/dep/ACE_wrappers/ace/ATM_Connector.inl +++ b/dep/ACE_wrappers/ace/ATM_Connector.inl @@ -1,8 +1,10 @@ // -*- 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 { @@ -10,6 +12,7 @@ ACE_ATM_Connector::dump (void) const 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, @@ -35,7 +38,9 @@ ACE_ATM_Connector::ACE_ATM_Connector (ACE_ATM_Stream &new_stream, 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, @@ -54,6 +59,7 @@ ACE_ATM_Connector::complete (ACE_ATM_Stream &new_stream, return 0; #endif } + ACE_INLINE int ACE_ATM_Connector::add_leaf (ACE_ATM_Stream ¤t_stream, @@ -70,26 +76,33 @@ ACE_ATM_Connector::add_leaf (ACE_ATM_Stream ¤t_stream, 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); @@ -99,6 +112,7 @@ ACE_ATM_Connector::add_leaf (ACE_ATM_Stream ¤t_stream, return 0; #endif } + ACE_INLINE int ACE_ATM_Connector::reset_new_handle (ACE_HANDLE handle) @@ -113,5 +127,6 @@ ACE_ATM_Connector::reset_new_handle (ACE_HANDLE 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 index ffa018ff645..d3e5116b0f8 100644 --- a/dep/ACE_wrappers/ace/ATM_Params.cpp +++ b/dep/ACE_wrappers/ace/ATM_Params.cpp @@ -1,12 +1,21 @@ // $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 index 93c36d9b8ba..a244644915d 100644 --- a/dep/ACE_wrappers/ace/ATM_Params.h +++ b/dep/ACE_wrappers/ace/ATM_Params.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file ATM_Params.h @@ -9,15 +10,21 @@ */ //========================================================================== + #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 @@ -41,7 +48,9 @@ typedef int Param_Udata; 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 * @@ -77,88 +86,129 @@ public: = 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 index 0118ac392d6..de2a4d45127 100644 --- a/dep/ACE_wrappers/ace/ATM_Params.inl +++ b/dep/ACE_wrappers/ace/ATM_Params.inl @@ -1,7 +1,9 @@ // -*- 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 { @@ -9,6 +11,7 @@ ACE_ATM_Params::dump (void) const ACE_TRACE ("ACE_ATM_Params::dump"); #endif /* ACE_HAS_DUMP */ } + ACE_INLINE ACE_ATM_Params::ACE_ATM_Params (int rw_flag, const char device[], @@ -37,12 +40,14 @@ ACE_ATM_Params::ACE_ATM_Params (int rw_flag, { 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 @@ -50,6 +55,7 @@ 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) @@ -57,6 +63,7 @@ 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 @@ -64,6 +71,7 @@ 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) @@ -71,6 +79,7 @@ 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 @@ -78,6 +87,7 @@ 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) @@ -85,6 +95,7 @@ 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 ) @@ -92,6 +103,7 @@ 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 ) @@ -99,6 +111,7 @@ 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 ) @@ -106,6 +119,7 @@ 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 ) @@ -113,6 +127,7 @@ 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 ) @@ -120,6 +135,7 @@ 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) @@ -127,6 +143,7 @@ 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 @@ -134,6 +151,7 @@ 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) @@ -141,6 +159,7 @@ 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 @@ -148,6 +167,7 @@ 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 @@ -155,6 +175,7 @@ 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) @@ -162,6 +183,7 @@ 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 @@ -169,6 +191,7 @@ 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) @@ -176,6 +199,7 @@ 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 @@ -183,6 +207,7 @@ 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) @@ -190,6 +215,7 @@ 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 @@ -197,6 +223,7 @@ 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) @@ -204,4 +231,5 @@ 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 index 5d4ea5ae673..60e4cafad3f 100644 --- a/dep/ACE_wrappers/ace/ATM_QoS.cpp +++ b/dep/ACE_wrappers/ace/ATM_QoS.cpp @@ -1,11 +1,17 @@ // $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. @@ -30,7 +36,9 @@ 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"); @@ -45,6 +53,7 @@ ACE_ATM_QoS::ACE_ATM_QoS (int pktSize) ACE_UNUSED_ARG (pktSize); #endif /* ACE_HAS_LINUX_ATM */ } + ACE_ATM_QoS::ACE_ATM_QoS(int rate, int pktSize) { @@ -56,6 +65,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, 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 @@ -64,7 +74,9 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, = 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; @@ -72,6 +84,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, 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; @@ -79,22 +92,29 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, 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, @@ -104,18 +124,21 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, } 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 ) @@ -124,12 +147,14 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, 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; @@ -139,6 +164,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, // 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; @@ -148,6 +174,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, // 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, @@ -170,6 +197,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, 0, 15, ACE_DEFAULT_THREAD_PRIORITY ); + qos_.sending_flowspec (send_fspec); qos_.receiving_flowspec (recv_fspec); #elif defined (ACE_HAS_FORE_ATM_XTI) @@ -181,6 +209,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, 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; @@ -191,11 +220,13 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate, 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) @@ -210,7 +241,9 @@ ACE_ATM_QoS::set_cbr_rate (int rate, 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 @@ -221,7 +254,9 @@ ACE_ATM_QoS::set_cbr_rate (int rate, = 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; @@ -229,6 +264,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate, 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; @@ -236,22 +272,29 @@ ACE_ATM_QoS::set_cbr_rate (int rate, 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, @@ -261,18 +304,21 @@ ACE_ATM_QoS::set_cbr_rate (int rate, } 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 ) + @@ -281,12 +327,14 @@ ACE_ATM_QoS::set_cbr_rate (int rate, 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. @@ -306,6 +354,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate, 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; @@ -315,6 +364,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate, // 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; @@ -324,6 +374,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate, // 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, @@ -347,6 +398,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate, 0, 15, ACE_DEFAULT_THREAD_PRIORITY ); + qos_.sending_flowspec( send_fspec ); qos_.receiving_flowspec( recv_fspec ); */ @@ -355,6 +407,7 @@ ACE_ATM_QoS::set_cbr_rate (int 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; @@ -363,6 +416,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate, 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, @@ -371,6 +425,7 @@ ACE_ATM_QoS::set_rate (ACE_HANDLE fd, 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) @@ -384,6 +439,7 @@ ACE_ATM_QoS::set_rate (ACE_HANDLE fd, 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, @@ -401,35 +457,46 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd, 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, @@ -441,30 +508,39 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd, 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; @@ -476,18 +552,23 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd, 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; @@ -495,6 +576,7 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd, 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)) @@ -504,27 +586,35 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd, 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); @@ -534,6 +624,9 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd, 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 index 48b5bae5bb7..3e839fb50d1 100644 --- a/dep/ACE_wrappers/ace/ATM_QoS.h +++ b/dep/ACE_wrappers/ace/ATM_QoS.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file ATM_QoS.h @@ -9,14 +10,19 @@ */ //========================================================================== + #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 @@ -37,7 +43,9 @@ 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 * @@ -56,39 +64,52 @@ public: 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 index 90097eeae01..52b5211190d 100644 --- a/dep/ACE_wrappers/ace/ATM_QoS.inl +++ b/dep/ACE_wrappers/ace/ATM_QoS.inl @@ -1,7 +1,9 @@ // -*- 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 { @@ -9,11 +11,13 @@ ACE_ATM_QoS::dump (void) const 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) @@ -21,4 +25,5 @@ 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 index ef0d32304fb..83b4625436d 100644 --- a/dep/ACE_wrappers/ace/ATM_Stream.cpp +++ b/dep/ACE_wrappers/ace/ATM_Stream.cpp @@ -1,12 +1,19 @@ // $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 { @@ -24,6 +31,7 @@ ACE_ATM_Stream::get_peer_name (void) const // ::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); @@ -32,8 +40,10 @@ ACE_ATM_Stream::get_peer_name (void) const // 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 (); @@ -43,16 +53,19 @@ ACE_ATM_Stream::get_peer_name (void) const // 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'; @@ -63,8 +76,10 @@ ACE_ATM_Stream::get_peer_name (void) const 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]; @@ -85,16 +100,19 @@ ACE_ATM_Stream::get_peer_name (void) const 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, @@ -103,11 +121,13 @@ ACE_ATM_Stream::get_peer_name (void) const 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 { @@ -118,6 +138,7 @@ ACE_ATM_Stream::get_handle (void) const 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 @@ -129,12 +150,14 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi, 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) { @@ -143,6 +166,7 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi, info.options); return -1; } + char *buf_ret = (char *) ACE_OS::malloc (info.options); if (buf_ret == 0) { @@ -151,41 +175,52 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi, 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, @@ -198,8 +233,10 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi, == 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 */ @@ -217,6 +254,7 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi, } 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; @@ -232,18 +270,22 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi, } 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 index 5c68845d5c6..e880f7197d4 100644 --- a/dep/ACE_wrappers/ace/ATM_Stream.h +++ b/dep/ACE_wrappers/ace/ATM_Stream.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file ATM_Stream.h @@ -9,16 +10,22 @@ */ //============================================================================= + #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 @@ -30,7 +37,9 @@ 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 * @@ -42,42 +51,57 @@ 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 index 8d00a413f05..087c1ed440b 100644 --- a/dep/ACE_wrappers/ace/ATM_Stream.inl +++ b/dep/ACE_wrappers/ace/ATM_Stream.inl @@ -1,7 +1,9 @@ // -*- 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 { @@ -9,11 +11,13 @@ ACE_ATM_Stream::dump (void) const 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) @@ -26,6 +30,7 @@ ACE_ATM_Stream::open (ACE_ATM_Params params) 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(), @@ -35,7 +40,9 @@ ACE_ATM_Stream::open (ACE_ATM_Params params) 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; @@ -50,12 +57,14 @@ ACE_ATM_Stream::open (ACE_ATM_Params params) 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) @@ -67,6 +76,7 @@ ACE_ATM_Stream::close (void) return 0; #endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ } + ACE_INLINE ATM_Stream& ACE_ATM_Stream::get_stream (void) @@ -74,6 +84,7 @@ 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, @@ -95,6 +106,7 @@ ACE_ATM_Stream::recv (void *buf, return (0); #endif /* ACE_HAS_FORE_ATM_XTI */ } + ACE_INLINE ssize_t ACE_ATM_Stream::send_n (const void *buf, @@ -117,4 +129,5 @@ ACE_ATM_Stream::send_n (const void *buf, return (0); #endif /* ACE_HAS_FORE_ATM_XTI */ } + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Acceptor.h b/dep/ACE_wrappers/ace/Acceptor.h index 4e3ad904517..855b2f877a3 100644 --- a/dep/ACE_wrappers/ace/Acceptor.h +++ b/dep/ACE_wrappers/ace/Acceptor.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Acceptor.h @@ -8,16 +9,23 @@ * @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 * @@ -45,14 +53,17 @@ 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 @@ -91,6 +102,7 @@ public: 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 @@ -132,27 +144,37 @@ public: 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. @@ -162,12 +184,14 @@ protected: * 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 @@ -179,33 +203,43 @@ protected: * 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 @@ -213,12 +247,15 @@ protected: * 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 * @@ -238,6 +275,7 @@ class ACE_Strategy_Acceptor : public ACE_Acceptor { public: + // Useful STL-style traits. typedef ACE_Creation_Strategy creation_strategy_type; @@ -248,17 +286,21 @@ public: 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} @@ -275,6 +317,7 @@ public: 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. @@ -314,6 +357,7 @@ public: 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} @@ -330,33 +374,47 @@ public: 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 @@ -368,12 +426,14 @@ protected: * 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 @@ -385,45 +445,62 @@ protected: * 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 * @@ -448,13 +525,16 @@ 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 @@ -466,6 +546,7 @@ public: 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 @@ -477,8 +558,10 @@ public: 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}. @@ -487,18 +570,25 @@ public: 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 @@ -509,6 +599,7 @@ protected: * 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, @@ -516,35 +607,45 @@ protected: 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 @@ -554,25 +655,35 @@ private: 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 index f7596987d16..9701af2e236 100644 --- a/dep/ACE_wrappers/ace/Activation_Queue.cpp +++ b/dep/ACE_wrappers/ace/Activation_Queue.cpp @@ -1,15 +1,20 @@ #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 { @@ -25,9 +30,11 @@ ACE_Activation_Queue::dump (void) const //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) @@ -37,6 +44,7 @@ ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue *new_qu { if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); + if (new_queue) this->queue_ = new_queue; else @@ -46,6 +54,7 @@ ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue *new_qu this->delete_queue_ = true; } } + void ACE_Activation_Queue::queue (ACE_Message_Queue *q) { @@ -54,6 +63,7 @@ ACE_Activation_Queue::queue (ACE_Message_Queue *q) { // 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 @@ -62,17 +72,21 @@ ACE_Activation_Queue::queue (ACE_Message_Queue *q) // 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) { @@ -86,11 +100,13 @@ ACE_Activation_Queue::dequeue (ACE_Time_Value *tv) 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. @@ -108,12 +124,16 @@ ACE_Activation_Queue::enqueue (ACE_Method_Request *mr, 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 index cd250bd556f..69197c1b72d 100644 --- a/dep/ACE_wrappers/ace/Activation_Queue.h +++ b/dep/ACE_wrappers/ace/Activation_Queue.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Activation_Queue.h @@ -9,19 +10,28 @@ * @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 * @@ -66,9 +76,12 @@ public: 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 @@ -82,6 +95,7 @@ public: * 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() @@ -103,39 +117,58 @@ public: * 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 index 1fcaf0bfce2..4c0ffc049d3 100644 --- a/dep/ACE_wrappers/ace/Activation_Queue.inl +++ b/dep/ACE_wrappers/ace/Activation_Queue.inl @@ -1,25 +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 index 3ebe4c7c87c..0f3d5485cde 100644 --- a/dep/ACE_wrappers/ace/Active_Map_Manager.cpp +++ b/dep/ACE_wrappers/ace/Active_Map_Manager.cpp @@ -1,6 +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 index 1ad95757379..174009910a6 100644 --- a/dep/ACE_wrappers/ace/Active_Map_Manager.h +++ b/dep/ACE_wrappers/ace/Active_Map_Manager.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Active_Map_Manager.h @@ -9,15 +10,21 @@ */ //============================================================================= + #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 * @@ -32,6 +39,7 @@ 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 @@ -39,30 +47,42 @@ public: */ 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. * @@ -74,18 +94,24 @@ private: { /// 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 index 522dada40ff..df90ada6a00 100644 --- a/dep/ACE_wrappers/ace/Active_Map_Manager.inl +++ b/dep/ACE_wrappers/ace/Active_Map_Manager.inl @@ -1,8 +1,11 @@ // -*- 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) { @@ -11,6 +14,7 @@ ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (void) 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) @@ -18,16 +22,19 @@ ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (ACE_UINT32 slot_index, 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 { @@ -35,32 +42,38 @@ ACE_Active_Map_Manager_Key::operator== (const ACE_Active_Map_Manager_Key &rhs) c 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) { @@ -69,6 +82,7 @@ ACE_Active_Map_Manager_Key::decode (const void *data) data, sizeof this->key_data_); } + ACE_INLINE void ACE_Active_Map_Manager_Key::encode (void *data) const { @@ -77,4 +91,5 @@ ACE_Active_Map_Manager_Key::encode (void *data) const &this->key_data_, sizeof this->key_data_); } + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Active_Map_Manager_T.h b/dep/ACE_wrappers/ace/Active_Map_Manager_T.h index 9e109f85deb..7930628dc94 100644 --- a/dep/ACE_wrappers/ace/Active_Map_Manager_T.h +++ b/dep/ACE_wrappers/ace/Active_Map_Manager_T.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Active_Map_Manager_T.h @@ -9,16 +10,22 @@ */ //============================================================================= + #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 * @@ -32,37 +39,48 @@ 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 @@ -74,10 +92,12 @@ public: */ 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 @@ -86,6 +106,7 @@ public: 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 @@ -95,11 +116,14 @@ public: 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 @@ -109,15 +133,19 @@ public: */ 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 @@ -127,41 +155,58 @@ public: */ 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 index b5731b5ef66..647b55ebd56 100644 --- a/dep/ACE_wrappers/ace/Active_Map_Manager_T.inl +++ b/dep/ACE_wrappers/ace/Active_Map_Manager_T.inl @@ -1,29 +1,38 @@ // -*- 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) @@ -31,25 +40,30 @@ ACE_Active_Map_Manager::bind (const T &value, 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_ || @@ -65,8 +79,10 @@ ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key, // 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 { @@ -74,6 +90,7 @@ ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key) const 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 @@ -81,37 +98,47 @@ ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key, 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, @@ -119,44 +146,60 @@ ACE_Active_Map_Manager::rebind (const ACE_Active_Map_Manager_Key &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) @@ -164,13 +207,16 @@ ACE_Active_Map_Manager::unbind (const ACE_Active_Map_Manager_Key &key, 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) { @@ -178,11 +224,13 @@ ACE_Active_Map_Manager::unbind (const ACE_Active_Map_Manager_Key &key) 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) @@ -190,37 +238,44 @@ ACE_Active_Map_Manager::ACE_Active_Map_Manager (size_t 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 { @@ -228,24 +283,29 @@ ACE_Active_Map_Manager::dump (void) const 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 index c8e88524da3..db6e29c7273 100644 --- a/dep/ACE_wrappers/ace/Addr.cpp +++ b/dep/ACE_wrappers/ace/Addr.cpp @@ -1,57 +1,74 @@ // $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 index fbc0df0d547..fa9b5d757b6 100644 --- a/dep/ACE_wrappers/ace/Addr.h +++ b/dep/ACE_wrappers/ace/Addr.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Addr.h @@ -8,14 +9,20 @@ * @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 * @@ -28,48 +35,70 @@ 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 index 6cc9e27c4cd..44fd495a6e9 100644 --- a/dep/ACE_wrappers/ace/Addr.inl +++ b/dep/ACE_wrappers/ace/Addr.inl @@ -1,47 +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.h b/dep/ACE_wrappers/ace/Arg_Shifter.h index cd043a60886..b5700c9f98f 100644 --- a/dep/ACE_wrappers/ace/Arg_Shifter.h +++ b/dep/ACE_wrappers/ace/Arg_Shifter.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Arg_Shifter.h @@ -8,15 +9,22 @@ * @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 * @@ -62,15 +70,19 @@ public: 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 @@ -104,6 +116,7 @@ public: * 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) * @@ -134,54 +147,76 @@ public: * 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 index 2b4aa1ac5d6..6b0860caaee 100644 --- a/dep/ACE_wrappers/ace/Argv_Type_Converter.cpp +++ b/dep/ACE_wrappers/ace/Argv_Type_Converter.cpp @@ -1,14 +1,20 @@ // $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), @@ -20,11 +26,13 @@ ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, wchar_t** argv) 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) @@ -36,6 +44,7 @@ ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, char **argv) 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])); } @@ -43,6 +52,7 @@ ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, char **argv) { } #endif // ACE_USES_WCHAR + ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void) { #if defined (ACE_USES_WCHAR) @@ -52,8 +62,10 @@ ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void) // 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 @@ -61,12 +73,15 @@ ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void) // 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) @@ -89,11 +104,13 @@ ACE_Argv_Type_Converter::initialize (void) } } + 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 @@ -115,16 +132,20 @@ ACE_Argv_Type_Converter::align_char_with_wchar (void) } } } + // 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 @@ -147,11 +168,14 @@ ACE_Argv_Type_Converter::align_wchar_with_char (void) } } } + // 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) { @@ -169,10 +193,13 @@ ACE_Argv_Type_Converter::cleanup (void) 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 index d8de2b84b4b..957a431a6c3 100644 --- a/dep/ACE_wrappers/ace/Argv_Type_Converter.h +++ b/dep/ACE_wrappers/ace/Argv_Type_Converter.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Argv_Type_Converter.h @@ -8,15 +9,21 @@ * @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 * @@ -32,57 +39,82 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 index b9946d7ea8c..e4b0ed5a059 100644 --- a/dep/ACE_wrappers/ace/Argv_Type_Converter.inl +++ b/dep/ACE_wrappers/ace/Argv_Type_Converter.inl @@ -1,7 +1,9 @@ // -*- 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) { @@ -10,12 +12,14 @@ ACE_Argv_Type_Converter::get_TCHAR_argv (void) { 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) { @@ -24,13 +28,17 @@ ACE_Argv_Type_Converter::get_ASCII_argv (void) { 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 index a6b2008e462..8ef7f094ac8 100644 --- a/dep/ACE_wrappers/ace/Array.h +++ b/dep/ACE_wrappers/ace/Array.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Array.h @@ -13,13 +14,17 @@ * @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.h b/dep/ACE_wrappers/ace/Array_Base.h index fbd8695d5a6..feef89eda01 100644 --- a/dep/ACE_wrappers/ace/Array_Base.h +++ b/dep/ACE_wrappers/ace/Array_Base.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Array_Base.h @@ -8,19 +9,27 @@ * @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 * @@ -34,9 +43,11 @@ 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; @@ -47,21 +58,27 @@ public: 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 @@ -71,18 +88,24 @@ public: * 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 @@ -90,16 +113,20 @@ public: * 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. @@ -107,6 +134,7 @@ public: * It does not affect new_size */ int max_size (size_type new_size); + /** * @name Forward Iterator Accessors * @@ -118,6 +146,7 @@ public: const_iterator begin (void) const; const_iterator end (void) const; //@} + /** * @name Reverse Iterator Accessors * @@ -129,16 +158,21 @@ public: 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 @@ -147,13 +181,18 @@ protected: * 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 * @@ -170,35 +209,49 @@ 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 index b92e0177a85..046c1bffc89 100644 --- a/dep/ACE_wrappers/ace/Array_Base.inl +++ b/dep/ACE_wrappers/ace/Array_Base.inl @@ -1,7 +1,9 @@ // -*- 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) @@ -11,80 +13,95 @@ ACE_Array_Base::~ACE_Array_Base (void) 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 { @@ -92,6 +109,7 @@ ACE_Array_Iterator::dump (void) const // 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), @@ -99,10 +117,12 @@ ACE_Array_Iterator::ACE_Array_Iterator (ACE_Array_Base &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_; @@ -114,10 +134,13 @@ ACE_Array_Iterator::advance (void) 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.h b/dep/ACE_wrappers/ace/Array_Map.h index 435154217a8..18c0dbe1b39 100644 --- a/dep/ACE_wrappers/ace/Array_Map.h +++ b/dep/ACE_wrappers/ace/Array_Map.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Array_Map.h @@ -15,17 +16,24 @@ */ //============================================================================= + #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 * @@ -80,6 +88,7 @@ template > class ACE_Array_Map { public: + // STL-style typedefs/traits. typedef Key key_type; typedef Value data_type; @@ -92,22 +101,28 @@ public: 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 * @@ -119,6 +134,7 @@ public: const_iterator begin (void) const; const_iterator end (void) const; //@} + /** * @name Reverse Iterator Accessors * @@ -130,24 +146,30 @@ public: 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. @@ -158,6 +180,7 @@ public: * 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 @@ -166,23 +189,28 @@ public: /// 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 * @@ -194,18 +222,21 @@ public: * 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 @@ -214,40 +245,57 @@ public: * 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 index 66abdb26f98..b053dc0a441 100644 --- a/dep/ACE_wrappers/ace/Array_Map.inl +++ b/dep/ACE_wrappers/ace/Array_Map.inl @@ -1,7 +1,9 @@ // -*- 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 ( @@ -11,89 +13,105 @@ ACE_Array_Map::ACE_Array_Map ( , 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 ( @@ -102,6 +120,7 @@ ACE_Array_Map::count ( 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[] ( @@ -110,4 +129,5 @@ ACE_Array_Map::operator[] ( 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 index 8d39c3b7291..3faf3426d07 100644 --- a/dep/ACE_wrappers/ace/Assert.cpp +++ b/dep/ACE_wrappers/ace/Assert.cpp @@ -1,8 +1,12 @@ // $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 @@ -10,9 +14,12 @@ __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 index f3bf9f3c335..5bdf56f0531 100644 --- a/dep/ACE_wrappers/ace/Assert.h +++ b/dep/ACE_wrappers/ace/Assert.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Assert.h @@ -8,14 +9,20 @@ * @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)) @@ -25,6 +32,8 @@ ACE_END_VERSIONED_NAMESPACE_DECL ? 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.h b/dep/ACE_wrappers/ace/Asynch_Acceptor.h index 46761275202..e14126d3f1f 100644 --- a/dep/ACE_wrappers/ace/Asynch_Acceptor.h +++ b/dep/ACE_wrappers/ace/Asynch_Acceptor.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Asynch_Acceptor.h @@ -8,21 +9,29 @@ * @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 * @@ -39,8 +48,10 @@ 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 @@ -104,8 +115,10 @@ public: 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 @@ -113,12 +126,14 @@ public: * 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. * @@ -126,6 +141,7 @@ public: * 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 @@ -149,6 +165,7 @@ public: 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. * @@ -161,77 +178,104 @@ public: * 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.h b/dep/ACE_wrappers/ace/Asynch_Connector.h index 1882bf98a6a..64781ad36a5 100644 --- a/dep/ACE_wrappers/ace/Asynch_Connector.h +++ b/dep/ACE_wrappers/ace/Asynch_Connector.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Asynch_Connector.h @@ -8,20 +9,28 @@ * @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 * @@ -32,26 +41,31 @@ class ACE_Message_Block; * 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. @@ -63,6 +77,7 @@ public: */ virtual int cancel (void); + /** * Template method to validate peer before service is opened. * This method is called when the connection attempt completes, @@ -93,48 +108,64 @@ public: 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 index a4a254d91d6..f004fb0d234 100644 --- a/dep/ACE_wrappers/ace/Asynch_IO.cpp +++ b/dep/ACE_wrappers/ace/Asynch_IO.cpp @@ -1,79 +1,99 @@ // $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, @@ -85,6 +105,7 @@ ACE_Asynch_Operation::open (ACE_Handler &handler, completion_key, proactor); } + int ACE_Asynch_Operation::cancel (void) { @@ -95,6 +116,7 @@ ACE_Asynch_Operation::cancel (void) } return this->implementation ()->cancel (); } + ACE_Proactor * ACE_Asynch_Operation::proactor (void) const { @@ -105,12 +127,15 @@ ACE_Asynch_Operation::proactor (void) const } 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 @@ -122,19 +147,24 @@ ACE_Asynch_Operation::get_proactor (ACE_Proactor *user_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, @@ -143,15 +173,18 @@ ACE_Asynch_Read_Stream::open (ACE_Handler &handler, { // 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, @@ -170,6 +203,7 @@ ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block, priority, signal_number); } + #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) int ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, @@ -190,53 +224,65 @@ ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, 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, @@ -245,15 +291,18 @@ ACE_Asynch_Write_Stream::open (ACE_Handler &handler, { // 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, @@ -272,6 +321,7 @@ ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block, priority, signal_number); } + #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) int ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, @@ -292,53 +342,65 @@ ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, 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, @@ -347,15 +409,18 @@ ACE_Asynch_Read_File::open (ACE_Handler &handler, { // 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, @@ -378,6 +443,7 @@ ACE_Asynch_Read_File::read (ACE_Message_Block &message_block, priority, signal_number); } + #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) int ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block, @@ -402,38 +468,47 @@ ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block, 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, @@ -442,15 +517,18 @@ ACE_Asynch_Write_File::open (ACE_Handler &handler, { // 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, @@ -473,6 +551,7 @@ ACE_Asynch_Write_File::write (ACE_Message_Block &message_block, priority, signal_number); } + #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) int ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block, @@ -497,38 +576,47 @@ ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block, 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, @@ -537,15 +625,18 @@ ACE_Asynch_Accept::open (ACE_Handler &handler, { // 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, @@ -568,59 +659,73 @@ ACE_Asynch_Accept::accept (ACE_Message_Block &message_block, 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, @@ -629,15 +734,18 @@ ACE_Asynch_Connect::open (ACE_Handler &handler, { // 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, @@ -660,44 +768,54 @@ ACE_Asynch_Connect::connect (ACE_HANDLE connect_handle, 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, @@ -706,15 +824,18 @@ ACE_Asynch_Transmit_File::open (ACE_Handler &handler, { // 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, @@ -743,56 +864,69 @@ ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, 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, @@ -803,9 +937,11 @@ ACE_Asynch_Transmit_File::Header_And_Trailer::Header_And_Trailer (ACE_Message_Bl 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, @@ -817,46 +953,55 @@ ACE_Asynch_Transmit_File::Header_And_Trailer::header_and_trailer (ACE_Message_Bl 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) { @@ -868,6 +1013,7 @@ ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void) else { // Something is valid + // If header is valid, set the fields if (this->header_ != 0) { @@ -884,6 +1030,7 @@ ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void) this->transmit_buffers_.Head = 0; this->transmit_buffers_.HeadLength = 0; } + // If trailer is valid, set the fields if (this->trailer_ != 0) { @@ -900,11 +1047,14 @@ ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void) 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) { @@ -912,6 +1062,7 @@ ACE_Handler::ACE_Handler (void) ACE_NEW (p, ACE_Handler::Proxy (this)); this->proxy_.reset (p); } + ACE_Handler::ACE_Handler (ACE_Proactor *d) : proactor_ (d), handle_ (ACE_INVALID_HANDLE) { @@ -919,115 +1070,142 @@ ACE_Handler::ACE_Handler (ACE_Proactor *d) 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, @@ -1036,15 +1214,18 @@ ACE_Asynch_Read_Dgram::open (ACE_Handler &handler, { // 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, @@ -1067,62 +1248,76 @@ ACE_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, 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, @@ -1131,15 +1326,18 @@ ACE_Asynch_Write_Dgram::open (ACE_Handler &handler, { // 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, @@ -1162,45 +1360,56 @@ ACE_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, 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 index ce28f64ae1a..3b5004ce46e 100644 --- a/dep/ACE_wrappers/ace/Asynch_IO.h +++ b/dep/ACE_wrappers/ace/Asynch_IO.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Asynch_IO.h @@ -21,14 +22,19 @@ * @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" @@ -36,14 +42,18 @@ # 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 @@ -58,6 +68,7 @@ struct ACE_TRANSMIT_FILE_BUFFERS }; 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 */ @@ -65,15 +76,18 @@ typedef ACE_TRANSMIT_FILE_BUFFERS* ACE_LPTRANSMIT_FILE_BUFFERS; # 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 * @@ -89,13 +103,17 @@ class ACE_Time_Value; */ 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. @@ -106,8 +124,10 @@ public: * @@ 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. @@ -115,6 +135,7 @@ public: * This returns ACE_INVALID_HANDLE on POSIX4-Unix platforms. */ ACE_HANDLE event (void) const; + /** * This really makes sense only when doing file I/O. * @@ -125,6 +146,7 @@ public: */ unsigned long offset (void) const; unsigned long offset_high (void) const; + /** * Priority of the operation. * @@ -136,6 +158,7 @@ public: * 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 @@ -144,19 +167,25 @@ public: */ 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 * @@ -171,6 +200,7 @@ class ACE_Asynch_Operation_Impl; */ class ACE_Export ACE_Asynch_Operation { + public: /** * Initializes the factory with information which will be used with @@ -182,6 +212,7 @@ public: ACE_HANDLE handle, const void *completion_key, ACE_Proactor *proactor); + /** * (Attempts to) cancel the asynchronous operation pending against * the {handle} registered with this Operation. @@ -219,23 +250,31 @@ public: */ 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 * @@ -251,11 +290,14 @@ class ACE_Asynch_Read_Stream_Impl; */ 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. @@ -274,6 +316,7 @@ public: ACE_HANDLE handle = ACE_INVALID_HANDLE, const void *completion_key = 0, ACE_Proactor *proactor = 0); + /** * Initiate an asynchronous read operation. * @@ -303,6 +346,7 @@ public: 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 @@ -314,12 +358,15 @@ public: 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 @@ -334,32 +381,42 @@ public: */ 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 * @@ -374,11 +431,14 @@ class ACE_Asynch_Write_Stream_Result_Impl; */ 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. @@ -403,6 +463,7 @@ public: 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 @@ -438,6 +499,7 @@ public: 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 @@ -449,12 +511,15 @@ public: 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 @@ -469,32 +534,42 @@ public: */ 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 * @@ -512,11 +587,14 @@ class ACE_Asynch_Read_File_Result_Impl; */ 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. @@ -542,6 +620,7 @@ public: 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 @@ -562,6 +641,7 @@ public: 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 @@ -577,13 +657,16 @@ public: 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 @@ -604,29 +687,37 @@ public: */ 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 * @@ -644,11 +735,14 @@ class ACE_Asynch_Write_File_Result_Impl; */ 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), @@ -659,6 +753,7 @@ public: 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 @@ -680,6 +775,7 @@ public: 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 @@ -695,12 +791,15 @@ public: 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 @@ -721,29 +820,37 @@ public: */ 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 * @@ -759,11 +866,14 @@ class ACE_Asynch_Accept_Impl; */ 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), @@ -774,6 +884,7 @@ public: 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 @@ -815,13 +926,16 @@ public: 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 @@ -835,27 +949,36 @@ public: */ 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_; }; @@ -863,6 +986,7 @@ public: // Forward declarations class ACE_Asynch_Connect_Result_Impl; class ACE_Asynch_Connect_Impl; + /** * @class ACE_Asynch_Connect * @@ -876,11 +1000,14 @@ class ACE_Asynch_Connect_Impl; */ 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. @@ -891,6 +1018,7 @@ public: ACE_HANDLE handle = ACE_INVALID_HANDLE, const void *completion_key = 0, ACE_Proactor *proactor = 0); + /** * This starts off an asynchronous Connect. */ @@ -901,13 +1029,16 @@ public: 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 @@ -921,27 +1052,36 @@ public: */ 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 * @@ -962,13 +1102,17 @@ class ACE_Asynch_Transmit_File_Impl; */ 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), @@ -979,6 +1123,7 @@ public: 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 @@ -1008,12 +1153,15 @@ public: 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 @@ -1027,35 +1175,47 @@ public: */ 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 * @@ -1067,55 +1227,74 @@ public: */ 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 * @@ -1131,11 +1310,14 @@ class ACE_Addr; */ 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), @@ -1146,6 +1328,7 @@ public: 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 @@ -1179,12 +1362,15 @@ public: 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 @@ -1199,36 +1385,49 @@ public: */ 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 * @@ -1244,11 +1443,14 @@ class ACE_Asynch_Write_Dgram_Result_Impl; */ 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), @@ -1259,6 +1461,7 @@ public: 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 @@ -1292,12 +1495,15 @@ public: 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 @@ -1312,32 +1518,43 @@ public: */ 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 * @@ -1351,57 +1568,75 @@ 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 * @@ -1422,22 +1657,30 @@ public: }; 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 * @@ -1450,14 +1693,18 @@ class ACE_Asynch_Acceptor; */ 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 @@ -1466,17 +1713,22 @@ public: */ 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 index b705e4461e2..5bfc8b4c749 100644 --- a/dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp +++ b/dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp @@ -1,86 +1,118 @@ // $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 index 18f719ee425..9e6652e7e8e 100644 --- a/dep/ACE_wrappers/ace/Asynch_IO_Impl.h +++ b/dep/ACE_wrappers/ace/Asynch_IO_Impl.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Asynch_IO_Impl.h @@ -18,20 +19,28 @@ * @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 * @@ -43,24 +52,33 @@ 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 @@ -68,6 +86,7 @@ public: * on non-POSIX4 systems and returns 0. */ virtual int signal_number (void) const = 0; + // protected: // // These two should really be protected. But sometimes it @@ -77,12 +96,15 @@ public: 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 * @@ -94,6 +116,7 @@ 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, @@ -104,19 +127,24 @@ public: 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 * @@ -129,6 +157,7 @@ class ACE_Export ACE_Asynch_Read_Stream_Impl : public virtual ACE_Asynch_Operati { 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, @@ -136,6 +165,7 @@ public: 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 @@ -147,10 +177,12 @@ public: 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 * @@ -163,17 +195,22 @@ class ACE_Export ACE_Asynch_Read_Stream_Result_Impl : public virtual ACE_Asynch_ { 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 * @@ -186,6 +223,7 @@ class ACE_Export ACE_Asynch_Write_Stream_Impl : public virtual ACE_Asynch_Operat { 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, @@ -193,6 +231,7 @@ public: 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 @@ -204,10 +243,12 @@ public: 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 * @@ -220,17 +261,22 @@ class ACE_Export ACE_Asynch_Write_Stream_Result_Impl : public virtual ACE_Asynch { 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 * @@ -243,6 +289,7 @@ class ACE_Export ACE_Asynch_Read_File_Impl : public virtual ACE_Asynch_Read_Stre { 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 @@ -255,6 +302,7 @@ public: 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 @@ -270,6 +318,7 @@ public: 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, @@ -277,6 +326,7 @@ public: 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 @@ -288,10 +338,12 @@ public: 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 * @@ -304,10 +356,12 @@ class ACE_Export ACE_Asynch_Read_File_Result_Impl : public virtual ACE_Asynch_Re 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 * @@ -320,6 +374,7 @@ class ACE_Export ACE_Asynch_Write_File_Impl : public virtual ACE_Asynch_Write_St { 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 @@ -332,6 +387,7 @@ public: 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 @@ -347,6 +403,7 @@ public: 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, @@ -354,6 +411,7 @@ public: 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 @@ -365,10 +423,12 @@ public: 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 * @@ -381,10 +441,12 @@ class ACE_Export ACE_Asynch_Write_File_Result_Impl : public virtual ACE_Asynch_W { 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 * @@ -397,6 +459,7 @@ class ACE_Export ACE_Asynch_Accept_Impl : public virtual ACE_Asynch_Operation_Im { 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 @@ -415,10 +478,12 @@ public: int priority, int signal_number, int addr_family) = 0; + protected: /// Do-nothing constructor. ACE_Asynch_Accept_Impl (void); }; + /** * @class ACE_Asynch_Accept_Result_Impl * @@ -431,20 +496,26 @@ class ACE_Export ACE_Asynch_Accept_Result_Impl : public virtual ACE_Asynch_Resul { 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 * @@ -457,6 +528,7 @@ class ACE_Export ACE_Asynch_Connect_Impl : public virtual ACE_Asynch_Operation_I { public: virtual ~ACE_Asynch_Connect_Impl (void); + /** * This starts off an asynchronous connect */ @@ -467,10 +539,12 @@ public: const void *act, int priority, int signal_number) = 0; + protected: /// Do-nothing constructor. ACE_Asynch_Connect_Impl (void); }; + /** * @class ACE_Asynch_Connect_Result_Impl * @@ -483,13 +557,16 @@ class ACE_Export ACE_Asynch_Connect_Result_Impl : public virtual ACE_Asynch_Resu { 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 * @@ -502,6 +579,7 @@ 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, @@ -513,10 +591,12 @@ public: 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 * @@ -529,25 +609,33 @@ class ACE_Export ACE_Asynch_Transmit_File_Result_Impl : public virtual ACE_Async { 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 * @@ -560,6 +648,7 @@ class ACE_Export ACE_Asynch_Read_Dgram_Impl : public virtual ACE_Asynch_Operatio { 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 @@ -593,10 +682,12 @@ public: 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 * @@ -609,21 +700,28 @@ class ACE_Export ACE_Asynch_Read_Dgram_Result_Impl : public virtual ACE_Asynch_R { 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 * @@ -636,6 +734,7 @@ class ACE_Export ACE_Asynch_Write_Dgram_Impl : public virtual ACE_Asynch_Operati { 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 @@ -669,10 +768,12 @@ public: 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 * @@ -685,23 +786,31 @@ class ACE_Export ACE_Asynch_Write_Dgram_Result_Impl : public virtual ACE_Asynch_ { 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 index 1ebbb929407..60dc69dfb31 100644 --- a/dep/ACE_wrappers/ace/Asynch_IO_Impl.inl +++ b/dep/ACE_wrappers/ace/Asynch_IO_Impl.inl @@ -1,88 +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 index c0d059f0aaf..34715c2bba4 100644 --- a/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp +++ b/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp @@ -1,18 +1,25 @@ // $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) { @@ -21,37 +28,49 @@ ACE_Asynch_Pseudo_Task::start (void) 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, @@ -61,8 +80,10 @@ ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle, // 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) @@ -75,8 +96,10 @@ ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle, | ACE_Event_Handler::DONT_CALL); return -1; } + return 0; } + int ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_HANDLE handle) { @@ -84,21 +107,25 @@ ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_HANDLE 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 index ec37579be7f..4c5a94feca4 100644 --- a/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h +++ b/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Asynch_Pseudo_Task.h @@ -8,23 +9,31 @@ * @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 * @@ -34,23 +43,32 @@ 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 index 3646093924f..473c482adcd 100644 --- a/dep/ACE_wrappers/ace/Atomic_Op.cpp +++ b/dep/ACE_wrappers/ace/Atomic_Op.cpp @@ -1,23 +1,31 @@ // $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) { @@ -41,6 +49,7 @@ single_cpu_increment (volatile long *value) ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_INTEL_ASSEMBLY*/ } + long single_cpu_decrement (volatile long *value) { @@ -64,6 +73,7 @@ single_cpu_decrement (volatile long *value) ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_INTEL_ASSEMBLY*/ } + long single_cpu_exchange (volatile long *value, long rhs) { @@ -86,6 +96,7 @@ single_cpu_exchange (volatile long *value, long rhs) ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_INTEL_ASSEMBLY*/ } + long single_cpu_exchange_add (volatile long *value, long rhs) { @@ -127,6 +138,7 @@ single_cpu_exchange_add (volatile long *value, long rhs) ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_INTEL_ASSEMBLY*/ } + long multi_cpu_increment (volatile long *value) { @@ -144,6 +156,7 @@ multi_cpu_increment (volatile long *value) ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_INTEL_ASSEMBLY*/ } + long multi_cpu_decrement (volatile long *value) { @@ -161,6 +174,7 @@ multi_cpu_decrement (volatile long *value) ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_INTEL_ASSEMBLY*/ } + long multi_cpu_exchange (volatile long *value, long rhs) { @@ -179,6 +193,7 @@ multi_cpu_exchange (volatile long *value, long rhs) ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_INTEL_ASSEMBLY*/ } + long multi_cpu_exchange_add (volatile long *value, long rhs) { @@ -215,15 +230,20 @@ multi_cpu_exchange_add (volatile long *value, long 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) { @@ -242,6 +262,7 @@ ACE_Atomic_Op::init_functions (void) exchange_add_fn_ = multi_cpu_exchange_add; } } + void ACE_Atomic_Op::dump (void) const { @@ -250,10 +271,12 @@ ACE_Atomic_Op::dump (void) const 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) { @@ -272,6 +295,7 @@ ACE_Atomic_Op::init_functions (void) exchange_add_fn_ = multi_cpu_exchange_add; } } + void ACE_Atomic_Op::dump (void) const { @@ -280,6 +304,8 @@ ACE_Atomic_Op::dump (void) const 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 index 33a90819fbd..c750999af4c 100644 --- a/dep/ACE_wrappers/ace/Atomic_Op.h +++ b/dep/ACE_wrappers/ace/Atomic_Op.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Atomic_Op.h @@ -8,16 +9,22 @@ * @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) @@ -38,8 +45,11 @@ # 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 * @@ -55,63 +65,90 @@ 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 * @@ -127,68 +164,98 @@ 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 index ae51db7d115..ed6bfbdbc1b 100644 --- a/dep/ACE_wrappers/ace/Atomic_Op.inl +++ b/dep/ACE_wrappers/ace/Atomic_Op.inl @@ -1,28 +1,36 @@ // -*- 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) { @@ -34,11 +42,13 @@ ACE_Atomic_Op::operator++ (void) 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) { @@ -50,11 +60,13 @@ ACE_Atomic_Op::operator-- (void) 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) { @@ -68,6 +80,7 @@ ACE_Atomic_Op::operator+= (long rhs) return (*exchange_add_fn_) (&this->value_, rhs) + rhs; #endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ } + ACE_INLINE long ACE_Atomic_Op::operator-= (long rhs) { @@ -81,36 +94,43 @@ ACE_Atomic_Op::operator-= (long rhs) 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) { @@ -123,6 +143,7 @@ ACE_Atomic_Op::operator= (long rhs) #endif /* WIN32 */ return *this; } + ACE_INLINE ACE_Atomic_Op & ACE_Atomic_Op::operator= ( const ACE_Atomic_Op &rhs) @@ -136,33 +157,39 @@ ACE_Atomic_Op::operator= ( #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) { @@ -174,11 +201,13 @@ ACE_Atomic_Op::operator++ (void) 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) { @@ -190,11 +219,13 @@ ACE_Atomic_Op::operator-- (void) 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) { @@ -208,6 +239,7 @@ ACE_Atomic_Op::operator+= (unsigned long rhs) 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) { @@ -222,36 +254,43 @@ ACE_Atomic_Op::operator-= (unsigned long 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) { @@ -264,6 +303,7 @@ ACE_Atomic_Op::operator= (unsigned long rhs) #endif /* WIN32 */ return *this; } + ACE_INLINE ACE_Atomic_Op & ACE_Atomic_Op::operator= ( const ACE_Atomic_Op &rhs) @@ -277,15 +317,19 @@ ACE_Atomic_Op::operator= ( #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 index e5dd4407261..842673e58cc 100644 --- a/dep/ACE_wrappers/ace/Atomic_Op_Sparc.c +++ b/dep/ACE_wrappers/ace/Atomic_Op_Sparc.c @@ -6,7 +6,9 @@ * 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() { @@ -21,6 +23,7 @@ ace_atomic_add_long: \n\ addl 0x00000008(%esp), %eax \n\ ret \n\ "); + __asm("\n\ .globl ace_atomic_swap_long \n\ .type ace_atomic_swap_long,@function \n\ @@ -31,6 +34,7 @@ ace_atomic_swap_long: \n\ xchg %eax, (%edx) \n\ ret \n\ "); + __asm("\n\ .globl ace_atomic_swap_add_long \n\ .type ace_atomic_swap_add_long,@function \n\ @@ -42,7 +46,9 @@ ace_atomic_swap_add_long: \n\ ret \n\ "); } + #elif defined(__x86_64) && defined(__SUNPRO_C) + static void __sunpro_asm_code() { __asm("\n\ @@ -55,6 +61,7 @@ ace_atomic_add_long: \n\ addq %rsi, %rax \n\ ret \n\ "); + __asm("\n\ .globl ace_atomic_swap_long \n\ .type ace_atomic_swap_long,@function \n\ @@ -64,6 +71,7 @@ ace_atomic_swap_long: \n\ movq %rsi, %rax \n\ ret \n\ "); + __asm("\n\ .globl ace_atomic_swap_add_long \n\ .type ace_atomic_swap_add_long,@function \n\ @@ -74,7 +82,9 @@ ace_atomic_swap_add_long: \n\ ret \n\ "); } + #elif defined (__sparcv9) + unsigned long ace_atomic_add_long (volatile unsigned long *dest, long rhs) { @@ -89,6 +99,7 @@ ace_atomic_add_long (volatile unsigned long *dest, long rhs) "retl\n" "add %o2, %o1, %o0\n"); } + unsigned long ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs) { @@ -103,6 +114,7 @@ ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs) "retl\n" "mov %o3, %o0\n"); } + unsigned long ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs) { @@ -118,7 +130,9 @@ ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs) "retl\n" "mov %o4, %o0\n"); } + #else + unsigned long ace_atomic_add_long (volatile unsigned long *dest, long rhs) { @@ -133,6 +147,7 @@ ace_atomic_add_long (volatile unsigned long *dest, long rhs) "retl\n" "add %o2, %o1, %o0\n"); } + unsigned long ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs) { @@ -147,6 +162,7 @@ ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs) "retl\n" "mov %o3, %o0\n"); } + unsigned long ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs) { @@ -162,7 +178,9 @@ ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs) "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; diff --git a/dep/ACE_wrappers/ace/Atomic_Op_Sparc.h b/dep/ACE_wrappers/ace/Atomic_Op_Sparc.h index 1c748753d55..d521520c9ec 100644 --- a/dep/ACE_wrappers/ace/Atomic_Op_Sparc.h +++ b/dep/ACE_wrappers/ace/Atomic_Op_Sparc.h @@ -1,12 +1,15 @@ /* -*- 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.h b/dep/ACE_wrappers/ace/Atomic_Op_T.h index 326c1df2c8b..afd163c58e9 100644 --- a/dep/ACE_wrappers/ace/Atomic_Op_T.h +++ b/dep/ACE_wrappers/ace/Atomic_Op_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Atomic_Op_T.h @@ -8,69 +9,85 @@ * @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 @@ -78,6 +95,7 @@ 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<> @@ -86,26 +104,31 @@ 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 * @@ -128,50 +151,74 @@ 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 @@ -180,6 +227,7 @@ public: * 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 @@ -187,12 +235,15 @@ public: * 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 * @@ -211,46 +262,67 @@ 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 @@ -262,6 +334,7 @@ public: * 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 @@ -269,22 +342,29 @@ public: * 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 index fbbdc7711d8..ff051b0cbce 100644 --- a/dep/ACE_wrappers/ace/Atomic_Op_T.inl +++ b/dep/ACE_wrappers/ace/Atomic_Op_T.inl @@ -1,12 +1,17 @@ // -*- 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) @@ -15,6 +20,7 @@ ACE_Atomic_Op_Ex::operator++ (void) ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); return ++this->value_; } + template ACE_INLINE TYPE ACE_Atomic_Op_Ex::operator+= ( @@ -24,6 +30,7 @@ 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) @@ -32,6 +39,7 @@ ACE_Atomic_Op_Ex::operator-- (void) ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); return --this->value_; } + template ACE_INLINE TYPE ACE_Atomic_Op_Ex::operator-= ( @@ -41,6 +49,7 @@ 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 ( @@ -50,6 +59,7 @@ ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex ( { // ACE_TRACE ("ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex"); } + template ACE_INLINE TYPE ACE_Atomic_Op_Ex::operator++ (int) @@ -58,6 +68,7 @@ ACE_Atomic_Op_Ex::operator++ (int) ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); return this->value_++; } + template ACE_INLINE TYPE ACE_Atomic_Op_Ex::operator-- (int) @@ -66,6 +77,7 @@ ACE_Atomic_Op_Ex::operator-- (int) ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); return this->value_--; } + template ACE_INLINE bool ACE_Atomic_Op_Ex::operator== ( @@ -75,6 +87,7 @@ 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!= ( @@ -83,6 +96,7 @@ ACE_Atomic_Op_Ex::operator!= ( // ACE_TRACE ("ACE_Atomic_Op_Ex::operator!="); return !(*this == rhs); } + template ACE_INLINE bool ACE_Atomic_Op_Ex::operator>= ( @@ -92,6 +106,7 @@ 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> ( @@ -101,6 +116,7 @@ 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<= ( @@ -110,6 +126,7 @@ 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< ( @@ -119,17 +136,22 @@ 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 @@ -138,6 +160,7 @@ ACE_Atomic_Op_Ex::value (void) const 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) @@ -148,6 +171,7 @@ ACE_Atomic_Op_Ex::value_i (void) // lock. Use with care ;-) return this->value_; } + template ACE_INLINE ACE_Atomic_Op_Ex & ACE_Atomic_Op_Ex::operator= ( @@ -158,9 +182,11 @@ ACE_Atomic_Op_Ex::operator= ( this->value_ = rhs; return *this; } + // // ACE_Atomic_Op inline functions // + template ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op ( ACE_Atomic_Op const & rhs) @@ -169,6 +195,7 @@ ACE_Atomic_Op::ACE_Atomic_Op ( // ACE_TRACE ("ACE_Atomic_Op::ACE_Atomic_Op"); } + template ACE_INLINE ACE_Atomic_Op & ACE_Atomic_Op::operator= ( @@ -177,6 +204,7 @@ ACE_Atomic_Op::operator= ( this->impl_ = i; return *this; } + template ACE_INLINE ACE_Atomic_Op & ACE_Atomic_Op::operator= ( @@ -185,18 +213,21 @@ ACE_Atomic_Op::operator= ( 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+= ( @@ -204,18 +235,21 @@ ACE_Atomic_Op::operator+= ( { 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-= ( @@ -223,6 +257,7 @@ ACE_Atomic_Op::operator-= ( { return this->impl_ -= rhs; } + template ACE_INLINE bool ACE_Atomic_Op::operator== ( @@ -230,6 +265,7 @@ ACE_Atomic_Op::operator== ( { return this->impl_ == rhs; } + template ACE_INLINE bool ACE_Atomic_Op::operator!= ( @@ -237,6 +273,7 @@ ACE_Atomic_Op::operator!= ( { return this->impl_ != rhs; } + template ACE_INLINE bool ACE_Atomic_Op::operator>= ( @@ -244,6 +281,7 @@ ACE_Atomic_Op::operator>= ( { return this->impl_ >= rhs; } + template ACE_INLINE bool ACE_Atomic_Op::operator> ( @@ -251,6 +289,7 @@ ACE_Atomic_Op::operator> ( { return this->impl_ > rhs; } + template ACE_INLINE bool ACE_Atomic_Op::operator<= ( @@ -258,6 +297,7 @@ ACE_Atomic_Op::operator<= ( { return this->impl_ <= rhs; } + template ACE_INLINE bool ACE_Atomic_Op::operator< ( @@ -265,12 +305,14 @@ ACE_Atomic_Op::operator< ( { 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 @@ -280,16 +322,19 @@ ACE_Atomic_Op::dump (void) const #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 index ffe5c9450c0..875b7ad05cd 100644 --- a/dep/ACE_wrappers/ace/Auto_Event.cpp +++ b/dep/ACE_wrappers/ace/Auto_Event.cpp @@ -1,12 +1,17 @@ // $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, @@ -18,6 +23,7 @@ ACE_Auto_Event::ACE_Auto_Event (int initial_state, arg) { } + #if defined (ACE_HAS_WCHAR) ACE_Auto_Event::ACE_Auto_Event (int initial_state, int type, @@ -31,6 +37,7 @@ ACE_Auto_Event::ACE_Auto_Event (int initial_state, { } #endif /* ACE_HAS_WCHAR */ + void ACE_Auto_Event::dump (void) const { @@ -38,5 +45,6 @@ ACE_Auto_Event::dump (void) const 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 index 9d29771cc02..307c89cddae 100644 --- a/dep/ACE_wrappers/ace/Auto_Event.h +++ b/dep/ACE_wrappers/ace/Auto_Event.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Auto_Event.h @@ -10,15 +11,21 @@ * @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 * @@ -37,6 +44,7 @@ public: 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, @@ -44,17 +52,23 @@ public: 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 index fb5d4e857a1..b614e0b0d77 100644 --- a/dep/ACE_wrappers/ace/Auto_Event.inl +++ b/dep/ACE_wrappers/ace/Auto_Event.inl @@ -1,9 +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.h b/dep/ACE_wrappers/ace/Auto_Functor.h index 2c8a963fcd7..339054506be 100644 --- a/dep/ACE_wrappers/ace/Auto_Functor.h +++ b/dep/ACE_wrappers/ace/Auto_Functor.h @@ -11,12 +11,17 @@ #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 { /** @@ -30,8 +35,10 @@ struct Auto_Functor_Ref { X * p_; Functor f_; + Auto_Functor_Ref(X * p, Functor f); }; + /** * @class Auto_Functor * @@ -53,45 +60,69 @@ 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 index 898f60ff2a9..d4cb2cc0473 100644 --- a/dep/ACE_wrappers/ace/Auto_Functor.inl +++ b/dep/ACE_wrappers/ace/Auto_Functor.inl @@ -1,7 +1,9 @@ // -*- 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) @@ -9,18 +11,21 @@ Auto_Functor_Ref(X * p, Functor f) , 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) @@ -29,6 +34,7 @@ ACE_Utils::Auto_Functor:: operator=(Auto_Functor & rhs) f_ = rhs.f_; return *this; } + #if !defined(ACE_LACKS_MEMBER_TEMPLATES) template template ACE_INLINE ACE_Utils::Auto_Functor::Auto_Functor(Auto_Functor& rhs) @@ -36,6 +42,7 @@ ACE_Utils::Auto_Functor::Auto_Functor(Auto_Functor& rhs) , f_(rhs.f_) { } + template template ACE_INLINE ACE_Utils::Auto_Functor& ACE_Utils::Auto_Functor::operator=(Auto_Functor& rhs) @@ -44,23 +51,27 @@ ACE_Utils::Auto_Functor::operator=(Auto_Functor& rhs) 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() @@ -69,18 +80,21 @@ ACE_Utils::Auto_Functor::release() 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) @@ -92,22 +106,29 @@ ACE_Utils::Auto_Functor::operator=(Auto_Functor_Ref rhs) } 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.h b/dep/ACE_wrappers/ace/Auto_IncDec_T.h index 745a83a100e..bc46b8b2f50 100644 --- a/dep/ACE_wrappers/ace/Auto_IncDec_T.h +++ b/dep/ACE_wrappers/ace/Auto_IncDec_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Auto_IncDec_T.h @@ -9,15 +10,22 @@ */ //============================================================================= + #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 * @@ -33,16 +41,21 @@ 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 @@ -50,10 +63,13 @@ private: 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 @@ -65,9 +81,12 @@ ACE_END_VERSIONED_NAMESPACE_DECL // 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 index b7f91b1cb66..e61980e7192 100644 --- a/dep/ACE_wrappers/ace/Auto_IncDec_T.inl +++ b/dep/ACE_wrappers/ace/Auto_IncDec_T.inl @@ -1,8 +1,11 @@ // -*- 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) @@ -10,10 +13,13 @@ ACE_Auto_IncDec::ACE_Auto_IncDec { ++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.h b/dep/ACE_wrappers/ace/Auto_Ptr.h index 5fbe5647fdd..d7547c440e2 100644 --- a/dep/ACE_wrappers/ace/Auto_Ptr.h +++ b/dep/ACE_wrappers/ace/Auto_Ptr.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Auto_Ptr.h @@ -11,13 +12,17 @@ * @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 @@ -27,7 +32,9 @@ # pragma warning(disable: 4284) #endif /* _MSC_VER */ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + /** * @class ACE_Auto_Basic_Ptr * @@ -39,24 +46,32 @@ 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) @@ -66,6 +81,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL using std::auto_ptr; #endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ #else /* ACE_HAS_STANDARD_CPP_LIBRARY */ + /** * @class auto_ptr * @@ -76,13 +92,18 @@ 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 @@ -94,10 +115,13 @@ 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 * @@ -111,24 +135,31 @@ 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 * @@ -140,12 +171,15 @@ 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. * @@ -172,7 +206,9 @@ ACE_auto_ptr_reset (AUTO_PTR_TYPE & ap, 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 @@ -184,19 +220,24 @@ ACE_END_VERSIONED_NAMESPACE_DECL // 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 index 6a801bfc2ad..9ea47c3f208 100644 --- a/dep/ACE_wrappers/ace/Auto_Ptr.inl +++ b/dep/ACE_wrappers/ace/Auto_Ptr.inl @@ -1,8 +1,11 @@ // -*- 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 { @@ -10,6 +13,7 @@ ACE_Auto_Basic_Ptr::dump (void) const ACE_TRACE ("ACE_Auto_Basic_Ptr::dump"); #endif /* ACE_HAS_DUMP */ } + template ACE_INLINE void ACE_Auto_Basic_Array_Ptr::dump (void) const { @@ -17,18 +21,21 @@ ACE_Auto_Basic_Array_Ptr::dump (void) const 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) { @@ -37,6 +44,7 @@ ACE_Auto_Basic_Ptr::release (void) this->p_ = 0; return old; } + template ACE_INLINE void ACE_Auto_Basic_Ptr::reset (X *p) { @@ -45,6 +53,7 @@ ACE_Auto_Basic_Ptr::reset (X *p) delete this->get (); this->p_ = p; } + template ACE_INLINE ACE_Auto_Basic_Ptr & ACE_Auto_Basic_Ptr::operator= (ACE_Auto_Basic_Ptr &rhs) { @@ -55,40 +64,48 @@ ACE_Auto_Basic_Ptr::operator= (ACE_Auto_Basic_Ptr &rhs) } 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) { @@ -97,6 +114,7 @@ ACE_Auto_Basic_Array_Ptr::release (void) this->p_ = 0; return old; } + template ACE_INLINE void ACE_Auto_Basic_Array_Ptr::reset (X *p) { @@ -105,12 +123,14 @@ ACE_Auto_Basic_Array_Ptr::reset (X *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) { @@ -121,26 +141,31 @@ ACE_Auto_Basic_Array_Ptr::operator= (ACE_Auto_Basic_Array_Ptr &rhs) } 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 index 5597ea34c3c..515a73f95a9 100644 --- a/dep/ACE_wrappers/ace/Barrier.cpp +++ b/dep/ACE_wrappers/ace/Barrier.cpp @@ -1,24 +1,34 @@ // $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_)); @@ -26,6 +36,7 @@ ACE_Sub_Barrier::dump (void) const 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, @@ -35,12 +46,15 @@ ACE_Sub_Barrier::ACE_Sub_Barrier (unsigned int 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_)); @@ -50,6 +64,7 @@ ACE_Barrier::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ } + ACE_Barrier::ACE_Barrier (unsigned int count, const ACE_TCHAR *name, void *arg) @@ -63,20 +78,25 @@ ACE_Barrier::ACE_Barrier (unsigned int count, 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 @@ -90,9 +110,11 @@ ACE_Barrier::wait (void) 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. @@ -102,36 +124,45 @@ ACE_Barrier::wait (void) 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 { @@ -140,14 +171,17 @@ ACE_Thread_Barrier::dump (void) const 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 { @@ -157,6 +191,8 @@ ACE_Process_Barrier::dump (void) const #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 index 69b59c99115..5fc9b9e8b7d 100644 --- a/dep/ACE_wrappers/ace/Barrier.h +++ b/dep/ACE_wrappers/ace/Barrier.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Barrier.h @@ -10,18 +11,26 @@ * @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 * @@ -35,10 +44,15 @@ public: 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. @@ -46,16 +60,22 @@ struct ACE_Export ACE_Sub_Barrier 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 * @@ -80,8 +100,10 @@ public: 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. /// @@ -89,6 +111,7 @@ public: /// @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. @@ -97,18 +120,24 @@ public: /// /// @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 @@ -120,11 +149,13 @@ protected: 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 @@ -139,12 +170,15 @@ 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 * @@ -158,18 +192,25 @@ 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 index 2abf87a53c5..10430d917a3 100644 --- a/dep/ACE_wrappers/ace/Barrier.inl +++ b/dep/ACE_wrappers/ace/Barrier.inl @@ -1,17 +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 index 6a9fd2889c5..d74f1934161 100644 --- a/dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp +++ b/dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp @@ -1,21 +1,29 @@ // $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, @@ -33,6 +41,7 @@ ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter ( , 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_ @@ -45,9 +54,11 @@ ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter ( 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) { @@ -55,23 +66,27 @@ ACE_Base_Thread_Adapter::inherit_log_msg (void) (*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) { @@ -79,13 +94,17 @@ ACE_Base_Thread_Adapter::thr_desc_log_msg (void) 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 @@ -93,13 +112,18 @@ ACE_THREAD_ADAPTER_NAME (void *args) 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 index 575f79fa2b5..beee7210f42 100644 --- a/dep/ACE_wrappers/ace/Base_Thread_Adapter.h +++ b/dep/ACE_wrappers/ace/Base_Thread_Adapter.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Base_Thread_Adapter.h @@ -8,27 +9,37 @@ * @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 * @@ -42,9 +53,11 @@ 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 @@ -54,8 +67,11 @@ protected: long flags_; }; + + class ACE_Service_Gestalt; + /** * @class ACE_Base_Thread_Adapter * @@ -75,23 +91,31 @@ class ACE_Service_Gestalt; 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, @@ -106,6 +130,7 @@ protected: /// 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_; @@ -113,22 +138,28 @@ private: 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 @@ -136,17 +167,22 @@ protected: * 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 @@ -154,6 +190,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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 index cc42abf3c96..3bac80246dd 100644 --- a/dep/ACE_wrappers/ace/Base_Thread_Adapter.inl +++ b/dep/ACE_wrappers/ace/Base_Thread_Adapter.inl @@ -1,17 +1,21 @@ // -*- 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, @@ -26,11 +30,13 @@ ACE_Base_Thread_Adapter::set_log_msg_hooks ( 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) @@ -38,4 +44,5 @@ 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 index 2fc7585f2cb..c9bf92f78ee 100644 --- a/dep/ACE_wrappers/ace/Based_Pointer_Repository.cpp +++ b/dep/ACE_wrappers/ace/Based_Pointer_Repository.cpp @@ -1,11 +1,14 @@ // $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 * @@ -22,30 +25,37 @@ public: 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 ()) @@ -57,27 +67,35 @@ ACE_Based_Pointer_Repository::find (void *addr, void *&base_addr) 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 ()) @@ -89,11 +107,14 @@ ACE_Based_Pointer_Repository::unbind (void *addr) // 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 index 66aa86f422f..047e34dca28 100644 --- a/dep/ACE_wrappers/ace/Based_Pointer_Repository.h +++ b/dep/ACE_wrappers/ace/Based_Pointer_Repository.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Based_Pointer_Repository.h @@ -9,20 +10,28 @@ * @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 * @@ -33,9 +42,11 @@ 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. @@ -44,27 +55,38 @@ public: */ 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.h b/dep/ACE_wrappers/ace/Based_Pointer_T.h index ea116a5c3f7..39437bbb3c9 100644 --- a/dep/ACE_wrappers/ace/Based_Pointer_T.h +++ b/dep/ACE_wrappers/ace/Based_Pointer_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Based_Pointer_T.h @@ -9,11 +10,15 @@ * @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 @@ -21,7 +26,9 @@ // notation)" #pragma warning(disable: 4284) #endif /* _MSC_VER */ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + /** * @class ACE_Based_Pointer_Basic * @@ -55,6 +62,7 @@ public: * address 0. */ ACE_Based_Pointer_Basic (void); + /** * Initialize this object using the @a initial pointer. This * constructor initializes the by asking the @@ -77,46 +85,66 @@ public: * 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 * @@ -135,32 +163,44 @@ public: /// 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 index 3792bf2ecce..ba6a5aa511b 100644 --- a/dep/ACE_wrappers/ace/Based_Pointer_T.inl +++ b/dep/ACE_wrappers/ace/Based_Pointer_T.inl @@ -1,15 +1,19 @@ // -*- 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) { @@ -21,6 +25,7 @@ ACE_Based_Pointer_Basic::operator = (CONCRETE *rhs) this->target_ = ((char *) rhs - ((char *) this - this->base_offset_)); } + template ACE_INLINE void ACE_Based_Pointer::operator = (CONCRETE *rhs) { @@ -32,27 +37,33 @@ ACE_Based_Pointer::operator = (CONCRETE *rhs) 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 { @@ -61,58 +72,68 @@ ACE_Based_Pointer_Basic::operator [] (int index) const 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 index 68fc629adb5..760afa35e6d 100644 --- a/dep/ACE_wrappers/ace/Basic_Stats.cpp +++ b/dep/ACE_wrappers/ace/Basic_Stats.cpp @@ -1,22 +1,29 @@ // $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_; } @@ -33,9 +40,11 @@ ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs) 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 { @@ -46,20 +55,25 @@ ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, ACE_UINT32 sf) const 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 index 3e4b29fc698..fcc9996d8ba 100644 --- a/dep/ACE_wrappers/ace/Basic_Stats.h +++ b/dep/ACE_wrappers/ace/Basic_Stats.h @@ -9,15 +9,20 @@ */ //============================================================================= + #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 @@ -33,12 +38,16 @@ public: * 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 @@ -48,23 +57,32 @@ public: */ 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 index 7dc8d12a57c..e2f153884e3 100644 --- a/dep/ACE_wrappers/ace/Basic_Stats.inl +++ b/dep/ACE_wrappers/ace/Basic_Stats.inl @@ -1,7 +1,9 @@ // -*- 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) @@ -12,15 +14,18 @@ ACE_Basic_Stats::ACE_Basic_Stats (void) , 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; @@ -41,6 +46,8 @@ ACE_Basic_Stats::sample (ACE_UINT64 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 index 2d835a43b3b..f7c87cdb9ce 100644 --- a/dep/ACE_wrappers/ace/Basic_Types.cpp +++ b/dep/ACE_wrappers/ace/Basic_Types.cpp @@ -1,12 +1,15 @@ #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" @@ -15,7 +18,9 @@ ACE_RCSID (ace, // 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 { @@ -25,6 +30,7 @@ ACE_U_LongLong::output (FILE *file) const ACE_OS::fprintf (file, "0x%lx", l_ ()); } + ACE_TCHAR * ACE_U_LongLong::as_string (ACE_TCHAR *output, unsigned int base, @@ -89,6 +95,7 @@ ACE_U_LongLong::as_string (ACE_TCHAR *output, { ACE_OS::sprintf(output, (uppercase ? "%lX" : "%lx"), this->l_ ()); + } break; } @@ -100,9 +107,11 @@ ACE_U_LongLong::as_string (ACE_TCHAR *output, } } } + return output; } + # if !defined (ACE_LACKS_IOSTREAM_TOTALLY) ostream& operator<< (ostream& os, const ACE_U_LongLong& ll) @@ -113,6 +122,7 @@ operator<< (ostream& os, const ACE_U_LongLong& ll) 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) @@ -122,6 +132,9 @@ operator<< (ostream& os, const ACE_U_LongLong& ll) 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 index 6a36971c3a9..9b57fd81c43 100644 --- a/dep/ACE_wrappers/ace/Basic_Types.h +++ b/dep/ACE_wrappers/ace/Basic_Types.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Basic_Types.h @@ -41,37 +42,50 @@ * */ //============================================================================= + #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. @@ -79,6 +93,7 @@ // 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, @@ -96,6 +111,7 @@ typedef ACE::If_Then_Else< #endif /* ACE_LACKS_LONGLONG_T */ >::result_type >::result_type intptr_t; + typedef ACE::If_Then_Else< (sizeof (void*) == sizeof (unsigned int)), unsigned int, @@ -113,9 +129,12 @@ typedef ACE::If_Then_Else< #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 @@ -132,6 +151,7 @@ typedef ACE::If_Then_Else< # 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 @@ -146,6 +166,7 @@ typedef ACE::If_Then_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 @@ -158,6 +179,7 @@ typedef ACE::If_Then_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 @@ -170,6 +192,7 @@ typedef ACE::If_Then_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) @@ -197,10 +220,13 @@ typedef ACE::If_Then_Else< # 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) @@ -210,6 +236,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL #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) @@ -217,6 +244,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL #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) @@ -228,6 +256,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL #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) @@ -239,6 +268,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL #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) @@ -250,6 +280,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL #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) @@ -261,6 +292,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL #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) @@ -275,8 +307,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL # 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) @@ -293,11 +327,15 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL # 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 @@ -305,17 +343,21 @@ typedef unsigned char ACE_Byte; # 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) @@ -362,12 +404,14 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -379,6 +423,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -386,6 +431,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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 @@ -399,11 +445,14 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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 * @@ -432,6 +481,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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; @@ -445,17 +495,21 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 &); @@ -468,16 +522,19 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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. @@ -491,20 +548,27 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 @@ -516,7 +580,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_UINT32 hi_; /// Low 32 bits. ACE_UINT32 lo_; + # else + /// Low 32 bits. ACE_UINT32 lo_; /// High 32 bits. @@ -527,23 +593,31 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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, @@ -559,13 +633,19 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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) @@ -579,6 +659,7 @@ ACE_U64_TO_U32 (ACE_U_LongLong const & n) */ return n.lo (); } + inline ACE_UINT32 ACE_CU64_TO_CU32 (ACE_U_LongLong const & n) { @@ -590,13 +671,16 @@ 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. @@ -619,6 +703,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -626,6 +711,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -633,6 +719,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -640,6 +727,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -647,6 +735,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -656,6 +745,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -665,6 +755,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -674,6 +765,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -683,6 +775,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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") @@ -690,6 +783,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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") @@ -697,6 +791,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -710,6 +805,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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 @@ -720,6 +816,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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 @@ -730,6 +827,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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 @@ -750,6 +848,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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 @@ -763,6 +862,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL #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 @@ -775,14 +875,17 @@ ACE_END_VERSIONED_NAMESPACE_DECL #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 index 4f4f04ab9d9..c6f0013d45e 100644 --- a/dep/ACE_wrappers/ace/Basic_Types.inl +++ b/dep/ACE_wrappers/ace/Basic_Types.inl @@ -1,65 +1,80 @@ // -*- 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 { @@ -74,22 +89,27 @@ ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const 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 { @@ -104,33 +124,41 @@ ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const 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) { @@ -147,107 +175,135 @@ ACE_U_LongLong::operator= (const ACE_INT32 &rhs) // 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) { @@ -257,6 +313,7 @@ ACE_U_LongLong::operator++ (int) ++*this; return temp; } + ACE_INLINE const ACE_U_LongLong ACE_U_LongLong::operator-- (int) { @@ -266,139 +323,170 @@ ACE_U_LongLong::operator-- (int) --*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 { @@ -406,11 +494,13 @@ ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const : 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 { @@ -418,11 +508,13 @@ ACE_U_LongLong::operator<= (const ACE_U_LongLong &n) const : 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 { @@ -430,11 +522,13 @@ ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const : 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 { @@ -442,24 +536,29 @@ ACE_U_LongLong::operator>= (const ACE_U_LongLong &n) const : 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) { @@ -477,131 +576,168 @@ ACE_U_LongLong::operator= (const ACE_INT32 &rhs) 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 { @@ -609,6 +745,7 @@ ACE_U_LongLong::ull_mult (ACE_U_LongLong a, ACE_UINT32 b, ACE_UINT32 *carry) con const ACE_U_LongLong zero (0, 0); ACE_U_LongLong accum (0, 0); ACE_UINT32 c; + *carry = 0; if (b > 0) do @@ -622,47 +759,60 @@ ACE_U_LongLong::ull_mult (ACE_U_LongLong a, ACE_UINT32 b, ACE_UINT32 *carry) con 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) { @@ -672,6 +822,7 @@ ACE_U_LongLong::operator++ (int) ++*this; return temp; } + ACE_INLINE const ACE_U_LongLong ACE_U_LongLong::operator-- (int) { @@ -681,30 +832,37 @@ ACE_U_LongLong::operator-- (int) --*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 { @@ -716,8 +874,10 @@ ACE_U_LongLong::operator/ (const ACE_UINT32 n) const // = ((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 { @@ -728,55 +888,67 @@ ACE_U_LongLong::operator% (const ACE_UINT32 n) const // = (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 index 2bdf6f86291..16ea929002e 100644 --- a/dep/ACE_wrappers/ace/Bound_Ptr.h +++ b/dep/ACE_wrappers/ace/Bound_Ptr.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Bound_Ptr.h @@ -9,15 +10,22 @@ * @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 * @@ -33,45 +41,61 @@ 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 * @@ -91,13 +115,17 @@ 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 @@ -110,12 +138,16 @@ public: // 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 @@ -125,7 +157,9 @@ public: // 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); @@ -133,8 +167,10 @@ public: 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. @@ -143,6 +179,7 @@ public: * 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. @@ -151,46 +188,64 @@ public: * 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 * @@ -214,16 +269,22 @@ 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. /** @@ -231,6 +292,7 @@ public: * 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. @@ -239,15 +301,20 @@ public: * 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 @@ -257,17 +324,21 @@ public: * 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 @@ -276,6 +347,7 @@ public: * servants. */ long add_ref (void); + /// Decrement the reference count on the underlying object, which is deleted /// if the count has reached zero. /** @@ -285,22 +357,33 @@ public: * 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 index 03a8a5849b3..540a5516eab 100644 --- a/dep/ACE_wrappers/ace/Bound_Ptr.inl +++ b/dep/ACE_wrappers/ace/Bound_Ptr.inl @@ -1,11 +1,15 @@ /* -*- 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) { @@ -15,6 +19,7 @@ ACE_Bound_Ptr_Counter::internal_create (long init_obj_ref_count) 0); return temp; } + template inline ACE_Bound_Ptr_Counter * ACE_Bound_Ptr_Counter::create_strong (void) { @@ -29,43 +34,57 @@ ACE_Bound_Ptr_Counter::create_strong (void) 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) @@ -75,55 +94,69 @@ ACE_Bound_Ptr_Counter::create_weak (void) #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_), @@ -131,6 +164,7 @@ ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_ { COUNTER::attach_strong (this->counter_); } + template inline ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr &r) : counter_ (r.counter_), @@ -146,12 +180,14 @@ ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Pt 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) { @@ -159,6 +195,7 @@ ACE_Strong_Bound_Ptr::operator = (const ACE_Strong_Bound_Ptr::operator = (const ACE_Strong_Bound_Ptrcounter_ = new_counter; this->ptr_ = new_ptr; } + template inline void ACE_Strong_Bound_Ptr::operator = (const ACE_Weak_Bound_Ptr &rhs) { @@ -174,8 +212,10 @@ ACE_Strong_Bound_Ptr::operator = (const ACE_Weak_Bound_Ptr::operator = (const ACE_Weak_Bound_Ptrcounter_) == 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) { @@ -252,6 +304,7 @@ ACE_Strong_Bound_Ptr::reset (X *p) if (COUNTER::detach_strong (old_counter) == 0) delete old_ptr; } + template inline void ACE_Strong_Bound_Ptr::reset (auto_ptr p) { @@ -262,12 +315,14 @@ ACE_Strong_Bound_Ptr::reset (auto_ptr p) 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_), @@ -275,6 +330,7 @@ ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptrcounter_); } + template inline ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr &r) : counter_ (r.counter_), @@ -282,11 +338,13 @@ ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_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) { @@ -297,6 +355,7 @@ ACE_Weak_Bound_Ptr::operator = (const ACE_Weak_Bound_Ptrcounter_ = new_counter; this->ptr_ = rhs.ptr_; } + template inline void ACE_Weak_Bound_Ptr::operator = (const ACE_Strong_Bound_Ptr &rhs) { @@ -307,6 +366,7 @@ ACE_Weak_Bound_Ptr::operator = (const ACE_Strong_Bound_Ptrcounter_ = new_counter; this->ptr_ = rhs.ptr_; } + template inline bool ACE_Weak_Bound_Ptr::operator== (const ACE_Weak_Bound_Ptr &r) const { @@ -314,8 +374,10 @@ ACE_Weak_Bound_Ptr::operator== (const ACE_Weak_Bound_Ptrcounter_)) return r.ptr_ == 0; + return this->ptr_ == r.ptr_; } + template inline bool ACE_Weak_Bound_Ptr::operator== (const ACE_Strong_Bound_Ptr &r) const { @@ -323,8 +385,10 @@ ACE_Weak_Bound_Ptr::operator== (const ACE_Strong_Bound_Ptrcounter_)) return r.ptr_ == 0; + return this->ptr_ == r.ptr_; } + template inline bool ACE_Weak_Bound_Ptr::operator== (X *p) const { @@ -332,8 +396,10 @@ ACE_Weak_Bound_Ptr::operator== (X *p) const // 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 { @@ -341,8 +407,10 @@ ACE_Weak_Bound_Ptr::operator!= (const ACE_Weak_Bound_Ptrcounter_)) return r.ptr_ != 0; + return this->ptr_ != r.ptr_; } + template inline bool ACE_Weak_Bound_Ptr::operator!= (const ACE_Strong_Bound_Ptr &r) const { @@ -350,8 +418,10 @@ ACE_Weak_Bound_Ptr::operator!= (const ACE_Strong_Bound_Ptrcounter_)) return r.ptr_ != 0; + return this->ptr_ != r.ptr_; } + template inline bool ACE_Weak_Bound_Ptr::operator!= (X *p) const { @@ -359,18 +429,22 @@ ACE_Weak_Bound_Ptr::operator!= (X *p) const // 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 { @@ -378,6 +452,7 @@ ACE_Weak_Bound_Ptr::unsafe_get (void) const // is defined to be unsafe! return this->ptr_; } + template inline int ACE_Weak_Bound_Ptr::null (void) const { @@ -385,8 +460,10 @@ ACE_Weak_Bound_Ptr::null (void) const // 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) { @@ -395,11 +472,13 @@ ACE_Weak_Bound_Ptr::reset (X *p) 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 () { @@ -411,4 +490,5 @@ ACE_Weak_Bound_Ptr::remove_ref () } 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 index 40ea4936f2f..e7647006b65 100644 --- a/dep/ACE_wrappers/ace/CDR_Base.cpp +++ b/dep/ACE_wrappers/ace/CDR_Base.cpp @@ -1,27 +1,36 @@ #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 && \ @@ -47,14 +56,17 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t 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__)) @@ -93,21 +105,27 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) // 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 @@ -158,13 +176,17 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) // 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; @@ -181,16 +203,20 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) * 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; @@ -203,10 +229,12 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) * reinterpret_cast (target + 6) = c4; #endif #endif + orig += 8; target += 8; } } + // (n & 3) == (n % 4). switch (n&3) { case 3: @@ -221,10 +249,12 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) 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. @@ -238,16 +268,20 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) --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. @@ -259,6 +293,7 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) * 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)); @@ -273,11 +308,14 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) 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; } @@ -291,6 +329,7 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) * 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)); @@ -305,13 +344,16 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) 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; @@ -327,7 +369,9 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) target += 16; } } + #else /* ACE_SIZEOF_LONG != 8 */ + while (orig < end) { #if defined (ACE_HAS_PENTIUM) && defined (__GNUG__) @@ -339,10 +383,12 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) *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; @@ -373,21 +419,26 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) * 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: @@ -402,6 +453,7 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) 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). @@ -410,6 +462,7 @@ 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) { @@ -418,10 +471,12 @@ ACE_CDR::swap_8_array (char const * orig, char* target, size_t n) 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) { @@ -430,6 +485,7 @@ ACE_CDR::swap_16_array (char const * orig, char* target, size_t n) target += 16; } } + void ACE_CDR::mb_align (ACE_Message_Block *mb) { @@ -442,34 +498,44 @@ ACE_CDR::mb_align (ACE_Message_Block *mb) 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) @@ -482,16 +548,19 @@ ACE_CDR::total_length (const ACE_Message_Block* begin, 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. @@ -505,6 +574,7 @@ ACE_CDR::consolidate (ACE_Message_Block *dst, 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 ()) @@ -517,23 +587,28 @@ ACE_CDR::consolidate (ACE_Message_Block *dst, 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) @@ -551,6 +626,7 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs) 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) { @@ -561,9 +637,11 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs) 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. @@ -596,6 +674,7 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs) } return *this; } + ACE_CDR::LongDouble& ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble& rhs) { @@ -603,20 +682,24 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble& 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) @@ -633,8 +716,10 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const 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) { @@ -645,9 +730,11 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const 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. @@ -667,6 +754,7 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const ++ri; } } + #if defined (ACE_LITTLE_ENDIAN) ACE_CDR::swap_8 (lhs_ptr, lhs_ptr); #endif @@ -675,31 +763,38 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const { 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 index 3d7ac40bd2e..c3b2e368514 100644 --- a/dep/ACE_wrappers/ace/CDR_Base.h +++ b/dep/ACE_wrappers/ace/CDR_Base.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file CDR_Base.h @@ -23,16 +24,23 @@ */ //============================================================================= + #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 @@ -42,7 +50,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL # 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 * @@ -56,16 +66,19 @@ public: // 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, @@ -73,9 +86,11 @@ public: /// @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 @@ -83,14 +98,17 @@ public: * 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 * @@ -106,6 +124,7 @@ public: /// 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), @@ -128,9 +147,11 @@ public: 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. @@ -142,9 +163,11 @@ public: * 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 @@ -153,13 +176,16 @@ public: * @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 * @@ -176,6 +202,7 @@ public: 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) @@ -203,6 +230,7 @@ public: ACE_CDR::Long l; ACE_CDR::Long h; # endif /* ! ACE_BIG_ENDIAN */ + /** * @name Overloaded Relation Operators. * @@ -214,11 +242,13 @@ public: //@} }; # 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 */ @@ -239,6 +269,7 @@ public: # endif /* ACE_SIZEOF_INT != 4 */ }; # endif /* ACE_SIZEOF_FLOAT != 4 */ + # if ACE_SIZEOF_DOUBLE == 8 typedef double Double; # else /* ACE_SIZEOF_DOUBLE != 8 */ @@ -253,10 +284,12 @@ public: # 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 @@ -281,11 +314,15 @@ public: # 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); } @@ -314,22 +351,30 @@ public: 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 index ba33e73c481..85373170af7 100644 --- a/dep/ACE_wrappers/ace/CDR_Base.inl +++ b/dep/ACE_wrappers/ace/CDR_Base.inl @@ -1,15 +1,19 @@ // -*- 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: @@ -57,6 +61,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // 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) { @@ -90,6 +95,7 @@ ACE_CDR::swap_2 (const char *orig, char* target) *udst = (usrc << 8) | (usrc >> 8); #endif /* ACE_HAS_PENTIUM */ } + ACE_INLINE void ACE_CDR::swap_4 (const char* orig, char* target) { @@ -124,6 +130,7 @@ ACE_CDR::swap_4 (const char* orig, char* target) * reinterpret_cast (target) = x; #endif /* ACE_HAS_INTRINSIC_BYTESWAP */ } + ACE_INLINE void ACE_CDR::swap_8 (const char* orig, char* target) { @@ -185,17 +192,20 @@ ACE_CDR::swap_8 (const char* orig, char* target) * 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) { @@ -203,6 +213,7 @@ ACE_CDR::first_size (size_t minsize) { // 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. @@ -218,10 +229,12 @@ ACE_CDR::first_size (size_t minsize) } 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 @@ -233,7 +246,10 @@ ACE_CDR::next_size (size_t minsize) 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 index 7ddb1408167..074631080c4 100644 --- a/dep/ACE_wrappers/ace/CDR_Size.cpp +++ b/dep/ACE_wrappers/ace/CDR_Size.cpp @@ -2,13 +2,17 @@ #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) { @@ -19,11 +23,13 @@ ACE_SizeCDR::write_wchar (ACE_CDR::WChar x) 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)) @@ -59,6 +65,7 @@ ACE_SizeCDR::write_wchar (ACE_CDR::WChar x) errno = EINVAL; return (this->good_bit_ = false); } + if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar)) { const void *temp = &x; @@ -69,9 +76,11 @@ ACE_SizeCDR::write_wchar (ACE_CDR::WChar x) 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) @@ -92,8 +101,10 @@ ACE_SizeCDR::write_string (ACE_CDR::ULong len, 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) { @@ -102,6 +113,7 @@ ACE_SizeCDR::write_string (const ACE_CString &x) 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) @@ -113,6 +125,7 @@ ACE_SizeCDR::write_wstring (ACE_CDR::ULong len, errno = EACCES; return (this->good_bit_ = false); } + if (static_cast (this->major_version_) == 1 && static_cast (this->minor_version_) == 2) { @@ -125,6 +138,7 @@ ACE_SizeCDR::write_wstring (ACE_CDR::ULong len, this->write_ulong ( ACE_Utils::truncate_cast ( ACE_OutputCDR::wchar_maxbytes () * len)); + if (good_ulong) { return this->write_wchar_array (x, len); @@ -136,6 +150,7 @@ ACE_SizeCDR::write_wstring (ACE_CDR::ULong len, return this->write_ulong (0); } } + else if (x != 0) { @@ -146,30 +161,35 @@ ACE_SizeCDR::write_wstring (ACE_CDR::ULong len, 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 *) { @@ -177,19 +197,23 @@ ACE_SizeCDR::write_16 (const ACE_CDR::LongDouble *) 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, @@ -198,9 +222,11 @@ ACE_SizeCDR::write_array (const void *, { 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) @@ -208,11 +234,13 @@ ACE_SizeCDR::write_boolean_array (const ACE_CDR::Boolean*, 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) @@ -223,11 +251,13 @@ ACE_SizeCDR::adjust (size_t size, #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 index 6335bf847bb..777c29acc4d 100644 --- a/dep/ACE_wrappers/ace/CDR_Size.h +++ b/dep/ACE_wrappers/ace/CDR_Size.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file CDR_Size.h @@ -20,16 +21,23 @@ * */ //============================================================================= + #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 * @@ -42,15 +50,19 @@ 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); @@ -66,6 +78,7 @@ public: 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, @@ -75,6 +88,7 @@ public: 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. @@ -105,22 +119,27 @@ public: 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 @@ -138,31 +157,42 @@ private: 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, @@ -181,7 +211,9 @@ 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, @@ -198,9 +230,13 @@ 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 index af1864745b9..4ea81523faf 100644 --- a/dep/ACE_wrappers/ace/CDR_Size.inl +++ b/dep/ACE_wrappers/ace/CDR_Size.inl @@ -1,8 +1,11 @@ // -*- 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) @@ -12,33 +15,40 @@ ACE_SizeCDR::ACE_SizeCDR (ACE_CDR::Octet 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) { @@ -46,55 +56,65 @@ ACE_SizeCDR::write_char (ACE_CDR::Char x) // 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) { @@ -106,6 +126,7 @@ ACE_SizeCDR::write_string (const ACE_CDR::Char *x) } return this->write_string (0, 0); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x) { @@ -117,6 +138,7 @@ ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *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) @@ -128,6 +150,7 @@ ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x, ACE_CDR::OCTET_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_wchar_array (const ACE_CDR::WChar* x, ACE_CDR::ULong length) @@ -148,6 +171,7 @@ ACE_SizeCDR::write_wchar_array (const ACE_CDR::WChar* x, 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) @@ -157,6 +181,7 @@ ACE_SizeCDR::write_octet_array (const ACE_CDR::Octet* x, ACE_CDR::OCTET_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_short_array (const ACE_CDR::Short *x, ACE_CDR::ULong length) @@ -166,6 +191,7 @@ ACE_SizeCDR::write_short_array (const ACE_CDR::Short *x, ACE_CDR::SHORT_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::ULong length) @@ -175,6 +201,7 @@ ACE_SizeCDR::write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::SHORT_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_long_array (const ACE_CDR::Long *x, ACE_CDR::ULong length) @@ -184,6 +211,7 @@ ACE_SizeCDR::write_long_array (const ACE_CDR::Long *x, ACE_CDR::LONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::ULong length) @@ -193,6 +221,7 @@ ACE_SizeCDR::write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::LONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::ULong length) @@ -202,6 +231,7 @@ ACE_SizeCDR::write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::LONGLONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::ULong length) @@ -211,6 +241,7 @@ ACE_SizeCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::LONGLONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_float_array (const ACE_CDR::Float *x, ACE_CDR::ULong length) @@ -221,6 +252,7 @@ ACE_SizeCDR::write_float_array (const ACE_CDR::Float *x, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_double_array (const ACE_CDR::Double *x, ACE_CDR::ULong length) @@ -230,6 +262,7 @@ ACE_SizeCDR::write_double_array (const ACE_CDR::Double *x, ACE_CDR::LONGLONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_longdouble_array (const ACE_CDR::LongDouble* x, ACE_CDR::ULong length) @@ -240,80 +273,94 @@ ACE_SizeCDR::write_longdouble_array (const ACE_CDR::LongDouble* x, 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) @@ -321,47 +368,57 @@ 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 index 776910b2666..1282f75358a 100644 --- a/dep/ACE_wrappers/ace/CDR_Stream.cpp +++ b/dep/ACE_wrappers/ace/CDR_Stream.cpp @@ -2,15 +2,21 @@ #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, @@ -41,15 +47,18 @@ ACE_OutputCDR::ACE_OutputCDR (size_t size, 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, @@ -85,12 +94,14 @@ ACE_OutputCDR::ACE_OutputCDR (char *data, // 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, @@ -115,12 +126,14 @@ ACE_OutputCDR::ACE_OutputCDR (ACE_Data_Block *data_block, // 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, @@ -142,22 +155,26 @@ ACE_OutputCDR::ACE_OutputCDR (ACE_Message_Block *data, // 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, @@ -173,14 +190,18 @@ ACE_OutputCDR::grow_and_adjust (size_t 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, @@ -195,6 +216,7 @@ ACE_OutputCDR::grow_and_adjust (size_t size, 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. @@ -204,7 +226,9 @@ ACE_OutputCDR::grow_and_adjust (size_t size, 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. @@ -218,14 +242,17 @@ ACE_OutputCDR::grow_and_adjust (size_t size, 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) { @@ -286,6 +313,7 @@ ACE_OutputCDR::write_wchar (ACE_CDR::WChar x) 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) @@ -295,6 +323,7 @@ ACE_OutputCDR::write_string (ACE_CDR::ULong len, // 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)) @@ -309,8 +338,10 @@ ACE_OutputCDR::write_string (ACE_CDR::ULong len, 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) { @@ -319,6 +350,7 @@ ACE_OutputCDR::write_string (const ACE_CString &x) 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) @@ -334,6 +366,7 @@ ACE_OutputCDR::write_wstring (ACE_CDR::ULong len, errno = EACCES; return (this->good_bit_ = false); } + if (static_cast (this->major_version_) == 1 && static_cast (this->minor_version_) == 2) { @@ -346,6 +379,7 @@ ACE_OutputCDR::write_wstring (ACE_CDR::ULong len, this->write_ulong ( ACE_Utils::truncate_cast ( ACE_OutputCDR::wchar_maxbytes_ * len)); + if (good_ulong) { return this->write_wchar_array (x, len); @@ -357,6 +391,7 @@ ACE_OutputCDR::write_wstring (ACE_CDR::ULong len, return this->write_ulong (0); } } + else if (x != 0) { @@ -367,6 +402,7 @@ ACE_OutputCDR::write_wstring (ACE_CDR::ULong len, return this->write_wchar (0); return (this->good_bit_ = false); } + ACE_CDR::Boolean ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb) { @@ -377,6 +413,7 @@ ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb) 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)) @@ -388,6 +425,7 @@ ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb) return (this->good_bit_ = false); continue; } + if (length < this->memcpy_tradeoff_ && this->current_->wr_ptr () + length < this->current_->end ()) { @@ -398,16 +436,19 @@ ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb) 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; @@ -416,8 +457,10 @@ ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb) (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) { @@ -427,8 +470,10 @@ ACE_OutputCDR::write_1 (const ACE_CDR::Octet *x) *reinterpret_cast (buf) = *x; return true; } + return false; } + ACE_CDR::Boolean ACE_OutputCDR::write_2 (const ACE_CDR::UShort *x) { @@ -451,8 +496,10 @@ ACE_OutputCDR::write_2 (const ACE_CDR::UShort *x) } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ } + return false; } + ACE_CDR::Boolean ACE_OutputCDR::write_4 (const ACE_CDR::ULong *x) { @@ -475,12 +522,15 @@ ACE_OutputCDR::write_4 (const ACE_CDR::ULong *x) } #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__) @@ -512,8 +562,10 @@ ACE_OutputCDR::write_8 (const ACE_CDR::ULongLong *x) # endif /* ACE_ENABLE_SWAP_ON_WRITE */ #endif /* !__arm__ */ } + return false; } + ACE_CDR::Boolean ACE_OutputCDR::write_16 (const ACE_CDR::LongDouble *x) { @@ -538,8 +590,10 @@ ACE_OutputCDR::write_16 (const ACE_CDR::LongDouble *x) } #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) @@ -550,6 +604,7 @@ ACE_OutputCDR::write_wchar_array_i (const ACE_CDR::WChar *x, 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) @@ -578,6 +633,7 @@ ACE_OutputCDR::write_wchar_array_i (const ACE_CDR::WChar *x, return false; } + ACE_CDR::Boolean ACE_OutputCDR::write_array (const void *x, size_t size, @@ -627,6 +683,7 @@ ACE_OutputCDR::write_array (const void *x, return false; } + ACE_CDR::Boolean ACE_OutputCDR::write_boolean_array (const ACE_CDR::Boolean* x, ACE_CDR::ULong length) @@ -637,13 +694,16 @@ ACE_OutputCDR::write_boolean_array (const ACE_CDR::Boolean* x, // 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) { @@ -655,6 +715,7 @@ ACE_OutputCDR::write_long_placeholder (void) return buf; } + char * ACE_OutputCDR::write_short_placeholder (void) { @@ -666,11 +727,13 @@ ACE_OutputCDR::write_short_placeholder (void) 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 @@ -683,14 +746,17 @@ ACE_OutputCDR::replace (ACE_CDR::Long x, char* loc) 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 @@ -703,9 +769,11 @@ ACE_OutputCDR::replace (ACE_CDR::Short x, char* loc) ACE_CDR::swap_2 (reinterpret_cast (&x), loc); } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ + return true; } + int ACE_OutputCDR::consolidate (void) { @@ -723,6 +791,7 @@ ACE_OutputCDR::consolidate (void) { 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 @@ -737,6 +806,7 @@ ACE_OutputCDR::consolidate (void) { 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); @@ -744,9 +814,11 @@ ACE_OutputCDR::consolidate (void) this->current_ = &this->start_; this->current_is_writable_ = true; } + return 0; } + ACE_Message_Block* ACE_OutputCDR::find (char* loc) { @@ -758,22 +830,29 @@ ACE_OutputCDR::find (char* loc) 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, @@ -788,12 +867,14 @@ ACE_InputCDR::ACE_InputCDR (const char *buf, 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, @@ -812,6 +893,7 @@ ACE_InputCDR::ACE_InputCDR (size_t bufsiz, 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, @@ -829,8 +911,10 @@ ACE_InputCDR::ACE_InputCDR (const ACE_Message_Block *data, 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, @@ -850,6 +934,7 @@ ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data, 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, @@ -867,18 +952,22 @@ ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data, { // 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) @@ -899,8 +988,10 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, #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 ()) { @@ -911,12 +1002,14 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, { 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_, @@ -936,8 +1029,10 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, #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 ()) { @@ -945,6 +1040,7 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, // 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); @@ -953,12 +1049,14 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, { 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), @@ -975,16 +1073,19 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs) #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_), @@ -996,14 +1097,17 @@ ACE_InputCDR::ACE_InputCDR (ACE_InputCDR::Transfer_Contents x) { 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) { @@ -1018,11 +1122,14 @@ ACE_InputCDR::operator= (const ACE_InputCDR& rhs) 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, @@ -1052,12 +1159,14 @@ ACE_InputCDR::ACE_InputCDR (const ACE_OutputCDR& rhs, { 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) { @@ -1077,8 +1186,10 @@ ACE_InputCDR::skip_wchar (void) else return this->read_4 (reinterpret_cast (temp)); } + return (this->good_bit_ = false); } + ACE_CDR::Boolean ACE_InputCDR::read_wchar (ACE_CDR::WChar& x) { @@ -1092,31 +1203,37 @@ ACE_InputCDR::read_wchar (ACE_CDR::WChar& x) 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) @@ -1166,10 +1283,12 @@ ACE_InputCDR::read_wchar (ACE_CDR::WChar& x) x = static_cast (ox); return true; } + } } return (this->good_bit_ = false); } + ACE_CDR::Boolean ACE_InputCDR::read_string (ACE_CDR::Char *&x) { @@ -1181,9 +1300,12 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x) 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. @@ -1192,7 +1314,9 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x) 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 (); @@ -1209,9 +1333,11 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x) 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) { @@ -1222,9 +1348,11 @@ ACE_InputCDR::read_string (ACE_CString &x) x = data; return true; } + x = ""; return (this->good_bit_ = false); } + ACE_CDR::Boolean ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) { @@ -1241,35 +1369,45 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) 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; } } @@ -1278,10 +1416,13 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) 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; } } @@ -1296,10 +1437,12 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) 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, @@ -1309,6 +1452,7 @@ ACE_InputCDR::read_array (void* x, if (length == 0) return true; char* buf = 0; + if (this->adjust (size * length, align, buf) == 0) { #if defined (ACE_DISABLE_SWAP_ON_READ) @@ -1344,6 +1488,7 @@ ACE_InputCDR::read_array (void* x, } return false; } + ACE_CDR::Boolean ACE_InputCDR::read_wchar_array_i (ACE_CDR::WChar* x, ACE_CDR::ULong length) @@ -1354,6 +1499,7 @@ ACE_InputCDR::read_wchar_array_i (ACE_CDR::WChar* x, 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) @@ -1383,6 +1529,7 @@ ACE_InputCDR::read_wchar_array_i (ACE_CDR::WChar* x, return false; } + ACE_CDR::Boolean ACE_InputCDR::read_boolean_array (ACE_CDR::Boolean *x, ACE_CDR::ULong length) @@ -1394,6 +1541,7 @@ ACE_InputCDR::read_boolean_array (ACE_CDR::Boolean *x, 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 @@ -1401,8 +1549,10 @@ ACE_InputCDR::read_boolean_array (ACE_CDR::Boolean *x, // 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) { @@ -1412,9 +1562,11 @@ ACE_InputCDR::read_1 (ACE_CDR::Octet *x) this->start_.rd_ptr (1); return true; } + this->good_bit_ = false; return false; } + ACE_CDR::Boolean ACE_InputCDR::read_2 (ACE_CDR::UShort *x) { @@ -1434,6 +1586,7 @@ ACE_InputCDR::read_2 (ACE_CDR::UShort *x) this->good_bit_ = false; return false; } + ACE_CDR::Boolean ACE_InputCDR::read_4 (ACE_CDR::ULong *x) { @@ -1453,10 +1606,12 @@ ACE_InputCDR::read_4 (ACE_CDR::ULong *x) 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) @@ -1498,9 +1653,11 @@ ACE_InputCDR::read_8 (ACE_CDR::ULongLong *x) #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) { @@ -1519,9 +1676,11 @@ ACE_InputCDR::read_16 (ACE_CDR::LongDouble *x) #endif /* ACE_DISABLE_SWAP_ON_READ */ return true; } + this->good_bit_ = false; return false; } + ACE_CDR::Boolean ACE_InputCDR::skip_string (void) { @@ -1537,11 +1696,13 @@ ACE_InputCDR::skip_string (void) } 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 @@ -1553,6 +1714,7 @@ ACE_InputCDR::skip_wstring (void) } return continue_skipping; } + ACE_CDR::Boolean ACE_InputCDR::skip_bytes (size_t len) { @@ -1564,47 +1726,58 @@ ACE_InputCDR::skip_bytes (size_t len) 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) { @@ -1612,74 +1785,95 @@ ACE_InputCDR::exchange_data_blocks (ACE_InputCDR &cdr) 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? @@ -1696,12 +1890,16 @@ ACE_InputCDR::clone_from (ACE_InputCDR &cdr) // . // (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)) @@ -1710,107 +1908,141 @@ ACE_InputCDR::clone_from (ACE_InputCDR &cdr) // 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) { @@ -1821,6 +2053,7 @@ operator<< (std::ostream &os, ACE_OutputCDR::from_wchar x) os.setf (ios_base::dec, ios_base::basefield); return os; } + std::ostream& operator<< (std::ostream &os, ACE_OutputCDR::from_octet x) { @@ -1829,6 +2062,8 @@ operator<< (std::ostream &os, ACE_OutputCDR::from_octet x) 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 index 16d10f483cf..348433a0de4 100644 --- a/dep/ACE_wrappers/ace/CDR_Stream.h +++ b/dep/ACE_wrappers/ace/CDR_Stream.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file CDR_Stream.h @@ -35,26 +36,37 @@ * @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 * @@ -80,6 +92,7 @@ public: 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. @@ -105,6 +118,7 @@ public: 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 . @@ -125,6 +139,7 @@ public: 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 . @@ -142,6 +157,7 @@ public: 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, @@ -149,33 +165,40 @@ public: 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, @@ -188,6 +211,7 @@ public: ACE_CDR::ULong bound_; ACE_CDR::Boolean nocopy_; }; + struct ACE_Export from_wstring { from_wstring (ACE_CDR::WChar* ws, @@ -201,6 +225,7 @@ public: ACE_CDR::Boolean nocopy_; }; //@} + /** * @{ @name Write operations * Return 0 on failure and 1 on success. @@ -218,6 +243,7 @@ public: 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, @@ -227,6 +253,7 @@ public: 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. @@ -257,10 +284,12 @@ public: 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 @@ -276,6 +305,7 @@ public: 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 @@ -288,6 +318,7 @@ public: */ 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. @@ -307,6 +338,7 @@ public: 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. */ @@ -324,28 +356,36 @@ public: 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 @@ -354,18 +394,21 @@ public: * @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. @@ -373,25 +416,32 @@ public: * 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 @@ -400,45 +450,57 @@ public: */ 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 @@ -456,9 +518,11 @@ private: 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 @@ -468,11 +532,14 @@ private: 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. @@ -484,6 +551,7 @@ private: */ 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 @@ -491,6 +559,7 @@ private: * 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 @@ -501,20 +570,26 @@ private: * 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 @@ -527,7 +602,9 @@ protected: static size_t wchar_maxbytes_; }; + // **************************************************************** + /** * @class ACE_InputCDR * @@ -550,6 +627,7 @@ public: // 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 @@ -562,12 +640,14 @@ public: 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 @@ -581,6 +661,7 @@ public: 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 @@ -589,6 +670,7 @@ public: 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 @@ -600,62 +682,76 @@ public: 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 { /** @@ -670,6 +766,7 @@ public: const ACE_CDR::Char *&val_; ACE_CDR::ULong bound_; }; + struct ACE_Export to_wstring { /// The constructor taking a non-const wstring is @@ -683,6 +780,7 @@ public: ACE_CDR::ULong bound_; }; //@} + /** * Return @c false on failure and @c true on success. */ @@ -700,10 +798,12 @@ public: 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. @@ -737,6 +837,7 @@ public: ACE_CDR::Boolean read_longdouble_array (ACE_CDR::LongDouble* x, ACE_CDR::ULong length); //@} + /** * Return @c false on failure and @c true on success. */ @@ -755,6 +856,7 @@ public: 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. @@ -762,13 +864,16 @@ public: */ 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. @@ -777,35 +882,43 @@ public: * 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. @@ -814,15 +927,20 @@ public: * 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. @@ -831,18 +949,23 @@ public: * @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 @@ -851,50 +974,65 @@ public: */ 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 @@ -911,6 +1049,7 @@ private: 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 @@ -919,12 +1058,16 @@ private: */ 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 * @@ -943,33 +1086,40 @@ 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: @@ -979,6 +1129,7 @@ protected: 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, @@ -986,6 +1137,7 @@ protected: 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 @@ -997,6 +1149,7 @@ protected: 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. @@ -1008,15 +1161,19 @@ protected: 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 * @@ -1031,6 +1188,7 @@ 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&, @@ -1046,6 +1204,7 @@ public: 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: @@ -1063,6 +1222,7 @@ protected: 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, @@ -1070,6 +1230,7 @@ protected: 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 @@ -1081,6 +1242,7 @@ protected: 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. @@ -1092,30 +1254,40 @@ protected: 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, @@ -1134,7 +1306,9 @@ 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, @@ -1151,10 +1325,12 @@ 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, @@ -1173,7 +1349,9 @@ 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, @@ -1190,23 +1368,36 @@ 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 index b471c56c6b9..9fef2d8fab0 100644 --- a/dep/ACE_wrappers/ace/CDR_Stream.inl +++ b/dep/ACE_wrappers/ace/CDR_Stream.inl @@ -1,51 +1,63 @@ // -*- 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, @@ -55,6 +67,7 @@ ACE_OutputCDR::from_string::from_string (ACE_CDR::Char *s, nocopy_ (nocopy) { } + ACE_INLINE ACE_OutputCDR::from_string::from_string (const ACE_CDR::Char *s, ACE_CDR::ULong b, @@ -64,6 +77,7 @@ ACE_OutputCDR::from_string::from_string (const ACE_CDR::Char *s, nocopy_ (nocopy) { } + ACE_INLINE ACE_InputCDR::to_string::to_string (ACE_CDR::Char *&s, ACE_CDR::ULong b) @@ -71,6 +85,7 @@ ACE_InputCDR::to_string::to_string (ACE_CDR::Char *&s, bound_ (b) { } + ACE_INLINE ACE_InputCDR::to_string::to_string (const ACE_CDR::Char *&s, ACE_CDR::ULong b) @@ -78,6 +93,7 @@ ACE_InputCDR::to_string::to_string (const ACE_CDR::Char *&s, bound_ (b) { } + ACE_INLINE ACE_OutputCDR::from_wstring::from_wstring (ACE_CDR::WChar *ws, ACE_CDR::ULong b, @@ -87,6 +103,7 @@ ACE_OutputCDR::from_wstring::from_wstring (ACE_CDR::WChar *ws, nocopy_ (nocopy) { } + ACE_INLINE ACE_OutputCDR::from_wstring::from_wstring (const ACE_CDR::WChar *ws, ACE_CDR::ULong b, @@ -96,6 +113,7 @@ ACE_OutputCDR::from_wstring::from_wstring (const ACE_CDR::WChar *ws, nocopy_ (nocopy) { } + ACE_INLINE ACE_InputCDR::to_wstring::to_wstring (ACE_CDR::WChar *&ws, ACE_CDR::ULong b) @@ -103,6 +121,7 @@ ACE_InputCDR::to_wstring::to_wstring (ACE_CDR::WChar *&ws, bound_ (b) { } + ACE_INLINE ACE_InputCDR::to_wstring::to_wstring (const ACE_CDR::WChar *&ws, ACE_CDR::ULong b) @@ -110,12 +129,15 @@ ACE_InputCDR::to_wstring::to_wstring (const ACE_CDR::WChar *&ws, bound_ (b) { } + ACE_INLINE ACE_InputCDR::Transfer_Contents::Transfer_Contents (ACE_InputCDR &rhs) : rhs_ (rhs) { } + // **************************************************************** + ACE_INLINE ACE_OutputCDR::~ACE_OutputCDR (void) { @@ -124,39 +146,49 @@ ACE_OutputCDR::~ACE_OutputCDR (void) 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) { @@ -167,6 +199,7 @@ ACE_OutputCDR::write_boolean (ACE_CDR::Boolean x) ? static_cast (1) : static_cast (0))); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_char (ACE_CDR::Char x) { @@ -177,56 +210,66 @@ ACE_OutputCDR::write_char (ACE_CDR::Char x) } 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) { @@ -236,8 +279,10 @@ ACE_OutputCDR::write_string (const ACE_CDR::Char *x) 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) { @@ -247,8 +292,10 @@ ACE_OutputCDR::write_wstring (const ACE_CDR::WChar *x) 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) @@ -260,17 +307,20 @@ ACE_OutputCDR::write_char_array (const ACE_CDR::Char *x, 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), @@ -280,6 +330,7 @@ ACE_OutputCDR::write_wchar_array (const ACE_CDR::WChar* x, 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) @@ -289,6 +340,7 @@ ACE_OutputCDR::write_octet_array (const ACE_CDR::Octet* x, ACE_CDR::OCTET_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_short_array (const ACE_CDR::Short *x, ACE_CDR::ULong length) @@ -298,6 +350,7 @@ ACE_OutputCDR::write_short_array (const ACE_CDR::Short *x, ACE_CDR::SHORT_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::ULong length) @@ -307,6 +360,7 @@ ACE_OutputCDR::write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::SHORT_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_long_array (const ACE_CDR::Long *x, ACE_CDR::ULong length) @@ -316,6 +370,7 @@ ACE_OutputCDR::write_long_array (const ACE_CDR::Long *x, ACE_CDR::LONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::ULong length) @@ -325,6 +380,7 @@ ACE_OutputCDR::write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::LONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::ULong length) @@ -334,6 +390,7 @@ ACE_OutputCDR::write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::LONGLONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::ULong length) @@ -343,6 +400,7 @@ ACE_OutputCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::LONGLONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_float_array (const ACE_CDR::Float *x, ACE_CDR::ULong length) @@ -353,6 +411,7 @@ ACE_OutputCDR::write_float_array (const ACE_CDR::Float *x, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_double_array (const ACE_CDR::Double *x, ACE_CDR::ULong length) @@ -362,6 +421,7 @@ ACE_OutputCDR::write_double_array (const ACE_CDR::Double *x, ACE_CDR::LONGLONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_longdouble_array (const ACE_CDR::LongDouble* x, ACE_CDR::ULong length) @@ -371,11 +431,13 @@ ACE_OutputCDR::write_longdouble_array (const ACE_CDR::LongDouble* x, 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, @@ -383,15 +445,19 @@ ACE_OutputCDR::adjust (size_t size, { 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) { @@ -399,24 +465,30 @@ ACE_OutputCDR::adjust (size_t size, 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) { @@ -424,41 +496,49 @@ ACE_OutputCDR::get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor) 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 { @@ -467,11 +547,13 @@ ACE_OutputCDR::byte_order (void) const 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 { @@ -482,6 +564,7 @@ ACE_OutputCDR::current_alignment (void) const return 0; #endif /* ACE_LACKS_CDR_ALIGNMENT */ } + ACE_INLINE void ACE_OutputCDR::current_alignment (size_t current_alignment) { @@ -492,6 +575,7 @@ ACE_OutputCDR::current_alignment (size_t current_alignment) return 0; #endif /* ACE_LACKS_CDR_ALIGNMENT */ } + ACE_INLINE int ACE_OutputCDR::align_write_ptr (size_t alignment) { @@ -505,27 +589,33 @@ ACE_OutputCDR::align_write_ptr (size_t alignment) 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) { @@ -533,11 +623,13 @@ ACE_InputCDR::~ACE_InputCDR (void) 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) { @@ -546,6 +638,7 @@ ACE_InputCDR::read_boolean (ACE_CDR::Boolean& x) x = tmp ? true : false; return (ACE_CDR::Boolean) this->good_bit_; } + ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_char (ACE_CDR::Char &x) { @@ -557,18 +650,21 @@ ACE_InputCDR::read_char (ACE_CDR::Char &x) 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) { @@ -576,45 +672,53 @@ ACE_InputCDR::read_long (ACE_CDR::Long &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) @@ -626,6 +730,7 @@ ACE_InputCDR::read_char_array (ACE_CDR::Char* x, this->good_bit_ = false; return false; } + if (this->char_translator_ == 0) return this->read_array (x, ACE_CDR::OCTET_SIZE, @@ -633,6 +738,7 @@ ACE_InputCDR::read_char_array (ACE_CDR::Char* x, 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) @@ -644,6 +750,7 @@ ACE_InputCDR::read_wchar_array (ACE_CDR::WChar* x, 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)) @@ -655,6 +762,7 @@ ACE_InputCDR::read_wchar_array (ACE_CDR::WChar* x, : ACE_CDR::LONG_ALIGN, length); } + ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_octet_array (ACE_CDR::Octet* x, ACE_CDR::ULong length) @@ -666,11 +774,13 @@ ACE_InputCDR::read_octet_array (ACE_CDR::Octet* x, 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) @@ -682,11 +792,13 @@ ACE_InputCDR::read_short_array (ACE_CDR::Short *x, 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) @@ -698,11 +810,13 @@ ACE_InputCDR::read_ushort_array (ACE_CDR::UShort *x, 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) @@ -714,11 +828,13 @@ ACE_InputCDR::read_long_array (ACE_CDR::Long *x, 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) @@ -730,11 +846,13 @@ ACE_InputCDR::read_ulong_array (ACE_CDR::ULong *x, 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) @@ -746,11 +864,13 @@ ACE_InputCDR::read_longlong_array (ACE_CDR::LongLong *x, 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) @@ -762,11 +882,13 @@ ACE_InputCDR::read_ulonglong_array (ACE_CDR::ULongLong *x, 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) @@ -778,12 +900,14 @@ ACE_InputCDR::read_float_array (ACE_CDR::Float *x, 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) @@ -795,11 +919,13 @@ ACE_InputCDR::read_double_array (ACE_CDR::Double *x, 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) @@ -816,91 +942,108 @@ ACE_InputCDR::read_longdouble_array (ACE_CDR::LongDouble* x, 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, @@ -911,107 +1054,126 @@ ACE_InputCDR::adjust (size_t size, #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) @@ -1019,130 +1181,157 @@ 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) { @@ -1153,6 +1342,7 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_string x) && (!x.bound_ || ACE_OS::strlen (x.val_) <= x.bound_)); } + ACE_INLINE ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wstring x) { @@ -1163,88 +1353,103 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wstring x) && (!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) { @@ -1254,6 +1459,7 @@ ACE_OutputCDR::append_string (ACE_InputCDR &stream) delete [] x; return flag; } + ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_wstring (ACE_InputCDR &stream) { @@ -1263,21 +1469,25 @@ ACE_OutputCDR::append_wstring (ACE_InputCDR &stream) 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) { @@ -1287,60 +1497,72 @@ ACE_InputCDR::align_read_ptr (size_t 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, @@ -1350,6 +1572,7 @@ ACE_Char_Codeset_Translator::read_array (ACE_InputCDR& in, { 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, @@ -1359,6 +1582,7 @@ ACE_Char_Codeset_Translator::write_array (ACE_OutputCDR& out, { return out.write_array(x, size, align, length); } + ACE_INLINE int ACE_Char_Codeset_Translator::adjust (ACE_OutputCDR& out, size_t size, @@ -1367,68 +1591,81 @@ ACE_Char_Codeset_Translator::adjust (ACE_OutputCDR& out, { 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, @@ -1438,6 +1675,7 @@ ACE_WChar_Codeset_Translator::read_array (ACE_InputCDR& in, { 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, @@ -1447,6 +1685,7 @@ ACE_WChar_Codeset_Translator::write_array (ACE_OutputCDR& out, { return out.write_array(x, size, align, length); } + ACE_INLINE int ACE_WChar_Codeset_Translator::adjust (ACE_OutputCDR& out, size_t size, @@ -1455,29 +1694,35 @@ ACE_WChar_Codeset_Translator::adjust (ACE_OutputCDR& out, { 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.h b/dep/ACE_wrappers/ace/CE_Screen_Output.h index 5c66b2d7f70..e4a3e3d92b0 100644 --- a/dep/ACE_wrappers/ace/CE_Screen_Output.h +++ b/dep/ACE_wrappers/ace/CE_Screen_Output.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file CE_Screen_Output.h @@ -8,21 +9,29 @@ * @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 * @@ -39,14 +48,21 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 @@ -55,26 +71,40 @@ public: */ 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 index 48dd70132c0..ce45893b0a2 100644 --- a/dep/ACE_wrappers/ace/CORBA_macros.h +++ b/dep/ACE_wrappers/ace/CORBA_macros.h @@ -1,4 +1,5 @@ // -*- C++ -*- + // ============================================================================ /** * @file CORBA_macros.h @@ -15,16 +16,24 @@ * @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 @@ -37,7 +46,9 @@ #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: @@ -71,36 +82,46 @@ // 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) @@ -111,33 +132,44 @@ # 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 \ @@ -155,45 +187,58 @@ { \ 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. @@ -204,8 +249,10 @@ # 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. @@ -215,12 +262,14 @@ 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 @@ -236,6 +285,7 @@ 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. @@ -247,6 +297,7 @@ 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 @@ -258,6 +309,7 @@ ACE_TRY_LABEL ## LABEL: \ if (ACE_TRY_FLAG) \ do { + // Check for exceptions within try blocks. # define ACE_TRY_CHECK \ { \ @@ -267,6 +319,7 @@ goto ACE_TRY_LABEL; \ } \ } + // Checking exception within EX try blocks. # define ACE_TRY_CHECK_EX(LABEL) \ { \ @@ -276,6 +329,7 @@ goto ACE_TRY_LABEL ## LABEL; \ } \ } + // Throwing exception within TRY blocks. # define ACE_TRY_THROW(EXCEPTION) \ { \ @@ -283,12 +337,14 @@ 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 @@ -310,19 +366,23 @@ 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 @@ -337,6 +397,7 @@ 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 @@ -344,37 +405,53 @@ # 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. @@ -384,20 +461,24 @@ * 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 /** @@ -412,6 +493,7 @@ #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. /** @@ -423,6 +505,7 @@ 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. /** @@ -432,10 +515,12 @@ #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 @@ -443,38 +528,49 @@ #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.h b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.h index a6200bfc449..1476597ab54 100644 --- a/dep/ACE_wrappers/ace/Cache_Map_Manager_T.h +++ b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Cache_Map_Manager_T.h @@ -8,27 +9,39 @@ * @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 * @@ -48,45 +61,57 @@ template ; 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 @@ -95,6 +120,7 @@ public: */ 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 @@ -104,6 +130,7 @@ public: */ 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 @@ -112,6 +139,7 @@ public: * 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 @@ -119,6 +147,7 @@ public: */ 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 @@ -129,6 +158,7 @@ public: 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 @@ -141,6 +171,7 @@ public: 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 @@ -151,41 +182,59 @@ public: */ 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 * @@ -197,7 +246,9 @@ private: 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. @@ -205,44 +256,62 @@ public: 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 * @@ -255,59 +324,83 @@ template /// 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 index d850b314f32..bcd48bd33e9 100644 --- a/dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl +++ b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl @@ -1,43 +1,52 @@ // -*- 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) { @@ -48,28 +57,34 @@ ACE_Cache_Map_Managermap_.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 { @@ -77,6 +92,7 @@ ACE_Cache_Map_Iterator (*this->iterator_implementation_).int_id_.first ()); return retn; } + template ACE_INLINE ACE_Cache_Map_Iterator & ACE_Cache_Map_Iterator::operator++ (void) @@ -84,6 +100,7 @@ ACE_Cache_Map_Iterator ++this->iterator_implementation_; return *this; } + template ACE_INLINE ACE_Cache_Map_Iterator ACE_Cache_Map_Iterator::operator++ (int) @@ -92,6 +109,7 @@ ACE_Cache_Map_Iterator ++this->iterator_implementation_; return retn; } + template ACE_INLINE ACE_Cache_Map_Iterator & ACE_Cache_Map_Iterator::operator-- (void) @@ -99,6 +117,7 @@ ACE_Cache_Map_Iterator --this->iterator_implementation_; return *this; } + template ACE_INLINE ACE_Cache_Map_Iterator ACE_Cache_Map_Iterator::operator-- (int) @@ -107,6 +126,7 @@ ACE_Cache_Map_Iterator --this->iterator_implementation_; return retn; } + template ACE_INLINE void ACE_Cache_Map_Iterator::dump (void) const { @@ -114,42 +134,51 @@ ACE_Cache_Map_Iterator 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 { @@ -157,6 +186,7 @@ ACE_Cache_Map_Reverse_Iteratorreverse_iterator_implementation_).int_id_.first ()); return retv; } + template ACE_INLINE ACE_Cache_Map_Reverse_Iterator & ACE_Cache_Map_Reverse_Iterator::operator++ (void) @@ -164,6 +194,7 @@ ACE_Cache_Map_Reverse_Iteratorreverse_iterator_implementation_; return *this; } + template ACE_INLINE ACE_Cache_Map_Reverse_Iterator ACE_Cache_Map_Reverse_Iterator::operator++ (int) @@ -172,6 +203,7 @@ ACE_Cache_Map_Reverse_Iteratorreverse_iterator_implementation_; return retn; } + template ACE_INLINE ACE_Cache_Map_Reverse_Iterator & ACE_Cache_Map_Reverse_Iterator::operator-- (void) @@ -179,6 +211,7 @@ ACE_Cache_Map_Reverse_Iteratorreverse_iterator_implementation_; return *this; } + template ACE_INLINE ACE_Cache_Map_Reverse_Iterator ACE_Cache_Map_Reverse_Iterator::operator-- (int) @@ -188,6 +221,7 @@ ACE_Cache_Map_Reverse_Iterator ACE_INLINE void ACE_Cache_Map_Reverse_Iterator::dump (void) const { @@ -195,14 +229,17 @@ ACE_Cache_Map_Reverse_Iteratorreverse_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.h b/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h index 0c077c77e06..9f3227b54f1 100644 --- a/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h +++ b/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Cached_Connect_Strategy_T.h @@ -8,21 +9,29 @@ * @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 * @@ -48,19 +57,24 @@ public: 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; @@ -74,6 +88,7 @@ public: 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, 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, @@ -111,6 +135,7 @@ protected: 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, @@ -120,6 +145,7 @@ protected: 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, @@ -128,6 +154,7 @@ protected: 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 @@ -144,12 +171,16 @@ protected: 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 * @@ -173,12 +204,16 @@ template { + 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, @@ -187,11 +222,15 @@ public: 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, @@ -202,17 +241,23 @@ protected: 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.h b/dep/ACE_wrappers/ace/Caching_Strategies_T.h index 82aeb9c10ba..d78332e41f5 100644 --- a/dep/ACE_wrappers/ace/Caching_Strategies_T.h +++ b/dep/ACE_wrappers/ace/Caching_Strategies_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Caching_Strategies_T.h @@ -8,20 +9,28 @@ * @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 * @@ -37,40 +46,54 @@ 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 * @@ -86,53 +109,73 @@ 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 * @@ -156,9 +199,12 @@ 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 @@ -167,51 +213,69 @@ public: * 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 * @@ -234,10 +298,14 @@ private: 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 @@ -246,46 +314,63 @@ public: * 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 * @@ -306,9 +391,13 @@ private: 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 @@ -317,48 +406,66 @@ public: * 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 * @@ -371,54 +478,76 @@ private: 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 index 8463e1cd650..41fa2d30301 100644 --- a/dep/ACE_wrappers/ace/Caching_Strategies_T.inl +++ b/dep/ACE_wrappers/ace/Caching_Strategies_T.inl @@ -1,9 +1,13 @@ // -*-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) @@ -17,6 +21,7 @@ ACE_Caching_Strategy_Adapter::ACE_C this->delete_implementation_ = true; } } + template ACE_INLINE ACE_Caching_Strategy_Adapter::~ACE_Caching_Strategy_Adapter (void) { @@ -27,21 +32,25 @@ ACE_Caching_Strategy_Adapter::~ACE_ 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) @@ -49,6 +58,7 @@ ACE_Caching_Strategy_Adapter::notif return this->implementation_->notify_bind (result, attr); } + template ACE_INLINE int ACE_Caching_Strategy_Adapter::notify_find (int result, ATTRIBUTES &attr) @@ -56,6 +66,7 @@ ACE_Caching_Strategy_Adapter::notif return this->implementation_->notify_find (result, attr); } + template ACE_INLINE int ACE_Caching_Strategy_Adapter::notify_unbind (int result, const ATTRIBUTES &attr) @@ -63,6 +74,7 @@ ACE_Caching_Strategy_Adapter::notif return this->implementation_->notify_unbind (result, attr); } + template ACE_INLINE int ACE_Caching_Strategy_Adapter::notify_trybind (int result, ATTRIBUTES &attr) @@ -70,6 +82,7 @@ ACE_Caching_Strategy_Adapter::notif return this->implementation_->notify_trybind (result, attr); } + template ACE_INLINE int ACE_Caching_Strategy_Adapter::notify_rebind (int result, const ATTRIBUTES &attr) @@ -77,41 +90,50 @@ ACE_Caching_Strategy_Adapter::notif 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, @@ -119,8 +141,10 @@ ACE_LRU_Caching_Strategy::notify_bind ( { if (result == 0) ++this->timer_; + return result; } + template ACE_INLINE int ACE_LRU_Caching_Strategy::notify_find ( int result, @@ -131,8 +155,10 @@ ACE_LRU_Caching_Strategy::notify_find ( attr = this->timer_; ++this->timer_; } + return result; } + template ACE_INLINE int ACE_LRU_Caching_Strategy::notify_unbind ( int result, @@ -140,6 +166,7 @@ ACE_LRU_Caching_Strategy::notify_unbind ( { return result; } + template ACE_INLINE int ACE_LRU_Caching_Strategy::notify_trybind ( int result, @@ -147,6 +174,7 @@ ACE_LRU_Caching_Strategy::notify_trybind ( { return result; } + template ACE_INLINE int ACE_LRU_Caching_Strategy::notify_rebind ( int result, @@ -154,219 +182,275 @@ ACE_LRU_Caching_Strategy::notify_rebind ( { 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.h b/dep/ACE_wrappers/ace/Caching_Utility_T.h index 61a45bff0af..9859159be4c 100644 --- a/dep/ACE_wrappers/ace/Caching_Utility_T.h +++ b/dep/ACE_wrappers/ace/Caching_Utility_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Caching_Utility_T.h @@ -8,18 +9,26 @@ * @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 * @@ -38,33 +47,44 @@ template 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 * @@ -82,14 +102,19 @@ protected: 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 @@ -97,21 +122,28 @@ public: */ 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 * @@ -130,14 +162,19 @@ private: 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 @@ -145,26 +182,34 @@ public: */ 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 * @@ -183,13 +228,17 @@ template 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 @@ -197,7 +246,9 @@ public: */ 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 @@ -207,15 +258,19 @@ protected: 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 /** @@ -234,13 +289,17 @@ template 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 @@ -248,7 +307,9 @@ public: */ 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 @@ -258,22 +319,30 @@ protected: 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 index c64417095f7..4f8151d1bc6 100644 --- a/dep/ACE_wrappers/ace/Capabilities.cpp +++ b/dep/ACE_wrappers/ace/Capabilities.cpp @@ -2,27 +2,36 @@ #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) { @@ -68,6 +77,7 @@ ACE_Capabilities::parse (const ACE_TCHAR *buf, ACE_TString &cap) i < 3 && *buf && ACE_OS::ace_isdigit (*buf); i++) oc = oc * 8 + (*buf++ - ACE_TEXT ('0')); + cap += (ACE_TCHAR) oc; continue; } @@ -76,15 +86,20 @@ ACE_Capabilities::parse (const ACE_TCHAR *buf, ACE_TString &cap) } 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) { @@ -96,9 +111,11 @@ ACE_Capabilities::resetcaps (void) iter.next (entry); delete entry->int_id_; } + this->caps_.close (); this->caps_.open (); } + int ACE_Capabilities::fillent (const ACE_TCHAR *buf) { @@ -109,11 +126,14 @@ ACE_Capabilities::fillent (const ACE_TCHAR *buf) 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')) @@ -126,6 +146,7 @@ ACE_Capabilities::fillent (const ACE_TCHAR *buf) && *buf!= ACE_TEXT ('#') && *buf != ACE_TEXT (',')) name += *buf++; + // If name is null. switch (*buf) { @@ -167,11 +188,14 @@ ACE_Capabilities::fillent (const ACE_TCHAR *buf) default: return 0; } + if (*buf++ != ACE_TEXT (',')) return -1; } + return 0; } + int ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line) { @@ -180,16 +204,20 @@ ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line) // 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; @@ -202,37 +230,46 @@ ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line) } 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) @@ -240,63 +277,80 @@ ACE_Capabilities::getval (const ACE_TCHAR *keyname, int &val) 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 index f25d8fbb914..459afd1c681 100644 --- a/dep/ACE_wrappers/ace/Capabilities.h +++ b/dep/ACE_wrappers/ace/Capabilities.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Capabilities.h @@ -9,23 +10,30 @@ */ //============================================================================= + #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 * @@ -39,18 +47,26 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 * @@ -64,9 +80,11 @@ class ACE_Export ACE_IntCapEntry : public ACE_CapEntry public: ACE_IntCapEntry (int val); int getval (void) const; + protected: int val_; }; + /** * @class ACE_StringCapEntry * @@ -80,9 +98,11 @@ 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 * @@ -96,9 +116,11 @@ class ACE_Export ACE_BoolCapEntry : public ACE_CapEntry public: ACE_BoolCapEntry (int val); int getval (void) const; + protected: int val_; }; + /** * @class ACE_Capabilities * @@ -117,59 +139,84 @@ protected: 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 index de65bf36a67..37284b28696 100644 --- a/dep/ACE_wrappers/ace/Capabilities.inl +++ b/dep/ACE_wrappers/ace/Capabilities.inl @@ -1,43 +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 index e71b082982d..960e74fffa4 100644 --- a/dep/ACE_wrappers/ace/Cleanup.cpp +++ b/dep/ACE_wrappers/ace/Cleanup.cpp @@ -1,35 +1,47 @@ // $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 { @@ -37,12 +49,15 @@ ACE_Cleanup_Info::operator== (const ACE_Cleanup_Info &o) const && 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 * @@ -61,42 +76,53 @@ public: 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, @@ -106,9 +132,12 @@ ACE_OS_Exit_Info::at_exit_i (void *object, 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 @@ -117,6 +146,7 @@ ACE_OS_Exit_Info::at_exit_i (void *object, return 0; } } + int ACE_OS_Exit_Info::find (void *object) { @@ -131,8 +161,10 @@ ACE_OS_Exit_Info::find (void *object) return 1; } } + return 0; } + void ACE_OS_Exit_Info::call_hooks (void) { @@ -156,5 +188,6 @@ ACE_OS_Exit_Info::call_hooks (void) (*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 index 5f38ace7276..c38db701360 100644 --- a/dep/ACE_wrappers/ace/Cleanup.h +++ b/dep/ACE_wrappers/ace/Cleanup.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Cleanup.h @@ -12,21 +13,29 @@ * 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 * @@ -37,14 +46,18 @@ 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 * @@ -55,18 +68,25 @@ 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 * @@ -79,16 +99,21 @@ 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 @@ -97,7 +122,9 @@ private: */ ACE_Cleanup_Info_Node *registered_objects_; }; + ACE_END_VERSIONED_NAMESPACE_DECL + # if defined (ACE_HAS_INLINED_OSCALLS) # if defined (ACE_INLINE) # undef ACE_INLINE @@ -105,6 +132,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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 index a9dadfef182..9c36d6b1ffd 100644 --- a/dep/ACE_wrappers/ace/Cleanup.inl +++ b/dep/ACE_wrappers/ace/Cleanup.inl @@ -1,9 +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.h b/dep/ACE_wrappers/ace/Cleanup_Strategies_T.h index 24ccd9d8516..776ae28441b 100644 --- a/dep/ACE_wrappers/ace/Cleanup_Strategies_T.h +++ b/dep/ACE_wrappers/ace/Cleanup_Strategies_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Cleanup_Strategies_T.h @@ -9,16 +10,22 @@ */ //============================================================================= + #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 * @@ -31,14 +38,19 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 * @@ -53,12 +65,16 @@ public: 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 * @@ -77,7 +93,9 @@ 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 * @@ -97,8 +115,10 @@ 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 * @@ -114,13 +134,17 @@ 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 index 7556b76088c..d0bb0778304 100644 --- a/dep/ACE_wrappers/ace/Codecs.cpp +++ b/dep/ACE_wrappers/ace/Codecs.cpp @@ -2,28 +2,38 @@ #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, @@ -32,21 +42,27 @@ ACE_Base64::encode (const ACE_Byte* input, { 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]; @@ -67,6 +83,7 @@ ACE_Base64::encode (const ACE_Byte* input, bits <<= 8; } } + if (char_count != 0) { bits <<= (16 - (8 * char_count)); @@ -86,17 +103,21 @@ ACE_Base64::encode (const ACE_Byte* input, 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 @@ -106,25 +127,31 @@ ACE_Base64::length (const ACE_Byte* 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) { @@ -134,6 +161,7 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) continue; bits += decoder_[input[i]]; ++char_count; + if (char_count == 4) { result[pos++] = static_cast (bits >> 16); @@ -147,6 +175,7 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) bits <<= 6; } } + int errors = 0; if ( i == input_len) { @@ -176,6 +205,7 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) break; } } + if (errors) { delete[] result; @@ -185,6 +215,7 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) *output_len = pos; return result; } + void ACE_Base64::init () { @@ -199,5 +230,6 @@ ACE_Base64::init () } return; } + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Codecs.h b/dep/ACE_wrappers/ace/Codecs.h index adde72115f1..0e0f13ac319 100644 --- a/dep/ACE_wrappers/ace/Codecs.h +++ b/dep/ACE_wrappers/ace/Codecs.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Codecs.h @@ -14,17 +15,24 @@ * */ //============================================================================= + #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 * @@ -38,7 +46,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_Export ACE_Base64 { public: + //@{ + /** * Encodes a stream of bytes to Base64 data * @@ -49,6 +59,7 @@ public: * @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, @@ -63,6 +74,7 @@ public: */ static ACE_Byte* decode (const ACE_Byte* input, size_t* output_len); + /** * Return the length of the encoded input data * @@ -71,26 +83,40 @@ public: * */ 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 index b91717db347..62488c8927c 100644 --- a/dep/ACE_wrappers/ace/Codeset_IBM1047.cpp +++ b/dep/ACE_wrappers/ace/Codeset_IBM1047.cpp @@ -13,13 +13,18 @@ */ //============================================================================= + #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[] = @@ -41,6 +46,7 @@ namespace "\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 @@ -61,23 +67,29 @@ namespace "\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) @@ -89,24 +101,31 @@ ACE_IBM1047_ISO8859::read_char (ACE_InputCDR &in, } 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, @@ -120,10 +139,13 @@ ACE_IBM1047_ISO8859::read_char_array (ACE_InputCDR& in, { 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) @@ -132,6 +154,7 @@ ACE_IBM1047_ISO8859::write_char (ACE_OutputCDR& out, this->write_1 (out, reinterpret_cast (&from_IBM1047[x])); } + ACE_CDR::Boolean ACE_IBM1047_ISO8859::write_string (ACE_OutputCDR& out, ACE_CDR::ULong len, @@ -141,6 +164,7 @@ ACE_IBM1047_ISO8859::write_string (ACE_OutputCDR& out, 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, @@ -150,30 +174,39 @@ ACE_IBM1047_ISO8859::write_char_array (ACE_OutputCDR& out, 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) @@ -185,24 +218,31 @@ ACE_ISO8859_IBM1047::read_char (ACE_InputCDR& in, } 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, @@ -216,10 +256,13 @@ ACE_ISO8859_IBM1047::read_char_array (ACE_InputCDR &in, { 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) @@ -228,6 +271,7 @@ ACE_ISO8859_IBM1047::write_char (ACE_OutputCDR &out, this->write_1 (out, reinterpret_cast (&to_IBM1047[x])); } + ACE_CDR::Boolean ACE_ISO8859_IBM1047::write_string (ACE_OutputCDR& out, ACE_CDR::ULong len, @@ -238,22 +282,29 @@ ACE_ISO8859_IBM1047::write_string (ACE_OutputCDR& out, 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 index e3feebf539b..7e0df2b5c08 100644 --- a/dep/ACE_wrappers/ace/Codeset_IBM1047.h +++ b/dep/ACE_wrappers/ace/Codeset_IBM1047.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Codeset_IBM1047.h @@ -12,17 +13,25 @@ */ //============================================================================= + #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 * @@ -37,8 +46,10 @@ 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 &); @@ -55,6 +66,7 @@ public: 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 (); @@ -62,6 +74,7 @@ public: /// set registry, 0x00010001 virtual ACE_CDR::ULong tcs (); }; + /** * @class ACE_ISO8859_IBM1047 * @@ -76,8 +89,10 @@ 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 &); @@ -94,6 +109,7 @@ public: 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 (); @@ -101,8 +117,12 @@ public: /// 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 index 98b084377a4..789340af33c 100644 --- a/dep/ACE_wrappers/ace/Codeset_Registry.cpp +++ b/dep/ACE_wrappers/ace/Codeset_Registry.cpp @@ -10,17 +10,23 @@ * @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, @@ -44,6 +50,7 @@ ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale, } return 1; } + int ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id, ACE_CString &locale, @@ -67,6 +74,7 @@ ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id, } return 1; } + int ACE_Codeset_Registry::is_compatible_i (ACE_CDR::ULong codeset_id, ACE_CDR::ULong other) @@ -80,14 +88,17 @@ ACE_Codeset_Registry::is_compatible_i (ACE_CDR::ULong codeset_id, 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) { @@ -96,5 +107,6 @@ ACE_Codeset_Registry::get_max_bytes_i (ACE_CDR::ULong 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 index 441a8188089..80887d9a106 100644 --- a/dep/ACE_wrappers/ace/Codeset_Registry.h +++ b/dep/ACE_wrappers/ace/Codeset_Registry.h @@ -20,41 +20,52 @@ * @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 { @@ -65,9 +76,11 @@ protected: 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, @@ -80,10 +93,13 @@ private: 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 index a27444f52b4..4419cf5e7fc 100644 --- a/dep/ACE_wrappers/ace/Codeset_Registry.inl +++ b/dep/ACE_wrappers/ace/Codeset_Registry.inl @@ -13,7 +13,9 @@ * @author Phil Mesnier */ //============================================================================= + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + ACE_INLINE int ACE_Codeset_Registry::locale_to_registry(const ACE_CString &locale, @@ -36,6 +38,7 @@ ACE_Codeset_Registry::locale_to_registry(const ACE_CString &locale, 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 @@ -63,6 +66,7 @@ ACE_Codeset_Registry::registry_to_locale(ACE_CDR::ULong codeset_id, 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 @@ -78,6 +82,7 @@ ACE_Codeset_Registry::is_compatible (ACE_CDR::ULong codeset_id, 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 @@ -93,4 +98,5 @@ ACE_Codeset_Registry::get_max_bytes (ACE_CDR::ULong codeset_id) 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 index 05d3bf983cb..1f900db9b4f 100644 --- a/dep/ACE_wrappers/ace/Codeset_Registry_db.cpp +++ b/dep/ACE_wrappers/ace/Codeset_Registry_db.cpp @@ -9,8 +9,11 @@ * 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_[] = { @@ -24,6 +27,8 @@ ACE_Codeset_Registry::registry_db_[] = {"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 index 2f52c35578e..2cfb6bc26b6 100644 --- a/dep/ACE_wrappers/ace/Codeset_Symbols.h +++ b/dep/ACE_wrappers/ace/Codeset_Symbols.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Codeset_Symbols.h @@ -12,6 +13,7 @@ //============================================================================= #ifndef CODESET_SYMBOLS_H #define CODESET_SYMBOLS_H + // These numbers are assigned by the OpenGroup, a database is // available at // @@ -213,6 +215,7 @@ #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 index 00542479376..658100f1818 100644 --- a/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.cpp +++ b/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.cpp @@ -1,4 +1,5 @@ // -*- C++ -*- + /** * @file Condition_Recursive_Thread_Mutex.cpp * @@ -8,22 +9,29 @@ * * @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 (); @@ -32,29 +40,35 @@ ACE_Condition::dump (void) const 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 @@ -82,28 +96,35 @@ ACE_Condition::wait (ACE_Recursive_Thread_Mutex &mut 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 index 33eb522b8c3..8625aa2fcea 100644 --- a/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.h +++ b/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Condition_Recursive_Thread_Mutex.h @@ -10,19 +11,26 @@ * @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 * @@ -36,14 +44,17 @@ 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 @@ -51,6 +62,7 @@ public: * 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 @@ -61,24 +73,35 @@ public: */ 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 { @@ -86,8 +109,11 @@ 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.h b/dep/ACE_wrappers/ace/Condition_T.h index 02bd5f56e9b..8e6132ec92c 100644 --- a/dep/ACE_wrappers/ace/Condition_T.h +++ b/dep/ACE_wrappers/ace/Condition_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Condition_T.h @@ -10,17 +11,25 @@ * @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 * @@ -49,8 +58,10 @@ public: /// 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 @@ -59,8 +70,10 @@ public: * 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 @@ -70,29 +83,39 @@ public: * 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 * @@ -116,22 +139,30 @@ 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 index d8c74727ad8..e3b452734a2 100644 --- a/dep/ACE_wrappers/ace/Condition_T.inl +++ b/dep/ACE_wrappers/ace/Condition_T.inl @@ -1,41 +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 index da3e7397e03..d1142f72172 100644 --- a/dep/ACE_wrappers/ace/Condition_Thread_Mutex.cpp +++ b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.cpp @@ -8,20 +8,29 @@ * * @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) @@ -32,6 +41,7 @@ ACE_Condition_Thread_Mutex::dump (void) const 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) @@ -47,6 +57,7 @@ ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, 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, @@ -61,20 +72,24 @@ ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, 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) @@ -84,24 +99,29 @@ ACE_Condition_Thread_Mutex::wait (ACE_Thread_Mutex &mutex, &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 index 4889ad28a80..bc47ae2514a 100644 --- a/dep/ACE_wrappers/ace/Condition_Thread_Mutex.h +++ b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Condition_Thread_Mutex.h @@ -10,36 +11,49 @@ * @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 * @@ -67,19 +81,23 @@ public: 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 @@ -87,8 +105,10 @@ public: * 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 @@ -98,37 +118,48 @@ public: * 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 * @@ -138,17 +169,23 @@ 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 index e99d4780fef..851269e4af6 100644 --- a/dep/ACE_wrappers/ace/Condition_Thread_Mutex.inl +++ b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.inl @@ -1,30 +1,38 @@ // -*- 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) { @@ -34,21 +42,25 @@ ACE_Condition_Thread_Mutex::remove (void) } 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, @@ -58,4 +70,5 @@ ACE_Process_Condition::ACE_Process_Condition (MUTEX &m, // 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 index 2cd03a12ac6..fd8548d9e8d 100644 --- a/dep/ACE_wrappers/ace/Configuration.cpp +++ b/dep/ACE_wrappers/ace/Configuration.cpp @@ -4,29 +4,37 @@ #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) { @@ -34,27 +42,32 @@ ACE_Section_Key_Internal::dec_ref (void) 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) { @@ -62,26 +75,34 @@ ACE_Configuration_Section_Key::operator= (const ACE_Configuration_Section_Key& r { 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, @@ -94,6 +115,7 @@ ACE_Configuration::expand_path (const ACE_Configuration_Section_Key& key, ACE_Tokenizer parser (pData.get ()); parser.delimiter_replace ('\\', '\0'); parser.delimiter_replace ('/', '\0'); + for (ACE_TCHAR *temp = parser.next (); temp != 0; temp = parser.next ()) @@ -104,10 +126,14 @@ ACE_Configuration::expand_path (const ACE_Configuration_Section_Key& key, 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 @@ -116,52 +142,63 @@ 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. @@ -175,9 +212,11 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const 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, @@ -208,6 +247,7 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const ACE_TString valueName; VALUETYPE valueType; VALUETYPE rhsType; + // Enumerate each value in this section while ((rc) && nonconst_this->enumerate_values (thisSection, valueIndex, @@ -296,8 +336,10 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const // 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 = @@ -310,6 +352,7 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const { rc = (* (thisCharData + count) == * (rhsCharData + count)); } + delete [] thisCharData; delete [] rhsCharData; }// end if the length's match @@ -318,9 +361,13 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const // 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, @@ -339,9 +386,13 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const } ++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; @@ -372,51 +423,66 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const } 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, @@ -425,9 +491,11 @@ ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_K { 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, @@ -441,6 +509,7 @@ ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_K errno = errnum; return -1; } + if ((errnum = ACE_TEXT_RegCreateKeyEx (base_key, sub_section, 0, @@ -460,11 +529,14 @@ ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_K 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, @@ -472,17 +544,21 @@ ACE_Configuration_Win32Registry::remove_section (const ACE_Configuration_Section { 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 @@ -502,6 +578,7 @@ ACE_Configuration_Win32Registry::remove_section (const ACE_Configuration_Section buffer_size = ACE_DEFAULT_BUFSIZE; } } + int errnum; errnum = ACE_TEXT_RegDeleteKey (base_key, sub_section); if (errnum != ERROR_SUCCESS) @@ -509,8 +586,10 @@ ACE_Configuration_Win32Registry::remove_section (const ACE_Configuration_Section errno = errnum; return -1; } + return 0; } + int ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Section_Key& key, int index, @@ -520,9 +599,11 @@ ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Secti 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, @@ -538,7 +619,9 @@ ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Secti errno = rc; return -1; } + name = name_buffer; + switch (value_type) { case REG_BINARY: @@ -553,8 +636,10 @@ ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Secti default: type = INVALID; } + return 0; } + int ACE_Configuration_Win32Registry::enumerate_sections (const ACE_Configuration_Section_Key& key, int index, @@ -563,6 +648,7 @@ ACE_Configuration_Win32Registry::enumerate_sections (const ACE_Configuration_Sec 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, @@ -580,9 +666,12 @@ ACE_Configuration_Win32Registry::enumerate_sections (const ACE_Configuration_Sec 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, @@ -591,9 +680,11 @@ ACE_Configuration_Win32Registry::set_string_value (const ACE_Configuration_Secti 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); @@ -608,8 +699,10 @@ ACE_Configuration_Win32Registry::set_string_value (const ACE_Configuration_Secti errno = errnum; return -1; } + return 0; } + int ACE_Configuration_Win32Registry::set_integer_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -618,9 +711,11 @@ ACE_Configuration_Win32Registry::set_integer_value (const ACE_Configuration_Sect 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, @@ -632,8 +727,10 @@ ACE_Configuration_Win32Registry::set_integer_value (const ACE_Configuration_Sect errno = errnum; return -1; } + return 0; } + int ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -643,9 +740,11 @@ ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Secti 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, @@ -658,8 +757,10 @@ ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Secti errno = errnum; return -1; } + return 0; } + int ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -668,9 +769,11 @@ ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Secti 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; @@ -685,16 +788,20 @@ ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Secti 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, @@ -705,9 +812,11 @@ ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Secti 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, @@ -716,9 +825,11 @@ ACE_Configuration_Win32Registry::get_integer_value (const ACE_Configuration_Sect 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; @@ -732,13 +843,16 @@ ACE_Configuration_Win32Registry::get_integer_value (const ACE_Configuration_Sect 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, @@ -749,9 +863,11 @@ ACE_Configuration_Win32Registry::get_binary_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; @@ -766,15 +882,19 @@ ACE_Configuration_Win32Registry::get_binary_value ( 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, @@ -786,9 +906,12 @@ ACE_Configuration_Win32Registry::get_binary_value ( 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, @@ -797,9 +920,11 @@ ACE_Configuration_Win32Registry::find_value (const ACE_Configuration_Section_Key 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, @@ -813,6 +938,7 @@ ACE_Configuration_Win32Registry::find_value (const ACE_Configuration_Section_Key errno = result; return -1; } + switch (type) { case REG_SZ: @@ -827,8 +953,10 @@ ACE_Configuration_Win32Registry::find_value (const ACE_Configuration_Section_Key default: return -1; // unknown type } + return 0; } + int ACE_Configuration_Win32Registry::remove_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name) @@ -836,18 +964,22 @@ ACE_Configuration_Win32Registry::remove_value (const ACE_Configuration_Section_K 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) @@ -855,9 +987,11 @@ ACE_Configuration_Win32Registry::load_key (const ACE_Configuration_Section_Key& 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, @@ -875,6 +1009,7 @@ ACE_Configuration_Win32Registry::resolve_key (HKEY hKey, errno = errnum; return 0; } + // recurse through the path ACE_TCHAR *temp_path = 0; ACE_NEW_RETURN (temp_path, @@ -885,12 +1020,14 @@ ACE_Configuration_Win32Registry::resolve_key (HKEY hKey, 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, @@ -929,43 +1066,53 @@ ACE_Configuration_Win32Registry::resolve_key (HKEY hKey, ::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) @@ -976,6 +1123,7 @@ ACE_Configuration_Value_IntId& ACE_Configuration_Value_IntId::operator= (const A } return *this; } + void ACE_Configuration_Value_IntId::free (ACE_Allocator *alloc) { @@ -984,67 +1132,84 @@ ACE_Configuration_Value_IntId::free (ACE_Allocator *alloc) 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) { @@ -1055,12 +1220,14 @@ ACE_Configuration_Section_IntId::operator= (const ACE_Configuration_Section_IntI } 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), @@ -1068,28 +1235,35 @@ ACE_Configuration_Section_Key_Heap::ACE_Configuration_Section_Key_Heap (const AC { 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) { @@ -1103,19 +1277,23 @@ ACE_Configuration_Heap::open (size_t default_map_size) 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_, @@ -1123,6 +1301,7 @@ ACE_Configuration_Heap::open (const ACE_TCHAR* 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) @@ -1130,22 +1309,27 @@ ACE_Configuration_Heap::open (const ACE_TCHAR* file_name, 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, @@ -1162,6 +1346,7 @@ ACE_Configuration_Heap::create_index (void) } return 0; } + int ACE_Configuration_Heap::create_index_helper (void *buffer) { @@ -1169,6 +1354,7 @@ ACE_Configuration_Heap::create_index_helper (void *buffer) 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) @@ -1176,15 +1362,18 @@ ACE_Configuration_Heap::load_key (const ACE_Configuration_Section_Key& key, 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, @@ -1194,25 +1383,31 @@ ACE_Configuration_Heap::add_section (const ACE_Configuration_Section_Key& base, 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); @@ -1224,41 +1419,51 @@ ACE_Configuration_Heap::add_section (const ACE_Configuration_Section_Key& base, } 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) { @@ -1266,12 +1471,15 @@ ACE_Configuration_Heap::new_section (const ACE_TString& section, 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. */) { @@ -1279,11 +1487,13 @@ ACE_Configuration_Heap::new_section (const ACE_TString& section, 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, @@ -1292,6 +1502,7 @@ ACE_Configuration_Heap::new_section (const ACE_TString& section, result = ACE_Configuration_Section_Key (temp); return return_value; } + int ACE_Configuration_Heap::value_open_helper (size_t hash_table_size, void *buffer) @@ -1300,6 +1511,7 @@ ACE_Configuration_Heap::value_open_helper (size_t hash_table_size, 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) @@ -1308,6 +1520,7 @@ ACE_Configuration_Heap::section_open_helper (size_t hash_table_size, 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, @@ -1317,7 +1530,9 @@ ACE_Configuration_Heap::open_section (const ACE_Configuration_Section_Key& base, 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; ) @@ -1329,8 +1544,10 @@ ACE_Configuration_Heap::open_section (const ACE_Configuration_Section_Key& base, 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, @@ -1338,19 +1555,24 @@ ACE_Configuration_Heap::open_simple_section (const ACE_Configuration_Section_Key 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) @@ -1358,8 +1580,10 @@ ACE_Configuration_Heap::open_simple_section (const ACE_Configuration_Section_Key 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 ()), @@ -1367,6 +1591,7 @@ ACE_Configuration_Heap::open_simple_section (const ACE_Configuration_Section_Key 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, @@ -1375,55 +1600,68 @@ ACE_Configuration_Heap::remove_section (const ACE_Configuration_Section_Key& key 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 (); @@ -1432,20 +1670,27 @@ ACE_Configuration_Heap::remove_section (const ACE_Configuration_Section_Key& key 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, @@ -1457,12 +1702,15 @@ ACE_Configuration_Heap::enumerate_values (const ACE_Configuration_Section_Key& k 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) { @@ -1472,20 +1720,26 @@ ACE_Configuration_Heap::enumerate_values (const ACE_Configuration_Section_Key& k 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, @@ -1497,29 +1751,36 @@ ACE_Configuration_Heap::enumerate_sections (const ACE_Configuration_Section_Key& 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, @@ -1529,13 +1790,16 @@ ACE_Configuration_Heap::set_string_value (const ACE_Configuration_Section_Key& k 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); @@ -1570,8 +1834,10 @@ ACE_Configuration_Heap::set_string_value (const ACE_Configuration_Section_Key& k } return 0; } + return 0; } + int ACE_Configuration_Heap::set_integer_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -1581,15 +1847,18 @@ ACE_Configuration_Heap::set_integer_value (const ACE_Configuration_Section_Key& 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); @@ -1614,8 +1883,10 @@ ACE_Configuration_Heap::set_integer_value (const ACE_Configuration_Section_Key& } return 0; } + return 0; } + int ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -1626,15 +1897,18 @@ ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& k 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); @@ -1667,8 +1941,10 @@ ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& k } return 0; } + return 0; } + int ACE_Configuration_Heap::get_string_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -1678,70 +1954,86 @@ ACE_Configuration_Heap::get_string_value (const ACE_Configuration_Section_Key& k 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, @@ -1753,32 +2045,38 @@ ACE_Configuration_Heap::get_binary_value ( 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, @@ -1788,23 +2086,28 @@ ACE_Configuration_Heap::find_value (const ACE_Configuration_Section_Key& key, 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) @@ -1813,27 +2116,34 @@ ACE_Configuration_Heap::remove_value (const ACE_Configuration_Section_Key& key, 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 index 1fd5bb2fed8..55bd705bf64 100644 --- a/dep/ACE_wrappers/ace/Configuration.h +++ b/dep/ACE_wrappers/ace/Configuration.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Configuration.h @@ -24,9 +25,11 @@ * @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" @@ -34,17 +37,23 @@ #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 * @@ -61,16 +70,20 @@ 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 * @@ -86,15 +99,19 @@ class ACE_Export ACE_Configuration_Section_Key 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 & @@ -102,6 +119,7 @@ public: private: ACE_Section_Key_Internal *key_; }; + /** * @class ACE_Configuration * @@ -126,14 +144,17 @@ public: 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. * @@ -151,6 +172,7 @@ public: 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. @@ -164,6 +186,7 @@ public: 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. * @@ -186,6 +209,7 @@ public: int index, ACE_TString& name, VALUETYPE& type) = 0; + /** * Enumerates through the subsections in a section. * @@ -205,6 +229,7 @@ public: */ 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. @@ -218,6 +243,7 @@ public: 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. @@ -231,6 +257,7 @@ public: 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. @@ -246,6 +273,7 @@ public: 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. @@ -259,6 +287,7 @@ public: 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. @@ -272,6 +301,7 @@ public: 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. @@ -290,6 +320,7 @@ public: const ACE_TCHAR* name, void*& data, size_t& length) = 0; + /** * Retrieves the type of a named configuration value. * @@ -303,6 +334,7 @@ public: 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. @@ -313,6 +345,7 @@ public: */ 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 @@ -325,6 +358,7 @@ public: const ACE_TString& path_in, ACE_Configuration_Section_Key& key_out, int create = 1); + /** * @deprecated Exports the configuration database to filename. * If @a filename is already present, it is overwritten. This function is @@ -332,6 +366,7 @@ public: * either ACE_Registry_ImpExp or ACE_Ini_ImpExp instead. */ int export_config (const ACE_TCHAR* filename); + /** * @deprecated Imports the configuration database from filename. Any * existing data is not removed. This function is deprecated and will be @@ -339,28 +374,34 @@ public: * or ACE_Ini_ImpExp instead. */ int import_config (const ACE_TCHAR* filename); + /** * Determine if the contents of this object is the same as the * contents of the object on the right hand side. * Returns true if they are equal and false if they are not equal */ bool operator==(const ACE_Configuration& rhs) const; + /** * Determine if the contents of this object are different from the * contents of the object on the right hand side. * Returns false if they are equal and true if they are not equal */ bool operator!=(const ACE_Configuration& rhs) const; + /** * * Represents the "NULL" string to simplify the internal logic. * */ static ACE_TCHAR NULL_String_; + protected: /// Default ctor ACE_Configuration (void); + /// Resolves the internal key from a section key ACE_Section_Key_Internal* get_internal_key (const ACE_Configuration_Section_Key& key); + /** * Tests to see if @a name is valid. @a name must be < 255 characters * and not contain the path separator '\', brackets [] or = (maybe @@ -369,6 +410,7 @@ protected: * if @a allow_path is true. */ int validate_name (const ACE_TCHAR* name, int allow_path = 0); + /** * Test to see if @a name is valid. The default value for a key can be * unnamed, which means either @a name is == 0 or @a name == '\0` is @@ -376,13 +418,17 @@ protected: * same rules that apply to keys. */ int validate_value_name (const ACE_TCHAR* name); + // Not used ACE_Configuration (const ACE_Configuration& rhs); ACE_Configuration& operator= (const ACE_Configuration& rhs); + ACE_Configuration_Section_Key root_; }; + #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY) + /** * @class ACE_Section_Key_Win32 * @@ -395,14 +441,18 @@ class ACE_Export ACE_Section_Key_Win32 : public ACE_Section_Key_Internal public: /// Constructor based on an HKEY ACE_Section_Key_Win32 (HKEY hKey); + HKEY hKey_; + protected: /// Destructor - invokes 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 * @@ -415,54 +465,69 @@ protected: 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 @@ -476,22 +541,28 @@ public: 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 * @@ -504,29 +575,41 @@ 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_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 * @@ -550,21 +635,30 @@ 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 @@ -576,6 +670,7 @@ public: } data_; size_t length_; }; + typedef ACE_Hash_Map_With_Allocator VALUE_MAP; @@ -585,8 +680,10 @@ typedef ACE_Hash_Map_Manager_Ex, 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 * @@ -599,22 +696,30 @@ 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; @@ -624,8 +729,10 @@ typedef ACE_Hash_Map_Manager_Ex, 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 * @@ -640,19 +747,24 @@ class ACE_Export ACE_Configuration_Section_Key_Heap 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 * @@ -672,55 +784,72 @@ protected: 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, @@ -730,26 +859,37 @@ private: 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 index 787de75b900..19c2c591bf4 100644 --- a/dep/ACE_wrappers/ace/Configuration.inl +++ b/dep/ACE_wrappers/ace/Configuration.inl @@ -1,10 +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 index 75e5f61a792..bd5a79b143a 100644 --- a/dep/ACE_wrappers/ace/Configuration_Import_Export.cpp +++ b/dep/ACE_wrappers/ace/Configuration_Import_Export.cpp @@ -1,24 +1,31 @@ // $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 @@ -32,6 +39,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) 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; @@ -44,6 +52,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) } 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. @@ -61,6 +70,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) (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; @@ -70,9 +80,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) 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 @@ -84,6 +96,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) return -3; } *end = 0; + if (config_.expand_path (config_.root_section (), buffer + 1, section, 1)) { ACE_OS::fclose (in); @@ -92,12 +105,14 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) } 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; @@ -183,16 +198,19 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) } } // 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. @@ -205,6 +223,7 @@ ACE_Registry_ImpExp::export_config (const ACE_TCHAR* filename) return -1; } int result = -1; + FILE* out = ACE_OS::fopen (filename, ACE_TEXT ("w")); if (out) { @@ -218,9 +237,11 @@ ACE_Registry_ImpExp::export_config (const ACE_TCHAR* filename) } 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, @@ -329,6 +350,7 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio } return 0; } + // // This method read the line format origionally used in ACE 5.1 // @@ -340,6 +362,7 @@ ACE_Registry_ImpExp::process_previous_line_format (ACE_TCHAR* buffer, 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 @@ -365,13 +388,16 @@ ACE_Registry_ImpExp::process_previous_line_format (ACE_TCHAR* buffer, 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) @@ -384,6 +410,7 @@ ACE_Ini_ImpExp::import_config (const ACE_TCHAR* filename) 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; @@ -395,6 +422,7 @@ ACE_Ini_ImpExp::import_config (const ACE_TCHAR* filename) line[0] == ACE_TEXT ('#') || line[0] == '\0') continue; + if (line[0] == ACE_TEXT ('[')) { // We have a new section here, strip out the section name @@ -405,6 +433,7 @@ ACE_Ini_ImpExp::import_config (const ACE_TCHAR* filename) return -3; } *end = 0; + if (config_.expand_path (config_.root_section (), line + 1, section, @@ -413,8 +442,10 @@ ACE_Ini_ImpExp::import_config (const ACE_TCHAR* filename) 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 '=' @@ -447,20 +478,24 @@ ACE_Ini_ImpExp::import_config (const ACE_TCHAR* filename) ++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. @@ -473,6 +508,7 @@ ACE_Ini_ImpExp::export_config (const ACE_TCHAR* filename) return -1; } int result = -1; + FILE* out = ACE_OS::fopen (filename, ACE_TEXT ("w")); if (out) { @@ -486,9 +522,11 @@ ACE_Ini_ImpExp::export_config (const ACE_TCHAR* filename) } 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, @@ -569,7 +607,9 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, } default: return -3; + }// end switch on type + line += ACE_TEXT ("\n"); if (ACE_OS::fputs (line.fast_rep (), out) < 0) return -4; @@ -594,19 +634,24 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, ++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; @@ -614,10 +659,13 @@ ACE_Ini_ImpExp::squish (ACE_TCHAR *src) 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 index f6e5923fe02..ec47bafa144 100644 --- a/dep/ACE_wrappers/ace/Configuration_Import_Export.h +++ b/dep/ACE_wrappers/ace/Configuration_Import_Export.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Configuration_Import_Export.h @@ -19,15 +20,20 @@ * - 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 * @@ -43,27 +49,33 @@ 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 * @@ -84,28 +96,35 @@ 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 * @@ -147,21 +166,25 @@ 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 @@ -171,6 +194,7 @@ private: 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. @@ -180,10 +204,13 @@ private: * 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 index 4406455ad63..6f32c9a2de2 100644 --- a/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.cpp +++ b/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.cpp @@ -1,10 +1,14 @@ #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 index 60dc01f4fa2..0770c3a6c26 100644 --- a/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.h +++ b/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Connection_Recycling_Strategy.h @@ -11,11 +12,15 @@ #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 * @@ -26,23 +31,34 @@ 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.h b/dep/ACE_wrappers/ace/Connector.h index f6da43e3539..73689356501 100644 --- a/dep/ACE_wrappers/ace/Connector.h +++ b/dep/ACE_wrappers/ace/Connector.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Connector.h @@ -8,17 +9,24 @@ * @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 * @@ -32,14 +40,18 @@ 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 * @@ -49,10 +61,12 @@ 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, @@ -66,40 +80,57 @@ public: * 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 * @@ -119,6 +150,7 @@ 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; @@ -126,6 +158,7 @@ public: 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 @@ -134,6 +167,7 @@ public: */ 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 @@ -142,9 +176,12 @@ public: */ 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 @@ -164,6 +201,7 @@ public: 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 @@ -183,6 +221,7 @@ public: 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 @@ -197,6 +236,7 @@ public: 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 @@ -204,27 +244,37 @@ public: * 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 @@ -235,6 +285,7 @@ protected: * 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 @@ -255,6 +306,7 @@ protected: 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 @@ -266,9 +318,11 @@ protected: * 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, @@ -278,27 +332,35 @@ protected: 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 @@ -306,11 +368,15 @@ private: * 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 * @@ -330,6 +396,7 @@ class ACE_Strategy_Connector : public ACE_Connector { public: + // Useful STL-style traits. typedef ACE_Creation_Strategy creation_strategy_type; @@ -339,6 +406,7 @@ public: concurrency_strategy_type; typedef ACE_Connector base_type; + // = Define some useful (old style) traits. typedef ACE_Creation_Strategy CREATION_STRATEGY; @@ -348,6 +416,7 @@ public: CONCURRENCY_STRATEGY; typedef ACE_Connector SUPER; + /** * Initialize a connector. @a flags indicates how 's * should be initialized prior to being activated. Right now, the @@ -359,6 +428,7 @@ public: 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 @@ -368,6 +438,7 @@ public: */ 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 @@ -379,18 +450,23 @@ public: 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 @@ -403,6 +479,7 @@ protected: * 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 @@ -415,6 +492,7 @@ protected: int reuse_addr, int flags, int perms); + /** * Bridge method for connecting the new connection into the * SVC_HANDLER. The default behavior delegates to the @@ -433,6 +511,7 @@ protected: 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 @@ -444,30 +523,42 @@ protected: * 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 index 45d29744728..754ef0e5194 100644 --- a/dep/ACE_wrappers/ace/Containers.cpp +++ b/dep/ACE_wrappers/ace/Containers.cpp @@ -1,9 +1,13 @@ // $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 index 211f0cda68e..f6f1d35bb60 100644 --- a/dep/ACE_wrappers/ace/Containers.h +++ b/dep/ACE_wrappers/ace/Containers.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Containers.h @@ -8,18 +9,25 @@ * @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 * @@ -33,22 +41,32 @@ public: 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 index 4ad213039ed..8094672a8f6 100644 --- a/dep/ACE_wrappers/ace/Containers.inl +++ b/dep/ACE_wrappers/ace/Containers.inl @@ -1,7 +1,9 @@ // -*- 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), @@ -9,6 +11,7 @@ ACE_DLList_Node::ACE_DLList_Node (void) prev_ (0) { } + ACE_INLINE ACE_DLList_Node::ACE_DLList_Node (void *i, ACE_DLList_Node *n, @@ -18,4 +21,5 @@ ACE_DLList_Node::ACE_DLList_Node (void *i, prev_ (p) { } + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Containers_T.h b/dep/ACE_wrappers/ace/Containers_T.h index f41858b1553..8969d3cf969 100644 --- a/dep/ACE_wrappers/ace/Containers_T.h +++ b/dep/ACE_wrappers/ace/Containers_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Containers_T.h @@ -8,26 +9,38 @@ * @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 * @@ -66,18 +79,21 @@ 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 @@ -85,12 +101,15 @@ public: * 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 @@ -98,6 +117,7 @@ public: * 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 @@ -105,6 +125,7 @@ public: * 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 @@ -112,36 +133,47 @@ public: * -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 * @@ -183,22 +215,27 @@ public: * 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 @@ -206,6 +243,7 @@ public: * 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 @@ -213,6 +251,7 @@ public: * failure occurs. */ int pop (T &item); + ///Constant time examination of top of stack. /** * Return top stack item without removing it. Returns -1 if the @@ -220,37 +259,49 @@ public: * -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 * @@ -261,20 +312,29 @@ 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 * @@ -315,8 +375,10 @@ 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. @@ -325,23 +387,28 @@ public: * 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 @@ -349,6 +416,7 @@ public: * 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 @@ -356,6 +424,7 @@ public: * failure occurs. */ int pop (T &item); + ///Examine the top of the stack. /** * Return top stack item without removing it. Returns -1 if the @@ -363,18 +432,23 @@ public: * -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 @@ -382,38 +456,49 @@ public: * 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 * @@ -426,30 +511,41 @@ 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 * @@ -461,19 +557,24 @@ 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 @@ -483,16 +584,21 @@ public: * 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 @@ -501,9 +607,11 @@ protected: * 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 @@ -511,18 +619,24 @@ protected: * 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 * @@ -542,6 +656,7 @@ class ACE_Double_Linked_List_Iterator : public ACE_Double_Linked_List_Iterator_B 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 @@ -552,12 +667,15 @@ public: * @@ 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. @@ -565,20 +683,28 @@ public: * 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 * @@ -599,6 +725,7 @@ class ACE_Double_Linked_List_Reverse_Iterator : public ACE_Double_Linked_List_It 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 @@ -609,12 +736,15 @@ public: * @@ 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. @@ -622,21 +752,29 @@ public: * 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 * @@ -688,9 +826,11 @@ 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. @@ -699,47 +839,57 @@ public: * 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 @@ -747,6 +897,7 @@ public: * 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 @@ -754,7 +905,9 @@ public: * 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. @@ -762,6 +915,7 @@ public: * 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. /** @@ -769,37 +923,45 @@ public: * 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 @@ -809,6 +971,7 @@ protected: 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. @@ -818,18 +981,24 @@ protected: * 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 @@ -841,6 +1010,7 @@ typedef ACE_Double_Linked_List ACE_DLList_Base; // 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 * @@ -864,25 +1034,31 @@ class ACE_DLList : public ACE_DLList_Base 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. * @@ -890,6 +1066,7 @@ public: * 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. * @@ -898,6 +1075,7 @@ public: */ T *delete_tail (void); //@} + /** * Provide random access to any item in the list. * @@ -909,10 +1087,13 @@ public: * @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. * @@ -921,8 +1102,10 @@ public: * 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 @@ -939,6 +1122,7 @@ public: */ ~ACE_DLList (void); }; + /** * @class ACE_DLList_Iterator * @@ -951,11 +1135,15 @@ public: 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 @@ -966,19 +1154,23 @@ public: * @@ 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} @@ -986,11 +1178,14 @@ public: * 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 * @@ -1003,11 +1198,15 @@ private: 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 @@ -1018,28 +1217,36 @@ public: * @@ 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 * @@ -1050,34 +1257,46 @@ 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 * @@ -1092,22 +1311,29 @@ 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 * @@ -1121,18 +1347,24 @@ class ACE_Fixed_Set_Const_Iterator : public ACE_Fixed_Set_Iterator_Base &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 * @@ -1173,42 +1405,52 @@ 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). @@ -1216,6 +1458,7 @@ public: * 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 @@ -1223,37 +1466,47 @@ public: * 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 * @@ -1268,29 +1521,39 @@ 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 * @@ -1333,12 +1596,15 @@ 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. /** @@ -1346,17 +1612,20 @@ public: * 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 @@ -1364,26 +1633,32 @@ public: * 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 @@ -1392,6 +1667,7 @@ public: * 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 @@ -1400,36 +1676,46 @@ public: * 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 * @@ -1443,39 +1729,54 @@ 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 * @@ -1517,8 +1818,10 @@ 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. @@ -1527,39 +1830,48 @@ public: * 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 @@ -1568,12 +1880,14 @@ public: * 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 @@ -1582,16 +1896,21 @@ public: * 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 @@ -1599,6 +1918,7 @@ private: */ 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 @@ -1612,20 +1932,28 @@ private: */ 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 * @@ -1665,9 +1993,13 @@ 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 @@ -1675,6 +2007,7 @@ public: */ 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. @@ -1682,6 +2015,7 @@ public: ACE_Array (size_t size, const T &default_value, ACE_Allocator* alloc = 0); + ///Copy constructor. /** * The copy constructor performs initialization by making an exact @@ -1689,6 +2023,7 @@ public: * return true. */ ACE_Array (const ACE_Array &s); + ///Assignment operator /** * Assignment operator performs an assignment by making an exact @@ -1699,7 +2034,9 @@ public: * 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 @@ -1707,6 +2044,7 @@ public: * are equal. */ bool operator== (const ACE_Array &s) const; + ///Inequality comparison operator. /** * Compare this array with {s} for inequality such that {*this} != @@ -1715,16 +2053,22 @@ public: */ 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 index b28da9699cd..912c9df8bb8 100644 --- a/dep/ACE_wrappers/ace/Containers_T.inl +++ b/dep/ACE_wrappers/ace/Containers_T.inl @@ -1,19 +1,23 @@ // -*- 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) { @@ -26,6 +30,7 @@ ACE_Bounded_Stack::push (const T &new_item) else return -1; } + template ACE_INLINE int ACE_Bounded_Stack::pop (T &item) { @@ -38,6 +43,7 @@ ACE_Bounded_Stack::pop (T &item) else return -1; } + template ACE_INLINE int ACE_Bounded_Stack::top (T &item) const { @@ -50,24 +56,29 @@ ACE_Bounded_Stack::top (T &item) const 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) { @@ -80,6 +91,7 @@ ACE_Fixed_Stack::push (const T &new_item) else return -1; } + template ACE_INLINE int ACE_Fixed_Stack::pop (T &item) { @@ -92,6 +104,7 @@ ACE_Fixed_Stack::pop (T &item) else return -1; } + template ACE_INLINE int ACE_Fixed_Stack::top (T &item) const { @@ -104,17 +117,20 @@ ACE_Fixed_Stack::top (T &item) const 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 { @@ -127,80 +143,103 @@ ACE_Unbounded_Stack::top (T &item) const 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 { @@ -209,26 +248,33 @@ ACE_Ordered_MultiSet_Iterator::dump (void) const #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, @@ -236,34 +282,45 @@ ACE_Array::ACE_Array (size_t size, : 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) { @@ -273,6 +330,7 @@ ACE_DLList::get (T *&item, size_t index) item = (T *) node->item_; return result; } + template ACE_INLINE void ACE_DLList::dump (void) const { @@ -280,6 +338,7 @@ ACE_DLList::dump (void) const ACE_DLList_Base::dump (); #endif /* ACE_HAS_DUMP */ } + template ACE_INLINE int ACE_DLList::remove (ACE_DLList_Node *n) { @@ -289,21 +348,25 @@ ACE_DLList::remove (ACE_DLList_Node *n) 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) { @@ -311,18 +374,21 @@ ACE_DLList_Iterator::remove (void) 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) { @@ -332,17 +398,20 @@ ACE_DLList_Iterator::next (T *&ptr) 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 { @@ -351,6 +420,7 @@ ACE_DLList_Iterator::dump (void) const #endif /* ACE_HAS_DUMP */ } + template ACE_INLINE int ACE_DLList_Reverse_Iterator::remove (void) { @@ -358,23 +428,27 @@ ACE_DLList_Reverse_Iterator::remove (void) 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) { @@ -385,6 +459,7 @@ ACE_DLList_Reverse_Iterator::next (T *&ptr) ptr = (T *) temp->item_; return 1; } + template ACE_INLINE T * ACE_DLList_Reverse_Iterator::next (void) const { @@ -392,6 +467,7 @@ ACE_DLList_Reverse_Iterator::next (void) const return (T *) (temp ? temp->item_ : 0); } + template ACE_INLINE void ACE_DLList_Reverse_Iterator::dump (void) const { @@ -399,4 +475,5 @@ ACE_DLList_Reverse_Iterator::dump (void) const 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 index d7180dffc58..92cc98cd1ef 100644 --- a/dep/ACE_wrappers/ace/Copy_Disabled.cpp +++ b/dep/ACE_wrappers/ace/Copy_Disabled.cpp @@ -5,15 +5,20 @@ * * @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 index d94e949d78e..4dd6c2216b5 100644 --- a/dep/ACE_wrappers/ace/Copy_Disabled.h +++ b/dep/ACE_wrappers/ace/Copy_Disabled.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //=========================================================================== /** * @file Copy_Disabled.h @@ -8,14 +9,20 @@ * @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 * @@ -42,13 +49,18 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 index dd72a3d7fac..3b3eede4364 100644 --- a/dep/ACE_wrappers/ace/Countdown_Time.cpp +++ b/dep/ACE_wrappers/ace/Countdown_Time.cpp @@ -1,19 +1,24 @@ #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) { @@ -23,17 +28,20 @@ ACE_Countdown_Time::start (void) 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; @@ -47,11 +55,13 @@ ACE_Countdown_Time::stop (void) 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 index 42267584e60..cc76bed02f4 100644 --- a/dep/ACE_wrappers/ace/Countdown_Time.h +++ b/dep/ACE_wrappers/ace/Countdown_Time.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Countdown_Time.h @@ -8,15 +9,22 @@ * @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 * @@ -31,31 +39,43 @@ 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 index 4b335a4fd61..7b4fb00f2b2 100644 --- a/dep/ACE_wrappers/ace/DEV.cpp +++ b/dep/ACE_wrappers/ace/DEV.cpp @@ -1,12 +1,19 @@ // $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 { @@ -14,12 +21,16 @@ ACE_DEV::dump (void) const 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) { @@ -28,5 +39,6 @@ ACE_DEV::close (void) 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 index 6cff2d16794..6a6a7419e37 100644 --- a/dep/ACE_wrappers/ace/DEV.h +++ b/dep/ACE_wrappers/ace/DEV.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file DEV.h @@ -9,18 +10,24 @@ */ //============================================================================= + #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 @@ -28,7 +35,9 @@ #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 * @@ -40,24 +49,31 @@ 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 index c7e4e0a19b3..4d97a73d8e8 100644 --- a/dep/ACE_wrappers/ace/DEV.inl +++ b/dep/ACE_wrappers/ace/DEV.inl @@ -1,7 +1,9 @@ // -*- 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 { @@ -12,4 +14,5 @@ ACE_DEV::disable (int signum) const 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 index 2cd36775308..73abb6568aa 100644 --- a/dep/ACE_wrappers/ace/DEV_Addr.cpp +++ b/dep/ACE_wrappers/ace/DEV_Addr.cpp @@ -1,52 +1,70 @@ // $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, @@ -57,26 +75,35 @@ ACE_DEV_Addr::set (const ACE_DEV_Addr &sa) 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 index efb8ebcaf24..f658cb0207d 100644 --- a/dep/ACE_wrappers/ace/DEV_Addr.h +++ b/dep/ACE_wrappers/ace/DEV_Addr.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file DEV_Addr.h @@ -8,15 +9,22 @@ * @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 * @@ -28,39 +36,56 @@ 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 index 523848f6572..5c1da68d7e7 100644 --- a/dep/ACE_wrappers/ace/DEV_Addr.inl +++ b/dep/ACE_wrappers/ace/DEV_Addr.inl @@ -1,37 +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 index a6ae6a64d2c..02763c95296 100644 --- a/dep/ACE_wrappers/ace/DEV_Connector.cpp +++ b/dep/ACE_wrappers/ace/DEV_Connector.cpp @@ -1,16 +1,23 @@ // $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 { @@ -18,10 +25,12 @@ ACE_DEV_Connector::dump (void) const 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, @@ -32,6 +41,7 @@ ACE_DEV_Connector::connect (ACE_DEV_IO &new_io, int perms) { ACE_TRACE ("ACE_DEV_Connector::connect"); + ACE_HANDLE handle = ACE::handle_timed_open (timeout, remote_sap.get_path_name (), flags, perms); @@ -39,5 +49,6 @@ ACE_DEV_Connector::connect (ACE_DEV_IO &new_io, 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 index 34db1362889..565d7ae024a 100644 --- a/dep/ACE_wrappers/ace/DEV_Connector.h +++ b/dep/ACE_wrappers/ace/DEV_Connector.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file DEV_Connector.h @@ -8,17 +9,22 @@ * @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 * @@ -29,6 +35,7 @@ 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 @@ -53,6 +60,7 @@ public: 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 @@ -77,20 +85,27 @@ public: 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 index f5a0f6d8e4e..924a4254791 100644 --- a/dep/ACE_wrappers/ace/DEV_Connector.inl +++ b/dep/ACE_wrappers/ace/DEV_Connector.inl @@ -1,8 +1,11 @@ // -*- 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, @@ -19,6 +22,7 @@ ACE_DEV_Connector::ACE_DEV_Connector (ACE_DEV_IO &new_io, 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) { @@ -26,4 +30,5 @@ ACE_DEV_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/DEV_IO.cpp b/dep/ACE_wrappers/ace/DEV_IO.cpp index f0769e49b25..e3c92041f28 100644 --- a/dep/ACE_wrappers/ace/DEV_IO.cpp +++ b/dep/ACE_wrappers/ace/DEV_IO.cpp @@ -1,23 +1,33 @@ // $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 { @@ -25,25 +35,31 @@ ACE_DEV_IO::get_remote_addr (ACE_DEV_Addr &addr) const 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 { @@ -58,12 +74,15 @@ ACE_DEV_IO::send (size_t n, ...) const 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; @@ -71,11 +90,13 @@ ACE_DEV_IO::send (size_t n, ...) const 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 { @@ -90,12 +111,15 @@ ACE_DEV_IO::recv (size_t n, ...) const 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; @@ -103,5 +127,6 @@ ACE_DEV_IO::recv (size_t n, ...) const 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 index a34339f1fd5..e19cfd35603 100644 --- a/dep/ACE_wrappers/ace/DEV_IO.h +++ b/dep/ACE_wrappers/ace/DEV_IO.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file DEV_IO.h @@ -9,20 +10,28 @@ * @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 * @@ -32,16 +41,21 @@ 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 * @@ -84,30 +98,37 @@ public: 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 @@ -115,6 +136,7 @@ public: * 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 @@ -123,31 +145,42 @@ public: * 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 index ebb05bc586f..796d24e114a 100644 --- a/dep/ACE_wrappers/ace/DEV_IO.inl +++ b/dep/ACE_wrappers/ace/DEV_IO.inl @@ -1,21 +1,28 @@ // -*- 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, @@ -25,6 +32,7 @@ ACE_DEV_IO::recv_n (void *buf, ACE_TRACE ("ACE_DEV_IO::recv_n"); #if defined (ACE_WIN32) ACE_UNUSED_ARG (timeout); + return ACE::read_n (this->get_handle (), buf, n, @@ -37,30 +45,35 @@ ACE_DEV_IO::recv_n (void *buf, 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 @@ -70,6 +83,7 @@ ACE_DEV_IO::send (const void *buf, size_t n, (const char *) buf, n, overlapped); } + ACE_INLINE ssize_t ACE_DEV_IO::recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const @@ -78,6 +92,7 @@ ACE_DEV_IO::recv (void *buf, size_t n, 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 @@ -85,18 +100,21 @@ ACE_DEV_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) c 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 { @@ -104,4 +122,5 @@ ACE_DEV_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int flags) c 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 index 73d7f0459f5..43cfa2efa84 100644 --- a/dep/ACE_wrappers/ace/DLL.cpp +++ b/dep/ACE_wrappers/ace/DLL.cpp @@ -1,16 +1,23 @@ // $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), @@ -20,6 +27,7 @@ ACE_DLL::ACE_DLL (bool close_handle_on_destruction) { ACE_TRACE ("ACE_DLL::ACE_DLL (int)"); } + ACE_DLL::ACE_DLL (const ACE_DLL &rhs) : open_mode_ (0), dll_name_ (0), @@ -28,6 +36,7 @@ ACE_DLL::ACE_DLL (const ACE_DLL &rhs) 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_, @@ -38,23 +47,30 @@ ACE_DLL::ACE_DLL (const ACE_DLL &rhs) 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) @@ -65,25 +81,31 @@ ACE_DLL::ACE_DLL (const ACE_TCHAR *dll_name, 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: @@ -94,14 +116,17 @@ ACE_DLL::~ACE_DLL (void) // 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, @@ -109,7 +134,9 @@ ACE_DLL::open_i (const ACE_TCHAR *dll_filename, ACE_SHLIB_HANDLE handle) { ACE_TRACE ("ACE_DLL::open_i"); + this->error_ = 0; + if (!dll_filename) { if (ACE::debug ()) @@ -119,6 +146,7 @@ ACE_DLL::open_i (const ACE_TCHAR *dll_filename, : this->dll_name_)); return -1; } + if (this->dll_handle_) { // If we have a good handle and its the same name, just return. @@ -127,50 +155,69 @@ ACE_DLL::open_i (const ACE_TCHAR *dll_filename, 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 { @@ -179,32 +226,43 @@ ACE_DLL::error (void) const { 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 index d374d46c640..a9700daafc0 100644 --- a/dep/ACE_wrappers/ace/DLL.h +++ b/dep/ACE_wrappers/ace/DLL.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file DLL.h @@ -8,17 +9,24 @@ * @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 * @@ -35,6 +43,7 @@ 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. @@ -46,9 +55,11 @@ public: * 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. @@ -71,8 +82,10 @@ public: 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. @@ -106,14 +119,17 @@ public: 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(). @@ -125,10 +141,12 @@ public: * 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 @@ -136,32 +154,44 @@ public: * 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 index 6b8df486d12..9463aa5e1bc 100644 --- a/dep/ACE_wrappers/ace/DLL_Manager.cpp +++ b/dep/ACE_wrappers/ace/DLL_Manager.cpp @@ -1,8 +1,11 @@ // $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" @@ -10,12 +13,17 @@ #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), @@ -23,18 +31,21 @@ ACE_DLL_Handle::ACE_DLL_Handle (void) { 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, @@ -42,6 +53,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, { 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.. @@ -53,13 +65,16 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, 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) { @@ -85,9 +100,11 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, */ 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, @@ -99,6 +116,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, #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)) @@ -106,6 +124,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_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, @@ -118,8 +137,10 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, : 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 @@ -134,6 +155,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, 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 @@ -147,6 +169,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, 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, @@ -159,9 +182,11 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, : "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. @@ -176,10 +201,13 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, name->c_str (), errno, this->error ()->c_str ())); + } #endif /* AIX */ + name_iter.advance (); } + if (this->handle_ == ACE_SHLIB_INVALID_HANDLE) { if (ACE::debug ()) @@ -188,11 +216,14 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, 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"), @@ -202,17 +233,21 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, 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. @@ -220,6 +255,7 @@ ACE_DLL_Handle::close (int unload) --this->refcount_; else this->refcount_ = 0; + if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ") @@ -227,6 +263,7 @@ ACE_DLL_Handle::close (int unload) this->dll_name_, this->handle_, this->refcount_)); + if (this->refcount_ == 0 && this->handle_ != ACE_SHLIB_INVALID_HANDLE && unload == 1) @@ -237,37 +274,45 @@ ACE_DLL_Handle::close (int unload) 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 @@ -278,6 +323,7 @@ ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors) #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 @@ -290,31 +336,38 @@ ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors) 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: ") @@ -322,9 +375,12 @@ ACE_DLL_Handle::get_handle (int become_owner) 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) { @@ -334,6 +390,7 @@ ACE_DLL_Handle::error (void) (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) @@ -342,6 +399,7 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, // 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); @@ -352,6 +410,7 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, } 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) @@ -359,6 +418,7 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, 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) @@ -382,6 +442,7 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, #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; @@ -417,6 +478,7 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, try_this = dll_name; break; } + if (try_this.length ()) { try_names.size (j + 1); @@ -425,14 +487,18 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, } 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. @@ -445,17 +511,22 @@ ACE_DLL_Manager::instance (int 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), @@ -463,25 +534,30 @@ ACE_DLL_Manager::ACE_DLL_Manager (int size) 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; { @@ -494,10 +570,12 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, 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) @@ -508,9 +586,11 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, 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) @@ -520,36 +600,45 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, ++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. @@ -568,23 +657,30 @@ ACE_DLL_Manager::unload_policy (u_long unload_policy) } } } + 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. @@ -599,28 +695,34 @@ ACE_DLL_Manager::close (void) 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; @@ -637,6 +739,7 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload) { // 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)) @@ -646,8 +749,10 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload) 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); @@ -656,11 +761,13 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload) 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; } } @@ -670,9 +777,12 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload) 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 index aeeec3fa0ca..0e571b6c03a 100644 --- a/dep/ACE_wrappers/ace/DLL_Manager.h +++ b/dep/ACE_wrappers/ace/DLL_Manager.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file DLL_Manager.h @@ -8,23 +9,31 @@ * @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 * @@ -48,12 +57,16 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 @@ -67,56 +80,72 @@ public: 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 * @@ -155,61 +184,87 @@ 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 index 5e265b6b04f..8b26d0dd925 100644 --- a/dep/ACE_wrappers/ace/Date_Time.cpp +++ b/dep/ACE_wrappers/ace/Date_Time.cpp @@ -1,8 +1,11 @@ // 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 index ed038f924f7..7e91549d2a5 100644 --- a/dep/ACE_wrappers/ace/Date_Time.h +++ b/dep/ACE_wrappers/ace/Date_Time.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Date_Time.h @@ -9,15 +10,21 @@ * */ //========================================================================== + #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 * @@ -28,8 +35,10 @@ 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, @@ -40,42 +49,61 @@ public: 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_; @@ -86,10 +114,13 @@ private: 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 index 0ff0bf275b2..d34807d83a4 100644 --- a/dep/ACE_wrappers/ace/Date_Time.inl +++ b/dep/ACE_wrappers/ace/Date_Time.inl @@ -1,11 +1,14 @@ // -*- 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) { @@ -38,24 +41,29 @@ ACE_Date_Time::update (const ACE_Time_Value& timevalue) 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, @@ -77,7 +85,9 @@ ACE_Date_Time::ACE_Date_Time (long day, { 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 @@ -85,6 +95,7 @@ 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) @@ -92,6 +103,7 @@ 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 @@ -99,6 +111,7 @@ 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) @@ -106,6 +119,7 @@ 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 @@ -113,6 +127,7 @@ 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) @@ -120,6 +135,7 @@ 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 @@ -127,6 +143,7 @@ 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) @@ -134,6 +151,7 @@ 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 @@ -141,6 +159,7 @@ 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) @@ -148,6 +167,7 @@ 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 @@ -155,6 +175,7 @@ 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) @@ -162,6 +183,7 @@ 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 @@ -169,6 +191,7 @@ 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) @@ -176,6 +199,7 @@ 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 @@ -183,6 +207,7 @@ 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) @@ -190,4 +215,5 @@ 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 index 81a5a8a46fe..9eefd496b9b 100644 --- a/dep/ACE_wrappers/ace/Default_Constants.h +++ b/dep/ACE_wrappers/ace/Default_Constants.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Default_Constants.h @@ -12,70 +13,90 @@ * 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: @@ -83,77 +104,98 @@ # 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) @@ -162,22 +204,27 @@ # 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) @@ -185,6 +232,7 @@ # 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) @@ -192,6 +240,7 @@ # 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 @@ -199,28 +248,34 @@ # 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) @@ -229,100 +284,127 @@ # 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 @@ -334,6 +416,7 @@ #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 "\\" @@ -343,27 +426,34 @@ # 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" @@ -378,13 +468,16 @@ # 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 (";") @@ -402,12 +495,15 @@ # 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) @@ -418,6 +514,7 @@ # 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) @@ -426,9 +523,11 @@ # 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" @@ -436,6 +535,7 @@ #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 @@ -450,12 +550,15 @@ # 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" @@ -465,6 +568,7 @@ # 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 index a46e649d441..2cd90d17738 100644 --- a/dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp +++ b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp @@ -1,15 +1,20 @@ // $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) @@ -21,10 +26,12 @@ ACE_RCSID (ace, # 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" @@ -38,7 +45,9 @@ ACE_RCSID (ace, #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_ () @@ -48,36 +57,44 @@ ACE_Dev_Poll_Reactor_Notify::ACE_Dev_Poll_Reactor_Notify (void) #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. @@ -85,40 +102,53 @@ ACE_Dev_Poll_Reactor_Notify::open (ACE_Reactor_Impl *r, 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. @@ -128,25 +158,32 @@ ACE_Dev_Poll_Reactor_Notify::notify (ACE_Event_Handler *eh, &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 @@ -154,13 +191,16 @@ ACE_Dev_Poll_Reactor_Notify::dispatch_notifications ( // 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 @@ -171,6 +211,7 @@ ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle, 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 @@ -179,22 +220,27 @@ ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle, 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, @@ -204,13 +250,16 @@ ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle, 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 @@ -218,67 +267,85 @@ ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle, 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 @@ -287,10 +354,12 @@ ACE_Dev_Poll_Reactor_Notify::dispatch_notify (ACE_Notification_Buffer &buffer) 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: @@ -312,42 +381,54 @@ ACE_Dev_Poll_Reactor_Notify::dispatch_notify (ACE_Notification_Buffer &buffer) 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_ = %@"), @@ -356,7 +437,9 @@ ACE_Dev_Poll_Reactor_Notify::dump (void) const 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), @@ -364,11 +447,13 @@ ACE_Dev_Poll_Reactor_Handler_Repository (void) { 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; @@ -377,11 +462,13 @@ ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle ( 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 @@ -390,48 +477,62 @@ ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range ( 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)) { @@ -444,8 +545,10 @@ ACE_Dev_Poll_Reactor_Handler_Repository::find (ACE_HANDLE handle, else errno = ENOENT; } + return eh; } + int ACE_Dev_Poll_Reactor_Handler_Repository::bind ( ACE_HANDLE handle, @@ -453,32 +556,43 @@ ACE_Dev_Poll_Reactor_Handler_Repository::bind ( 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, @@ -511,6 +625,7 @@ ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (ACE_Sig_Handler *sh, , restart_ (0) { ACE_TRACE ("ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor"); + if (this->open (ACE::max_handles (), 0, sh, @@ -523,6 +638,7 @@ ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (ACE_Sig_Handler *sh, 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, @@ -567,11 +683,14 @@ ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (size_t size, 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, @@ -581,68 +700,87 @@ ACE_Dev_Poll_Reactor::open (size_t size, 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, @@ -654,83 +792,111 @@ ACE_Dev_Poll_Reactor::open (size_t size, 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; @@ -738,34 +904,45 @@ ACE_Dev_Poll_Reactor::close (void) 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 @@ -773,75 +950,98 @@ ACE_Dev_Poll_Reactor::work_pending_i (ACE_Time_Value * max_wait_time) #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 @@ -854,12 +1054,14 @@ ACE_Dev_Poll_Reactor::handle_events_i (ACE_Time_Value *max_wait_time, 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 @@ -871,58 +1073,75 @@ ACE_Dev_Poll_Reactor::handle_events_i (ACE_Time_Value *max_wait_time, } 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 ( @@ -936,19 +1155,24 @@ ACE_Dev_Poll_Reactor::dispatch_notification_handlers ( // 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; @@ -961,12 +1185,14 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) 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 @@ -992,6 +1218,7 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) 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. @@ -1027,11 +1254,13 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) 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 @@ -1039,6 +1268,7 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) 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. @@ -1047,31 +1277,38 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) // 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); @@ -1079,87 +1316,110 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) } } // 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 @@ -1170,11 +1430,15 @@ ACE_Dev_Poll_Reactor::register_handler_i (ACE_HANDLE handle, 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)) { @@ -1182,12 +1446,15 @@ ACE_Dev_Poll_Reactor::register_handler_i (ACE_HANDLE 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 */, @@ -1197,25 +1464,32 @@ ACE_Dev_Poll_Reactor::register_handler ( { 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, @@ -1224,93 +1498,123 @@ ACE_Dev_Poll_Reactor::register_handler (int signum, 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, @@ -1318,184 +1622,263 @@ ACE_Dev_Poll_Reactor::remove_handler (int signum, 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) { @@ -1503,6 +1886,7 @@ ACE_Dev_Poll_Reactor::uses_event_associations (void) // this method always return zero. return 0; } + long ACE_Dev_Poll_Reactor::schedule_timer (ACE_Event_Handler *event_handler, const void *arg, @@ -1510,131 +1894,171 @@ ACE_Dev_Poll_Reactor::schedule_timer (ACE_Event_Handler *event_handler, 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 @@ -1642,124 +2066,164 @@ ACE_Dev_Poll_Reactor::handler (ACE_HANDLE handle, { 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). // @@ -1771,50 +2235,63 @@ ACE_Dev_Poll_Reactor::mask_ops_i (ACE_HANDLE handle, // (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) { @@ -1826,7 +2303,9 @@ ACE_Dev_Poll_Reactor::mask_ops_i (ACE_HANDLE handle, 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 @@ -1837,11 +2316,14 @@ ACE_Dev_Poll_Reactor::mask_ops_i (ACE_HANDLE handle, ::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, @@ -1849,35 +2331,42 @@ ACE_Dev_Poll_Reactor::mask_ops_i (ACE_HANDLE handle, 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, @@ -1891,10 +2380,12 @@ ACE_Dev_Poll_Reactor::dump (void) const 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) @@ -1902,7 +2393,9 @@ ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event (ACE_Reactor_Mask mask) #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) @@ -1915,6 +2408,7 @@ ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event (ACE_Reactor_Mask mask) 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)) @@ -1925,6 +2419,7 @@ ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event (ACE_Reactor_Mask mask) 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)) { @@ -1934,21 +2429,26 @@ ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event (ACE_Reactor_Mask mask) 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)); @@ -1957,6 +2457,7 @@ ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly (ACE_Time_Value *max_wait) { ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook)); } + // Check for timeouts and errors. if (result == -1) { @@ -1968,14 +2469,18 @@ ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly (ACE_Time_Value *max_wait) 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; @@ -1983,12 +2488,14 @@ ACE_Dev_Poll_Reactor::Token_Guard::acquire (ACE_Time_Value *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) { @@ -1997,10 +2504,14 @@ ACE_Dev_Poll_Reactor::Token_Guard::acquire (ACE_Time_Value *max_wait) 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 index 14464f33439..c675999bb4c 100644 --- a/dep/ACE_wrappers/ace/Dev_Poll_Reactor.h +++ b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.h @@ -1,4 +1,5 @@ // -*- C++ -*- + // ========================================================================= /** * @file Dev_Poll_Reactor.h @@ -11,34 +12,46 @@ */ // ========================================================================= + #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 * @@ -59,17 +72,24 @@ class ACE_Dev_Poll_Reactor; 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 @@ -98,17 +118,24 @@ public: 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 * @@ -122,8 +149,10 @@ public: class ACE_Dev_Poll_Reactor_Notify : public ACE_Reactor_Notify { public: + /// Constructor ACE_Dev_Poll_Reactor_Notify (void); + /** * @name Initialization and Termination Methods * @@ -134,6 +163,7 @@ public: 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 @@ -147,6 +177,7 @@ public: 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. /** @@ -156,22 +187,28 @@ public: */ 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 @@ -182,6 +219,7 @@ public: * 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 @@ -189,6 +227,7 @@ public: * 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 @@ -197,21 +236,26 @@ public: 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 @@ -220,6 +264,7 @@ protected: * 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. @@ -234,12 +279,16 @@ protected: */ 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 *. * @@ -251,48 +300,62 @@ protected: 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 * @@ -300,32 +363,44 @@ public: * 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 * @@ -359,15 +434,18 @@ private: * 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 @@ -379,6 +457,7 @@ public: 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 @@ -399,8 +478,10 @@ public: 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, @@ -408,6 +489,7 @@ public: 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. @@ -416,15 +498,20 @@ public: * 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, @@ -436,6 +523,7 @@ public: */ 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 @@ -457,11 +545,13 @@ public: * @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 @@ -472,7 +562,9 @@ public: */ 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 @@ -480,6 +572,7 @@ public: * @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 @@ -487,16 +580,20 @@ public: * 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 @@ -506,11 +603,13 @@ public: 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 @@ -522,11 +621,13 @@ public: 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() @@ -536,6 +637,7 @@ public: */ 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 @@ -543,6 +645,7 @@ public: */ 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 @@ -550,6 +653,7 @@ public: */ 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 @@ -560,35 +664,49 @@ public: 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, @@ -612,6 +730,7 @@ public: 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 @@ -621,10 +740,12 @@ public: */ 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 @@ -637,22 +758,29 @@ public: 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 == @@ -662,6 +790,7 @@ public: 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 @@ -673,6 +802,7 @@ public: * 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 @@ -680,6 +810,7 @@ public: * 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 @@ -687,11 +818,13 @@ public: */ 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 @@ -700,6 +833,7 @@ public: 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 @@ -707,16 +841,21 @@ public: */ 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 @@ -725,6 +864,7 @@ public: * 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 @@ -733,8 +873,10 @@ public: * 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 @@ -744,16 +886,19 @@ public: * @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 * @@ -764,6 +909,7 @@ public: * manipulated with these methods. */ //@{ + /// GET/SET/ADD/CLR the dispatch mask "bit" bound with the /// event_handler and mask. /** @@ -772,6 +918,7 @@ public: 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. /** @@ -780,29 +927,39 @@ public: 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, @@ -813,45 +970,55 @@ protected: * 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. /** @@ -860,11 +1027,15 @@ protected: 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. /** @@ -872,31 +1043,39 @@ protected: * 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 == @@ -904,31 +1083,42 @@ protected: */ 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. /** @@ -938,11 +1128,14 @@ protected: * 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 * @@ -952,16 +1145,21 @@ protected: 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 @@ -969,22 +1167,31 @@ protected: /// 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 * @@ -999,6 +1206,7 @@ protected: class ACE_Dev_Poll_Handler_Guard { public: + /// Constructor /** * The constructor checks to see if @a eh is a reference-counted handler and @@ -1009,26 +1217,37 @@ public: * 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 index bd11e66ebe6..96e71f2dea5 100644 --- a/dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl +++ b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl @@ -1,8 +1,11 @@ // -*- 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), @@ -10,7 +13,9 @@ ACE_Dev_Poll_Event_Tuple::ACE_Dev_Poll_Event_Tuple (void) suspended (0) { } + // --------------------------------------------------------------------- + #if 0 ACE_INLINE ACE_Dev_Poll_Ready_Set::ACE_Dev_Poll_Ready_Set (void) @@ -19,59 +24,78 @@ ACE_Dev_Poll_Ready_Set::ACE_Dev_Poll_Ready_Set (void) { } #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, @@ -81,15 +105,19 @@ ACE_Dev_Poll_Handler_Guard::ACE_Dev_Poll_Handler_Guard { 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 @@ -112,11 +140,13 @@ ACE_Dev_Poll_Handler_Guard::ACE_Dev_Poll_Handler_Guard * 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 @@ -126,12 +156,15 @@ ACE_Dev_Poll_Handler_Guard::~ACE_Dev_Poll_Handler_Guard (void) * 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), @@ -141,23 +174,29 @@ ACE_Dev_Poll_Reactor::upcall (ACE_Event_Handler *event_handler, // 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) { @@ -167,19 +206,23 @@ ACE_Dev_Poll_Reactor::Token_Guard::~Token_Guard (void) 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 index 61950b53700..180642fc0f9 100644 --- a/dep/ACE_wrappers/ace/Dirent.cpp +++ b/dep/ACE_wrappers/ace/Dirent.cpp @@ -1,5 +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 index 11fde3d452f..036a942c611 100644 --- a/dep/ACE_wrappers/ace/Dirent.h +++ b/dep/ACE_wrappers/ace/Dirent.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Dirent.h @@ -11,15 +12,21 @@ * @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 * @@ -31,15 +38,20 @@ 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 @@ -59,6 +71,7 @@ public: * 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 @@ -66,10 +79,12 @@ public: */ 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 @@ -83,6 +98,7 @@ public: * 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 @@ -90,14 +106,18 @@ public: * 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 index adce9b950bf..01ce3a96c4b 100644 --- a/dep/ACE_wrappers/ace/Dirent.inl +++ b/dep/ACE_wrappers/ace/Dirent.inl @@ -1,29 +1,37 @@ // -*- 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) @@ -33,17 +41,20 @@ ACE_Dirent::ACE_Dirent (const ACE_TCHAR *dirname) 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) @@ -52,31 +63,37 @@ ACE_Dirent::read (struct ACE_DIRENT *entry, ? 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 index 9ed414bfcaf..875a466e5b3 100644 --- a/dep/ACE_wrappers/ace/Dirent_Selector.cpp +++ b/dep/ACE_wrappers/ace/Dirent_Selector.cpp @@ -1,25 +1,34 @@ // $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, @@ -28,6 +37,7 @@ ACE_Dirent_Selector::open (const ACE_TCHAR *dir, n_ = ACE_OS::scandir (dir, &this->namelist_, sel, cmp); return n_; } + int ACE_Dirent_Selector::close (void) { @@ -40,9 +50,11 @@ ACE_Dirent_Selector::close (void) #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 index d223414fadc..3356f18723d 100644 --- a/dep/ACE_wrappers/ace/Dirent_Selector.h +++ b/dep/ACE_wrappers/ace/Dirent_Selector.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Dirent_Selector.h @@ -10,16 +11,22 @@ * @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 * @@ -31,29 +38,39 @@ 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 index 1f1192c8567..15f804704bf 100644 --- a/dep/ACE_wrappers/ace/Dirent_Selector.inl +++ b/dep/ACE_wrappers/ace/Dirent_Selector.inl @@ -1,15 +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 index 7c43dbe5050..fce6bcc277a 100644 --- a/dep/ACE_wrappers/ace/Dump.cpp +++ b/dep/ACE_wrappers/ace/Dump.cpp @@ -1,32 +1,41 @@ // $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 { @@ -37,29 +46,35 @@ ACE_Dumpable_Ptr::operator= (const ACE_Dumpable *dumper) const (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) { @@ -71,14 +86,17 @@ ACE_ODB::dump_objects (void) 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) @@ -89,6 +107,7 @@ ACE_ODB::register_object (const ACE_Dumpable *dumper) break; } } + if (i == this->current_size_) { slot = this->current_size_++; @@ -97,22 +116,27 @@ ACE_ODB::register_object (const ACE_Dumpable *dumper) 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 index 0bd02f83b83..354b162cfb6 100644 --- a/dep/ACE_wrappers/ace/Dump.h +++ b/dep/ACE_wrappers/ace/Dump.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Dump.h @@ -46,14 +47,19 @@ */ //============================================================================= + #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 * @@ -65,16 +71,21 @@ 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 * @@ -87,11 +98,13 @@ 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 * @@ -103,22 +116,29 @@ 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 @@ -128,19 +148,26 @@ private: /// 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.h b/dep/ACE_wrappers/ace/Dump_T.h index cc18fdce813..4134df75392 100644 --- a/dep/ACE_wrappers/ace/Dump_T.h +++ b/dep/ACE_wrappers/ace/Dump_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Dump_T.h @@ -9,14 +10,19 @@ */ //============================================================================= + #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 * @@ -36,16 +42,21 @@ 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) @@ -58,12 +69,15 @@ ACE_END_VERSIONED_NAMESPACE_DECL 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 index ef8ce0cec0c..2a3f8b0f26d 100644 --- a/dep/ACE_wrappers/ace/Dynamic.cpp +++ b/dep/ACE_wrappers/ace/Dynamic.cpp @@ -1,27 +1,35 @@ // $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 index 48b10b87eaa..6906ebf1267 100644 --- a/dep/ACE_wrappers/ace/Dynamic.h +++ b/dep/ACE_wrappers/ace/Dynamic.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Dynamic.h @@ -9,14 +10,19 @@ * @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 * @@ -31,19 +37,25 @@ 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 @@ -52,10 +64,13 @@ private: */ 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 index efe1a7553e5..1e8e968f898 100644 --- a/dep/ACE_wrappers/ace/Dynamic.inl +++ b/dep/ACE_wrappers/ace/Dynamic.inl @@ -1,28 +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 index fe0617ba1c8..e6c89e5238e 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.cpp +++ b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.cpp @@ -1,16 +1,22 @@ #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, @@ -24,21 +30,26 @@ ACE_Dynamic_Message_Strategy::ACE_Dynamic_Message_Strategy (unsigned long static 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) { @@ -59,23 +70,29 @@ ACE_Dynamic_Message_Strategy::priority_status (ACE_Message_Block & mb, // 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") @@ -94,9 +111,11 @@ ACE_Dynamic_Message_Strategy::dump (void) const 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, @@ -107,9 +126,11 @@ ACE_Deadline_Message_Strategy::ACE_Deadline_Message_Strategy (unsigned long stat 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) @@ -119,18 +140,24 @@ ACE_Deadline_Message_Strategy::convert_priority (ACE_Time_Value & priority, 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, @@ -141,9 +168,11 @@ ACE_Laxity_Message_Strategy::ACE_Laxity_Message_Strategy (unsigned long static_b 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) @@ -154,18 +183,24 @@ ACE_Laxity_Message_Strategy::convert_priority (ACE_Time_Value & priority, 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 index ab40483e066..db6a51bb70e 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.h +++ b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Dynamic_Message_Strategy.h @@ -8,16 +9,23 @@ * @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 * @@ -40,9 +48,12 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 @@ -54,57 +65,78 @@ public: /// 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 * @@ -127,14 +159,18 @@ public: 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 * @@ -158,18 +194,25 @@ public: 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 index 013cc186c71..9742a07fd88 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.inl +++ b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.inl @@ -1,37 +1,44 @@ // -*- 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) { @@ -43,12 +50,14 @@ ACE_Dynamic_Message_Strategy::dynamic_priority_max (unsigned long 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) { @@ -62,4 +71,5 @@ ACE_Dynamic_Message_Strategy::dynamic_priority_offset (unsigned long ul) 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.h b/dep/ACE_wrappers/ace/Dynamic_Service.h index 8ed9a50b7b7..fb2469c5418 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Service.h +++ b/dep/ACE_wrappers/ace/Dynamic_Service.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Dynamic_Service.h @@ -9,17 +10,25 @@ * @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 * @@ -36,34 +45,46 @@ 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 index 402f99a8878..31324bf535b 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Service.inl +++ b/dep/ACE_wrappers/ace/Dynamic_Service.inl @@ -1,25 +1,31 @@ // -*- 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, @@ -27,5 +33,7 @@ ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* repo, { 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 index cac33ef3783..174b009d7b6 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp +++ b/dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp @@ -5,30 +5,38 @@ #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, @@ -36,16 +44,20 @@ ACE_Dynamic_Service_Base::find_i (const ACE_Service_Gestalt* &repo, { 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, @@ -53,8 +65,10 @@ ACE_Dynamic_Service_Base::instance (const ACE_Service_Gestalt* repo, 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) @@ -63,13 +77,16 @@ ACE_Dynamic_Service_Base::instance (const ACE_Service_Gestalt* repo, 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"), @@ -77,7 +94,9 @@ ACE_Dynamic_Service_Base::instance (const ACE_Service_Gestalt* 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 index c0a6cccfe5a..4491a9407d8 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Service_Base.h +++ b/dep/ACE_wrappers/ace/Dynamic_Service_Base.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Dynamic_Service_Base.h @@ -9,16 +10,23 @@ * @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 * @@ -29,31 +37,39 @@ class ACE_Service_Type; */ 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 index 5aed803a36c..9a371ff3c16 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.cpp +++ b/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.cpp @@ -3,22 +3,27 @@ #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 ()) @@ -26,6 +31,7 @@ ACE_Dynamic_Service_Dependency::~ACE_Dynamic_Service_Dependency (void) ACE_TEXT ("(%P|%t) DSD, this=%@ - destroying\n"), this)); } + void ACE_Dynamic_Service_Dependency::init (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal) @@ -41,5 +47,6 @@ ACE_Dynamic_Service_Dependency::init (const ACE_Service_Gestalt *cfg, 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 index e08e6ec0951..ce4c1d3e7cd 100644 --- a/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.h +++ b/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Dynamic_Service_Dependency.h @@ -8,17 +9,23 @@ * @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 * @@ -47,13 +54,18 @@ public: 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 index e3ce23c8640..e01c15ef865 100644 --- a/dep/ACE_wrappers/ace/Encoding_Converter.cpp +++ b/dep/ACE_wrappers/ace/Encoding_Converter.cpp @@ -1,10 +1,13 @@ // $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 index 4567f31f741..8833d3fced8 100644 --- a/dep/ACE_wrappers/ace/Encoding_Converter.h +++ b/dep/ACE_wrappers/ace/Encoding_Converter.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================= /** * @file Encoding_Converter.h @@ -11,13 +12,19 @@ * @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. @@ -33,9 +40,11 @@ public: 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, @@ -43,6 +52,7 @@ public: 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, @@ -51,8 +61,11 @@ public: 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 index a3b36b2efb1..3cd365f3ae1 100644 --- a/dep/ACE_wrappers/ace/Encoding_Converter_Factory.cpp +++ b/dep/ACE_wrappers/ace/Encoding_Converter_Factory.cpp @@ -1,11 +1,14 @@ // $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, @@ -18,6 +21,7 @@ ACE_Encoding_Converter_Factory::create ( bool const convert_for_bigendian = false; #endif /* ACE_BIG_ENDIAN */ ACE_Encoding_Converter* converter = 0; + switch (hint) { case ACE_UTF_32BE: @@ -51,17 +55,21 @@ ACE_Encoding_Converter_Factory::create ( 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 index 1ee3747122f..c1311451db5 100644 --- a/dep/ACE_wrappers/ace/Encoding_Converter_Factory.h +++ b/dep/ACE_wrappers/ace/Encoding_Converter_Factory.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================= /** * @file Encoding_Converter_Factory.h @@ -10,14 +11,21 @@ * @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. */ @@ -29,6 +37,7 @@ public: 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. @@ -36,8 +45,11 @@ public: 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.h b/dep/ACE_wrappers/ace/Env_Value_T.h index 046ea9b4031..05b4706c122 100644 --- a/dep/ACE_wrappers/ace/Env_Value_T.h +++ b/dep/ACE_wrappers/ace/Env_Value_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Env_Value_T.h @@ -12,16 +13,22 @@ * @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 * @@ -40,81 +47,104 @@ public: * '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 @@ -125,10 +155,13 @@ 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 index c18a3205eb7..d9af1b03164 100644 --- a/dep/ACE_wrappers/ace/Env_Value_T.inl +++ b/dep/ACE_wrappers/ace/Env_Value_T.inl @@ -1,15 +1,19 @@ // $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) @@ -18,6 +22,7 @@ ACE_Env_Value::ACE_Env_Value (const ACE_TCHAR *varname, { this->fetch_value (); } + template ACE_INLINE void ACE_Env_Value::open (const ACE_TCHAR *varname, const T &defval) @@ -26,6 +31,7 @@ ACE_Env_Value::open (const ACE_TCHAR *varname, this->value_ = defval; this->fetch_value (); } + template ACE_INLINE void ACE_Env_Value::fetch_value (void) { @@ -39,13 +45,16 @@ ACE_Env_Value::fetch_value (void) 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 index d98e055fd3e..a5461de4bd9 100644 --- a/dep/ACE_wrappers/ace/Event.cpp +++ b/dep/ACE_wrappers/ace/Event.cpp @@ -1,11 +1,17 @@ // $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, @@ -25,10 +31,12 @@ ACE_Event::ACE_Event (int manual_reset, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Event::ACE_Event"))); } + ACE_Event::~ACE_Event (void) { this->remove (); } + int ACE_Event::remove (void) { @@ -40,11 +48,13 @@ ACE_Event::remove (void) } 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) { @@ -52,21 +62,25 @@ ACE_Event::wait (const ACE_Time_Value *abstime, int use_absolute_time) 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 { @@ -75,5 +89,6 @@ ACE_Event::dump (void) const 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 index 3c9f744a9c4..69d819b3978 100644 --- a/dep/ACE_wrappers/ace/Event.h +++ b/dep/ACE_wrappers/ace/Event.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Event.h @@ -10,15 +11,21 @@ * @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 * @@ -39,16 +46,20 @@ public: 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 @@ -58,6 +69,7 @@ public: * overwriting it. */ void handle (ACE_event_t new_handle); + /** * if MANUAL reset * sleep till the event becomes signaled @@ -67,11 +79,13 @@ public: * 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 @@ -82,6 +96,7 @@ public: * reset event */ int signal (void); + /** * if MANUAL reset * wakeup all waiting threads and @@ -91,30 +106,39 @@ public: * 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 index 295bf267de1..ae0805c95f0 100644 --- a/dep/ACE_wrappers/ace/Event.inl +++ b/dep/ACE_wrappers/ace/Event.inl @@ -1,14 +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 index c360e156ad5..916998eea52 100644 --- a/dep/ACE_wrappers/ace/Event_Handler.cpp +++ b/dep/ACE_wrappers/ace/Event_Handler.cpp @@ -1,19 +1,26 @@ // 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), @@ -23,149 +30,185 @@ ACE_Event_Handler::ACE_Event_Handler (ACE_Reactor *r, { // 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 @@ -173,42 +216,53 @@ ACE_Event_Handler::remove_reference (void) 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, @@ -217,6 +271,7 @@ ACE_Event_Handler::register_stdin_handler (ACE_Event_Handler *eh, { #if defined (ACE_WIN32) ACE_UNUSED_ARG (reactor); + eh->reactor (reactor); return thr_mgr->spawn (&read_adapter, static_cast (eh), flags); #else @@ -228,12 +283,14 @@ ACE_Event_Handler::register_stdin_handler (ACE_Event_Handler *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 @@ -241,16 +298,21 @@ ACE_Event_Handler::remove_stdin_handler (ACE_Reactor *reactor, 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_) { @@ -259,6 +321,7 @@ ACE_Event_Handler_var::ACE_Event_Handler_var (const ACE_Event_Handler_var &b) this->ptr_->add_reference (); } } + ACE_Event_Handler_var::~ACE_Event_Handler_var (void) { if (this->ptr_ != 0) @@ -267,6 +330,7 @@ ACE_Event_Handler_var::~ACE_Event_Handler_var (void) this->ptr_->remove_reference (); } } + ACE_Event_Handler_var & ACE_Event_Handler_var::operator= (ACE_Event_Handler *p) { @@ -275,25 +339,31 @@ ACE_Event_Handler_var::operator= (ACE_Event_Handler *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) { @@ -301,16 +371,20 @@ ACE_Event_Handler_var::release (void) 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), @@ -318,5 +392,6 @@ ACE_Notification_Buffer::ACE_Notification_Buffer (ACE_Event_Handler *eh, { 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 index 1939ff59850..e97cca48a46 100644 --- a/dep/ACE_wrappers/ace/Event_Handler.h +++ b/dep/ACE_wrappers/ace/Event_Handler.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //========================================================================== /** * @file Event_Handler.h @@ -8,24 +9,32 @@ * @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 * @@ -73,26 +82,36 @@ public: 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 @@ -101,17 +120,21 @@ public: */ 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.. @@ -135,15 +158,20 @@ public: * 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 @@ -164,11 +193,14 @@ public: 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 @@ -178,6 +210,7 @@ public: * @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 @@ -188,6 +221,7 @@ public: * @return Current reference count. */ virtual Reference_Count remove_reference (void); + /** * @class Policy * @@ -195,10 +229,13 @@ public: */ class ACE_Export Policy { + public: + /// Virtual destructor. virtual ~Policy (void); }; + /** * @class Reference_Counting_Policy * @@ -215,7 +252,9 @@ public: { /// This policy can only be created by the handler. friend class ACE_Event_Handler; + public: + enum Value { /// Perform reference counting. @@ -223,34 +262,48 @@ public: /// 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 * @@ -261,31 +314,45 @@ private: */ 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 * @@ -296,20 +363,27 @@ 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 index 1f285572543..d97c45466ae 100644 --- a/dep/ACE_wrappers/ace/Event_Handler.inl +++ b/dep/ACE_wrappers/ace/Event_Handler.inl @@ -1,9 +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.h b/dep/ACE_wrappers/ace/Event_Handler_T.h index 99c7ad8eaf5..47cc5fd56bf 100644 --- a/dep/ACE_wrappers/ace/Event_Handler_T.h +++ b/dep/ACE_wrappers/ace/Event_Handler_T.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Event_Handler_T.h @@ -8,15 +9,21 @@ * @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 * @@ -58,17 +65,23 @@ 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, @@ -80,9 +93,12 @@ public: 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); @@ -92,60 +108,84 @@ public: 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 index 2207be8ab2a..40db43e8e23 100644 --- a/dep/ACE_wrappers/ace/Event_Handler_T.inl +++ b/dep/ACE_wrappers/ace/Event_Handler_T.inl @@ -1,114 +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 index 26a772ed064..32805184d04 100644 --- a/dep/ACE_wrappers/ace/Exception_Macros.h +++ b/dep/ACE_wrappers/ace/Exception_Macros.h @@ -1,4 +1,5 @@ // -*- C++ -*- + // ============================================================================ /** * @file Exception_Macros.h @@ -15,14 +16,20 @@ * @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 @@ -42,6 +49,8 @@ # 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 index 80342f65f01..c5ace7f90d9 100644 --- a/dep/ACE_wrappers/ace/FIFO.cpp +++ b/dep/ACE_wrappers/ace/FIFO.cpp @@ -1,39 +1,51 @@ // $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, @@ -43,15 +55,18 @@ ACE_FIFO::ACE_FIFO (const ACE_TCHAR *fifo_name, 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 ()); @@ -59,5 +74,6 @@ ACE_FIFO::close (void) } return result; } + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO.h b/dep/ACE_wrappers/ace/FIFO.h index e640f640a69..a1ef6038e35 100644 --- a/dep/ACE_wrappers/ace/FIFO.h +++ b/dep/ACE_wrappers/ace/FIFO.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file FIFO.h @@ -9,16 +10,22 @@ */ //========================================================================== + #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 * @@ -36,33 +43,44 @@ public: /// 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 index 726e719307e..05cc030a917 100644 --- a/dep/ACE_wrappers/ace/FIFO.inl +++ b/dep/ACE_wrappers/ace/FIFO.inl @@ -1,8 +1,11 @@ // -*- 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 { @@ -10,6 +13,7 @@ ACE_FIFO::get_local_addr (const ACE_TCHAR *&r) const r = this->rendezvous_; return 0; } + ACE_INLINE int ACE_FIFO::remove (void) { @@ -17,4 +21,5 @@ ACE_FIFO::remove (void) 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 index 1a7085b1502..08eb20fb469 100644 --- a/dep/ACE_wrappers/ace/FIFO_Recv.cpp +++ b/dep/ACE_wrappers/ace/FIFO_Recv.cpp @@ -1,13 +1,19 @@ // $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 { @@ -19,19 +25,23 @@ ACE_FIFO_Recv::dump (void) const 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, @@ -40,6 +50,7 @@ ACE_FIFO_Recv::open (const ACE_TCHAR *fifo_name, 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) @@ -50,11 +61,13 @@ ACE_FIFO_Recv::open (const ACE_TCHAR *fifo_name, 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, @@ -63,6 +76,7 @@ ACE_FIFO_Recv::ACE_FIFO_Recv (const ACE_TCHAR *fifo_name, : aux_handle_ (ACE_INVALID_HANDLE) { ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv"); + if (this->ACE_FIFO_Recv::open (fifo_name, flags, perms, @@ -70,5 +84,6 @@ ACE_FIFO_Recv::ACE_FIFO_Recv (const ACE_TCHAR *fifo_name, 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 index 723e5be6e9f..7c9ffbec84e 100644 --- a/dep/ACE_wrappers/ace/FIFO_Recv.h +++ b/dep/ACE_wrappers/ace/FIFO_Recv.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file FIFO_Recv.h @@ -9,16 +10,23 @@ */ //========================================================================== + #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 * @@ -31,36 +39,48 @@ 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 index a127a8a2c3f..d4c3fee4326 100644 --- a/dep/ACE_wrappers/ace/FIFO_Recv.inl +++ b/dep/ACE_wrappers/ace/FIFO_Recv.inl @@ -1,19 +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 index a9eb284d842..5a8cb5c04d5 100644 --- a/dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp +++ b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp @@ -1,12 +1,19 @@ // $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 { @@ -15,9 +22,11 @@ ACE_FIFO_Recv_Msg::dump (void) const 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, @@ -26,16 +35,19 @@ ACE_FIFO_Recv_Msg::open (const ACE_TCHAR *fifo_name, 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, @@ -43,6 +55,7 @@ ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg (const ACE_TCHAR *fifo_name, LPSECURITY_ATTRIBUTES sa) { ACE_TRACE ("ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg"); + if (this->ACE_FIFO_Recv_Msg::open (fifo_name, flags, perms, @@ -50,5 +63,6 @@ ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg (const ACE_TCHAR *fifo_name, 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 index 57a340a3b15..5490814c56b 100644 --- a/dep/ACE_wrappers/ace/FIFO_Recv_Msg.h +++ b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file FIFO_Recv_Msg.h @@ -9,16 +10,22 @@ */ //============================================================================= + #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 * @@ -41,18 +48,21 @@ 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 @@ -78,6 +88,7 @@ public: * @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. @@ -96,26 +107,33 @@ public: * 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 index c1cbf4e37db..0a0b0673d38 100644 --- a/dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl +++ b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl @@ -1,13 +1,17 @@ // -*- 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) { @@ -39,12 +43,15 @@ ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf &recv_msg) 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. @@ -53,6 +60,7 @@ ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf &recv_msg) // 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; @@ -60,23 +68,29 @@ ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf &recv_msg) 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, @@ -96,6 +110,7 @@ ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf *data, 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, @@ -103,6 +118,7 @@ ACE_FIFO_Recv_Msg::recv (int *band, int *flags) { ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); + if (ACE_OS::getpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, @@ -117,4 +133,5 @@ ACE_FIFO_Recv_Msg::recv (int *band, } } #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 index 3913f4a86d5..79ea87682d3 100644 --- a/dep/ACE_wrappers/ace/FIFO_Send.cpp +++ b/dep/ACE_wrappers/ace/FIFO_Send.cpp @@ -1,12 +1,18 @@ // $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 { @@ -15,10 +21,12 @@ ACE_FIFO_Send::dump (void) const 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, @@ -31,6 +39,7 @@ ACE_FIFO_Send::open (const ACE_TCHAR *rendezvous_name, perms, sa); } + ACE_FIFO_Send::ACE_FIFO_Send (const ACE_TCHAR *fifo_name, int flags, mode_t perms, @@ -45,5 +54,6 @@ ACE_FIFO_Send::ACE_FIFO_Send (const ACE_TCHAR *fifo_name, 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 index 503054e47d3..7c0928cceaf 100644 --- a/dep/ACE_wrappers/ace/FIFO_Send.h +++ b/dep/ACE_wrappers/ace/FIFO_Send.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file FIFO_Send.h @@ -9,16 +10,23 @@ */ //========================================================================== + #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 * @@ -30,29 +38,39 @@ 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 index e04afc77074..a01facd61f0 100644 --- a/dep/ACE_wrappers/ace/FIFO_Send.inl +++ b/dep/ACE_wrappers/ace/FIFO_Send.inl @@ -1,19 +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 index 711d827911f..441a850c354 100644 --- a/dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp +++ b/dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp @@ -1,13 +1,20 @@ // $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 { @@ -16,6 +23,7 @@ ACE_FIFO_Send_Msg::dump (void) const ACE_FIFO_Send::dump (); #endif /* ACE_HAS_DUMP */ } + ssize_t ACE_FIFO_Send_Msg::send (const ACE_Str_Buf &send_msg) { @@ -30,20 +38,25 @@ ACE_FIFO_Send_Msg::send (const ACE_Str_Buf &send_msg) 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, @@ -53,6 +66,7 @@ ACE_FIFO_Send_Msg::open (const ACE_TCHAR *fifo_name, 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, @@ -62,5 +76,6 @@ ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (const ACE_TCHAR *fifo_name, 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 index c625dcc3381..ff746969156 100644 --- a/dep/ACE_wrappers/ace/FIFO_Send_Msg.h +++ b/dep/ACE_wrappers/ace/FIFO_Send_Msg.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file FIFO_Send_Msg.h @@ -9,19 +10,26 @@ */ //============================================================================= + #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 * @@ -34,40 +42,51 @@ 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 index b2f5036f549..0a34e64e370 100644 --- a/dep/ACE_wrappers/ace/FIFO_Send_Msg.inl +++ b/dep/ACE_wrappers/ace/FIFO_Send_Msg.inl @@ -1,15 +1,20 @@ // -*- 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, @@ -25,6 +30,7 @@ ACE_FIFO_Send_Msg::send (const ACE_Str_Buf *data, 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, @@ -32,6 +38,7 @@ ACE_FIFO_Send_Msg::send (int band, int flags) { ACE_TRACE ("ACE_FIFO_Send_Msg::send"); + if (ACE_OS::putpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, @@ -42,4 +49,5 @@ ACE_FIFO_Send_Msg::send (int band, 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 index 3f4c02b6dcf..50b6342bc89 100644 --- a/dep/ACE_wrappers/ace/FILE.cpp +++ b/dep/ACE_wrappers/ace/FILE.cpp @@ -1,15 +1,23 @@ // $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 { @@ -18,17 +26,22 @@ ACE_FILE::dump (void) const 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 ()); @@ -36,52 +49,65 @@ ACE_FILE::close (void) } 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 @@ -90,25 +116,33 @@ ACE_FILE::get_local_addr (ACE_Addr &addr) const 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 index bc6ffe68785..44d5ac71d20 100644 --- a/dep/ACE_wrappers/ace/FILE.h +++ b/dep/ACE_wrappers/ace/FILE.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file FILE.h @@ -8,18 +9,24 @@ * @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 @@ -27,7 +34,9 @@ #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 * @@ -38,11 +47,14 @@ 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 * @@ -54,17 +66,23 @@ 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 @@ -78,34 +96,45 @@ public: */ 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 index 5bed51dd798..288374afc58 100644 --- a/dep/ACE_wrappers/ace/FILE.inl +++ b/dep/ACE_wrappers/ace/FILE.inl @@ -1,7 +1,9 @@ // -*- 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 { @@ -12,4 +14,5 @@ ACE_FILE::disable (int signum) const 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 index 6b282822fde..4b95a7db874 100644 --- a/dep/ACE_wrappers/ace/FILE_Addr.cpp +++ b/dep/ACE_wrappers/ace/FILE_Addr.cpp @@ -1,21 +1,28 @@ // $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) { @@ -34,9 +41,12 @@ ACE_FILE_Addr::set (const ACE_FILE_Addr &sa) 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, @@ -45,16 +55,20 @@ ACE_FILE_Addr::set (const ACE_FILE_Addr &sa) 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) { @@ -65,6 +79,7 @@ ACE_FILE_Addr::set (const ACE_TCHAR *filename) sizeof this->filename_ / sizeof (ACE_TCHAR)); return 0; } + ACE_FILE_Addr & ACE_FILE_Addr::operator= (const ACE_FILE_Addr &sa) { @@ -72,28 +87,35 @@ ACE_FILE_Addr::operator= (const ACE_FILE_Addr &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)); diff --git a/dep/ACE_wrappers/ace/FILE_Addr.h b/dep/ACE_wrappers/ace/FILE_Addr.h index 2ad8ea993ea..0604b689e5b 100644 --- a/dep/ACE_wrappers/ace/FILE_Addr.h +++ b/dep/ACE_wrappers/ace/FILE_Addr.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file FILE_Addr.h @@ -8,16 +9,22 @@ * @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 * @@ -29,39 +36,55 @@ 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 index 4f8a99d7a76..0ae7d31d278 100644 --- a/dep/ACE_wrappers/ace/FILE_Addr.inl +++ b/dep/ACE_wrappers/ace/FILE_Addr.inl @@ -2,24 +2,33 @@ // // $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 index 7ae8d002de3..b4f4d09e3c6 100644 --- a/dep/ACE_wrappers/ace/FILE_Connector.cpp +++ b/dep/ACE_wrappers/ace/FILE_Connector.cpp @@ -1,27 +1,36 @@ // $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, @@ -33,7 +42,9 @@ ACE_FILE_Connector::connect (ACE_FILE_IO &new_io, { 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) @@ -47,21 +58,28 @@ ACE_FILE_Connector::connect (ACE_FILE_IO &new_io, // 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 index 3b820c2b21c..4f87e209d66 100644 --- a/dep/ACE_wrappers/ace/FILE_Connector.h +++ b/dep/ACE_wrappers/ace/FILE_Connector.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file FILE_Connector.h @@ -8,16 +9,21 @@ * @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 * @@ -36,6 +42,7 @@ 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 @@ -57,6 +64,7 @@ public: 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 @@ -80,20 +88,27 @@ public: 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 index 867549f953a..deab94e0061 100644 --- a/dep/ACE_wrappers/ace/FILE_Connector.inl +++ b/dep/ACE_wrappers/ace/FILE_Connector.inl @@ -1,8 +1,11 @@ // -*- 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, @@ -21,6 +24,7 @@ ACE_FILE_Connector::ACE_FILE_Connector (ACE_FILE_IO &new_io, remote_sap.get_path_name (), ACE_TEXT ("ACE_FILE_IO"))); } + ACE_INLINE int ACE_FILE_Connector::reset_new_handle (ACE_HANDLE handle) { @@ -28,4 +32,5 @@ ACE_FILE_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/FILE_IO.cpp b/dep/ACE_wrappers/ace/FILE_IO.cpp index 3d644951807..c68df3e0416 100644 --- a/dep/ACE_wrappers/ace/FILE_IO.cpp +++ b/dep/ACE_wrappers/ace/FILE_IO.cpp @@ -1,34 +1,46 @@ // $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 { @@ -43,12 +55,15 @@ ACE_FILE_IO::send (size_t n, ...) const 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); @@ -58,11 +73,13 @@ ACE_FILE_IO::send (size_t n, ...) const 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 { @@ -77,12 +94,15 @@ ACE_FILE_IO::recv (size_t n, ...) const 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); @@ -92,17 +112,21 @@ ACE_FILE_IO::recv (size_t n, ...) const 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, @@ -117,5 +141,6 @@ ACE_FILE_IO::recvv (iovec *io_vec) 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 index c5042c75e45..a1a470b8d30 100644 --- a/dep/ACE_wrappers/ace/FILE_IO.h +++ b/dep/ACE_wrappers/ace/FILE_IO.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file FILE_IO.h @@ -8,24 +9,33 @@ * @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 * @@ -35,47 +45,61 @@ 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 @@ -83,6 +107,7 @@ public: * 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 @@ -91,17 +116,21 @@ public: * 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 @@ -111,24 +140,32 @@ public: * 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 index 80f18745ad7..d2e4f756c2c 100644 --- a/dep/ACE_wrappers/ace/FILE_IO.inl +++ b/dep/ACE_wrappers/ace/FILE_IO.inl @@ -1,10 +1,13 @@ // -*- 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 { @@ -13,6 +16,7 @@ ACE_FILE_IO::sendv_n (const iovec iov[], int n) const iov, n); } + ACE_INLINE ssize_t ACE_FILE_IO::send_n (const ACE_Message_Block *message_block, const ACE_Time_Value *timeout, @@ -24,7 +28,9 @@ ACE_FILE_IO::send_n (const ACE_Message_Block *message_block, 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 { @@ -35,53 +41,64 @@ ACE_FILE_IO::recvv_n (iovec iov[], int n) const 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 @@ -89,24 +106,28 @@ ACE_FILE_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) 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 @@ -116,6 +137,7 @@ ACE_FILE_IO::send (const void *buf, size_t n, buf, n, overlapped); } + ACE_INLINE ssize_t ACE_FILE_IO::recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const @@ -124,5 +146,7 @@ ACE_FILE_IO::recv (void *buf, size_t n, 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 index 54779482753..2b06ff26640 100644 --- a/dep/ACE_wrappers/ace/File_Lock.cpp +++ b/dep/ACE_wrappers/ace/File_Lock.cpp @@ -1,22 +1,30 @@ // $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), @@ -29,6 +37,7 @@ ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h, 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, @@ -36,12 +45,14 @@ ACE_File_Lock::ACE_File_Lock (const ACE_TCHAR *name, : 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, @@ -51,10 +62,12 @@ ACE_File_Lock::open (const ACE_TCHAR *name, 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 index aca576b562c..c0629762d15 100644 --- a/dep/ACE_wrappers/ace/File_Lock.h +++ b/dep/ACE_wrappers/ace/File_Lock.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file File_Lock.h @@ -8,15 +9,21 @@ * @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 * @@ -38,6 +45,7 @@ public: */ 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 . @@ -45,22 +53,27 @@ public: 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 @@ -69,17 +82,21 @@ public: * 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 @@ -88,20 +105,24 @@ public: 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 @@ -111,31 +132,40 @@ public: * 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 index abdd9d4a256..20b00039222 100644 --- a/dep/ACE_wrappers/ace/File_Lock.inl +++ b/dep/ACE_wrappers/ace/File_Lock.inl @@ -1,25 +1,30 @@ // -*- 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, @@ -28,35 +33,42 @@ ACE_File_Lock::tryacquire_write_upgrade (short whence, // 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; @@ -65,12 +77,14 @@ ACE_File_Lock::remove (int 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) { @@ -78,4 +92,5 @@ ACE_File_Lock::set_handle (ACE_HANDLE h) 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 index df1fe934c7d..cfb70f94f68 100644 --- a/dep/ACE_wrappers/ace/Filecache.cpp +++ b/dep/ACE_wrappers/ace/Filecache.cpp @@ -1,4 +1,5 @@ // $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" @@ -9,9 +10,11 @@ #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 @@ -20,6 +23,7 @@ ACE_RCSID (ace, #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 | \ @@ -38,20 +42,25 @@ ACE_RCSID (ace, #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) @@ -59,16 +68,19 @@ ACE_Filecache_Handle::ACE_Filecache_Handle (const ACE_TCHAR *filename, 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 @@ -76,23 +88,28 @@ ACE_Filecache_Handle::ACE_Filecache_Handle (const ACE_TCHAR *filename, // 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 { @@ -104,6 +121,7 @@ ACE_Filecache_Handle::handle (void) const } return this->handle_; } + int ACE_Filecache_Handle::error (void) const { @@ -112,6 +130,7 @@ ACE_Filecache_Handle::error (void) const else return this->file_->error (); } + ACE_OFF_T ACE_Filecache_Handle::size (void) const { @@ -120,13 +139,16 @@ ACE_Filecache_Handle::size (void) const 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, @@ -141,6 +163,7 @@ ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry ( prev_ (prev) { } + template <> ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry (ACE_Filecache_Hash_Entry *next, ACE_Filecache_Hash_Entry *prev) @@ -149,19 +172,23 @@ ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry (ACE_Filecache_Hash_Entry *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, @@ -169,12 +196,15 @@ ACE_Filecache_Hash::equal (const ACE_TCHAR *const &id1, { return ACE_OS::strcmp (id1, id2) == 0; } + #undef ACE_Filecache_Hash #undef ACE_Filecache_Hash_Entry + // ------------- // ACE_Filecache // ------------- + ACE_Filecache * ACE_Filecache::instance (void) { @@ -185,6 +215,7 @@ ACE_Filecache::instance (void) *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) @@ -192,28 +223,35 @@ ACE_Filecache::instance (void) 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; @@ -222,16 +260,20 @@ ACE_Filecache::insert_i (const ACE_TCHAR *filename, } 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) @@ -242,58 +284,74 @@ ACE_Filecache::remove_i (const ACE_TCHAR *filename) } 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 (); } @@ -307,35 +365,45 @@ ACE_Filecache::fetch (const ACE_TCHAR *filename, int mapit) 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_) { @@ -345,10 +413,13 @@ ACE_Filecache::finish (ACE_Filecache_Object *&file) 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 @@ -365,9 +436,11 @@ ACE_Filecache::finish (ACE_Filecache_Object *&file) } #endif } + break; default: file->release (); + // Last one using a stale file is resposible for deleting it. if (file->stale_) { @@ -379,10 +452,13 @@ ACE_Filecache::finish (ACE_Filecache_Object *&file) file = 0; } } + break; } + return file; } + void ACE_Filecache_Object::init (void) { @@ -391,8 +467,10 @@ ACE_Filecache_Object::init (void) 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_ (), @@ -408,6 +486,7 @@ ACE_Filecache_Object::ACE_Filecache_Object (void) { this->init (); } + ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, ACE_SYNCH_RW_MUTEX &lock, LPSECURITY_ATTRIBUTES sa, @@ -425,24 +504,29 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, 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_); @@ -452,6 +536,7 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, ACE_TEXT ("ACE_Filecache_Object::ctor: open")); return; } + if (mapit) { // Can we map the file? @@ -465,9 +550,11 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, 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, @@ -477,9 +564,11 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, 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? @@ -489,7 +578,9 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, 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) @@ -498,6 +589,7 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, ACE_TEXT ("ACE_Filecache_Object::acquire: open")); return; } + // Can we write? if (ACE_OS::pwrite (this->handle_, "", 1, this->size_ - 1) != 1) { @@ -506,6 +598,7 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, 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) @@ -514,8 +607,10 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, 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) @@ -524,19 +619,23 @@ ACE_Filecache_Object::~ACE_Filecache_Object (void) 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_); @@ -552,9 +651,11 @@ ACE_Filecache_Object::release (void) 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); @@ -575,17 +676,21 @@ ACE_Filecache_Object::release (void) 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) { @@ -594,36 +699,42 @@ ACE_Filecache_Object::error_i (int error_value, const ACE_TCHAR *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 @@ -636,7 +747,9 @@ ACE_Filecache_Object::update (void) const #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 index bdc89e39b36..c6dba10f339 100644 --- a/dep/ACE_wrappers/ace/Filecache.h +++ b/dep/ACE_wrappers/ace/Filecache.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Filecache.h @@ -9,25 +10,34 @@ */ //============================================================================= + #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 * @@ -79,10 +89,12 @@ class ACE_Export ACE_Filecache_Handle // 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 @@ -91,21 +103,29 @@ public: 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 @@ -118,16 +138,22 @@ public: 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 * @@ -141,20 +167,27 @@ 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, @@ -163,29 +196,38 @@ protected: 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 * @@ -198,51 +240,68 @@ 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, @@ -253,31 +312,43 @@ public: 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 index c453ef6dafc..252ea6240da 100644 --- a/dep/ACE_wrappers/ace/Flag_Manip.cpp +++ b/dep/ACE_wrappers/ace/Flag_Manip.cpp @@ -1,20 +1,28 @@ // $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) { @@ -34,21 +42,27 @@ ACE::set_flags (ACE_HANDLE handle, int flags) } #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) { @@ -64,15 +78,19 @@ ACE::clr_flags (ACE_HANDLE handle, int flags) } #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 index d88a97fd033..6bd797e5606 100644 --- a/dep/ACE_wrappers/ace/Flag_Manip.h +++ b/dep/ACE_wrappers/ace/Flag_Manip.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Flag_Manip.h @@ -10,36 +11,49 @@ * @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 index bcf170defeb..229a4ee596c 100644 --- a/dep/ACE_wrappers/ace/Flag_Manip.inl +++ b/dep/ACE_wrappers/ace/Flag_Manip.inl @@ -1,13 +1,17 @@ // -*- 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 @@ -18,4 +22,5 @@ ACE::get_flags (ACE_HANDLE handle) 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 index 15ce13a7f6d..446df96fa31 100644 --- a/dep/ACE_wrappers/ace/Framework_Component.cpp +++ b/dep/ACE_wrappers/ace/Framework_Component.cpp @@ -1,50 +1,69 @@ // 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. @@ -54,20 +73,25 @@ ACE_Framework_Repository::close (void) 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. @@ -84,23 +108,29 @@ ACE_Framework_Repository::instance (int size) } } } + 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] && @@ -110,20 +140,24 @@ ACE_Framework_Repository::register_component (ACE_Framework_Component *fc) "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) @@ -133,23 +167,30 @@ ACE_Framework_Repository::remove_component (const ACE_TCHAR *name) 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) @@ -163,20 +204,26 @@ ACE_Framework_Repository::remove_dll_components_i (const ACE_TCHAR *dll_name) 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) { @@ -193,6 +240,7 @@ ACE_Framework_Repository::compact (void) else if (end_hole != this->current_size_) break; } + if (start_hole != this->current_size_) { // move the contents and reset current_size_ @@ -205,8 +253,10 @@ ACE_Framework_Repository::compact (void) // active slot. this->current_size_ = start_hole; } + } while (start_hole != this->current_size_); } + void ACE_Framework_Repository::dump (void) const { @@ -214,14 +264,17 @@ ACE_Framework_Repository::dump (void) const 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 index 5d0c5a93645..fecd8ccf3bb 100644 --- a/dep/ACE_wrappers/ace/Framework_Component.h +++ b/dep/ACE_wrappers/ace/Framework_Component.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Framework_Component.h @@ -31,17 +32,24 @@ * @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 * @@ -52,27 +60,35 @@ 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 * @@ -87,77 +103,109 @@ 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 index 46736dd73ab..1fb2de38b85 100644 --- a/dep/ACE_wrappers/ace/Framework_Component.inl +++ b/dep/ACE_wrappers/ace/Framework_Component.inl @@ -1,9 +1,12 @@ // -*- 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, @@ -14,7 +17,9 @@ ACE_Framework_Component::ACE_Framework_Component (void *_this, { ACE_TRACE ("ACE_Framework_Component::ctor"); } + /***************************************************************/ + ACE_INLINE int ACE_Framework_Repository::current_size (void) const { @@ -22,6 +27,7 @@ ACE_Framework_Repository::current_size (void) const 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 { @@ -29,4 +35,5 @@ ACE_Framework_Repository::total_size (void) const 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.h b/dep/ACE_wrappers/ace/Framework_Component_T.h index 5ddc94a633f..f8d365a86c0 100644 --- a/dep/ACE_wrappers/ace/Framework_Component_T.h +++ b/dep/ACE_wrappers/ace/Framework_Component_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Framework_Component_T.h @@ -8,14 +9,18 @@ * @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 * @@ -34,26 +39,34 @@ 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.h b/dep/ACE_wrappers/ace/Free_List.h index 9c674df8abb..ba1f0e4dded 100644 --- a/dep/ACE_wrappers/ace/Free_List.h +++ b/dep/ACE_wrappers/ace/Free_List.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Free_List.h @@ -8,17 +9,23 @@ * @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 * @@ -32,17 +39,22 @@ 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 * @@ -71,50 +83,69 @@ public: 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 index e707388f9af..618adcf5a61 100644 --- a/dep/ACE_wrappers/ace/Functor.cpp +++ b/dep/ACE_wrappers/ace/Functor.cpp @@ -24,15 +24,21 @@ */ //============================================================================= + #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 index ba0a37c0281..d8f393c68b6 100644 --- a/dep/ACE_wrappers/ace/Functor.h +++ b/dep/ACE_wrappers/ace/Functor.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Functor.h @@ -26,19 +27,26 @@ */ //========================================================================== + #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 * @@ -55,8 +63,10 @@ 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 @@ -66,15 +76,18 @@ public: */ 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 * @@ -87,6 +100,7 @@ public: /// Simply returns t unsigned long operator () (char t) const; }; + /** * @class ACE_Hash * @@ -99,6 +113,7 @@ public: /// Simply returns t unsigned long operator () (signed char t) const; }; + /** * @class ACE_Hash * @@ -111,8 +126,10 @@ public: /// Simply returns t unsigned long operator () (unsigned char t) const; }; + #if 0 // @@ ADD HASHES FOR ACE TYPES + /** * @class ACE_Hash * @@ -125,6 +142,7 @@ public: /// Simply returns t unsigned long operator () (ACE_INT16 t) const; }; + /** * @class ACE_Hash * @@ -137,6 +155,7 @@ public: /// Simply returns t unsigned long operator () (ACE_UINT16 t) const; }; + /** * @class ACE_Hash * @@ -149,6 +168,7 @@ public: /// Simply returns t unsigned long operator () (ACE_INT32 t) const; }; + /** * @class ACE_Hash * @@ -161,6 +181,7 @@ public: /// Simply returns t unsigned long operator () (ACE_UINT32 t) const; }; + /** * @class ACE_Hash * @@ -173,8 +194,10 @@ public: /// Simply returns t unsigned long operator () (ACE_UINT64 t) const; }; + // @@ DONE ADDING HASHES FOR ACE TYPES #endif + /** * @class ACE_Hash * @@ -187,6 +210,7 @@ public: /// Simply returns t unsigned long operator () (short t) const; }; + /** * @class ACE_Hash * @@ -199,6 +223,7 @@ public: /// Simply returns t unsigned long operator () (unsigned short t) const; }; + /** * @class ACE_Hash * @@ -211,6 +236,7 @@ public: /// Simply returns t unsigned long operator () (int t) const; }; + /** * @class ACE_Hash * @@ -223,6 +249,7 @@ public: /// Simply returns t unsigned long operator () (unsigned int t) const; }; + /** * @class ACE_Hash * @@ -235,6 +262,7 @@ public: /// Simply returns t unsigned long operator () (long t) const; }; + /** * @class ACE_Hash * @@ -247,6 +275,7 @@ public: /// Simply returns t unsigned long operator () (unsigned long t) const; }; + #if !defined (ACE_LACKS_LONGLONG_T) && (ACE_SIZEOF_LONG < 8) /** * @class ACE_Hash @@ -261,6 +290,7 @@ public: 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) @@ -277,6 +307,7 @@ public: unsigned long operator () (const ACE_UINT64 &t) const; }; #endif /* ACE_SIZEOF_LONG < 8 */ + /** * @class ACE_Hash * @@ -289,6 +320,7 @@ public: /// Calls ACE::hash_pjw unsigned long operator () (const char *t) const; }; + /** * @class ACE_Hash * @@ -301,6 +333,7 @@ public: /// Calls ACE::hash_pjw unsigned long operator () (const char *t) const; }; + /** * @class ACE_Hash * @@ -312,6 +345,7 @@ class ACE_Export ACE_Hash public: unsigned long operator () (const void *) const; }; + /** * @class ACE_Equal_To * @@ -325,6 +359,7 @@ public: int operator () (const char *lhs, const char *rhs) const; }; + /** * @class ACE_Equal_To * @@ -339,6 +374,7 @@ public: int operator () (const char *lhs, const char *rhs) const; }; + /** * @class ACE_Equal_To * @@ -353,6 +389,7 @@ public: int operator () (const ACE_UINT16 lhs, const ACE_UINT16 rhs) const; }; + /** * @class ACE_Equal_To * @@ -367,6 +404,7 @@ public: int operator () (const ACE_INT16 lhs, const ACE_INT16 rhs) const; }; + /** * @class ACE_Equal_To * @@ -381,6 +419,7 @@ public: int operator () (const ACE_UINT32 lhs, const ACE_UINT32 rhs) const; }; + /** * @class ACE_Equal_To * @@ -395,6 +434,7 @@ public: int operator () (const ACE_INT32 lhs, const ACE_INT32 rhs) const; }; + /** * @class ACE_Equal_To * @@ -409,6 +449,7 @@ public: int operator () (const ACE_UINT64 lhs, const ACE_UINT64 rhs) const; }; + /** * @class ACE_Less_Than * @@ -423,6 +464,7 @@ public: int operator () (const char *lhs, const char *rhs) const; }; + /** * @class ACE_Less_Than * @@ -437,7 +479,9 @@ public: int operator () (const char *lhs, const char *rhs) const; }; + #if defined (ACE_HAS_WCHAR) + # if ! defined (ACE_LACKS_NATIVE_WCHAR_T) /** * @class ACE_Hash @@ -464,6 +508,7 @@ public: /// Calls ACE::hash_pjw unsigned long operator () (const wchar_t *t) const; }; + /** * @class ACE_Hash * @@ -476,6 +521,7 @@ public: /// Calls ACE::hash_pjw unsigned long operator () (const wchar_t *t) const; }; + /** * @class ACE_Equal_To * @@ -489,6 +535,7 @@ public: int operator () (const wchar_t *lhs, const wchar_t *rhs) const; }; + /** * @class ACE_Equal_To * @@ -503,6 +550,7 @@ public: int operator () (const wchar_t *lhs, const wchar_t *rhs) const; }; + /** * @class ACE_Less_Than * @@ -517,6 +565,7 @@ public: int operator () (const wchar_t *lhs, const wchar_t *rhs) const; }; + /** * @class ACE_Less_Than * @@ -531,11 +580,15 @@ public: 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 index 48e4875089b..30e539459a8 100644 --- a/dep/ACE_wrappers/ace/Functor.inl +++ b/dep/ACE_wrappers/ace/Functor.inl @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Functor.inl @@ -23,25 +24,33 @@ */ //============================================================================= + #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 @@ -49,37 +58,44 @@ 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 { @@ -90,36 +106,43 @@ ACE_Hash::operator () (ACE_UINT64 t) const #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 @@ -128,6 +151,7 @@ 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 @@ -139,101 +163,122 @@ ACE_Hash::operator () (const ACE_UINT64 &t) const #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 index 6a518a556a6..798c9d26286 100644 --- a/dep/ACE_wrappers/ace/Functor_String.cpp +++ b/dep/ACE_wrappers/ace/Functor_String.cpp @@ -1,6 +1,8 @@ #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 index 51a41cd1d7d..5fabef1f625 100644 --- a/dep/ACE_wrappers/ace/Functor_String.h +++ b/dep/ACE_wrappers/ace/Functor_String.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Functor_String.h @@ -15,22 +16,29 @@ #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 * @@ -45,6 +53,7 @@ public: const ACE_CString &rhs) const; }; + /** * @class ACE_Hash * @@ -58,6 +67,7 @@ public: unsigned long operator () (const ACE_CString &lhs) const; }; + /** * @class ACE_Less_Than * @@ -73,7 +83,9 @@ public: const ACE_CString &rhs) const; }; + #if defined (ACE_USES_WCHAR) + /** * @class ACE_Equal_To * @@ -88,6 +100,7 @@ public: const ACE_WString &rhs) const; }; + /** * @class ACE_Hash * @@ -100,6 +113,7 @@ public: /// Calls ACE::hash_pjw unsigned long operator () (const ACE_WString &lhs) const; }; + /** * @class ACE_Less_Than * @@ -114,11 +128,15 @@ public: 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 index 00dc758fce0..bdac96386f8 100644 --- a/dep/ACE_wrappers/ace/Functor_String.inl +++ b/dep/ACE_wrappers/ace/Functor_String.inl @@ -1,21 +1,26 @@ // -*- 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 @@ -23,6 +28,7 @@ ACE_Less_Than::operator () (const ACE_CString &lhs, return (lhs < rhs); } + #if defined (ACE_USES_WCHAR) ACE_INLINE unsigned long ACE_Hash::operator () (const ACE_WString &t) const @@ -30,17 +36,21 @@ 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.h b/dep/ACE_wrappers/ace/Functor_T.h index dad8bbe5582..4a3a621366c 100644 --- a/dep/ACE_wrappers/ace/Functor_T.h +++ b/dep/ACE_wrappers/ace/Functor_T.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Functor_T.h @@ -24,18 +25,25 @@ */ //============================================================================= + #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 * @@ -55,19 +63,25 @@ 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 * @@ -80,6 +94,7 @@ public: /// Simply calls t.hash () unsigned long operator () (const TYPE &t) const; }; + /** * @class ACE_Pointer_Hash * @@ -92,6 +107,7 @@ public: /// Simply returns t. unsigned long operator () (TYPE t) const; }; + /** * @class ACE_Equal_To * @@ -106,6 +122,7 @@ public: bool operator () (const TYPE &lhs, const TYPE &rhs) const; }; + /** * @class ACE_Less_Than * @@ -121,17 +138,22 @@ public: 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 index bcc1556fd9c..35cfed5b798 100644 --- a/dep/ACE_wrappers/ace/Functor_T.inl +++ b/dep/ACE_wrappers/ace/Functor_T.inl @@ -1,12 +1,15 @@ // -*- 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 { @@ -21,16 +24,19 @@ ACE_Pointer_Hash::operator () (TYPE t) const # 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.h b/dep/ACE_wrappers/ace/Future.h index 72de047756e..d86efd5a485 100644 --- a/dep/ACE_wrappers/ace/Future.h +++ b/dep/ACE_wrappers/ace/Future.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Future.h @@ -11,23 +12,32 @@ * @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 * @@ -39,12 +49,16 @@ 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 * @@ -61,15 +75,19 @@ 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 * @@ -87,6 +105,7 @@ 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 @@ -96,10 +115,12 @@ private: */ 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 @@ -110,6 +131,7 @@ private: */ 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 @@ -120,6 +142,7 @@ private: * 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 @@ -130,18 +153,25 @@ private: * 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 @@ -150,6 +180,7 @@ private: * 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. @@ -157,6 +188,7 @@ private: * 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. @@ -164,24 +196,37 @@ private: * 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 * @@ -196,20 +241,26 @@ 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 @@ -217,6 +268,7 @@ public: * 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. @@ -225,8 +277,10 @@ public: * 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. @@ -236,6 +290,7 @@ public: * effect. */ int set (const T &r); + /** * Wait to get the object's value. * @@ -250,6 +305,7 @@ public: */ 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 @@ -261,8 +317,10 @@ public: * 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 @@ -277,6 +335,7 @@ public: * @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 @@ -289,30 +348,41 @@ public: * 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.h b/dep/ACE_wrappers/ace/Future_Set.h index 76c31fd41aa..b41fc673986 100644 --- a/dep/ACE_wrappers/ace/Future_Set.h +++ b/dep/ACE_wrappers/ace/Future_Set.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Future_Set.h @@ -8,19 +9,25 @@ * @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 * @@ -38,10 +45,13 @@ 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. @@ -53,6 +63,7 @@ public: * 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. @@ -61,6 +72,7 @@ public: * 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 @@ -78,41 +90,57 @@ public: */ 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/Get_Opt.cpp b/dep/ACE_wrappers/ace/Get_Opt.cpp index 02b85b96abc..9725171701d 100644 --- a/dep/ACE_wrappers/ace/Get_Opt.cpp +++ b/dep/ACE_wrappers/ace/Get_Opt.cpp @@ -1,8 +1,11 @@ // $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" @@ -10,9 +13,11 @@ #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. @@ -45,6 +50,7 @@ ACE_RCSID (ace, * 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. @@ -80,8 +86,11 @@ ACE_RCSID (ace, * 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 @@ -110,8 +119,10 @@ ACE_Get_Opt::ACE_Get_Opt (int argc, #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) @@ -121,6 +132,7 @@ ACE_Get_Opt::ACE_Get_Opt (int argc, #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 @@ -149,9 +161,11 @@ ACE_Get_Opt::ACE_Get_Opt (int argc, } } } + 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; @@ -173,13 +187,16 @@ ACE_Get_Opt::~ACE_Get_Opt (void) 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_) { @@ -191,10 +208,12 @@ ACE_Get_Opt::nextchar_i (void) || 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; @@ -209,34 +228,42 @@ ACE_Get_Opt::nextchar_i (void) 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. @@ -251,6 +278,7 @@ ACE_Get_Opt::long_option_i (void) } } } + if ((hits > 1) && !exact) { // Great, we found a match, but unfortunately we found more than @@ -263,6 +291,7 @@ ACE_Get_Opt::long_option_i (void) this->optind++; return '?'; } + if (pfound != 0) { // Okay, we found a good one (either a single hit or an exact match). @@ -334,20 +363,25 @@ ACE_Get_Opt::long_option_i (void) } 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) @@ -406,19 +440,23 @@ ACE_Get_Opt::short_option_i (void) } 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') @@ -427,11 +465,14 @@ ACE_Get_Opt::operator () (void) 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) @@ -439,12 +480,14 @@ ACE_Get_Opt::long_option (const ACE_TCHAR *name, 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 @@ -511,10 +554,13 @@ ACE_Get_Opt::long_option (const ACE_TCHAR *name, *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 @@ -527,6 +573,7 @@ ACE_Get_Opt::long_option (const ACE_TCHAR *name, } return 0; } + const ACE_TCHAR* ACE_Get_Opt::long_option (void) const { @@ -535,21 +582,25 @@ ACE_Get_Opt::long_option (void) const 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") @@ -566,6 +617,7 @@ ACE_Get_Opt::dump (void) const 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) @@ -581,19 +633,24 @@ ACE_Get_Opt::dump (void) const 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; @@ -605,36 +662,46 @@ ACE_Get_Opt::permute_args (void) 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_) @@ -643,11 +710,13 @@ ACE_Get_Opt::permute (void) } 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, @@ -656,9 +725,11 @@ ACE_Get_Opt::ACE_Get_Opt_Long_Option::ACE_Get_Opt_Long_Option ( 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 index 70555e5530a..e00518954e6 100644 --- a/dep/ACE_wrappers/ace/Get_Opt.h +++ b/dep/ACE_wrappers/ace/Get_Opt.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Get_Opt.h @@ -9,22 +10,29 @@ * @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 * @@ -32,6 +40,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * This is a C++ wrapper for getopt(3c) and getopt_long(3c). */ + class ACE_Export ACE_Get_Opt { public: @@ -45,6 +54,7 @@ public: * 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 @@ -54,6 +64,7 @@ public: * 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' @@ -61,18 +72,22 @@ public: */ 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. @@ -162,6 +177,7 @@ public: int report_errors = 0, int ordering = PERMUTE_ARGS, int long_only = 0); + #else private: void ACE_Get_Opt_Init (const ACE_TCHAR *optstring); @@ -183,6 +199,7 @@ public: #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 @@ -220,12 +237,14 @@ public: * 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 @@ -233,6 +252,7 @@ public: * 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 @@ -246,6 +266,7 @@ public: * 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. @@ -259,6 +280,7 @@ public: */ 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. @@ -276,29 +298,37 @@ public: 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. @@ -307,6 +337,7 @@ public: * @c argc() accessor method instead. */ int argc_; + /// Holds the @a argv pointer. /** * @deprecated This is public for backwards compatibility only. @@ -315,6 +346,7 @@ public: * @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. @@ -323,6 +355,7 @@ public: * @c opt_ind() accessor method instead. */ int optind; + /// Callers store zero here to inhibit the error message for /// unrecognized options. /** @@ -332,6 +365,7 @@ public: * @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(). /** @@ -341,6 +375,7 @@ public: * @c opt_arg() accessor method instead. */ ACE_TCHAR *optarg; + private: /** * @class ACE_Get_Opt_Long_Option This class is for internal use @@ -353,13 +388,18 @@ private: 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 @@ -368,35 +408,48 @@ private: /// 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 @@ -405,27 +458,38 @@ private: * 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 index f8f499f4177..e307fb5e400 100644 --- a/dep/ACE_wrappers/ace/Get_Opt.inl +++ b/dep/ACE_wrappers/ace/Get_Opt.inl @@ -1,37 +1,45 @@ // -*- 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, @@ -58,6 +66,7 @@ ACE_INLINE ACE_Get_Opt::ACE_Get_Opt (int argc, { ACE_Get_Opt_Init (optstring); } + ACE_INLINE ACE_Get_Opt::ACE_Get_Opt (int argc, ACE_TCHAR **argv, const char *optstring, @@ -84,4 +93,5 @@ ACE_INLINE ACE_Get_Opt::ACE_Get_Opt (int argc, 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 index cad219c8e96..12f6a2465c6 100644 --- a/dep/ACE_wrappers/ace/Global_Macros.h +++ b/dep/ACE_wrappers/ace/Global_Macros.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Global_Macros.h @@ -12,34 +13,45 @@ * 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: @@ -50,8 +62,10 @@ public: 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 @@ -59,12 +73,16 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) @@ -74,15 +92,18 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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. @@ -92,7 +113,9 @@ ACE_END_VERSIONED_NAMESPACE_DECL 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) @@ -111,13 +134,16 @@ ACE_END_VERSIONED_NAMESPACE_DECL #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. @@ -135,7 +161,9 @@ ACE_END_VERSIONED_NAMESPACE_DECL #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) \ @@ -160,7 +188,9 @@ ACE_END_VERSIONED_NAMESPACE_DECL # 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) \ @@ -169,6 +199,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL } \ } \ while (0) + # define ACE_DES_ARRAY_NOFREE(POINTER,SIZE,CLASS) \ do { \ if (POINTER) \ @@ -182,6 +213,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL } \ } \ while (0) + # define ACE_DES_FREE(POINTER,DEALLOCATOR,CLASS) \ do { \ if (POINTER) \ @@ -191,6 +223,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL } \ } \ while (0) + # define ACE_DES_ARRAY_FREE(POINTER,SIZE,DEALLOCATOR,CLASS) \ do { \ if (POINTER) \ @@ -205,6 +238,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL } \ } \ while (0) + # if defined (ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR) # define ACE_DES_NOFREE_TEMPLATE(POINTER,T_CLASS,T_PARAMETER) \ do { \ @@ -227,6 +261,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL } \ } \ while (0) + #if defined (ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) # define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \ do { \ @@ -427,11 +462,14 @@ ACE_END_VERSIONED_NAMESPACE_DECL 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 @@ -464,6 +502,7 @@ typedef void (*ACE_Service_Object_Exterminator)(void *); */ # 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. /** @@ -484,6 +523,7 @@ extern ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS ; */ #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. /** @@ -516,6 +556,7 @@ extern EXPORT_NAME##_Export ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLA */ # 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 @@ -544,7 +585,9 @@ public:\ }; #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:\ @@ -555,13 +598,16 @@ public:\ };\ 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 @@ -571,9 +617,11 @@ static ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##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. /** @@ -593,6 +641,7 @@ static ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS; # 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. /** @@ -608,6 +657,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC * 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 @@ -643,6 +693,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC 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 @@ -704,12 +755,16 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC 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 @@ -720,6 +775,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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) @@ -782,10 +838,13 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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; } \ @@ -798,6 +857,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC 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;} \ @@ -813,6 +873,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC 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) \ @@ -841,6 +902,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC 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) @@ -850,7 +912,9 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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) @@ -860,39 +924,48 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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 @@ -900,33 +973,41 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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 @@ -934,7 +1015,9 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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 @@ -946,27 +1029,32 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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 @@ -974,33 +1062,41 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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 @@ -1009,6 +1105,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # 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 @@ -1018,6 +1115,8 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC #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.h b/dep/ACE_wrappers/ace/Guard_T.h index 7bf491bb69a..a70bdda713a 100644 --- a/dep/ACE_wrappers/ace/Guard_T.h +++ b/dep/ACE_wrappers/ace/Guard_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Guard_T.h @@ -10,16 +11,22 @@ * @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 * @@ -35,52 +42,71 @@ 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 * @@ -94,26 +120,37 @@ 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 * @@ -127,33 +164,47 @@ 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 * @@ -167,39 +218,54 @@ 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 * @@ -213,23 +279,33 @@ 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 * @@ -245,34 +321,46 @@ 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 index 1395dd38565..5fb22b3bac7 100644 --- a/dep/ACE_wrappers/ace/Guard_T.inl +++ b/dep/ACE_wrappers/ace/Guard_T.inl @@ -1,18 +1,23 @@ // -*- 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) { @@ -24,6 +29,7 @@ ACE_Guard::release (void) return this->lock_->release (); } } + template ACE_INLINE ACE_Guard::ACE_Guard (ACE_LOCK &l) : lock_ (&l), @@ -31,6 +37,7 @@ ACE_Guard::ACE_Guard (ACE_LOCK &l) { this->acquire (); } + template ACE_INLINE ACE_Guard::ACE_Guard (ACE_LOCK &l, bool block) : lock_ (&l), @@ -41,60 +48,72 @@ ACE_Guard::ACE_Guard (ACE_LOCK &l, bool block) 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) @@ -105,32 +124,38 @@ ACE_Write_Guard::ACE_Write_Guard (ACE_LOCK &m, 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) @@ -141,4 +166,5 @@ ACE_Read_Guard::ACE_Read_Guard (ACE_LOCK &m, 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 index b5fb77a81e5..9e9805a676f 100644 --- a/dep/ACE_wrappers/ace/Handle_Gobbler.h +++ b/dep/ACE_wrappers/ace/Handle_Gobbler.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Handle_Gobbler.h @@ -10,14 +11,19 @@ */ //============================================================================= + #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 * @@ -30,25 +36,34 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 index 1d00c04325a..4b81218e6de 100644 --- a/dep/ACE_wrappers/ace/Handle_Gobbler.inl +++ b/dep/ACE_wrappers/ace/Handle_Gobbler.inl @@ -1,12 +1,16 @@ // -*- 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) { @@ -14,11 +18,13 @@ ACE_Handle_Gobbler::close_remaining_handles (void) 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) { @@ -27,19 +33,25 @@ ACE_Handle_Gobbler::free_handles (size_t n_handles) 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)) @@ -57,7 +69,10 @@ ACE_Handle_Gobbler::consume_handles (size_t n_handles_to_keep_available) 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 index b722edeb02d..213fa933d7a 100644 --- a/dep/ACE_wrappers/ace/Handle_Ops.cpp +++ b/dep/ACE_wrappers/ace/Handle_Ops.cpp @@ -1,13 +1,18 @@ // $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, @@ -16,6 +21,7 @@ ACE::handle_timed_open (ACE_Time_Value *timeout, LPSECURITY_ATTRIBUTES sa) { ACE_TRACE ("ACE::handle_timed_open"); + if (timeout != 0) { #if !defined (ACE_WIN32) @@ -23,17 +29,21 @@ ACE::handle_timed_open (ACE_Time_Value *timeout, // 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 index 771b7a179c0..16ee852725d 100644 --- a/dep/ACE_wrappers/ace/Handle_Ops.h +++ b/dep/ACE_wrappers/ace/Handle_Ops.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Handle_Ops.h @@ -8,16 +9,24 @@ * 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 { @@ -33,7 +42,10 @@ namespace ACE 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 index 4802c3c6406..288d0010169 100644 --- a/dep/ACE_wrappers/ace/Handle_Set.cpp +++ b/dep/ACE_wrappers/ace/Handle_Set.cpp @@ -1,13 +1,20 @@ // 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) @@ -16,25 +23,31 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set) #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])); @@ -43,10 +56,12 @@ ACE_Handle_Set::dump (void) const 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, // @@ -58,6 +73,7 @@ ACE_Handle_Set::dump (void) const // // 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, @@ -76,12 +92,15 @@ const char ACE_Handle_Set::nbits_[256] = 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"); @@ -96,20 +115,26 @@ ACE_Handle_Set::ACE_Handle_Set (const fd_set &fd_mask) #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] @@ -118,26 +143,32 @@ ACE_Handle_Set::count_bits (u_long n) + 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) { @@ -147,7 +178,9 @@ ACE_Handle_Set::bitpos (u_long bit) 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. @@ -159,6 +192,7 @@ ACE_Handle_Set::bitpos (u_long bit) #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) { @@ -166,27 +200,33 @@ ACE_Handle_Set::sync (ACE_HANDLE max) #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--) @@ -210,6 +250,7 @@ ACE_Handle_Set::set_max (ACE_HANDLE current_max) + 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; @@ -217,12 +258,15 @@ ACE_Handle_Set::set_max (ACE_HANDLE current_max) 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_)); @@ -234,6 +278,7 @@ ACE_Handle_Set_Iterator::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ } + ACE_HANDLE ACE_Handle_Set_Iterator::operator () (void) { @@ -244,9 +289,11 @@ ACE_Handle_Set_Iterator::operator () (void) 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, @@ -258,6 +305,7 @@ ACE_Handle_Set_Iterator::operator () (void) // 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. @@ -265,6 +313,7 @@ ACE_Handle_Set_Iterator::operator () (void) else { ACE_HANDLE result = this->handle_index_; + // Increment the iterator and advance to the next bit in this // word. this->handle_index_++; @@ -274,18 +323,22 @@ ACE_Handle_Set_Iterator::operator () (void) # 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 @@ -300,10 +353,12 @@ ACE_Handle_Set_Iterator::operator () (void) // 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 (; @@ -316,11 +371,13 @@ ACE_Handle_Set_Iterator::operator () (void) 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 @@ -328,19 +385,26 @@ ACE_Handle_Set_Iterator::operator () (void) // 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_++; @@ -349,9 +413,12 @@ ACE_Handle_Set_Iterator::operator () (void) { // 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 { @@ -359,11 +426,14 @@ ACE_Handle_Set_Iterator::operator () (void) 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) @@ -381,13 +451,16 @@ ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs) // 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 @@ -426,10 +499,12 @@ ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs) #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; @@ -439,17 +514,21 @@ ACE_Handle_Set_Iterator::reset_state (void) 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 @@ -487,5 +566,6 @@ ACE_Handle_Set_Iterator::reset_state (void) } #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 index 148316f8445..6e33055b4f6 100644 --- a/dep/ACE_wrappers/ace/Handle_Set.h +++ b/dep/ACE_wrappers/ace/Handle_Set.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Handle_Set.h @@ -8,28 +9,37 @@ * @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 * @@ -44,37 +54,48 @@ 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. @@ -83,31 +104,41 @@ public: * 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 /// or other calls that may have @@ -64,33 +79,46 @@ public: * 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 @@ -103,6 +131,7 @@ public: * 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 @@ -113,6 +142,7 @@ public: * 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 @@ -123,6 +153,7 @@ public: * 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 @@ -130,6 +161,7 @@ public: * 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 @@ -137,17 +169,23 @@ public: * 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. @@ -156,8 +194,10 @@ public: * 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. @@ -166,26 +206,36 @@ public: * 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 @@ -193,61 +243,76 @@ public: 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 @@ -256,6 +321,7 @@ public: * 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) @@ -264,9 +330,11 @@ public: 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 @@ -286,13 +354,17 @@ private: 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 @@ -302,6 +374,8 @@ 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 index 908bae22640..27433389323 100644 --- a/dep/ACE_wrappers/ace/Time_Value.inl +++ b/dep/ACE_wrappers/ace/Time_Value.inl @@ -1,8 +1,11 @@ // -*- 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 @@ -12,7 +15,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // - 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 { @@ -27,20 +32,24 @@ ACE_Time_Value::operator timeval () const 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 { @@ -55,6 +64,7 @@ ACE_Time_Value::operator const timeval * () const 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) { @@ -69,6 +79,7 @@ ACE_Time_Value::set (time_t sec, suseconds_t usec) #endif this->normalize (); } + ACE_INLINE void ACE_Time_Value::set (double d) { @@ -78,16 +89,20 @@ ACE_Time_Value::set (double d) 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_ () @@ -95,37 +110,46 @@ ACE_Time_Value::ACE_Time_Value (void) // 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 { @@ -134,6 +158,7 @@ ACE_Time_Value::msec (ACE_UINT64 &ms) const ms *= 1000; ms += (this->tv_.tv_usec / 1000); } + ACE_INLINE void ACE_Time_Value::msec (ACE_UINT64 &ms) /*const*/ { @@ -141,7 +166,9 @@ ACE_Time_Value::msec (ACE_UINT64 &ms) /*const*/ 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) { @@ -152,30 +179,38 @@ ACE_Time_Value::msec (long milliseconds) // 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) @@ -187,17 +222,21 @@ ACE_Time_Value::to_usec (ACE_UINT64 & usec) const 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) @@ -211,7 +250,9 @@ operator > (const ACE_Time_Value &tv1, else return 0; } + // True if tv1 >= tv2. + ACE_INLINE bool operator >= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) @@ -225,7 +266,9 @@ operator >= (const ACE_Time_Value &tv1, else return 0; } + // Returns the value of the object as a timespec_t. + ACE_INLINE ACE_Time_Value::operator timespec_t () const { @@ -236,7 +279,9 @@ ACE_Time_Value::operator timespec_t () const 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_ () @@ -244,7 +289,9 @@ ACE_Time_Value::ACE_Time_Value (const timespec_t &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) @@ -252,7 +299,9 @@ operator < (const ACE_Time_Value &tv1, // 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) @@ -260,7 +309,9 @@ operator <= (const ACE_Time_Value &tv1, // 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) @@ -269,7 +320,9 @@ operator == (const ACE_Time_Value &tv1, 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) @@ -277,7 +330,9 @@ operator != (const ACE_Time_Value &tv1, // 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) { @@ -287,6 +342,7 @@ ACE_Time_Value::operator+= (const ACE_Time_Value &tv) this->normalize (); return *this; } + ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator+= (time_t tv) { @@ -294,6 +350,7 @@ ACE_Time_Value::operator+= (time_t tv) this->sec (this->sec () + tv); return *this; } + ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator= (const ACE_Time_Value &tv) { @@ -302,6 +359,7 @@ ACE_Time_Value::operator= (const ACE_Time_Value &tv) this->usec (tv.usec ()); return *this; } + ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator= (time_t tv) { @@ -310,7 +368,9 @@ ACE_Time_Value::operator= (time_t tv) this->usec (0); return *this; } + // Subtract TV to this. + ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator-= (const ACE_Time_Value &tv) { @@ -320,6 +380,7 @@ ACE_Time_Value::operator-= (const ACE_Time_Value &tv) this->normalize (); return *this; } + ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator-= (time_t tv) { @@ -327,7 +388,9 @@ ACE_Time_Value::operator-= (time_t tv) 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) @@ -335,9 +398,12 @@ operator + (const ACE_Time_Value &tv1, // 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) @@ -345,9 +411,12 @@ operator - (const ACE_Time_Value &tv1, // 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 index 0d514fafc04..b92960415cf 100644 --- a/dep/ACE_wrappers/ace/Timeprobe.cpp +++ b/dep/ACE_wrappers/ace/Timeprobe.cpp @@ -1,10 +1,16 @@ // $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 index f70a80121b8..4ec811e6317 100644 --- a/dep/ACE_wrappers/ace/Timeprobe.h +++ b/dep/ACE_wrappers/ace/Timeprobe.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timeprobe.h @@ -33,25 +34,33 @@ * 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 * @@ -62,11 +71,14 @@ 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 * @@ -81,30 +93,40 @@ public: 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. @@ -113,13 +135,17 @@ 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 @@ -127,35 +153,49 @@ typedef ACE_Timeprobe_Ex # 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 index 27f75376273..aa7a9240648 100644 --- a/dep/ACE_wrappers/ace/Timeprobe.inl +++ b/dep/ACE_wrappers/ace/Timeprobe.inl @@ -1,11 +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.h b/dep/ACE_wrappers/ace/Timeprobe_T.h index 0c9c2adf3e7..c180f7d7a72 100644 --- a/dep/ACE_wrappers/ace/Timeprobe_T.h +++ b/dep/ACE_wrappers/ace/Timeprobe_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timeprobe_T.h @@ -9,16 +10,23 @@ */ //============================================================================= + #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 * @@ -53,91 +61,126 @@ 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 * @@ -150,21 +193,28 @@ 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 index f13f2b0dd2e..c19291efaf7 100644 --- a/dep/ACE_wrappers/ace/Timer_Hash.h +++ b/dep/ACE_wrappers/ace/Timer_Hash.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Timer_Hash.h @@ -9,51 +10,67 @@ */ //============================================================================= + #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.h b/dep/ACE_wrappers/ace/Timer_Hash_T.h index 63161031528..882369cf5c9 100644 --- a/dep/ACE_wrappers/ace/Timer_Hash_T.h +++ b/dep/ACE_wrappers/ace/Timer_Hash_T.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Timer_Hash_T.h @@ -8,20 +9,27 @@ * @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 * @@ -38,15 +46,19 @@ public: ACE_Timer_Hash_Upcall, 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, @@ -54,12 +66,14 @@ public: 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, @@ -67,28 +81,34 @@ public: 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 * @@ -104,22 +124,30 @@ class ACE_Timer_Hash_Iterator_T : public ACE_Timer_Queue_Iterator_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 * @@ -137,10 +165,13 @@ 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 @@ -151,6 +182,7 @@ public: 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 @@ -159,13 +191,17 @@ public: * 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 @@ -175,6 +211,7 @@ public: */ 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 @@ -184,6 +221,7 @@ public: */ 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 @@ -198,30 +236,39 @@ public: 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 @@ -237,44 +284,60 @@ private: 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 index 668f6f04735..61673974068 100644 --- a/dep/ACE_wrappers/ace/Timer_Heap.h +++ b/dep/ACE_wrappers/ace/Timer_Heap.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Timer_Heap.h @@ -8,25 +9,34 @@ * @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.h b/dep/ACE_wrappers/ace/Timer_Heap_T.h index c56584c3339..904e596e616 100644 --- a/dep/ACE_wrappers/ace/Timer_Heap_T.h +++ b/dep/ACE_wrappers/ace/Timer_Heap_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timer_Heap_T.h @@ -8,19 +9,26 @@ * @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 * @@ -36,22 +44,30 @@ class ACE_Timer_Heap_Iterator_T : public ACE_Timer_Queue_Iterator_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 * @@ -72,7 +88,9 @@ 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. @@ -92,6 +110,7 @@ public: 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 @@ -101,13 +120,17 @@ public: */ 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 @@ -117,6 +140,7 @@ public: */ 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 @@ -124,6 +148,7 @@ public: */ 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 @@ -136,8 +161,10 @@ public: 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 @@ -147,11 +174,15 @@ public: * 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, @@ -172,40 +203,50 @@ protected: 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 @@ -213,19 +254,26 @@ private: * 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 @@ -233,6 +281,7 @@ private: * 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, @@ -244,13 +293,16 @@ private: * "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 @@ -258,23 +310,30 @@ private: * 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 index 09d21e9fcc5..847eac1a1e9 100644 --- a/dep/ACE_wrappers/ace/Timer_List.h +++ b/dep/ACE_wrappers/ace/Timer_List.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timer_List.h @@ -9,25 +10,34 @@ */ //============================================================================= + #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.h b/dep/ACE_wrappers/ace/Timer_List_T.h index 4048d37f00a..66d148f81eb 100644 --- a/dep/ACE_wrappers/ace/Timer_List_T.h +++ b/dep/ACE_wrappers/ace/Timer_List_T.h @@ -1,4 +1,5 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Timer_List_T.h @@ -8,16 +9,21 @@ * @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 * @@ -34,22 +40,30 @@ 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 * @@ -73,12 +87,15 @@ 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 @@ -87,13 +104,17 @@ public: * 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 @@ -103,6 +124,7 @@ public: */ 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 @@ -110,6 +132,7 @@ public: */ 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 @@ -122,18 +145,25 @@ public: 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 @@ -153,32 +183,45 @@ private: 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 index 6c6b87fb688..0f5990ae546 100644 --- a/dep/ACE_wrappers/ace/Timer_Queue.h +++ b/dep/ACE_wrappers/ace/Timer_Queue.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timer_Queue.h @@ -9,13 +10,18 @@ * @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) @@ -23,18 +29,25 @@ #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.h b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.h index f6d08e55730..390aed19da0 100644 --- a/dep/ACE_wrappers/ace/Timer_Queue_Adapters.h +++ b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timer_Queue_Adapters.h @@ -9,24 +10,32 @@ * 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 * @@ -45,6 +54,7 @@ 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 @@ -52,6 +62,7 @@ public: * 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. /** @@ -63,28 +74,37 @@ public: 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 * @@ -105,39 +125,53 @@ 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 @@ -154,7 +188,9 @@ public: 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 @@ -164,47 +200,63 @@ public: */ 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 index c44347e989a..77011eacf8b 100644 --- a/dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl +++ b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl @@ -1,12 +1,15 @@ // -*- 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) { @@ -16,9 +19,11 @@ ACE_Thread_Timer_Queue_Adapter::timer_queue (TQ *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.h b/dep/ACE_wrappers/ace/Timer_Queue_T.h index 2d11fc8072f..8e5478b3245 100644 --- a/dep/ACE_wrappers/ace/Timer_Queue_T.h +++ b/dep/ACE_wrappers/ace/Timer_Queue_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timer_Queue_T.h @@ -10,16 +11,22 @@ * @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 * @@ -32,11 +39,14 @@ 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 * @@ -48,10 +58,13 @@ 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, @@ -59,6 +72,7 @@ public: 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, @@ -67,60 +81,85 @@ public: 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 * @@ -138,17 +177,23 @@ 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 * @@ -164,6 +209,7 @@ 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 @@ -173,14 +219,18 @@ public: */ 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 @@ -200,6 +250,7 @@ public: 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 @@ -209,6 +260,7 @@ public: */ 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, @@ -217,6 +269,7 @@ public: */ 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 @@ -230,12 +283,14 @@ public: 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 @@ -244,6 +299,7 @@ public: */ 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 . @@ -280,20 +336,25 @@ public: * * 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. @@ -306,73 +367,102 @@ public: */ 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 * @@ -389,15 +479,19 @@ public: ACE_Event_Handler_Handle_Timeout_Upcall, 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, @@ -405,12 +499,14 @@ public: 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, @@ -418,39 +514,50 @@ public: 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 index a62ab8e9d35..7606a2e1f62 100644 --- a/dep/ACE_wrappers/ace/Timer_Queue_T.inl +++ b/dep/ACE_wrappers/ace/Timer_Queue_T.inl @@ -1,7 +1,9 @@ // -*- 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, @@ -17,6 +19,7 @@ ACE_Timer_Node_T::set (const TYPE &type, this->next_ = n; this->timer_id_ = timer_id; } + template ACE_INLINE void ACE_Timer_Node_T::set (const TYPE &type, const void *a, @@ -34,76 +37,91 @@ ACE_Timer_Node_T::set (const TYPE &type, 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) { @@ -113,16 +131,19 @@ ACE_Timer_Node_T::get_dispatch_info (ACE_Timer_Node_Dispatch_Info_T 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) { @@ -131,14 +152,17 @@ ACE_Timer_Queue_T::expire (void) 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) @@ -149,6 +173,7 @@ ACE_Timer_Queue_T::upcall (ACE_Timer_Node_Dispatch_Info 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, @@ -161,6 +186,7 @@ ACE_Timer_Queue_T::preinvoke (ACE_Timer_Node_Dispatch_I 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, @@ -173,20 +199,24 @@ ACE_Timer_Queue_T::postinvoke (ACE_Timer_Node_Dispatch_ 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 index 70cd3af4674..5ee99ff1823 100644 --- a/dep/ACE_wrappers/ace/Timer_Queuefwd.h +++ b/dep/ACE_wrappers/ace/Timer_Queuefwd.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timer_Queuefwd.h @@ -10,19 +11,29 @@ * @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 index 68fd94065fb..888dc4a4470 100644 --- a/dep/ACE_wrappers/ace/Timer_Wheel.h +++ b/dep/ACE_wrappers/ace/Timer_Wheel.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timer_Wheel.h @@ -9,25 +10,34 @@ */ //============================================================================= + #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.h b/dep/ACE_wrappers/ace/Timer_Wheel_T.h index 5cedf75ebe6..7222837011b 100644 --- a/dep/ACE_wrappers/ace/Timer_Wheel_T.h +++ b/dep/ACE_wrappers/ace/Timer_Wheel_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Timer_Wheel_T.h @@ -8,17 +9,23 @@ * @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 * @@ -35,28 +42,38 @@ class ACE_Timer_Wheel_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 * @@ -83,58 +100,75 @@ public: /// 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; @@ -149,8 +183,10 @@ private: 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. @@ -169,18 +205,23 @@ private: 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 index 89ad0599128..99686563f67 100644 --- a/dep/ACE_wrappers/ace/Token.cpp +++ b/dep/ACE_wrappers/ace/Token.cpp @@ -1,24 +1,35 @@ // $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_)); @@ -29,6 +40,7 @@ ACE_Token::dump (void) const 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), @@ -43,8 +55,10 @@ ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry (ACE_Thread_Mutex &m, #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) @@ -61,14 +75,17 @@ ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry (ACE_Thread_Mutex &m, 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. // @@ -78,12 +95,15 @@ ACE_Token::ACE_Token_Queue::remove_entry (ACE_Token::ACE_Token_Queue_Entry *entr 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; @@ -93,11 +113,13 @@ ACE_Token::ACE_Token_Queue::remove_entry (ACE_Token::ACE_Token_Queue_Entry *entr 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. // @@ -127,15 +149,20 @@ ACE_Token::ACE_Token_Queue::insert_entry (ACE_Token::ACE_Token_Queue_Entry &entr // 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), @@ -147,10 +174,12 @@ ACE_Token::ACE_Token (const ACE_TCHAR *name, void *any) { // 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, @@ -159,10 +188,13 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), { 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_) { @@ -171,28 +203,34 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), 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_, @@ -200,6 +238,7 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), 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?) @@ -215,41 +254,50 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), 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) { @@ -259,6 +307,7 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), // Wakeup next waiter since this thread timed out. this->wakeup_next_waiter (); } + // Return error. return -1; } @@ -267,25 +316,32 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), // 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, @@ -294,79 +350,100 @@ ACE_Token::acquire (void (*sleep_hook_func)(void *), 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) { @@ -376,6 +453,7 @@ ACE_Token::renew (int requeue_position, // Wakeup next waiter since this thread timed out. this->wakeup_next_waiter (); } + // Return error. return -1; } @@ -384,22 +462,29 @@ ACE_Token::renew (int requeue_position, // 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_; @@ -408,18 +493,23 @@ ACE_Token::release (void) // // 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) @@ -427,8 +517,10 @@ ACE_Token::wakeup_next_waiter (void) // No more waiters... return; } + // Wakeup next waiter. ACE_Token_Queue *queue = 0; + // Writer threads get priority to run first. if (this->writers_.head_ != 0) { @@ -440,11 +532,15 @@ ACE_Token::wakeup_next_waiter (void) 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 index 2368f264cde..e98e5f9a774 100644 --- a/dep/ACE_wrappers/ace/Token.h +++ b/dep/ACE_wrappers/ace/Token.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Token.h @@ -11,26 +12,38 @@ * @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 * @@ -63,6 +76,7 @@ class ACE_Time_Value; class ACE_Export ACE_Token { public: + /** * Available queueing strategies. */ @@ -73,17 +87,25 @@ public: /// 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 @@ -101,18 +123,21 @@ public: 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 @@ -133,19 +158,24 @@ public: */ 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 @@ -153,28 +183,39 @@ public: 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 @@ -182,18 +223,24 @@ public: /// 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_; @@ -201,59 +248,81 @@ public: /// 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: @@ -264,9 +333,13 @@ public: 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: @@ -276,21 +349,29 @@ public: 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 index 922ac3c3e43..f09a0e6f3de 100644 --- a/dep/ACE_wrappers/ace/Token.inl +++ b/dep/ACE_wrappers/ace/Token.inl @@ -1,21 +1,28 @@ // -*- 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) { @@ -23,6 +30,7 @@ ACE_Token::remove (void) // Don't have an implementation for this yet... ACE_NOTSUP_RETURN (-1); } + ACE_INLINE int ACE_Token::tryacquire (void) { @@ -30,21 +38,26 @@ ACE_Token::tryacquire (void) 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) { @@ -52,6 +65,7 @@ ACE_Token::acquire_read (void) return this->shared_acquire (0, 0, 0, ACE_Token::READ_TOKEN); } + ACE_INLINE int ACE_Token::acquire_write (void) { @@ -59,6 +73,7 @@ ACE_Token::acquire_write (void) return this->shared_acquire (0, 0, 0, ACE_Token::WRITE_TOKEN); } + ACE_INLINE int ACE_Token::tryacquire_read (void) { @@ -66,6 +81,7 @@ ACE_Token::tryacquire_read (void) 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, @@ -74,6 +90,7 @@ ACE_Token::acquire_read (void (*sleep_hook_func)(void *), 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) { @@ -81,12 +98,14 @@ ACE_Token::tryacquire_write (void) 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, @@ -95,6 +114,7 @@ ACE_Token::acquire_write (void (*sleep_hook_func)(void *), 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) { @@ -110,6 +130,7 @@ ACE_Token::ACE_Token_Queue_Entry::wait (ACE_Time_Value *timeout, ACE_Thread_Mute return this->cv_.wait (timeout); #endif /* ACE_TOKEN_USES_SEMAPHORE */ } + ACE_INLINE int ACE_Token::ACE_Token_Queue_Entry::signal (void) { @@ -120,27 +141,36 @@ ACE_Token::ACE_Token_Queue_Entry::signal (void) 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 index 7e14d4742a3..e9c4964f19e 100644 --- a/dep/ACE_wrappers/ace/Token_Collection.cpp +++ b/dep/ACE_wrappers/ace/Token_Collection.cpp @@ -1,39 +1,52 @@ #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) { @@ -41,6 +54,7 @@ ACE_Token_Collection::extract (const ACE_TCHAR *token_name, ACE_Token_Proxy *&pr TOKEN_NAME name (token_name); return collection_.unbind (token_name, proxy); } + ACE_Token_Proxy * ACE_Token_Collection::is_member (const ACE_TCHAR *token_name) { @@ -50,6 +64,7 @@ ACE_Token_Collection::is_member (const ACE_TCHAR *token_name) // 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) { @@ -57,13 +72,16 @@ ACE_Token_Collection::is_member (const ACE_Token_Proxy &token) 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 ()) @@ -82,8 +100,10 @@ ACE_Token_Collection::acquire (int notify, ACE_RETURN (-1); } } + return 0; } + int ACE_Token_Collection::acquire (const ACE_TCHAR *token_name, int notify, @@ -102,6 +122,7 @@ ACE_Token_Collection::acquire (const ACE_TCHAR *token_name, return temp->acquire (notify, sleep_hook, options); } + int ACE_Token_Collection::tryacquire (const ACE_TCHAR *token_name, void (*sleep_hook)(void *)) @@ -114,14 +135,18 @@ ACE_Token_Collection::tryacquire (const ACE_TCHAR *token_name, // 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 ()) @@ -133,14 +158,18 @@ ACE_Token_Collection::tryacquire (void (*sleep_hook)(void *)) 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 ()) @@ -151,8 +180,10 @@ ACE_Token_Collection::renew (int requeue_position, 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, @@ -161,8 +192,10 @@ ACE_Token_Collection::renew (const ACE_TCHAR *token_name, 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"), @@ -171,11 +204,14 @@ ACE_Token_Collection::renew (const ACE_TCHAR *token_name, // 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 ()) @@ -185,8 +221,10 @@ ACE_Token_Collection::release (ACE_Synch_Options &) temp->int_id_->name ())); temp->int_id_->release (); } + return 0; } + int ACE_Token_Collection::release (const ACE_TCHAR *token_name, ACE_Synch_Options &options) @@ -202,10 +240,12 @@ ACE_Token_Collection::release (const ACE_TCHAR *token_name, // 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 ()) @@ -216,6 +256,7 @@ ACE_Token_Collection::~ACE_Token_Collection (void) } } + // This method doesn't mean anything for a collection. ACE_Token_Proxy * ACE_Token_Collection::clone (void) const @@ -223,6 +264,7 @@ 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 *) @@ -230,6 +272,7 @@ 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 { @@ -245,6 +288,8 @@ ACE_Token_Collection::dump (void) const 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 index cd8fcc7c8bf..6dad64ac6f0 100644 --- a/dep/ACE_wrappers/ace/Token_Collection.h +++ b/dep/ACE_wrappers/ace/Token_Collection.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Token_Collection.h @@ -18,17 +19,24 @@ * @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 * @@ -60,7 +68,9 @@ public: */ 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 @@ -74,6 +84,7 @@ public: * 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 @@ -82,15 +93,19 @@ public: * 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 @@ -101,6 +116,7 @@ public: // 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 @@ -119,6 +135,7 @@ public: 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, @@ -126,11 +143,14 @@ public: 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 @@ -142,12 +162,14 @@ public: 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 @@ -158,48 +180,65 @@ public: 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 index ff22563089b..73f1e95d76e 100644 --- a/dep/ACE_wrappers/ace/Token_Collection.inl +++ b/dep/ACE_wrappers/ace/Token_Collection.inl @@ -1,12 +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 index 2819813cae0..e0ca87bdcc4 100644 --- a/dep/ACE_wrappers/ace/Token_Invariants.cpp +++ b/dep/ACE_wrappers/ace/Token_Invariants.cpp @@ -1,15 +1,22 @@ #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) { @@ -17,6 +24,7 @@ ACE_Token_Invariant_Manager::instance (void) 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_, @@ -26,26 +34,34 @@ ACE_Token_Invariant_Manager::instance (void) 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 ()); @@ -57,54 +73,69 @@ ACE_Token_Invariant_Manager::acquired (const ACE_Token_Proxy *proxy) 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 { @@ -119,6 +150,7 @@ ACE_Token_Invariant_Manager::dump (void) const #endif /* ACE_HAS_DUMP */ } + int ACE_Token_Invariant_Manager::get_mutex (const ACE_TCHAR *token_name, ACE_Mutex_Invariants *&inv) @@ -129,6 +161,7 @@ ACE_Token_Invariant_Manager::get_mutex (const ACE_TCHAR *token_name, // We did not find one in the collection. { ACE_Mutex_Invariants *new_invariant; + ACE_NEW_RETURN (new_invariant, ACE_Mutex_Invariants, -1); @@ -137,12 +170,15 @@ ACE_Token_Invariant_Manager::get_mutex (const ACE_TCHAR *token_name, 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) @@ -153,39 +189,50 @@ ACE_Token_Invariant_Manager::get_rwlock (const ACE_TCHAR *token_name, // 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) { @@ -197,21 +244,25 @@ ACE_Mutex_Invariants::acquired (void) 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 { @@ -222,14 +273,17 @@ ACE_Mutex_Invariants::dump (void) const 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) { @@ -246,6 +300,7 @@ ACE_RWLock_Invariants::writer_acquired (void) else return 1; } + int ACE_RWLock_Invariants::reader_acquired (void) { @@ -260,6 +315,7 @@ ACE_RWLock_Invariants::reader_acquired (void) return 1; } } + void ACE_RWLock_Invariants::releasing (void) { @@ -268,17 +324,20 @@ ACE_RWLock_Invariants::releasing (void) 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 { @@ -290,6 +349,8 @@ ACE_RWLock_Invariants::dump (void) const 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 index b0e7d43032a..1649e5937b3 100644 --- a/dep/ACE_wrappers/ace/Token_Invariants.h +++ b/dep/ACE_wrappers/ace/Token_Invariants.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Token_Invariants.h @@ -14,18 +15,25 @@ * */ //============================================================================= + #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 * @@ -38,22 +46,30 @@ 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 * @@ -68,27 +84,37 @@ 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 * @@ -104,88 +130,117 @@ private: 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 index bef609164e3..178a0e5c63b 100644 --- a/dep/ACE_wrappers/ace/Token_Manager.cpp +++ b/dep/ACE_wrappers/ace/Token_Manager.cpp @@ -1,23 +1,33 @@ #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 ()) @@ -28,10 +38,12 @@ ACE_Token_Manager::~ACE_Token_Manager () // 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) @@ -42,6 +54,7 @@ ACE_Token_Manager::instance (void) (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_, @@ -51,8 +64,10 @@ ACE_Token_Manager::instance (void) 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) @@ -61,13 +76,17 @@ ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy, // 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) { @@ -75,11 +94,14 @@ ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy, 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. @@ -89,12 +111,15 @@ ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy, // 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_); @@ -102,17 +127,24 @@ ACE_Token_Manager::check_deadlock (ACE_Token_Proxy *proxy) 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: @@ -128,6 +160,7 @@ ACE_Token_Manager::check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy) token->name (), proxy->token_->name ())); } + return 1; case 0: default: @@ -153,11 +186,13 @@ ACE_Token_Manager::check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy) } // 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) { @@ -169,9 +204,11 @@ ACE_Token_Manager::token_waiting_for (const ACE_TCHAR *client_id) 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. @@ -180,13 +217,17 @@ 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 { @@ -211,6 +252,7 @@ ACE_Token_Manager::release_token (ACE_Tokens *&token) // else // someone is still interested in the token, so keep it around. } + void ACE_Token_Manager::dump (void) const { @@ -225,6 +267,8 @@ ACE_Token_Manager::dump (void) const 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 index 8a0211c503a..6a7c17d4167 100644 --- a/dep/ACE_wrappers/ace/Token_Manager.h +++ b/dep/ACE_wrappers/ace/Token_Manager.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Token_Manager.h @@ -8,20 +9,29 @@ * @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 * @@ -35,6 +45,7 @@ class ACE_Mutex_Token; */ 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 @@ -43,10 +54,13 @@ class ACE_Export ACE_Token_Manager : public ACE_Cleanup 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 @@ -55,6 +69,7 @@ public: * 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. @@ -65,9 +80,11 @@ public: */ 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, @@ -76,44 +93,59 @@ public: * 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 index ac2bb417bf4..a44778c89b2 100644 --- a/dep/ACE_wrappers/ace/Token_Manager.inl +++ b/dep/ACE_wrappers/ace/Token_Manager.inl @@ -1,19 +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 index 5fc66863be5..8950a47b2b0 100644 --- a/dep/ACE_wrappers/ace/Token_Request_Reply.cpp +++ b/dep/ACE_wrappers/ace/Token_Request_Reply.cpp @@ -1,18 +1,27 @@ // $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, @@ -30,25 +39,32 @@ ACE_Token_Request::ACE_Token_Request (int token_type, 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) { @@ -58,6 +74,7 @@ ACE_Token_Request::decode (void) else // Skip this->tokenName_ + '\0' + ':'. this->client_id_ = &this->token_name_[(token_len + 2) * sizeof (ACE_TCHAR)]; + // Fixed size header // token_name_ plus '\0' // ':' @@ -66,10 +83,13 @@ ACE_Token_Request::decode (void) + 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 { @@ -78,6 +98,7 @@ ACE_Token_Request::dump (void) const 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 @@ -87,6 +108,7 @@ ACE_Token_Request::dump (void) const else // == WRITER ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("WLOCK\n"))); } + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("operation = "))); switch (this->operation_type ()) { @@ -103,6 +125,7 @@ ACE_Token_Request::dump (void) const 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 @@ -113,32 +136,41 @@ ACE_Token_Request::dump (void) const 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 { @@ -148,6 +180,8 @@ ACE_Token_Reply::dump (void) const 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 index 15228922b74..1c09f7af8f6 100644 --- a/dep/ACE_wrappers/ace/Token_Request_Reply.h +++ b/dep/ACE_wrappers/ace/Token_Request_Reply.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Token_Request_Reply.h @@ -14,18 +15,25 @@ */ //============================================================================= + #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 * @@ -51,8 +59,10 @@ public: // 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) @@ -67,89 +77,124 @@ public: 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 * @@ -163,30 +208,42 @@ 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). @@ -194,15 +251,21 @@ private: /// (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 index 58eb0e3ff9d..4291bfa6089 100644 --- a/dep/ACE_wrappers/ace/Token_Request_Reply.inl +++ b/dep/ACE_wrappers/ace/Token_Request_Reply.inl @@ -1,86 +1,105 @@ // -*- 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) { @@ -96,75 +115,91 @@ ACE_Token_Request::options (const ACE_Synch_Options &opt) 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 index 48122a8d98e..5592b8169a3 100644 --- a/dep/ACE_wrappers/ace/Trace.cpp +++ b/dep/ACE_wrappers/ace/Trace.cpp @@ -1,61 +1,83 @@ // $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) @@ -64,7 +86,9 @@ ACE_Trace::ACE_Trace (const ACE_TCHAR *n, 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 ()) @@ -85,8 +109,10 @@ ACE_Trace::ACE_Trace (const ACE_TCHAR *n, } } } + // 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 @@ -107,5 +133,6 @@ ACE_Trace::~ACE_Trace (void) } } } + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Trace.h b/dep/ACE_wrappers/ace/Trace.h index 6f47ac167f6..f1c6aa86037 100644 --- a/dep/ACE_wrappers/ace/Trace.h +++ b/dep/ACE_wrappers/ace/Trace.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Trace.h @@ -8,14 +9,20 @@ * @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 * @@ -30,37 +37,50 @@ 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 { @@ -68,7 +88,10 @@ private: 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 index a95d03f3b68..aef1c4ea57e 100644 --- a/dep/ACE_wrappers/ace/Truncate.h +++ b/dep/ACE_wrappers/ace/Truncate.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Truncate.h @@ -10,25 +11,36 @@ * @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); }; @@ -44,6 +56,7 @@ namespace ACE_Utils #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); }; @@ -57,7 +70,9 @@ namespace ACE_Utils # endif /* __GNUC__ */ template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; #endif /* !ACE_LACKS_LONGLONG_T */ + // ----------------------------------------------------- + /** * @struct To_Unsigned * @@ -66,30 +81,39 @@ namespace ACE_Utils * 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" @@ -100,6 +124,7 @@ namespace ACE_Utils struct To_Unsigned { typedef unsigned long long unsigned_type; + unsigned_type operator() (unsigned_type x) { return x; } }; #else @@ -107,50 +132,61 @@ namespace ACE_Utils 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" @@ -162,13 +198,16 @@ namespace ACE_Utils { 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 * @@ -185,6 +224,7 @@ namespace ACE_Utils typename RIGHT, bool IS_LEFT_SIGNED, bool IS_RIGHT_SIGNED> struct Safe_Comparator; + // LEFT: signed, RIGHT: unsigned template struct Safe_Comparator @@ -201,6 +241,7 @@ namespace ACE_Utils } } }; + // LEFT: unsigned, RIGHT: signed template struct Safe_Comparator @@ -217,6 +258,7 @@ namespace ACE_Utils } } }; + // LEFT: unsigned, RIGHT: unsigned template struct Safe_Comparator @@ -227,6 +269,7 @@ namespace ACE_Utils return lhs > rhs; } }; + // LEFT: signed, RIGHT: signed template struct Safe_Comparator @@ -237,7 +280,9 @@ namespace ACE_Utils return lhs > rhs; } }; + // ----------------------------------------------------- + /** * @struct Fast_Comparator * @@ -259,6 +304,7 @@ namespace ACE_Utils 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) @@ -272,12 +318,15 @@ namespace ACE_Utils && 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, @@ -285,6 +334,7 @@ namespace ACE_Utils 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 @@ -292,8 +342,11 @@ namespace ACE_Utils return (static_cast (lhs) > static_cast (rhs)); } + }; + // ----------------------------------------------------- + /** * @struct Comparator * @@ -331,7 +384,9 @@ namespace ACE_Utils Sign_Check::is_signed, Sign_Check::is_signed> >::result_type comp_type; }; + // ----------------------------------------------------- + /** * @struct Truncator * @@ -349,10 +404,12 @@ namespace ACE_Utils 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 @@ -361,6 +418,7 @@ namespace ACE_Utils 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) @@ -370,7 +428,9 @@ namespace ACE_Utils ? ACE_Numeric_Limits::max () : static_cast (val)); } + }; + // Partial specialization for the case where the types are the same. // No truncation is necessary. template @@ -382,6 +442,7 @@ namespace ACE_Utils } }; + #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 @@ -403,6 +464,7 @@ namespace ACE_Utils } }; #endif /* ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */ + // ----------------------------------------------------- /** * @struct Noop_Truncator @@ -422,6 +484,7 @@ namespace ACE_Utils } }; // ----------------------------------------------------- + /** * @class truncate_cast * @@ -445,20 +508,27 @@ namespace ACE_Utils (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 { @@ -470,6 +540,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -481,6 +552,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -492,6 +564,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -503,6 +576,7 @@ namespace ACE_Utils : static_cast (val)); } }; + #if defined (ACE_SIZEOF_LONG) && ACE_SIZEOF_LONG < 8 template<> struct Truncator @@ -515,6 +589,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -526,6 +601,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -537,6 +613,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -548,6 +625,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -559,7 +637,9 @@ namespace ACE_Utils : static_cast (val)); } }; + #endif /* ACE_SIZEOF_LONG < 8 */ + #if defined (ACE_SIZEOF_INT) && ACE_SIZEOF_INT < 8 template<> struct Truncator @@ -572,6 +652,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -583,6 +664,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -594,6 +676,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -605,10 +688,13 @@ namespace ACE_Utils : static_cast (val)); } }; + #endif /* ACE_SIZEOF_INT < 8 */ + //---------------------------------------------------------- // sizeof(FROM) == sizeof(TO) //---------------------------------------------------------- + template<> struct Truncator { @@ -617,6 +703,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -625,6 +712,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -633,6 +721,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -644,6 +733,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -655,6 +745,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -663,6 +754,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -674,8 +766,10 @@ namespace ACE_Utils : static_cast (val)); } }; + #if defined (ACE_SIZEOF_INT) && defined (ACE_SIZEOF_LONG) \ && ACE_SIZEOF_INT == ACE_SIZEOF_LONG + template<> struct Truncator { @@ -684,6 +778,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -692,6 +787,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -703,6 +799,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -717,6 +814,7 @@ namespace ACE_Utils // : static_cast (val)); } }; + template<> struct Truncator { @@ -725,6 +823,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -734,6 +833,7 @@ namespace ACE_Utils } }; + template<> struct Truncator { @@ -745,7 +845,9 @@ namespace ACE_Utils : static_cast (val)); } }; + #endif /* ACE_SIZEOF_INT == ACE_SIZEOF_LONG */ + template<> struct Truncator { @@ -754,6 +856,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -765,9 +868,11 @@ namespace ACE_Utils : static_cast (val)); } }; + //---------------------------------------------------------- // sizeof(FROM) < sizeof(TO) //---------------------------------------------------------- + template<> struct Truncator { @@ -776,6 +881,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -784,6 +890,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -792,6 +899,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -800,6 +908,7 @@ namespace ACE_Utils return static_cast (val); } }; + #if defined (ACE_SIZEOF_LONG) && ACE_SIZEOF_LONG < 8 template<> struct Truncator @@ -809,6 +918,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -817,6 +927,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -828,6 +939,7 @@ namespace ACE_Utils : static_cast (val)); } }; + template<> struct Truncator { @@ -836,6 +948,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -845,6 +958,7 @@ namespace ACE_Utils } }; #endif /* ACE_SIZEOF_LONG < 8 */ + #if defined (ACE_SIZEOF_INT) && ACE_SIZEOF_INT < 8 template<> struct Truncator @@ -854,6 +968,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -862,6 +977,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -870,6 +986,7 @@ namespace ACE_Utils return static_cast (val); } }; + template<> struct Truncator { @@ -879,6 +996,7 @@ namespace ACE_Utils } }; #endif /* ACE_SIZEOF_INT < 8 */ + template<> struct Truncator { @@ -890,6 +1008,7 @@ namespace ACE_Utils : static_cast (val)); } }; + // Partial specialization for the case where the types are the same. // No truncation is necessary. template @@ -900,6 +1019,7 @@ namespace ACE_Utils return val; } }; + // Partial specialization for the case where the types are the same, // but the from type is const. No truncation is necessary. // @@ -913,16 +1033,24 @@ namespace ACE_Utils 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.h b/dep/ACE_wrappers/ace/Typed_SV_Message.h index 3ef09104f37..69c87f73c2c 100644 --- a/dep/ACE_wrappers/ace/Typed_SV_Message.h +++ b/dep/ACE_wrappers/ace/Typed_SV_Message.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Typed_SV_Message.h @@ -9,14 +10,20 @@ */ //========================================================================== + #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 * @@ -36,46 +43,66 @@ public: 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 index 0c394d7e648..6d8ea702321 100644 --- a/dep/ACE_wrappers/ace/Typed_SV_Message.inl +++ b/dep/ACE_wrappers/ace/Typed_SV_Message.inl @@ -1,9 +1,12 @@ // -*- 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, @@ -14,6 +17,7 @@ ACE_Typed_SV_Message::ACE_Typed_SV_Message (long t, this->length (l); this->max_size (m); } + template ACE_INLINE ACE_Typed_SV_Message::ACE_Typed_SV_Message (const T &d, long t, @@ -26,57 +30,67 @@ ACE_Typed_SV_Message::ACE_Typed_SV_Message (const T &d, 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.h b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h index d1c88b32931..f5f336b010d 100644 --- a/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h +++ b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Typed_SV_Message_Queue.h @@ -8,15 +9,21 @@ * @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 * @@ -32,6 +39,7 @@ public: 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, @@ -43,31 +51,43 @@ public: 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 index 7115bb7fc20..90539936e62 100644 --- a/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.inl +++ b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.inl @@ -1,8 +1,11 @@ // -*- 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, @@ -11,18 +14,22 @@ ACE_Typed_SV_Message_Queue::open (key_t external_id, 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 (), @@ -30,8 +37,10 @@ ACE_Typed_SV_Message_Queue::recv (ACE_Typed_SV_Message &mb, 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) @@ -44,22 +53,28 @@ ACE_Typed_SV_Message_Queue::send (const ACE_Typed_SV_Message &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 index e342923833e..0f2a14d9c42 100644 --- a/dep/ACE_wrappers/ace/UNIX_Addr.cpp +++ b/dep/ACE_wrappers/ace/UNIX_Addr.cpp @@ -1,29 +1,41 @@ // $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[]) { @@ -31,7 +43,9 @@ ACE_UNIX_Addr::string_to_addr (const char 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 { @@ -40,26 +54,32 @@ ACE_UNIX_Addr::addr_to_string (ACE_TCHAR s[], size_t len) const 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) { @@ -70,16 +90,21 @@ ACE_UNIX_Addr::set (const ACE_UNIX_Addr &sa) 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) { @@ -90,10 +115,12 @@ ACE_UNIX_Addr::set (const sockaddr_un *un, int len) 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[]) { @@ -104,17 +131,22 @@ ACE_UNIX_Addr::set (const char rendezvous_point[]) (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 index fca8745d4b4..6dd4130f251 100644 --- a/dep/ACE_wrappers/ace/UNIX_Addr.h +++ b/dep/ACE_wrappers/ace/UNIX_Addr.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file UNIX_Addr.h @@ -9,19 +10,27 @@ */ //============================================================================= + #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 * @@ -33,53 +42,77 @@ 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 index 513651fe1e4..5e801b56fea 100644 --- a/dep/ACE_wrappers/ace/UNIX_Addr.inl +++ b/dep/ACE_wrappers/ace/UNIX_Addr.inl @@ -2,10 +2,14 @@ // // $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 @@ -13,6 +17,7 @@ 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[]) @@ -20,7 +25,9 @@ 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 { @@ -28,17 +35,23 @@ ACE_UNIX_Addr::operator == (const ACE_UNIX_Addr &sap) const 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 index e83a675fdc4..97d90dfa570 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp +++ b/dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp @@ -1,13 +1,21 @@ // $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 { @@ -15,17 +23,22 @@ ACE_UPIPE_Acceptor::dump (void) const 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) @@ -33,23 +46,28 @@ ACE_UPIPE_Acceptor::open (const ACE_UPIPE_Addr &local_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, @@ -59,22 +77,29 @@ ACE_UPIPE_Acceptor::accept (ACE_UPIPE_Stream &new_stream, { 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) @@ -90,6 +115,7 @@ ACE_UPIPE_Acceptor::accept (ACE_UPIPE_Stream &new_stream, 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 . @@ -97,6 +123,8 @@ ACE_UPIPE_Acceptor::accept (ACE_UPIPE_Stream &new_stream, 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 index 0f419f04130..c23acd0fca0 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Acceptor.h +++ b/dep/ACE_wrappers/ace/UPIPE_Acceptor.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file UPIPE_Acceptor.h @@ -10,17 +11,24 @@ */ //============================================================================= + #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 * @@ -33,19 +41,25 @@ 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 @@ -57,21 +71,30 @@ public: 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 index 963d247e245..9432ad7bb88 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Acceptor.inl +++ b/dep/ACE_wrappers/ace/UPIPE_Acceptor.inl @@ -1,11 +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 index 3b881f67abf..755e10ebefe 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Addr.h +++ b/dep/ACE_wrappers/ace/UPIPE_Addr.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file UPIPE_Addr.h @@ -9,16 +10,25 @@ */ //============================================================================= + #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 index ad1947411cc..863dde91fc1 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Connector.cpp +++ b/dep/ACE_wrappers/ace/UPIPE_Connector.cpp @@ -1,15 +1,23 @@ // $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 { @@ -17,10 +25,12 @@ ACE_UPIPE_Connector::dump (void) const 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, @@ -32,9 +42,11 @@ ACE_UPIPE_Connector::connect (ACE_UPIPE_Stream &new_stream, { 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) @@ -44,10 +56,13 @@ ACE_UPIPE_Connector::connect (ACE_UPIPE_Stream &new_stream, 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. @@ -58,10 +73,13 @@ ACE_UPIPE_Connector::connect (ACE_UPIPE_Stream &new_stream, 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) @@ -77,6 +95,8 @@ ACE_UPIPE_Connector::connect (ACE_UPIPE_Stream &new_stream, 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 index e31cb37889f..328587f36a0 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Connector.h +++ b/dep/ACE_wrappers/ace/UPIPE_Connector.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file UPIPE_Connector.h @@ -9,15 +10,21 @@ */ //============================================================================= + #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 * @@ -30,6 +37,7 @@ 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 @@ -54,6 +62,7 @@ public: 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 @@ -78,21 +87,30 @@ public: 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 index 01635c127a5..fa43dbea326 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Connector.inl +++ b/dep/ACE_wrappers/ace/UPIPE_Connector.inl @@ -1,7 +1,9 @@ // -*- 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, @@ -21,10 +23,12 @@ ACE_UPIPE_Connector::ACE_UPIPE_Connector (ACE_UPIPE_Stream &new_stream, 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 index ba477e4f312..66c537f9d5d 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Stream.cpp +++ b/dep/ACE_wrappers/ace/UPIPE_Stream.cpp @@ -1,19 +1,28 @@ // $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) @@ -22,14 +31,17 @@ ACE_UPIPE_Stream::~ACE_UPIPE_Stream (void) 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 { @@ -37,23 +49,29 @@ ACE_UPIPE_Stream::dump (void) const 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 { @@ -61,6 +79,7 @@ ACE_UPIPE_Stream::get_remote_addr (ACE_UPIPE_Addr &remote_sap) const remote_sap = this->remote_addr_; return 0; } + int ACE_UPIPE_Stream::send (ACE_Message_Block *mb_p, ACE_Time_Value *timeout) @@ -68,18 +87,22 @@ ACE_UPIPE_Stream::send (ACE_Message_Block *mb_p, 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), @@ -90,7 +113,9 @@ ACE_UPIPE_Stream::send (const char *buffer, ? -1 : static_cast (n); } + // Receive a buffer. + ssize_t ACE_UPIPE_Stream::recv (char *buffer, size_t n, @@ -99,6 +124,7 @@ ACE_UPIPE_Stream::recv (char *buffer, ACE_TRACE ("ACE_UPIPE_Stream::recv"); // Index in buffer. size_t bytes_read = 0; + while (bytes_read < n) if (this->mb_last_ != 0) { @@ -107,6 +133,7 @@ ACE_UPIPE_Stream::recv (char *buffer, if (this_len < n) { // The remaining data is not enough. + ACE_OS::memcpy ((void *) &buffer[bytes_read], this->mb_last_->rd_ptr (), this_len); @@ -122,8 +149,10 @@ ACE_UPIPE_Stream::recv (char *buffer, 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 (); @@ -133,6 +162,7 @@ ACE_UPIPE_Stream::recv (char *buffer, { // 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) @@ -142,28 +172,35 @@ ACE_UPIPE_Stream::recv (char *buffer, 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, @@ -172,11 +209,13 @@ ACE_UPIPE_Stream::recv_n (char *buf, 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; @@ -186,8 +225,11 @@ ACE_UPIPE_Stream::recv_n (char *buf, 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 index 74402350135..2cf53b1e274 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Stream.h +++ b/dep/ACE_wrappers/ace/UPIPE_Stream.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file UPIPE_Stream.h @@ -10,18 +11,25 @@ */ //============================================================================= + #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 * @@ -32,75 +40,102 @@ 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 index 72156d465ce..7a0d73c3179 100644 --- a/dep/ACE_wrappers/ace/UPIPE_Stream.inl +++ b/dep/ACE_wrappers/ace/UPIPE_Stream.inl @@ -1,11 +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 index c0eb127db9c..6c660a37c4b 100644 --- a/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.cpp +++ b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.cpp @@ -1,4 +1,5 @@ // $Id: UTF16_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ + // ====================================================================== // // The actual conversion methods are covered by the copyright information @@ -17,18 +18,24 @@ // 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; @@ -36,6 +43,7 @@ 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. @@ -43,6 +51,7 @@ static const ACE_UINT32 UNI_MAX_UTF16 = 0x0010FFFF; // 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 @@ -58,6 +67,7 @@ static const ACE_Byte trailingBytesForUTF8[256] = { 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. @@ -65,13 +75,16 @@ 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, @@ -82,14 +95,17 @@ ACE_UTF16_Encoding_Converter::to_utf8 (const void* source, 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) { @@ -129,6 +145,7 @@ ACE_UTF16_Encoding_Converter::to_utf8 (const void* source, break; } } + // Figure out how many bytes the result will require unsigned short bytesToWrite = 0; if (ch < 0x80) @@ -144,12 +161,14 @@ ACE_UTF16_Encoding_Converter::to_utf8 (const void* source, bytesToWrite = 3; ch = UNI_REPLACEMENT_CHAR; } + target += bytesToWrite; if (target > targetEnd) { result = TARGET_EXHAUSTED; break; } + // NOTE: Everything falls through for efficiency purposes. switch (bytesToWrite) { @@ -167,8 +186,10 @@ ACE_UTF16_Encoding_Converter::to_utf8 (const void* source, } target += bytesToWrite; } + return result; } + ACE_UTF16_Encoding_Converter::Result ACE_UTF16_Encoding_Converter::from_utf8 (const ACE_Byte* source, size_t source_size, @@ -180,6 +201,7 @@ ACE_UTF16_Encoding_Converter::from_utf8 (const ACE_Byte* source, 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; @@ -189,12 +211,14 @@ ACE_UTF16_Encoding_Converter::from_utf8 (const ACE_Byte* source, 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) { @@ -217,11 +241,13 @@ ACE_UTF16_Encoding_Converter::from_utf8 (const ACE_Byte* source, 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 @@ -267,14 +293,17 @@ ACE_UTF16_Encoding_Converter::from_utf8 (const ACE_Byte* source, *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, @@ -291,38 +320,46 @@ ACE_UTF16_Encoding_Converter::encoded (const ACE_Byte* source, { 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 index 14b7fff3e46..231ce158dfa 100644 --- a/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.h +++ b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================= /** * @file UTF16_Encoding_Converter.h @@ -11,12 +12,17 @@ * @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. */ @@ -26,8 +32,10 @@ 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, @@ -35,6 +43,7 @@ public: 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, @@ -42,28 +51,37 @@ public: 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 index eb47e459646..e5292757889 100644 --- a/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.inl +++ b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.inl @@ -1,5 +1,6 @@ /* -*- C++ -*- */ // $Id: UTF16_Encoding_Converter.inl 80826 2008-03-04 14:51:23Z wotte $ + // ====================================================================== // // The actual conversion methods are covered by the copyright information @@ -17,21 +18,26 @@ // 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 @@ -55,12 +61,16 @@ ACE_UTF16_Encoding_Converter::is_legal_utf8 (const ACE_Byte* source, 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 index 66d13634216..325eded7428 100644 --- a/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.cpp +++ b/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.cpp @@ -1,4 +1,5 @@ // $Id: UTF32_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ + // ====================================================================== // // The actual conversion methods are covered by the copyright information @@ -18,20 +19,27 @@ // 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, @@ -44,15 +52,18 @@ ACE_UTF32_Encoding_Converter::to_utf8 (const void* source, 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 @@ -62,6 +73,7 @@ ACE_UTF32_Encoding_Converter::to_utf8 (const void* source, break; } } + // Figure out how many bytes the result will require. Turn any // illegally large ACE_UINT32 things (> Plane 17) into replacement // chars. @@ -86,12 +98,14 @@ ACE_UTF32_Encoding_Converter::to_utf8 (const void* source, result = SOURCE_ILLEGAL; break; } + target += bytesToWrite; if (target > targetEnd) { result = TARGET_EXHAUSTED; break; } + // NOTE: everything falls through. switch (bytesToWrite) { @@ -109,8 +123,10 @@ ACE_UTF32_Encoding_Converter::to_utf8 (const void* source, } target += bytesToWrite; } + return result; } + ACE_UTF32_Encoding_Converter::Result ACE_UTF32_Encoding_Converter::from_utf8 (const ACE_Byte* source, size_t source_size, @@ -123,10 +139,12 @@ ACE_UTF32_Encoding_Converter::from_utf8 (const ACE_Byte* source, 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; @@ -136,12 +154,14 @@ ACE_UTF32_Encoding_Converter::from_utf8 (const ACE_Byte* source, 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) { @@ -164,11 +184,13 @@ ACE_UTF32_Encoding_Converter::from_utf8 (const ACE_Byte* source, 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 @@ -196,19 +218,23 @@ ACE_UTF32_Encoding_Converter::from_utf8 (const ACE_Byte* source, 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, @@ -220,8 +246,10 @@ ACE_UTF32_Encoding_Converter::encoded (const ACE_Byte* source, { 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 index 4fc1cf0479b..dc811d7251d 100644 --- a/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.h +++ b/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================= /** * @file UTF32_Encoding_Converter.h @@ -11,12 +12,17 @@ * @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. */ @@ -26,8 +32,10 @@ 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, @@ -35,6 +43,7 @@ public: 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, @@ -42,14 +51,18 @@ public: 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 index 14b79bae755..42e452150a4 100644 --- a/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.cpp +++ b/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.cpp @@ -1,11 +1,15 @@ // $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) { @@ -22,10 +26,12 @@ ACE_UTF8_Encoding_Converter::ACE_UTF8_Encoding_Converter (void) 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, @@ -38,8 +44,10 @@ ACE_UTF8_Encoding_Converter::to_utf8 (const void* source, 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, @@ -52,6 +60,7 @@ ACE_UTF8_Encoding_Converter::from_utf8 (const ACE_Byte* source, 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 ( @@ -60,6 +69,7 @@ ACE_UTF8_Encoding_Converter::from_utf8 (const ACE_Byte* source, targetStart[source_size] = 0; return CONVERSION_OK; } + ACE_UTF8_Encoding_Converter* ACE_UTF8_Encoding_Converter::encoded (const ACE_Byte* source, size_t source_size) @@ -69,6 +79,7 @@ ACE_UTF8_Encoding_Converter::encoded (const ACE_Byte* source, if (source[i] < 0x01 || source[i] > 0x7f) return 0; } + // All characters are "valid" ASCII ACE_UTF8_Encoding_Converter* converter = 0; ACE_NEW_RETURN (converter, @@ -76,6 +87,7 @@ ACE_UTF8_Encoding_Converter::encoded (const ACE_Byte* source, 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 index bd397ba9a1b..989adca194a 100644 --- a/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.h +++ b/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================= /** * @file UTF8_Encoding_Converter.h @@ -11,12 +12,17 @@ * @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. */ @@ -26,8 +32,10 @@ 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. @@ -36,6 +44,7 @@ public: 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, @@ -44,16 +53,21 @@ public: 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 index cd9aa519f4e..d27c8f8a33b 100644 --- a/dep/ACE_wrappers/ace/UUID.cpp +++ b/dep/ACE_wrappers/ace/UUID.cpp @@ -1,9 +1,12 @@ //$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" @@ -11,11 +14,14 @@ #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) @@ -23,18 +29,22 @@ namespace ACE_Utils 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) @@ -50,6 +60,7 @@ namespace ACE_Utils 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), @@ -63,8 +74,10 @@ namespace ACE_Utils { 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_), @@ -76,13 +89,16 @@ namespace ACE_Utils 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) { @@ -93,12 +109,14 @@ namespace ACE_Utils // 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_, @@ -121,6 +139,7 @@ namespace ACE_Utils 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_, @@ -136,19 +155,24 @@ namespace ACE_Utils (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) { @@ -159,6 +183,7 @@ namespace ACE_Utils "IllegalArgument (incorrect string length)\n")); return; } + /// Special case for the nil UUID. if (uuid_string == *NIL_UUID.to_string ()) { @@ -168,6 +193,7 @@ namespace ACE_Utils ACE_UNUSED_ARG (copy_constructor_not_supported); return; } + unsigned int time_low; unsigned int time_mid; unsigned int time_hi_and_version; @@ -175,6 +201,7 @@ namespace ACE_Utils 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 @@ -202,6 +229,7 @@ namespace ACE_Utils &node[4], &node[5] ); + if (nScanned != 11) { ACE_DEBUG ((LM_DEBUG, @@ -247,6 +275,7 @@ namespace ACE_Utils thr_pid_buf ); #endif /* ACE_HAS_TR24731_2005_CRT */ + if (nScanned != 12) { ACE_DEBUG ((LM_DEBUG, @@ -255,15 +284,19 @@ namespace ACE_Utils 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) { @@ -272,8 +305,10 @@ namespace ACE_Utils "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) @@ -283,6 +318,7 @@ namespace ACE_Utils "IllegalArgument (unsupported version)\n")); return; } + if ((this->clock_seq_hi_and_reserved_ & 0xc0) == 0xc0) { if (uuid_string.length () == NIL_UUID.to_string ()->length ()) @@ -298,10 +334,12 @@ namespace ACE_Utils 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) @@ -309,16 +347,19 @@ namespace ACE_Utils 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) { @@ -330,6 +371,7 @@ namespace ACE_Utils // macaddress.node [3], // macaddress.node [4], // macaddress.node [5])); + ACE_OS::memcpy (&node_id, macaddress.node, sizeof (node_id)); @@ -343,46 +385,57 @@ namespace ACE_Utils 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) { @@ -390,16 +443,20 @@ namespace ACE_Utils 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_) @@ -413,25 +470,32 @@ namespace ACE_Utils { 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: @@ -454,6 +518,7 @@ namespace ACE_Utils #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; @@ -461,24 +526,30 @@ namespace ACE_Utils 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 index a29ba320b38..f2dceff3e51 100644 --- a/dep/ACE_wrappers/ace/UUID.h +++ b/dep/ACE_wrappers/ace/UUID.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file UUID.h @@ -9,37 +10,50 @@ * @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 * @@ -61,45 +75,65 @@ namespace ACE_Utils 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_; @@ -110,10 +144,12 @@ namespace ACE_Utils 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 * @@ -123,29 +159,40 @@ namespace ACE_Utils 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 @@ -154,29 +201,40 @@ namespace ACE_Utils 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 index b35db00eb54..a60fb6ce17f 100644 --- a/dep/ACE_wrappers/ace/UUID.inl +++ b/dep/ACE_wrappers/ace/UUID.inl @@ -1,98 +1,119 @@ // -*- 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 { @@ -103,13 +124,16 @@ namespace ACE_Utils (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 // { @@ -151,13 +175,16 @@ namespace ACE_Utils 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 // { @@ -169,4 +196,5 @@ namespace ACE_Utils // return false; // } } + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Unbounded_Queue.h b/dep/ACE_wrappers/ace/Unbounded_Queue.h index ae349e3b791..0c16ac23388 100644 --- a/dep/ACE_wrappers/ace/Unbounded_Queue.h +++ b/dep/ACE_wrappers/ace/Unbounded_Queue.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Unbounded_Queue.h @@ -8,18 +9,26 @@ * @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 * @@ -31,28 +40,38 @@ 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 * @@ -64,28 +83,38 @@ 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 * @@ -123,9 +152,11 @@ 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. @@ -133,58 +164,71 @@ public: * 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. /** @@ -192,6 +236,7 @@ public: * 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 @@ -200,40 +245,54 @@ public: * 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 index f00a3b1d540..0758412b984 100644 --- a/dep/ACE_wrappers/ace/Unbounded_Queue.inl +++ b/dep/ACE_wrappers/ace/Unbounded_Queue.inl @@ -1,22 +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.h b/dep/ACE_wrappers/ace/Unbounded_Set.h index a56860fe8a8..44fb84068ee 100644 --- a/dep/ACE_wrappers/ace/Unbounded_Set.h +++ b/dep/ACE_wrappers/ace/Unbounded_Set.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Unbounded_Set.h @@ -8,15 +9,21 @@ * @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. @@ -26,8 +33,10 @@ 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. @@ -38,10 +47,13 @@ class ACE_Unbounded_Set_Iterator : public { 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. @@ -51,12 +63,16 @@ 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. @@ -68,16 +84,21 @@ class ACE_Unbounded_Set : public 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 index 4aa5fe5ce9b..365b025c0be 100644 --- a/dep/ACE_wrappers/ace/Unbounded_Set.inl +++ b/dep/ACE_wrappers/ace/Unbounded_Set.inl @@ -1,24 +1,30 @@ // -*- 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, +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, @@ -26,15 +32,18 @@ ACE_Unbounded_Set_Const_Iterator (const ACE_Unbounded_Set &s, : 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.h b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.h index df08645bda6..ab16a54be86 100644 --- a/dep/ACE_wrappers/ace/Unbounded_Set_Ex.h +++ b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Unbounded_Set_Ex.h @@ -8,22 +9,31 @@ * @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 * @@ -35,38 +45,54 @@ 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 * @@ -79,38 +105,54 @@ 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 * @@ -155,6 +197,7 @@ 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; @@ -162,6 +205,7 @@ public: 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. @@ -170,38 +214,47 @@ public: * 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). @@ -209,12 +262,14 @@ public: * 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 @@ -222,55 +277,72 @@ public: * 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 index 00a06d18e95..356a1f58f1d 100644 --- a/dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl +++ b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl @@ -1,18 +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 index 4fcd4f37b2b..f42beba0c99 100644 --- a/dep/ACE_wrappers/ace/Value_Ptr.h +++ b/dep/ACE_wrappers/ace/Value_Ptr.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Value_Ptr.h @@ -11,11 +12,16 @@ * @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 { /** @@ -40,6 +46,7 @@ namespace ACE /// Copy the given object. static T * clone (T const * p) { return new T (*p); } }; + /** * @class Value_Ptr * @@ -60,14 +67,19 @@ namespace ACE 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. /** @@ -77,9 +89,11 @@ namespace ACE * 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) { @@ -88,13 +102,17 @@ namespace ACE 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) @@ -104,32 +122,47 @@ namespace ACE 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.h b/dep/ACE_wrappers/ace/Vector_T.h index 8b2c9a1db51..7be43bfd631 100644 --- a/dep/ACE_wrappers/ace/Vector_T.h +++ b/dep/ACE_wrappers/ace/Vector_T.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file Vector_T.h @@ -9,20 +10,28 @@ * @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 * @@ -66,6 +75,7 @@ public: */ typedef ACE_Vector_Iterator Iterator; + /** * General constructor. * @@ -76,10 +86,12 @@ public: */ 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. @@ -87,6 +99,7 @@ public: * @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 @@ -96,11 +109,13 @@ public: * @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 @@ -116,6 +131,7 @@ public: */ 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 @@ -127,6 +143,7 @@ public: * 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 @@ -134,6 +151,7 @@ public: * 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 @@ -149,13 +167,16 @@ public: * 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 != @@ -163,23 +184,30 @@ public: * @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!=() @@ -201,6 +229,7 @@ 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 @@ -216,6 +245,7 @@ int compare (const ACE_Vector& v1, * @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, @@ -223,6 +253,7 @@ int partial_compare (const ACE_Vector& v1, const size_t to_ndx); #endif /* 0 */ // **************************************************************** + /** * @class ACE_Vector_Iterator * @@ -238,35 +269,49 @@ 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 index 9ddbd308d27..4b773109a84 100644 --- a/dep/ACE_wrappers/ace/Vector_T.inl +++ b/dep/ACE_wrappers/ace/Vector_T.inl @@ -1,8 +1,11 @@ // -*- 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) @@ -11,25 +14,30 @@ ACE_Vector::ACE_Vector (const size_t init_size, { 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) { @@ -39,12 +47,15 @@ void ACE_Vector::pop_back (void) 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) { @@ -52,12 +63,15 @@ ACE_Vector::swap (ACE_Vector &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), @@ -65,10 +79,12 @@ ACE_Vector_Iterator::ACE_Vector_Iterator (ACE_Vector::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_; @@ -78,11 +94,14 @@ ACE_Vector_Iterator::advance (void) // 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 index 8fe7029d442..ff3f3e64074 100644 --- a/dep/ACE_wrappers/ace/Version.h +++ b/dep/ACE_wrappers/ace/Version.h @@ -2,6 +2,7 @@ // -*- 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 diff --git a/dep/ACE_wrappers/ace/Versioned_Namespace.h b/dep/ACE_wrappers/ace/Versioned_Namespace.h index 7e13cf0bcc4..9b71d0111fc 100644 --- a/dep/ACE_wrappers/ace/Versioned_Namespace.h +++ b/dep/ACE_wrappers/ace/Versioned_Namespace.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file Versioned_Namespace.h @@ -12,15 +13,20 @@ * @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 @@ -29,13 +35,18 @@ # 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 index 09cc83eb982..7355a025bbd 100644 --- a/dep/ACE_wrappers/ace/WFMO_Reactor.cpp +++ b/dep/ACE_wrappers/ace/WFMO_Reactor.cpp @@ -1,21 +1,30 @@ // $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) { @@ -25,6 +34,7 @@ ACE_WFMO_Reactor_Handler_Repository::open (size_t size) size, MAXIMUM_WAIT_OBJECTS), -1); + // Dynamic allocation ACE_NEW_RETURN (this->current_handles_, ACE_HANDLE[size], @@ -38,6 +48,7 @@ ACE_WFMO_Reactor_Handler_Repository::open (size_t size) ACE_NEW_RETURN (this->to_be_added_info_, To_Be_Added_Info[size], -1); + // Initialization this->max_size_ = size; this->max_handlep1_ = 0; @@ -46,10 +57,13 @@ ACE_WFMO_Reactor_Handler_Repository::open (size_t size) 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 @@ -58,6 +72,7 @@ ACE_WFMO_Reactor_Handler_Repository::~ACE_WFMO_Reactor_Handler_Repository (void) 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, @@ -65,90 +80,127 @@ ACE_WFMO_Reactor_Handler_Repository::bit_ops (long &existing_masks, { // 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, @@ -161,6 +213,7 @@ ACE_WFMO_Reactor_Handler_Repository::unbind_i (ACE_HANDLE handle, 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 @@ -174,6 +227,7 @@ ACE_WFMO_Reactor_Handler_Repository::unbind_i (ACE_HANDLE handle, 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, @@ -187,12 +241,15 @@ ACE_WFMO_Reactor_Handler_Repository::unbind_i (ACE_HANDLE handle, 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) @@ -205,6 +262,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_handler_i (size_t slot, 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 @@ -221,6 +279,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_handler_i (size_t slot, 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_) @@ -230,6 +289,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_handler_i (size_t slot, // 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 @@ -242,6 +302,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_handler_i (size_t slot, // 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. @@ -253,8 +314,10 @@ ACE_WFMO_Reactor_Handler_Repository::remove_handler_i (size_t slot, 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) @@ -267,6 +330,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_suspended_handler_i (size_t slot, 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 @@ -283,6 +347,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_suspended_handler_i (size_t slot, 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_) @@ -292,6 +357,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_suspended_handler_i (size_t slot, // 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 @@ -315,8 +381,10 @@ ACE_WFMO_Reactor_Handler_Repository::remove_suspended_handler_i (size_t slot, 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) @@ -329,6 +397,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_to_be_added_handler_i (size_t slot, 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 @@ -345,6 +414,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_to_be_added_handler_i (size_t slot, 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_) @@ -354,6 +424,7 @@ ACE_WFMO_Reactor_Handler_Repository::remove_to_be_added_handler_i (size_t slot, // 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 @@ -377,16 +448,20 @@ ACE_WFMO_Reactor_Handler_Repository::remove_to_be_added_handler_i (size_t slot, 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, @@ -403,6 +478,7 @@ ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i (ACE_HANDLE handle, // 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, @@ -419,6 +495,7 @@ ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i (ACE_HANDLE handle, // 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, @@ -435,16 +512,20 @@ ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i (ACE_HANDLE handle, // 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, @@ -461,6 +542,7 @@ ACE_WFMO_Reactor_Handler_Repository::resume_handler_i (ACE_HANDLE handle, // 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, @@ -477,6 +559,7 @@ ACE_WFMO_Reactor_Handler_Repository::resume_handler_i (ACE_HANDLE handle, // 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, @@ -493,36 +576,45 @@ ACE_WFMO_Reactor_Handler_Repository::resume_handler_i (ACE_HANDLE handle, // 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, @@ -533,15 +625,18 @@ ACE_WFMO_Reactor_Handler_Repository::bind_i (bool io_entry, { 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. @@ -556,8 +651,11 @@ ACE_WFMO_Reactor_Handler_Repository::bind_i (bool io_entry, 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 (); @@ -567,8 +665,10 @@ ACE_WFMO_Reactor_Handler_Repository::bind_i (bool io_entry, 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) { @@ -586,6 +686,7 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void) 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_) { @@ -604,15 +705,19 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void) 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_) { @@ -620,9 +725,11 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void) 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_ || @@ -652,6 +759,7 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void) // handles. ++i; } + // Now that all internal structures have been updated, make // the upcall. if (event_handler != 0) @@ -659,7 +767,9 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void) 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 (); @@ -667,8 +777,10 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void) } } } + return 0; } + int ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void) { @@ -685,6 +797,7 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void) 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_) { @@ -703,15 +816,19 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void) 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 @@ -719,9 +836,11 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void) // 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. @@ -748,6 +867,7 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void) // suspended handles. ++i; } + // Now that all internal structures have been updated, make // the upcall. if (event_handler != 0) @@ -755,7 +875,9 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void) 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 (); @@ -763,8 +885,10 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void) } } } + return 0; } + int ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos (void) { @@ -778,6 +902,7 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos (void) 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_) { @@ -796,15 +921,19 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos (void) 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_) { @@ -812,9 +941,11 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos (void) 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 { @@ -824,8 +955,10 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos (void) 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) @@ -833,28 +966,37 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos (void) 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, @@ -863,19 +1005,25 @@ ACE_WFMO_Reactor_Handler_Repository::dump (void) const 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, @@ -884,23 +1032,30 @@ ACE_WFMO_Reactor_Handler_Repository::dump (void) const 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 */ @@ -935,6 +1090,7 @@ ACE_WFMO_Reactor::ACE_WFMO_Reactor (ACE_Sig_Handler *sh, ACE_TEXT ("%p\n"), ACE_TEXT ("WFMO_Reactor"))); } + ACE_WFMO_Reactor::ACE_WFMO_Reactor (size_t size, int unused, ACE_Sig_Handler *sh, @@ -963,6 +1119,7 @@ ACE_WFMO_Reactor::ACE_WFMO_Reactor (size_t size, deactivated_ (0) { ACE_UNUSED_ARG (unused); + if (this->open (size, 0, sh, tq, 0, notify) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), @@ -971,11 +1128,13 @@ ACE_WFMO_Reactor::ACE_WFMO_Reactor (size_t size, #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, @@ -986,14 +1145,18 @@ ACE_WFMO_Reactor::open (size_t size, { 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_, @@ -1006,9 +1169,11 @@ ACE_WFMO_Reactor::open (size_t size, 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_, @@ -1021,9 +1186,11 @@ ACE_WFMO_Reactor::open (size_t size, 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_) { @@ -1035,8 +1202,10 @@ ACE_WFMO_Reactor::open (size_t size, // 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) @@ -1045,27 +1214,34 @@ ACE_WFMO_Reactor::open (size_t size, -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) @@ -1073,6 +1249,7 @@ ACE_WFMO_Reactor::open (size_t size, 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 ()) @@ -1083,10 +1260,13 @@ ACE_WFMO_Reactor::open (size_t size, // 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) { @@ -1096,11 +1276,13 @@ ACE_WFMO_Reactor::set_sig_handler (ACE_Sig_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) { @@ -1110,41 +1292,51 @@ ACE_WFMO_Reactor::timer_queue (ACE_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_; @@ -1152,6 +1344,7 @@ ACE_WFMO_Reactor::~ACE_WFMO_Reactor (void) this->delete_notify_handler_ = false; } } + int ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle, ACE_HANDLE io_handle, @@ -1161,24 +1354,31 @@ ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle, // 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; @@ -1189,6 +1389,7 @@ ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle, 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) @@ -1200,6 +1401,7 @@ ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle, event_handle = event->handle (); delete_event = true; } + int result = ::WSAEventSelect ((SOCKET) io_handle, event_handle, new_network_events); @@ -1234,8 +1436,11 @@ ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle, } 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, @@ -1244,9 +1449,11 @@ ACE_WFMO_Reactor::mask_ops_i (ACE_HANDLE io_handle, // 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; @@ -1271,6 +1478,8 @@ ACE_WFMO_Reactor::mask_ops_i (ACE_HANDLE io_handle, return -1; } + + int ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i (ACE_HANDLE io_handle, ACE_Reactor_Mask new_masks, @@ -1283,6 +1492,7 @@ ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i (ACE_HANDLE io_hand 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 @@ -1296,6 +1506,7 @@ ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i (ACE_HANDLE io_hand 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 @@ -1309,6 +1520,7 @@ ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i (ACE_HANDLE io_hand 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 @@ -1322,18 +1534,23 @@ ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i (ACE_HANDLE io_hand 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) @@ -1342,7 +1559,9 @@ ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle, 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 @@ -1356,6 +1575,7 @@ ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle, 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 @@ -1369,6 +1589,7 @@ ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle, 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 @@ -1382,10 +1603,13 @@ ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle, 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, @@ -1393,13 +1617,17 @@ ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle, { 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 && @@ -1407,38 +1635,47 @@ ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle, 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 @@ -1446,13 +1683,16 @@ 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 { @@ -1462,18 +1702,24 @@ ACE_WFMO_Reactor::event_handling (ACE_Time_Value *max_wait_time, 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) @@ -1492,8 +1738,10 @@ ACE_WFMO_Reactor::event_handling (ACE_Time_Value *max_wait_time, } } while (result == 0); + return result; } + int ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time, int alertable) @@ -1503,6 +1751,7 @@ ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time, // 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 @@ -1530,6 +1779,7 @@ ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time, 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 (); @@ -1538,6 +1788,7 @@ ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time, this->lock_.release (); } return 1; + #else int timeout = max_wait_time == 0 ? INFINITE : max_wait_time->msec (); DWORD result = 0; @@ -1550,18 +1801,23 @@ ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time, 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: @@ -1574,10 +1830,12 @@ ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time, 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) @@ -1585,6 +1843,7 @@ ACE_WFMO_Reactor::wait_for_multiple_events (int timeout, // 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. @@ -1601,6 +1860,7 @@ ACE_WFMO_Reactor::wait_for_multiple_events (int timeout, alertable); #endif /* ACE_HAS_PHARLAP */ } + DWORD ACE_WFMO_Reactor::poll_remaining_handles (DWORD slot) { @@ -1609,6 +1869,7 @@ ACE_WFMO_Reactor::poll_remaining_handles (DWORD slot) FALSE, 0); } + int ACE_WFMO_Reactor::calculate_timeout (ACE_Time_Value *max_wait_time) { @@ -1617,12 +1878,14 @@ ACE_WFMO_Reactor::calculate_timeout (ACE_Time_Value *max_wait_time) 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) { @@ -1630,34 +1893,42 @@ ACE_WFMO_Reactor::expire_timers (void) 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. @@ -1667,11 +1938,14 @@ 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) @@ -1687,21 +1961,27 @@ ACE_WFMO_Reactor::dispatch_handles (DWORD wait_status) 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) @@ -1715,6 +1995,7 @@ ACE_WFMO_Reactor::dispatch_handles (DWORD wait_status) } } } + int ACE_WFMO_Reactor::dispatch_handler (DWORD slot, DWORD max_handlep1) @@ -1722,6 +2003,7 @@ ACE_WFMO_Reactor::dispatch_handler (DWORD slot, // 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 @@ -1731,6 +2013,7 @@ ACE_WFMO_Reactor::dispatch_handler (DWORD slot, 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); @@ -1742,41 +2025,52 @@ ACE_WFMO_Reactor::dispatch_handler (DWORD slot, // 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_, @@ -1801,32 +2095,40 @@ ACE_WFMO_Reactor::complex_dispatch_handler (DWORD slot, { 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, @@ -1835,11 +2137,14 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, // 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); @@ -1850,6 +2155,7 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, ACE_SET_BITS (problems, ACE_Event_Handler::WRITE_MASK); } } + if (ACE_BIT_ENABLED (actual_events, FD_CONNECT)) { if (events.iErrorCode[FD_CONNECT_BIT] == 0) @@ -1877,6 +2183,7 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, } } } + if (ACE_BIT_ENABLED (actual_events, FD_OOB)) { action = event_handler->handle_exception (io_handle); @@ -1887,6 +2194,7 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, ACE_SET_BITS (problems, ACE_Event_Handler::EXCEPT_MASK); } } + if (ACE_BIT_ENABLED (actual_events, FD_READ)) { action = event_handler->handle_input (io_handle); @@ -1897,6 +2205,7 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, 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)) { @@ -1908,6 +2217,7 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK); } } + if (ACE_BIT_ENABLED (actual_events, FD_ACCEPT)) { action = event_handler->handle_input (io_handle); @@ -1918,6 +2228,7 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, ACE_SET_BITS (problems, ACE_Event_Handler::ACCEPT_MASK); } } + if (ACE_BIT_ENABLED (actual_events, FD_QOS)) { action = event_handler->handle_qos (io_handle); @@ -1928,6 +2239,7 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, 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); @@ -1938,17 +2250,21 @@ ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, 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 ()) @@ -1960,6 +2276,7 @@ ACE_WFMO_Reactor::update_state (void) 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 { @@ -1972,6 +2289,7 @@ ACE_WFMO_Reactor::update_state (void) // 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. @@ -1999,58 +2317,72 @@ ACE_WFMO_Reactor::update_state (void) 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), @@ -2058,6 +2390,7 @@ ACE_WFMO_Reactor_Notify::ACE_WFMO_Reactor_Notify (size_t max_notifies) max_notify_iterations_ (-1) { } + int ACE_WFMO_Reactor_Notify::open (ACE_Reactor_Impl *wfmo_reactor, ACE_Timer_Queue *timer_queue, @@ -2067,25 +2400,31 @@ ACE_WFMO_Reactor_Notify::open (ACE_Reactor_Impl *wfmo_reactor, 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; @@ -2104,17 +2443,22 @@ ACE_WFMO_Reactor_Notify::handle_signal (int signum, { 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: @@ -2139,17 +2483,21 @@ ACE_WFMO_Reactor_Notify::handle_signal (int signum, 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. @@ -2159,15 +2507,18 @@ ACE_WFMO_Reactor_Notify::handle_signal (int signum, // 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, @@ -2179,25 +2530,31 @@ ACE_WFMO_Reactor_Notify::notify (ACE_Event_Handler *event_handler, 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) { @@ -2205,25 +2562,31 @@ ACE_WFMO_Reactor_Notify::max_notify_iterations (int 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 @@ -2231,19 +2594,25 @@ ACE_WFMO_Reactor_Notify::purge_pending_notifications (ACE_Event_Handler *eh, // 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 @@ -2255,7 +2624,9 @@ ACE_WFMO_Reactor_Notify::purge_pending_notifications (ACE_Event_Handler *eh, // applying the mask { ACE_Event_Handler *event_handler = buffer->eh_; + event_handler->remove_reference (); + mb->release (); ++number_purged; } @@ -2272,11 +2643,13 @@ ACE_WFMO_Reactor_Notify::purge_pending_notifications (ACE_Event_Handler *eh, 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 (); @@ -2288,14 +2661,17 @@ ACE_WFMO_Reactor_Notify::purge_pending_notifications (ACE_Event_Handler *eh, 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 { @@ -2309,21 +2685,26 @@ ACE_WFMO_Reactor_Notify::dump (void) const 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) @@ -2334,6 +2715,7 @@ ACE_WFMO_Reactor::purge_pending_notifications (ACE_Event_Handler *eh, else return this->notify_handler_->purge_pending_notifications (eh, mask); } + int ACE_WFMO_Reactor::resumable_handler (void) { @@ -2341,6 +2723,7 @@ ACE_WFMO_Reactor::resumable_handler (void) return 0; } + // No-op WinSOCK2 methods to help WFMO_Reactor compile #if !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) int @@ -2350,6 +2733,7 @@ WSAEventSelect (SOCKET /* s */, { return -1; } + int WSAEnumNetworkEvents (SOCKET /* s */, WSAEVENT /* hEventObject */, @@ -2358,6 +2742,8 @@ WSAEnumNetworkEvents (SOCKET /* s */, 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 index b02ad8bf9f0..8a6a8af8ad1 100644 --- a/dep/ACE_wrappers/ace/WFMO_Reactor.h +++ b/dep/ACE_wrappers/ace/WFMO_Reactor.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file WFMO_Reactor.h @@ -10,14 +11,19 @@ * @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" @@ -28,6 +34,7 @@ #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) /* @@ -41,28 +48,39 @@ #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 * @@ -75,6 +93,7 @@ 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 * @@ -88,6 +107,7 @@ class ACE_Export ACE_WFMO_Reactor_Handler_Repository public: friend class ACE_WFMO_Reactor; friend class ACE_WFMO_Reactor_Test; + /** * @class Common_Info * @@ -103,17 +123,21 @@ 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 @@ -121,18 +145,23 @@ public: * 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, @@ -141,11 +170,14 @@ public: 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 * @@ -157,10 +189,13 @@ public: 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, @@ -170,12 +205,15 @@ public: 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 * @@ -187,12 +225,16 @@ public: 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, @@ -203,13 +245,16 @@ public: 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 * @@ -221,12 +266,16 @@ public: 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, @@ -237,25 +286,34 @@ public: 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, @@ -264,33 +322,45 @@ public: 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 @@ -304,38 +374,49 @@ public: 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 @@ -344,44 +425,60 @@ public: 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 * @@ -402,12 +499,15 @@ 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 @@ -420,25 +520,32 @@ public: 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 @@ -451,6 +558,7 @@ public: * overhead. */ void max_notify_iterations (int); + /** * Get the maximum number of times that the * method will iterate and @@ -459,6 +567,7 @@ public: * 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 @@ -468,24 +577,30 @@ public: */ 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 @@ -496,6 +611,7 @@ private: */ int max_notify_iterations_; }; + /** * @class ACE_WFMO_Reactor * @@ -537,6 +653,7 @@ 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. @@ -547,11 +664,14 @@ public: */ 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. * @@ -566,6 +686,7 @@ public: ACE_Sig_Handler * = 0, ACE_Timer_Queue * = 0, ACE_Reactor_Notify * = 0); + /** * Initialize ACE_WFMO_Reactor with the specified size. * @@ -581,25 +702,34 @@ public: 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, @@ -625,6 +755,7 @@ public: */ 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 @@ -637,20 +768,25 @@ public: 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 @@ -662,6 +798,7 @@ public: */ 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 @@ -677,6 +814,7 @@ public: 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 @@ -685,6 +823,7 @@ public: 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 @@ -693,11 +832,13 @@ public: */ 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 @@ -708,11 +849,13 @@ public: 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 @@ -723,6 +866,7 @@ public: */ 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 @@ -738,6 +882,7 @@ public: */ 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 @@ -745,6 +890,7 @@ public: */ 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 @@ -756,32 +902,44 @@ public: 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 @@ -789,7 +947,9 @@ public: * 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, @@ -811,6 +971,7 @@ public: 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 @@ -820,10 +981,12 @@ public: */ 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 @@ -836,7 +999,9 @@ public: 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 @@ -844,6 +1009,7 @@ public: */ 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 @@ -851,6 +1017,7 @@ public: */ 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 @@ -858,6 +1025,7 @@ public: */ 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 @@ -865,7 +1033,9 @@ public: */ 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 @@ -877,6 +1047,7 @@ public: 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 @@ -889,6 +1060,7 @@ public: * overhead. */ virtual void max_notify_iterations (int); + /** * Get the maximum number of times that the * method will iterate and @@ -897,6 +1069,7 @@ public: * 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 @@ -904,12 +1077,15 @@ public: */ 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 @@ -918,6 +1094,7 @@ public: 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 @@ -925,34 +1102,46 @@ public: */ 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 @@ -961,6 +1150,7 @@ public: 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 @@ -969,99 +1159,132 @@ public: 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. * @@ -1072,26 +1295,34 @@ protected: * 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 @@ -1101,28 +1332,37 @@ protected: * 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 index 2abf621f739..a155019d841 100644 --- a/dep/ACE_wrappers/ace/WFMO_Reactor.inl +++ b/dep/ACE_wrappers/ace/WFMO_Reactor.inl @@ -1,13 +1,17 @@ // -*- 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 */, @@ -18,8 +22,11 @@ ACE_Wakeup_All_Threads_Handler::handle_signal (int /* signum */, // 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), @@ -31,6 +38,7 @@ ACE_WFMO_Reactor_Handler_Repository::Common_Info::Common_Info (void) close_masks_ (ACE_Event_Handler::NULL_MASK) { } + ACE_INLINE void ACE_WFMO_Reactor_Handler_Repository::Common_Info::reset (void) { @@ -42,6 +50,7 @@ ACE_WFMO_Reactor_Handler_Repository::Common_Info::reset (void) 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, @@ -59,47 +68,61 @@ ACE_WFMO_Reactor_Handler_Repository::Common_Info::set (bool io_entry, 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, @@ -119,6 +142,7 @@ ACE_WFMO_Reactor_Handler_Repository::Current_Info::set (bool io_entry, delete_entry, close_masks); } + ACE_INLINE void ACE_WFMO_Reactor_Handler_Repository::Current_Info::set (Common_Info &common_info, bool suspend_entry) @@ -126,37 +150,47 @@ ACE_WFMO_Reactor_Handler_Repository::Current_Info::set (Common_Info &common_info 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, @@ -178,6 +212,7 @@ ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::set (ACE_HANDLE event_han 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, @@ -187,6 +222,7 @@ ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::set (ACE_HANDLE event_han this->suspend_entry_ = suspend_entry; Common_Info::set (common_info); } + ACE_INLINE void ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::reset (void) { @@ -194,29 +230,38 @@ ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::reset (void) 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) { @@ -224,6 +269,7 @@ ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::reset (void) 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, @@ -245,6 +291,7 @@ ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set (ACE_HANDLE event_handl delete_entry, close_masks); } + ACE_INLINE void ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set (ACE_HANDLE event_handle, Common_Info &common_info, @@ -254,30 +301,40 @@ ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set (ACE_HANDLE event_handl 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 { @@ -292,6 +349,7 @@ ACE_WFMO_Reactor_Handler_Repository::handles (void) const else return this->current_handles_ + 1; } + ACE_INLINE ACE_WFMO_Reactor_Handler_Repository::Current_Info * ACE_WFMO_Reactor_Handler_Repository::current_info (void) const { @@ -300,6 +358,7 @@ ACE_WFMO_Reactor_Handler_Repository::current_info (void) const else return this->current_info_ + 1; } + ACE_INLINE DWORD ACE_WFMO_Reactor_Handler_Repository::max_handlep1 (void) const { @@ -308,6 +367,7 @@ ACE_WFMO_Reactor_Handler_Repository::max_handlep1 (void) const else return this->max_handlep1_ - 1; } + ACE_INLINE int ACE_WFMO_Reactor_Handler_Repository::scheduled_for_deletion (size_t slot) const { @@ -316,6 +376,7 @@ ACE_WFMO_Reactor_Handler_Repository::scheduled_for_deletion (size_t slot) const else return this->current_info_[slot + 1].delete_entry_ == true; } + ACE_INLINE int ACE_WFMO_Reactor_Handler_Repository::invalid_handle (ACE_HANDLE handle) const { @@ -330,6 +391,7 @@ ACE_WFMO_Reactor_Handler_Repository::invalid_handle (ACE_HANDLE handle) const else return 0; } + ACE_INLINE bool ACE_WFMO_Reactor_Handler_Repository::changes_required (void) { @@ -339,6 +401,7 @@ ACE_WFMO_Reactor_Handler_Repository::changes_required (void) || this->handles_to_be_suspended_ > 0 || this->handles_to_be_resumed_ > 0; } + ACE_INLINE int ACE_WFMO_Reactor_Handler_Repository::make_changes (void) { @@ -346,50 +409,65 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes (void) // 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, @@ -397,6 +475,7 @@ ACE_WFMO_Reactor::schedule_timer (ACE_Event_Handler *handler, const ACE_Time_Value &interval) { ACE_TRACE ("ACE_WFMO_Reactor::schedule_timer"); + if (0 != this->timer_queue_) { long result = this->timer_queue_->schedule @@ -404,13 +483,17 @@ ACE_WFMO_Reactor::schedule_timer (ACE_Event_Handler *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) @@ -420,6 +503,7 @@ ACE_WFMO_Reactor::cancel_timer (ACE_Event_Handler *handler, 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, @@ -430,12 +514,14 @@ ACE_WFMO_Reactor::cancel_timer (long timer_id, 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, @@ -443,17 +529,20 @@ ACE_WFMO_Reactor::register_handler (ACE_Event_Handler *event_handler, 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, @@ -461,11 +550,13 @@ ACE_WFMO_Reactor::register_handler (ACE_HANDLE io_handle, { // 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, @@ -474,11 +565,13 @@ ACE_WFMO_Reactor::register_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->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, @@ -486,56 +579,68 @@ ACE_WFMO_Reactor::register_handler (const ACE_Handle_Set &handles, { // 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) @@ -543,6 +648,7 @@ ACE_WFMO_Reactor::remove_handler (ACE_Event_Handler *event_handler, 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) @@ -550,6 +656,7 @@ ACE_WFMO_Reactor::remove_handler (ACE_HANDLE handle, return this->handler_rep_.unbind (handle, mask); } + ACE_INLINE int ACE_WFMO_Reactor::remove_handler (const ACE_Handle_Set &handles, ACE_Reactor_Mask mask) @@ -557,60 +664,77 @@ ACE_WFMO_Reactor::remove_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_.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++) @@ -621,6 +745,7 @@ ACE_WFMO_Reactor::suspend_handlers (void) 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; @@ -641,51 +766,65 @@ ACE_WFMO_Reactor::suspend_handlers (void) 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; @@ -697,6 +836,7 @@ ACE_WFMO_Reactor::resume_handlers (void) 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; @@ -717,11 +857,14 @@ ACE_WFMO_Reactor::resume_handlers (void) 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) { @@ -729,37 +872,44 @@ ACE_WFMO_Reactor::uses_event_associations (void) // 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) { @@ -767,28 +917,35 @@ ACE_WFMO_Reactor::owner (ACE_thread_t *t) *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) { @@ -796,6 +953,7 @@ ACE_WFMO_Reactor::change_owner (void) this->new_owner_ = ACE_thread_t (0); return 0; } + ACE_INLINE int ACE_WFMO_Reactor::safe_dispatch (DWORD wait_status) { @@ -808,18 +966,22 @@ ACE_WFMO_Reactor::safe_dispatch (DWORD wait_status) { 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, @@ -827,6 +989,7 @@ ACE_WFMO_Reactor::notify (ACE_Event_Handler *event_handler, { return this->notify_handler_->notify (event_handler, mask, timeout); } + ACE_INLINE int ACE_WFMO_Reactor::register_handler (int signum, ACE_Event_Handler *new_sh, @@ -838,12 +1001,14 @@ ACE_WFMO_Reactor::register_handler (int 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) @@ -856,8 +1021,10 @@ ACE_WFMO_Reactor::register_handler (const ACE_Sig_Set &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, @@ -869,10 +1036,12 @@ ACE_WFMO_Reactor::remove_handler (int signum, 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) @@ -881,60 +1050,72 @@ ACE_WFMO_Reactor::remove_handler (const ACE_Sig_Set &sigset) #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, @@ -946,6 +1127,7 @@ ACE_WFMO_Reactor::ready_ops (ACE_Event_Handler *event_handler, ACE_UNUSED_ARG (ops); ACE_NOTSUP_RETURN (-1); } + ACE_INLINE int ACE_WFMO_Reactor::ready_ops (ACE_HANDLE handle, ACE_Reactor_Mask, @@ -956,32 +1138,39 @@ ACE_WFMO_Reactor::ready_ops (ACE_HANDLE 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 { @@ -994,14 +1183,18 @@ 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 index b839aced003..43cb20c4343 100644 --- a/dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp +++ b/dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp @@ -1,10 +1,14 @@ // $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" @@ -14,82 +18,100 @@ ACE_RCSID (ace, #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, @@ -113,9 +135,11 @@ ACE_WIN32_Asynch_Result::ACE_WIN32_Asynch_Result 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, @@ -125,6 +149,7 @@ ACE_WIN32_Asynch_Operation::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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) { @@ -134,14 +159,17 @@ ACE_WIN32_Asynch_Operation::open (const ACE_Handler::Proxy_Ptr &handler_proxy, } 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) { @@ -149,23 +177,29 @@ ACE_WIN32_Asynch_Operation::cancel (void) // 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), @@ -173,25 +207,31 @@ ACE_WIN32_Asynch_Operation::ACE_WIN32_Asynch_Operation (ACE_WIN32_Proactor *win3 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, @@ -217,6 +257,7 @@ ACE_WIN32_Asynch_Read_Stream_Result::ACE_WIN32_Asynch_Read_Stream_Result ( scatter_enabled_ (scatter_enabled) { } + void ACE_WIN32_Asynch_Read_Stream_Result::complete (size_t bytes_transferred, int success, @@ -228,6 +269,7 @@ ACE_WIN32_Asynch_Read_Stream_Result::complete (size_t 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); @@ -238,90 +280,111 @@ ACE_WIN32_Asynch_Read_Stream_Result::complete (size_t bytes_transferred, 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, @@ -332,11 +395,13 @@ ACE_WIN32_Asynch_Read_Stream::read (ACE_Message_Block &message_block, 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, @@ -349,13 +414,17 @@ ACE_WIN32_Asynch_Read_Stream::read (ACE_Message_Block &message_block, 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, @@ -366,24 +435,30 @@ ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, #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; @@ -396,6 +471,7 @@ ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, 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; @@ -406,15 +482,19 @@ ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, 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, @@ -428,10 +508,14 @@ ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, 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, @@ -439,10 +523,13 @@ ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, &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) @@ -452,19 +539,23 @@ ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, // 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); @@ -475,9 +566,11 @@ ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, 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) { @@ -489,7 +582,9 @@ ACE_WIN32_Asynch_Read_Stream::shared_read (ACE_WIN32_Asynch_Read_Stream_Result * } 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 (), @@ -499,6 +594,7 @@ ACE_WIN32_Asynch_Read_Stream::shared_read (ACE_WIN32_Asynch_Read_Stream_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) @@ -509,21 +605,26 @@ ACE_WIN32_Asynch_Read_Stream::shared_read (ACE_WIN32_Asynch_Read_Stream_Result * // 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, @@ -535,31 +636,37 @@ ACE_WIN32_Asynch_Read_Stream::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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, @@ -580,6 +687,7 @@ ACE_WIN32_Asynch_Write_Stream_Result::ACE_WIN32_Asynch_Write_Stream_Result ( gather_enabled_ (gather_enabled) { } + void ACE_WIN32_Asynch_Write_Stream_Result::complete (size_t bytes_transferred, int success, @@ -591,6 +699,7 @@ ACE_WIN32_Asynch_Write_Stream_Result::complete (size_t 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); @@ -601,90 +710,111 @@ ACE_WIN32_Asynch_Write_Stream_Result::complete (size_t bytes_transferred, 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, @@ -693,14 +823,17 @@ ACE_WIN32_Asynch_Write_Stream::write (ACE_Message_Block &message_block, 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_, @@ -712,13 +845,17 @@ ACE_WIN32_Asynch_Write_Stream::write (ACE_Message_Block &message_block, 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, @@ -729,21 +866,26 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, #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; @@ -756,6 +898,7 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, 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++; @@ -767,16 +910,20 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, } ++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_, @@ -789,8 +936,11 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, 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, @@ -798,10 +948,13 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, 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) @@ -811,19 +964,23 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, // 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); @@ -834,9 +991,11 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, 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) { @@ -847,7 +1006,9 @@ ACE_WIN32_Asynch_Write_Stream::shared_write (ACE_WIN32_Asynch_Write_Stream_Resul 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; @@ -875,6 +1036,7 @@ ACE_WIN32_Asynch_Write_Stream::shared_write (ACE_WIN32_Asynch_Write_Stream_Resul // 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) @@ -883,9 +1045,11 @@ ACE_WIN32_Asynch_Write_Stream::shared_write (ACE_WIN32_Asynch_Write_Stream_Resul // 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"), @@ -893,9 +1057,11 @@ ACE_WIN32_Asynch_Write_Stream::shared_write (ACE_WIN32_Asynch_Write_Stream_Resul 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, @@ -907,16 +1073,19 @@ ACE_WIN32_Asynch_Write_Stream::open (const ACE_Handler::Proxy_Ptr &handler_proxy 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, @@ -945,6 +1114,7 @@ ACE_WIN32_Asynch_Read_File_Result::ACE_WIN32_Asynch_Read_File_Result ( this->Offset = offset; this->OffsetHigh = offset_high; } + void ACE_WIN32_Asynch_Read_File_Result::complete (size_t bytes_transferred, int success, @@ -956,12 +1126,14 @@ ACE_WIN32_Asynch_Read_File_Result::complete (size_t 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 ()) @@ -969,100 +1141,125 @@ ACE_WIN32_Asynch_Read_File_Result::complete (size_t bytes_transferred, // 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 (), @@ -1070,6 +1267,7 @@ ACE_WIN32_Asynch_Read_File::ACE_WIN32_Asynch_Read_File (ACE_WIN32_Proactor *win3 ACE_WIN32_Asynch_Read_Stream (win32_proactor) { } + int ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block, size_t bytes_to_read, @@ -1082,6 +1280,7 @@ ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block, 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, @@ -1089,6 +1288,7 @@ ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block, 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_, @@ -1102,13 +1302,17 @@ ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block, 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, @@ -1120,29 +1324,38 @@ ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, { #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) { @@ -1150,8 +1363,10 @@ ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, 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_, @@ -1166,16 +1381,20 @@ ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, 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) @@ -1185,28 +1404,34 @@ ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, // 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, @@ -1220,6 +1445,7 @@ ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block, priority, signal_number); } + int ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, size_t bytes_to_read, @@ -1233,9 +1459,11 @@ ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, 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, @@ -1247,16 +1475,19 @@ ACE_WIN32_Asynch_Read_File::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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, @@ -1285,6 +1516,7 @@ ACE_WIN32_Asynch_Write_File_Result::ACE_WIN32_Asynch_Write_File_Result ( this->Offset = offset; this->OffsetHigh = offset_high; } + void ACE_WIN32_Asynch_Write_File_Result::complete (size_t bytes_transferred, int success, @@ -1296,12 +1528,14 @@ ACE_WIN32_Asynch_Write_File_Result::complete (size_t 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 ()) @@ -1309,99 +1543,124 @@ ACE_WIN32_Asynch_Write_File_Result::complete (size_t bytes_transferred, // 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 (), @@ -1409,6 +1668,7 @@ ACE_WIN32_Asynch_Write_File::ACE_WIN32_Asynch_Write_File (ACE_WIN32_Proactor *wi ACE_WIN32_Asynch_Write_Stream (win32_proactor) { } + int ACE_WIN32_Asynch_Write_File::write (ACE_Message_Block &message_block, size_t bytes_to_write, @@ -1421,12 +1681,14 @@ ACE_WIN32_Asynch_Write_File::write (ACE_Message_Block &message_block, 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_, @@ -1440,13 +1702,17 @@ ACE_WIN32_Asynch_Write_File::write (ACE_Message_Block &message_block, 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, @@ -1458,18 +1724,24 @@ ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, { #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 @@ -1481,9 +1753,11 @@ ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, 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; @@ -1494,8 +1768,10 @@ ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, 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_, @@ -1510,16 +1786,20 @@ ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, 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) @@ -1529,28 +1809,36 @@ ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, // 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, @@ -1564,6 +1852,7 @@ ACE_WIN32_Asynch_Write_File::write (ACE_Message_Block &message_block, priority, signal_number); } + int ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, size_t bytes_to_write, @@ -1577,9 +1866,11 @@ ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, 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, @@ -1591,36 +1882,43 @@ ACE_WIN32_Asynch_Write_File::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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, @@ -1646,6 +1944,7 @@ ACE_WIN32_Asynch_Accept_Result::ACE_WIN32_Asynch_Accept_Result ( accept_handle_ (accept_handle) { } + void ACE_WIN32_Asynch_Accept_Result::complete (size_t bytes_transferred, int success, @@ -1657,86 +1956,105 @@ ACE_WIN32_Asynch_Accept_Result::complete (size_t 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, @@ -1760,7 +2078,9 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, 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) { @@ -1768,6 +2088,7 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, 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) @@ -1789,6 +2110,7 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, // 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, @@ -1802,7 +2124,9 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, priority, signal_number), -1); + u_long bytes_read; + // Initiate the accept. int initiate_result = ::AcceptEx ((SOCKET) result->listen_handle (), (SOCKET) result->accept_handle (), @@ -1815,6 +2139,7 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, 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) @@ -1823,14 +2148,18 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, // 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, @@ -1850,12 +2179,15 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, 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, @@ -1867,27 +2199,33 @@ ACE_WIN32_Asynch_Accept::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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, @@ -1903,6 +2241,7 @@ ACE_WIN32_Asynch_Connect_Result::ACE_WIN32_Asynch_Connect_Result { ; } + void ACE_WIN32_Asynch_Connect_Result::complete (size_t bytes_transferred, int success, @@ -1914,74 +2253,91 @@ ACE_WIN32_Asynch_Connect_Result::complete (size_t 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 (), @@ -1989,27 +2345,33 @@ ACE_WIN32_Asynch_Connect::ACE_WIN32_Asynch_Connect (ACE_WIN32_Proactor * win32_p 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, @@ -2017,6 +2379,7 @@ ACE_WIN32_Asynch_Connect::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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_) @@ -2024,17 +2387,22 @@ ACE_WIN32_Asynch_Connect::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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, @@ -2045,11 +2413,13 @@ ACE_WIN32_Asynch_Connect::connect (ACE_HANDLE connect_handle, 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; @@ -2061,17 +2431,22 @@ ACE_WIN32_Asynch_Connect::connect (ACE_HANDLE connect_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, @@ -2081,8 +2456,10 @@ ACE_WIN32_Asynch_Connect::connect (ACE_HANDLE connect_handle, 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, @@ -2099,8 +2476,10 @@ ACE_WIN32_Asynch_Connect::connect (ACE_HANDLE connect_handle, this->post_result (result, true); } } + return 0; } + int ACE_WIN32_Asynch_Connect::post_result (ACE_WIN32_Asynch_Connect_Result * result, bool post_enable) { @@ -2112,6 +2491,7 @@ int ACE_WIN32_Asynch_Connect::post_result (ACE_WIN32_Asynch_Connect_Result * res // 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: ") @@ -2122,15 +2502,19 @@ int ACE_WIN32_Asynch_Connect::post_result (ACE_WIN32_Asynch_Connect_Result * res // 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, @@ -2138,6 +2522,7 @@ ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, int reuse_addr) { result->set_bytes_transferred (0); + ACE_HANDLE handle = result->connect_handle (); if (handle == ACE_INVALID_HANDLE) { @@ -2145,6 +2530,7 @@ ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, handle = ACE_OS::socket (protocol_family, SOCK_STREAM, 0); + // save it result->connect_handle (handle); if (handle == ACE_INVALID_HANDLE) @@ -2156,6 +2542,7 @@ ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, ACE_TEXT ("socket")), -1); } + // Reuse the address int one = 1; if (protocol_family != PF_UNIX && @@ -2174,6 +2561,7 @@ ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, -1); } } + if (local_sap != ACE_Addr::sap_any) { sockaddr * laddr = reinterpret_cast (local_sap.get_addr ()); @@ -2188,6 +2576,7 @@ ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, -1); } } + // set non blocking mode if (ACE::set_flags (handle, ACE_NONBLOCK) != 0) { @@ -2198,24 +2587,29 @@ ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, 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 // @@ -2227,57 +2621,76 @@ ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, // // 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) @@ -2285,101 +2698,126 @@ ACE_WIN32_Asynch_Connect::close (void) 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, @@ -2411,6 +2849,7 @@ ACE_WIN32_Asynch_Transmit_File_Result::ACE_WIN32_Asynch_Transmit_File_Result ( flags_ (flags) { } + void ACE_WIN32_Asynch_Transmit_File_Result::complete (size_t bytes_transferred, int success, @@ -2422,6 +2861,7 @@ ACE_WIN32_Asynch_Transmit_File_Result::complete (size_t 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. @@ -2431,84 +2871,102 @@ ACE_WIN32_Asynch_Transmit_File_Result::complete (size_t bytes_transferred, 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, @@ -2522,6 +2980,7 @@ ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, 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) { @@ -2530,6 +2989,7 @@ ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, } 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_, @@ -2546,9 +3006,11 @@ ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, 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 (), @@ -2560,6 +3022,7 @@ ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, 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) @@ -2568,11 +3031,14 @@ ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, // 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, @@ -2595,12 +3061,15 @@ ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, 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, @@ -2612,31 +3081,37 @@ ACE_WIN32_Asynch_Transmit_File::open (const ACE_Handler::Proxy_Ptr &handler_prox 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 @@ -2644,79 +3119,95 @@ ACE_WIN32_Asynch_Read_Dgram_Result::remote_address (ACE_Addr& addr) const 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, @@ -2739,10 +3230,13 @@ ACE_WIN32_Asynch_Read_Dgram_Result::ACE_WIN32_Asynch_Read_Dgram_Result ( 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, @@ -2754,34 +3248,45 @@ ACE_WIN32_Asynch_Read_Dgram_Result::complete (size_t 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, @@ -2792,23 +3297,30 @@ ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, 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; @@ -2821,6 +3333,7 @@ ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, 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++; @@ -2831,11 +3344,13 @@ ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, 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, @@ -2850,6 +3365,7 @@ ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, priority, signal_number), -1); + // do the scatter/gather recv ssize_t initiate_result = ACE_OS::recvfrom (result->handle (), iov, @@ -2871,19 +3387,23 @@ ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, // 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 { @@ -2891,11 +3411,14 @@ ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, // 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, @@ -2907,98 +3430,118 @@ ACE_WIN32_Asynch_Read_Dgram::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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, @@ -3024,6 +3567,7 @@ ACE_WIN32_Asynch_Write_Dgram_Result::ACE_WIN32_Asynch_Write_Dgram_Result ( handle_ (handle) { } + void ACE_WIN32_Asynch_Write_Dgram_Result::complete (size_t bytes_transferred, int success, @@ -3035,32 +3579,42 @@ ACE_WIN32_Asynch_Write_Dgram_Result::complete (size_t 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, @@ -3071,17 +3625,23 @@ ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, 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) @@ -3091,23 +3651,27 @@ ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, 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, @@ -3121,7 +3685,9 @@ ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, priority, signal_number), -1); + // do the scatter/gather send + ssize_t initiate_result = ACE_OS::sendto (result->handle (), iov, iovcnt, @@ -3132,6 +3698,7 @@ ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, result, 0); + if (initiate_result == SOCKET_ERROR) { // If initiate failed, check for a bad error. @@ -3143,19 +3710,23 @@ ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, // 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 { @@ -3163,11 +3734,14 @@ ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, // 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, @@ -3179,22 +3753,27 @@ ACE_WIN32_Asynch_Write_Dgram::open (const ACE_Handler::Proxy_Ptr &handler_proxy, 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 index 76af1142d30..a1cf22ae0a0 100644 --- a/dep/ACE_wrappers/ace/WIN32_Asynch_IO.h +++ b/dep/ACE_wrappers/ace/WIN32_Asynch_IO.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file WIN32_Asynch_IO.h @@ -20,24 +21,32 @@ * @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 * @@ -56,42 +65,58 @@ class ACE_Export ACE_WIN32_Asynch_Result : public virtual ACE_Asynch_Result_Impl { /// 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, @@ -101,19 +126,26 @@ protected: 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 * @@ -134,29 +166,39 @@ public: 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 * @@ -168,47 +210,65 @@ class ACE_Export ACE_WIN32_Asynch_Read_Stream_Result : public virtual ACE_Asynch { /// 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. @@ -221,22 +281,29 @@ protected: 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 * @@ -252,9 +319,11 @@ protected: 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, @@ -262,6 +331,7 @@ public: 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. @@ -271,11 +341,14 @@ public: 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), @@ -286,19 +359,23 @@ public: 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 * @@ -310,47 +387,65 @@ class ACE_Export ACE_WIN32_Asynch_Write_Stream_Result : public virtual ACE_Async { /// 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. @@ -363,23 +458,30 @@ protected: 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 * @@ -399,6 +501,7 @@ class ACE_Export ACE_WIN32_Asynch_Write_Stream : public virtual ACE_Asynch_Write 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, @@ -406,6 +509,7 @@ public: 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. @@ -415,11 +519,15 @@ public: 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), @@ -430,19 +538,23 @@ public: 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 * @@ -454,50 +566,68 @@ class ACE_Export ACE_WIN32_Asynch_Read_File_Result : public virtual ACE_Asynch_R { /// 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. @@ -512,14 +642,17 @@ protected: 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 * @@ -538,9 +671,11 @@ protected: 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 @@ -553,6 +688,7 @@ public: 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. @@ -568,11 +704,14 @@ public: 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), @@ -583,14 +722,17 @@ public: 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 @@ -602,6 +744,7 @@ private: 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. @@ -612,6 +755,7 @@ private: int priority, int signal_number = 0); }; + /** * @class ACE_WIN32_Asynch_Write_File_Result * @@ -634,49 +778,67 @@ class ACE_Export ACE_WIN32_Asynch_Write_File_Result : public virtual ACE_Asynch_ { /// 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. @@ -691,14 +853,17 @@ protected: 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 * @@ -717,6 +882,7 @@ class ACE_Export ACE_WIN32_Asynch_Write_File : public virtual ACE_Asynch_Write_F 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 @@ -729,6 +895,7 @@ public: 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. @@ -743,11 +910,14 @@ public: 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), @@ -758,14 +928,17 @@ public: 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 @@ -777,6 +950,7 @@ private: 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. @@ -787,6 +961,7 @@ private: int priority, int signal_number = 0); }; + /** * @class ACE_WIN32_Asynch_Accept_Result * @@ -802,47 +977,65 @@ class ACE_Export ACE_WIN32_Asynch_Accept_Result : public virtual ACE_Asynch_Acce { /// 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. @@ -855,22 +1048,29 @@ protected: 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 * @@ -889,6 +1089,7 @@ class ACE_Export ACE_WIN32_Asynch_Accept : public virtual ACE_Asynch_Accept_Impl 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 @@ -907,11 +1108,14 @@ public: 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), @@ -922,15 +1126,18 @@ public: 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 * @@ -946,40 +1153,56 @@ class ACE_Export ACE_WIN32_Asynch_Connect_Result : public virtual ACE_Asynch_Con { /// 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. @@ -989,18 +1212,23 @@ protected: 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 */ @@ -1010,10 +1238,13 @@ class ACE_Export ACE_WIN32_Asynch_Connect : 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 @@ -1023,6 +1254,7 @@ public: ACE_HANDLE handle, const void *completion_key, ACE_Proactor *proactor = 0); + /** * Start an asynchronous connect. * @@ -1039,37 +1271,47 @@ public: 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 @@ -1085,19 +1327,24 @@ private: * 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 * @@ -1114,52 +1361,72 @@ class ACE_Export ACE_WIN32_Asynch_Transmit_File_Result : public virtual ACE_Asyn { /// 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. @@ -1176,28 +1443,37 @@ protected: 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 * @@ -1223,6 +1499,7 @@ class ACE_Export ACE_WIN32_Asynch_Transmit_File : public virtual ACE_Asynch_Tran 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 @@ -1244,11 +1521,14 @@ public: 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), @@ -1259,15 +1539,18 @@ public: 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 * @@ -1279,50 +1562,70 @@ class ACE_Export ACE_WIN32_Asynch_Read_Dgram_Result : public virtual ACE_Asynch_ { /// 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. @@ -1336,25 +1639,34 @@ protected: 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 * @@ -1374,8 +1686,10 @@ class ACE_Export ACE_WIN32_Asynch_Read_Dgram : public virtual ACE_Asynch_Read_Dg 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 @@ -1400,9 +1714,11 @@ public: 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), @@ -1413,18 +1729,22 @@ public: 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 * @@ -1436,47 +1756,65 @@ class ACE_Export ACE_WIN32_Asynch_Write_Dgram_Result : public virtual ACE_Asynch { /// 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. @@ -1489,23 +1827,30 @@ protected: 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 * @@ -1525,8 +1870,10 @@ class ACE_Export ACE_WIN32_Asynch_Write_Dgram : public virtual ACE_Asynch_Write_ 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 @@ -1551,9 +1898,12 @@ public: 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), @@ -1564,19 +1914,24 @@ public: 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 index a7cb45a686e..dceb8336277 100644 --- a/dep/ACE_wrappers/ace/WIN32_Proactor.cpp +++ b/dep/ACE_wrappers/ace/WIN32_Proactor.cpp @@ -1,13 +1,19 @@ // $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 * @@ -17,6 +23,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL */ class ACE_WIN32_Wakeup_Completion : public ACE_WIN32_Asynch_Result { + public: /// Constructor. ACE_WIN32_Wakeup_Completion (ACE_Handler::Proxy_Ptr &handler_proxy, @@ -24,14 +31,17 @@ public: 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), @@ -48,18 +58,23 @@ ACE_WIN32_Proactor::ACE_WIN32_Proactor (size_t number_of_threads, 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) { @@ -67,11 +82,13 @@ ACE_WIN32_Proactor::close (void) 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_, @@ -79,23 +96,30 @@ ACE_WIN32_Proactor::close (void) &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_, @@ -119,6 +143,7 @@ ACE_WIN32_Proactor::register_handle (ACE_HANDLE handle, } return 0; } + ACE_Asynch_Read_Stream_Impl * ACE_WIN32_Proactor::create_asynch_read_stream (void) { @@ -128,6 +153,7 @@ ACE_WIN32_Proactor::create_asynch_read_stream (void) 0); return implementation; } + ACE_Asynch_Write_Stream_Impl * ACE_WIN32_Proactor::create_asynch_write_stream (void) { @@ -137,6 +163,7 @@ ACE_WIN32_Proactor::create_asynch_write_stream (void) 0); return implementation; } + ACE_Asynch_Read_Dgram_Impl * ACE_WIN32_Proactor::create_asynch_read_dgram (void) { @@ -146,6 +173,7 @@ ACE_WIN32_Proactor::create_asynch_read_dgram (void) 0); return implementation; } + ACE_Asynch_Write_Dgram_Impl * ACE_WIN32_Proactor::create_asynch_write_dgram (void) { @@ -155,6 +183,7 @@ ACE_WIN32_Proactor::create_asynch_write_dgram (void) 0); return implementation; } + ACE_Asynch_Read_File_Impl * ACE_WIN32_Proactor::create_asynch_read_file (void) { @@ -164,6 +193,7 @@ ACE_WIN32_Proactor::create_asynch_read_file (void) 0); return implementation; } + ACE_Asynch_Write_File_Impl * ACE_WIN32_Proactor::create_asynch_write_file (void) { @@ -173,6 +203,7 @@ ACE_WIN32_Proactor::create_asynch_write_file (void) 0); return implementation; } + ACE_Asynch_Accept_Impl * ACE_WIN32_Proactor::create_asynch_accept (void) { @@ -182,6 +213,7 @@ ACE_WIN32_Proactor::create_asynch_accept (void) 0); return implementation; } + ACE_Asynch_Connect_Impl * ACE_WIN32_Proactor::create_asynch_connect (void) { @@ -191,6 +223,7 @@ ACE_WIN32_Proactor::create_asynch_connect (void) 0); return implementation; } + ACE_Asynch_Transmit_File_Impl * ACE_WIN32_Proactor::create_asynch_transmit_file (void) { @@ -200,6 +233,7 @@ ACE_WIN32_Proactor::create_asynch_transmit_file (void) 0); return implementation; } + ACE_Asynch_Read_Stream_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -224,6 +258,7 @@ ACE_WIN32_Proactor::create_asynch_read_stream_result 0); return implementation; } + ACE_Asynch_Write_Stream_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -248,6 +283,7 @@ ACE_WIN32_Proactor::create_asynch_write_stream_result 0); return implementation; } + ACE_Asynch_Read_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -276,6 +312,7 @@ ACE_WIN32_Proactor::create_asynch_read_file_result 0); return implementation; } + ACE_Asynch_Write_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -304,6 +341,7 @@ ACE_WIN32_Proactor::create_asynch_write_file_result 0); return implementation; } + ACE_Asynch_Read_Dgram_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -332,6 +370,7 @@ ACE_WIN32_Proactor::create_asynch_read_dgram_result 0); return implementation; } + ACE_Asynch_Write_Dgram_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -358,6 +397,7 @@ ACE_WIN32_Proactor::create_asynch_write_dgram_result 0); return implementation; } + ACE_Asynch_Accept_Result_Impl * ACE_WIN32_Proactor::create_asynch_accept_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -384,6 +424,7 @@ ACE_WIN32_Proactor::create_asynch_accept_result 0); return implementation; } + ACE_Asynch_Connect_Result_Impl * ACE_WIN32_Proactor::create_asynch_connect_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -404,6 +445,7 @@ ACE_WIN32_Proactor::create_asynch_connect_result 0); return implementation; } + ACE_Asynch_Transmit_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_transmit_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, @@ -438,6 +480,7 @@ ACE_WIN32_Proactor::create_asynch_transmit_file_result 0); return implementation; } + ACE_Asynch_Result_Impl * ACE_WIN32_Proactor::create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy, const void *act, @@ -457,32 +500,40 @@ ACE_WIN32_Proactor::create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_p 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 { @@ -491,6 +542,7 @@ ACE_WIN32_Proactor::get_handle (void) const else return 0; } + int ACE_WIN32_Proactor::handle_events (ACE_Time_Value &wait_time) { @@ -498,17 +550,20 @@ ACE_WIN32_Proactor::handle_events (ACE_Time_Value &wait_time) 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, @@ -518,16 +573,19 @@ ACE_WIN32_Proactor::handle_events (unsigned long 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, @@ -540,12 +598,15 @@ ACE_WIN32_Proactor::handle_events (unsigned long milli_seconds) { // 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_ @@ -559,8 +620,10 @@ ACE_WIN32_Proactor::handle_events (unsigned long milli_seconds) // 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, @@ -568,6 +631,7 @@ ACE_WIN32_Proactor::handle_events (unsigned long milli_seconds) } return 1; } + void ACE_WIN32_Proactor::application_specific_code (ACE_WIN32_Asynch_Result *asynch_result, size_t bytes_transferred, @@ -588,18 +652,22 @@ ACE_WIN32_Proactor::application_specific_code (ACE_WIN32_Asynch_Result *asynch_r 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 @@ -607,7 +675,9 @@ ACE_WIN32_Proactor::post_completion (ACE_WIN32_Asynch_Result *result) 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 @@ -616,6 +686,7 @@ ACE_WIN32_Proactor::post_completion (ACE_WIN32_Asynch_Result *result) ) == FALSE) { delete result; + if (ACE::debug ()) { ACE_DEBUG ((LM_ERROR, @@ -624,47 +695,58 @@ ACE_WIN32_Proactor::post_completion (ACE_WIN32_Asynch_Result *result) } 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, @@ -678,6 +760,7 @@ ACE_WIN32_Asynch_Timer::ACE_WIN32_Asynch_Timer time_ (tv) { } + void ACE_WIN32_Asynch_Timer::complete (size_t, int, @@ -688,6 +771,7 @@ ACE_WIN32_Asynch_Timer::complete (size_t, 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, @@ -699,9 +783,11 @@ ACE_WIN32_Wakeup_Completion::ACE_WIN32_Wakeup_Completion (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 */, @@ -712,6 +798,8 @@ ACE_WIN32_Wakeup_Completion::complete (size_t /* bytes_transferred */, 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 index 3caccc45d95..1035021fb6d 100644 --- a/dep/ACE_wrappers/ace/WIN32_Proactor.h +++ b/dep/ACE_wrappers/ace/WIN32_Proactor.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file WIN32_Proactor.h @@ -12,24 +13,33 @@ * @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 * @@ -42,18 +52,23 @@ class ACE_WIN32_Proactor_Timer_Handler; 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 @@ -61,6 +76,7 @@ public: * 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 @@ -68,6 +84,7 @@ public: * 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, @@ -77,16 +94,22 @@ public: * 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); @@ -96,8 +119,10 @@ public: 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, @@ -106,6 +131,7 @@ public: 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, @@ -114,6 +140,7 @@ public: 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, @@ -124,6 +151,7 @@ public: 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, @@ -134,6 +162,7 @@ public: 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, @@ -145,6 +174,7 @@ public: 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, @@ -155,6 +185,7 @@ public: 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, @@ -164,6 +195,7 @@ public: 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, @@ -171,6 +203,7 @@ public: 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, @@ -184,6 +217,7 @@ public: 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, @@ -192,52 +226,65 @@ public: 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 * @@ -251,6 +298,7 @@ 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, @@ -259,15 +307,19 @@ protected: 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 index 60633ccc59a..59d5649e508 100644 --- a/dep/ACE_wrappers/ace/XML_Svc_Conf.cpp +++ b/dep/ACE_wrappers/ace/XML_Svc_Conf.cpp @@ -1,10 +1,16 @@ // $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 index cd76210dc0d..5455657ece2 100644 --- a/dep/ACE_wrappers/ace/XML_Svc_Conf.h +++ b/dep/ACE_wrappers/ace/XML_Svc_Conf.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file XML_Svc_Conf.h @@ -9,15 +10,22 @@ */ //============================================================================= + #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 * @@ -35,16 +43,24 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * */ + 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 index 2a7e8a335ae..ac3443ee8b5 100644 --- a/dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp +++ b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp @@ -1,12 +1,19 @@ // $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 { @@ -14,11 +21,14 @@ ACE_XTI_ATM_Mcast::dump (void) const 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, @@ -26,10 +36,12 @@ ACE_XTI_ATM_Mcast::add_leaf (ACE_TLI_Stream ¤t_stream, 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) @@ -49,8 +61,11 @@ ACE_XTI_ATM_Mcast::add_leaf (ACE_TLI_Stream ¤t_stream, 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 index 7327fca80ac..9cd01f8ac0b 100644 --- a/dep/ACE_wrappers/ace/XTI_ATM_Mcast.h +++ b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file XTI_ATM_Mcast.h @@ -9,17 +10,24 @@ */ //============================================================================= + #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 * @@ -32,6 +40,7 @@ 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 @@ -59,6 +68,7 @@ public: 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 @@ -86,6 +96,7 @@ public: 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 @@ -101,19 +112,27 @@ public: 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 index aa5d9c3240f..b182bb41b20 100644 --- a/dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl +++ b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl @@ -1,7 +1,9 @@ // -*- 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, @@ -24,10 +26,12 @@ ACE_XTI_ATM_Mcast::ACE_XTI_ATM_Mcast (ACE_TLI_Stream &new_stream, && 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, @@ -57,4 +61,5 @@ ACE_XTI_ATM_Mcast::connect (ACE_TLI_Stream &new_stream, udata, opt); } + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ace.rc b/dep/ACE_wrappers/ace/ace.rc index 946f20c7c7c..54792491900 100644 --- a/dep/ACE_wrappers/ace/ace.rc +++ b/dep/ACE_wrappers/ace/ace.rc @@ -1,4 +1,5 @@ #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 @@ -27,6 +28,7 @@ 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 diff --git a/dep/ACE_wrappers/ace/ace_wchar.cpp b/dep/ACE_wrappers/ace/ace_wchar.cpp index 4a006b50b24..4f7ca485585 100644 --- a/dep/ACE_wrappers/ace/ace_wchar.cpp +++ b/dep/ACE_wrappers/ace/ace_wchar.cpp @@ -1,13 +1,18 @@ // -*- 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 index 0f399635d68..75afa83968b 100644 --- a/dep/ACE_wrappers/ace/ace_wchar.h +++ b/dep/ACE_wrappers/ace/ace_wchar.h @@ -1,4 +1,5 @@ //* -*- C++ -*- */ + //============================================================================= /** * @file ace_wchar.h @@ -8,12 +9,16 @@ * @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. @@ -25,6 +30,7 @@ # 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 @@ -33,20 +39,25 @@ # 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 */ @@ -71,16 +82,19 @@ # 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) @@ -88,11 +102,14 @@ using std::size_t; # 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 @@ -101,6 +118,7 @@ using std::size_t; # 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; @@ -126,27 +144,36 @@ typedef wchar_t ACE_ANTI_TCHAR; # 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 * @@ -161,23 +188,30 @@ 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 * @@ -192,29 +226,39 @@ 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 @@ -223,6 +267,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL #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 @@ -273,6 +318,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL #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 @@ -280,6 +326,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL #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 @@ -332,6 +379,8 @@ ACE_END_VERSIONED_NAMESPACE_DECL #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 index b3e7078f458..744b44f5e73 100644 --- a/dep/ACE_wrappers/ace/ace_wchar.inl +++ b/dep/ACE_wrappers/ace/ace_wchar.inl @@ -1,29 +1,37 @@ // -*- 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, @@ -38,13 +46,16 @@ ACE_Wide_To_Ascii::convert (const wchar_t *wstr) 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) @@ -55,6 +66,7 @@ ACE_Wide_To_Ascii::convert (const wchar_t *wstr) 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)) { @@ -64,6 +76,7 @@ ACE_Wide_To_Ascii::convert (const wchar_t *wstr) wchar_t *t = const_cast (wstr); str[i] = static_cast (*(t + i)); } + return str; } char *str = new char[ACE_MAX_ICONV_BUFFER-lensi]; @@ -77,6 +90,7 @@ ACE_Wide_To_Ascii::convert (const wchar_t *wstr) # endif /* ACE_WIN32 */ return str; } + inline ACE_Wide_To_Ascii::ACE_Wide_To_Ascii (const wchar_t *s) { @@ -88,31 +102,37 @@ ACE_Wide_To_Ascii::ACE_Wide_To_Ascii (const wchar_t *s) #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) @@ -123,6 +143,7 @@ ACE_Ascii_To_Wide::convert (const char *str) 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)]; @@ -130,6 +151,7 @@ ACE_Ascii_To_Wide::convert (const char *str) 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)]; @@ -143,6 +165,7 @@ ACE_Ascii_To_Wide::convert (const char *str) # endif /* ACE_WIN32 */ return wstr; } + inline ACE_Ascii_To_Wide::ACE_Ascii_To_Wide (const char *s) { @@ -154,5 +177,7 @@ ACE_Ascii_To_Wide::ACE_Ascii_To_Wide (const char *s) #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 index 5b9cacc8fe5..3f4c6c14a08 100644 --- a/dep/ACE_wrappers/ace/checked_iterator.h +++ b/dep/ACE_wrappers/ace/checked_iterator.h @@ -1,6 +1,8 @@ // -*- C++ -*- + #ifndef ACE_CHECKED_ITERATOR_H #define ACE_CHECKED_ITERATOR_H + /** * @file checked_iterator.h * @@ -29,10 +31,12 @@ * * @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 && _MSC_FULL_VER < 160020506) template stdext::checked_array_iterator @@ -50,5 +54,6 @@ ACE_make_checked_array_iterator (PTR buf, size_t /* len */) return buf; } # endif /* _MSC_VER >= 1400 */ + #endif /* ACE_CHECKED_ITERATOR_H */ diff --git a/dep/ACE_wrappers/ace/config-WinCE.h b/dep/ACE_wrappers/ace/config-WinCE.h index 754899960eb..83db197b8e4 100644 --- a/dep/ACE_wrappers/ace/config-WinCE.h +++ b/dep/ACE_wrappers/ace/config-WinCE.h @@ -1,21 +1,28 @@ // $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) @@ -28,9 +35,11 @@ # 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. @@ -39,18 +48,22 @@ // 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 @@ -67,57 +80,77 @@ #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 @@ -134,13 +167,16 @@ //#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 @@ -155,6 +191,7 @@ #define ACE_LACKS_SYSTEM #define ACE_LACKS_SIGACTION #define ACE_LACKS_PIPE + //#define ACE_LACKS_CUSERID //#define ACE_LACKS_CHDIR #define ACE_LACKS_ENV @@ -165,29 +202,40 @@ #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 index b0955aa2107..5c1972b5675 100644 --- a/dep/ACE_wrappers/ace/config-aix-5.x.h +++ b/dep/ACE_wrappers/ace/config-aix-5.x.h @@ -1,8 +1,10 @@ // $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 @@ -10,6 +12,7 @@ #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. @@ -23,6 +26,7 @@ #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) @@ -35,26 +39,32 @@ // # 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 @@ -71,10 +81,12 @@ # 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 @@ -83,116 +95,157 @@ # 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). @@ -202,11 +255,15 @@ #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. @@ -217,10 +274,12 @@ // 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 @@ -229,20 +288,25 @@ # 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 @@ -251,10 +315,13 @@ (!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 @@ -262,5 +329,6 @@ #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 index 781a5c9fba1..927bd14919b 100644 --- a/dep/ACE_wrappers/ace/config-all.h +++ b/dep/ACE_wrappers/ace/config-all.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file config-all.h @@ -10,13 +11,18 @@ * @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 @@ -29,12 +35,16 @@ # 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 @@ -44,12 +54,14 @@ # 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 @@ -59,15 +71,20 @@ # 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 index 25b84bc4be8..5c80c872ad7 100644 --- a/dep/ACE_wrappers/ace/config-borland-common.h +++ b/dep/ACE_wrappers/ace/config-borland-common.h @@ -1,9 +1,12 @@ // -*- 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) @@ -11,6 +14,7 @@ #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 @@ -19,13 +23,16 @@ # 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 @@ -54,6 +61,7 @@ # 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 index 825642c408c..87fe263503d 100644 --- a/dep/ACE_wrappers/ace/config-cray.h +++ b/dep/ACE_wrappers/ace/config-cray.h @@ -1,8 +1,10 @@ /* -*- 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 @@ -10,63 +12,105 @@ 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 @@ -81,10 +125,14 @@ #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 @@ -96,18 +144,26 @@ #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 @@ -117,7 +173,9 @@ # 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 @@ -127,21 +185,30 @@ # 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 index 94f5a8cdd9c..6d467d64964 100644 --- a/dep/ACE_wrappers/ace/config-cxx-common.h +++ b/dep/ACE_wrappers/ace/config-cxx-common.h @@ -1,12 +1,15 @@ // -*- 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 @@ -14,6 +17,7 @@ # 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 @@ -28,8 +32,10 @@ # 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 @@ -38,6 +44,7 @@ # 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) @@ -45,30 +52,36 @@ // 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 index 4551b47b48f..e6683e29795 100644 --- a/dep/ACE_wrappers/ace/config-cygwin32.h +++ b/dep/ACE_wrappers/ace/config-cygwin32.h @@ -1,21 +1,29 @@ /* -*- 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) @@ -24,18 +32,25 @@ #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 @@ -43,6 +58,7 @@ # 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 @@ -64,32 +80,49 @@ #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 @@ -107,35 +140,49 @@ #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 @@ -147,10 +194,14 @@ # 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 index dd0c14c506f..d4e8a068e43 100644 --- a/dep/ACE_wrappers/ace/config-doxygen.h +++ b/dep/ACE_wrappers/ace/config-doxygen.h @@ -1,4 +1,5 @@ // -*- C++ -*- + /** * This is a configuration file to define all the macros that Doxygen * needs @@ -13,10 +14,13 @@ */ #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 @@ -37,27 +41,37 @@ #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 @@ -66,29 +80,42 @@ #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 index d392c9e9b77..d5ead871030 100644 --- a/dep/ACE_wrappers/ace/config-freebsd.h +++ b/dep/ACE_wrappers/ace/config-freebsd.h @@ -1,12 +1,16 @@ /* -*- 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 @@ -14,23 +18,30 @@ // 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 @@ -38,7 +49,9 @@ #define _THREAD_SAFE #endif /* _THREAD_SAFE */ #endif + #define ACE_HAS_GPERF + #if (__FreeBSD_version < 420000) #define ACE_LACKS_GETPGID #define ACE_LACKS_SETPGID @@ -46,6 +59,7 @@ #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 @@ -53,6 +67,7 @@ #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 @@ -62,7 +77,9 @@ #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, @@ -71,98 +88,135 @@ enum schedparam_policy { 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 @@ -170,31 +224,39 @@ extern "C" { char * cuserid (char *s); } # 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 @@ -202,17 +264,22 @@ extern "C" { char * cuserid (char *s); } #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 index 86ff313e357..ff365a5890d 100644 --- a/dep/ACE_wrappers/ace/config-g++-common.h +++ b/dep/ACE_wrappers/ace/config-g++-common.h @@ -1,12 +1,15 @@ // -*- 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 @@ -14,16 +17,20 @@ #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 @@ -32,6 +39,7 @@ #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)) @@ -39,9 +47,11 @@ # 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 @@ -50,17 +60,21 @@ // 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) @@ -73,6 +87,7 @@ # 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. @@ -86,6 +101,7 @@ # 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 ; @@ -99,12 +115,15 @@ 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. @@ -112,6 +131,7 @@ # 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 index 01b390d63ab..bb169ba06ba 100644 --- a/dep/ACE_wrappers/ace/config-ghs-common.h +++ b/dep/ACE_wrappers/ace/config-ghs-common.h @@ -1,20 +1,26 @@ /* -*- 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 @@ -24,12 +30,15 @@ # 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 index 532153a06bc..17de9afa38c 100644 --- a/dep/ACE_wrappers/ace/config-hpux-11.00.h +++ b/dep/ACE_wrappers/ace/config-hpux-11.00.h @@ -1,19 +1,28 @@ /* -*- 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" @@ -24,6 +33,7 @@ # 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. @@ -46,44 +56,58 @@ // 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. @@ -92,11 +116,13 @@ # 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 @@ -106,17 +132,20 @@ # 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 @@ -125,70 +154,97 @@ #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 @@ -196,66 +252,96 @@ // 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") @@ -267,16 +353,20 @@ #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. @@ -286,15 +376,18 @@ #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 @@ -305,6 +398,7 @@ #define ACE_HAS_CONFLICTING_XTI_MACROS /* Platform provides header */ #define ACE_HAS_SYS_XTI_H 1 + ///////////////////////////////////////////////////////////////////////// // // Threads information. @@ -315,6 +409,7 @@ // 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 @@ -322,10 +417,13 @@ #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... @@ -338,11 +436,15 @@ # 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 index a969f016c4e..290d2b60fc6 100644 --- a/dep/ACE_wrappers/ace/config-icc-common.h +++ b/dep/ACE_wrappers/ace/config-icc-common.h @@ -1,9 +1,11 @@ // -*- 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 @@ -11,6 +13,7 @@ # 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) @@ -23,6 +26,7 @@ # 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. @@ -36,6 +40,7 @@ # 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 ; @@ -49,11 +54,13 @@ 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 @@ -62,12 +69,15 @@ # 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 @@ -76,23 +86,29 @@ // 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 index ceea3389eef..195027f94ec 100644 --- a/dep/ACE_wrappers/ace/config-integritySCA.h +++ b/dep/ACE_wrappers/ace/config-integritySCA.h @@ -1,6 +1,8 @@ // -*- 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 @@ -8,6 +10,7 @@ * * $Id: config-integritySCA.h 81935 2008-06-12 22:01:53Z jtc $ */ + #define ghs /* compilation defines */ #define ACE_LACKS_GETPGID @@ -22,6 +25,7 @@ #define ACE_LACKS_GETUID #define ACE_LACKS_GETEGID #define ACE_LACKS_GETGID + #ifndef ACE_HAS_EXCEPTIONS #define ACE_HAS_EXCEPTIONS #endif @@ -33,17 +37,24 @@ #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 @@ -56,16 +67,22 @@ #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 @@ -125,9 +142,11 @@ #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 */ @@ -145,20 +164,28 @@ #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 @@ -182,10 +209,13 @@ extern "C" #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 @@ -193,9 +223,12 @@ int unlink(const char *); #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 index a7ed81d037a..a47126ff5f2 100644 --- a/dep/ACE_wrappers/ace/config-irix6.5.x-sgic++.h +++ b/dep/ACE_wrappers/ace/config-irix6.5.x-sgic++.h @@ -1,14 +1,19 @@ // -*- 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 index 63a1c906c1f..ab5413412c1 100644 --- a/dep/ACE_wrappers/ace/config-irix6.x-common.h +++ b/dep/ACE_wrappers/ace/config-irix6.x-common.h @@ -9,20 +9,27 @@ // 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. @@ -42,93 +49,130 @@ #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 @@ -139,53 +183,76 @@ #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 index ca25e0bd1ea..91276bdbaad 100644 --- a/dep/ACE_wrappers/ace/config-irix6.x-g++.h +++ b/dep/ACE_wrappers/ace/config-irix6.x-g++.h @@ -1,18 +1,24 @@ /* -*- 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 index 13b23eb6040..d832995ea8c 100644 --- a/dep/ACE_wrappers/ace/config-irix6.x-sgic++.h +++ b/dep/ACE_wrappers/ace/config-irix6.x-sgic++.h @@ -1,29 +1,37 @@ /* -*- 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 index a0dda28c282..6743c53adfc 100644 --- a/dep/ACE_wrappers/ace/config-linux-common.h +++ b/dep/ACE_wrappers/ace/config-linux-common.h @@ -1,35 +1,46 @@ /* -*- 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 @@ -38,7 +49,9 @@ # 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) @@ -50,7 +63,9 @@ # 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 @@ -61,10 +76,12 @@ # 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 @@ -75,23 +92,28 @@ // 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. @@ -99,6 +121,7 @@ # 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+ */ @@ -107,6 +130,7 @@ # 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. @@ -119,6 +143,7 @@ # 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 @@ -126,12 +151,15 @@ // 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__) @@ -176,130 +204,177 @@ # 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. @@ -307,20 +382,27 @@ # 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 @@ -334,6 +416,7 @@ # 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. @@ -350,6 +433,7 @@ # 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 @@ -358,6 +442,8 @@ # 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 index dfa320d5a03..4c5dc3c4bdb 100644 --- a/dep/ACE_wrappers/ace/config-linux.h +++ b/dep/ACE_wrappers/ace/config-linux.h @@ -1,24 +1,32 @@ // -*- 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) @@ -28,31 +36,41 @@ # 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 index fea774c648a..5af65ccc557 100644 --- a/dep/ACE_wrappers/ace/config-lite.h +++ b/dep/ACE_wrappers/ace/config-lite.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file config-lite.h @@ -14,35 +15,48 @@ * 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) @@ -52,16 +66,20 @@ 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 @@ -72,10 +90,15 @@ typedef void (*ACE_INIT_LOG_MSG_HOOK) (ACE_OS_Log_Msg_Attributes &attr ); 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 @@ -135,6 +158,8 @@ ACE_END_VERSIONED_NAMESPACE_DECL 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 index 137b142078a..baeafa88bb8 100644 --- a/dep/ACE_wrappers/ace/config-lynxos.h +++ b/dep/ACE_wrappers/ace/config-lynxos.h @@ -1,20 +1,27 @@ // $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__) @@ -24,6 +31,7 @@ // 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 @@ -95,8 +103,10 @@ #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 @@ -109,20 +119,25 @@ # 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 @@ -132,14 +147,17 @@ # 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 index e567017ceea..ef9ffc59a08 100644 --- a/dep/ACE_wrappers/ace/config-macosx-leopard.h +++ b/dep/ACE_wrappers/ace/config-macosx-leopard.h @@ -1,11 +1,15 @@ /* -*- 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. @@ -15,14 +19,19 @@ # 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 @@ -30,98 +39,140 @@ #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 @@ -131,14 +182,19 @@ # 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 @@ -146,6 +202,7 @@ #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 @@ -159,10 +216,13 @@ #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 index 443800d0ac8..e2b3361752f 100644 --- a/dep/ACE_wrappers/ace/config-macosx-panther.h +++ b/dep/ACE_wrappers/ace/config-macosx-panther.h @@ -1,99 +1,143 @@ /* -*- 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 @@ -102,14 +146,19 @@ # 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 @@ -117,6 +166,7 @@ #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 @@ -130,10 +180,13 @@ #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 index 3fce4d269e2..282e8800c3c 100644 --- a/dep/ACE_wrappers/ace/config-macosx-tiger.h +++ b/dep/ACE_wrappers/ace/config-macosx-tiger.h @@ -1,11 +1,15 @@ /* -*- 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. @@ -15,11 +19,15 @@ # 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 @@ -27,96 +35,137 @@ #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 @@ -125,14 +174,19 @@ # 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 @@ -140,6 +194,7 @@ #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 @@ -153,10 +208,13 @@ #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 index 6ef585cc8d5..e8ec1af6e96 100644 --- a/dep/ACE_wrappers/ace/config-macosx.h +++ b/dep/ACE_wrappers/ace/config-macosx.h @@ -1,99 +1,145 @@ /* -*- 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 @@ -102,13 +148,17 @@ # 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 @@ -116,6 +166,7 @@ #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 @@ -129,10 +180,13 @@ #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 index 5d213e5cdc4..5d1067e6c13 100644 --- a/dep/ACE_wrappers/ace/config-macros.h +++ b/dep/ACE_wrappers/ace/config-macros.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //========================================================================== /** * @file config-macros.h @@ -16,15 +17,19 @@ * 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 @@ -34,7 +39,9 @@ # 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 @@ -42,6 +49,7 @@ # 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 @@ -49,6 +57,7 @@ # 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) @@ -61,10 +70,12 @@ */ # 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) @@ -73,18 +84,22 @@ # 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 @@ -92,6 +107,7 @@ */ # define ACE_TYPENAME typename #endif /* !ACE_LACKS_DEPRECATED_MACROS */ + #if !defined (ACE_LACKS_DEPRECATED_MACROS) /** * @deprecated The @c ACE_TEMPLATE_SPECIALIZATION and @@ -102,21 +118,26 @@ # 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)) || \ @@ -124,25 +145,31 @@ # 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 @@ -151,6 +178,7 @@ // 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*) \ { \ @@ -158,27 +186,33 @@ } \ 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) @@ -187,20 +221,24 @@ #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. @@ -208,12 +246,14 @@ # 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 @@ -224,22 +264,29 @@ # 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. @@ -252,13 +299,16 @@ // 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 @@ -275,6 +325,7 @@ # 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) @@ -286,6 +337,7 @@ # 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) @@ -297,6 +349,7 @@ # 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) @@ -309,6 +362,7 @@ # 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 @@ -319,12 +373,14 @@ # 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) @@ -342,20 +398,24 @@ # 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) \ @@ -365,6 +425,7 @@ # 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 @@ -385,6 +446,7 @@ * determined dynamically at run-time. */ // ============================================================================ + #define ACE_OSCALL_RETURN(X,TYPE,FAILVALUE) \ do \ return (TYPE) (X); \ @@ -393,6 +455,7 @@ do \ RESULT = (TYPE) (X); \ while (0) + #if defined (ACE_WIN32) # define ACE_WIN32CALL_RETURN(X,TYPE,FAILVALUE) \ do { \ @@ -408,6 +471,7 @@ 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) @@ -417,18 +481,25 @@ 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 @@ -447,6 +518,7 @@ typedef DWORD ACE_THR_FUNC_RETURN; typedef void* ACE_THR_FUNC_RETURN; # endif /* ACE_VXWORKS */ typedef ACE_THR_FUNC_RETURN (*ACE_THR_FUNC)(void *); + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -455,12 +527,14 @@ typedef void (*ACE_THR_C_DEST)(void *); } #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" { @@ -473,6 +547,7 @@ typedef ACE_THR_FUNC_RETURN (*ACE_THR_C_FUNC)(void *); # 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. @@ -480,6 +555,7 @@ typedef ACE_THR_FUNC_RETURN (*ACE_THR_C_FUNC)(void *); // 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 @@ -491,14 +567,17 @@ typedef ACE_THR_FUNC_RETURN (*ACE_THR_C_FUNC)(void *); // 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) @@ -512,6 +591,7 @@ extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \ # define ACE_USES_CLASSIC_SVC_CONF 1 # endif /* ACE_HAS_XML_SVC_CONF */ #endif /* ACE_USES_CLASSIC_SVC_CONF */ + // ============================================================================ // Default svc.conf file extension. // ============================================================================ @@ -520,14 +600,17 @@ extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \ #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 */ @@ -540,6 +623,7 @@ extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \ #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 @@ -548,5 +632,6 @@ extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \ #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 index 24471ce9c18..5766987f07d 100644 --- a/dep/ACE_wrappers/ace/config-minimal.h +++ b/dep/ACE_wrappers/ace/config-minimal.h @@ -1,31 +1,40 @@ /* -*- 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 index a75b57f7ac6..22ddffee139 100644 --- a/dep/ACE_wrappers/ace/config-mvs.h +++ b/dep/ACE_wrappers/ace/config-mvs.h @@ -1,9 +1,12 @@ /* -*- 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 */ @@ -15,23 +18,30 @@ #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 @@ -72,6 +82,7 @@ #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 @@ -100,15 +111,20 @@ #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" diff --git a/dep/ACE_wrappers/ace/config-netbsd.h b/dep/ACE_wrappers/ace/config-netbsd.h index 75ffbe2fd6a..b05b26e3963 100644 --- a/dep/ACE_wrappers/ace/config-netbsd.h +++ b/dep/ACE_wrappers/ace/config-netbsd.h @@ -1,13 +1,17 @@ /* -*- 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 @@ -17,6 +21,7 @@ # 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 @@ -118,6 +123,7 @@ #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 @@ -128,11 +134,15 @@ #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 @@ -142,12 +152,16 @@ typedef signed long ACE_INT64; #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 index 00c6da6b37e..e81e36bc613 100644 --- a/dep/ACE_wrappers/ace/config-openbsd.h +++ b/dep/ACE_wrappers/ace/config-openbsd.h @@ -1,28 +1,38 @@ /* -*- 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 @@ -30,119 +40,166 @@ #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 @@ -151,21 +208,29 @@ #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 index 50a7539666c..90541513f35 100644 --- a/dep/ACE_wrappers/ace/config-openvms.h +++ b/dep/ACE_wrappers/ace/config-openvms.h @@ -1,11 +1,15 @@ /* -*- 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 @@ -16,11 +20,16 @@ //#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 @@ -30,6 +39,7 @@ #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 @@ -42,9 +52,13 @@ #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 @@ -62,6 +76,7 @@ #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 @@ -72,10 +87,14 @@ #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 @@ -91,6 +110,7 @@ #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 @@ -109,6 +129,7 @@ #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 @@ -121,10 +142,12 @@ #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 @@ -139,16 +162,19 @@ #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 @@ -158,11 +184,13 @@ #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 index ef6c8fc1d2a..e0751c32f1c 100644 --- a/dep/ACE_wrappers/ace/config-pharlap.h +++ b/dep/ACE_wrappers/ace/config-pharlap.h @@ -1,10 +1,13 @@ /* -*- 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 @@ -16,12 +19,15 @@ # 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 @@ -32,45 +38,54 @@ #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 index d1e1f74e776..492692179d8 100644 --- a/dep/ACE_wrappers/ace/config-posix-nonetworking.h +++ b/dep/ACE_wrappers/ace/config-posix-nonetworking.h @@ -1,10 +1,13 @@ /* -*- 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 @@ -18,6 +21,7 @@ # 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 @@ -31,6 +35,7 @@ # define ACE_LACKS_IFREQ # define ACE_LACKS_IFCONF # define ACE_LACKS_LINGER + // Missing methods # define ACE_LACKS_GETHOSTBYADDR # define ACE_LACKS_GETHOSTBYNAME @@ -70,10 +75,13 @@ # 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 index 6015293d546..a9cb744435b 100644 --- a/dep/ACE_wrappers/ace/config-posix.h +++ b/dep/ACE_wrappers/ace/config-posix.h @@ -1,8 +1,11 @@ /* -*- 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 @@ -12,11 +15,13 @@ # 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) @@ -30,11 +35,13 @@ # 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 @@ -48,16 +55,20 @@ # 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 index 923a68d073b..ef37758352a 100644 --- a/dep/ACE_wrappers/ace/config-qnx-neutrino.h +++ b/dep/ACE_wrappers/ace/config-qnx-neutrino.h @@ -2,15 +2,19 @@ // $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__. @@ -19,7 +23,9 @@ # 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__ @@ -27,6 +33,7 @@ #else # define ACE_CC_NAME ACE_TEXT ("NTO compiler ??") #endif + // /usr/nto/include/float.h defines // FLT_MAX_EXP 127 // DBL_MAX_EXP 1023 @@ -35,6 +42,7 @@ // 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 @@ -124,6 +132,7 @@ #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 index c2c63c33b58..5ad3326b412 100644 --- a/dep/ACE_wrappers/ace/config-qnx-rtp-62x.h +++ b/dep/ACE_wrappers/ace/config-qnx-rtp-62x.h @@ -7,6 +7,7 @@ #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. // @@ -68,6 +69,7 @@ #define ACE_HAS_UCONTEXT_T #define ACE_HAS_VOIDPTR_MMAP #define ACE_HAS_VOIDPTR_SOCKOPT + ///////////////////////////////////////////////////////////////// // Definition of the features that are not available. // @@ -97,7 +99,9 @@ #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 @@ -105,8 +109,11 @@ #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 diff --git a/dep/ACE_wrappers/ace/config-qnx-rtp-common.h b/dep/ACE_wrappers/ace/config-qnx-rtp-common.h index 7ed1a01a249..ee832adf604 100644 --- a/dep/ACE_wrappers/ace/config-qnx-rtp-common.h +++ b/dep/ACE_wrappers/ace/config-qnx-rtp-common.h @@ -1,15 +1,19 @@ // -*- 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__. @@ -18,7 +22,9 @@ # 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__ @@ -26,6 +32,7 @@ #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 @@ -34,6 +41,7 @@ // 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 index 577934b88f4..af55eeb6cae 100644 --- a/dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h +++ b/dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h @@ -3,15 +3,18 @@ // 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 @@ -63,6 +66,7 @@ #define ACE_HAS_UCONTEXT_T #define ACE_HAS_VOIDPTR_MMAP #define ACE_HAS_VOIDPTR_SOCKOPT + ///////////////////////////////////////////////////////////////// // Definition of the features that are not available. // @@ -101,7 +105,9 @@ #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 @@ -110,15 +116,20 @@ #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 @@ -133,7 +144,9 @@ #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 index 313a8184b6b..a176efd8f3e 100644 --- a/dep/ACE_wrappers/ace/config-qnx-rtp.h +++ b/dep/ACE_wrappers/ace/config-qnx-rtp.h @@ -8,6 +8,7 @@ #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" @@ -19,6 +20,7 @@ # 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 index 95239f4f1a5..558a6e1007c 100644 --- a/dep/ACE_wrappers/ace/config-rtems.h +++ b/dep/ACE_wrappers/ace/config-rtems.h @@ -1,20 +1,26 @@ /* -*- 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 @@ -26,9 +32,13 @@ # 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 @@ -49,12 +59,15 @@ #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 @@ -65,6 +78,7 @@ # 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 @@ -125,6 +139,7 @@ #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 @@ -135,13 +150,17 @@ # 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 index 6cf82043688..7d5c4f4ebef 100644 --- a/dep/ACE_wrappers/ace/config-sco-5.0.0-nothread.h +++ b/dep/ACE_wrappers/ace/config-sco-5.0.0-nothread.h @@ -1,11 +1,15 @@ /* -*- 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 index 7ce4b215d1a..35c33a43fad 100644 --- a/dep/ACE_wrappers/ace/config-sco-5.0.0.h +++ b/dep/ACE_wrappers/ace/config-sco-5.0.0.h @@ -1,15 +1,19 @@ /* -*- 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 @@ -18,55 +22,77 @@ #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 index 3c54e85f644..31d424d76b5 100644 --- a/dep/ACE_wrappers/ace/config-suncc-common.h +++ b/dep/ACE_wrappers/ace/config-suncc-common.h @@ -1,9 +1,11 @@ // -*- 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 @@ -27,6 +29,7 @@ # 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 @@ -35,12 +38,15 @@ # 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 @@ -49,11 +55,14 @@ // 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 index 70da9c4ee14..7ba78c2b3bd 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.10.h +++ b/dep/ACE_wrappers/ace/config-sunos5.10.h @@ -1,39 +1,52 @@ /* -*- 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 index d1abcdf22ac..3f78c9f94e6 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.11.h +++ b/dep/ACE_wrappers/ace/config-sunos5.11.h @@ -1,11 +1,16 @@ /* -*- 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 index eea5bcb7a41..9622a068232 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.4-g++.h +++ b/dep/ACE_wrappers/ace/config-sunos5.4-g++.h @@ -1,93 +1,135 @@ /* -*- 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) @@ -96,32 +138,45 @@ # 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 index 2f988660fce..8714b8d72fc 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.4-sunc++-4.x.h +++ b/dep/ACE_wrappers/ace/config-sunos5.4-sunc++-4.x.h @@ -1,132 +1,191 @@ /* -*- 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 index 4c17ea67a27..83d4d164951 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.5.h +++ b/dep/ACE_wrappers/ace/config-sunos5.5.h @@ -1,27 +1,36 @@ /* -*- 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) @@ -50,12 +59,14 @@ # 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 @@ -68,17 +79,21 @@ // 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 @@ -87,12 +102,16 @@ # 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. @@ -102,6 +121,7 @@ // 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) @@ -111,7 +131,9 @@ # 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) @@ -121,127 +143,173 @@ # 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 @@ -252,6 +320,7 @@ # 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 @@ -259,32 +328,46 @@ # 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) @@ -300,28 +383,36 @@ # 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 index 9108b6a0ed9..2ebf5a274a0 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.6.h +++ b/dep/ACE_wrappers/ace/config-sunos5.6.h @@ -1,11 +1,17 @@ /* -*- 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 @@ -16,6 +22,7 @@ // 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 @@ -24,6 +31,7 @@ #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 */ @@ -70,29 +78,38 @@ #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) @@ -100,9 +117,11 @@ #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 index 53a5e917f46..b2b62b7e7bb 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.7.h +++ b/dep/ACE_wrappers/ace/config-sunos5.7.h @@ -1,58 +1,79 @@ /* -*- 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 index 73a0f7ba8a6..36ce6d4a81a 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.8.h +++ b/dep/ACE_wrappers/ace/config-sunos5.8.h @@ -1,29 +1,40 @@ /* -*- 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 index cd42df15d0a..39b5721b527 100644 --- a/dep/ACE_wrappers/ace/config-sunos5.9.h +++ b/dep/ACE_wrappers/ace/config-sunos5.9.h @@ -1,13 +1,19 @@ /* -*- 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 index f66f838002f..18e2cb23f79 100644 --- a/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v2.h +++ b/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v2.h @@ -1,28 +1,37 @@ // -*- 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 @@ -32,6 +41,7 @@ #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 @@ -43,6 +53,7 @@ typedef long fd_mask; // should be in select.h but no such file #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) @@ -55,6 +66,7 @@ typedef enum CMA_T_SCHED_POLICY { 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. @@ -70,226 +82,321 @@ typedef enum CMA_T_SCHED_POLICY { #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 index e0514100214..c002835a857 100644 --- a/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v3.h +++ b/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v3.h @@ -2,28 +2,37 @@ // // $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 @@ -33,6 +42,7 @@ #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 @@ -44,6 +54,7 @@ typedef long fd_mask; // should be in select.h but no such file #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) @@ -56,6 +67,7 @@ typedef enum CMA_T_SCHED_POLICY { 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. @@ -71,250 +83,354 @@ typedef enum CMA_T_SCHED_POLICY { #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$ @@ -324,24 +440,33 @@ typedef enum CMA_T_SCHED_POLICY { #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 index 5b8e79627b8..1577e1e6866 100644 --- a/dep/ACE_wrappers/ace/config-tandem.h +++ b/dep/ACE_wrappers/ace/config-tandem.h @@ -1,8 +1,10 @@ /* -*- 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 @@ -12,53 +14,72 @@ // 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) @@ -74,42 +95,58 @@ #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) @@ -117,15 +154,21 @@ #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 @@ -142,8 +185,10 @@ #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 index 34cd823e757..db16845b529 100644 --- a/dep/ACE_wrappers/ace/config-tru64.h +++ b/dep/ACE_wrappers/ace/config-tru64.h @@ -1,42 +1,55 @@ /* -*- 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 @@ -44,6 +57,7 @@ # 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 @@ -55,7 +69,9 @@ #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 @@ -110,6 +126,7 @@ #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 @@ -117,17 +134,22 @@ #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 index c6d329e9d93..03725638a70 100644 --- a/dep/ACE_wrappers/ace/config-unixware-7.1.0.h +++ b/dep/ACE_wrappers/ace/config-unixware-7.1.0.h @@ -1,38 +1,52 @@ /* -*- 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 */ @@ -44,63 +58,86 @@ #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 @@ -110,184 +147,267 @@ #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 index a81b546bca9..988c451effb 100644 --- a/dep/ACE_wrappers/ace/config-unixware-7.1.0.udk.h +++ b/dep/ACE_wrappers/ace/config-unixware-7.1.0.udk.h @@ -1,29 +1,42 @@ /* -*- 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. @@ -34,16 +47,20 @@ /* # 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 */ @@ -55,78 +72,106 @@ #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 @@ -136,186 +181,270 @@ //#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 @@ -326,6 +455,7 @@ #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 index 8c6baa29996..6d967b52217 100644 --- a/dep/ACE_wrappers/ace/config-visualage.h +++ b/dep/ACE_wrappers/ace/config-visualage.h @@ -1,10 +1,13 @@ /* -*- 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__ @@ -12,6 +15,7 @@ #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 index f856c805280..52c2958654d 100644 --- a/dep/ACE_wrappers/ace/config-vxworks.h +++ b/dep/ACE_wrappers/ace/config-vxworks.h @@ -1,10 +1,13 @@ //* -*- 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" @@ -30,6 +33,7 @@ # endif # endif #endif /* ! ACE_VXWORKS */ + #if (ACE_VXWORKS == 0x551) # include "ace/config-vxworks5.x.h" #elif (ACE_VXWORKS == 0x620) @@ -45,6 +49,8 @@ #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 index d5c2dcf98b3..eeb22490090 100644 --- a/dep/ACE_wrappers/ace/config-vxworks5.x.h +++ b/dep/ACE_wrappers/ace/config-vxworks5.x.h @@ -1,34 +1,45 @@ /* -*- 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 @@ -36,37 +47,47 @@ # 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 @@ -183,6 +204,7 @@ #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 @@ -196,6 +218,7 @@ #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 @@ -217,8 +240,10 @@ #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 @@ -245,16 +270,20 @@ #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 @@ -279,9 +308,11 @@ #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) @@ -289,22 +320,27 @@ // 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 index d4717fd1749..f7978b0036e 100644 --- a/dep/ACE_wrappers/ace/config-vxworks6.2.h +++ b/dep/ACE_wrappers/ace/config-vxworks6.2.h @@ -1,33 +1,43 @@ /* -*- 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 @@ -35,20 +45,24 @@ # 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) @@ -57,6 +71,7 @@ # endif # endif #endif + // OS-specific configuration #define ACE_HAS_4_4BSD_SENDMSG_RECVMSG #define ACE_HAS_NONCONST_GETBY @@ -146,6 +161,7 @@ # 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 @@ -159,6 +175,7 @@ #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 @@ -169,6 +186,7 @@ #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 @@ -177,8 +195,10 @@ #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) @@ -241,6 +261,7 @@ # 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 @@ -267,9 +288,11 @@ # 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) @@ -277,24 +300,30 @@ // 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 index c383ef5d023..fe90626e3dc 100644 --- a/dep/ACE_wrappers/ace/config-vxworks6.3.h +++ b/dep/ACE_wrappers/ace/config-vxworks6.3.h @@ -1,25 +1,33 @@ /* -*- 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 @@ -27,6 +35,7 @@ # define _C99 # endif # endif + #elif defined (__DCC__) # define ACE_HAS_STANDARD_CPP_LIBRARY 1 # define ACE_TEMPLATES_REQUIRE_SOURCE @@ -35,6 +44,7 @@ # 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) @@ -43,6 +53,7 @@ # endif # endif #endif + // OS-specific configuration #define ACE_HAS_4_4BSD_SENDMSG_RECVMSG #define ACE_HAS_NONCONST_GETBY @@ -125,6 +136,7 @@ #define ACE_HAS_SIGTIMEDWAIT #define ACE_HAS_SIGSUSPEND #define ACE_HAS_GETIFADDRS + #define ACE_LACKS_SETEGID #define ACE_LACKS_SETPGID #define ACE_LACKS_SETREGID @@ -138,6 +150,7 @@ #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 @@ -148,6 +161,7 @@ #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 @@ -155,8 +169,10 @@ #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) @@ -231,6 +247,7 @@ # 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 @@ -260,9 +277,11 @@ # 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) @@ -270,24 +289,30 @@ // 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 index 6b80a57961b..80c28ab624c 100644 --- a/dep/ACE_wrappers/ace/config-vxworks6.4.h +++ b/dep/ACE_wrappers/ace/config-vxworks6.4.h @@ -1,18 +1,23 @@ //* -*- 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 @@ -20,14 +25,18 @@ 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 @@ -35,6 +44,7 @@ # define _C99 # endif # endif + #elif defined (__DCC__) # define ACE_HAS_STANDARD_CPP_LIBRARY 1 # define ACE_TEMPLATES_REQUIRE_SOURCE @@ -43,6 +53,7 @@ # 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__ @@ -58,6 +69,7 @@ # define ACE_HAS_PENTIUM #endif #endif + #if !defined __RTP__ # if defined (TOOL) && (TOOL == gnu) # if defined (CPU) && (CPU == PPC85XX || CPU == PPC604 || CPU == PPC603) @@ -66,6 +78,7 @@ # endif # endif #endif + // OS-specific configuration #define ACE_HAS_4_4BSD_SENDMSG_RECVMSG #define ACE_HAS_3_PARAM_READDIR_R @@ -148,6 +161,7 @@ #define ACE_HAS_SIGTIMEDWAIT #define ACE_HAS_SIGSUSPEND #define ACE_HAS_GETIFADDRS + #define ACE_LACKS_SETEGID #define ACE_LACKS_SETPGID #define ACE_LACKS_SETREGID @@ -161,6 +175,7 @@ #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 @@ -171,6 +186,7 @@ #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 @@ -178,8 +194,10 @@ #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) @@ -256,6 +274,7 @@ # 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 @@ -289,27 +308,34 @@ # 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 index 1b9b0910b5f..d40f695774c 100644 --- a/dep/ACE_wrappers/ace/config-vxworks6.5.h +++ b/dep/ACE_wrappers/ace/config-vxworks6.5.h @@ -1,19 +1,26 @@ //* -*- 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 index 047a373f8a8..a2058aa51c3 100644 --- a/dep/ACE_wrappers/ace/config-vxworks6.6.h +++ b/dep/ACE_wrappers/ace/config-vxworks6.6.h @@ -1,22 +1,30 @@ //* -*- 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 index e8acd200c4b..371919cfdc4 100644 --- a/dep/ACE_wrappers/ace/config-win32-borland.h +++ b/dep/ACE_wrappers/ace/config-win32-borland.h @@ -1,35 +1,48 @@ // -*- 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 @@ -56,17 +69,21 @@ #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 @@ -77,16 +94,19 @@ # 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 @@ -95,10 +115,12 @@ # 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 index c59b1257f76..1abeccd4c54 100644 --- a/dep/ACE_wrappers/ace/config-win32-common.h +++ b/dep/ACE_wrappers/ace/config-win32-common.h @@ -1,26 +1,32 @@ /* -*- 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. // @@ -30,9 +36,11 @@ # 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) @@ -40,6 +48,7 @@ # 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 @@ -50,6 +59,7 @@ #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) @@ -57,6 +67,7 @@ # 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, @@ -66,11 +77,13 @@ #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 @@ -78,6 +91,7 @@ #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 @@ -87,6 +101,7 @@ // #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 @@ -97,11 +112,13 @@ #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 @@ -134,25 +151,32 @@ #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 @@ -164,24 +188,30 @@ #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 @@ -197,6 +227,7 @@ #define ACE_LACKS_GETUID #define ACE_LACKS_GETEUID #define ACE_LACKS_SETGID + /* LACKS miscellaneous */ #define ACE_LACKS_ALARM #define ACE_LACKS_ARPA_INET_H @@ -234,10 +265,14 @@ #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. @@ -245,51 +280,72 @@ #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 @@ -297,16 +353,22 @@ #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 @@ -314,10 +376,12 @@ # 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) @@ -328,6 +392,7 @@ # 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 @@ -341,6 +406,7 @@ // 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) @@ -350,20 +416,25 @@ #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 @@ -410,13 +481,16 @@ # 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") @@ -428,41 +502,51 @@ # 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) @@ -470,6 +554,7 @@ # 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 | \ @@ -478,6 +563,7 @@ // 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 @@ -489,6 +575,7 @@ #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) @@ -497,21 +584,26 @@ #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. @@ -521,15 +613,18 @@ # 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 @@ -562,9 +657,11 @@ # 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 index d737efcac82..ca855f5bc97 100644 --- a/dep/ACE_wrappers/ace/config-win32-dmc.h +++ b/dep/ACE_wrappers/ace/config-win32-dmc.h @@ -1,21 +1,28 @@ // -*- 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) @@ -25,9 +32,12 @@ # 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 @@ -35,6 +45,7 @@ #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 @@ -82,15 +93,19 @@ #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 index b1b2db6f93a..775488f3f7f 100644 --- a/dep/ACE_wrappers/ace/config-win32-ghs.h +++ b/dep/ACE_wrappers/ace/config-win32-ghs.h @@ -1,15 +1,20 @@ // -*- 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 @@ -17,11 +22,13 @@ #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) @@ -31,11 +38,14 @@ # 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 @@ -43,6 +53,7 @@ #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 @@ -69,14 +80,18 @@ # 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 index 58b7bf74fc5..71f521af45a 100644 --- a/dep/ACE_wrappers/ace/config-win32-interix.h +++ b/dep/ACE_wrappers/ace/config-win32-interix.h @@ -1,11 +1,14 @@ // -*- 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 @@ -23,8 +26,11 @@ # 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 @@ -36,11 +42,14 @@ #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 @@ -61,10 +70,12 @@ #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 @@ -75,8 +86,10 @@ // 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 @@ -85,3 +98,4 @@ 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 index 7ba9700da12..259e5d927fd 100644 --- a/dep/ACE_wrappers/ace/config-win32-mingw.h +++ b/dep/ACE_wrappers/ace/config-win32-mingw.h @@ -1,32 +1,43 @@ // -*- 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 @@ -39,7 +50,9 @@ #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 @@ -71,14 +84,18 @@ #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 index a760b0182f9..b2b45c6894b 100644 --- a/dep/ACE_wrappers/ace/config-win32-msvc-7.h +++ b/dep/ACE_wrappers/ace/config-win32-msvc-7.h @@ -14,84 +14,113 @@ * @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 index e4878c41a3c..f35ba9f4f94 100644 --- a/dep/ACE_wrappers/ace/config-win32-msvc-8.h +++ b/dep/ACE_wrappers/ace/config-win32-msvc-8.h @@ -14,22 +14,28 @@ * @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 @@ -38,61 +44,83 @@ #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 @@ -102,16 +130,20 @@ # 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 index 17545c36b0e..ee8feef52e1 100644 --- a/dep/ACE_wrappers/ace/config-win32-msvc-9.h +++ b/dep/ACE_wrappers/ace/config-win32-msvc-9.h @@ -12,22 +12,28 @@ * @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 @@ -36,74 +42,100 @@ #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 index 738a9e2264e..7abad321c7d 100644 --- a/dep/ACE_wrappers/ace/config-win32-msvc.h +++ b/dep/ACE_wrappers/ace/config-win32-msvc.h @@ -12,34 +12,42 @@ * @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) @@ -49,6 +57,7 @@ #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 @@ -66,6 +75,7 @@ # 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 @@ -77,11 +87,13 @@ # 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 @@ -101,6 +113,7 @@ #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 @@ -110,13 +123,17 @@ #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 */ @@ -136,6 +153,7 @@ # 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 @@ -146,6 +164,7 @@ # 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 index 1ec87c34f08..96c351bd567 100644 --- a/dep/ACE_wrappers/ace/config-win32.h +++ b/dep/ACE_wrappers/ace/config-win32.h @@ -14,36 +14,47 @@ * @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 @@ -51,6 +62,7 @@ #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" @@ -65,14 +77,18 @@ #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/gethrtime.cpp b/dep/ACE_wrappers/ace/gethrtime.cpp index 360db7a78a3..163645cd68b 100644 --- a/dep/ACE_wrappers/ace/gethrtime.cpp +++ b/dep/ACE_wrappers/ace/gethrtime.cpp @@ -4,21 +4,28 @@ // 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__) @@ -31,6 +38,7 @@ ACE_GETHRTIME_NAME (void) #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". @@ -38,11 +46,13 @@ ACE_GETHRTIME_NAME (void) 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 */ diff --git a/dep/ACE_wrappers/ace/iosfwd.h b/dep/ACE_wrappers/ace/iosfwd.h index bed916d560a..561e15e8ad8 100644 --- a/dep/ACE_wrappers/ace/iosfwd.h +++ b/dep/ACE_wrappers/ace/iosfwd.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file iosfwd.h @@ -18,21 +19,29 @@ */ //============================================================================= + #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 @@ -50,8 +59,10 @@ 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; @@ -64,8 +75,11 @@ 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; @@ -75,8 +89,12 @@ 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 index bc40ed7a180..37538c0824d 100644 --- a/dep/ACE_wrappers/ace/os_include/arpa/os_inet.h +++ b/dep/ACE_wrappers/ace/os_include/arpa/os_inet.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_inet.h @@ -11,22 +12,30 @@ * @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 @@ -37,6 +46,7 @@ * 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 @@ -45,17 +55,21 @@ * 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 index 1a3d2d0f1f2..da099f89dc2 100644 --- a/dep/ACE_wrappers/ace/os_include/net/os_if.h +++ b/dep/ACE_wrappers/ace/os_include/net/os_if.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_if.h @@ -11,13 +12,18 @@ * @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. @@ -37,17 +43,21 @@ # 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 @@ -76,6 +86,7 @@ struct ifreq { #define ifr_tap ifr_ifru.ifru_tap /* tap function */ }; #endif /* ACE_LACKS_IFREQ */ + #if defined (ACE_LACKS_IFCONF) struct ifconf { int ifc_len; @@ -87,18 +98,23 @@ struct ifconf { #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 index eaf1ad7589d..c90fb8fa8d4 100644 --- a/dep/ACE_wrappers/ace/os_include/netinet/os_in.h +++ b/dep/ACE_wrappers/ace/os_include/netinet/os_in.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_in.h @@ -11,18 +12,25 @@ * @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_ @@ -34,16 +42,19 @@ # 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 @@ -56,12 +67,14 @@ extern "C" 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 { @@ -71,6 +84,7 @@ extern "C" 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 */ @@ -78,6 +92,7 @@ extern "C" char sun_path[104]; /* path name (gag) */ }; #endif /* ACE_LACKS_SOCKADDR_UN */ + # if defined (ACE_LACKS_IP_MREQ) struct ip_mreq { @@ -85,21 +100,26 @@ extern "C" 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 @@ -111,43 +131,56 @@ extern "C" #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 index 47cbb5cdc85..9f60cd91af8 100644 --- a/dep/ACE_wrappers/ace/os_include/netinet/os_tcp.h +++ b/dep/ACE_wrappers/ace/os_include/netinet/os_tcp.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_tcp.h @@ -11,27 +12,36 @@ * @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 index 23d7001cd43..2011403ff3c 100644 --- a/dep/ACE_wrappers/ace/os_include/os_aio.h +++ b/dep/ACE_wrappers/ace/os_include/os_aio.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_aio.h @@ -11,27 +12,37 @@ * @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 index a4094cb3a85..1c1ed53d852 100644 --- a/dep/ACE_wrappers/ace/os_include/os_assert.h +++ b/dep/ACE_wrappers/ace/os_include/os_assert.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_assert.h @@ -11,27 +12,36 @@ * @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 index 8ffceb742d8..fd1ff253fce 100644 --- a/dep/ACE_wrappers/ace/os_include/os_byteswap.h +++ b/dep/ACE_wrappers/ace/os_include/os_byteswap.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_byteswap.h @@ -10,24 +11,32 @@ * @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 index c71e90ee34d..27ce474b6dc 100644 --- a/dep/ACE_wrappers/ace/os_include/os_complex.h +++ b/dep/ACE_wrappers/ace/os_include/os_complex.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_complex.h @@ -11,24 +12,32 @@ * @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 index 85f777e13a0..09e536d521a 100644 --- a/dep/ACE_wrappers/ace/os_include/os_cpio.h +++ b/dep/ACE_wrappers/ace/os_include/os_cpio.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_cpio.h @@ -11,24 +12,32 @@ * @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 index 03fc231da48..61a3df06375 100644 --- a/dep/ACE_wrappers/ace/os_include/os_ctype.h +++ b/dep/ACE_wrappers/ace/os_include/os_ctype.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_ctype.h @@ -11,26 +12,35 @@ * @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 index 3361fae8001..4e81e94d1bf 100644 --- a/dep/ACE_wrappers/ace/os_include/os_dirent.h +++ b/dep/ACE_wrappers/ace/os_include/os_dirent.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_dirent.h @@ -11,35 +12,46 @@ * @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; @@ -50,16 +62,22 @@ struct dirent { // 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_; }; @@ -70,18 +88,22 @@ typedef wDIR ACE_DIR; #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 index 2b5741d1d9e..f7691ad8a58 100644 --- a/dep/ACE_wrappers/ace/os_include/os_dlfcn.h +++ b/dep/ACE_wrappers/ace/os_include/os_dlfcn.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_dlfcn.h @@ -11,16 +12,22 @@ * @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 /**/ @@ -28,23 +35,27 @@ # 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 */ @@ -69,18 +80,23 @@ extern "C" # 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 index ec841acd9a5..6534aa8c7c8 100644 --- a/dep/ACE_wrappers/ace/os_include/os_errno.h +++ b/dep/ACE_wrappers/ace/os_include/os_errno.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_errno.h @@ -11,25 +12,33 @@ * @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 @@ -72,57 +81,74 @@ extern "C" // '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 index 1ed31de9022..ad5beeb9511 100644 --- a/dep/ACE_wrappers/ace/os_include/os_fcntl.h +++ b/dep/ACE_wrappers/ace/os_include/os_fcntl.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_fcntl.h @@ -11,27 +12,36 @@ * @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 @@ -45,9 +55,11 @@ extern "C" # 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 @@ -67,23 +79,29 @@ extern "C" #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 index cdba3cd5f76..a178c04c91b 100644 --- a/dep/ACE_wrappers/ace/os_include/os_fenv.h +++ b/dep/ACE_wrappers/ace/os_include/os_fenv.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_fenv.h @@ -11,24 +12,32 @@ * @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 index accd8468db0..6b114a5dc3e 100644 --- a/dep/ACE_wrappers/ace/os_include/os_float.h +++ b/dep/ACE_wrappers/ace/os_include/os_float.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_float.h @@ -11,24 +12,32 @@ * @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 index d747adfcee9..391e8606e27 100644 --- a/dep/ACE_wrappers/ace/os_include/os_fmtmsg.h +++ b/dep/ACE_wrappers/ace/os_include/os_fmtmsg.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_fmtmsg.h @@ -11,24 +12,32 @@ * @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 index e7e3a49eb7d..2f592ef46e1 100644 --- a/dep/ACE_wrappers/ace/os_include/os_fnmatch.h +++ b/dep/ACE_wrappers/ace/os_include/os_fnmatch.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_fnmatch.h @@ -11,24 +12,32 @@ * @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 index e687b4e35ea..ab4655f241b 100644 --- a/dep/ACE_wrappers/ace/os_include/os_ftw.h +++ b/dep/ACE_wrappers/ace/os_include/os_ftw.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_ftw.h @@ -11,25 +12,34 @@ * @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 index d02b2fd6dd6..2ffdbab53e6 100644 --- a/dep/ACE_wrappers/ace/os_include/os_glob.h +++ b/dep/ACE_wrappers/ace/os_include/os_glob.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_glob.h @@ -11,24 +12,32 @@ * @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 index 173f8bee4f5..bc0741e9de2 100644 --- a/dep/ACE_wrappers/ace/os_include/os_grp.h +++ b/dep/ACE_wrappers/ace/os_include/os_grp.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_grp.h @@ -11,25 +12,34 @@ * @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 index cfb32ef11b7..14a69870112 100644 --- a/dep/ACE_wrappers/ace/os_include/os_iconv.h +++ b/dep/ACE_wrappers/ace/os_include/os_iconv.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_iconv.h @@ -11,25 +12,34 @@ * @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 index 1b02b8f4d23..d56951b6b57 100644 --- a/dep/ACE_wrappers/ace/os_include/os_intrin.h +++ b/dep/ACE_wrappers/ace/os_include/os_intrin.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_intrin.h @@ -10,27 +11,36 @@ * @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); @@ -38,9 +48,11 @@ 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 index 8cf01535d58..86105a723a6 100644 --- a/dep/ACE_wrappers/ace/os_include/os_inttypes.h +++ b/dep/ACE_wrappers/ace/os_include/os_inttypes.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_inttypes.h @@ -11,26 +12,36 @@ * @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 index 54a1775ea3d..bccc85f17ad 100644 --- a/dep/ACE_wrappers/ace/os_include/os_iso646.h +++ b/dep/ACE_wrappers/ace/os_include/os_iso646.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_iso646.h @@ -11,24 +12,32 @@ * @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 index bb1349d83bb..5ca91673d8e 100644 --- a/dep/ACE_wrappers/ace/os_include/os_kstat.h +++ b/dep/ACE_wrappers/ace/os_include/os_kstat.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_kstat.h @@ -8,27 +9,36 @@ * @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 index 4646849fc1d..29648b459d8 100644 --- a/dep/ACE_wrappers/ace/os_include/os_langinfo.h +++ b/dep/ACE_wrappers/ace/os_include/os_langinfo.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_langinfo.h @@ -11,25 +12,34 @@ * @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 index 2e6aac3e3e6..5692f5effe1 100644 --- a/dep/ACE_wrappers/ace/os_include/os_libgen.h +++ b/dep/ACE_wrappers/ace/os_include/os_libgen.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_libgen.h @@ -11,24 +12,32 @@ * @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_local.h b/dep/ACE_wrappers/ace/os_include/os_local.h index 014bf4d5521..64ff0d4d06f 100644 --- a/dep/ACE_wrappers/ace/os_include/os_local.h +++ b/dep/ACE_wrappers/ace/os_include/os_local.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_local.h @@ -11,25 +12,34 @@ * @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 index cd646baaddf..8a1fcd84790 100644 --- a/dep/ACE_wrappers/ace/os_include/os_math.h +++ b/dep/ACE_wrappers/ace/os_include/os_math.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_math.h @@ -11,25 +12,34 @@ * @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 index a7e8441929a..731dbc11210 100644 --- a/dep/ACE_wrappers/ace/os_include/os_monetary.h +++ b/dep/ACE_wrappers/ace/os_include/os_monetary.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_monetary.h @@ -11,25 +12,34 @@ * @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 index 784d02db00f..186d10697e8 100644 --- a/dep/ACE_wrappers/ace/os_include/os_mqueue.h +++ b/dep/ACE_wrappers/ace/os_include/os_mqueue.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_mqueue.h @@ -11,25 +12,34 @@ * @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 index 95c7cb35d4d..f3decb0064f 100644 --- a/dep/ACE_wrappers/ace/os_include/os_ndbm.h +++ b/dep/ACE_wrappers/ace/os_include/os_ndbm.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_ndbm.h @@ -11,25 +12,34 @@ * @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 index 47335ce58f9..7c08f6df081 100644 --- a/dep/ACE_wrappers/ace/os_include/os_netdb.h +++ b/dep/ACE_wrappers/ace/os_include/os_netdb.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_netdb.h @@ -11,15 +12,21 @@ * @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_ @@ -31,14 +38,17 @@ # 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 */ @@ -49,6 +59,7 @@ struct hostent { #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 */ @@ -56,6 +67,7 @@ struct protoent { int p_proto; /* protocol # */ }; #endif /* ACE_LACKS_PROTOENT */ + #if defined (ACE_LACKS_SERVENT) struct servent { char *s_name; /* official service name */ @@ -64,6 +76,7 @@ struct servent { 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)]; @@ -82,12 +95,15 @@ struct servent { 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 index 33c9e66e23a..2b14f55c7ec 100644 --- a/dep/ACE_wrappers/ace/os_include/os_nl_types.h +++ b/dep/ACE_wrappers/ace/os_include/os_nl_types.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_nl_types.h @@ -11,24 +12,32 @@ * @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 index 45110347ce2..4dd5b582f31 100644 --- a/dep/ACE_wrappers/ace/os_include/os_pdh.h +++ b/dep/ACE_wrappers/ace/os_include/os_pdh.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_pdh.h @@ -10,27 +11,36 @@ * @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 index 493b1cd4922..4bd09ba9d54 100644 --- a/dep/ACE_wrappers/ace/os_include/os_pdhmsg.h +++ b/dep/ACE_wrappers/ace/os_include/os_pdhmsg.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_pdhmsg.h @@ -10,24 +11,32 @@ * @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 index 359c5b38b94..e9597e5d50e 100644 --- a/dep/ACE_wrappers/ace/os_include/os_poll.h +++ b/dep/ACE_wrappers/ace/os_include/os_poll.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_poll.h @@ -11,24 +12,32 @@ * @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 index 24e1606f17b..6556a64576d 100644 --- a/dep/ACE_wrappers/ace/os_include/os_pthread.h +++ b/dep/ACE_wrappers/ace/os_include/os_pthread.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_pthread.h @@ -11,24 +12,32 @@ * @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 @@ -40,6 +49,7 @@ 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) @@ -49,21 +59,25 @@ extern "C" pthread_t pthread_self (void); # 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) @@ -86,6 +100,7 @@ extern "C" pthread_t pthread_self (void); # 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)) @@ -100,6 +115,7 @@ extern "C" pthread_t pthread_self (void); # 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 @@ -109,6 +125,7 @@ extern "C" pthread_t pthread_self (void); # 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) @@ -204,6 +221,7 @@ extern "C" pthread_t pthread_self (void); // 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 @@ -212,6 +230,7 @@ extern "C" pthread_t pthread_self (void); # 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; @@ -219,22 +238,28 @@ extern "C" pthread_t pthread_self (void); 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 @@ -242,9 +267,11 @@ extern "C" pthread_t pthread_self (void); # 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 @@ -252,6 +279,7 @@ extern "C" pthread_t pthread_self (void); # 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 @@ -259,6 +287,7 @@ extern "C" pthread_t pthread_self (void); # 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 @@ -267,6 +296,7 @@ extern "C" pthread_t pthread_self (void); # 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 @@ -274,6 +304,7 @@ extern "C" pthread_t pthread_self (void); # undef THR_DETACHED # undef THR_SUSPENDED # undef THR_DAEMON + # define THR_BOUND 0x00000001 # define THR_NEW_LWP 0x00000002 # define THR_DETACHED 0x00000040 @@ -283,18 +314,23 @@ extern "C" pthread_t pthread_self (void); # 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" /** @@ -309,14 +345,18 @@ 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. @@ -326,23 +366,29 @@ public: # 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 @@ -350,7 +396,9 @@ public: 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 @@ -371,6 +419,7 @@ public: # 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 index 71f510aed7f..f3cba066af9 100644 --- a/dep/ACE_wrappers/ace/os_include/os_pwd.h +++ b/dep/ACE_wrappers/ace/os_include/os_pwd.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_pwd.h @@ -11,22 +12,30 @@ * @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 @@ -35,13 +44,16 @@ extern "C" 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 index 265d34843e6..94606e45e58 100644 --- a/dep/ACE_wrappers/ace/os_include/os_regex.h +++ b/dep/ACE_wrappers/ace/os_include/os_regex.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_regex.h @@ -11,28 +12,38 @@ * @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 index 2d4030ea356..15279dbeef3 100644 --- a/dep/ACE_wrappers/ace/os_include/os_sched.h +++ b/dep/ACE_wrappers/ace/os_include/os_sched.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_sched.h @@ -11,22 +12,30 @@ * @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 @@ -34,9 +43,11 @@ extern "C" 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 index 5768092120e..b67d902e9af 100644 --- a/dep/ACE_wrappers/ace/os_include/os_search.h +++ b/dep/ACE_wrappers/ace/os_include/os_search.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_search.h @@ -11,25 +12,34 @@ * @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 index f8dbd7c6bcf..e6ae6b19b40 100644 --- a/dep/ACE_wrappers/ace/os_include/os_semaphore.h +++ b/dep/ACE_wrappers/ace/os_include/os_semaphore.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_semaphore.h @@ -11,52 +12,67 @@ * @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 index 5310b2a6243..e5261965cd8 100644 --- a/dep/ACE_wrappers/ace/os_include/os_setjmp.h +++ b/dep/ACE_wrappers/ace/os_include/os_setjmp.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_setjmp.h @@ -11,24 +12,32 @@ * @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 index 1d84c0c430b..029e5553921 100644 --- a/dep/ACE_wrappers/ace/os_include/os_signal.h +++ b/dep/ACE_wrappers/ace/os_include/os_signal.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_signal.h @@ -11,24 +12,32 @@ * @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) @@ -38,17 +47,21 @@ # 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 @@ -56,6 +69,7 @@ extern "C" # 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. @@ -63,57 +77,75 @@ extern "C" # 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 @@ -122,6 +154,7 @@ extern "C" # 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) @@ -131,6 +164,7 @@ extern "C" // 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); @@ -162,6 +196,7 @@ extern "C" # endif /* SIG_PF */ typedef void (*ACE_SignalHandlerV)(...); #endif /* ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES */ + #if defined (ACE_LACKS_SIGACTION) struct sigaction { @@ -170,6 +205,7 @@ extern "C" 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 @@ -182,6 +218,7 @@ extern "C" # 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. @@ -201,13 +238,17 @@ extern "C" 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 index 74770aefb80..ffa80163f50 100644 --- a/dep/ACE_wrappers/ace/os_include/os_spawn.h +++ b/dep/ACE_wrappers/ace/os_include/os_spawn.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_spawn.h @@ -11,27 +12,36 @@ * @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 index 23e03eee83b..7a9fcf5a928 100644 --- a/dep/ACE_wrappers/ace/os_include/os_stdarg.h +++ b/dep/ACE_wrappers/ace/os_include/os_stdarg.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_stdarg.h @@ -11,16 +12,22 @@ * @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)) @@ -28,14 +35,17 @@ #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 index f30f85a4d0f..e739fddf26d 100644 --- a/dep/ACE_wrappers/ace/os_include/os_stdbool.h +++ b/dep/ACE_wrappers/ace/os_include/os_stdbool.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_stdbool.h @@ -11,24 +12,32 @@ * @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 index f07731270be..34e6001925f 100644 --- a/dep/ACE_wrappers/ace/os_include/os_stddef.h +++ b/dep/ACE_wrappers/ace/os_include/os_stddef.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_stddef.h @@ -11,22 +12,30 @@ * @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) @@ -38,6 +47,7 @@ extern "C" # 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 @@ -47,6 +57,7 @@ extern "C" # 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) @@ -54,6 +65,7 @@ extern "C" # 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 @@ -68,6 +80,7 @@ extern "C" # 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) @@ -75,9 +88,11 @@ extern "C" # 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 index a391227f450..5786e2a2b71 100644 --- a/dep/ACE_wrappers/ace/os_include/os_stdint.h +++ b/dep/ACE_wrappers/ace/os_include/os_stdint.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_stdint.h @@ -11,21 +12,28 @@ * @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)) @@ -33,61 +41,74 @@ extern "C" 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. @@ -98,19 +119,24 @@ _POSIX_V6_LPBIG_OFFBIG programming environment. # 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 index da3f6fe8298..23cec4d8eba 100644 --- a/dep/ACE_wrappers/ace/os_include/os_stdio.h +++ b/dep/ACE_wrappers/ace/os_include/os_stdio.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_stdio.h @@ -11,19 +12,26 @@ * @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 /**/ @@ -33,11 +41,13 @@ # 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) @@ -49,11 +59,13 @@ extern "C" # 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 @@ -66,9 +78,11 @@ extern "C" 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 index e66702829f2..4813f4e2bcc 100644 --- a/dep/ACE_wrappers/ace/os_include/os_stdlib.h +++ b/dep/ACE_wrappers/ace/os_include/os_stdlib.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_stdlib.h @@ -11,29 +12,39 @@ * @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 @@ -41,21 +52,27 @@ extern "C" 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 index 217d7458622..cfbc4fd2fcf 100644 --- a/dep/ACE_wrappers/ace/os_include/os_string.h +++ b/dep/ACE_wrappers/ace/os_include/os_string.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_string.h @@ -11,14 +12,20 @@ * @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. @@ -31,11 +38,13 @@ # 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) @@ -45,19 +54,24 @@ extern "C" # 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 index d8a6a6acd7e..8bfc768962f 100644 --- a/dep/ACE_wrappers/ace/os_include/os_strings.h +++ b/dep/ACE_wrappers/ace/os_include/os_strings.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_strings.h @@ -11,31 +12,42 @@ * @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 index 5139f85a516..961bd37feaa 100644 --- a/dep/ACE_wrappers/ace/os_include/os_stropts.h +++ b/dep/ACE_wrappers/ace/os_include/os_stropts.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_stropts.h @@ -11,14 +12,20 @@ * @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_ @@ -30,15 +37,19 @@ #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) @@ -48,9 +59,11 @@ # 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) @@ -58,24 +71,30 @@ # 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 { @@ -87,13 +106,16 @@ struct strbuf 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 index 612c34e29b6..f1713b47780 100644 --- a/dep/ACE_wrappers/ace/os_include/os_syslog.h +++ b/dep/ACE_wrappers/ace/os_include/os_syslog.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_syslog.h @@ -11,24 +12,32 @@ * @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 index 7c036cf1e9b..a0dc6ce2a76 100644 --- a/dep/ACE_wrappers/ace/os_include/os_tar.h +++ b/dep/ACE_wrappers/ace/os_include/os_tar.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_tar.h @@ -11,24 +12,32 @@ * @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 index eee01454fd0..d67aa4a1aa9 100644 --- a/dep/ACE_wrappers/ace/os_include/os_termios.h +++ b/dep/ACE_wrappers/ace/os_include/os_termios.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_termios.h @@ -11,27 +12,36 @@ * @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 index 8a0dfc5f05a..2b112a12875 100644 --- a/dep/ACE_wrappers/ace/os_include/os_tgmath.h +++ b/dep/ACE_wrappers/ace/os_include/os_tgmath.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_tgmath.h @@ -11,26 +12,35 @@ * @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 index 38a60fb4e1e..3670f3b492d 100644 --- a/dep/ACE_wrappers/ace/os_include/os_time.h +++ b/dep/ACE_wrappers/ace/os_include/os_time.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_time.h @@ -11,15 +12,21 @@ * @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 @@ -28,9 +35,11 @@ #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; @@ -43,6 +52,7 @@ using std::timezone; # endif using std::difftime; # endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ + # if !defined (ACE_HAS_POSIX_TIME) // Definition per POSIX. typedef struct timespec @@ -60,17 +70,21 @@ typedef struct timespec # 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 @@ -83,23 +97,28 @@ extern "C" # 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 index 719ee83def0..0eacf9dc4bb 100644 --- a/dep/ACE_wrappers/ace/os_include/os_trace.h +++ b/dep/ACE_wrappers/ace/os_include/os_trace.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_trace.h @@ -11,25 +12,34 @@ * @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 index f6f54b9f344..556bbdbbe45 100644 --- a/dep/ACE_wrappers/ace/os_include/os_ucontext.h +++ b/dep/ACE_wrappers/ace/os_include/os_ucontext.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_ucontext.h @@ -11,28 +12,38 @@ * @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 index eb2a9da6cfe..ad18c8a18d2 100644 --- a/dep/ACE_wrappers/ace/os_include/os_ulimit.h +++ b/dep/ACE_wrappers/ace/os_include/os_ulimit.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_ulimit.h @@ -11,24 +12,32 @@ * @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 index de26589b795..6e2d4a5c537 100644 --- a/dep/ACE_wrappers/ace/os_include/os_unistd.h +++ b/dep/ACE_wrappers/ace/os_include/os_unistd.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_unistd.h @@ -11,28 +12,38 @@ * @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(), @@ -42,11 +53,13 @@ // 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. @@ -77,24 +90,30 @@ extern "C" # 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 */ @@ -103,12 +122,15 @@ extern "C" # 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 @@ -117,16 +139,19 @@ extern "C" 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) @@ -137,6 +162,7 @@ extern "C" 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 @@ -146,25 +172,33 @@ extern "C" # 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 index d38072e497d..4cf719e34f9 100644 --- a/dep/ACE_wrappers/ace/os_include/os_utime.h +++ b/dep/ACE_wrappers/ace/os_include/os_utime.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_utime.h @@ -11,25 +12,34 @@ * @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 index 653b4794c96..234351366fb 100644 --- a/dep/ACE_wrappers/ace/os_include/os_utmpx.h +++ b/dep/ACE_wrappers/ace/os_include/os_utmpx.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_utmpx.h @@ -11,25 +12,34 @@ * @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 index ae655133893..a020715876f 100644 --- a/dep/ACE_wrappers/ace/os_include/os_wchar.h +++ b/dep/ACE_wrappers/ace/os_include/os_wchar.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_wchar.h @@ -11,30 +12,39 @@ * @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 index 22679dbc7ee..5f385e0fc63 100644 --- a/dep/ACE_wrappers/ace/os_include/os_wctype.h +++ b/dep/ACE_wrappers/ace/os_include/os_wctype.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_wctype.h @@ -11,26 +12,35 @@ * @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 index c0d749e978c..885893861a2 100644 --- a/dep/ACE_wrappers/ace/os_include/os_wordexp.h +++ b/dep/ACE_wrappers/ace/os_include/os_wordexp.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_wordexp.h @@ -11,25 +12,34 @@ * @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 index cf2fd568f44..99401b724cb 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_ipc.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_ipc.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_ipc.h @@ -11,48 +12,64 @@ * @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 index 444a5a178e1..151f400e2c2 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_loadavg.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_loadavg.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_loadavg.h @@ -10,24 +11,32 @@ * @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 index c66f175f3a6..c100d52fafe 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_mman.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_mman.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_mman.h @@ -11,17 +12,24 @@ * @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) @@ -32,11 +40,13 @@ } # 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 @@ -65,15 +75,19 @@ 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) @@ -81,23 +95,29 @@ PAGE_NOCACHE */ # 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 index 3fea009b6c6..57341dba97d 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_msg.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_msg.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_msg.h @@ -11,34 +12,45 @@ * @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 index 051683a7ab9..253b8127979 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_pstat.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_pstat.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_pstat.h @@ -10,25 +11,33 @@ * @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 index 5b2f13f6022..a724ed2e0eb 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_resource.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_resource.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_resource.h @@ -11,33 +12,44 @@ * @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) @@ -48,6 +60,7 @@ extern "C" # 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 @@ -58,10 +71,12 @@ extern "C" 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) @@ -69,18 +84,22 @@ extern "C" #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 index 4abacec9a75..f3e999831fd 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_select.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_select.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_select.h @@ -11,27 +12,36 @@ * @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... */ @@ -40,9 +50,11 @@ extern "C" # 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 index ace2f78e747..92153e2fcea 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_sem.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_sem.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_sem.h @@ -11,48 +12,64 @@ * @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 { @@ -64,9 +81,11 @@ extern "C" 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 index 11e7e306fae..83e32486cb6 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_shm.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_shm.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_shm.h @@ -11,28 +12,38 @@ * @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 index e5377824f65..cefc28c2134 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_socket.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_socket.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_socket.h @@ -11,38 +12,50 @@ * @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 */ @@ -50,110 +63,143 @@ extern "C" 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 @@ -166,9 +212,11 @@ extern "C" # 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) /* @@ -194,11 +242,13 @@ 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" { @@ -206,16 +256,20 @@ extern "C" #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, @@ -223,15 +277,18 @@ extern "C" 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, @@ -239,10 +296,13 @@ extern "C" 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 index 47f4eca2101..edd43d3932a 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_stat.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_stat.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_stat.h @@ -11,28 +12,39 @@ * @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. */ @@ -47,11 +59,14 @@ extern "C" # 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) @@ -60,8 +75,10 @@ extern "C" # 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. @@ -69,32 +86,43 @@ extern "C" # 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 index d53e5c072c0..6661aa437d9 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_statvfs.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_statvfs.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_statvfs.h @@ -11,24 +12,32 @@ * @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 index e68095fe35a..630c9de345b 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_sysctl.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_sysctl.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_sysctl.h @@ -10,24 +11,32 @@ * @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 index 0212536e942..19d57e984f9 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_sysinfo.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_sysinfo.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_sysinfo.h @@ -8,24 +9,32 @@ * @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 index c3f72cfc9d3..130a8265ac2 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_time.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_time.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_time.h @@ -11,25 +12,34 @@ * @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); @@ -41,9 +51,11 @@ extern "C" #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 index 4a6ac1ef04a..c8c0d74043c 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_timeb.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_timeb.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_timeb.h @@ -11,29 +12,39 @@ * @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 index ce6614b8490..d6769f7eb8d 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_times.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_times.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_times.h @@ -11,25 +12,34 @@ * @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 index d5ef4964abd..0377e024b69 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_types.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_types.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_types.h @@ -11,30 +12,41 @@ * @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; @@ -42,24 +54,30 @@ typedef double ACE_timer_t; # 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__) || \ @@ -79,6 +97,7 @@ typedef double ACE_timer_t; #else typedef loff_t ACE_LOFF_T; #endif + #if defined (ACE_WIN32) # if !defined (__BORLANDC__) typedef DWORD nlink_t; @@ -90,6 +109,7 @@ typedef double ACE_timer_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 @@ -99,6 +119,7 @@ typedef double ACE_timer_t; 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; @@ -106,26 +127,33 @@ typedef double ACE_timer_t; 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 index abffee236d6..ccc5bbeb12e 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_uio.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_uio.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_uio.h @@ -11,23 +12,31 @@ * @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. @@ -37,6 +46,7 @@ extern "C" 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); } @@ -44,19 +54,25 @@ extern "C" }; #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 index 995d13e3609..00b07315249 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_un.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_un.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_un.h @@ -11,22 +12,30 @@ * @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. @@ -34,9 +43,11 @@ struct sockaddr_un { }; #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 index f1e24c758a2..23748bb7160 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_utsname.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_utsname.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_utsname.h @@ -11,24 +12,32 @@ * @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 index 253e49c7cd5..fd42e2cdf90 100644 --- a/dep/ACE_wrappers/ace/os_include/sys/os_wait.h +++ b/dep/ACE_wrappers/ace/os_include/sys/os_wait.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file os_wait.h @@ -11,31 +12,42 @@ * @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 @@ -43,36 +55,44 @@ extern "C" # 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/post.h b/dep/ACE_wrappers/ace/post.h index d2f3ef278c7..7c77af216ad 100644 --- a/dep/ACE_wrappers/ace/post.h +++ b/dep/ACE_wrappers/ace/post.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file post.h @@ -10,6 +11,7 @@ * This file restores the original alignment rules. */ //============================================================================= + // No header guard #if defined (_MSC_VER) # pragma pack (pop) diff --git a/dep/ACE_wrappers/ace/pre.h b/dep/ACE_wrappers/ace/pre.h index 24ba0e6db1a..6984b22804e 100644 --- a/dep/ACE_wrappers/ace/pre.h +++ b/dep/ACE_wrappers/ace/pre.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file pre.h @@ -11,6 +12,7 @@ * boundary to ACE's default. */ //============================================================================= + // No header guard #if defined (_MSC_VER) # pragma warning (disable:4103) diff --git a/dep/ACE_wrappers/ace/streams.h b/dep/ACE_wrappers/ace/streams.h index 68c007d30a7..2b3ae4390fa 100644 --- a/dep/ACE_wrappers/ace/streams.h +++ b/dep/ACE_wrappers/ace/streams.h @@ -1,4 +1,5 @@ // -*- C++ -*- + //============================================================================= /** * @file streams.h @@ -17,26 +18,34 @@ */ //============================================================================= + #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 /**/ @@ -54,8 +63,10 @@ # 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; @@ -68,32 +79,42 @@ 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 /**/ @@ -102,13 +123,17 @@ # 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 index 5626dc02640..33fa67cd80b 100644 --- a/dep/ACE_wrappers/ace/svc_export.h +++ b/dep/ACE_wrappers/ace/svc_export.h @@ -1,20 +1,26 @@ // -*- 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) @@ -32,6 +38,8 @@ # 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/include/g3dlite/G3D/AABox.h b/dep/include/g3dlite/G3D/AABox.h index f42a0f2fa2d..699a3d94674 100644 --- a/dep/include/g3dlite/G3D/AABox.h +++ b/dep/include/g3dlite/G3D/AABox.h @@ -1,37 +1,51 @@ /** @file AABox.h + Axis-aligned box class + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2004-01-10 @edited 2006-02-10 + Copyright 2000-2006, Morgan McGuire. All rights reserved. */ + #ifndef G3D_AABOX_H #define G3D_AABOX_H + #include "G3D/platform.h" #include "G3D/Vector3.h" #include "G3D/debug.h" #include "G3D/Array.h" + namespace G3D { + /** An axis-aligned box. */ class AABox { private: + /** Optional argument placeholder */ static int dummy; + Vector3 lo; Vector3 hi; + public: + /** Does not initialize the fields */ inline AABox() {} + /** Constructs a zero-area AABox at v. */ inline AABox(const Vector3& v) { lo = hi = v; } + /** Assumes that low is less than or equal to high along each dimension. To have this automatically enforced, use AABox(low.min(high), low.max(high)); @@ -39,6 +53,7 @@ public: inline AABox(const Vector3& low, const Vector3& high) { set(low, high); } + /** Assumes that low is less than or equal to high along each dimension. */ inline void set(const Vector3& low, const Vector3& high) { @@ -50,12 +65,15 @@ public: hi = high; } + inline const Vector3& low() const { return lo; } + inline const Vector3& high() const { return hi; } + /** The largest possible finite box. */ @@ -63,20 +81,24 @@ public: static const AABox b = AABox(Vector3::minFinite(), Vector3::maxFinite()); return b; } + static inline const AABox& inf() { static const AABox b = AABox(-Vector3::inf(), Vector3::inf()); return b; } + static inline const AABox& zero() { static const AABox b = AABox(Vector3::zero(), Vector3::zero()); return b; } + /** Returns the centroid of the box. */ inline Vector3 center() const { return (lo + hi) * 0.5; } + /** Distance from corner(0) to the next corner along axis a. */ @@ -84,9 +106,11 @@ public: debugAssert(a < 3); return hi[a] - lo[a]; } + inline Vector3 extent() const { return hi - lo; } + /** @deprecated Use culledBy(Array&) */ @@ -96,6 +120,7 @@ public: int32& cullingPlaneIndex, const uint32 testMask, uint32& childMask) const; + /** @deprecated Use culledBy(Array&) */ @@ -104,39 +129,47 @@ public: int numPlanes, int32& cullingPlaneIndex = dummy, const uint32 testMask = 0xFFFFFF) const; + /** Splits the box into two AABoxes along the specified axis. low contains the part that was closer to negative infinity along axis, high contains the other part. Either may have zero volume. */ void split(const Vector3::Axis& axis, float location, AABox& low, AABox& high) const; + /** Conservative culling test for up to 32 planes. Returns true if there exists a plane[p] for which the entire object is in the negative half space (opposite the plane normal). + testMask and childMask are used for optimizing bounding volume hierarchies. The version of this method that produces childMask is slower than the version without; it should only be used for parent nodes. + @param cullingPlaneIndex The index of the first plane for which the entire object is in the negative half-space. The function exits early when one plane is found. -1 when the function returns false (i.e. when no plane culls the whole object). + @param testMask If bit p is 0, the bounding volume automatically passes the culling test for plane[p] (i.e. it is known that the volume is entirely within the positive half space). The function must return false if testMask is 0 and test all planes when testMask is -1 (0xFFFFFFFF). + @param childMask Test mask for the children of this volume. + */ bool culledBy( const Array& plane, int32& cullingPlaneIndex, const uint32 testMask, uint32& childMask) const; + /** Conservative culling test that does not produce a mask for children. */ @@ -144,6 +177,7 @@ public: const Array& plane, int32& cullingPlaneIndex = dummy, const uint32 testMask = -1) const; + inline bool contains( const Vector3& point) const { return @@ -154,47 +188,62 @@ public: (point.y <= hi.y) && (point.z <= hi.z); } + /** @deprecated */ inline float surfaceArea() const { Vector3 diag = hi - lo; return 2.0f * (diag.x * diag.y + diag.y * diag.z + diag.x * diag.z); } + inline float area() const { return surfaceArea(); } + inline float volume() const { Vector3 diag = hi - lo; return diag.x * diag.y * diag.z; } + Vector3 randomInteriorPoint() const; + Vector3 randomSurfacePoint() const; + /** @deprecated use Box constructor */ class Box toBox() const; + /** Returns true if there is any overlap */ bool intersects(const AABox& other) const; + /** Returns true if there is any overlap. @cite Jim Arvo's algorithm from Graphics Gems II*/ bool intersects(const class Sphere& other) const; + /** Return the intersection of the two boxes */ AABox intersect(const AABox& other) const { Vector3 H = hi.min(other.hi); Vector3 L = lo.max(other.lo).min(H); return AABox(L, H); } + inline unsigned int hashCode() const { return lo.hashCode() + hi.hashCode(); } + inline bool operator==(const AABox& b) const { return (lo == b.lo) && (hi == b.hi); } + inline bool operator!=(const AABox& b) const { return !((lo == b.lo) && (hi == b.hi)); } + void getBounds(AABox& out) const { out = *this; } }; + } + /** Hashing function for use with Table. */ @@ -202,5 +251,6 @@ inline unsigned int hashCode(const G3D::AABox& b) { return b.hashCode(); } + #endif diff --git a/dep/include/g3dlite/G3D/Array.h b/dep/include/g3dlite/G3D/Array.h index d9e90b55a00..f58ee5eeedb 100644 --- a/dep/include/g3dlite/G3D/Array.h +++ b/dep/include/g3dlite/G3D/Array.h @@ -1,14 +1,19 @@ /** @file Array.h + @maintainer Morgan McGuire, graphics3d.com @cite Portions written by Aaron Orenstein, a@orenstein.name + @created 2001-03-11 @edited 2007-05-12 + Copyright 2000-2007, Morgan McGuire. All rights reserved. */ + #ifndef G3D_ARRAY_H #define G3D_ARRAY_H + #include "G3D/platform.h" #include "G3D/debug.h" #include "G3D/System.h" @@ -18,34 +23,44 @@ #endif #include #include + #ifdef G3D_WIN32 # include + # pragma warning (push) // debug information too long # pragma warning( disable : 4312) # pragma warning( disable : 4786) #endif + namespace G3D { + /** Constant for passing to Array::resize */ const bool DONT_SHRINK_UNDERLYING_ARRAY = false; + /** Constant for Array::sort */ const int SORT_INCREASING = 1; /** Constant for Array::sort */ const int SORT_DECREASING = -1; + /** Dynamic 1D array. + Objects must have a default constructor (constructor that takes no arguments) in order to be used with this template. You will get the error "no appropriate default constructor found" if they do not. + Do not use with objects that overload placement operator new, since the speed of Array is partly due to pooled allocation. + If SSE is defined Arrays allocate the first element aligned to 16 bytes. + Array is highly optimized compared to std::vector. Array operations are less expensive than on std::vector and for large amounts of data, Array consumes only 1.5x the total size of the @@ -63,7 +78,9 @@ const int SORT_DECREASING = -1; safe way to access the underlying data as a flat C array -- Array::getCArray. Although (T*)std::vector::begin() can be used for this purpose, it is not guaranteed to succeed on all platforms. + To serialize an array, see G3D::serialize. + Do not subclass an Array. */ template @@ -71,8 +88,10 @@ class Array { private: /** 0...num-1 are initialized elements, num...numAllocated-1 are not */ T* data; + int num; int numAllocated; + void init(int n, int a) { debugAssert(n <= a); debugAssert(n >= 0); @@ -85,12 +104,14 @@ private: data = NULL; } } + void _copy(const Array &other) { init(other.num, other.num); for (int i = 0; i < num; i++) { data[i] = other.data[i]; } } + /** Returns true iff address points to an element of this array. Used by append. @@ -99,11 +120,13 @@ private: return (address >= data) && (address < data + num); } + /** Only compiled if you use the sort procedure. */ static bool __cdecl compareGT(const T& a, const T& b) { return a > b; } + /** Allocates a new array of size numAllocated (not a parameter to the method) and then copies at most oldNum elements from the old array to it. Destructors are @@ -111,32 +134,41 @@ private: */ void realloc(int oldNum) { T* oldData = data; + // The allocation is separate from the constructor invocation because we don't want // to pay for the cost of constructors until the newly allocated // elements are actually revealed to the application. They // will be constructed in the resize() method. + data = (T*)System::alignedMalloc(sizeof(T) * numAllocated, 16); + // Call the copy constructors {const int N = iMin(oldNum, numAllocated); const T* end = data + N; T* oldPtr = oldData; for (T* ptr = data; ptr < end; ++ptr, ++oldPtr) { + // Use placement new to invoke the constructor at the location // that we determined. Use the copy constructor to make the assignment. const T* constructed = new (ptr) T(*oldPtr); + (void)constructed; debugAssertM(constructed == ptr, "new returned a different address than the one provided by Array."); }} + // Call destructors on the old array (if there is no destructor, this will compile away) {const T* end = oldData + oldNum; for (T* ptr = oldData; ptr < end; ++ptr) { ptr->~T(); }} + System::alignedFree(oldData); } + public: + /** C++ STL style iterator variable. Call begin() to get the first iterator, pre-increment (++i) the iterator to get to @@ -144,6 +176,7 @@ public: */ typedef T* Iterator; typedef const T* ConstIterator; + /** C++ STL style iterator method. Returns the first iterator element. Do not change the size of the array while iterating. @@ -151,6 +184,7 @@ public: Iterator begin() { return data; } + ConstIterator begin() const { return data; } @@ -161,9 +195,11 @@ public: ConstIterator end() const { return data + num; } + Iterator end() { return data + num; } + /** The array returned is only valid until the next append() or resize call, or the Array is deallocated. @@ -171,6 +207,7 @@ public: T* getCArray() { return data; } + /** The array returned is only valid until the next append() or resize call, or the Array is deallocated. @@ -178,22 +215,26 @@ public: const T* getCArray() const { return data; } + /** Creates a zero length array (no heap allocation occurs until resize). */ Array() { init(0, 0); } + /** Creates an array of size. */ Array(int size) { init(size, size); } + /** Copy constructor */ Array(const Array& other) { _copy(other); } + /** Destructor does not delete() the objects if T is a pointer type (e.g. T = int*) instead, it deletes the pointers themselves and @@ -206,6 +247,7 @@ public: for (int i = 0; i < num; i++) { (data + i)->~T(); } + System::alignedFree(data); // Set to 0 in case this Array is global and gets referenced during app exit data = NULL; @@ -213,6 +255,7 @@ public: numAllocated = 0; } + /** Removes all elements. Use resize(0, false) or fastClear if you want to remove all elements without deallocating the underlying array @@ -221,10 +264,12 @@ public: void clear() { resize(0); } + /** resize(0, false) */ void fastClear() { resize(0, false); } + /** Assignment operator. */ @@ -235,6 +280,7 @@ public: } return *this; } + Array& operator=(const std::vector& other) { resize((int)other.size()); for (int i = 0; i < num; ++i) { @@ -242,12 +288,14 @@ public: } return *this; } + /** Number of elements in the array. */ inline int size() const { return num; } + /** Number of elements in the array. (Same as size; this is just here for convenience). @@ -255,6 +303,7 @@ public: inline int length() const { return size(); } + /** Swaps element index with the last element in the array then shrinks the array by one. @@ -265,6 +314,7 @@ public: data[index] = data[num - 1]; resize(size() - 1); } + /** Resizes, calling the default constructor for newly created objects and shrinking the underlying @@ -273,52 +323,65 @@ public: void resize(int n) { resize(n, true); } + /** Resizes without shrinking the underlying array */ void fastResize(int n) { resize(n, false); } + /** Inserts at the specified index and shifts all other elements up by one. */ void insert(int n, const T& value) { // Add space for the extra element resize(num + 1, false); + for (int i = num - 1; i > n; --i) { data[i] = data[i - 1]; } data[n] = value; } + /** @param shrinkIfNecessary if false, memory will never be reallocated when the array shrinks. This makes resizing much faster but can waste memory. */ void resize(int n, bool shrinkIfNecessary) { int oldNum = num; num = n; + // Call the destructors on newly hidden elements if there are any for (int i = num; i < oldNum; ++i) { (data + i)->~T(); } + // Once allocated, always maintain 10 elements or 32 bytes, whichever is higher. static const int minSize = iMax(10, 32 / sizeof(T)); + if (num > numAllocated) { // Grow the underlying array + if (numAllocated == 0) { // First allocation; grow to exactly the size requested to avoid wasting space. numAllocated = n; debugAssert(oldNum == 0); realloc(oldNum); } else { + if (num < minSize) { // Grow to at least the minimum size numAllocated = minSize; + } else { + // Increase the underlying size of the array. Grow aggressively // up to 64k, less aggressively up to 400k, and then grow relatively // slowly (1.5x per resize) to avoid excessive space consumption. // // These numbers are tweaked according to performance tests. + float growFactor = 3.0; + size_t oldSizeBytes = numAllocated * sizeof(T); if (oldSizeBytes > 400000) { // Avoid bloat @@ -327,19 +390,26 @@ public: // This is what std:: uses at all times growFactor = 2.0; } + numAllocated = (num - numAllocated) + (int)(numAllocated * growFactor); + if (numAllocated < minSize) { numAllocated = minSize; } } + realloc(oldNum); } + } else if ((num <= numAllocated / 3) && shrinkIfNecessary && (num > minSize)) { // Shrink the underlying array + // Only copy over old elements that still remain after resizing // (destructors were called for others if we're shrinking) realloc(iMin(num, oldNum)); + } + // Call the constructors on newly revealed elements. // Do not use parens because we don't want the intializer // invoked for POD types. @@ -347,12 +417,14 @@ public: new (data + i) T; } } + /** Add an element to the end of the array. Will not shrink the underlying array under any circumstances. It is safe to append an element that is already in the array. */ inline void append(const T& value) { + if (num < numAllocated) { // This is a simple situation; just stick it in the next free slot using // the copy constructor. @@ -372,6 +444,7 @@ public: } } + inline void append(const T& v1, const T& v2) { if (inArray(&v1) || inArray(&v2)) { T t1 = v1; @@ -390,6 +463,7 @@ public: } } + inline void append(const T& v1, const T& v2, const T& v3) { if (inArray(&v1) || inArray(&v2) || inArray(&v3)) { T t1 = v1; @@ -411,6 +485,7 @@ public: } } + inline void append(const T& v1, const T& v2, const T& v3, const T& v4) { if (inArray(&v1) || inArray(&v2) || inArray(&v3) || inArray(&v4)) { T t1 = v1; @@ -434,6 +509,7 @@ public: data[num - 1] = v4; } } + /** Returns true if the given element is in the array. */ @@ -443,8 +519,10 @@ public: return true; } } + return false; } + /** Append the elements of array. Cannot be called with this array as an argument. @@ -453,11 +531,14 @@ public: debugAssert(this != &array); int oldNum = num; int arrayLength = array.length(); + resize(num + arrayLength, false); + for (int i = 0; i < arrayLength; i++) { data[oldNum + i] = array.data[i]; } } + /** Pushes a new element onto the end and returns its address. This is the same as A.resize(A.size() + 1, false); A.last() @@ -466,24 +547,29 @@ public: resize(num + 1, false); return last(); } + /** Pushes an element onto the end (appends) */ inline void push(const T& value) { append(value); } + inline void push(const Array& array) { append(array); } + /** Alias to provide std::vector compatibility */ inline void push_back(const T& v) { push(v); } + /** "The member function removes the last element of the controlled sequence, which must be non-empty." For compatibility with std::vector. */ inline void pop_back() { pop(); } + /** "The member function returns the storage currently allocated to hold the controlled sequence, a value at least as large as size()" @@ -492,6 +578,7 @@ public: int capacity() const { return numAllocated; } + /** "The member function returns a reference to the first element of the controlled sequence, which must be non-empty." @@ -500,6 +587,7 @@ public: T& front() { return (*this)[0]; } + /** "The member function returns a reference to the first element of the controlled sequence, which must be non-empty." @@ -508,6 +596,7 @@ public: const T& front() const { return (*this)[0]; } + /** Removes the last element and returns it. By default, shrinks the underlying array. */ @@ -517,6 +606,7 @@ public: resize(num - 1, shrinkUnderlyingArrayIfNecessary); return temp; } + /** Pops the last element and discards it without returning anything. Faster than pop. By default, does not shrink the underlying array.*/ inline void popDiscard(bool shrinkUnderlyingArrayIfNecessary = false) { @@ -524,9 +614,11 @@ public: resize(num - 1, shrinkUnderlyingArrayIfNecessary); } + /** "The member function swaps the controlled sequences between *this and str." Note that this is slower than the optimal std implementation. + For compatibility with std::vector. */ void swap(Array& str) { @@ -535,6 +627,7 @@ public: *this = temp; } + /** Performs bounds checks in debug mode */ @@ -543,10 +636,12 @@ public: debugAssert(data!=NULL); return data[n]; } + inline T& operator[](unsigned int n) { debugAssertM(((int)n < num), format("Array index out of bounds. n = %d, size() = %d", n, num)); return data[n]; } + /** Performs bounds checks in debug mode */ @@ -555,21 +650,25 @@ public: debugAssert(data!=NULL); return data[n]; } + inline const T& operator[](unsigned int n) const { debugAssert((n < (unsigned int)num)); debugAssert(data!=NULL); return data[n]; } + inline T& randomElement() { debugAssert(num > 0); debugAssert(data!=NULL); return data[iRandom(0, num - 1)]; } + inline const T& randomElement() const { debugAssert(num > 0); debugAssert(data!=NULL); return data[iRandom(0, num - 1)]; } + /** Returns the last element, performing a check in debug mode that there is at least one element. @@ -579,45 +678,54 @@ public: debugAssert(data!=NULL); return data[num - 1]; } + /** Returns element lastIndex() */ inline T& last() { debugAssert(num > 0); debugAssert(data!=NULL); return data[num - 1]; } + /** Returns size() - 1 */ inline int lastIndex() const { debugAssertM(num > 0, "Array is empty"); return num - 1; } + inline int firstIndex() const { debugAssertM(num > 0, "Array is empty"); return 0; } + /** Returns element firstIndex(), performing a check in debug mode to ensure that there is at least one */ inline T& first() { debugAssertM(num > 0, "Array is empty"); return data[0]; } + inline const T& first() const { debugAssertM(num > 0, "Array is empty"); return data[0]; } + /** Returns iFloor(size() / 2), throws an assertion in debug mode if the array is empty */ inline int middleIndex() const { debugAssertM(num > 0, "Array is empty"); return num >> 1; } + /** Returns element middleIndex() */ inline const T& middle() const { debugAssertM(num > 0, "Array is empty"); return data[num >> 1]; } + /** Returns element middleIndex() */ inline T& middle() { debugAssertM(num > 0, "Array is empty"); return data[num >> 1]; } + /** Calls delete on all objects[0...size-1] and sets the size to zero. @@ -628,6 +736,7 @@ public: } resize(0); } + /** Returns the index of (the first occurance of) an index or -1 if not found. @@ -640,6 +749,7 @@ public: } return -1; } + /** Finds an element and returns the iterator to it. If the element isn't found then returns end(). @@ -652,6 +762,7 @@ public: } return end(); } + ConstIterator find(const T& value) const { for (int i = 0; i < num; ++i) { if (data[i] == value) { @@ -660,6 +771,7 @@ public: } return end(); } + /** Removes count elements from the array referenced either by index or Iterator. @@ -668,22 +780,28 @@ public: debugAssert((element >= begin()) && (element < end())); debugAssert((count > 0) && (element + count) <= end()); Iterator last = end() - count; + while(element < last) { element[0] = element[count]; ++element; } + resize(num - count); } + void remove(int index, int count = 1) { debugAssert((index >= 0) && (index < num)); debugAssert((count > 0) && (index + count <= num)); + remove(begin() + index, count); } + /** Reverse the elements of the array in place. */ void reverse() { T temp; + int n2 = num / 2; for (int i = 0; i < n2; ++i) { temp = data[num - 1 - i]; @@ -691,15 +809,19 @@ public: data[i] = temp; } } + /** Sort using a specific less-than function, e.g.: +
     bool __cdecl myLT(const MyClass& elem1, const MyClass& elem2) {
         return elem1.x < elem2.x;
     }
     
+ Note that for pointer arrays, the const must come after the class name, e.g., Array uses: +
     bool __cdecl myLT(MyClass*const& elem1, MyClass*const& elem2) {
         return elem1->x < elem2->x;
@@ -710,6 +832,7 @@ public:
         std::sort(data, data + num, lessThan);
     }
 
+
     /**
      Sorts the array in increasing order using the > or < operator.  To
      invoke this method on Array, T must override those operator.
@@ -730,6 +853,7 @@ public:
             std::sort(data, data + num, compareGT);
         }
     }
+
     /**
      Sorts elements beginIndex through and including endIndex.
      */
@@ -740,9 +864,11 @@ public:
             std::sort(data + beginIndex, data + endIndex + 1, compareGT);
         }
     }
+
     void sortSubArray(int beginIndex, int endIndex, bool (__cdecl *lessThan)(const T& elem1, const T& elem2)) {
         std::sort(data + beginIndex, data + endIndex + 1, lessThan);
     }
+
     /**
      The StrictWeakOrdering can be either a class that overloads the function call operator() or
      a function pointer of the form bool (__cdecl *lessThan)(const T& elem1, const T& elem2)
@@ -751,6 +877,7 @@ public:
     void sortSubArray(int beginIndex, int endIndex, StrictWeakOrdering& lessThan) {
         std::sort(data + beginIndex, data + endIndex + 1, lessThan);
     }
+
     /** Uses < and == to evaluate operator(); this is the default comparator for Array::partition. */
     class DefaultComparator {
     public:
@@ -764,11 +891,14 @@ public:
             }
         }
     };
+
     /** The output arrays are resized with fastClear() so that if they are already of the same size
         as this array no memory is allocated during partitioning.
+
         @param comparator A function, or class instance with an overloaded operator() that compares
         two elements of type T and returns 0 if they are equal, -1 if the second is smaller,
         and 1 if the first is smaller (i.e., following the conventions of std::string::compare).  For example:
+
         
         int compare(int A, int B) {
             if (A < B) {
@@ -788,6 +918,7 @@ public:
         Array& eqArray,
         Array& gtArray,
         const Comparator& comparator) const {
+
         // Make sure all arrays are independent
         debugAssert(<Array != this);
         debugAssert(&eqArray != this);
@@ -795,19 +926,24 @@ public:
         debugAssert(<Array != &eqArray);
         debugAssert(<Array != >Array);
         debugAssert(&eqArray != >Array);
+
         // Clear the arrays
         ltArray.fastClear();
         eqArray.fastClear();
         gtArray.fastClear();
+
         // Form a table of buckets for lt, eq, and gt
         Array* bucket[3] = {<Array, &eqArray, >Array};
+
         for (int i = 0; i < num; ++i) {
             int c = comparator(partitionElement, data[i]);
             debugAssertM(c >= -1 && c <= 1, "Comparator returned an illegal value.");
+
             // Insert into the correct bucket, 0, 1, or 2
             bucket[c + 1]->append(data[i]);
         }
     }
+
     /**
       Uses < and == on elements to perform a partition.  See partition().
      */
@@ -816,13 +952,16 @@ public:
         Array& ltArray,
         Array& eqArray,
         Array& gtArray) const {
+
         partition(partitionElement, ltArray, eqArray, gtArray, typename Array::DefaultComparator());
     }
+
     /**
      Paritions the array into those below the median, those above the median, and those elements
      equal to the median in expected O(n) time using quickselect.  If the array has an even
      number of different elements, the median for partition purposes is the largest value
      less than the median.
+
      @param tempArray used for working scratch space
      @param comparator see parition() for a discussion.*/
     template
@@ -832,32 +971,39 @@ public:
         Array&           gtMedian,
         Array&           tempArray,
         const Comparator&   comparator) const {
+
         ltMedian.fastClear();
         eqMedian.fastClear();
         gtMedian.fastClear();
+
         // Handle trivial cases first
         switch (size()) {
         case 0:
             // Array is empty; no parition is possible
             return;
+
         case 1:
             // One element
             eqMedian.append(first());
             return;
+
         case 2:
             {
                 // Two element array; median is the smaller
                 int c = comparator(first(), last());
+
                 switch (c) {
                 case -1:
                     // first was bigger
                     eqMedian.append(last());
                     gtMedian.append(first());
                     break;
+
                 case 0:
                     // Both equal to the median
                     eqMedian.append(first(), last());
                     break;
+
                 case 1:
                     // Last was bigger
                     eqMedian.append(first());
@@ -867,11 +1013,15 @@ public:
             }
             return;
         }
+
         // All other cases use a recursive randomized median
+
         // Number of values less than all in the current arrays
         int ltBoost = 0;
+
         // Number of values greater than all in the current arrays
         int gtBoost = 0;
+
         // For even length arrays, force the gt array to be one larger than the
         // lt array:
         //  [1 2 3] size = 3, choose half = (s + 1) /2
@@ -884,6 +1034,7 @@ public:
             lowerHalfSize = upperHalfSize = (size() + 1) / 2;
         }
         const T* xPtr = NULL;
+
         // Maintain pointers to the arrays; we'll switch these around during sorting
         // to avoid copies.
         const Array* source = this;
@@ -891,52 +1042,68 @@ public:
         Array* eq     = &eqMedian;
         Array* gt     = >Median;
         Array* extra  = &tempArray;
+
         while (true) {
             // Choose a random element -- choose the middle element; this is theoretically
             // suboptimal, but for loosly sorted array is actually the best strategy
+
             xPtr = &(source->middle());
             if (source->size() == 1) {
                 // Done; there's only one element left
                 break;
             }
             const T& x = *xPtr;
+
             // Note: partition (fast) clears the arrays for us
             source->partition(x, *lt, *eq, *gt, comparator);
+
             int L = lt->size() + ltBoost + eq->size();
             int U = gt->size() + gtBoost + eq->size();
             if ((L >= lowerHalfSize) &&
                 (U >= upperHalfSize)) {
+
                 // x must be the partition median
                 break;
+
             } else if (L < lowerHalfSize) {
+
                 // x must be smaller than the median.  Recurse into the 'gt' array.
                 ltBoost += lt->size() + eq->size();
+
                 // The new gt array will be the old source array, unless
                 // that was the this pointer (i.e., unless we are on the
                 // first iteration)
                 Array* newGt = (source == this) ? extra : const_cast*>(source);
+
                 // Now set up the gt array as the new source
                 source = gt;
                 gt = newGt;
+
             } else {
+
                 // x must be bigger than the median.  Recurse into the 'lt' array.
                 gtBoost += gt->size() + eq->size();
+
                 // The new lt array will be the old source array, unless
                 // that was the this pointer (i.e., unless we are on the
                 // first iteration)
                 Array* newLt = (source == this) ? extra : const_cast*>(source);
+
                 // Now set up the lt array as the new source
                 source = lt;
                 lt = newLt;
             }
         }
+
         // Now that we know the median, make a copy of it (since we're about to destroy the array that it
         // points into).
         T median = *xPtr;
         xPtr = NULL;
+
         // Partition the original array (note that this fast clears for us)
         partition(median, ltMedian, eqMedian, gtMedian, comparator);
     }
+
     /**
       Computes a median partition using the default comparator and a dynamically allocated temporary
       working array.  If the median is not in the array, it is chosen to be the largest value smaller
@@ -946,24 +1113,30 @@ public:
         Array&           ltMedian,
         Array&           eqMedian,
         Array&           gtMedian) const {
+
         Array temp;
         medianPartition(ltMedian, eqMedian, gtMedian, temp, DefaultComparator());
     }
 
+
     /** Redistributes the elements so that the new order is statistically independent
         of the original order. O(n) time.*/
     void randomize() {
         T temp;
+
         for (int i = size() - 1; i >= 0; --i) {
             int x = iRandom(0, i);
+
             temp = data[i];
             data[i] = data[x];
             data[x] = temp;
         }
     }
 
+
 };
 
+
 /** Array::contains for C-arrays */
 template bool contains(const T* array, int len, const T& e) {
     for (int i = len - 1; i >= 0; --i) {
@@ -973,8 +1146,11 @@ template bool contains(const T* array, int len, const T& e) {
     }
     return false;
 }
+
 } // namespace
+
 #endif
+
 #ifdef G3D_WIN32
 #   pragma warning (push)
 #endif
diff --git a/dep/include/g3dlite/G3D/Box.h b/dep/include/g3dlite/G3D/Box.h
index fccff258a25..8ec7ea3408d 100644
--- a/dep/include/g3dlite/G3D/Box.h
+++ b/dep/include/g3dlite/G3D/Box.h
@@ -1,66 +1,92 @@
 /**
   @file Box.h
+
   Box class
+
   @maintainer Morgan McGuire, matrix@graphics3d.com
+
   @cite Portions based on Dave Eberly's Magic Software Library at http://www.magic-software.com
   @created 2001-06-02
   @edited  2006-01-05
+
   Copyright 2000-2006, Morgan McGuire.
   All rights reserved.
  */
+
 #ifndef G3D_BOX_H
 #define G3D_BOX_H
+
 #include "G3D/platform.h"
 #include "G3D/Vector3.h"
 #include "G3D/Array.h"
 #include "G3D/Plane.h"
+
 namespace G3D {
+
 class CoordinateFrame;
+
 /**
  An arbitrary 3D box, useful as a bounding box.
 
+
   To construct a box from a coordinate frame, center and extent, use the idiom:
+
  Box box = cframe.toObjectSpace(Box(center - extent/2, center + extent/2));
  */
 class Box {
 private:
+
     static int32 dummy;
+
     friend class CoordinateFrame;
+
     /**
       
        3    2       7    6
+
        0    1       4    5
+
        front    back (seen through front)
       
*/ Vector3 _corner[8]; + /** Unit axes. */ Vector3 _axis[3]; + Vector3 _center; + /** Extent along each axis. */ Vector3 _extent; + float _area; float _volume; + void init( const Vector3& min, const Vector3& max); + public: + /** Does not initialize the fields. */ Box(); + /** Constructs a box from two opposite corners. */ Box( const Vector3& min, const Vector3& max); + Box(const class AABox& b); + /** Returns the object to world transformation for this box. localFrame().worldToObject(...) takes @@ -69,16 +95,20 @@ public: is no scaling in this transformation. */ CoordinateFrame localFrame() const; + void getLocalFrame(CoordinateFrame& frame) const; + /** Returns the centroid of the box. */ inline Vector3 center() const { return _center; } + inline Vector3 getCenter() const { return center(); } + /** Returns a corner (0 <= i < 8) @deprecated @@ -87,10 +117,12 @@ public: debugAssert(i < 8); return _corner[i]; } + inline Vector3 corner(int i) const { debugAssert(i < 8); return _corner[i]; } + /** Unit length. */ @@ -98,6 +130,7 @@ public: debugAssert(a < 3); return _axis[a]; } + /** Distance from corner(0) to the next corner along the box's local axis a. @@ -106,9 +139,11 @@ public: debugAssert(a < 3); return (float)_extent[a]; } + inline Vector3 extent() const { return _extent; } + /** Returns the four corners of a face (0 <= f < 6). The corners are returned to form a counter clockwise quad facing outwards. @@ -119,6 +154,7 @@ public: Vector3& v1, Vector3& v2, Vector3& v3) const; + /** @deprecated Use culledBy(Array&) */ @@ -128,6 +164,7 @@ public: int32& cullingPlaneIndex, const uint32 testMask, uint32& childMask) const; + /** @deprecated Use culledBy(Array&) */ @@ -136,6 +173,7 @@ public: int numPlanes, int32& cullingPlaneIndex = dummy, const uint32 testMask = -1) const; + /** See AABox::culledBy */ @@ -144,6 +182,7 @@ public: int32& cullingPlaneIndex, const uint32 testMask, uint32& childMask) const; + /** Conservative culling test that does not produce a mask for children. */ @@ -151,15 +190,21 @@ public: const Array& plane, int32& cullingPlaneIndex = dummy, const uint32 testMask = -1) const; + bool contains( const Vector3& point) const; + /** @deprecated */ float surfaceArea() const; + inline float area() const { return surfaceArea(); } + float volume() const; + void getRandomSurfacePoint(Vector3& P, Vector3& N = Vector3::dummy) const; + /** @deprecated Uniformly distributed on the surface. @@ -169,12 +214,16 @@ public: getRandomSurfacePoint(V); return V; } + /** Uniformly distributed on the interior (includes surface) */ Vector3 randomInteriorPoint() const; + void getBounds(class AABox&) const; }; + } + #endif diff --git a/dep/include/g3dlite/G3D/CollisionDetection.h b/dep/include/g3dlite/G3D/CollisionDetection.h index ee4683771a4..4add967ed8b 100644 --- a/dep/include/g3dlite/G3D/CollisionDetection.h +++ b/dep/include/g3dlite/G3D/CollisionDetection.h @@ -1,20 +1,26 @@ /** @file CollisionDetection.h + Moving collision detection for simple primitives. + @author Morgan McGuire, matrix@graphics3d.com @cite Spherical collision based on Paul Nettle's ftp://ftp.3dmaileffects.com/pub/FluidStudios/CollisionDetection/Fluid_Studios_Generic_Collision_Detection_for_Games_Using_Ellipsoids.pdf and comments by Max McGuire. Ray-sphere intersection by Eric Haines. Box-Box intersection written by Kevin Egan. Thanks to Max McGuire of Iron Lore for various bug fixes. + @created 2001-11-19 @edited 2006-01-10 + Copyright 2000-2006, Morgan McGuire. All rights reserved. */ + #ifndef G3D_COLLISIONDETECTION_H #define G3D_COLLISIONDETECTION_H + #include "G3D/platform.h" #include "G3D/Vector3.h" #include "G3D/Plane.h" @@ -23,15 +29,19 @@ #include "G3D/Array.h" #include "G3D/Ray.h" #include "G3D/Line.h" + namespace G3D { + /** Collision detection primitives and tools for building higher order collision detection schemes. + These routines provide moving and static collision detection. Moving collision detection allows the calculation of collisions that occur during a period of time -- as opposed to the intersection of two static bodies. + Moving collision detection routines detect collisions between only static primitives and moving spheres or points. Since the reference frame can be user defined, these functions can be used to @@ -39,18 +49,23 @@ namespace G3D { the velocity vector of one object from the velocity vector of the sphere or point the detection is to occur with. This unified velocity vector will act as if both objects are moving simultaneously. + Collisions are detected for single-sided objects only. That is, no collision is detected when leaving a primitive or passing through a plane or triangle opposite the normal... except for the point-sphere calculation or when otherwise noted. + For a sphere, the collision location returned is the point in world space where the surface of the sphere and the fixed object meet. It is not the position of the center of the sphere at the time of the collision. + The collision normal returned is the surface normal to the fixed object at the collision location. +

Static Collision Detection: (Neither object is moving) + @@ -65,56 +80,69 @@ namespace G3D {
Vector3LineSegmentRay *LinePlaneTriangleSphereCylinderCapsuleAABoxBox
Vector3Vector3::operator== Vector3::fuzzyEq G3D::distance
AABoxAABox::contains
BoxBox::contains(treat as Ray)CollisionDetection::collisionTimeForMovingPointFixedBox(treat as Ray)CollisionDetection::penetrationDepthForFixedBoxFixedPlaneCollisionDetection::penetrationDepthForFixedBoxFixedPlaneCollisionDetection::penetrationDepthForFixedSphereFixedBoxNone (use OPCODE)CollisionDetection::movingSpherePassesThroughFixedBoxCollisionDetection::penetrationDepthForFixedBoxFixedBoxCollisionDetection::penetrationDepthForFixedBoxFixedBox
+

Moving Collision Detection: + * Note: Moving collision detection against certain primitives is equivalent to static collision detection against a bigger primitive. Ray, Line Segment == ``moving Point''; Capsule ==``moving Sphere''; Plane == ``moving Line'' */ class CollisionDetection { private: + /** Default parameter if value passed to a function as reference is not to be calculated. Must be explicitly supported by function. */ static Vector3 ignore; + /** Default parameter if value passed to a function as reference is not to be calculated. Must be explicitly supported by function. */ static bool ignoreBool; + /** Default parameter if value passed to a function as reference is not to be calculated. Must be explicitly supported by function. */ static Array ignoreArray; + // Static class! CollisionDetection() {} virtual ~CollisionDetection() {} + public: + /** Converts an index [0, 15] to the corresponding separating axis. Does not return normalized vector in the edge-edge case (indices 6 through 15). + @param separatingAxisIndex Separating axis. @param box1 Box 1. @param box2 Box 2. + @return Axis that separates the two boxes. */ static Vector3 separatingAxisForSolidBoxSolidBox( const int separatingAxisIndex, const Box & box1, const Box & box2); + /** Tests whether two boxes have axes that are parallel to each other. If they are, axis1 and axis2 are set to be the parallel axes for both box1 and box2 respectively. + @param ca Dot products of each of the boxes axes @param epsilon Fudge factor (small unit by which the dot products may vary and still be considered zero). @param axis1 Parallel Axis 1. [Post Condition] @param axis2 Parallel Axis 2. [Post Condition] + @return true - If boxes have a parallel axis @return false - otherwise. */ @@ -123,12 +151,14 @@ public: const double epsilon, int & axis1, int & axis2); + /** Calculates the projected distance between the two boxes along the specified separating axis, negative distances correspond to an overlap along that separating axis. The distance is not divided by denominator dot(L, L), see penetrationDepthForFixedSphereFixedBox() for more details + @param separatingAxisIndex @param a Box 1's bounding sphere vector @param b Box 2's bounding sphere vector @@ -139,6 +169,7 @@ public: of Box 1 and Box 2. @param ad Pointer to array of dot products of Box 1 axes and D. @param bd Pointer to array of dot products of Box 2 axes and D. + @return Projected distance between the two boxes along the specified separating axis. */ @@ -152,6 +183,7 @@ public: const double* ad, const double* bd); + /** Creates a set of standard information about two boxes in order to solve for their collision. This information includes a vector to @@ -161,16 +193,20 @@ public: of both boxes (signed and unsigned values), and the dot products between all the axes of box1 and the boxes' center vector and box2 and the boxes' center vector. + @pre The following space requirements must be met: - c[] 9 elements - ca[] 9 elements - ad[] 3 elements - bd[] 3 elements + @cite dobted from David Eberly's papers, variables used in this function correspond to variables used in pages 6 and 7 in the pdf http://www.magic-software.com/Intersection.html http://www.magic-software.com/Documentation/DynamicCollisionDetection.pdf + @note Links are out-dated. (Kept to preserve origin and authorship) + @param box1 Box 1 @param box2 Box 2 @param a Box 1's bounding sphere vector @@ -193,15 +229,18 @@ public: double* ca, double* ad, double* bd); + /** Performs a simple bounding sphere check between two boxes to determine whether these boxes could possibly intersect. This is a very cheap operation (three dot products, two sqrts and a few others). If it returns true, an intersection is possible, but not necessarily guaranteed. + @param a Vector from box A's center to an outer vertex @param b Vector from box B's center to an outer vertex @param D Distance between the centers of the two boxes + @return true - if possible intersection @return false - otherwise (This does not guarantee an intersection) */ @@ -209,20 +248,25 @@ public: const Vector3 & a, const Vector3 & b, const Vector3 & D); + /** Determines whether two fixed solid boxes intersect. + @note To speed up collision detection, the lastSeparatingAxis from the previous time step can be passed in and that plane can be checked first. If the separating axis was not saved, or if the two boxes intersected then lastSeparatingAxis should equal -1. + @cite Adobted from David Eberly's papers, variables used in this function correspond to variables used in pages 6 and 7 in the pdf http://www.magic-software.com/Intersection.html http://www.magic-software.com/Documentation/DynamicCollisionDetection.pdf + @param box1 Box 1. @param box2 Box 2. @param lastSeparatingAxis Last separating axis. (optimization - see note) + @return true - Intersection. @return false - otherwise. */ @@ -230,17 +274,21 @@ public: const Box& box1, const Box& box2, const int lastSeparatingAxis = -1); + /** Calculates the closest points on two lines with each other. If the lines are parallel then using the starting point, else calculate the closest point on each line to the other. + @note This is very similiar to calculating the intersection of two lines. Logically then, the two points calculated would be identical if calculated with inifinite precision, but with the finite precision of floating point calculations, these values could (will) differ as the line slope approaches zero or inifinity. + @cite variables and algorithm based on derivation at the following website: http://softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm + @param line1 Line 1. @param line2 Line 2. @param closest1 Closest point on line 1. @@ -251,6 +299,7 @@ public: const Line & line2, Vector3 & closest1, Vector3 & closest2); + /** Calculates the depth of penetration between two fixed boxes. Contact normal faces away from box1 and into box2. If there is @@ -262,20 +311,24 @@ public: - if the separating axis corresponds to two edges the contact point is the midpoint of the smallest line segment between the two edge lines + @note This is very similiar to calculating the intersection of two lines. Logically then, the two points calculated would be identical if calculated with inifinite precision, but with the finite precision of floating point calculations, these values could (will) differ as the line slope approaches zero or inifinity. + @cite adobted from David Eberly's papers, variables used in this function correspond to variables used in pages 6 and 7 in the pdf http://www.magic-software.com/Intersection.html http://www.magic-software.com/Documentation/DynamicCollisionDetection.pdf + @param box1 Box 1 @param box2 Box 2 @param contactPoints Contact point between boxes. [Post Condition] @param contactNormals Surface normal at contact point. [Post Condition] @param lastSeparatingAxis Last separating axis. (Used for optimization) + @return Depth of penetration between the two boxes. If there is no intersection between the boxes, then a negative value is returned. */ @@ -285,17 +338,20 @@ public: Array& contactPoints, Array& contactNormals, const int lastSeparatingAxis = -1); + /** Calculates the depth of penetration between two fixed spheres as well as the deepest point of Sphere A that penetrates Sphere B. The normal returned points away from the object A, although it may represent a perpendicular to either the faces of object B or object A depending on their relative orientations. + @param sphereA Fixed Sphere A. @param sphereB Fixed Sphere B. @param contactPoints Sphere A's deepest point that penetrates Sphere B. [Post Condition] @param contactNormals Normal at penetration point. [Post Condition] + @return Depth of penetration. If there is no intersection between the objects then the depth will be a negative value. */ @@ -304,14 +360,17 @@ public: const Sphere& sphereB, Array& contactPoints, Array& contactNormals = ignoreArray); + /** Calculates the depth of penetration between a fixed sphere and a fixed box as well as the deepest point of the sphere that penetrates the box and the normal at that intersection. + @note There are three possible intersections between a sphere and box. - Sphere completely contained in the box - Sphere intersects one edge - Sphere intersects one vertex + The contact point and contact normal vary for each of these situations. - Sphere contained in Box: - Normal is based on side of least penetration (as is the depth calculation). @@ -322,12 +381,15 @@ public: - Sphere intersects one vertex - Normal is based on vector from the box center to the vertex of penetration. - Point is vertex of penetration. + @cite Adapted from Jim Arvo's method in Graphics Gems See also http://www.win.tue.nl/~gino/solid/gdc2001depth.pdf + @param sphere Fixed Sphere. @param box Fixed Box. @param contactPoints Sphere point that penetrates the box. [Post Condition] @param contactNormals Normal at the penetration point. [Post Condition] + @return Depth of penetration. If there is no intersection between the objects then the depth will be a negative value. */ @@ -336,15 +398,18 @@ public: const Box& box, Array& contactPoints, Array& contactNormals = ignoreArray); + /** Calculates the depth of penetration between a Fixed Sphere and a Fixed Plane as well as the deepest point of the sphere that penetrates the plane and the plane normal at that intersection. + @param sphere Fixed Sphere. @param plane Fixed Plane. @param contactPoints Sphere point that penetrates the plane. [Post Condition] @param contactNormals Normal at penetration point. [Post Condition] + @return Depth of penetration. If there is no intersection between the objects then the depth will be a negative value. */ @@ -353,15 +418,18 @@ public: const class Plane& planeB, Array& contactPoints, Array& contactNormals = ignoreArray); + /** Calculates the depth of penetration between a fixed box and a fixed plane as well as the vertexes of the box that penetrate the plane and the plane normals at those intersections. + @param box Fixed Box. @param plane Fixed Plane. @param contactPoints Box points that penetrate the plane. [Post Condition] @param contactNormals Normals at penetration points [Post Condition] + @return Depth of penetration. If there is no intersection between the objects then the depth will be a negative value. */ @@ -370,18 +438,22 @@ public: const Plane& plane, Array& contactPoints, Array& contactNormals = ignoreArray); + /** Calculates time between the intersection of a moving point and a fixed plane. + @note This is only a one sided collision test. The side defined by the plane's surface normal is the only one tested. For a two sided collision, call the function once for each side's surface normal. + @param point Moving point. @param velocity Point's velocity. @param plane Fixed plane. @param location Location of collision. [Post Condition] (Infinite vector on no collision) @param outNormal Plane's surface normal. [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -391,12 +463,15 @@ public: const class Plane& plane, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving point and a fixed triangle. + @note This is only a one sided collision test. The side defined by the triangle's surface normal is the only one tested. For a two sided collision, call the function once for each side's surface normal. + @param orig Moving point. @param dir Point's velocity. @param v0 Triangle vertex 1. @@ -404,6 +479,7 @@ public: @param v2 Triangle vertex 3 @param location Location of collision. [Post Condition] (Infinite vector on no collision) + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -415,12 +491,15 @@ public: const Vector3& v2) { return Ray::fromOriginAndDirection(orig, dir).intersectionTime(v0, v1, v2); } + /** Calculates time between the intersection of a moving point and a fixed triangle. + @note This is only a one sided collision test. The side defined by the triangle's surface normal is the only one tested. For a two sided collision, call the function once for each side's surface normal. + @param orig Moving point. @param dir Point's velocity. @param v0 Triangle vertex 1. @@ -428,6 +507,7 @@ public: @param v2 Triangle vertex 3 @param location Location of collision. [Post Condition] (Infinite vector on no collision) + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -444,18 +524,22 @@ public: } return t; } + /** Calculates time between the intersection of a moving point and a fixed triangle. + @note This is only a one sided collision test. The side defined by the triangle's surface normal is the only one tested. For a two sided collision, call the function once for each side's surface normal. + @param orig Moving point. @param dir Point's velocity. @param tri Fixed triangle. @param location Location of collision. [Post Condition] (Infinite vector on no collision) @param normal Triangle's surface normal. [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -465,20 +549,25 @@ public: const Triangle& tri, Vector3& location = ignore, Vector3& normal = ignore) { + float t = collisionTimeForMovingPointFixedTriangle( orig, dir, tri.vertex(0), tri.vertex(1), tri.vertex(2)); + if ((t < inf()) && (&location != &ignore)) { location = orig + dir * t; normal = tri.normal(); } return t; } + /** Calculates time between the intersection of a moving point and a fixed triangle. + @note This is only a one sided collision test. The side defined by the triangle's surface normal is the only one tested. For a two sided collision, call the function once for each side's surface normal. + @param orig Moving point. @param dir Point's velocity. @param v0 Triangle vertex 1. @@ -487,6 +576,7 @@ public: @param location Location of collision. [Post Condition] (Infinite vector on no collision) @param normal Triangle's surface normal. [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -505,11 +595,13 @@ public: } return t; } + /** Unlike other methods, does not support an output normal. If the ray origin is inside the box, returns inf() but inside is set to true. Beta API + @cite Andrew Woo, from "Graphics Gems", Academic Press, 1990 @cite Optimized code by Pierre Terdiman, 2000 (~20-30% faster on my Celeron 500) @cite Epsilon value added by Klaus Hartmann @@ -522,16 +614,20 @@ public: Vector3& outLocation, bool& inside = ignoreBool, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving point and a fixed Axis-Aligned Box (AABox). + @note Avoids the sqrt from collisionTimeForMovingPointFixedAABox. + @param point Moving point. @param velocity Sphere's velocity. @param box Fixed AAbox. @param location Location of collision. [Post Condition] @param Inside Does the ray originate inside the box? [Post Condition] @param normal Box's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -542,16 +638,20 @@ public: Vector3& outLocation, bool& inside = ignoreBool, Vector3& normal = ignore); + /** Calculates time between the intersection of a moving point and a fixed sphere. + @note When ray is starts inside the rectangle, the exiting intersection is detected. + @param point Moving point. @param velocity Point's velocity. @param Sphere Fixed Sphere. @param location Location of collision. [Post Condition] @param outNormal Sphere's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -561,15 +661,19 @@ public: const class Sphere& sphere, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving point and a fixed box. + @note If the point is already inside the box, no collision: inf is returned. + @param point Moving point. @param velocity Sphere's velocity. @param box Fixed box. @param location Position of collision. [Post Condition] @param outNormal Box's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -579,12 +683,15 @@ public: const class Box& box, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving point and a fixed rectangle defined by the points v0, v1, v2, & v3. + @note This is only a one sided collision test. The side defined by the rectangle's surface normal is the only one tested. For a two sided collision, call the function once for each side's surface normal. + @param point Moving point. @param velocity Sphere's velocity. @param v0 Rectangle vertex 1. @@ -593,6 +700,7 @@ public: @param v3 Rectangle vertex 4. @param location Location of collision [Post Condition] @param outNormal Rectangle's surface normal. [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -605,14 +713,17 @@ public: const Vector3& v3, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving point and a fixed capsule. + @param point Moving point. @param velocity Point's velocity. @param capsule Fixed capsule. @param location Location of collision. [Post Condition] @param outNormal Capsule's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -622,15 +733,18 @@ public: const class Capsule& capsule, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving sphere and a fixed triangle. + @param sphere Moving sphere. @param velocity Sphere's velocity. @param plane Fixed Plane. @param location Location of collision -- not center position of sphere at the collision time. [Post Condition] @param outNormal Box's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -640,15 +754,18 @@ public: const class Plane& plane, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving sphere and a fixed triangle. + @param sphere Moving sphere. @param velocity Sphere's velocity. @param triangle Fixed Triangle. @param location Location of collision -- not center position of sphere at the collision time. [Post Condition] @param outNormal Box's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -658,9 +775,11 @@ public: const Triangle& triangle, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving sphere and a fixed rectangle defined by the points v0, v1, v2, & v3. + @param sphere Moving sphere. @param velocity Sphere's velocity. @param v0 Rectangle vertex 1. @@ -670,6 +789,7 @@ public: @param location Location of collision -- not center position of sphere at the collision time. [Post Condition] @param outNormal Box's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -682,17 +802,21 @@ public: const Vector3& v3, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving sphere and a fixed box. + @note This function will not detect an intersection between a moving object that is already interpenetrating the fixed object. + @param sphere Moving sphere. @param velocity Sphere's velocity. @param box Fixed box. @param location Location of collision -- not center position of sphere at the collision time. [Post Condition] @param outNormal Box's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -702,17 +826,21 @@ public: const class Box& box, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving sphere and a fixed sphere. + @note This won't detect a collision if the sphere is already interpenetrating the fixed sphere. + @param movingSphere Moving sphere. @param velocity Sphere's velocity. @param fixedSphere Fixed Sphere. @param location Location of collision -- not center position of sphere at the collision time. [Post Condition] @param outNormal Sphere's surface normal to collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -722,17 +850,21 @@ public: const class Sphere& fixedSphere, Vector3& outLocation, Vector3& outNormal = ignore); + /** Calculates time between the intersection of a moving sphere and a fixed capsule. + @note This won't detect a collision if the sphere is already interpenetrating the capsule. + @param sphere Moving sphere. @param velocity Sphere's velocity. @param capsule Fixed capsule. @param location Location of collision -- not center position of sphere at the collision time. [Post Condition] @param outNormal Capsule's surface normal to the collision [Post Condition] + @return Time til collision. If there is no collision then the return value will be inf(). */ @@ -742,16 +874,20 @@ public: const class Capsule& capsule, Vector3& outLocation, Vector3& outNormal = ignore); + /** Finds the direction of bounce that a sphere would have when it intersects an object with the given time of collision, the collision location and the collision normal. + @note This function works like a pong style ball bounce. + @param sphere Moving sphere. @param velocity Sphere's velocity. @param collisionTime Time of collision. @param collisionLocation Collision location. @param collisionNormal Surface collision normal. + @return Direction of bounce. */ static Vector3 bounceDirection( @@ -760,17 +896,21 @@ public: const float collisionTime, const Vector3& collisionLocation, const Vector3& collisionNormal); + /** Finds the direction of slide given a moving sphere, its velocity, the time of collision and the collision location. This function works as if the sphere intersects the surface and continues to hug it. + @note The result will work well for calculating the movement of a player who collides with an object and continues moving along the object instead of just bouncing off it. + @param sphere Moving sphere. @param velocity Sphere's velocity. @param collisionTime Time of collision @param collisionLocation Collision location. + @return Direction of slide. */ static Vector3 slideDirection( @@ -778,27 +918,34 @@ public: const Vector3& velocity, const float collisionTime, const Vector3& collisionLocation); + /** Finds the closest point on a line segment to a given point. + @param v0 line vertex 1. @param v1 line vertex 2. @param point External point. + @return Closests point to point on the line segment. */ static Vector3 closestPointOnLineSegment( const Vector3& v0, const Vector3& v1, const Vector3& point); + /** Finds the closest point on a line segment to a given point. + @note This is an optimization to closestPointOnLineSegment. Edge length and direction can be used in this function if already pre-calculated. This prevents doing the same work twice. + @param v0 line vertex 1. @param v1 line vertex 2. @param edgeDirection The direction of the segment (unit length). @param edgeLength The length of the segment. @param point External point. + @return Closests point to point on the line segment. */ static Vector3 closestPointOnLineSegment( @@ -807,13 +954,16 @@ public: const Vector3& edgeDirection, float edgeLength, const Vector3& point); + /** Finds the closest point on the perimeter of the triangle to an external point; given a triangle defined by three points v0, v1, & v2, and the external point. + @param v0 Triangle vertex 1. @param v1 Triangle vertex 2. @param v2 Triangle vertex 3. @param point External point. + @return Closests point to point on the perimeter of the triangle. */ @@ -822,17 +972,21 @@ public: const Vector3& v1, const Vector3& v2, const Vector3& point); + /** Finds the closest point on the perimeter of the triangle to an external point; given a triangle defined by the array of points v, its edge directions and their lengths, as well as the external point. + @note This is an optimization to closestPointToTrianglePerimeter. Edge length and direction can be used in this function if already pre-calculated. This prevents doing the same work twice. + @param v0 Triangle vertex 1. @param v1 Triangle vertex 2. @param v2 Triangle vertex 3. @param point External point. + @return Closests point to point on the perimeter of the triangle. */ @@ -841,9 +995,11 @@ public: const Vector3 edgeDirection[3], const double edgeLength[3], const Vector3& point); + /** Tests whether a point is contained within the triangle defined by v0, v1, & v2 and its plane's normal. + @param v0 Triangle vertex 1. @param v1 Triangle vertex 2. @param v2 Triangle vertex 3. @@ -851,6 +1007,7 @@ public: @param point The point in question. @param primaryAxis Primary axis of triangle. This will be detected if not given. This parameter is provided as an optimization. + @return true - if point is inside the triangle. @return false - otherwise */ @@ -861,16 +1018,20 @@ public: const Vector3& normal, const Vector3& point, Vector3::Axis primaryAxis = Vector3::DETECT_AXIS); + /** Tests for the intersection of a moving sphere and a fixed box in a given time limit. + @note Returns true if any part of the sphere is inside the box during the time period (inf means "ever"). Useful for performing bounding-box collision detection. + @param sphere Moving sphere. @param velocity Velocity of moving sphere. @param box Fixed box. @param timeLimit Time limit for intersection test. + @return true - if the two objects will touch. @return false - if there is no intersection. */ @@ -879,15 +1040,19 @@ public: const Vector3& velocity, const Box& box, double timeLimit = inf()); + /** Tests for the intersection of a moving sphere and a fixed sphere in a given time limit. + @note This function will not detect an intersection between a moving object that is already interpenetrating the fixed object. + @param sphere Moving sphere. @param velocity Velocity of moving sphere. @param fixedSphere Fixed sphere. @param timeLimit Time limit for intersection test. + @return true - if the two spheres will touch. @return false - if there is no intersection. */ @@ -896,35 +1061,44 @@ public: const Vector3& velocity, const Sphere& fixedSphere, double timeLimit = inf()); + /** Tests for the intersection of two fixed spheres. + @param sphere1 Fixed sphere 1. @param sphere2 Fixed sphere 2. + @return true - if the two spheres touch. @return false - if there is no intersection. */ static bool fixedSolidSphereIntersectsFixedSolidSphere( const Sphere& sphere1, const Sphere& sphere2); + /** Tests for the intersection of a fixed sphere and a fixed box. + @param sphere Fixed sphere. @param box Fixed box. + @return true - if the two objects touch. @return false - if there is no intersection. */ static bool fixedSolidSphereIntersectsFixedSolidBox( const Sphere& sphere, const Box& box); + /** Tests whether a point is inside a rectangle defined by the vertexes v0, v1, v2, & v3, and the rectangle's plane normal. + @param v0 Rectangle vertex 1. @param v1 Rectangle vertex 2. @param v2 Rectangle vertex 3. @param v3 Rectangle vertex 4. @param normal Normal to rectangle's plane. @param point The point in question. + @return true - if point is inside the rectangle. @return false - otherwise */ @@ -935,15 +1109,18 @@ public: const Vector3& v3, const Vector3& normal, const Vector3& point); + /** Finds the closest point on the perimeter of the rectangle to an external point; given a rectangle defined by four points v0, v1, v2, & v3, and the external point. + @param v0 Rectangle vertex 1. @param v1 Rectangle vertex 2. @param v2 Rectangle vertex 3. @param v3 Rectangle vertex 4. @param point External point. + @return Closests point to point on the perimeter of the rectangle. */ @@ -953,15 +1130,18 @@ public: const Vector3& v2, const Vector3& v3, const Vector3& point); + /** Finds the closest point in the rectangle to an external point; Given a rectangle defined by four points v0, v1, v2, & v3, and the external point. + @param v0 Rectangle vertex 1. @param v1 Rectangle vertex 2. @param v2 Rectangle vertex 3 @param v3 Rectangle vertex 4. @param point External point. + @return Closet point in the rectangle to the external point. */ static Vector3 closestPointToRectangle( @@ -971,6 +1151,8 @@ public: const Vector3& v3, const Vector3& point); }; + } // namespace + #endif // G3D_COLLISIONDETECTION_H diff --git a/dep/include/g3dlite/G3D/CoordinateFrame.h b/dep/include/g3dlite/G3D/CoordinateFrame.h index 9f7bb609dc9..62cbbd47639 100644 --- a/dep/include/g3dlite/G3D/CoordinateFrame.h +++ b/dep/include/g3dlite/G3D/CoordinateFrame.h @@ -1,13 +1,18 @@ /** @file CoordinateFrame.h + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2001-03-04 @edited 2006-04-07 + Copyright 2000-2006, Morgan McGuire. All rights reserved. */ + #ifndef G3D_COORDINATEFRAME_H #define G3D_COORDINATEFRAME_H + #include "G3D/platform.h" #include "G3D/Vector3.h" #include "G3D/Vector4.h" @@ -18,63 +23,85 @@ #include #include #include + namespace G3D { + /** A rigid body RT (rotation-translation) transformation. + CoordinateFrame abstracts a 4x4 matrix that maps object space to world space: + v_world = C * v_object + CoordinateFrame::rotation is the upper 3x3 submatrix, CoordinateFrame::translation is the right 3x1 column. The 4th row is always [0 0 0 1], so it isn't stored. So you don't have to remember which way the multiplication and transformation work, it provides explicit toWorldSpace and toObjectSpace methods. Also, points, vectors (directions), and surface normals transform differently, so they have separate methods. + Some helper functions transform whole primitives like boxes in and out of object space. + Convert to Matrix4 using CoordinateFrame::toMatrix4. You can construct a CoordinateFrame from a Matrix4 using Matrix4::approxCoordinateFrame, however, because a Matrix4 is more general than a CoordinateFrame, some information may be lost. + See also: G3D::Matrix4, G3D::Quat */ class CoordinateFrame { public: + /** Takes object space points to world space. */ Matrix3 rotation; + /** Takes object space points to world space. */ Vector3 translation; + /** The direction an object "looks" relative to its own axes. @deprecated This is always -1 and will be fixed at that value in future releases. */ static const float zLookDirection; + inline bool operator==(const CoordinateFrame& other) const { return (translation == other.translation) && (rotation == other.rotation); } + inline bool operator!=(const CoordinateFrame& other) const { return !(*this == other); } + bool fuzzyEq(const CoordinateFrame& other) const; + bool fuzzyIsIdentity() const; + bool isIdentity() const; + /** Initializes to the identity coordinate frame. */ inline CoordinateFrame() : rotation(Matrix3::identity()), translation(Vector3::zero()) { } + CoordinateFrame(const Vector3& _translation) : rotation(Matrix3::identity()), translation(_translation) { } + CoordinateFrame(const Matrix3 &rotation, const Vector3 &translation) : rotation(rotation), translation(translation) { } + CoordinateFrame(const Matrix3 &rotation) : rotation(rotation), translation(Vector3::zero()) { } + CoordinateFrame(const CoordinateFrame &other) : rotation(other.rotation), translation(other.translation) {} + /** Computes the inverse of this coordinate frame. */ @@ -84,17 +111,22 @@ public: out.translation = -out.rotation * translation; return out; } + inline ~CoordinateFrame() {} + /** See also Matrix4::approxCoordinateFrame */ class Matrix4 toMatrix4() const; + /** Produces an XML serialization of this coordinate frame. */ std::string toXML() const; + /** Returns the heading of the lookVector as an angle in radians relative to the world -z axis. That is, a counter-clockwise heading where north (-z) is 0 and west (-x) is PI/2. + Note that the heading ignores the Y axis, so an inverted object has an inverted heading. */ @@ -103,6 +135,7 @@ public: float angle = -(float) atan2(-look.x, look.z); return angle; } + /** Takes the coordinate frame into object space. this->inverse() * c @@ -110,12 +143,15 @@ public: inline CoordinateFrame toObjectSpace(const CoordinateFrame& c) const { return this->inverse() * c; } + inline Vector4 toObjectSpace(const Vector4& v) const { return this->inverse().toWorldSpace(v); } + inline Vector4 toWorldSpace(const Vector4& v) const { return Vector4(rotation * Vector3(v.x, v.y, v.z) + translation * v.w, v.w); } + /** Transforms the point into world space. */ @@ -125,6 +161,7 @@ public: rotation[1][0] * v[0] + rotation[1][1] * v[1] + rotation[1][2] * v[2] + translation[1], rotation[2][0] * v[0] + rotation[2][1] * v[1] + rotation[2][2] * v[2] + translation[2]); } + /** Transforms the point into object space. */ @@ -138,17 +175,22 @@ public: rotation[0][1] * p[0] + rotation[1][1] * p[1] + rotation[2][1] * p[2], rotation[0][2] * p[0] + rotation[1][2] * p[1] + rotation[2][2] * p[2]); } + /** Transforms the vector into world space (no translation). */ inline Vector3 vectorToWorldSpace(const Vector3& v) const { return rotation * v; } + inline Vector3 normalToWorldSpace(const Vector3& v) const { return rotation * v; } + class Ray toObjectSpace(const Ray& r) const; + Ray toWorldSpace(const Ray& r) const; + /** Transforms the vector into object space (no translation). */ @@ -156,57 +198,86 @@ public: // Multiply on the left (same as rotation.transpose() * v) return v * rotation; } + inline Vector3 normalToObjectSpace(const Vector3 &v) const { // Multiply on the left (same as rotation.transpose() * v) return v * rotation; } + void pointToWorldSpace(const Array& v, Array& vout) const; + void normalToWorldSpace(const Array& v, Array& vout) const; + void vectorToWorldSpace(const Array& v, Array& vout) const; + void pointToObjectSpace(const Array& v, Array& vout) const; + void normalToObjectSpace(const Array& v, Array& vout) const; + void vectorToObjectSpace(const Array& v, Array& vout) const; + class Box toWorldSpace(const class AABox& b) const; + class Box toWorldSpace(const class Box& b) const; + class Cylinder toWorldSpace(const class Cylinder& b) const; + class Capsule toWorldSpace(const class Capsule& b) const; + class Plane toWorldSpace(const class Plane& p) const; + class Sphere toWorldSpace(const class Sphere& b) const; + class Triangle toWorldSpace(const class Triangle& t) const; + class Box toObjectSpace(const AABox& b) const; + class Box toObjectSpace(const Box& b) const; + class Plane toObjectSpace(const Plane& p) const; + class Sphere toObjectSpace(const Sphere& b) const; + Triangle toObjectSpace(const Triangle& t) const; + /** Compose: create the transformation that is other followed by this.*/ CoordinateFrame operator*(const CoordinateFrame &other) const { return CoordinateFrame(rotation * other.rotation, pointToWorldSpace(other.translation)); } + CoordinateFrame operator+(const Vector3& v) const { return CoordinateFrame(rotation, translation + v); } + CoordinateFrame operator-(const Vector3& v) const { return CoordinateFrame(rotation, translation - v); } + void lookAt(const Vector3& target); + void lookAt( const Vector3& target, Vector3 up); + /** @deprecated See lookVector */ inline Vector3 getLookVector() const { return rotation.getColumn(2) * zLookDirection; } + /** The direction this camera is looking (its negative z axis)*/ inline Vector3 lookVector() const { return rotation.getColumn(2) * zLookDirection; } + /** Returns the ray starting at the camera origin travelling in direction CoordinateFrame::lookVector. */ class Ray lookRay() const; + /** Up direction for this camera (its y axis). */ inline Vector3 upVector() const { return rotation.getColumn(1); } + /** If a viewer looks along the look vector, this is the viewer's "left" @deprecated leftVector @@ -214,10 +285,12 @@ public: inline Vector3 getLeftVector() const { return -rotation.getColumn(0); } + /** @deprecated See rightVector */ inline Vector3 getRightVector() const { return rotation.getColumn(0); } + /** If a viewer looks along the look vector, this is the viewer's "left". Useful for strafing motions and building alternative coordinate frames. @@ -225,9 +298,11 @@ public: inline Vector3 leftVector() const { return -rotation.getColumn(0); } + inline Vector3 rightVector() const { return rotation.getColumn(0); } + /** Linearly interpolates between two coordinate frames, using Quat::slerp for the rotations. @@ -235,7 +310,10 @@ public: CoordinateFrame lerp( const CoordinateFrame& other, float alpha) const; + }; + } // namespace + #endif diff --git a/dep/include/g3dlite/G3D/Crypto.h b/dep/include/g3dlite/G3D/Crypto.h index 73eaeeb8fa4..2805e8590c2 100644 --- a/dep/include/g3dlite/G3D/Crypto.h +++ b/dep/include/g3dlite/G3D/Crypto.h @@ -1,34 +1,47 @@ /** @file Crypto.h + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2006-03-29 @edited 2006-04-06 */ + #ifndef G3D_CRYPTO_H #define G3D_CRYPTO_H + #include "G3D/platform.h" #include "G3D/g3dmath.h" #include + namespace G3D { + /** Cryptography and hashing helper functions */ class Crypto { public: + /** Computes the CRC32 value of a byte array. CRC32 is designed to be a hash function that produces different values for similar strings. + This implementation is compatible with PKZIP and GZIP. + Based on http://www.gamedev.net/reference/programming/features/crc32/ */ static uint32 crc32(const void* bytes, size_t numBytes); + /** Returns the nth prime less than 2000 in constant time. The first prime has index 0 and is the number 2. */ static int smallPrime(int n); + /** Returns 1 + the largest value that can be passed to smallPrime. */ static int numSmallPrimes(); }; + } + #endif diff --git a/dep/include/g3dlite/G3D/GCamera.h b/dep/include/g3dlite/G3D/GCamera.h index c7e2f5aa711..50d5ca2244e 100644 --- a/dep/include/g3dlite/G3D/GCamera.h +++ b/dep/include/g3dlite/G3D/GCamera.h @@ -1,57 +1,74 @@ /** @file GCamera.h + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2001-06-02 @edited 2006-02-11 */ + #ifndef G3D_GCAMERA_H #define G3D_GCAMERA_H + #include "G3D/platform.h" #include "G3D/CoordinateFrame.h" #include "G3D/Vector3.h" #include "G3D/Plane.h" + namespace G3D { + /** There is a viewport of width x height size in world space that corresponds to a screenWidth x screenHeight pixel grid on a renderDevice->getWidth() x renderDevice->getHeight() window. + All viewport arguments are the pixel bounds of the viewport-- e.g., RenderDevice::getViewport(). */ class GCamera { private: + /** Vertical field of view (in radians) */ float fieldOfView; + /** The image plane depth corresponding to a vertical field of view, where the film size is 1x1. */ float imagePlaneDepth; + /** Clipping plane, *not* imaging plane. Positive numbers. */ float nearPlane; + /** Positive */ float farPlane; + CoordinateFrame cframe; + public: + class Frustum { public: class Face { public: /** Counter clockwise indices into vertexPos */ int vertexIndex[4]; + /** The plane containing the face. */ Plane plane; }; + /** The vertices, in homogeneous space. If w == 0, a vertex is at infinity. */ Array vertexPos; + /** The faces in the frustum. When the far plane is at infinity, there are 5 faces, otherwise there are 6. The faces are in the order @@ -59,12 +76,16 @@ public: */ Array faceArray; }; + GCamera(); + virtual ~GCamera(); + CoordinateFrame getCoordinateFrame() const; void getCoordinateFrame(CoordinateFrame& c) const; void setCoordinateFrame(const CoordinateFrame& c); + /** Sets the horizontal field of view, in radians. The initial angle is toRadians(55). @@ -75,6 +96,7 @@ public: */ void setFieldOfView(float angle); + /** Sets the field of view based on a desired image plane depth (s') and film dimensions in world space. Depth must be positive. Width, @@ -87,23 +109,28 @@ public: void setImagePlaneDepth( float depth, const class Rect2D& viewport); + inline double getFieldOfView() const { return fieldOfView; } + /** Projects a world space point onto a width x height screen. The returned coordinate uses pixmap addressing: x = right and y = down. The resulting z value is rhw. + If the point is behind the camera, Vector3::inf() is returned. */ G3D::Vector3 project( const G3D::Vector3& point, const class Rect2D& viewport) const; + /** Returns the pixel area covered by a shape of the given world space area at the given z value (z must be negative). */ float worldToScreenSpaceArea(float area, float z, const class Rect2D& viewport) const; + /** Returns the world space 3D viewport corners. These are at the near clipping plane. The corners are constructed @@ -116,6 +143,7 @@ public: Vector3& outUL, Vector3& outLL, Vector3& outLR) const; + /** Returns the image plane depth, s', given the current field of view for film of dimensions width x height. See @@ -124,12 +152,14 @@ public: float getImagePlaneDepth( const class Rect2D& viewport) const; + /** Returns the world space ray passing through the center of pixel (x, y) on the image plane. The pixel x and y axes are opposite the 3D object space axes: (0,0) is the upper left corner of the screen. They are in viewport coordinates, not screen coordinates. + Integer (x, y) values correspond to the upper left corners of pixels. If you want to cast rays through pixel centers, add 0.5 to x and y. @@ -139,36 +169,43 @@ public: float y, const class Rect2D& viewport) const; + /** Returns a negative z-value. */ inline float getNearPlaneZ() const { return -nearPlane; } + /** Returns a negative z-value. */ inline float getFarPlaneZ() const { return -farPlane; } + inline void setFarPlaneZ(float z) { debugAssert(z < 0); farPlane = -z; } + inline void setNearPlaneZ(float z) { debugAssert(z < 0); nearPlane = -z; } + /** Returns the GCamera space width of the viewport. */ float getViewportWidth( const class Rect2D& viewport) const; + /** Returns the GCamera space height of the viewport. */ float getViewportHeight( const class Rect2D& viewport) const; + /** Read back a GCamera space z-value at pixel (x, y) from the depth buffer. double getZValue( @@ -177,28 +214,39 @@ public: const class Rect2D& viewport, double polygonOffset = 0) const; */ + void setPosition(const Vector3& t); + void lookAt(const Vector3& position, const Vector3& up = Vector3::unitY()); + /** Returns the clipping planes of the frustum, in world space. The planes have normals facing into the view frustum. + The plane order is guaranteed to be: Near, Right, Left, Top, Bottom, [Far] + If the far plane is at infinity, the resulting array will have 5 planes, otherwise there will be 6. + The viewport is used only to determine the aspect ratio of the screen; the absolute dimensions and xy values don't matter. */ void getClipPlanes( const Rect2D& viewport, Array& outClip) const; + /** Returns the world space view frustum, which is a truncated pyramid describing the volume of space seen by this camera. */ void getFrustum(const Rect2D& viewport, GCamera::Frustum& f) const; + GCamera::Frustum frustum(const Rect2D& viewport) const; + }; + } // namespace G3D + #endif diff --git a/dep/include/g3dlite/G3D/Line.h b/dep/include/g3dlite/G3D/Line.h index 0741e2f804f..724d5ef88cb 100644 --- a/dep/include/g3dlite/G3D/Line.h +++ b/dep/include/g3dlite/G3D/Line.h @@ -1,64 +1,86 @@ /** @file Line.h + Line class + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2001-06-02 @edited 2006-02-28 */ + #ifndef G3D_LINE_H #define G3D_LINE_H + #include "G3D/platform.h" #include "G3D/Vector3.h" + namespace G3D { + class Plane; + /** An infinite 3D line. */ class Line { protected: + Vector3 _point; Vector3 _direction; + Line(const Vector3& point, const Vector3& direction) { _point = point; _direction = direction.direction(); } + public: + /** Undefined (provided for creating Array only) */ inline Line() {} + virtual ~Line() {} + /** Constructs a line from two (not equal) points. */ static Line fromTwoPoints(const Vector3 &point1, const Vector3 &point2) { return Line(point1, point2 - point1); } + /** Creates a line from a point and a (nonzero) direction. */ static Line fromPointAndDirection(const Vector3& point, const Vector3& direction) { return Line(point, direction); } + /** Returns the closest point on the line to point. */ Vector3 closestPoint(const Vector3& pt) const; + /** Returns the distance between point and the line */ double distance(const Vector3& point) const { return (closestPoint(point) - point).magnitude(); } + /** Returns a point on the line */ Vector3 point() const; + /** Returns the direction (or negative direction) of the line */ Vector3 direction() const; + /** Returns the point where the line and plane intersect. If there is no intersection, returns a point at infinity. */ Vector3 intersection(const Plane &plane) const; }; + };// namespace + #endif diff --git a/dep/include/g3dlite/G3D/Matrix3.h b/dep/include/g3dlite/G3D/Matrix3.h index 3c7849a4121..0fd85b306c9 100644 --- a/dep/include/g3dlite/G3D/Matrix3.h +++ b/dep/include/g3dlite/G3D/Matrix3.h @@ -1,50 +1,67 @@ /** @file Matrix3.h + 3x3 matrix class + @maintainer Morgan McGuire, matrix@graphics3d.com + @cite Portions based on Dave Eberly's Magic Software Library at http://www.magic-software.com + @created 2001-06-02 @edited 2006-04-05 */ + #ifndef G3D_MATRIX3_H #define G3D_MATRIX3_H + #include "G3D/platform.h" #include "G3D/System.h" #include "G3D/Vector3.h" #include "G3D/Vector4.h" + namespace G3D { + /** 3x3 matrix. Do not subclass. */ class Matrix3 { private: + float elt[3][3]; + // Hidden operators bool operator<(const Matrix3&) const; bool operator>(const Matrix3&) const; bool operator<=(const Matrix3&) const; bool operator>=(const Matrix3&) const; + public: + /** Initial values are undefined for performance. See also Matrix3::zero(), Matrix3::identity(), Matrix3::fromAxisAngle, etc.*/ inline Matrix3() {} + Matrix3 (const float aafEntry[3][3]); Matrix3 (const Matrix3& rkMatrix); Matrix3 (float fEntry00, float fEntry01, float fEntry02, float fEntry10, float fEntry11, float fEntry12, float fEntry20, float fEntry21, float fEntry22); + bool fuzzyEq(const Matrix3& b) const; + /** Constructs a matrix from a quaternion. @cite Graphics Gems II, p. 351--354 @cite Implementation from Watt and Watt, pg 362*/ Matrix3(const class Quat& q); + /** Sets all elements. */ void set(float fEntry00, float fEntry01, float fEntry02, float fEntry10, float fEntry11, float fEntry12, float fEntry20, float fEntry21, float fEntry22); + /** * member access, allows use of construct mat[r][c] */ @@ -53,68 +70,84 @@ public: debugAssert(iRow < 3); return (float*)&elt[iRow][0]; } + inline const float* operator[] (int iRow) const { debugAssert(iRow >= 0); debugAssert(iRow < 3); return (const float*)&elt[iRow][0]; } + inline operator float* () { return (float*)&elt[0][0]; } + inline operator const float* () const{ return (const float*)&elt[0][0]; } + Vector3 getColumn (int iCol) const; Vector3 getRow (int iRow) const; void setColumn(int iCol, const Vector3 &vector); void setRow(int iRow, const Vector3 &vector); + // assignment and comparison inline Matrix3& operator= (const Matrix3& rkMatrix) { System::memcpy(elt, rkMatrix.elt, 9 * sizeof(float)); return *this; } + bool operator== (const Matrix3& rkMatrix) const; bool operator!= (const Matrix3& rkMatrix) const; + // arithmetic operations Matrix3 operator+ (const Matrix3& rkMatrix) const; Matrix3 operator- (const Matrix3& rkMatrix) const; /** Matrix-matrix multiply */ Matrix3 operator* (const Matrix3& rkMatrix) const; Matrix3 operator- () const; + Matrix3& operator+= (const Matrix3& rkMatrix); Matrix3& operator-= (const Matrix3& rkMatrix); Matrix3& operator*= (const Matrix3& rkMatrix); + /** * matrix * vector [3x3 * 3x1 = 3x1] */ inline Vector3 operator* (const Vector3& v) const { Vector3 kProd; + for (int r = 0; r < 3; ++r) { kProd[r] = elt[r][0] * v[0] + elt[r][1] * v[1] + elt[r][2] * v[2]; } + return kProd; } + /** * vector * matrix [1x3 * 3x3 = 1x3] */ friend Vector3 operator* (const Vector3& rkVector, const Matrix3& rkMatrix); + /** * matrix * scalar */ Matrix3 operator* (float fScalar) const; + /** scalar * matrix */ friend Matrix3 operator* (double fScalar, const Matrix3& rkMatrix); friend Matrix3 operator* (float fScalar, const Matrix3& rkMatrix); friend Matrix3 operator* (int fScalar, const Matrix3& rkMatrix); + private: /** Multiplication where out != A and out != B */ static void _mul(const Matrix3& A, const Matrix3& B, Matrix3& out); public: + /** Optimized implementation of out = A * B. It is safe (but slow) to call with A, B, and out possibly pointer equal to one another.*/ // This is a static method so that it is not ambiguous whether "this" @@ -128,11 +161,14 @@ public: _mul(A, B, out); } } + private: static void _transpose(const Matrix3& A, Matrix3& out); public: + /** Optimized implementation of out = A.transpose(). It is safe (but slow) to call with A and out possibly pointer equal to one another. + Note that A.transpose() * v can be computed more efficiently as v * A. */ @@ -143,27 +179,36 @@ public: _transpose(A, out); } } + /** Returns true if the rows and column L2 norms are 1.0 and the rows are orthogonal. */ bool isOrthonormal() const; + Matrix3 transpose () const; bool inverse (Matrix3& rkInverse, float fTolerance = 1e-06) const; Matrix3 inverse (float fTolerance = 1e-06) const; float determinant () const; + /** singular value decomposition */ void singularValueDecomposition (Matrix3& rkL, Vector3& rkS, Matrix3& rkR) const; /** singular value decomposition */ void singularValueComposition (const Matrix3& rkL, const Vector3& rkS, const Matrix3& rkR); + /** Gram-Schmidt orthonormalization (applied to columns of rotation matrix) */ void orthonormalize(); + /** orthogonal Q, diagonal D, upper triangular U stored as (u01,u02,u12) */ void qDUDecomposition (Matrix3& rkQ, Vector3& rkD, Vector3& rkU) const; + float spectralNorm () const; + /** matrix must be orthonormal */ void toAxisAngle(Vector3& rkAxis, float& rfRadians) const; + static Matrix3 fromAxisAngle(const Vector3& rkAxis, float fRadians); + /** * The matrix must be orthonormal. The decomposition is yaw*pitch*roll * where yaw is rotation about the Up vector, pitch is rotation about the @@ -187,13 +232,17 @@ public: static Matrix3 fromEulerAnglesYZX (float fYAngle, float fPAngle, float fRAngle); static Matrix3 fromEulerAnglesZXY (float fYAngle, float fPAngle, float fRAngle); static Matrix3 fromEulerAnglesZYX (float fYAngle, float fPAngle, float fRAngle); + /** eigensolver, matrix must be symmetric */ void eigenSolveSymmetric (float afEigenvalue[3], Vector3 akEigenvector[3]) const; + static void tensorProduct (const Vector3& rkU, const Vector3& rkV, Matrix3& rkProduct); std::string toString() const; + static const float EPSILON; + // Special values. // The unguaranteed order of initialization of static variables across // translation units can be a source of annoying bugs, so now the static @@ -214,15 +263,18 @@ public: // http://www.mindview.net/ static const Matrix3& zero(); static const Matrix3& identity(); + // Deprecated. /** @deprecated Use Matrix3::zero() */ static const Matrix3 ZERO; /** @deprecated Use Matrix3::identity() */ static const Matrix3 IDENTITY; + protected: // support for eigensolver void tridiagonal (float afDiag[3], float afSubDiag[3]); bool qLAlgorithm (float afDiag[3], float afSubDiag[3]); + // support for singular value decomposition static const float ms_fSvdEpsilon; static const int ms_iSvdMaxIterations; @@ -230,23 +282,31 @@ protected: Matrix3& kR); static void golubKahanStep (Matrix3& kA, Matrix3& kL, Matrix3& kR); + // support for spectral norm static float maxCubicRoot (float afCoeff[3]); + }; + //---------------------------------------------------------------------------- /** v * M == M.transpose() * v */ inline Vector3 operator* (const Vector3& rkPoint, const Matrix3& rkMatrix) { Vector3 kProd; + for (int r = 0; r < 3; ++r) { kProd[r] = rkPoint[0] * rkMatrix.elt[0][r] + rkPoint[1] * rkMatrix.elt[1][r] + rkPoint[2] * rkMatrix.elt[2][r]; } + return kProd; } + } // namespace + #endif + diff --git a/dep/include/g3dlite/G3D/Plane.h b/dep/include/g3dlite/G3D/Plane.h index 3d57ad1bec8..c7043e23c42 100644 --- a/dep/include/g3dlite/G3D/Plane.h +++ b/dep/include/g3dlite/G3D/Plane.h @@ -1,32 +1,44 @@ /** @file Plane.h + Plane class + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2001-06-02 @edited 2004-07-18 */ + #ifndef G3D_PLANE_H #define G3D_PLANE_H + #include "G3D/platform.h" #include "G3D/Vector3.h" #include "G3D/Vector4.h" + namespace G3D { + /** An infinite 2D plane in 3D space. */ class Plane { private: + /** normal.Dot(x,y,z) = distance */ Vector3 _normal; float _distance; + /** Assumes the normal has unit length. */ Plane(const Vector3& n, float d) : _normal(n), _distance(d) { } + public: + Plane() : _normal(Vector3::unitY()), _distance(0) { } + /** Constructs a plane from three points. */ @@ -34,6 +46,7 @@ public: const Vector3& point0, const Vector3& point1, const Vector3& point2); + /** Constructs a plane from three points, where at most two are at infinity (w = 0, not xyz = inf). @@ -42,14 +55,18 @@ public: Vector4 point0, Vector4 point1, Vector4 point2); + /** The normal will be unitized. */ Plane( const Vector3& __normal, const Vector3& point); + static Plane fromEquation(float a, float b, float c, float d); + virtual ~Plane() {} + /** Returns true if point is on the side the normal points to or is in the plane. @@ -57,10 +74,12 @@ public: inline bool halfSpaceContains(Vector3 point) const { // Clamp to a finite range for testing point = point.clamp(Vector3::minFinite(), Vector3::maxFinite()); + // We can get away with putting values *at* the limits of the float32 range into // a dot product, since the dot product is carried out on float64. return _normal.dot(point) >= _distance; } + /** Returns true if point is on the side the normal points to or is in the plane. @@ -72,6 +91,7 @@ public: return halfSpaceContains(point.xyz() / point.w); } } + /** Returns true if point is on the side the normal points to or is in the plane. Only call on finite points. Faster than halfSpaceContains. @@ -80,46 +100,58 @@ public: debugAssert(point.isFinite()); return _normal.dot(point) >= _distance; } + /** Returns true if the point is nearly in the plane. */ inline bool fuzzyContains(const Vector3 &point) const { return fuzzyEq(point.dot(_normal), _distance); } + inline const Vector3& normal() const { return _normal; } + /** Returns distance from point to plane. Distance is negative if point is behind (not in plane in direction opposite normal) the plane. */ inline float distance(const Vector3& x) const { return (_normal.dot(x) - _distance); } + inline Vector3 closestPoint(const Vector3& x) const { return x + (_normal * (-distance(x))); } + /** Returns normal * distance from origin */ Vector3 center() const { return _normal * _distance; } + /** Inverts the facing direction of the plane so the new normal is the inverse of the old normal. */ void flip(); + /** Returns the equation in the form: + normal.Dot(Vector3(x, y, z)) + d = 0 */ void getEquation(Vector3 &normal, double& d) const; void getEquation(Vector3 &normal, float& d) const; + /** ax + by + cz + d = 0 */ void getEquation(double& a, double& b, double& c, double& d) const; void getEquation(float& a, float& b, float& c, float& d) const; + std::string toString() const; }; + } // namespace + #endif diff --git a/dep/include/g3dlite/G3D/Quat.h b/dep/include/g3dlite/G3D/Quat.h index 2c7fe68353e..f53d70be909 100644 --- a/dep/include/g3dlite/G3D/Quat.h +++ b/dep/include/g3dlite/G3D/Quat.h @@ -1,34 +1,46 @@ /** @file Quat.h + Quaternion + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2002-01-23 @edited 2006-05-10 */ + #ifndef G3D_QUAT_H #define G3D_QUAT_H + #include "G3D/platform.h" #include "G3D/g3dmath.h" #include "G3D/Vector3.h" #include "G3D/Matrix3.h" #include + namespace G3D { + /** Unit quaternions are used in computer graphics to represent rotation about an axis. Any 3x3 rotation matrix can be stored as a quaternion. + A quaternion represents the sum of a real scalar and an imaginary vector: ix + jy + kz + w. A unit quaternion representing a rotation by A about axis v has the form [sin(A/2)*v, cos(A/2)]. For a unit quaternion, q.conj() == q.inverse() is a rotation by -A about v. -q is the same rotation as q (negate both the axis and angle). + A non-unit quaterion q represents the same rotation as q.unitize() (Dam98 pg 28). + Although quaternion-vector operations (eg. Quat + Vector3) are well defined, they are not supported by this class because they typically are bugs when they appear in code. + Do not subclass. + BETA API -- subject to change @cite Erik B. Dam, Martin Koch, Martin Lillholm, Quaternions, Interpolation and Animation. Technical Report DIKU-TR-98/5, Department of Computer Science, University of Copenhagen, Denmark. 1998. */ @@ -39,64 +51,81 @@ private: bool operator>(const Quat&) const; bool operator<=(const Quat&) const; bool operator>=(const Quat&) const; + public: + /** q = [sin(angle / 2) * axis, cos(angle / 2)] + In Watt & Watt's notation, s = w, v = (x, y, z) In the Real-Time Rendering notation, u = (x, y, z), w = w */ float x, y, z, w; + /** Initializes to a zero degree rotation. */ inline Quat() : x(0), y(0), z(0), w(1) {} + Quat( const Matrix3& rot); + inline Quat(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) {} + /** Defaults to a pure vector quaternion */ inline Quat(const Vector3& v, float _w = 0) : x(v.x), y(v.y), z(v.z), w(_w) { } + /** The real part of the quaternion. */ inline const float& real() const { return w; } + inline float& real() { return w; } + /** Note: two quats can represent the Quat::sameRotation and not be equal. */ bool fuzzyEq(const Quat& q) { return G3D::fuzzyEq(x, q.x) && G3D::fuzzyEq(y, q.y) && G3D::fuzzyEq(z, q.z) && G3D::fuzzyEq(w, q.w); } + /** True if these quaternions represent the same rotation (note that every rotation is represented by two values; q and -q). */ bool sameRotation(const Quat& q) { return fuzzyEq(q) || fuzzyEq(-q); } + inline Quat operator-() const { return Quat(-x, -y, -z, -w); } + /** Returns the imaginary part (x, y, z) */ inline const Vector3& imag() const { return *(reinterpret_cast(this)); } + inline Vector3& imag() { return *(reinterpret_cast(this)); } + /** q = [sin(angle/2)*axis, cos(angle/2)] */ static Quat fromAxisAngleRotation( const Vector3& axis, float angle); + /** Returns the axis and angle of rotation represented by this quaternion (i.e. q = [sin(angle/2)*axis, cos(angle/2)]) */ void toAxisAngleRotation( Vector3& axis, double& angle) const; + void toAxisAngleRotation( Vector3& axis, float& angle) const { @@ -104,13 +133,18 @@ public: toAxisAngleRotation(axis, d); angle = (float)d; } + Matrix3 toRotationMatrix() const; + void toRotationMatrix( Matrix3& rot) const; + /** Spherical linear interpolation: linear interpolation along the shortest (3D) great-circle route between two quaternions. + Note: Correct rotations are expected between 0 and PI in the right order. + @cite Based on Game Physics -- David Eberly pg 538-540 @param threshold Critical angle between between rotations at which the algorithm switches to normalized lerp, which is more @@ -120,56 +154,72 @@ public: const Quat& other, float alpha, float threshold = 0.05f) const; + /** Normalized linear interpolation of quaternion components. */ Quat nlerp(const Quat& other, float alpha) const; + /** Negates the imaginary part. */ inline Quat conj() const { return Quat(-x, -y, -z, w); } + inline float sum() const { return x + y + z + w; } + inline float average() const { return sum() / 4.0f; } + inline Quat operator*(float s) const { return Quat(x * s, y * s, z * s, w * s); } + /** @cite Based on Watt & Watt, page 360 */ friend Quat operator* (float s, const Quat& q); + inline Quat operator/(float s) const { return Quat(x / s, y / s, z / s, w / s); } + inline float dot(const Quat& other) const { return (x * other.x) + (y * other.y) + (z * other.z) + (w * other.w); } + /** Note that q-1 = q.conj() for a unit quaternion. @cite Dam99 page 13 */ inline Quat inverse() const { return conj() / dot(*this); } + Quat operator-(const Quat& other) const; + Quat operator+(const Quat& other) const; + /** Quaternion multiplication (composition of rotations). Note that this does not commute. */ Quat operator*(const Quat& other) const; + /* (*this) * other.inverse() */ Quat operator/(const Quat& other) const { return (*this) * other.inverse(); } + /** Is the magnitude nearly 1.0? */ inline bool isUnit(float tolerance = 1e-5) const { return abs(dot(*this) - 1.0f) < tolerance; } + inline float magnitude() const { return sqrtf(dot(*this)); } + inline Quat log() const { if ((x == 0) && (y == 0) && (z == 0)) { if (w > 0) { @@ -197,14 +247,17 @@ public: // Solve for A in q = [sin(A)*v, cos(A)] Vector3 u(x, y, z); double len = u.magnitude(); + if (len == 0.0) { return } double A = atan2((double)w, len); Vector3 v = u / len; + return Quat(v * A, 0); } */ + /** exp q = [sin(A) * v, cos(A)] where q = [Av, 0]. Only defined for pure-vector quaternions */ inline Quat exp() const { @@ -215,10 +268,12 @@ public: return Quat(sinf(A) * v, cosf(A)); } + /** Raise this quaternion to a power. For a rotation, this is the effect of rotating x times as much as the original quaterion. + Note that q.pow(a).pow(b) == q.pow(a + b) @cite Dam98 pg 21 */ @@ -226,6 +281,7 @@ public: return (log() * x).exp(); } + /** @deprecated Use toUnit() @@ -238,6 +294,7 @@ public: return *this / sqrtf(mag2); } } + /** Returns a unit quaterion obtained by dividing through by the magnitude. @@ -245,6 +302,7 @@ public: inline Quat toUnit() const { return unitize(); } + /** The linear algebra 2-norm, sqrt(q dot q). This matches the value used in Dam's 1998 tech report but differs from the @@ -254,6 +312,7 @@ public: inline float norm() const { return magnitude(); } + // access quaternion as q[0] = q.x, q[1] = q.y, q[2] = q.z, q[3] = q.w // // WARNING. These member functions rely on @@ -261,11 +320,14 @@ public: // (2) the data packed in a 4*sizeof(float) memory block const float& operator[] (int i) const; float& operator[] (int i); + /** Generate uniform random unit quaternion (i.e. random "direction") @cite From "Uniform Random Rotations", Ken Shoemake, Graphics Gems III. */ static Quat unitRandom(); + // 2-char swizzles + Vector2 xx() const; Vector2 yx() const; Vector2 zx() const; @@ -282,7 +344,9 @@ public: Vector2 yw() const; Vector2 zw() const; Vector2 ww() const; + // 3-char swizzles + Vector3 xxx() const; Vector3 yxx() const; Vector3 zxx() const; @@ -347,7 +411,9 @@ public: Vector3 yww() const; Vector3 zww() const; Vector3 www() const; + // 4-char swizzles + Vector4 xxxx() const; Vector4 yxxx() const; Vector4 zxxx() const; @@ -605,24 +671,33 @@ public: Vector4 zwww() const; Vector4 wwww() const; }; + inline Quat exp(const Quat& q) { return q.exp(); } + inline Quat log(const Quat& q) { return q.log(); } + inline G3D::Quat operator*(double s, const G3D::Quat& q) { return q * (float)s; } + inline G3D::Quat operator*(float s, const G3D::Quat& q) { return q * s; } + } // Namespace G3D + // Outside the namespace to avoid overloading confusion for C++ inline G3D::Quat pow(const G3D::Quat& q, double x) { return q.pow((float)x); } + + #include "Quat.inl" + #endif diff --git a/dep/include/g3dlite/G3D/Quat.inl b/dep/include/g3dlite/G3D/Quat.inl index 6b1805ec6e7..705cb0455d4 100644 --- a/dep/include/g3dlite/G3D/Quat.inl +++ b/dep/include/g3dlite/G3D/Quat.inl @@ -1,28 +1,38 @@ /** Quat.inl - @cite Quaternion implementation based on Watt & Watt page 363. + + @cite Quaternion implementation based on Watt & Watt page 363. Thanks to Max McGuire for slerp optimizations. + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2002-01-23 @edited 2004-03-04 */ + namespace G3D { + inline float& Quat::operator[] (int i) { debugAssert(i >= 0); debugAssert(i < 4); return ((float*)this)[i]; } + inline const float& Quat::operator[] (int i) const { debugAssert(i >= 0); debugAssert(i < 4); return ((float*)this)[i]; } + + inline Quat Quat::operator-(const Quat& other) const { return Quat(x - other.x, y - other.y, z - other.z, w - other.w); } + inline Quat Quat::operator+(const Quat& other) const { return Quat(x + other.x, y + other.y, z + other.z, w + other.w); } + } diff --git a/dep/include/g3dlite/G3D/Ray.h b/dep/include/g3dlite/G3D/Ray.h index b44796420f0..3929cf1e6ac 100644 --- a/dep/include/g3dlite/G3D/Ray.h +++ b/dep/include/g3dlite/G3D/Ray.h @@ -1,16 +1,23 @@ /** @file Ray.h + Ray class + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2002-07-12 @edited 2006-02-21 */ + #ifndef G3D_RAY_H #define G3D_RAY_H + #include "G3D/platform.h" #include "G3D/Vector3.h" #include "G3D/Triangle.h" + namespace G3D { + /** A 3D Ray. */ @@ -20,23 +27,30 @@ private: this->origin = origin; this->direction = direction; } + public: Vector3 origin; + /** Not unit length */ Vector3 direction; + Ray() : origin(Vector3::zero()), direction(Vector3::zero()) {} + virtual ~Ray() {} + /** Creates a Ray from a origin and a (nonzero) direction. */ static Ray fromOriginAndDirection(const Vector3& point, const Vector3& direction) { return Ray(point, direction); } + Ray unit() const { return Ray(origin, direction.unit()); } + /** Returns the closest point on the Ray to point. */ @@ -48,33 +62,43 @@ public: return this->origin + direction * t; } } + /** Returns the closest distance between point and the Ray */ float distance(const Vector3& point) const { return (closestPoint(point) - point).magnitude(); } + /** Returns the point where the Ray and plane intersect. If there is no intersection, returns a point at infinity. + Planes are considered one-sided, so the ray will not intersect a plane where the normal faces in the traveling direction. */ Vector3 intersection(const class Plane& plane) const; + /** Returns the distance until intersection with the (solid) sphere. Will be 0 if inside the sphere, inf if there is no intersection. + The ray direction is not normalized. If the ray direction has unit length, the distance from the origin to intersection is equal to the time. If the direction does not have unit length, the distance = time * direction.length(). + See also the G3D::CollisionDetection "movingPoint" methods, which give more information about the intersection. */ float intersectionTime(const class Sphere& sphere) const; + float intersectionTime(const class Plane& plane) const; + float intersectionTime(const class Box& box) const; + float intersectionTime(const class AABox& box) const; + /** The three extra arguments are the weights of vertices 0, 1, and 2 at the intersection point; they are useful for texture mapping @@ -84,6 +108,7 @@ public: const Vector3& v0, const Vector3& v1, const Vector3& v2, const Vector3& edge01, const Vector3& edge02, double& w0, double& w1, double& w2) const; + /** Ray-triangle intersection for a 1-sided triangle. Fastest version. @cite http://www.acm.org/jgt/papers/MollerTrumbore97/ @@ -96,13 +121,16 @@ public: const Vector3& edge01, const Vector3& edge02) const; + inline float intersectionTime( const Vector3& vert0, const Vector3& vert1, const Vector3& vert2) const { + return intersectionTime(vert0, vert1, vert2, vert1 - vert0, vert2 - vert0); } + inline float intersectionTime( const Vector3& vert0, const Vector3& vert1, @@ -110,8 +138,10 @@ public: double& w0, double& w1, double& w2) const { + return intersectionTime(vert0, vert1, vert2, vert1 - vert0, vert2 - vert0, w0, w1, w2); } + /* One-sided triangle */ inline float intersectionTime(const Triangle& triangle) const { @@ -119,6 +149,7 @@ public: triangle.vertex(0), triangle.vertex(1), triangle.vertex(2), triangle.edge01, triangle.edge02); } + inline float intersectionTime( const Triangle& triangle, double& w0, @@ -127,6 +158,7 @@ public: return intersectionTime(triangle.vertex(0), triangle.vertex(1), triangle.vertex(2), triangle.edge01, triangle.edge02, w0, w1, w2); } + /** Refracts about the normal using G3D::Vector3::refractionDirection and bumps the ray slightly from the newOrigin. */ @@ -135,6 +167,7 @@ public: const Vector3& normal, float iInside, float iOutside) const; + /** Reflects about the normal using G3D::Vector3::reflectionDirection and bumps the ray slightly from @@ -144,44 +177,58 @@ public: const Vector3& normal) const; }; + #define EPSILON 0.000001 #define CROSS(dest,v1,v2) \ dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \ dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; \ dest[2]=v1[0]*v2[1]-v1[1]*v2[0]; + #define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]) + #define SUB(dest,v1,v2) \ dest[0]=v1[0]-v2[0]; \ dest[1]=v1[1]-v2[1]; \ dest[2]=v1[2]-v2[2]; + inline float Ray::intersectionTime( const Vector3& vert0, const Vector3& vert1, const Vector3& vert2, const Vector3& edge1, const Vector3& edge2) const { + (void)vert1; (void)vert2; + // Barycenteric coords float u, v; + float tvec[3], pvec[3], qvec[3]; + // begin calculating determinant - also used to calculate U parameter CROSS(pvec, direction, edge2); + // if determinant is near zero, ray lies in plane of triangle const float det = DOT(edge1, pvec); + if (det < EPSILON) { return (float)inf(); } + // calculate distance from vert0 to ray origin SUB(tvec, origin, vert0); + // calculate U parameter and test bounds u = DOT(tvec, pvec); if ((u < 0.0f) || (u > det)) { // Hit the plane outside the triangle return (float)inf(); } + // prepare to test V parameter CROSS(qvec, tvec, edge1); + // calculate V parameter and test bounds v = DOT(direction, qvec); if ((v < 0.0f) || (u + v > det)) { @@ -189,8 +236,10 @@ inline float Ray::intersectionTime( return (float)inf(); } + // Case where we don't need correct (u, v): const float t = DOT(edge2, qvec); + if (t >= 0.0f) { // Note that det must be positive return t / det; @@ -200,6 +249,7 @@ inline float Ray::intersectionTime( } } + inline float Ray::intersectionTime( const Vector3& vert0, const Vector3& vert1, @@ -209,53 +259,70 @@ inline float Ray::intersectionTime( double& w0, double& w1, double& w2) const { + (void)vert1; (void)vert2; + // Barycenteric coords float u, v; + float tvec[3], pvec[3], qvec[3]; + // begin calculating determinant - also used to calculate U parameter CROSS(pvec, direction, edge2); + // if determinant is near zero, ray lies in plane of triangle const float det = DOT(edge1, pvec); + if (det < EPSILON) { return (float)inf(); } + // calculate distance from vert0 to ray origin SUB(tvec, origin, vert0); + // calculate U parameter and test bounds u = DOT(tvec, pvec); if ((u < 0.0f) || (u > det)) { // Hit the plane outside the triangle return (float)inf(); } + // prepare to test V parameter CROSS(qvec, tvec, edge1); + // calculate V parameter and test bounds v = DOT(direction, qvec); if ((v < 0.0f) || (u + v > det)) { // Hit the plane outside the triangle return (float)inf(); } + float t = DOT(edge2, qvec); + if (t >= 0) { const float inv_det = 1.0f / det; t *= inv_det; u *= inv_det; v *= inv_det; + w0 = (1.0f - u - v); w1 = u; w2 = v; + return t; } else { // We had to travel backwards in time to intersect return (float)inf(); } } + #undef EPSILON #undef CROSS #undef DOT #undef SUB + }// namespace + #endif diff --git a/dep/include/g3dlite/G3D/RegistryUtil.h b/dep/include/g3dlite/G3D/RegistryUtil.h index d5b114d9a87..85b5d0ab1be 100644 --- a/dep/include/g3dlite/G3D/RegistryUtil.h +++ b/dep/include/g3dlite/G3D/RegistryUtil.h @@ -1,22 +1,32 @@ /** @file RegistryUtil.h + @created 2006-04-06 @edited 2006-04-06 + Copyright 2000-2006, Morgan McGuire. All rights reserved. */ + #ifndef G3D_REGISTRYUTIL_H #define G3D_REGISTRYUTIL_H + #include "G3D/platform.h" #include "G3D/g3dmath.h" + // This file is only used on Windows #ifdef G3D_WIN32 + #include + namespace G3D { + /** Provides generalized Windows registry querying. + All key names are one string in the format: "[base key]\[sub-keys]\value" + [base key] can be any of the following: HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG @@ -26,38 +36,52 @@ namespace G3D { HKEY_PERFORMANCE_NLSTEXT HKEY_PERFORMANCE_TEXT HKEY_USERS + keyExists() should be used to validate a key before reading or writing to ensure that a debug assert or false return is for a different error. */ class RegistryUtil { + public: /** returns true if the key exists */ static bool keyExists(const std::string& key); + /** returns false if the key could not be read for any reason. */ static bool readInt32(const std::string& key, int32& valueData); + /** Reads an arbitrary amount of data from a binary registry key. returns false if the key could not be read for any reason. + @beta @param valueData pointer to the output buffer of sufficient size. Pass NULL as valueData in order to have available data size returned in dataSize. @param dataSize size of the output buffer. When NULL is passed for valueData, contains the size of available data on successful return. */ static bool readBytes(const std::string& key, uint8* valueData, uint32& dataSize); + /** returns false if the key could not be read for any reason. */ static bool readString(const std::string& key, std::string& valueData); + /** returns false if the key could not be written for any reason. */ static bool writeInt32(const std::string& key, int32 valueData); + /** Writes an arbitrary amount of data to a binary registry key. returns false if the key could not be written for any reason. + @param valueData pointer to the input buffer @param dataSize size of the input buffer that should be written */ static bool writeBytes(const std::string& key, const uint8* valueData, uint32 dataSize); + /** returns false if the key could not be written for any reason. */ static bool writeString(const std::string& key, const std::string& valueData); + }; + } // namespace G3D + #endif // G3D_WIN32 + #endif // G3D_REGISTRYTUIL_H diff --git a/dep/include/g3dlite/G3D/Sphere.h b/dep/include/g3dlite/G3D/Sphere.h index 3ab1b19c74a..122e4d41f65 100644 --- a/dep/include/g3dlite/G3D/Sphere.h +++ b/dep/include/g3dlite/G3D/Sphere.h @@ -1,48 +1,65 @@ /** @file Sphere.h + Sphere class + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2001-06-02 @edited 2004-07-05 */ + #ifndef G3D_SPHERE_H #define G3D_SPHERE_H + #include "G3D/platform.h" #include "G3D/Vector3.h" #include "G3D/Array.h" #include "G3D/Sphere.h" + namespace G3D { + /** Sphere. */ class Sphere { private: + static int32 dummy; + public: Vector3 center; float radius; + Sphere() { center = Vector3::zero(); radius = 0; } + Sphere( const Vector3& center, float radius) { + this->center = center; this->radius = radius; } + virtual ~Sphere() {} + bool operator==(const Sphere& other) const { return (center == other.center) && (radius == other.radius); } + bool operator!=(const Sphere& other) const { return !((center == other.center) && (radius == other.radius)); } + /** Returns true if point is less than or equal to radius away from the center. */ bool contains(const Vector3& point) const; + /** @deprecated Use culledBy(Array&) */ @@ -52,6 +69,7 @@ public: int32& cullingPlaneIndex, const uint32 testMask, uint32& childMask) const; + /** @deprecated Use culledBy(Array&) */ @@ -60,6 +78,7 @@ public: int numPlanes, int32& cullingPlaneIndex = dummy, const uint32 testMask = -1) const; + /** See AABox::culledBy */ @@ -68,6 +87,7 @@ public: int32& cullingPlaneIndex, const uint32 testMask, uint32& childMask) const; + /** Conservative culling test that does not produce a mask for children. */ @@ -76,25 +96,34 @@ public: int32& cullingPlaneIndex = dummy, const uint32 testMask = -1) const; virtual std::string toString() const; + float volume() const; + /** @deprecated */ float surfaceArea() const; + inline float area() const { return surfaceArea(); } + /** Uniformly distributed on the surface. */ Vector3 randomSurfacePoint() const; + /** Uniformly distributed on the interior (includes surface) */ Vector3 randomInteriorPoint() const; + void getBounds(class AABox& out) const; }; + } // namespace + inline unsigned int hashCode(const G3D::Sphere& sphere) { return (unsigned int)(hashCode(sphere.center) + (sphere.radius * 13)); } + #endif diff --git a/dep/include/g3dlite/G3D/System.h b/dep/include/g3dlite/G3D/System.h index 183faffcf93..ab5a8d60a76 100644 --- a/dep/include/g3dlite/G3D/System.h +++ b/dep/include/g3dlite/G3D/System.h @@ -1,41 +1,58 @@ /** @file System.h + @maintainer Morgan McGuire, matrix@graphics3d.com + @cite Rob Wyatt http://www.gamasutra.com/features/wyatts_world/19990709/processor_detection_01.htm @cite Benjamin Jurke http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-ProcessorDetectionClass&forum=cotd&id=-1 @cite Michael Herf http://www.stereopsis.com/memcpy.html + @created 2003-01-25 @edited 2006-04-26 */ + #ifndef G3D_SYSTEM_H #define G3D_SYSTEM_H + #include "G3D/platform.h" #include "G3D/g3dmath.h" #include + #ifdef G3D_OSX # include #endif + namespace G3D { + typedef double RealTime; + class System { public: + /** Called automatically by the other System routines.*/ static void init(); + /** Guarantees that the start of the array is aligned to the specified number of bytes. */ static void* alignedMalloc(size_t bytes, size_t alignment); + /** Uses pooled storage to optimize small allocations (1 byte to 5 kilobytes). Can be 10x to 100x faster than calling ::malloc or new. + The result must be freed with free. + Threadsafe on Win32. + @sa calloc realloc OutOfMemoryCallback free */ static void* malloc(size_t bytes); + static void* calloc(size_t n, size_t x); + /** @param size Size of memory that the system was trying to allocate @param recoverable If true, the system will attempt to allocate again @@ -45,6 +62,7 @@ public: error was recoverable. */ typedef bool (*OutOfMemoryCallback)(size_t size, bool recoverable); + /** When System::malloc fails to allocate memory because the system is out of memory, it invokes this handler (if it is not NULL). @@ -52,42 +70,54 @@ public: was trying to allocate when it ran out. If the callback returns true, System::malloc will attempt to allocate the memory again. If the callback returns false, then System::malloc will return NULL. + You can use outOfMemoryCallback to free data structures or to register the failure. */ static OutOfMemoryCallback outOfMemoryCallback; + /** Version of realloc that works with System::malloc. */ static void* realloc(void* block, size_t bytes); + /** Returns a string describing how well System::malloc is using its internal pooled storage. "heap" memory was slow to allocate; the other data sizes are comparatively fast.*/ static std::string mallocPerformance(); static void resetMallocPerformanceCounters(); + /** Returns a string describing the current usage of the buffer pools used for optimizing System::malloc. */ static std::string mallocStatus(); + /** Free data allocated with System::malloc. + Threadsafe on Win32. */ static void free(void* p); + /** Frees memory allocated with alignedMalloc. */ static void alignedFree(void* ptr); + /** An implementation of memcpy that may be up to 2x as fast as the C library one on some processors. Guaranteed to have the same behavior as memcpy in all cases. */ static void memcpy(void* dst, const void* src, size_t numBytes); + /** An implementation of memset that may be up to 2x as fast as the C library one on some processors. Guaranteed to have the same behavior as memset in all cases. */ static void memset(void* dst, uint8 value, size_t numBytes); + }; + } // namespace + #endif diff --git a/dep/include/g3dlite/G3D/Table.h b/dep/include/g3dlite/G3D/Table.h index c1da412f3f3..1d021daae2b 100644 --- a/dep/include/g3dlite/G3D/Table.h +++ b/dep/include/g3dlite/G3D/Table.h @@ -1,14 +1,18 @@ /** @file Table.h + Templated hash table class. + @maintainer Morgan McGuire, matrix@graphics3d.com @created 2001-04-22 @edited 2006-10-14 Copyright 2000-2006, Morgan McGuire. All rights reserved. */ + #ifndef G3D_TABLE_H #define G3D_TABLE_H + #include "G3D/platform.h" #include "G3D/Array.h" #include "G3D/debug.h" @@ -17,71 +21,89 @@ #include "G3D/Crypto.h" #include #include + #ifdef G3D_WIN32 # pragma warning (push) // Debug name too long warning # pragma warning (disable : 4786) #endif + template struct GHashCode{}; + template <> struct GHashCode { size_t operator()(int key) const { return static_cast(key); } }; + template <> struct GHashCode { size_t operator()(G3D::uint32 key) const { return static_cast(key); } }; + template <> struct GHashCode { size_t operator()(G3D::uint64 key) const { return static_cast(key); } }; + template <> struct GHashCode { size_t operator()(const void* key) const { return reinterpret_cast(key); } }; + template struct GHashCode { size_t operator()(const T* key) const { return reinterpret_cast(key); } }; + template <> struct GHashCode { size_t operator()(const std::string& key) const { return static_cast(G3D::Crypto::crc32(key.c_str(), key.size())); } }; + template <> struct GHashCode { size_t operator()(const std::string& key) const { return static_cast(G3D::Crypto::crc32(key.c_str(), key.size())); } }; + namespace G3D { + /** An unordered data structure mapping keys to values. + Key must be a pointer, an int, a std::string, a class with a hashCode() method, or provide overloads for: +

     template<> struct GHashCode {
         size_t operator()(Key key) const { return reinterpret_cast( ... ); }
     };
+
    bool operator==(const Key&, const Key&);
   
+ G3D pre-defines GHashCode functions for common types (like int and std::string). If you use a Table with a different type you must write those functions yourself. For example, an enum would use: +
     template<> struct GHashCode {
         size_t operator()(MyEnum key) const { return reinterpret_cast( key ); }
     };
   
+ And rely on the default enum operator==. + Periodically check that debugGetLoad() is low (> 0.1). When it gets near 1.0 your hash function is badly designed and maps too many inputs to the same output. @@ -89,6 +111,7 @@ namespace G3D { template > class Table { public: + /** The pairs returned by iterator. */ @@ -97,6 +120,7 @@ public: Key key; Value value; }; + private: /** Linked list nodes used internally by HashTable. @@ -107,20 +131,24 @@ private: Entry entry; Node* next; + /** Provide pooled allocation for speed. */ inline void* operator new (size_t size) { return System::malloc(size); } + inline void operator delete (void* p) { System::free(p); } + Node(Key key, Value value, size_t hashCode, Node* next) { this->entry.key = key; this->entry.value = value; this->hashCode = hashCode; this->next = next; } + /** Clones a whole chain; */ @@ -128,42 +156,54 @@ private: return new Node(this->entry.key, this->entry.value, hashCode, (next == NULL) ? NULL : next->clone()); } }; + HashFunc m_HashFunc; + /** Number of elements in the table. */ size_t _size; + /** Array of Node*. We don't use Array because Table is lower level. Some elements may be NULL. */ Node** bucket; + /** Length of the bucket array. */ size_t numBuckets; + /** Re-hashes for a larger bucket size. */ void resize(size_t numBuckets) { + Node** oldBucket = bucket; bucket = (Node**)System::alignedMalloc(sizeof(Node*) * numBuckets, 16); System::memset(bucket, 0, sizeof(Node*) * numBuckets); + for (size_t b = 0; b < this->numBuckets; b++) { Node* node = oldBucket[b]; + while (node != NULL) { Node* nextNode = node->next; + // insert at the head of the list for bucket[i] size_t i = node->hashCode % numBuckets; node->next = bucket[i]; bucket[i] = node; + node = nextNode; } } + System::alignedFree(oldBucket); this->numBuckets = numBuckets; } + void copyFrom(const Table& h) { this->_size = h._size; this->numBuckets = h.numBuckets; @@ -175,6 +215,7 @@ private: } } } + /** Frees the heap structures for the nodes. */ @@ -192,7 +233,9 @@ private: numBuckets = 0; _size = 0; } + public: + /** Creates an empty hash table. This causes some heap allocation to occur. */ @@ -202,6 +245,7 @@ public: bucket = (Node**)System::alignedMalloc(sizeof(Node*) * numBuckets, 16); System::memset(bucket, 0, sizeof(Node*) * numBuckets); } + /** Destroys all of the memory allocated by the table, but does not call delete on keys or values if they are pointers. If you want to @@ -211,9 +255,11 @@ public: virtual ~Table() { freeMemory(); } + Table(const Table& h) { this->copyFrom(h); } + Table& operator=(const Table& h) { // No need to copy if the argument is this if (this != &h) { @@ -223,11 +269,13 @@ public: } return *this; } + /** Returns the length of the deepest bucket. */ size_t debugGetDeepestBucketSize() const { size_t deepest = 0; + for (size_t b = 0; b < numBuckets; b++) { size_t count = 0; Node* node = bucket[b]; @@ -235,12 +283,15 @@ public: node = node->next; ++count; } + if (count > deepest) { deepest = count; } } + return deepest; } + /** A small load (close to zero) means the hash table is acting very efficiently most of the time. A large load (close to 1) means @@ -251,22 +302,26 @@ public: double debugGetLoad() const { return debugGetDeepestBucketSize() / (double)size(); } + /** Returns the number of buckets. */ size_t debugGetNumBuckets() const { return numBuckets; } + /** C++ STL style iterator variable. See begin(). */ class Iterator { private: friend class Table; + /** Bucket index. */ size_t index; + /** Linked list node. */ @@ -275,26 +330,31 @@ public: size_t numBuckets; Node** bucket; bool isDone; + /** Creates the end iterator. */ Iterator(const Table* table) : table(const_cast*>(table)) { isDone = true; } + Iterator(const Table* table, size_t numBuckets, Node** bucket) : table(const_cast*>(table)), numBuckets(numBuckets), bucket(bucket) { + if (numBuckets == 0) { // Empty table isDone = true; return; } + index = 0; node = bucket[index]; isDone = false; findNext(); } + /** Finds the next element, setting isDone if one can't be found. Looks at the current element first. @@ -310,10 +370,12 @@ public: } } } + public: inline bool operator!=(const Iterator& other) const { return !(*this == other); } + bool operator==(const Iterator& other) const { if (other.isDone || isDone) { // Common case; check against isDone. @@ -325,6 +387,7 @@ public: (index == other.index); } } + /** Pre increment. */ @@ -333,6 +396,7 @@ public: findNext(); return *this; } + /** Post increment (slower than preincrement). */ @@ -341,17 +405,21 @@ public: ++(*this); return old; } + const Entry& operator*() const { return node->entry; } + Entry* operator->() const { return &(node->entry); } + operator Entry*() const { return &(node->entry); } }; + /** C++ STL style iterator method. Returns the first Entry, which contains a key and value. Use preincrement (++entry) to get to @@ -360,6 +428,7 @@ public: Iterator begin() const { return Iterator(this, numBuckets, bucket); } + /** C++ STL style iterator method. Returns one after the last iterator element. @@ -367,6 +436,7 @@ public: const Iterator end() const { return Iterator(this); } + /** Removes all elements */ @@ -378,6 +448,7 @@ public: System::memset(bucket, 0, sizeof(Node*) * numBuckets); } + /** Returns the number of keys. */ @@ -385,6 +456,7 @@ public: return _size; } + /** If you insert a pointer into the key or value of a table, you are responsible for deallocating the object eventually. Inserting @@ -393,53 +465,68 @@ public: void set(const Key& key, const Value& value) { size_t code = m_HashFunc(key); size_t b = code % numBuckets; + // Go to the bucket Node* n = bucket[b]; + // No bucket, so this must be the first if (n == NULL) { bucket[b] = new Node(key, value, code, NULL); ++_size; return; } + size_t bucketLength = 1; + // Sometimes a bad hash code will cause all elements // to collide. Detect this case and don't rehash when // it occurs; nothing good will come from the rehashing. bool allSameCode = true; + // Try to find the node do { allSameCode = allSameCode && (code == n->hashCode); + if ((code == n->hashCode) && (n->entry.key == key)) { // Replace the existing node. n->entry.value = value; return; } + n = n->next; ++bucketLength; } while (n != NULL); + const size_t maxBucketLength = 5; if ((bucketLength > maxBucketLength) & ! allSameCode && (numBuckets < _size * 20)) { // This bucket was really large; rehash if all elements // don't have the same hashcode the number of buckets is reasonable. resize(numBuckets * 2 + 1); } + // Not found; insert at the head. b = code % numBuckets; bucket[b] = new Node(key, value, code, bucket[b]); ++_size; } + /** Removes an element from the table if it is present. It is an error to remove an element that isn't present. */ void remove(const Key& key) { + size_t code = m_HashFunc(key); size_t b = code % numBuckets; + // Go to the bucket Node* n = bucket[b]; + // Make sure it was found alwaysAssertM(n != NULL, "Tried to remove a key that was not in the table."); + Node* previous = NULL; + // Try to find the node do { if ((code == n->hashCode) && (n->entry.key == key)) { @@ -454,31 +541,39 @@ public: --_size; return; } + previous = n; n = n->next; } while (n != NULL); + alwaysAssertM(false, "Tried to remove a key that was not in the table."); } + /** Returns the value associated with key. @deprecated Use get(key, val) or */ Value& get(const Key& key) const { + size_t code = m_HashFunc(key); size_t b = code % numBuckets; + Node* node = bucket[b]; + while (node != NULL) { if ((node->hashCode == code) && (node->entry.key == key)) { return node->entry.value; } node = node->next; } + debugAssertM(false, "Key not found"); // The next line is here just to make // a compiler warning go away. return node->entry.value; } + /** If the key is present in the table, val is set to the associated value and returns true. If the key is not present, returns false. @@ -486,7 +581,9 @@ public: bool get(const Key& key, Value& val) const { size_t code = m_HashFunc(key); size_t b = code % numBuckets; + Node* node = bucket[b]; + while (node != NULL) { if ((node->hashCode == code) && (node->entry.key == key)) { // found key @@ -495,25 +592,31 @@ public: } node = node->next; } + // Failed to find key return false; } + /** Returns true if key is in the table. */ bool containsKey(const Key& key) const { size_t code = m_HashFunc(key); size_t b = code % numBuckets; + Node* node = bucket[b]; + while (node != NULL) { if ((node->hashCode == code) && (node->entry.key == key)) { return true; } node = node->next; } + return false; } + /** Short syntax for get. */ @@ -521,6 +624,7 @@ public: return get(key); } + /** Returns an array of all of the keys in the table. You can iterate over the keys to get the values. @@ -530,6 +634,7 @@ public: getKeys(keyArray); return keyArray; } + void getKeys(Array& keyArray) const { keyArray.resize(0, DONT_SHRINK_UNDERLYING_ARRAY); for (size_t i = 0; i < numBuckets; i++) { @@ -540,10 +645,13 @@ public: } } } + /** Calls delete on all of the keys. Does not clear the table, however, so you are left with a table of dangling pointers. + Same as getKeys().deleteAll(); + To delete all of the values, you may want something like
         Array keys = table.getKeys();
@@ -558,10 +666,12 @@ public:
    void deleteKeys() {
        getKeys().deleteAll();
    }
+
    /**
     Calls delete on all of the values.  This is unsafe--
     do not call unless you know that each value appears
     at most once.
+
     Does not clear the table, so you are left with a table
     of dangling pointers.
     */
@@ -575,9 +685,12 @@ public:
        }
    }
 };
+
 } // namespace
+
 #ifdef G3D_WIN32
 #   pragma warning (pop)
 #endif
+
 #endif
 
diff --git a/dep/include/g3dlite/G3D/Triangle.h b/dep/include/g3dlite/G3D/Triangle.h
index 146fa0b6455..6852dac9492 100644
--- a/dep/include/g3dlite/G3D/Triangle.h
+++ b/dep/include/g3dlite/G3D/Triangle.h
@@ -1,20 +1,28 @@
 /**
  @file Triangle.h
+
  @maintainer Morgan McGuire, matrix@graphics3d.com
+
  @created 2003-04-05
  @edited  2004-03-14
+
  @cite Random point method by  Greg Turk, Generating random points in triangles.  In A. S. Glassner, ed., Graphics Gems, pp. 24-28. Academic Press, 1990
+
  Copyright 2000-2006, Morgan McGuire.
  All rights reserved.
  */
+
 #ifndef G3D_TRIANGLE_H
 #define G3D_TRIANGLE_H
+
 #include "G3D/platform.h"
 #include "G3D/g3dmath.h"
 #include "G3D/Vector3.h"
 #include "G3D/Plane.h"
 #include 
+
 namespace G3D {
+
 /**
   A generic triangle representation.  This should not be used
   as the underlying triangle for creating models; it is intended
@@ -25,37 +33,54 @@ class Triangle {
 private:
     friend class CollisionDetection;
     friend class Ray;
+
     Vector3                     _vertex[3];
+
     /** edgeDirection[i] is the normalized vector v[i+1] - v[i] */
     Vector3                     edgeDirection[3];
     double                      edgeMagnitude[3];
     Plane                       _plane;
     Vector3::Axis               _primaryAxis;
+
     /** vertex[1] - vertex[0] */
     Vector3                     edge01;
     /** vertex[2] - vertex[0] */
     Vector3                     edge02;
+
     float                       _area;
+
     void init(const Vector3& v0, const Vector3& v1, const Vector3& v2);
+
 public:
+
     Triangle();
+
     Triangle(const Vector3& v0, const Vector3& v1, const Vector3& v2);
+
     ~Triangle();
+
     /** 0, 1, or 2 */
     inline const Vector3& vertex(int n) const {
         debugAssert((n >= 0) && (n < 3));
         return _vertex[n];
     }
+
     double area() const;
+
     Vector3::Axis primaryAxis() const {
         return _primaryAxis;
     }
+
     const Vector3& normal() const;
+
     /** Barycenter */
     Vector3 center() const;
+
     const Plane& plane() const;
+
     /** Returns a random point in the triangle. */
     Vector3 randomPoint() const;
+
     /**
      For two triangles to be equal they must have
      the same vertices in the same order.
@@ -67,19 +92,26 @@ public:
                 return false;
             }
         }
+
         return true;
     }
+
     inline unsigned int hashCode() const {
         return
             _vertex[0].hashCode() +
             (_vertex[1].hashCode() >> 2) +
             _vertex[2].hashCode();
     }
+
     void getBounds(class AABox&) const;
+
 };
+
 } // namespace
+
 inline unsigned int hashCode(const G3D::Triangle& t) {
     return t.hashCode();
 }
+
 #endif
 
diff --git a/dep/include/g3dlite/G3D/Vector2.h b/dep/include/g3dlite/G3D/Vector2.h
index 813ef22c731..3d66e654f93 100644
--- a/dep/include/g3dlite/G3D/Vector2.h
+++ b/dep/include/g3dlite/G3D/Vector2.h
@@ -1,22 +1,30 @@
 /**
   @file Vector2.h
+
   2D vector class
+
   @maintainer Morgan McGuire, matrix@graphics3d.com
+
   @created 2001-06-02
   @edited  2006-01-14
   Copyright 2000-2006, Morgan McGuire.
   All rights reserved.
 */
+
 #ifndef G3D_VECTOR2_H
 #define G3D_VECTOR2_H
+
 #include "G3D/platform.h"
 #include "G3D/g3dmath.h"
 #include "Vector2int16.h"
 #include 
+
 namespace G3D {
+
 class Vector2;
 class Vector3;
 class Vector4;
+
 /**
  Do not subclass-- this implementation makes assumptions about the
  memory layout.
@@ -28,9 +36,11 @@ private:
     bool operator>(const Vector2&) const;
     bool operator<=(const Vector2&) const;
     bool operator>=(const Vector2&) const;
+
 public:
     // coordinates
     float x, y;
+
     // construction
     Vector2();
     Vector2(float x, float y);
@@ -38,10 +48,12 @@ public:
     Vector2(double coordinate[2]);
     Vector2(const Vector2& rkVector);
     Vector2(const class Vector2int16& v);
+
     float& operator[] (int i);
     const float& operator[] (int i) const;
     operator float* ();
     operator const float* () const;
+
     // assignment and comparison
     Vector2& operator= (const Vector2& rkVector);
     bool operator== (const Vector2& rkVector) const;
@@ -51,10 +63,13 @@ public:
     bool fuzzyNe(const Vector2& other) const;
     /** Returns true if this vector has finite length */
     bool isFinite() const;
+
     /** Returns true if this vector has length == 0 */
     bool isZero() const;
+
     /** Returns true if this vector has length == 1 */
     bool isUnit() const;
+
     // arithmetic operations
     Vector2 operator+ (const Vector2& rkVector) const;
     Vector2 operator- (const Vector2& rkVector) const;
@@ -63,25 +78,30 @@ public:
     Vector2 operator/ (const Vector2& rkVector) const;
     Vector2 operator/ (float fScalar) const;
     Vector2 operator- () const;
+
     inline float sum() const {
         return x + y;
     }
+
     /**
      Linear interpolation
      */
     inline Vector2 lerp(const Vector2& v, float alpha) const {
         return (*this) + (v - *this) * alpha;
     }
+
     inline Vector2 clamp(const Vector2& low, const Vector2& high) const {
         return Vector2(
             G3D::clamp(x, low.x, high.x),
             G3D::clamp(y, low.y, high.y));
     }
+
     inline Vector2 clamp(float low, float high) const {
         return Vector2(
             (float)G3D::clamp(x, low, high),
             (float)G3D::clamp(y, low, high));
     }
+
     // arithmetic updates
     Vector2& operator+= (const Vector2& rkVector);
     Vector2& operator-= (const Vector2& rkVector);
@@ -89,6 +109,7 @@ public:
     Vector2& operator/= (float fScalar);
     Vector2& operator*= (const Vector2& rkVector);
     Vector2& operator/= (const Vector2& rkVector);
+
     // vector operations
     float length() const;
     Vector2 direction() const;
@@ -99,13 +120,17 @@ public:
     Vector2 fastDirection() const {
         return direction();
     }
+
     float squaredLength () const;
     float dot (const Vector2& rkVector) const;
     float unitize (float fTolerance = 1e-06);
+
     Vector2 min(const Vector2 &v) const;
     Vector2 max(const Vector2 &v) const;
+
     // Random unit vector
     static Vector2 random();
+
     // Special values.
     // Intentionally not inlined: see Matrix3::identity() for details.
     static const Vector2& zero();
@@ -119,6 +144,8 @@ public:
     /** Largest representable vector */
     static const Vector2& maxFinite();
 
+
+
     // Deprecated. See Matrix3::identity() for details.
     /** @deprecated Use Vector2::zero() */
     static const Vector2 ZERO;
@@ -126,13 +153,18 @@ public:
     static const Vector2 UNIT_S;
     /** @deprecated Use Vector2::unitY() */
     static const Vector2 UNIT_T;
+
     std::string toString() const;
+
     // 2-char swizzles
+
     Vector2 xx() const;
     Vector2 yx() const;
     Vector2 xy() const;
     Vector2 yy() const;
+
     // 3-char swizzles
+
     Vector3 xxx() const;
     Vector3 yxx() const;
     Vector3 xyx() const;
@@ -141,7 +173,9 @@ public:
     Vector3 yxy() const;
     Vector3 xyy() const;
     Vector3 yyy() const;
+
     // 4-char swizzles
+
     Vector4 xxxx() const;
     Vector4 yxxx() const;
     Vector4 xyxx() const;
@@ -158,102 +192,132 @@ public:
     Vector4 yxyy() const;
     Vector4 xyyy() const;
     Vector4 yyyy() const;
+
 };
+
 inline Vector2 operator*(double s, const Vector2& v) {
     return v * (float)s;
 }
+
 inline Vector2 operator*(float s, const Vector2& v) {
     return v * s;
 }
+
 inline Vector2 operator*(int s, const Vector2& v) {
     return v * (float)s;
 }
 
+
 inline unsigned int hashCode(const G3D::Vector2& v) {
      return v.hashCode();
 }
 
+
 inline Vector2::Vector2 () : x(0.0f), y(0.0f) {
 }
 
+
 inline Vector2::Vector2(float _x, float _y) : x(_x), y(_y) {
 }
 
+
 inline Vector2::Vector2 (float afCoordinate[2]) {
     x = afCoordinate[0];
     y = afCoordinate[1];
 }
 
+
+
 inline Vector2::Vector2 (double afCoordinate[2]) {
     x = (float)afCoordinate[0];
     y = (float)afCoordinate[1];
 }
 
+
 inline Vector2::Vector2 (const Vector2& rkVector) {
     x = rkVector.x;
     y = rkVector.y;
 }
 
+
 inline Vector2::Vector2 (const Vector2int16& v) : x(v.x), y(v.y) {
 }
 
+
 inline float& Vector2::operator[] (int i) {
     return ((float*)this)[i];
 }
 
+
 inline const float& Vector2::operator[] (int i) const {
     return ((float*)this)[i];
 }
 
+
 inline Vector2::operator float* () {
     return (float*)this;
 }
+
 inline Vector2::operator const float* () const {
     return (float*)this;
 }
 
+
 inline Vector2& Vector2::operator= (const Vector2& rkVector) {
     x = rkVector.x;
     y = rkVector.y;
     return *this;
 }
 
+
 inline bool Vector2::operator== (const Vector2& rkVector) const {
     return ( x == rkVector.x && y == rkVector.y);
 }
 
+
 inline bool Vector2::operator!= (const Vector2& rkVector) const {
     return ( x != rkVector.x || y != rkVector.y);
 }
 
+
 inline Vector2 Vector2::operator+ (const Vector2& rkVector) const {
     return Vector2(x + rkVector.x, y + rkVector.y);
 }
 
+
 inline Vector2 Vector2::operator- (const Vector2& rkVector) const {
     return Vector2(x - rkVector.x, y - rkVector.y);
 }
 
+
 inline Vector2 Vector2::operator* (float fScalar) const {
     return Vector2(fScalar*x, fScalar*y);
 }
 
+
+
 inline Vector2 Vector2::operator- () const {
     return Vector2( -x, -y);
 }
 
+
+
 inline Vector2& Vector2::operator+= (const Vector2& rkVector) {
     x += rkVector.x;
     y += rkVector.y;
     return *this;
 }
 
+
+
 inline Vector2& Vector2::operator-= (const Vector2& rkVector) {
     x -= rkVector.x;
     y -= rkVector.y;
     return *this;
 }
 
+
+
 inline Vector2& Vector2::operator*= (float fScalar) {
     x *= fScalar;
     y *= fScalar;
@@ -261,36 +325,47 @@ inline Vector2& Vector2::operator*= (float fScalar) {
 }
 
 
+
+
 inline Vector2& Vector2::operator*= (const Vector2& rkVector) {
     x *= rkVector.x;
     y *= rkVector.y;
     return *this;
 }
 
+
+
 inline Vector2& Vector2::operator/= (const Vector2& rkVector) {
     x /= rkVector.x;
     y /= rkVector.y;
     return *this;
 }
 
+
 inline Vector2 Vector2::operator* (const Vector2& rkVector) const {
     return Vector2(x * rkVector.x, y * rkVector.y);
 }
 
+
+
 inline Vector2 Vector2::operator/ (const Vector2& rkVector) const {
     return Vector2(x / rkVector.x, y / rkVector.y);
 }
 
+
 inline float Vector2::squaredLength () const {
     return x*x + y*y;
 }
 
+
 inline float Vector2::length () const {
     return sqrtf(x*x + y*y);
 }
 
+
 inline Vector2 Vector2::direction () const {
     float lenSquared = x * x + y * y;
+
     if (lenSquared != 1.0f) {
         return *this / sqrtf(lenSquared);
     } else {
@@ -298,38 +373,56 @@ inline Vector2 Vector2::direction () const {
     }
 }
 
+
+
 inline float Vector2::dot (const Vector2& rkVector) const {
     return x*rkVector.x + y*rkVector.y;
 }
 
+
+
 inline Vector2 Vector2::min(const Vector2 &v) const {
     return Vector2(G3D::min(v.x, x), G3D::min(v.y, y));
 }
 
+
+
 inline Vector2 Vector2::max(const Vector2 &v) const {
     return Vector2(G3D::max(v.x, x), G3D::max(v.y, y));
 }
 
+
+
 inline bool Vector2::fuzzyEq(const Vector2& other) const {
     return G3D::fuzzyEq((*this - other).squaredLength(), 0);
 }
 
+
+
 inline bool Vector2::fuzzyNe(const Vector2& other) const {
     return G3D::fuzzyNe((*this - other).squaredLength(), 0);
 }
 
+
+
 inline bool Vector2::isFinite() const {
     return G3D::isFinite(x) && G3D::isFinite(y);
 }
 
+
+
 inline bool Vector2::isZero() const {
     return (x == 0.0f) && (y == 0.0f);
 }
 
+
+
 inline bool Vector2::isUnit() const {
     return squaredLength() == 1.0f;
 }
+
 }
+
 // Intentionally outside namespace to avoid operator overloading confusion
 inline G3D::Vector2 operator*(double s, const G3D::Vector2& v) {
     return v * (float)s;
@@ -338,7 +431,9 @@ inline G3D::Vector2 operator*(int s, const G3D::Vector2& v) {
     return v * (float)s;
 }
 
+
 inline unsigned int hashCode(const G3D::Vector2& v);
 
+
 #endif
 
diff --git a/dep/include/g3dlite/G3D/Vector2.inl b/dep/include/g3dlite/G3D/Vector2.inl
index 8a39c703e91..27abecf02ce 100644
--- a/dep/include/g3dlite/G3D/Vector2.inl
+++ b/dep/include/g3dlite/G3D/Vector2.inl
@@ -1,15 +1,20 @@
 /**
  @file Vector2.inl
+ 
  @maintainer Morgan McGuire, matrix@graphics3d.com
  @cite Portions by Laura Wollstadt, graphics3d.com
+ 
  @cite Portions based on Dave Eberly'x Magic Software Library
  at http://www.magic-software.com
-
+ 
+ 
  @created 2001-06-02
  @edited  2006-01-14
+
   Copyright 2000-2006, Morgan McGuire.
   All rights reserved.
  */
 
+
 }
 
diff --git a/dep/include/g3dlite/G3D/Vector2int16.h b/dep/include/g3dlite/G3D/Vector2int16.h
index f6459085d0f..40f39bae43d 100644
--- a/dep/include/g3dlite/G3D/Vector2int16.h
+++ b/dep/include/g3dlite/G3D/Vector2int16.h
@@ -1,16 +1,23 @@
 /**
   @file Vector2int16.h
+
   @maintainer Morgan McGuire, matrix@brown.edu
+
   @created 2003-08-09
   @edited  2004-01-03
+
   Copyright 2000-2006, Morgan McGuire.
   All rights reserved.
  */
+
 #ifndef VECTOR2INT16_H
 #define VECTOR2INT16_H
+
 #include "G3D/platform.h"
 #include "G3D/g3dmath.h"
+
 namespace G3D {
+
 /**
  A Vector2 that packs its fields into uint16s.
  */
@@ -18,6 +25,7 @@ namespace G3D {
     // Switch to tight alignment
     #pragma pack(push, 2)
 #endif
+
 class Vector2int16 {
 private:
     // Hidden operators
@@ -25,35 +33,44 @@ private:
     bool operator>(const Vector2int16&) const;
     bool operator<=(const Vector2int16&) const;
     bool operator>=(const Vector2int16&) const;
+
 public:
     G3D::int16              x;
     G3D::int16              y;
+
     Vector2int16() : x(0), y(0) {}
     Vector2int16(G3D::int16 _x, G3D::int16 _y) : x(_x), y(_y){}
     Vector2int16(const class Vector2& v);
+
     inline G3D::int16& operator[] (int i) {
         debugAssert(((unsigned int)i) <= 1);
         return ((G3D::int16*)this)[i];
     }
+
     inline const G3D::int16& operator[] (int i) const {
         debugAssert(((unsigned int)i) <= 1);
         return ((G3D::int16*)this)[i];
     }
 
+
     inline bool operator== (const Vector2int16& rkVector) const {
         return ((int32*)this)[0] == ((int32*)&rkVector)[0];
     }
+
     inline bool operator!= (const Vector2int16& rkVector) const {
         return ((int32*)this)[0] != ((int32*)&rkVector)[0];
     }
+
 }
 #if defined(G3D_LINUX) || defined(G3D_OSX)
     __attribute((aligned(1)))
 #endif
 ;
+
 #ifdef G3D_WIN32
     #pragma pack(pop)
 #endif
+
 }
 #endif
 
diff --git a/dep/include/g3dlite/G3D/Vector3.h b/dep/include/g3dlite/G3D/Vector3.h
index 8b5a1576062..9f46bf87233 100644
--- a/dep/include/g3dlite/G3D/Vector3.h
+++ b/dep/include/g3dlite/G3D/Vector3.h
@@ -1,37 +1,49 @@
 /**
   @file Vector3.h
+
   3D vector class
+
   @maintainer Morgan McGuire, matrix@graphics3d.com
+
   @created 2001-06-02
   @edited  2005-08-23
   Copyright 2000-2006, Morgan McGuire.
   All rights reserved.
  */
+
 #ifndef G3D_VECTOR3_H
 #define G3D_VECTOR3_H
+
 #include "G3D/platform.h"
 #include "G3D/g3dmath.h"
 #include "G3D/Vector2.h"
 #include 
 #include 
+
 namespace G3D {
+
 class Vector2;
 class Vector3;
 class Vector4;
+
 /**
   Swizzles
  Vector classes have swizzle operators, e.g. v.xy(), that
  allow selection of arbitrary sub-fields.  These cannot be used as write
  masks.  Examples
+
   
 Vector3 v(1, 2, 3);
 Vector3 j;
 Vector2 b;
+
 b = v.xz();
 j = b.xx();
 
+ Warning + Do not subclass-- this implementation makes assumptions about the memory layout. */ @@ -42,20 +54,25 @@ private: Note that if used for a collision or ray reflection you must negate the resulting vector to get a direction pointing away from the collision. +
        V'    N      V
+
          r   ^   -,
           \  |  /
             \|/
      
+ See also Vector3::reflectionDirection */ Vector3 reflectAbout(const Vector3& normal) const; + // Hidden operators bool operator<(const Vector3&) const; bool operator>(const Vector3&) const; bool operator<=(const Vector3&) const; bool operator>=(const Vector3&) const; + public: // construction Vector3(); @@ -65,8 +82,10 @@ public: Vector3(double coordinate[3]); Vector3(const Vector3& rkVector); Vector3(const class Vector3int16& v); + // coordinates float x, y, z; + // access vector V as V[0] = V.x, V[1] = V.y, V[2] = V.z // // WARNING. These member functions rely on @@ -74,18 +93,23 @@ public: // (2) the data packed in a 3*sizeof(float) memory block const float& operator[] (int i) const; float& operator[] (int i); + inline operator float* () { return (float*)this; } + operator const float* () const { return (float*)this; } + enum Axis {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, DETECT_AXIS=-1}; + /** Returns the largest dimension. Particularly convenient for determining which plane to project a triangle onto for point-in-polygon tests. */ Axis primaryAxis() const; + // assignment and comparison Vector3& operator= (const Vector3& rkVector); bool operator== (const Vector3& rkVector) const; @@ -93,12 +117,16 @@ public: unsigned int hashCode() const; bool fuzzyEq(const Vector3& other) const; bool fuzzyNe(const Vector3& other) const; + /** Returns true if this vector has finite length. */ bool isFinite() const; + /** Returns true if this vector has length ~= 0 */ bool isZero() const; + /** Returns true if this vector has length ~= 1 */ bool isUnit() const; + // arithmetic operations Vector3 operator+ (const Vector3& v) const; Vector3 operator- (const Vector3& v) const; @@ -107,6 +135,7 @@ public: Vector3 operator* (const Vector3& v) const; Vector3 operator/ (const Vector3& v) const; Vector3 operator- () const; + // arithmetic updates Vector3& operator+= (const Vector3& v); Vector3& operator-= (const Vector3& v); @@ -114,24 +143,30 @@ public: Vector3& operator/= (float s); Vector3& operator*= (const Vector3& v); Vector3& operator/= (const Vector3& v); + /** @deprecated Use magnitude */ float G3D_DEPRECATED length() const; + float magnitude() const; + /** The result is a nan vector if the length is almost zero. */ Vector3 direction() const; + /** Potentially less accurate but faster than direction(). Only works if System::hasSSE is true. */ Vector3 fastDirection() const; + /** See also G3D::Ray::reflect. The length is 1.
        V'    N       V
+
          r   ^    /
           \  |  /
             \|'-
@@ -139,6 +174,7 @@ public:
      */
     Vector3 reflectionDirection(const Vector3& normal) const;
 
+
     /**
      Returns Vector3::zero() if the length is nearly zero, otherwise
      returns a unit vector.
@@ -153,6 +189,7 @@ public:
             return *this * (1.0f / mag);
         }
     }
+
     /**
      Returns the direction of a refracted ray,
      where iExit is the index of refraction for the
@@ -160,14 +197,19 @@ public:
      for the new material.  Like Vector3::reflectionDirection,
      the result has length 1 and is
      pointed away from the intersection.
+
      Returns Vector3::zero() in the case of total internal refraction.
+
      @param iOutside The index of refraction (eta) outside
      (on the positive normal side) of the surface.
+
      @param iInside The index of refraction (eta) inside
      (on the negative normal side) of the surface.
+
      See also G3D::Ray::refract.
      
               N      V
+
               ^    /
               |  /
               |'-
@@ -179,28 +221,37 @@ public:
         const Vector3&  normal,
         float           iInside,
         float           iOutside) const;
+
     /** Synonym for direction */
     inline Vector3 unit() const {
         return direction();
     }
+
     /** Returns a normalized vector.  May be computed with lower precision than unit */
     inline Vector3 fastUnit() const {
         return fastDirection();
     }
+
     /** @deprecated Use squaredMagnitude */
     float G3D_DEPRECATED squaredLength() const;
+
     float squaredMagnitude () const;
+
     /** @deprecated Use squaredMagnitude */
     inline float G3D_DEPRECATED norm() const {
         return squaredMagnitude();
     }
+
     float dot(const Vector3& rkVector) const;
+
     float G3D_DEPRECATED unitize(float fTolerance = 1e-06);
+
     /** Cross product.  Note that two cross products in a row
         can be computed more cheaply: v1 x (v2 x v3) = (v1 dot v3) v2  - (v1 dot v2) v3.
       */
     Vector3 cross(const Vector3& rkVector) const;
     Vector3 unitCross (const Vector3& rkVector) const;
+
     /**
      Returns a matrix such that v.cross() * w = v.cross(w).
      
@@ -210,53 +261,67 @@ public:
      
*/ class Matrix3 cross() const; + Vector3 min(const Vector3 &v) const; Vector3 max(const Vector3 &v) const; + std::string toString() const; + inline Vector3 clamp(const Vector3& low, const Vector3& high) const { return Vector3( G3D::clamp(x, low.x, high.x), G3D::clamp(y, low.y, high.y), G3D::clamp(z, low.z, high.z)); } + inline Vector3 clamp(float low, float high) const { return Vector3( G3D::clamp(x, low, high), G3D::clamp(y, low, high), G3D::clamp(z, low, high)); } + /** Linear interpolation */ inline Vector3 lerp(const Vector3& v, float alpha) const { return (*this) + (v - *this) * alpha; } + /** Gram-Schmidt orthonormalization. */ static void orthonormalize (Vector3 akVector[3]); + /** Random unit vector, uniformly distributed */ static Vector3 random(); + /** Random unit vector, distributed so that the probability of V is proportional to max(V dot Normal, 0). + @cite Henrik Wann Jensen, Realistic Image Synthesis using Photon Mapping eqn 2.24 */ static Vector3 cosRandom(const Vector3& normal); + /** Random vector distributed over the hemisphere about normal. */ static Vector3 hemiRandom(const Vector3& normal); + // Input W must be initialize to a nonzero vector, output is {U,V,W} // an orthonormal basis. A hint is provided about whether or not W // is already unit length. static void generateOrthonormalBasis (Vector3& rkU, Vector3& rkV, Vector3& rkW, bool bUnitLengthW = true); + inline float sum() const { return x + y + z; } + inline float average() const { return sum() / 3.0f; } + // Special values. inline static const Vector3& zero() { static Vector3 v(0, 0, 0); return v; } inline static const Vector3& one() { static Vector3 v(1, 1, 1); return v; } @@ -269,6 +334,7 @@ public: inline static const Vector3& minFinite(){ static Vector3 v(-FLT_MAX, -FLT_MAX, -FLT_MAX); return v; } /** Largest representable vector */ inline static const Vector3& maxFinite(){ static Vector3 v(FLT_MAX, FLT_MAX, FLT_MAX); return v; } + // Deprecated. See Matrix3::identity() for details. /** @deprecated Use Vector3::zero() */ static const Vector3 ZERO; @@ -284,7 +350,9 @@ public: static const Vector3 INF3; /** @deprecated Use Vector3::nan() */ static const Vector3 NAN3; + // 2-char swizzles + Vector2 xx() const; Vector2 yx() const; Vector2 zx() const; @@ -294,7 +362,9 @@ public: Vector2 xz() const; Vector2 yz() const; Vector2 zz() const; + // 3-char swizzles + Vector3 xxx() const; Vector3 yxx() const; Vector3 zxx() const; @@ -322,7 +392,9 @@ public: Vector3 xzz() const; Vector3 yzz() const; Vector3 zzz() const; + // 4-char swizzles + Vector4 xxxx() const; Vector4 yxxx() const; Vector4 zxxx() const; @@ -404,21 +476,30 @@ public: Vector4 xzzz() const; Vector4 yzzz() const; Vector4 zzzz() const; + /** A value that can be passed to ignore a parameter. Never look at the result of dummy. */ static Vector3 dummy; }; + inline G3D::Vector3 operator*(float s, const G3D::Vector3& v) { return v * s; } + inline G3D::Vector3 operator*(double s, const G3D::Vector3& v) { return v * (float)s; } + inline G3D::Vector3 operator*(int s, const G3D::Vector3& v) { return v * (float)s; } + std::ostream& operator<<(std::ostream& os, const Vector3&); + } + unsigned int hashCode(const G3D::Vector3& v); + #include "Vector3.inl" + #endif diff --git a/dep/include/g3dlite/G3D/Vector3.inl b/dep/include/g3dlite/G3D/Vector3.inl index 1bfeb5ed441..e2f328165bb 100644 --- a/dep/include/g3dlite/G3D/Vector3.inl +++ b/dep/include/g3dlite/G3D/Vector3.inl @@ -1,12 +1,16 @@ -/** +/** @file Vector3.inl + @maintainer Morgan McGuire, matrix@graphics3d.com + @cite Portions based on Dave Eberly's Magic Software Library at http://www.magic-software.com + @created 2001-06-02 @edited 2004-05-21 Copyright 2000-2004, Morgan McGuire. All rights reserved. */ + //---------------------------------------------------------------------------- #ifdef SSE // If you receive an error on this line, it is because you do not have the file @@ -19,38 +23,50 @@ // to get this file. # include #endif + inline unsigned int hashCode(const G3D::Vector3& v) { return v.hashCode(); } + namespace G3D { + //---------------------------------------------------------------------------- inline Vector3::Vector3() : x(0.0f), y(0.0f), z(0.0f) { } + //---------------------------------------------------------------------------- + inline Vector3::Vector3 (float fX, float fY, float fZ) : x(fX), y(fY), z(fZ) { } + //---------------------------------------------------------------------------- inline Vector3::Vector3 (float V[3]) : x(V[0]), y(V[1]), z(V[2]){ } //---------------------------------------------------------------------------- inline Vector3::Vector3 (double V[3]) : x((float)V[0]), y((float)V[1]), z((float)V[2]){ } + //---------------------------------------------------------------------------- inline Vector3::Vector3 (const Vector3& V) : x(V.x), y(V.y), z(V.z) { } + //---------------------------------------------------------------------------- + //inline Vector3::Vector3 (const __m128& m) { // Cast from SSE packed floats // *this = *(Vector3*)&m; //} + //---------------------------------------------------------------------------- inline const float& Vector3::operator[] (int i) const { return ((float*)this)[i]; } + inline float& Vector3::operator[] (int i) { return ((float*)this)[i]; } + //---------------------------------------------------------------------------- inline Vector3& Vector3::operator= (const Vector3& rkVector) { x = rkVector.x; @@ -58,49 +74,64 @@ inline Vector3& Vector3::operator= (const Vector3& rkVector) { z = rkVector.z; return *this; } + //---------------------------------------------------------------------------- + inline bool Vector3::fuzzyEq(const Vector3& other) const { return G3D::fuzzyEq((*this - other).squaredMagnitude(), 0); } + //---------------------------------------------------------------------------- + inline bool Vector3::fuzzyNe(const Vector3& other) const { return G3D::fuzzyNe((*this - other).squaredMagnitude(), 0); } + //---------------------------------------------------------------------------- + inline bool Vector3::isFinite() const { return G3D::isFinite(x) && G3D::isFinite(y) && G3D::isFinite(z); } + //---------------------------------------------------------------------------- inline bool Vector3::operator== (const Vector3& rkVector) const { return ( x == rkVector.x && y == rkVector.y && z == rkVector.z ); } + //---------------------------------------------------------------------------- inline bool Vector3::operator!= (const Vector3& rkVector) const { return ( x != rkVector.x || y != rkVector.y || z != rkVector.z ); } + //---------------------------------------------------------------------------- inline Vector3 Vector3::operator+ (const Vector3& rkVector) const { return Vector3(x + rkVector.x, y + rkVector.y, z + rkVector.z); } + //---------------------------------------------------------------------------- inline Vector3 Vector3::operator- (const Vector3& rkVector) const { return Vector3(x - rkVector.x, y - rkVector.y, z - rkVector.z); } + //---------------------------------------------------------------------------- inline Vector3 Vector3::operator* (const Vector3& rkVector) const { return Vector3(x * rkVector.x, y * rkVector.y, z * rkVector.z); } + inline Vector3 Vector3::operator*(float f) const { return Vector3(x * f, y * f, z * f); } + //---------------------------------------------------------------------------- inline Vector3 Vector3::operator/ (const Vector3& rkVector) const { return Vector3(x / rkVector.x, y / rkVector.y, z / rkVector.z); } + //---------------------------------------------------------------------------- inline Vector3 Vector3::operator- () const { return Vector3(-x, -y, -z); } + //---------------------------------------------------------------------------- inline Vector3& Vector3::operator+= (const Vector3& rkVector) { x += rkVector.x; @@ -108,6 +139,7 @@ inline Vector3& Vector3::operator+= (const Vector3& rkVector) { z += rkVector.z; return *this; } + //---------------------------------------------------------------------------- inline Vector3& Vector3::operator-= (const Vector3& rkVector) { x -= rkVector.x; @@ -115,6 +147,7 @@ inline Vector3& Vector3::operator-= (const Vector3& rkVector) { z -= rkVector.z; return *this; } + //---------------------------------------------------------------------------- inline Vector3& Vector3::operator*= (float fScalar) { x *= fScalar; @@ -122,6 +155,7 @@ inline Vector3& Vector3::operator*= (float fScalar) { z *= fScalar; return *this; } + //---------------------------------------------------------------------------- inline Vector3& Vector3::operator*= (const Vector3& rkVector) { x *= rkVector.x; @@ -129,6 +163,7 @@ inline Vector3& Vector3::operator*= (const Vector3& rkVector) { z *= rkVector.z; return *this; } + //---------------------------------------------------------------------------- inline Vector3& Vector3::operator/= (const Vector3& rkVector) { x /= rkVector.x; @@ -136,43 +171,53 @@ inline Vector3& Vector3::operator/= (const Vector3& rkVector) { z /= rkVector.z; return *this; } + //---------------------------------------------------------------------------- inline float Vector3::squaredMagnitude () const { return x*x + y*y + z*z; } + //---------------------------------------------------------------------------- inline float Vector3::squaredLength () const { return squaredMagnitude(); } + //---------------------------------------------------------------------------- inline float Vector3::magnitude() const { return sqrtf(x*x + y*y + z*z); } + //---------------------------------------------------------------------------- inline float Vector3::length() const { return magnitude(); } + //---------------------------------------------------------------------------- inline Vector3 Vector3::direction () const { float lenSquared = squaredMagnitude(); float invSqrt = 1.0f / sqrtf(lenSquared); return Vector3(x * invSqrt, y * invSqrt, z * invSqrt); } + //---------------------------------------------------------------------------- + inline Vector3 Vector3::fastDirection () const { float lenSquared = x * x + y * y + z * z; float invSqrt = rsq(lenSquared); return Vector3(x * invSqrt, y * invSqrt, z * invSqrt); } + //---------------------------------------------------------------------------- inline float Vector3::dot (const Vector3& rkVector) const { return x*rkVector.x + y*rkVector.y + z*rkVector.z; } + //---------------------------------------------------------------------------- inline Vector3 Vector3::cross (const Vector3& rkVector) const { return Vector3(y*rkVector.z - z*rkVector.y, z*rkVector.x - x*rkVector.z, x*rkVector.y - y*rkVector.x); } + //---------------------------------------------------------------------------- inline Vector3 Vector3::unitCross (const Vector3& rkVector) const { Vector3 kCross(y*rkVector.z - z*rkVector.y, z*rkVector.x - x*rkVector.z, @@ -180,20 +225,26 @@ inline Vector3 Vector3::unitCross (const Vector3& rkVector) const { kCross.unitize(); return kCross; } + //---------------------------------------------------------------------------- inline Vector3 Vector3::min(const Vector3 &v) const { return Vector3(G3D::min(v.x, x), G3D::min(v.y, y), G3D::min(v.z, z)); } + //---------------------------------------------------------------------------- inline Vector3 Vector3::max(const Vector3 &v) const { return Vector3(G3D::max(v.x, x), G3D::max(v.y, y), G3D::max(v.z, z)); } + //---------------------------------------------------------------------------- inline bool Vector3::isZero() const { return G3D::fuzzyEq(squaredMagnitude(), 0.0f); } + //---------------------------------------------------------------------------- + inline bool Vector3::isUnit() const { return G3D::fuzzyEq(squaredMagnitude(), 1.0f); } + } // namespace diff --git a/dep/include/g3dlite/G3D/Vector3int16.h b/dep/include/g3dlite/G3D/Vector3int16.h index 84d8bb825de..e0631125960 100644 --- a/dep/include/g3dlite/G3D/Vector3int16.h +++ b/dep/include/g3dlite/G3D/Vector3int16.h @@ -1,16 +1,22 @@ /** @file Vector3int16.h + @maintainer Morgan McGuire, matrix@brown.edu + @created 2003-04-07 @edited 2003-06-24 Copyright 2000-2004, Morgan McGuire. All rights reserved. */ + #ifndef VECTOR3INT16_H #define VECTOR3INT16_H + #include "G3D/platform.h" #include "G3D/g3dmath.h" + namespace G3D { + /** A Vector3 that packs its fields into uint16s. */ @@ -18,6 +24,7 @@ namespace G3D { // Switch to tight alignment #pragma pack(push, 2) #endif + class Vector3int16 { private: // Hidden operators @@ -25,10 +32,12 @@ private: bool operator>(const Vector3int16&) const; bool operator<=(const Vector3int16&) const; bool operator>=(const Vector3int16&) const; + public: G3D::int16 x; G3D::int16 y; G3D::int16 z; + Vector3int16() : x(0), y(0), z(0) {} Vector3int16(G3D::int16 _x, G3D::int16 _y, G3D::int16 _z) : x(_x), y(_y), z(_z) {} Vector3int16(const class Vector3& v); @@ -37,9 +46,11 @@ public: __attribute((aligned(1))) #endif ; + #ifdef G3D_WIN32 #pragma pack(pop) #endif + } #endif diff --git a/dep/include/g3dlite/G3D/Vector4.h b/dep/include/g3dlite/G3D/Vector4.h index ea8b83a5303..1bf243e5ed7 100644 --- a/dep/include/g3dlite/G3D/Vector4.h +++ b/dep/include/g3dlite/G3D/Vector4.h @@ -1,23 +1,32 @@ /** @file Vector4.h + Homogeneous vector class. + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2002-07-09 @edited 2005-03-28 + Copyright 2000-2006, Morgan McGuire. All rights reserved. */ + #ifndef G3D_VECTOR4_H #define G3D_VECTOR4_H + #include "G3D/platform.h" #include "G3D/g3dmath.h" #include "G3D/Vector3.h" #include "G3D/Vector2.h" #include + namespace G3D { + class Vector2; class Vector3; class Vector4; + /** Do not subclass-- this implementation makes assumptions about the memory layout. @@ -29,6 +38,7 @@ private: bool operator>(const Vector4&) const; bool operator<=(const Vector4&) const; bool operator>=(const Vector4&) const; + public: // construction Vector4(); @@ -39,8 +49,10 @@ public: Vector4(const Vector3& rkVector, float fW); Vector4(const Vector2& v1, const Vector2& v2); Vector4(const Vector2& v1, float fz, float fw); + // coordinates float x, y, z, w; + // access vector V as V[0] = V.x, V[1] = V.y, V[2] = V.z, etc. // // WARNING. These member functions rely on @@ -50,63 +62,80 @@ public: const float& operator[] (int i) const; operator float* (); operator const float* () const; + // assignment and comparison Vector4& operator= (const Vector4& rkVector); bool operator== (const Vector4& rkVector) const; bool operator!= (const Vector4& rkVector) const; + inline void set(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } + inline void set(const Vector3& v, float _w) { x = v.x; y = v.y; z = v.z; w = _w; } + inline void set(const Vector2& v, float _z, float _w) { x = v.x; y = v.y; z = _z; w = _w; } + unsigned int hashCode() const; bool fuzzyEq(const Vector4& other) const; bool fuzzyNe(const Vector4& other) const; + inline static const Vector4& inf() { static Vector4 v((float)G3D::inf(), (float)G3D::inf(), (float)G3D::inf(), (float)G3D::inf()); return v; } inline static const Vector4& nan() { static Vector4 v((float)G3D::nan(), (float)G3D::nan(), (float)G3D::nan(), (float)G3D::nan()); return v; } + /** sqrt(this->dot(*this)) */ float length() const; float squaredLength() const; + inline float sum() const { return x + y + z + w; } + /** Returns true if this vector has finite length */ bool isFinite() const; + /** Returns true if this vector has length == 0 */ bool isZero() const; + /** Returns true if this vector has length == 1 */ bool isUnit() const; + // arithmetic operations Vector4 operator+ (const Vector4& rkVector) const; Vector4 operator- (const Vector4& rkVector) const; + inline Vector4 operator*(const Vector4& rkVector) const { return Vector4(x * rkVector.x, y * rkVector.y, z * rkVector.z, w * rkVector.w); } + inline Vector4 operator/(const Vector4& rkVector) const { return Vector4(x / rkVector.x, y / rkVector.y, z / rkVector.z, w / rkVector.w); } + Vector4 operator* (float fScalar) const; Vector4 operator/ (float fScalar) const; Vector4 operator- () const; friend Vector4 operator* (float, const Vector4& rkVector); + // arithmetic updates Vector4& operator+= (const Vector4& rkVector); Vector4& operator-= (const Vector4& rkVector); Vector4& operator*= (float fScalar); Vector4& operator/= (float fScalar); + inline Vector4 clamp(const Vector4& low, const Vector4& high) const { return Vector4( G3D::clamp(x, low.x, high.x), @@ -114,6 +143,7 @@ public: G3D::clamp(z, low.z, high.z), G3D::clamp(w, low.w, high.w)); } + inline Vector4 clamp(float low, float high) const { return Vector4( G3D::clamp(x, low, high), @@ -121,15 +151,21 @@ public: G3D::clamp(z, low, high), G3D::clamp(w, low, high)); } + float dot (const Vector4& rkVector) const; + Vector4 min(const Vector4& v) const; Vector4 max(const Vector4& v) const; + std::string toString() const; + /** Linear interpolation */ Vector4 lerp(const Vector4& v, float alpha) const; + // 2-char swizzles + Vector2 xx() const; Vector2 yx() const; Vector2 zx() const; @@ -146,7 +182,9 @@ public: Vector2 yw() const; Vector2 zw() const; Vector2 ww() const; + // 3-char swizzles + Vector3 xxx() const; Vector3 yxx() const; Vector3 zxx() const; @@ -211,7 +249,9 @@ public: Vector3 yww() const; Vector3 zww() const; Vector3 www() const; + // 4-char swizzles + Vector4 xxxx() const; Vector4 yxxx() const; Vector4 zxxx() const; @@ -468,12 +508,18 @@ public: Vector4 ywww() const; Vector4 zwww() const; Vector4 wwww() const; + }; + } + inline G3D::Vector4 operator* (float s, const G3D::Vector4& v) { return v * s; } + unsigned int hashCode(const G3D::Vector4& v); + #include "Vector4.inl" + #endif diff --git a/dep/include/g3dlite/G3D/Vector4.inl b/dep/include/g3dlite/G3D/Vector4.inl index 324d519d836..48ebf542723 100644 --- a/dep/include/g3dlite/G3D/Vector4.inl +++ b/dep/include/g3dlite/G3D/Vector4.inl @@ -1,25 +1,34 @@ -/** +/** @file Vector4.inl + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2002-07-09 @edited 2003-02-10 */ + //---------------------------------------------------------------------------- + inline unsigned int hashCode(const G3D::Vector4& v) { return v.hashCode(); } + namespace G3D { + //---------------------------------------------------------------------------- inline Vector4::Vector4() { x = y = z = w = 0; } + //---------------------------------------------------------------------------- + inline Vector4::Vector4 (float fX, float fY, float fZ, float fW) { x = fX; y = fY; z = fZ; w = fW; } + //---------------------------------------------------------------------------- inline Vector4::Vector4 (float afCoordinate[4]) { x = afCoordinate[0]; @@ -27,6 +36,7 @@ inline Vector4::Vector4 (float afCoordinate[4]) { z = afCoordinate[2]; w = afCoordinate[3]; } + //---------------------------------------------------------------------------- inline Vector4::Vector4(const Vector4& rkVector) { x = rkVector.x; @@ -41,21 +51,26 @@ inline Vector4::Vector4(const Vector3& rkVector, float fW) { z = rkVector.z; w = fW; } + //---------------------------------------------------------------------------- inline float& Vector4::operator[] (int i) { return ((float*)this)[i]; } + //---------------------------------------------------------------------------- inline const float& Vector4::operator[] (int i) const { return ((float*)this)[i]; } + //---------------------------------------------------------------------------- inline Vector4::operator float* () { return (float*)this; } + inline Vector4::operator const float* () const { return (float*)this; } + //---------------------------------------------------------------------------- inline Vector4& Vector4::operator= (const Vector4& rkVector) { x = rkVector.x; @@ -64,30 +79,37 @@ inline Vector4& Vector4::operator= (const Vector4& rkVector) { w = rkVector.w; return *this; } + //---------------------------------------------------------------------------- inline bool Vector4::operator== (const Vector4& rkVector) const { return ( (x == rkVector.x) && (y == rkVector.y) && (z == rkVector.z) && (w == rkVector.w)); } + //---------------------------------------------------------------------------- inline bool Vector4::operator!= (const Vector4& rkVector) const { return ( x != rkVector.x || y != rkVector.y || z != rkVector.z || w != rkVector.w); } + //---------------------------------------------------------------------------- inline Vector4 Vector4::operator+ (const Vector4& rkVector) const { return Vector4(x + rkVector.x, y + rkVector.y, z + rkVector.z, w + rkVector.w); } + //---------------------------------------------------------------------------- inline Vector4 Vector4::operator- (const Vector4& rkVector) const { return Vector4(x - rkVector.x, y - rkVector.y, z - rkVector.z, w - rkVector.w); } + //---------------------------------------------------------------------------- inline Vector4 Vector4::operator* (float fScalar) const { return Vector4(fScalar*x, fScalar*y, fScalar*z, fScalar*w); } + //---------------------------------------------------------------------------- inline Vector4 Vector4::operator- () const { return Vector4( -x, -y, -z, -w); } + //---------------------------------------------------------------------------- inline Vector4& Vector4::operator+= (const Vector4& rkVector) { x += rkVector.x; @@ -96,6 +118,7 @@ inline Vector4& Vector4::operator+= (const Vector4& rkVector) { w += rkVector.w; return *this; } + //---------------------------------------------------------------------------- inline Vector4& Vector4::operator-= (const Vector4& rkVector) { x -= rkVector.x; @@ -104,11 +127,14 @@ inline Vector4& Vector4::operator-= (const Vector4& rkVector) { w -= rkVector.w; return *this; } + //---------------------------------------------------------------------------- + inline Vector4 Vector4::lerp(const Vector4& v, float alpha) const { - return (*this) + (v - *this) * alpha; + return (*this) + (v - *this) * alpha; } + //---------------------------------------------------------------------------- inline Vector4& Vector4::operator*= (float fScalar) { x *= fScalar; @@ -118,37 +144,50 @@ inline Vector4& Vector4::operator*= (float fScalar) { return *this; } + //---------------------------------------------------------------------------- inline float Vector4::dot(const Vector4& rkVector) const { return x*rkVector.x + y*rkVector.y + z*rkVector.z + w*rkVector.w; } + //---------------------------------------------------------------------------- inline Vector4 Vector4::min(const Vector4 &v) const { return Vector4(G3D::min(v.x, x), G3D::min(v.y, y), G3D::min(v.z, z), G3D::min(v.w, w)); } + //---------------------------------------------------------------------------- inline Vector4 Vector4::max(const Vector4 &v) const { return Vector4(G3D::max(v.x, x), G3D::max(v.y, y), G3D::max(v.z, z), G3D::max(v.w, w)); } + //---------------------------------------------------------------------------- inline bool Vector4::isZero() const { return (x == 0.0f) && (y == 0.0f) && (z == 0.0f) && (w == 0.0f); } + //---------------------------------------------------------------------------- + inline bool Vector4::isFinite() const { return G3D::isFinite(x) && G3D::isFinite(y) && G3D::isFinite(z) && G3D::isFinite(w); } + //---------------------------------------------------------------------------- + inline bool Vector4::isUnit() const { return squaredLength() == 1.0; } + //---------------------------------------------------------------------------- + inline float Vector4::length() const { return sqrtf(squaredLength()); } + //---------------------------------------------------------------------------- + inline float Vector4::squaredLength() const { return x * x + y * y + z * z + w * w; } + } diff --git a/dep/include/g3dlite/G3D/debug.h b/dep/include/g3dlite/G3D/debug.h index e889eff31a8..408dd3ea146 100644 --- a/dep/include/g3dlite/G3D/debug.h +++ b/dep/include/g3dlite/G3D/debug.h @@ -1,9 +1,12 @@ #ifndef G3D_LITE_DEBUG_H #define G3D_LITE_DEBUG_H + #define debugStatement(x) #define debugAssert(x) #define debugAssertM(x, y) #define alwaysAssertM(x, y) + #endif + diff --git a/dep/include/g3dlite/G3D/format.h b/dep/include/g3dlite/G3D/format.h index b04c9cfab76..fd129381791 100644 --- a/dep/include/g3dlite/G3D/format.h +++ b/dep/include/g3dlite/G3D/format.h @@ -1,13 +1,18 @@ /** @file format.h + @maintainer Morgan McGuire, matrix@graphics3d.com + @author 2000-09-09 @edited 2005-11-03 + Copyright 2000-2005, Morgan McGuire. All rights reserved. */ + #ifndef G3D_FORMAT_H #define G3D_FORMAT_H + #include "G3D/platform.h" #include #include @@ -19,12 +24,15 @@ //#include #include #endif + #ifndef _MSC_VER #ifndef __cdecl #define __cdecl __attribute__((cdecl)) #endif #endif + namespace G3D { + /** Produces a string from arguments of the style of printf. This avoids problems with buffer overflows when using sprintf and makes it easy @@ -35,6 +43,7 @@ namespace G3D { std::string format( const char* fmt ...) G3D_CHECK_PRINTF_ARGS; + /** Like format, but can be called with the argument list from a ... function. */ @@ -42,6 +51,8 @@ std::string vformat( const char* fmt, va_list argPtr) G3D_CHECK_VPRINTF_ARGS; + }; // namespace + #endif diff --git a/dep/include/g3dlite/G3D/g3dmath.h b/dep/include/g3dlite/G3D/g3dmath.h index 6005d717482..38ee23fc3c1 100644 --- a/dep/include/g3dlite/G3D/g3dmath.h +++ b/dep/include/g3dlite/G3D/g3dmath.h @@ -1,15 +1,21 @@ /** @file g3dmath.h + Math util class. + @maintainer Morgan McGuire, matrix@graphics3d.com @cite highestBit by Jukka Liimatta + @created 2001-06-02 @edited 2006-01-16 + Copyright 2000-2006, Morgan McGuire. All rights reserved. */ + #ifndef G3DMATH_H #define G3DMATH_H + #ifdef _MSC_VER // Disable conditional expression is constant, which occurs incorrectly on inlined functions # pragma warning (push) @@ -17,70 +23,96 @@ // disable: "C++ exception handler used" # pragma warning (disable : 4530) #endif + #include "G3D/platform.h" #include #include #include #include + /*These defines enable functionality introduced with the 1999 ISO C **standard. They must be defined before the inclusion of math.h to **engage them. If optimisation is enabled, these functions will be **inlined. With optimisation switched off, you have to link in the **maths library using -lm. */ + #define _ISOC9X_SOURCE1 #define _ISOC99_SOURCE1 #define __USE_ISOC9X1 #define __USE_ISOC991 + #include + #include "G3D/debug.h" + #undef min #undef max + namespace G3D { + #if defined(_MSC_VER) + #if !defined(_WIN64) + /** Win32 implementation of the C99 fast rounding routines. + @cite routines are Copyright (C) 2001 Erik de Castro Lopo + Permission to use, copy, modify, distribute, and sell this file for any purpose is hereby granted without fee, provided that the above copyright and this permission notice appear in all copies. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ + __inline long int lrint (double flt) { int intgr; + _asm { fld flt fistp intgr }; + return intgr; } + __inline long int lrintf(float flt) { int intgr; + _asm { fld flt fistp intgr }; + return intgr; } + #else + __inline long int lrint (double flt) { return (long int)floor(flt+0.5f); } + __inline long int lrintf(float flt) { return (long int)floorf(flt+0.5f); } + #endif + #endif + const double fuzzyEpsilon = 0.00001; + /** Returns a reference to a static double. This value should not be tested against directly, instead G3D::isNan() and G3D::isFinite() will return reliable results. */ inline const double& inf() { + // We already have included but // not using it in older gcc for safe compilations #if (__GNUC__ == 2) @@ -91,10 +123,12 @@ inline const double& inf() { #endif return i; } + /** Returns a reference to a static double. This value should not be tested against directly, instead G3D::isNan() and G3D::isFinite() will return reliable results. */ inline const double& nan() { + // We already have included but // not using it in older gcc for safe compilations #if (__GNUC__ == 2) @@ -105,21 +139,25 @@ inline const double& nan() { #endif return n; } + /** Returns a reference to a static double. Use instead of G3D_PI. */ inline const double& pi() { static const double p = 3.1415926535898; return p; } + /** Returns a reference to a static double. Use instead of G3D_HALF_PI. */ inline const double& halfPi() { static const double p = 1.5707963267949; return p; } + /** Returns a reference to a static double. Use instead of G3D_TWO_PI. */ inline const double& twoPi() { static const double p = 6.283185; return p; } + /** @def G3D_PI @deprecated Use G3D::pi() instead. */ #define G3D_PI (3.1415926535898) @@ -129,12 +167,14 @@ inline const double& twoPi() { /** @def G3D_TWO_PI @deprecated Use G3D::twoPi() instead. */ #define G3D_TWO_PI (6.283185) + typedef signed char int8; typedef unsigned char uint8; typedef short int16; typedef unsigned short uint16; typedef int int32; typedef unsigned int uint32; + #ifdef _MSC_EXTENSIONS typedef __int64 int64; typedef unsigned __int64 uint64; @@ -143,25 +183,31 @@ typedef unsigned int uint32; typedef unsigned long long uint64; #endif typedef unsigned int uint; + typedef float float32; typedef double float64; + int iAbs(int iValue); int iCeil(double fValue); + /** Clamps the value to the range [low, hi] (inclusive) */ int iClamp(int val, int low, int hi); double clamp(double val, double low, double hi); float clamp(float val, float low, float hi); + /** Returns a + (b - a) * f; */ inline double lerp(double a, double b, double f) { return a + (b - a) * f; } + inline float lerp(float a, float b, float f) { return a + (b - a) * f; } + /** Wraps the value to the range [0, hi) (exclusive on the high end). This is like the clock arithmetic @@ -169,13 +215,17 @@ inline float lerp(float a, float b, float f) { to be positive. */ int iWrap(int val, int hi); + int iFloor(double fValue); + int iSign(int iValue); int iSign(double fValue); + inline int iSign(float f) { return iSign((double)f); } + /** Fast round to integer using the lrint routine. Typically 6x faster than casting to integer. @@ -183,6 +233,7 @@ inline int iSign(float f) { inline int iRound(double fValue) { return lrint(fValue); } + /** Fast round to integer using the lrint routine. Typically 6x faster than casting to integer. @@ -190,11 +241,13 @@ inline int iRound(double fValue) { inline int iRound(float f) { return lrintf(f); } + /** Returns a random number uniformly at random between low and hi (inclusive). */ int iRandom(int low, int hi); + double abs (double fValue); double aCos (double fValue); double aSin (double fValue); @@ -202,121 +255,152 @@ double aTan (double fValue); double aTan2 (double fY, double fX); double sign (double fValue); double square (double fValue); + /** Returns true if the argument is a finite real number. */ bool isFinite(double x); + /** Returns true if the argument is NaN (not a number). You can't use x == nan to test this because all comparisons against nan return false. */ bool isNaN(double x); + /** Computes x % 3. */ int iMod3(int x); + /** [0, 1] @deprecated use uniformRandom() */ double unitRandom (); + /** Uniform random number between low and hi, inclusive. @deprecated use uniformRandom() */ double random(double low, double hi); + /** [-1, 1] @deprecated use uniformRandom() */ double symmetricRandom (); + /** Uniform random number between low and hi, inclusive. [low, hi] */ float uniformRandom(float low = 0.0f, float hi = 1.0f); + /** Normally distributed random number. */ float gaussRandom(float mean = 0.0f, float stdev = 1.0f); + #if defined(_MSC_VER) && (_MSC_VER <= 1200) + /** VC6 lacks std::min and std::max */ inline double min(double x, double y) { return std::_cpp_min(x, y); } + /** VC6 lacks std::min and std::max */ inline float min(float x, float y) { return std::_cpp_min(x, y); } + /** VC6 lacks std::min and std::max */ inline int min(int x, int y) { return std::_cpp_min(x, y); } + /** VC6 lacks std::min and std::max */ inline double max(double x, double y) { return std::_cpp_max(x, y); } + /** VC6 lacks std::min and std::max */ inline float max(float x, float y) { return std::_cpp_max(x, y); } + /** VC6 lacks std::min and std::max */ inline int max(int x, int y) { return std::_cpp_max(x, y); } + #else template inline T min(const T& x, const T& y) { return std::min(x, y); } + template inline T max(const T& x, const T& y) { return std::max(x, y); } + #endif + int iMin(int x, int y); int iMax(int x, int y); + double square(double x); double sumSquares(double x, double y); double sumSquares(double x, double y, double z); double distance(double x, double y); double distance(double x, double y, double z); + /** Returnes the 0-based index of the highest 1 bit from the left. -1 means the number was 0. + @cite Based on code by jukka@liimatta.org */ int highestBit(uint32 x); + /** Note that fuzzyEq(a, b) && fuzzyEq(b, c) does not imply fuzzyEq(a, c), although that will be the case on some occasions. */ bool fuzzyEq(double a, double b); + /** True if a is definitely not equal to b. Guaranteed false if a == b. Possibly false when a != b.*/ bool fuzzyNe(double a, double b); + /** Is a strictly greater than b? (Guaranteed false if a <= b). (Possibly false if a > b) */ bool fuzzyGt(double a, double b); + /** Is a near or greater than b? */ bool fuzzyGe(double a, double b); + /** Is a strictly less than b? (Guaranteed false if a >= b)*/ bool fuzzyLt(double a, double b); + /** Is a near or less than b? */ bool fuzzyLe(double a, double b); + /** Computes 1 / sqrt(x). */ inline float rsq(float x) { return 1.0f / sqrtf(x); } + /** Uses SSE to implement rsq. @cite Nick nicolas@capens.net */ inline float SSErsq(float x) { + #if defined(SSE) && defined(G3D_WIN32) && !defined(_WIN64) __asm { movss xmm0, x @@ -328,38 +412,46 @@ inline float SSErsq(float x) { return 1.0f / sqrt(x); #endif } + /** Return the next power of 2 higher than the input If the input is already a power of 2, the output will be the same as the input. */ int ceilPow2(unsigned int in); + /** * True if num is a power of two. */ bool isPow2(int num); + bool isOdd(int num); bool isEven(int num); + double toRadians(double deg); double toDegrees(double rad); + /** Returns true if x is not exactly equal to 0.0f. */ inline bool any(float x) { return x != 0; } + /** Returns true if x is not exactly equal to 0.0f. */ inline bool all(float x) { return x != 0; } + /** v / v (for DirectX/Cg support) */ inline float normalize(float v) { return v / v; } + /** a * b (for DirectX/Cg support) */ @@ -367,33 +459,39 @@ inline float dot(float a, float b) { return a * b; } + /** a * b (for DirectX/Cg support) */ inline float mul(float a, float b) { return a * b; } + /** 2^x */ inline double exp2(double x) { return pow(2.0, x); } + inline double rsqrt(double x) { return 1.0 / sqrt(x); } + /** sin(x)/x */ inline double sinc(double x) { double r = sin(x) / x; + if (isNaN(r)) { return 1.0; } else { return r; } } + /** Computes a floating point modulo; the result is t wrapped to the range [lo, hi). */ @@ -401,18 +499,28 @@ inline double wrap(double t, double lo, double hi) { if ((t >= lo) && (t < hi)) { return t; } + debugAssert(hi > lo); + double interval = hi - lo; + return t - interval * iFloor((t - lo) / interval); + } + inline double wrap(double t, double hi) { return wrap(t, 0, hi); } + } // namespace + #ifdef _MSC_VER # pragma warning (pop) #endif + #include "g3dmath.inl" + #endif + diff --git a/dep/include/g3dlite/G3D/g3dmath.inl b/dep/include/g3dlite/G3D/g3dmath.inl index fa27c7e51ec..ad685bc5ce4 100644 --- a/dep/include/g3dlite/G3D/g3dmath.inl +++ b/dep/include/g3dlite/G3D/g3dmath.inl @@ -1,34 +1,45 @@ /** @file g3dmath.inl + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2001-06-02 @edited 2006-01-14 */ + #include + #ifdef _MSC_VER // Disable conditional expression is constant, which occurs incorrectly on inlined functions # pragma warning (push) # pragma warning( disable : 4127 ) #endif + namespace G3D { + inline bool isNaN(double x) { bool b1 = (x < 0.0); bool b2 = (x >= 0.0); bool b3 = !(b1 || b2); return b3; } + inline bool isFinite(double x) { return ! isNaN(x) && (x < G3D::inf()) && (x > -G3D::inf()); } + //---------------------------------------------------------------------------- inline int iAbs (int iValue) { return ( iValue >= 0 ? iValue : -iValue ); } + //---------------------------------------------------------------------------- inline int iCeil (double fValue) { return int(::ceil(fValue)); } + //---------------------------------------------------------------------------- + inline int iClamp(int val, int low, int hi) { debugAssert(low <= hi); if (val <= low) { @@ -39,7 +50,9 @@ inline int iClamp(int val, int low, int hi) { return val; } } + //---------------------------------------------------------------------------- + inline double clamp(double val, double low, double hi) { debugAssert(low <= hi); if (val <= low) { @@ -50,6 +63,7 @@ inline double clamp(double val, double low, double hi) { return val; } } + inline float clamp(float val, float low, float hi) { debugAssert(low <= hi); if (val <= low) { @@ -61,6 +75,7 @@ inline float clamp(float val, float low, float hi) { } } //---------------------------------------------------------------------------- + inline int iWrap(int val, int hi) { if (val < 0) { return ((val % hi) + hi) % hi; @@ -68,21 +83,26 @@ inline int iWrap(int val, int hi) { return val % hi; } } + //---------------------------------------------------------------------------- inline int iFloor (double fValue) { return int(::floor(fValue)); } + //---------------------------------------------------------------------------- inline int iSign (int iValue) { return ( iValue > 0 ? + 1 : ( iValue < 0 ? -1 : 0 ) ); } + inline int iSign (double fValue) { return ( fValue > 0.0 ? + 1 : ( fValue < 0.0 ? -1 : 0 ) ); } + //---------------------------------------------------------------------------- inline double abs (double fValue) { return double(::fabs(fValue)); } + //---------------------------------------------------------------------------- inline double aCos (double fValue) { if ( -1.0 < fValue ) { @@ -94,6 +114,7 @@ inline double aCos (double fValue) { return G3D_PI; } } + //---------------------------------------------------------------------------- inline double aSin (double fValue) { if ( -1.0 < fValue ) { @@ -106,90 +127,115 @@ inline double aSin (double fValue) { return G3D_HALF_PI; } } + //---------------------------------------------------------------------------- inline double aTan (double fValue) { return double(::atan(fValue)); } + //---------------------------------------------------------------------------- inline double aTan2 (double fY, double fX) { return double(::atan2(fY, fX)); } + //---------------------------------------------------------------------------- inline double sign (double fValue) { if (fValue > 0.0) { return 1.0; } + if (fValue < 0.0) { return -1.0; } + return 0.0; } + inline double G3D_DEPRECATED unitRandom () { return double(::rand()) / double(RAND_MAX); } + inline float uniformRandom(float low, float hi) { return (hi - low) * float(::rand()) / float(RAND_MAX) + low; } + //---------------------------------------------------------------------------- inline double G3D_DEPRECATED symmetricRandom () { return 2.0 * double(::rand()) / double(RAND_MAX) - 1.0; } + //---------------------------------------------------------------------------- inline double square(double x) { return x * x; } + //---------------------------------------------------------------------------- inline double sumSquares(double x, double y) { return x*x + y*y; } + //---------------------------------------------------------------------------- inline double sumSquares(double x, double y, double z) { return x*x + y*y + z*z; } + //---------------------------------------------------------------------------- inline double distance(double x, double y) { return sqrt(sumSquares(x, y)); } + //---------------------------------------------------------------------------- inline double distance(double x, double y, double z) { return sqrt(sumSquares(x, y, z)); } + //---------------------------------------------------------------------------- + /** @deprecated use G3D::min */ inline int iMin(int x, int y) { return (x >= y) ? y : x; } + //---------------------------------------------------------------------------- /** @deprecated use G3D::min */ inline int iMax(int x, int y) { return (x >= y) ? x : y; } + //---------------------------------------------------------------------------- inline int ceilPow2(unsigned int in) { in -= 1; + in |= in >> 16; in |= in >> 8; in |= in >> 4; in |= in >> 2; in |= in >> 1; + return in + 1; } + inline bool isPow2(int num) { return ((num & -num) == num); } + inline bool isOdd(int num) { return (num & 1) == 1; } + inline bool isEven(int num) { return (num & 1) == 0; } + inline double toRadians(double deg) { return deg * G3D_PI / 180.0; } + inline double toDegrees(double rad) { return rad * 180.0 / G3D_PI; } + /** Computes an appropriate epsilon for comparing a and b. */ @@ -206,28 +252,37 @@ inline double eps(double a, double b) { return fuzzyEpsilon * aa; } } + inline bool fuzzyEq(double a, double b) { return (a == b) || (abs(a - b) <= eps(a, b)); } + inline bool fuzzyNe(double a, double b) { return ! fuzzyEq(a, b); } + inline bool fuzzyGt(double a, double b) { return a > b + eps(a, b); } + inline bool fuzzyGe(double a, double b) { return a > b - eps(a, b); } + inline bool fuzzyLt(double a, double b) { return a < b - eps(a, b); } + inline bool fuzzyLe(double a, double b) { return a < b + eps(a, b); } + inline int iMod3(int x) { return x % 3; } + } // namespace G3D + #ifdef _MSC_VER // Disable conditional expression is constant, which occurs incorrectly on inlined functions # pragma warning (pop) diff --git a/dep/include/g3dlite/G3D/platform.h b/dep/include/g3dlite/G3D/platform.h index 3275a6a164c..16f9b208d18 100644 --- a/dep/include/g3dlite/G3D/platform.h +++ b/dep/include/g3dlite/G3D/platform.h @@ -1,26 +1,35 @@ /** @file platform.h + #defines for platform specific issues. + @maintainer Morgan McGuire, matrix@graphics3d.com + @created 2003-06-09 @edited 2006-01-16 */ + #ifndef G3D_PLATFORM_H #define G3D_PLATFORM_H + /** The version number of G3D in the form: MmmBB -> version M.mm [beta BB] */ #define G3D_VER 61000 + #if defined(G3D_RELEASEDEBUG) # define G3D_DEBUGRELEASE #endif + #if defined(G3D_DEBUGRELEASE) && defined(_DEBUG) # undef _DEBUG #endif + #if !defined(G3D_DEBUG) && (defined(_DEBUG) || defined(G3D_DEBUGRELEASE)) # define G3D_DEBUG #endif + #ifdef _MSC_VER #define G3D_WIN32 #elif defined(__MINGW32__) @@ -40,52 +49,65 @@ #error Unknown platform #endif + // Default to compiling with SSE, but if you want to compile // without installing SP5.0 and the Processor Pack on Windows, compile with NO_SSE // defined (can be passed to the compiler command line with /D "NO_SSE") #if !defined(NO_SSE) #define SSE #endif + #ifdef G3D_WIN32 // Turn off warnings about deprecated C routines (TODO: revisit) # pragma warning (disable : 4996) #endif + // On g++, recognize cases where the -msse2 flag was not specified #if defined(SSE) && defined(__GNUC__) && ! defined (__SSE__) # undef SSE #endif + #if defined(__GNUC__) # if __STDC_VERSION__ < 199901 # define restrict __restrict__ # endif #endif + // Verify that the supported compilers are being used and that this is a known // processor. + #ifdef G3D_LINUX # ifndef __GNUC__ # error G3D only supports the gcc compiler on Linux. # endif + //# ifndef __i386__ //# error G3D only supports x86 machines on Linux. //# endif + # define G3D_DEPRECATED __attribute__((__deprecated__)) + # ifndef __cdecl # define __cdecl __attribute__((cdecl)) # endif + # ifndef __stdcall # define __stdcall __attribute__((stdcall)) # endif + # define G3D_CHECK_PRINTF_METHOD_ARGS __attribute__((__format__(__printf__, 2, 3))) # define G3D_CHECK_VPRINTF_METHOD_ARGS __attribute__((__format__(__printf__, 2, 0))) # define G3D_CHECK_PRINTF_ARGS __attribute__((__format__(__printf__, 1, 2))) # define G3D_CHECK_VPRINTF_ARGS __attribute__((__format__(__printf__, 1, 0))) #endif + #ifdef G3D_OSX #ifndef __GNUC__ #error G3D only supports the gcc compiler on OS X. #endif + #if defined(__i386__) #define G3D_OSX_INTEL #elif defined(__PPC__) @@ -93,24 +115,30 @@ #else #define G3D_OSX_UNKNOWN #endif + # ifndef __cdecl # define __cdecl __attribute__((cdecl)) # endif + # ifndef __stdcall # define __stdcall __attribute__((stdcall)) # endif + # define G3D_DEPRECATED __attribute__((__deprecated__)) + # define G3D_CHECK_PRINTF_METHOD_ARGS __attribute__((__format__(__printf__, 2, 3))) # define G3D_CHECK_VPRINTF_METHOD_ARGS __attribute__((__format__(__printf__, 2, 0))) # define G3D_CHECK_PRINTF_ARGS __attribute__((__format__(__printf__, 1, 2))) # define G3D_CHECK_VPRINTF_ARGS __attribute__((__format__(__printf__, 1, 0))) #endif + #ifdef G3D_WIN32 // Microsoft Visual C++ 7.1 _MSC_VER = 1310 // Microsoft Visual C++ 7.0 _MSC_VER = 1300 // Microsoft Visual C++ 6.0 _MSC_VER = 1200 // Microsoft Visual C++ 5.0 _MSC_VER = 1100 + // Old versions of MSVC (6.0 and previous) don't // support C99 for loop scoping rules. This fixes them. # if (_MSC_VER <= 1200) @@ -118,34 +146,42 @@ # pragma warning (disable : 4127) # define for if (false) {} else for # endif + # if (_MSC_VER <= 1200) // Nothing we can do on VC6 for deprecated functions # define G3D_DEPRECATED # else # define G3D_DEPRECATED __declspec(deprecated) # endif + // Prevent Winsock conflicts by hiding the winsock API #ifndef _WINSOCKAPI_ # define _G3D_INTERNAL_HIDE_WINSOCK_ # define _WINSOCKAPI_ # endif + // Disable 'name too long for browse information' warning # pragma warning (disable : 4786) // TODO: remove # pragma warning (disable : 4244) + # if defined(_MSC_VER) && (_MSC_VER <= 1200) // VC6 std:: has signed problems in it # pragma warning (disable : 4018) # endif + # define ZLIB_WINAPI + // Mingw32 defines restrict # ifndef G3D_MINGW32 # define restrict # endif + # define G3D_CHECK_PRINTF_ARGS # define G3D_CHECK_VPRINTF_ARGS # define G3D_CHECK_PRINTF_METHOD_ARGS # define G3D_CHECK_VPRINTF_METHOD_ARGS + // On MSVC, we need to link against the multithreaded DLL version of // the C++ runtime because that is what SDL and ZLIB are compiled // against. This is not the default for MSVC, so we set the following @@ -155,11 +191,13 @@ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_.2f.md.2c_2f.ml.2c_2f.mt.2c_2f.ld.asp // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_Compiler_Reference.asp // + #if 0 //ignore that for Trinity // DLL runtime #ifndef _DLL #define _DLL #endif + // Multithreaded runtime #ifndef _MT #define _MT 1 @@ -169,6 +207,7 @@ #undef _STATIC_CPPLIB #endif #endif + #ifdef _DEBUG #pragma comment (linker, "/NODEFAULTLIB:libc.lib") #pragma comment (linker, "/NODEFAULTLIB:libcmt.lib") @@ -182,38 +221,50 @@ #pragma comment(linker, "/NODEFAULTLIB:libcmtd.lib") #pragma comment(linker, "/NODEFAULTLIB:msvcrtd.lib") #endif + // Now set up external linking + #ifdef _DEBUG // zlib and SDL were linked against the release MSVCRT; force // the debug version. #pragma comment(linker, "/NODEFAULTLIB:MSVCRT.LIB") # endif + # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif + # define NOMINMAX 1 # include # undef WIN32_LEAN_AND_MEAN # undef NOMINMAX + #ifdef _G3D_INTERNAL_HIDE_WINSOCK_ # undef _G3D_INTERNAL_HIDE_WINSOCK_ # undef _WINSOCKAPI_ #endif + #endif + # if defined(_MSC_VER) && (_MSC_VER <= 1200) // VC6 std:: has signed/unsigned problems # pragma warning (disable : 4018) # endif + /** @def STR(expression) + Creates a string from the expression. Frequently used with G3D::Shader to express shading programs inline. + STR(this becomes a string)
 evaluates the same as "this becomes a string"
  */
 #define STR(x) #x
+
 #undef G3D_DEPRECATED
 #define G3D_DEPRECATED
+
 // Header guard
 #endif
 
diff --git a/dep/include/g3dlite/G3D/stringutils.h b/dep/include/g3dlite/G3D/stringutils.h
index eae346b0985..59449313bf5 100644
--- a/dep/include/g3dlite/G3D/stringutils.h
+++ b/dep/include/g3dlite/G3D/stringutils.h
@@ -1,28 +1,37 @@
 /**
  @file stringutils.h
+
  @maintainer Morgan McGuire, matrix@graphics3d.com
+
  @author  2000-09-09
  @edited  2002-11-30
  */
+
 #ifndef G3D_STRINGUTILS_H
 #define G3D_STRINGUTILS_H
+
 #include "G3D/platform.h"
 #include "G3D/Array.h"
 #include 
+
 namespace G3D {
+
 extern const char* NEWLINE;
+
 /**
  Returns true if the test string begins with the pattern string.
  */
 bool beginsWith(
     const std::string&          test,
     const std::string&          pattern);
+
 /**
  Returns true if the test string ends with the pattern string.
  */
 bool endsWith(
     const std::string&          test,
     const std::string&          pattern);
+
 /**
  Produces a new string that is the input string
  wrapped at a certain number of columns (where
@@ -33,28 +42,34 @@ bool endsWith(
 std::string wordWrap(
     const std::string&          input,
     int                         numCols);
+
 /**
  A comparison function for passing to Array::sort.
  */
 int stringCompare(
     const std::string&          s1,
     const std::string&          s2);
+
 int stringPtrCompare(
     const std::string*          s1,
     const std::string*          s2);
+
 /**
  Returns a new string that is an uppercase version of x.
  */
 std::string toUpper(
     const std::string&          x);
+
 std::string toLower(
     const std::string&          x);
+
 /**
  Splits x at each occurance of splitChar.
  */
 G3D::Array stringSplit(
     const std::string&          x,
     char                        splitChar);
+
 /**
  joinChar is not inserted at the beginning or end, just in between
  elements.
@@ -62,44 +77,55 @@ G3D::Array stringSplit(
 std::string stringJoin(
     const G3D::Array&   a,
     char                        joinChar);
+
 std::string stringJoin(
     const G3D::Array&   a,
     const std::string&               joinStr);
+
 /**
  Strips whitespace from both ends of the string.
  */
 std::string trimWhitespace(
     const std::string&              s);
+
 /** These standard C functions are renamed for clarity/naming
    conventions and to return bool, not int.
    */
 inline bool isWhiteSpace(const char c) {
     return isspace(c) != 0;
 }
+
 /** These standard C functions are renamed for clarity/naming
    conventions and to return bool, not int.
    */
 inline bool isNewline(const char c) {
     return (c == '\n') || (c == '\r');
 }
+
 /** These standard C functions are renamed for clarity/naming
    conventions and to return bool, not int.
    */
 inline bool isDigit(const char c) {
     return isdigit(c) != 0;
 }
+
 /** These standard C functions are renamed for clarity/naming
    conventions and to return bool, not int.
    */
 inline bool isLetter(const char c) {
     return isalpha(c) != 0;
 }
+
 inline bool isSlash(const char c) {
     return (c == '\\') || (c == '/');
 }
+
 inline bool isQuote(const char c) {
     return (c == '\'') || (c == '\"');
 }
+
 }; // namespace
+
 #endif
 
+
diff --git a/dep/include/mersennetwister/MersenneTwister.h b/dep/include/mersennetwister/MersenneTwister.h
index 736eb46dd26..0fbd9242e45 100644
--- a/dep/include/mersennetwister/MersenneTwister.h
+++ b/dep/include/mersennetwister/MersenneTwister.h
@@ -2,16 +2,19 @@
 // Mersenne Twister random number generator -- a C++ class MTRand
 // Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
 // Richard J. Wagner  v1.0  15 May 2003  rjwagner@writeme.com
+
 // The Mersenne Twister is an algorithm for generating random numbers.  It
 // was designed with consideration of the flaws in various other generators.
 // The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
 // are far greater.  The generator is also fast; it avoids multiplication and
 // division, and it benefits from caches and pipelines.  For more information
 // see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html
+
 // Reference
 // M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
 // Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
 // Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
+
 // Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
 // Copyright (C) 2000 - 2003, Richard J. Wagner
 // All rights reserved.
@@ -42,6 +45,7 @@
 // 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.
+
 // The original code included the following notice:
 //
 //     When you use this, send an email to: matumoto@math.keio.ac.jp
@@ -49,26 +53,34 @@
 //
 // It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu
 // when you write.
+
 #ifndef MERSENNETWISTER_H
 #define MERSENNETWISTER_H
+
 // Not thread safe (unless auto-initialization is avoided and each thread has
 // its own MTRand object)
+
 #include"Platform/Define.h"
+
 #include 
 #include 
 #include 
+
 class MTRand {
 // Data
 public:
     typedef ::uint32 uint32;
     enum { N = 624 };       // length of state vector
     enum { SAVE = N + 1 };  // length of array for save()
+
 protected:
     enum { M = 397 };  // period parameter
+
     uint32 state[N];   // internal state
     uint32 *pNext;     // next value to get from state
     int left;          // number of values left before reload needed
 
+
 //Methods
 public:
     MTRand( const uint32& oneSeed );  // initialize with a simple uint32
@@ -76,9 +88,11 @@ public:
     MTRand();                         // auto-initialize with /dev/urandom or time() and clock()
     MTRand(const MTRand&);            // prevent copy constructor
     MTRand& operator=(const MTRand&); // no-op operator=
+
     // Do NOT use for CRYPTOGRAPHY without securely hashing several returned
     // values together, otherwise the generator state can be learned after
     // reading 624 consecutive values.
+
     // Access to 32-bit random numbers
     double rand();                          // real number in [0,1]
     double rand( const double& n );         // real number in [0,n]
@@ -89,14 +103,18 @@ public:
     uint32 randInt();                       // integer in [0,2^32-1]
     uint32 randInt( const uint32& n );      // integer in [0,n] for n < 2^32
     double operator()() { return rand(); }  // same as rand()
+
     // Access to 53-bit random numbers (capacity of IEEE double precision)
     double rand53();  // real number in [0,1)
+
     // Access to nonuniform random number distributions
     double randNorm( const double& mean = 0.0, const double& variance = 0.0 );
+
     // Re-seeding functions with same behavior as initializers
     void seed( const uint32 oneSeed );
     void seed( uint32 *const bigSeed, const uint32 seedLength = N );
     void seed();
+
     // Saving and loading generator state
     void save( uint32* saveArray ) const;  // to array of size SAVE
     void load( uint32 *const loadArray );  // from such array
@@ -116,33 +134,46 @@ protected:
         { return m ^ (mixBits(s0,s1)>>1) ^ uint32(-(int32)(loBit(s1) & 0x9908b0dfUL)); }
     static uint32 hash( time_t t, clock_t c );
 };
+
 inline MTRand::MTRand(const MTRand&)
     { seed(); }
+
 inline MTRand& MTRand::operator=(const MTRand&)
     { return *this; }
+
 inline MTRand::MTRand( const uint32& oneSeed )
     { seed(oneSeed); }
+
 inline MTRand::MTRand( uint32 *const bigSeed, const uint32 seedLength )
     { seed(bigSeed,seedLength); }
+
 inline MTRand::MTRand()
     { seed(); }
+
 inline double MTRand::rand()
     { return double(randInt()) * (1.0/4294967295.0); }
+
 inline double MTRand::rand( const double& n )
     { return rand() * n; }
+
 inline double MTRand::randExc()
     { return double(randInt()) * (1.0/4294967296.0); }
+
 inline double MTRand::randExc( const double& n )
     { return randExc() * n; }
+
 inline double MTRand::randDblExc()
     { return ( double(randInt()) + 0.5 ) * (1.0/4294967296.0); }
+
 inline double MTRand::randDblExc( const double& n )
     { return randDblExc() * n; }
+
 inline double MTRand::rand53()
 {
     uint32 a = randInt() >> 5, b = randInt() >> 6;
     return ( a * 67108864.0 + b ) * (1.0/9007199254740992.0);  // by Isaku Wada
 }
+
 inline double MTRand::randNorm( const double& mean, const double& variance )
 {
     // Return a real number from a normal (Gaussian) distribution with given
@@ -151,12 +182,15 @@ inline double MTRand::randNorm( const double& mean, const double& variance )
     double phi = 2.0 * 3.14159265358979323846264338328 * randExc();
     return mean + r * cos(phi);
 }
+
 inline MTRand::uint32 MTRand::randInt()
 {
     // Pull a 32-bit integer from the generator state
     // Every other access function simply transforms the numbers extracted here
+
     if( left == 0 ) reload();
     --left;
+
     register uint32 s1;
     s1 = *pNext++;
     s1 ^= (s1 >> 11);
@@ -164,6 +198,7 @@ inline MTRand::uint32 MTRand::randInt()
     s1 ^= (s1 << 15) & 0xefc60000UL;
     return ( s1 ^ (s1 >> 18) );
 }
+
 inline MTRand::uint32 MTRand::randInt( const uint32& n )
 {
     // Find which bits are used in n
@@ -174,6 +209,7 @@ inline MTRand::uint32 MTRand::randInt( const uint32& n )
     used |= used >> 4;
     used |= used >> 8;
     used |= used >> 16;
+
     // Draw numbers until one is found in [0,n]
     uint32 i;
     do
@@ -182,6 +218,7 @@ inline MTRand::uint32 MTRand::randInt( const uint32& n )
     return i;
 }
 
+
 inline void MTRand::seed( const uint32 oneSeed )
 {
     // Seed the generator with a simple uint32
@@ -189,6 +226,7 @@ inline void MTRand::seed( const uint32 oneSeed )
     reload();
 }
 
+
 inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength )
 {
     // Seed the generator with an array of uint32's
@@ -224,12 +262,14 @@ inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength )
     reload();
 }
 
+
 inline void MTRand::seed()
 {
     // Seed the generator with hash of time() and clock() values
     seed( hash( time(NULL), clock() ) );
 }
 
+
 inline void MTRand::initialize( const uint32 seed )
 {
     // Initialize generator state with seed
@@ -247,6 +287,7 @@ inline void MTRand::initialize( const uint32 seed )
     }
 }
 
+
 inline void MTRand::reload()
 {
     // Generate N new values in state
@@ -258,15 +299,19 @@ inline void MTRand::reload()
     for( i = M; --i; ++p )
         *p = twist( p[M-N], p[0], p[1] );
     *p = twist( p[M-N], p[0], state[0] );
+
     left = N, pNext = state;
 }
 
+
 inline MTRand::uint32 MTRand::hash( time_t t, clock_t c )
 {
     // Get a uint32 from t and c
     // Better than uint32(x) in case x is floating point in [0,1]
     // Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
+
     static uint32 differ = 0;  // guarantee time-based seeds will change
+
     uint32 h1 = 0;
     unsigned char *p = (unsigned char *) &t;
     for( size_t i = 0; i < sizeof(t); ++i )
@@ -284,6 +329,7 @@ inline MTRand::uint32 MTRand::hash( time_t t, clock_t c )
     return ( h1 + differ++ ) ^ h2;
 }
 
+
 inline void MTRand::save( uint32* saveArray ) const
 {
     register uint32 *sa = saveArray;
@@ -293,6 +339,7 @@ inline void MTRand::save( uint32* saveArray ) const
     *sa = left;
 }
 
+
 inline void MTRand::load( uint32 *const loadArray )
 {
     register uint32 *s = state;
@@ -302,6 +349,7 @@ inline void MTRand::load( uint32 *const loadArray )
     left = *la;
     pNext = &state[N-left];
 }
+
 /* Trinity not use streams for random values output
 inline std::ostream& operator<<( std::ostream& os, const MTRand& mtrand )
 {
@@ -311,6 +359,7 @@ inline std::ostream& operator<<( std::ostream& os, const MTRand& mtrand )
     return os << mtrand.left;
 }
 
+
 inline std::istream& operator>>( std::istream& is, MTRand& mtrand )
 {
     register MTRand::uint32 *s = mtrand.state;
@@ -321,7 +370,9 @@ inline std::istream& operator>>( std::istream& is, MTRand& mtrand )
     return is;
 }
 */
+
 #endif  // MERSENNETWISTER_H
+
 // Change log:
 //
 // v0.1 - First release on 15 May 2000
diff --git a/dep/include/sockets/Base64.h b/dep/include/sockets/Base64.h
index 7db41c27d36..b1fd5364fc2 100644
--- a/dep/include/sockets/Base64.h
+++ b/dep/include/sockets/Base64.h
@@ -4,49 +4,63 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_Base64_H
 #define _SOCKETS_Base64_H
+
 #include "sockets-config.h"
 #ifdef _MSC_VER
 #pragma warning(disable:4514)
 #endif
+
 #include 
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 /** \defgroup util Utilities */
+
 /** Base64 encode/decode.
     \ingroup util */
 class Base64
 {
 public:
     Base64();
+
     void encode(FILE *, std::string& , bool add_crlf = true);
     void encode(const std::string&, std::string& , bool add_crlf = true);
     void encode(const char *, size_t, std::string& , bool add_crlf = true);
     void encode(const unsigned char *, size_t, std::string& , bool add_crlf = true);
+
     void decode(const std::string&, std::string& );
     void decode(const std::string&, unsigned char *, size_t&);
+
     size_t decode_length(const std::string& );
+
 private:
     Base64(const Base64& ) {}
     Base64& operator=(const Base64& ) { return *this; }
@@ -54,8 +68,11 @@ static  const char *bstr;
 static  const char rstr[128];
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_Base64_H
 
+
diff --git a/dep/include/sockets/Exception.h b/dep/include/sockets/Exception.h
index ac33ea1c6d6..ae48ab765ba 100644
--- a/dep/include/sockets/Exception.h
+++ b/dep/include/sockets/Exception.h
@@ -5,39 +5,55 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _Sockets_Exception_H
 #define _Sockets_Exception_H
+
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
+
 class Exception
 {
 public:
     Exception(const std::string& description);
     virtual ~Exception() {}
+
     virtual const std::string ToString() const;
+
     Exception(const Exception& ) {} // copy constructor
+
     Exception& operator=(const Exception& ) { return *this; } // assignment operator
+
 private:
     std::string m_description;
+
 };
 
+
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
+
 #endif // _Sockets_Exception_H
 
+
diff --git a/dep/include/sockets/File.h b/dep/include/sockets/File.h
index 104f79b4d13..e1d00ec38c7 100644
--- a/dep/include/sockets/File.h
+++ b/dep/include/sockets/File.h
@@ -4,33 +4,41 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_File_H
 #define _SOCKETS_File_H
+
 #include "sockets-config.h"
 #include "IFile.h"
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /** IFile implementation of a disk file.
     \ingroup file */
 class File : public IFile
@@ -38,19 +46,26 @@ class File : public IFile
 public:
     File();
     ~File();
+
     bool fopen(const std::string&, const std::string&);
     void fclose();
+
     size_t fread(char *, size_t, size_t) const;
     size_t fwrite(const char *, size_t, size_t);
+
     char *fgets(char *, int) const;
     void fprintf(const char *format, ...);
+
     off_t size() const;
     bool eof() const;
+
     void reset_read() const;
     void reset_write();
+
 private:
     File(const File& ) {} // copy constructor
     File& operator=(const File& ) { return *this; } // assignment operator
+
     std::string m_path;
     std::string m_mode;
     FILE *m_fil;
@@ -59,8 +74,12 @@ private:
 };
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_File_H
 
+
diff --git a/dep/include/sockets/IFile.h b/dep/include/sockets/IFile.h
index ef4c859427e..e1e39727b52 100644
--- a/dep/include/sockets/IFile.h
+++ b/dep/include/sockets/IFile.h
@@ -4,31 +4,39 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_IFile_H
 #define _SOCKETS_IFile_H
+
 #include "sockets-config.h"
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 /** \defgroup file File handling */
 /** Pure virtual file I/O interface.
     \ingroup file */
@@ -36,20 +44,29 @@ class IFile
 {
 public:
     virtual ~IFile() {}
+
     virtual bool fopen(const std::string&, const std::string&) = 0;
     virtual void fclose() = 0;
+
     virtual size_t fread(char *, size_t, size_t) const = 0;
     virtual size_t fwrite(const char *, size_t, size_t) = 0;
+
     virtual char *fgets(char *, int) const = 0;
     virtual void fprintf(const char *format, ...) = 0;
+
     virtual off_t size() const = 0;
     virtual bool eof() const = 0;
+
     virtual void reset_read() const = 0;
     virtual void reset_write() = 0;
+
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_IFile_H
 
+
diff --git a/dep/include/sockets/ISocketHandler.h b/dep/include/sockets/ISocketHandler.h
index 4bc72949e5e..bb1aa42bafc 100644
--- a/dep/include/sockets/ISocketHandler.h
+++ b/dep/include/sockets/ISocketHandler.h
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -25,13 +30,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef _SOCKETS_ISocketHandler_H
 #define _SOCKETS_ISocketHandler_H
 #include "sockets-config.h"
+
 #include 
+
 #include "socket_include.h"
 #include "Socket.h"
 #include "StdLog.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 typedef enum {
     LIST_CALLONCONNECT = 0,
 #ifdef ENABLE_DETACH
@@ -41,14 +50,17 @@ typedef enum {
     LIST_RETRY,
     LIST_CLOSE
 } list_t;
+
 class SocketAddress;
 class Mutex;
 
+
 /** Socket container class, event generator.
     \ingroup basic */
 class ISocketHandler
 {
     friend class Socket;
+
 public:
     /** Connection pool class for internal use by the ISocketHandler.
         \ingroup internal */
@@ -60,22 +72,29 @@ public:
             CopyConnection( src );
             SetIsClient();
         }
+
         void OnRead() {
             Handler().LogError(this, "OnRead", 0, "data on hibernating socket", LOG_LEVEL_FATAL);
             SetCloseAndDelete();
         }
         void OnOptions(int,int,int,SOCKET) {}
+
     };
 #endif
+
 public:
     virtual ~ISocketHandler() {}
+
     /** Get mutex reference for threadsafe operations. */
     virtual Mutex& GetMutex() const = 0;
+
     /** Register StdLog object for error callback.
         \param log Pointer to log class */
     virtual void RegStdLog(StdLog *log) = 0;
+
     /** Log error to log class for print out / storage. */
     virtual void LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t = LOG_LEVEL_WARNING) = 0;
+
     // -------------------------------------------------------------------------
     // Socket stuff
     // -------------------------------------------------------------------------
@@ -89,21 +108,26 @@ public:
     virtual void Get(SOCKET s,bool& r,bool& w,bool& e) = 0;
     /** Set read/write/exception file descriptor sets (fd_set). */
     virtual void Set(SOCKET s,bool bRead,bool bWrite,bool bException = true) = 0;
+
     /** Wait for events, generate callbacks. */
     virtual int Select(long sec,long usec) = 0;
     /** This method will not return until an event has been detected. */
     virtual int Select() = 0;
     /** Wait for events, generate callbacks. */
     virtual int Select(struct timeval *tsel) = 0;
+
     /** Check that a socket really is handled by this socket handler. */
     virtual bool Valid(Socket *) = 0;
     /** Return number of sockets handled by this handler.  */
     virtual size_t GetCount() = 0;
+
     /** Override and return false to deny all incoming connections.
         \param p ListenSocket class pointer (use GetPort to identify which one) */
     virtual bool OkToAccept(Socket *p) = 0;
+
     /** Called by Socket when a socket changes state. */
     virtual void AddList(SOCKET s,list_t which_one,bool add) = 0;
+
     // -------------------------------------------------------------------------
     // Connection pool
     // -------------------------------------------------------------------------
@@ -116,6 +140,7 @@ public:
         \return true if connection pool is enabled */
     virtual bool PoolEnabled() = 0;
 #endif // ENABLE_POOL
+
     // -------------------------------------------------------------------------
     // Socks4
     // -------------------------------------------------------------------------
@@ -143,6 +168,7 @@ public:
         \return true if direct connection should be tried if connection to socks4 server fails */
     virtual bool Socks4TryDirect() = 0;
 #endif // ENABLE_SOCKS4
+
     // -------------------------------------------------------------------------
     // DNS resolve server
     // -------------------------------------------------------------------------
@@ -172,6 +198,7 @@ public:
     /** Returns true if socket waiting for a resolve event. */
     virtual bool Resolving(Socket *) = 0;
 #endif // ENABLE_RESOLVER
+
 #ifdef ENABLE_TRIGGERS
     /** Fetch unique trigger id. */
     virtual int TriggerID(Socket *src) = 0;
@@ -186,16 +213,21 @@ public:
             Leave them in place if 'false' - if a trigger should be called many times */
     virtual void Trigger(int id, Socket::TriggerData& data, bool erase = true) = 0;
 #endif // ENABLE_TRIGGERS
+
 #ifdef ENABLE_DETACH
     /** Indicates that the handler runs under SocketThread. */
     virtual void SetSlave(bool x = true) = 0;
     /** Indicates that the handler runs under SocketThread. */
     virtual bool IsSlave() = 0;
 #endif // ENABLE_DETACH
+
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_ISocketHandler_H
 
+
diff --git a/dep/include/sockets/Ipv4Address.h b/dep/include/sockets/Ipv4Address.h
index 5a8d9a6ce20..ba2292425a0 100644
--- a/dep/include/sockets/Ipv4Address.h
+++ b/dep/include/sockets/Ipv4Address.h
@@ -5,27 +5,33 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_Ipv4Address_H
 #define _SOCKETS_Ipv4Address_H
+
 #include "sockets-config.h"
 #include "SocketAddress.h"
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /* Ipv4 address implementation.
     \ingroup basic */
 class Ipv4Address : public SocketAddress
@@ -48,25 +54,33 @@ public:
     Ipv4Address(const std::string& host,port_t port);
     Ipv4Address(struct sockaddr_in&);
     ~Ipv4Address();
+
     // SocketAddress implementation
+
     operator struct sockaddr *();
     operator socklen_t();
     bool operator==(SocketAddress&);
+
     void SetPort(port_t port);
     port_t GetPort();
+
     void SetAddress(struct sockaddr *sa);
     int GetFamily();
+
     bool IsValid();
     std::auto_ptr GetCopy();
+
     /** Convert address struct to text. */
     std::string Convert(bool include_port = false);
     std::string Reverse();
+
     /** Resolve hostname. */
 static  bool Resolve(const std::string& hostname,struct in_addr& a);
     /** Reverse resolve (IP to hostname). */
 static  bool Reverse(struct in_addr& a,std::string& name);
     /** Convert address struct to text. */
 static  std::string Convert(struct in_addr& a);
+
 private:
     Ipv4Address(const Ipv4Address& ) {} // copy constructor
     Ipv4Address& operator=(const Ipv4Address& ) { return *this; } // assignment operator
@@ -75,8 +89,11 @@ private:
 };
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
 #endif // _SOCKETS_Ipv4Address_H
 
+
diff --git a/dep/include/sockets/Ipv6Address.h b/dep/include/sockets/Ipv6Address.h
index b1a6afa98c6..9bd651786bc 100644
--- a/dep/include/sockets/Ipv6Address.h
+++ b/dep/include/sockets/Ipv6Address.h
@@ -5,14 +5,17 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -21,15 +24,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define _SOCKETS_Ipv6Address_H
 #include "sockets-config.h"
 #ifdef ENABLE_IPV6
+
 #include "SocketAddress.h"
 #ifdef IPPROTO_IPV6
 #if defined( _WIN32) && !defined(__CYGWIN__)
 typedef unsigned __int32 uint32_t;
 #endif
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /** Ipv6 address implementation.
     \ingroup basic */
 class Ipv6Address : public SocketAddress
@@ -48,31 +54,40 @@ public:
     Ipv6Address(const std::string& host,port_t port);
     Ipv6Address(struct sockaddr_in6&);
     ~Ipv6Address();
+
     // SocketAddress implementation
+
     operator struct sockaddr *();
     operator socklen_t();
     bool operator==(SocketAddress&);
+
     void SetPort(port_t port);
     port_t GetPort();
+
     void SetAddress(struct sockaddr *sa);
     int GetFamily();
+
     bool IsValid();
     std::auto_ptr GetCopy();
+
     /** Convert address struct to text. */
     std::string Convert(bool include_port = false);
     std::string Reverse();
+
     /** Resolve hostname. */
 static  bool Resolve(const std::string& hostname,struct in6_addr& a);
     /** Reverse resolve (IP to hostname). */
 static  bool Reverse(struct in6_addr& a,std::string& name);
     /** Convert address struct to text. */
 static  std::string Convert(struct in6_addr& a,bool mixed = false);
+
     void SetFlowinfo(uint32_t);
     uint32_t GetFlowinfo();
 #ifndef _WIN32
     void SetScopeId(uint32_t);
     uint32_t GetScopeId();
 #endif
+
 private:
     Ipv6Address(const Ipv6Address& ) {} // copy constructor
     Ipv6Address& operator=(const Ipv6Address& ) { return *this; } // assignment operator
@@ -81,6 +96,8 @@ private:
 };
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
@@ -88,3 +105,4 @@ private:
 #endif // ENABLE_IPV6
 #endif // _SOCKETS_Ipv6Address_H
 
+
diff --git a/dep/include/sockets/ListenSocket.h b/dep/include/sockets/ListenSocket.h
index aeb5bf028f2..80aa48f20b4 100644
--- a/dep/include/sockets/ListenSocket.h
+++ b/dep/include/sockets/ListenSocket.h
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -25,11 +30,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef _SOCKETS_ListenSocket_H
 #define _SOCKETS_ListenSocket_H
 #include "sockets-config.h"
+
 #ifdef _WIN32
 #include 
 #else
 #include 
 #endif
+
 #include "ISocketHandler.h"
 #include "Socket.h"
 #include "Utility.h"
@@ -39,10 +46,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifdef ENABLE_EXCEPTIONS
 #include "Exception.h"
 #endif
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /** Binds incoming port number to new Socket class X.
     \ingroup basic */
 template 
@@ -75,6 +84,7 @@ public:
             delete m_creator;
         }
     }
+
     /** Close file descriptor. */
     int Close() {
         if (GetSocket() != INVALID_SOCKET)
@@ -83,6 +93,7 @@ public:
         }
         return 0;
     }
+
     /** Bind and listen to any interface.
         \param port Port (0 is random)
         \param depth Listen queue depth */
@@ -102,6 +113,7 @@ public:
             return Bind(ad, depth);
         }
     }
+
     int Bind(SocketAddress& ad,int depth) {
 #ifdef USE_SCTP
         if (dynamic_cast(m_creator))
@@ -111,6 +123,7 @@ public:
 #endif
         return Bind(ad, "tcp", depth);
     }
+
     /** Bind and listen to any interface, with optional protocol.
         \param port Port (0 is random)
         \param protocol Network protocol
@@ -131,6 +144,7 @@ public:
             return Bind(ad, protocol, depth);
         }
     }
+
     /** Bind and listen to specific interface.
         \param intf Interface hostname
         \param port Port (0 is random)
@@ -161,6 +175,7 @@ public:
             return -1;
         }
     }
+
     /** Bind and listen to specific interface.
         \param intf Interface hostname
         \param port Port (0 is random)
@@ -192,6 +207,7 @@ public:
             return -1;
         }
     }
+
     /** Bind and listen to ipv4 interface.
         \param a Ipv4 interface address
         \param port Port (0 is random)
@@ -215,6 +231,7 @@ public:
         Ipv4Address ad(a, port);
         return Bind(ad, protocol, depth);
     }
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
     /** Bind and listen to ipv6 interface.
@@ -242,6 +259,7 @@ public:
     }
 #endif
 #endif
+
     /** Bind and listen to network interface.
         \param ad Interface address
         \param protocol Network protocol
@@ -274,22 +292,26 @@ public:
         Attach(s);
         return 0;
     }
+
     /** Return assigned port number. */
     port_t GetPort()
     {
         return GetSockPort();
     }
+
     /** Return listen queue depth. */
     int GetDepth()
     {
         return m_depth;
     }
+
     /** OnRead on a ListenSocket receives an incoming connection. */
     void OnRead()
     {
         struct sockaddr sa;
         socklen_t sa_len = sizeof(struct sockaddr);
         SOCKET a_s = accept(GetSocket(), &sa, &sa_len);
+
         if (a_s == INVALID_SOCKET)
         {
             Handler().LogError(this, "accept", Errno, StrError(Errno), LOG_LEVEL_ERROR);
@@ -365,16 +387,20 @@ public:
             tmp -> OnAccept();
         }
     }
+
     /** Please don't use this method.
         "accept()" is handled automatically in the OnRead() method. */
         virtual SOCKET Accept(SOCKET socket, struct sockaddr *saptr, socklen_t *lenptr)
         {
                 return accept(socket, saptr, lenptr);
         }
+
         bool HasCreator() { return m_bHasCreate; }
+
     void OnOptions(int,int,int,SOCKET) {
         SetSoReuseaddr(true);
     }
+
 protected:
     ListenSocket(const ListenSocket& s) : Socket(s) {}
 private:
@@ -384,8 +410,12 @@ private:
     bool m_bHasCreate;
 };
 
+
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_ListenSocket_H
 
+
diff --git a/dep/include/sockets/Lock.h b/dep/include/sockets/Lock.h
index f2d9e6fb713..e819537ef26 100644
--- a/dep/include/sockets/Lock.h
+++ b/dep/include/sockets/Lock.h
@@ -4,31 +4,39 @@
 **/
 /*
 Copyright (C) 2005,2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_Lock_H
 #define _SOCKETS_Lock_H
+
 #include "sockets-config.h"
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 class Mutex;
+
 /** Mutex encapsulation class.
     \ingroup threading */
 class Lock
@@ -36,13 +44,17 @@ class Lock
 public:
     Lock(Mutex&);
     ~Lock();
+
 private:
     Mutex& m_mutex;
 };
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 #endif // _SOCKETS_Lock_H
 
+
diff --git a/dep/include/sockets/Mutex.h b/dep/include/sockets/Mutex.h
index 4dba5e7b401..8fce2ce08ba 100644
--- a/dep/include/sockets/Mutex.h
+++ b/dep/include/sockets/Mutex.h
@@ -4,35 +4,43 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_Mutex_H
 #define _SOCKETS_Mutex_H
+
 #include "sockets-config.h"
 #ifndef _WIN32
 #include 
 #else
 #include 
 #endif
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 /** Mutex container class, used by Lock.
     \ingroup threading */
 class Mutex
@@ -41,6 +49,7 @@ class Mutex
 public:
     Mutex();
     ~Mutex();
+
     void Lock();
     void Unlock();
 private:
@@ -51,8 +60,10 @@ private:
 #endif
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 #endif // _SOCKETS_Mutex_H
 
+
diff --git a/dep/include/sockets/Parse.h b/dep/include/sockets/Parse.h
index 6ad4d44290c..4b42ea768b2 100644
--- a/dep/include/sockets/Parse.h
+++ b/dep/include/sockets/Parse.h
@@ -2,39 +2,51 @@
  **
  ** Written: 1999-Feb-10 grymse@alhem.net
  **/
+
 /*
 Copyright (C) 1999-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_Parse_H
 #define _SOCKETS_Parse_H
+
 #include "sockets-config.h"
 #ifdef _MSC_VER
 #pragma warning(disable:4514)
 #endif
+
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /***************************************************/
 /* interface of class Parse */
+
 /** Splits a string whatever way you want.
     \ingroup util */
 class Parse
@@ -67,6 +79,7 @@ public:
     void getline(std::string&);
     size_t getptr() { return pa_the_ptr; }
     void EnableQuote(bool b) { pa_quote = b; }
+
 private:
     std::string pa_the_str;
     std::string pa_splits;
@@ -79,8 +92,11 @@ private:
     bool  pa_quote;
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_Parse_H
 
+
diff --git a/dep/include/sockets/ResolvServer.h b/dep/include/sockets/ResolvServer.h
index fb3f5ec1527..b713a8ad382 100644
--- a/dep/include/sockets/ResolvServer.h
+++ b/dep/include/sockets/ResolvServer.h
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -28,9 +33,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifdef ENABLE_RESOLVER
 #include "socket_include.h"
 #include "Thread.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 /** \defgroup async Asynchronous DNS */
 /** Async DNS resolver thread.
     \ingroup async */
@@ -39,21 +46,29 @@ class ResolvServer : public Thread
 public:
     ResolvServer(port_t);
     ~ResolvServer();
+
     void Run();
     void Quit();
+
     bool Ready();
+
 private:
     ResolvServer(const ResolvServer& ) {} // copy constructor
     ResolvServer& operator=(const ResolvServer& ) { return *this; } // assignment operator
+
     bool m_quit;
     port_t m_port;
     bool m_ready;
 };
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // ENABLE_RESOLVER
 #endif // _SOCKETS_ResolvServer_H
 
+
diff --git a/dep/include/sockets/ResolvSocket.h b/dep/include/sockets/ResolvSocket.h
index 2347f040a7a..38ff3335c28 100644
--- a/dep/include/sockets/ResolvSocket.h
+++ b/dep/include/sockets/ResolvSocket.h
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -28,10 +33,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifdef ENABLE_RESOLVER
 #include "TcpSocket.h"
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 class Mutex;
+
 /** Async DNS resolver socket.
     \ingroup async */
 class ResolvSocket : public TcpSocket
@@ -40,6 +48,7 @@ class ResolvSocket : public TcpSocket
             std::map > cache_t; /* host, result */
     typedef std::map > timeout_t; /* host, time */
+
 public:
     ResolvSocket(ISocketHandler&);
     ResolvSocket(ISocketHandler&, Socket *parent, const std::string& host, port_t port, bool ipv6 = false);
@@ -48,19 +57,25 @@ public:
     ResolvSocket(ISocketHandler&, Socket *parent, in6_addr&);
 #endif
     ~ResolvSocket();
+
     void OnAccept() { m_bServer = true; }
     void OnLine(const std::string& line);
     void OnDetached();
     void OnDelete();
+
     void SetId(int x) { m_resolv_id = x; }
     int GetId() { return m_resolv_id; }
+
     void OnConnect();
+
 #ifdef ENABLE_IPV6
     void SetResolveIpv6(bool x = true) { m_resolve_ipv6 = x; }
 #endif
+
 private:
     ResolvSocket(const ResolvSocket& s) : TcpSocket(s) {} // copy constructor
     ResolvSocket& operator=(const ResolvSocket& ) { return *this; } // assignment operator
+
     std::string m_query;
     std::string m_data;
     bool m_bServer;
@@ -80,9 +95,13 @@ private:
 };
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // ENABLE_RESOLVER
 #endif // _SOCKETS_ResolvSocket_H
 
+
diff --git a/dep/include/sockets/SctpSocket.h b/dep/include/sockets/SctpSocket.h
index b3fdd9ae1ab..50757fc4b13 100644
--- a/dep/include/sockets/SctpSocket.h
+++ b/dep/include/sockets/SctpSocket.h
@@ -5,14 +5,17 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -20,15 +23,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef _SOCKETS_SctpSocket_H
 #define _SOCKETS_SctpSocket_H
 #include "sockets-config.h"
+
 #include "StreamSocket.h"
 #ifdef USE_SCTP
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 #define SCTP_BUFSIZE_READ 16400
+
 class SocketAddress;
 
+
 class SctpSocket : public StreamSocket
 {
 public:
@@ -37,6 +45,7 @@ public:
         \param type SCTP_STREAM or SCTP_SEQPACKET */
     SctpSocket(ISocketHandler& h,int type);
     ~SctpSocket();
+
     /** bind() */
     int Bind(const std::string&,port_t);
     int Bind(SocketAddress&);
@@ -46,43 +55,56 @@ public:
     /** sctp_bindx() */
     int RemoveAddress(const std::string&,port_t);
     int RemoveAddress(SocketAddress&);
+
     /** connect() */
     int Open(const std::string&,port_t);
     int Open(SocketAddress&);
+
     /** Connect timeout callback. */
     void OnConnectTimeout();
 #ifdef _WIN32
     /** Connection failed reported as exception on win32 */
     void OnException();
 #endif
+
 #ifndef SOLARIS
     /** sctp_connectx() */
     int AddConnection(const std::string&,port_t);
     int AddConnection(SocketAddress&);
 #endif
+
     /** Get peer addresses of an association. */
     int getpaddrs(sctp_assoc_t id,std::list&);
     /** Get all bound addresses of an association. */
     int getladdrs(sctp_assoc_t id,std::list&);
+
     /** sctp_peeloff */
     int PeelOff(sctp_assoc_t id);
+
     /** recvmsg callback */
     virtual void OnReceiveMessage(const char *buf,size_t sz,struct sockaddr *sa,socklen_t sa_len,struct sctp_sndrcvinfo *sinfo,int msg_flags) = 0;
+
     void OnOptions(int,int,int,SOCKET) {}
+
     virtual int Protocol();
+
 protected:
     SctpSocket(const SctpSocket& s) : StreamSocket(s) {}
     void OnRead();
     void OnWrite();
+
 private:
     SctpSocket& operator=(const SctpSocket& s) { return *this; }
     int m_type; ///< SCTP_STREAM or SCTP_SEQPACKET
     char *m_buf; ///< Temporary receive buffer
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE
 #endif
+
 #endif // USE_SCTP
 #endif // _SOCKETS_SctpSocket_H
 
+
diff --git a/dep/include/sockets/Socket.h b/dep/include/sockets/Socket.h
index cb1c2fb3c29..8a7fdc9d2fd 100644
--- a/dep/include/sockets/Socket.h
+++ b/dep/include/sockets/Socket.h
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This software is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -25,25 +30,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef _SOCKETS_Socket_H
 #define _SOCKETS_Socket_H
 #include "sockets-config.h"
+
 #include 
 #include 
 #include 
 #ifdef HAVE_OPENSSL
 #include 
 #endif
+
 #include "socket_include.h"
 #include 
 #include "SocketAddress.h"
 #include "Thread.h"
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 class ISocketHandler;
 class SocketAddress;
 class IFile;
 
+
 /** \defgroup basic Basic sockets */
 /** Socket base class.
     \ingroup basic */
@@ -58,7 +68,9 @@ class Socket
     public:
         SocketThread(Socket *p);
         ~SocketThread();
+
         void Run();
+
     private:
         Socket *GetSocket() const { return m_socket; }
         SocketThread(const SocketThread& s) : m_socket(s.GetSocket()) {}
@@ -66,6 +78,7 @@ class Socket
         Socket *m_socket;
     };
 #endif // ENABLE_DETACH
+
 #ifdef ENABLE_TRIGGERS
 public:
     /** Data pass class from source to destination. */
@@ -74,12 +87,15 @@ public:
     public:
         TriggerData() : m_src(NULL) {}
         virtual ~TriggerData() {}
+
         Socket *GetSource() const { return m_src; }
         void SetSource(Socket *x) { m_src = x; }
+
     private:
         Socket *m_src;
     };
 #endif // ENABLE_TRIGGERS
+
     /** Socket mode flags. */
 /*
     enum {
@@ -88,17 +104,20 @@ public:
         SOCK_CLOSE =            0x02, ///< Close and delete flag
         SOCK_DISABLE_READ =         0x04, ///< Disable checking for read events
         SOCK_CONNECTED =        0x08, ///< Socket is connected (tcp/udp)
+
         SOCK_ERASED_BY_HANDLER =    0x10, ///< Set by handler before delete
         // HAVE_OPENSSL
         SOCK_ENABLE_SSL =       0x20, ///< Enable SSL for this TcpSocket
         SOCK_SSL =          0x40, ///< ssl negotiation mode (TcpSocket)
         SOCK_SSL_SERVER =       0x80, ///< True if this is an incoming ssl TcpSocket connection
+
         // ENABLE_IPV6
         SOCK_IPV6 =             0x0100, ///< This is an ipv6 socket if this one is true
         // ENABLE_POOL
         SOCK_CLIENT =           0x0200, ///< only client connections are pooled
         SOCK_RETAIN =           0x0400, ///< keep connection on close
         SOCK_LOST =             0x0800, ///< connection lost
+
         // ENABLE_SOCKS4
         SOCK_SOCKS4 =           0x1000, ///< socks4 negotiation mode (TcpSocket)
         // ENABLE_DETACH
@@ -106,30 +125,38 @@ public:
         SOCK_DETACHED =         0x4000, ///< Socket has been detached
         // StreamSocket
         STREAMSOCK_CONNECTING =     0x8000, ///< Flag indicating connection in progress
+
         STREAMSOCK_FLUSH_BEFORE_CLOSE = 0x010000L, ///< Send all data before closing (default true)
         STREAMSOCK_CALL_ON_CONNECT =    0x020000L, ///< OnConnect will be called next ISocketHandler cycle if true
         STREAMSOCK_RETRY_CONNECT =  0x040000L, ///< Try another connection attempt next ISocketHandler cycle
         STREAMSOCK_LINE_PROTOCOL =  0x080000L, ///< Line protocol mode flag
+
     };
 */
+
 public:
     /** "Default" constructor */
     Socket(ISocketHandler&);
+
     virtual ~Socket();
+
     /** Socket class instantiation method. Used when a "non-standard" constructor
      * needs to be used for the socket class. Note: the socket class still needs
      * the "default" constructor with one ISocketHandler& as input parameter.
      */
     virtual Socket *Create() { return NULL; }
+
     /** Returns reference to sockethandler that owns the socket.
     If the socket is detached, this is a reference to the slave sockethandler.
     */
     ISocketHandler& Handler() const;
+
     /** Returns reference to sockethandler that owns the socket.
     This one always returns the reference to the original sockethandler,
     even if the socket is detached.
     */
     ISocketHandler& MasterHandler() const;
+
     /** Called by ListenSocket after accept but before socket is added to handler.
      * CTcpSocket uses this to create its ICrypt member variable.
      * The ICrypt member variable is created by a virtual method, therefore
@@ -138,59 +165,83 @@ public:
      * or ssl (port 443).
      */
     virtual void Init();
+
     /** Create a socket file descriptor.
         \param af Address family AF_INET / AF_INET6 / ...
         \param type SOCK_STREAM / SOCK_DGRAM / ...
         \param protocol "tcp" / "udp" / ... */
     SOCKET CreateSocket(int af,int type,const std::string& protocol = "");
+
     /** Assign this socket a file descriptor created
         by a call to socket() or otherwise. */
     void Attach(SOCKET s);
+
     /** Return file descriptor assigned to this socket. */
     SOCKET GetSocket();
+
     /** Close connection immediately - internal use.
         \sa SetCloseAndDelete */
     virtual int Close();
+
     /** Add file descriptor to sockethandler fd_set's. */
     void Set(bool bRead,bool bWrite,bool bException = true);
+
     /** Returns true when socket file descriptor is valid
         and socket is not about to be closed. */
     virtual bool Ready();
+
     /** Returns pointer to ListenSocket that created this instance
      * on an incoming connection. */
     Socket *GetParent();
+
     /** Used by ListenSocket to set parent pointer of newly created
      * socket instance. */
     void SetParent(Socket *);
+
     /** Get listening port from ListenSocket<>. */
     virtual port_t GetPort();
+
     /** Set socket non-block operation. */
     bool SetNonblocking(bool);
+
     /** Set socket non-block operation. */
     bool SetNonblocking(bool, SOCKET);
+
     /** Total lifetime of instance. */
     time_t Uptime();
+
     /** Set address/port of last connect() call. */
     void SetClientRemoteAddress(SocketAddress&);
+
     /** Get address/port of last connect() call. */
     std::auto_ptr GetClientRemoteAddress();
+
     /** Common interface for SendBuf used by Tcp and Udp sockets. */
     virtual void SendBuf(const char *,size_t,int = 0);
+
     /** Common interface for Send used by Tcp and Udp sockets. */
     virtual void Send(const std::string&,int = 0);
+
     /** Outgoing traffic counter. */
     virtual uint64_t GetBytesSent(bool clear = false);
+
     /** Incoming traffic counter. */
     virtual uint64_t GetBytesReceived(bool clear = false);
+
     // LIST_TIMEOUT
+
     /** Enable timeout control. 0=disable timeout check. */
     void SetTimeout(time_t secs);
+
     /** Check timeout. \return true if time limit reached */
     bool Timeout(time_t tnow);
+
     /** Used by ListenSocket. ipv4 and ipv6 */
     void SetRemoteAddress(SocketAddress&);
+
     /** \name Event callbacks */
     //@{
+
     /** Called when there is something to be read from the file descriptor. */
     virtual void OnRead();
     /** Called when there is room for another write on the file descriptor. */
@@ -228,6 +279,7 @@ public:
     /** Connection timeout. */
     virtual void OnConnectTimeout();
     //@}
+
     /** \name Socket mode flags, set/reset */
     //@{
     /** Set delete by handler true when you want the sockethandler to
@@ -236,34 +288,43 @@ public:
     /** Check delete by handler flag.
         \return true if this instance should be deleted by the sockethandler */
     bool DeleteByHandler();
+
     // LIST_CLOSE - conditional event queue
+
     /** Set close and delete to terminate the connection. */
     void SetCloseAndDelete(bool = true);
     /** Check close and delete flag.
         \return true if this socket should be closed and the instance removed */
     bool CloseAndDelete();
+
     /** Return number of seconds since socket was ordered to close. \sa SetCloseAndDelete */
     time_t TimeSinceClose();
+
     /** Ignore read events for an output only socket. */
     void DisableRead(bool x = true);
     /** Check ignore read events flag.
         \return true if read events should be ignored */
     bool IsDisableRead();
+
     /** Set connected status. */
     void SetConnected(bool = true);
     /** Check connected status.
         \return true if connected */
     bool IsConnected();
+
     /** Connection lost - error while reading/writing from a socket - TcpSocket only. */
     void SetLost();
     /** Check connection lost status flag, used by TcpSocket only.
         \return true if there was an error while r/w causing the socket to close */
     bool Lost();
+
     /** Set flag indicating the socket is being actively deleted by the sockethandler. */
     void SetErasedByHandler(bool x = true);
     /** Get value of flag indicating socket is deleted by sockethandler. */
     bool ErasedByHandler();
+
     //@}
+
     /** \name Information about remote connection */
     //@{
     /** Returns address of remote end. */
@@ -283,6 +344,7 @@ public:
     /** ipv4 and ipv6(not implemented) */
     std::string GetRemoteHostname();
     //@}
+
     /** Returns local port number for bound socket file descriptor. */
     port_t GetSockPort();
     /** Returns local ipv4 address for bound socket file descriptor. */
@@ -304,8 +366,10 @@ public:
        checked with an #ifdef below.
        This might cause a compile error on other operating systems. */
     // --------------------------------------------------------------------------
+
     // IP options
     //@{
+
     bool SetIpOptions(const void *p, socklen_t len);
     bool SetIpTOS(unsigned char tos);
     unsigned char IpTOS();
@@ -317,6 +381,7 @@ public:
     bool SetMulticastLoop(bool x = true);
     bool IpAddMembership(struct ip_mreq&);
     bool IpDropMembership(struct ip_mreq&);
+
 #ifdef IP_PKTINFO
     bool SetIpPktinfo(bool x = true);
 #endif
@@ -351,9 +416,11 @@ public:
     bool IpDropMembership(struct ip_mreqn&);
 #endif
     //@}
+
     // SOCKET options
     /** @name Socket Options */
     //@{
+
     bool SoAcceptconn();
     bool SetSoBroadcast(bool x = true);
     bool SetSoDebug(bool x = true);
@@ -372,6 +439,7 @@ public:
     int SoType();
     bool SetSoReuseaddr(bool x = true);
     bool SetSoKeepalive(bool x = true);
+
 #ifdef SO_BSDCOMPAT
     bool SetSoBsdcompat(bool x = true);
 #endif
@@ -400,8 +468,10 @@ public:
     bool SetSoNosigpipe(bool x = true);
 #endif
     //@}
+
     // TCP options in TcpSocket.h/TcpSocket.cpp
 
+
 #ifdef HAVE_OPENSSL
     /** @name SSL Support */
     //@{
@@ -436,6 +506,7 @@ public:
     virtual SSL *GetSsl() { return NULL; }
     //@}
 #endif // HAVE_OPENSSL
+
 #ifdef ENABLE_IPV6
     /** Enable ipv6 for this socket. */
     void SetIpv6(bool x = true);
@@ -443,6 +514,7 @@ public:
         \return true if this is an ipv6 socket */
     bool IsIpv6();
 #endif
+
 #ifdef ENABLE_POOL
     /** @name Connection Pool */
     //@{
@@ -470,6 +542,7 @@ public:
     void CopyConnection(Socket *sock);
     //@}
 #endif // ENABLE_POOL
+
 #ifdef ENABLE_SOCKS4
     /** \name Socks4 support */
     //@{
@@ -485,6 +558,7 @@ public:
     bool Socks4();
     /** Set flag indicating Socks4 handshaking in progress */
     void SetSocks4(bool x = true);
+
     /** Set socks4 server host address to use */
     void SetSocks4Host(ipaddr_t a);
     /** Set socks4 server hostname to use. */
@@ -504,6 +578,7 @@ public:
     const std::string& GetSocks4Userid();
     //@}
 #endif // ENABLE_SOCKS4
+
 #ifdef ENABLE_RESOLVER
     /** \name Asynchronous Resolver */
     //@{
@@ -538,6 +613,7 @@ public:
     virtual void OnResolveFailed(int id);
     //@}
 #endif  // ENABLE_RESOLVER
+
 #ifdef ENABLE_DETACH
     /** \name Thread Support */
     //@{
@@ -545,12 +621,15 @@ public:
         socket is ready for operation again.
         \sa ResolvSocket */
     virtual void OnDetached();
+
     // LIST_DETACH
+
     /** Internal use. */
     void SetDetach(bool x = true);
     /** Check detach flag.
         \return true if the socket should detach to its own thread */
     bool IsDetach();
+
     /** Internal use. */
     void SetDetached(bool x = true);
     /** Check detached flag.
@@ -565,8 +644,10 @@ public:
     void DetachSocket();
     //@}
 #endif // ENABLE_DETACH
+
     /** Write traffic to an IFile. Socket will not delete this object. */
     void SetTrafficMonitor(IFile *p) { m_traffic_monitor = p; }
+
 #ifdef ENABLE_TRIGGERS
     /** \name Triggers */
     //@{
@@ -580,16 +661,21 @@ public:
     virtual void OnCancelled(int id);
     //@}
 #endif
+
 protected:
     /** default constructor not available */
     Socket() : m_handler(m_handler) {}
     /** copy constructor not available */
     Socket(const Socket& s) : m_handler(s.m_handler) {}
+
     /** assignment operator not available. */
     Socket& operator=(const Socket& ) { return *this; }
+
     /** All traffic will be written to this IFile, if set. */
     IFile *GetTrafficMonitor() { return m_traffic_monitor; }
+
 //  unsigned long m_flags; ///< boolean flags, replacing old 'bool' members
+
 private:
     ISocketHandler& m_handler; ///< Reference of ISocketHandler in control of this socket
     SOCKET m_socket; ///< File descriptor
@@ -607,29 +693,35 @@ private:
     time_t m_timeout_start; ///< Set by SetTimeout
     time_t m_timeout_limit; ///< Defined by SetTimeout
     bool m_bLost; ///< connection lost
+
 #ifdef _WIN32
 static  WSAInitializer m_winsock_init; ///< Winsock initialization singleton class
 #endif
+
 #ifdef HAVE_OPENSSL
     bool m_b_enable_ssl; ///< Enable SSL for this TcpSocket
     bool m_b_ssl; ///< ssl negotiation mode (TcpSocket)
     bool m_b_ssl_server; ///< True if this is an incoming ssl TcpSocket connection
 #endif
+
 #ifdef ENABLE_IPV6
     bool m_ipv6; ///< This is an ipv6 socket if this one is true
 #endif
+
 #ifdef ENABLE_POOL
     int m_socket_type; ///< Type of socket, from socket() call
     std::string m_socket_protocol; ///< Protocol, from socket() call
     bool m_bClient; ///< only client connections are pooled
     bool m_bRetain; ///< keep connection on close
 #endif
+
 #ifdef ENABLE_SOCKS4
     bool m_bSocks4; ///< socks4 negotiation mode (TcpSocket)
     ipaddr_t m_socks4_host; ///< socks4 server address
     port_t m_socks4_port; ///< socks4 server port number
     std::string m_socks4_userid; ///< socks4 server usedid
 #endif
+
 #ifdef ENABLE_DETACH
     bool m_detach; ///< Socket ordered to detach flag
     bool m_detached; ///< Socket has been detached
@@ -637,9 +729,12 @@ static  WSAInitializer m_winsock_init; ///< Winsock initialization singleton cla
     ISocketHandler *m_slave_handler; ///< Actual sockethandler while detached
 #endif
 };
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
 #endif // _SOCKETS_Socket_H
 
+
diff --git a/dep/include/sockets/SocketAddress.h b/dep/include/sockets/SocketAddress.h
index af7aaa3a03d..496600b112c 100644
--- a/dep/include/sockets/SocketAddress.h
+++ b/dep/include/sockets/SocketAddress.h
@@ -5,28 +5,34 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_SocketAddress_H
 #define _SOCKETS_SocketAddress_H
+
 #include "sockets-config.h"
 #include 
 #include 
 #include "socket_include.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /**
    This class and its subclasses is intended to be used as replacement
    for the internal data type 'ipaddr_t' and various implementations of
@@ -41,36 +47,50 @@ class SocketAddress
 {
 public:
     virtual ~SocketAddress() {}
+
     /** Get a pointer to the address struct. */
     virtual operator struct sockaddr *() = 0;
+
     /** Get length of address struct. */
     virtual operator socklen_t() = 0;
+
     /** Compare two addresses. */
     virtual bool operator==(SocketAddress&) = 0;
+
     /** Set port number.
         \param port Port number in host byte order */
     virtual void SetPort(port_t port) = 0;
+
     /** Get port number.
         \return Port number in host byte order. */
     virtual port_t GetPort() = 0;
+
     /** Set socket address.
         \param sa Pointer to either 'struct sockaddr_in' or 'struct sockaddr_in6'. */
     virtual void SetAddress(struct sockaddr *sa) = 0;
+
     /** Convert address to text. */
     virtual std::string Convert(bool include_port) = 0;
+
     /** Reverse lookup of address. */
     virtual std::string Reverse() = 0;
+
     /** Get address family. */
     virtual int GetFamily() = 0;
+
     /** Address structure is valid. */
     virtual bool IsValid() = 0;
+
     /** Get a copy of this SocketAddress object. */
     virtual std::auto_ptr GetCopy() = 0;
 };
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
 #endif // _SOCKETS_SocketAddress_H
 
+
diff --git a/dep/include/sockets/SocketHandler.h b/dep/include/sockets/SocketHandler.h
index e187de5f675..1812c9c386f 100644
--- a/dep/include/sockets/SocketHandler.h
+++ b/dep/include/sockets/SocketHandler.h
@@ -4,40 +4,50 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_SocketHandler_H
 #define _SOCKETS_SocketHandler_H
+
 #include "sockets-config.h"
 #include 
 #include 
+
 #include "socket_include.h"
 #include "ISocketHandler.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 class Socket;
 #ifdef ENABLE_RESOLVER
 class ResolvServer;
 #endif
 class Mutex;
+
 /** Socket container class, event generator.
     \ingroup basic */
 class SocketHandler : public ISocketHandler
@@ -45,43 +55,60 @@ class SocketHandler : public ISocketHandler
 protected:
     /** Map type for holding file descriptors/socket object pointers. */
     typedef std::map socket_m;
+
 public:
     /** SocketHandler constructor.
         \param log Optional log class pointer */
     SocketHandler(StdLog *log = NULL);
+
     /** SocketHandler threadsafe constructor.
         \param mutex Externally declared mutex variable
         \param log Optional log class pointer */
     SocketHandler(Mutex& mutex,StdLog *log = NULL);
+
     ~SocketHandler();
+
     /** Get mutex reference for threadsafe operations. */
     Mutex& GetMutex() const;
+
     /** Register StdLog object for error callback.
         \param log Pointer to log class */
     void RegStdLog(StdLog *log);
+
     /** Log error to log class for print out / storage. */
     void LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t = LOG_LEVEL_WARNING);
+
     /** Add socket instance to socket map. Removal is always automatic. */
     void Add(Socket *);
+
     /** Get status of read/write/exception file descriptor set for a socket. */
     void Get(SOCKET s,bool& r,bool& w,bool& e);
+
     /** Set read/write/exception file descriptor sets (fd_set). */
     void Set(SOCKET s,bool bRead,bool bWrite,bool bException = true);
+
     /** Wait for events, generate callbacks. */
     int Select(long sec,long usec);
+
     /** This method will not return until an event has been detected. */
     int Select();
+
     /** Wait for events, generate callbacks. */
     int Select(struct timeval *tsel);
+
     /** Check that a socket really is handled by this socket handler. */
     bool Valid(Socket *);
+
     /** Return number of sockets handled by this handler.  */
     size_t GetCount();
+
     /** Override and return false to deny all incoming connections.
         \param p ListenSocket class pointer (use GetPort to identify which one) */
     bool OkToAccept(Socket *p);
+
     /** Called by Socket when a socket changes state. */
     void AddList(SOCKET s,list_t which_one,bool add);
+
     // Connection pool
 #ifdef ENABLE_POOL
     /** Find available open connection (used by connection pool). */
@@ -92,6 +119,7 @@ public:
         \return true if connection pool is enabled */
     bool PoolEnabled();
 #endif // ENABLE_POOL
+
     // Socks4
 #ifdef ENABLE_SOCKS4
     /** Set socks4 server ip that all new tcp sockets should use. */
@@ -117,6 +145,7 @@ public:
         \return true if direct connection should be tried if connection to socks4 server fails */
     bool Socks4TryDirect();
 #endif // ENABLE_SOCKS4
+
     // DNS resolve server
 #ifdef ENABLE_RESOLVER
     /** Enable asynchronous DNS.
@@ -144,6 +173,7 @@ public:
     /** Returns true if the socket is waiting for a resolve event. */
     bool Resolving(Socket *);
 #endif // ENABLE_RESOLVER
+
 #ifdef ENABLE_TRIGGERS
     /** Fetch unique trigger id. */
     int TriggerID(Socket *src);
@@ -158,22 +188,27 @@ public:
             Leave them in place if 'false' - if a trigger should be called many times */
     void Trigger(int id, Socket::TriggerData& data, bool erase = true);
 #endif // ENABLE_TRIGGERS
+
 #ifdef ENABLE_DETACH
     /** Indicates that the handler runs under SocketThread. */
     void SetSlave(bool x = true);
     /** Indicates that the handler runs under SocketThread. */
     bool IsSlave();
 #endif
+
     /** Sanity check of those accursed lists. */
     void CheckSanity();
+
 protected:
     socket_m m_sockets; ///< Active sockets map
     socket_m m_add; ///< Sockets to be added to sockets map
     std::list m_delete; ///< Sockets to be deleted (failed when Add)
+
 protected:
     StdLog *m_stdlog; ///< Registered log class, or NULL
     Mutex& m_mutex; ///< Thread safety mutex
     bool m_b_use_mutex; ///< Mutex correctly initialized
+
 private:
     void CheckList(socket_v&,const std::string&); ///< Used by CheckSanity
     /** Remove socket from socket map, used by Socket class. */
@@ -185,6 +220,7 @@ private:
     int m_preverror; ///< debug select() error
     int m_errcnt; ///< debug select() error
     time_t m_tlast; ///< timeout control
+
     // state lists
     socket_v m_fds; ///< Active file descriptor list
     socket_v m_fds_erase; ///< File descriptors that are to be erased from m_sockets
@@ -195,6 +231,7 @@ private:
     socket_v m_fds_timeout; ///< checklist timeout
     socket_v m_fds_retry; ///< checklist retry client connect
     socket_v m_fds_close; ///< checklist close and delete
+
 #ifdef ENABLE_SOCKS4
     ipaddr_t m_socks4_host; ///< Socks4 server host ip
     port_t m_socks4_port; ///< Socks4 server port number
@@ -220,8 +257,11 @@ private:
 #endif
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_SocketHandler_H
 
+
diff --git a/dep/include/sockets/StdLog.h b/dep/include/sockets/StdLog.h
index 65d91081338..8266479f21c 100644
--- a/dep/include/sockets/StdLog.h
+++ b/dep/include/sockets/StdLog.h
@@ -4,31 +4,39 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_StdLog_H
 #define _SOCKETS_StdLog_H
+
 #include "sockets-config.h"
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 /** error level enum. */
 typedef enum
 {
@@ -38,8 +46,10 @@ typedef enum
     LOG_LEVEL_INFO
 } loglevel_t;
 
+
 class ISocketHandler;
 class Socket;
+
 /** \defgroup logging Log help classes */
 /** Log class interface.
     \ingroup logging */
@@ -47,6 +57,7 @@ class StdLog
 {
 public:
     virtual ~StdLog() {}
+
     virtual void error(ISocketHandler *,Socket *,
         const std::string& user_text,
         int err,
@@ -54,8 +65,11 @@ public:
         loglevel_t = LOG_LEVEL_WARNING) = 0;
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_StdLog_H
 
+
diff --git a/dep/include/sockets/StdoutLog.h b/dep/include/sockets/StdoutLog.h
index 8e97700a2ff..aee865be6af 100644
--- a/dep/include/sockets/StdoutLog.h
+++ b/dep/include/sockets/StdoutLog.h
@@ -4,32 +4,40 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_StdoutLog_H
 #define _SOCKETS_StdoutLog_H
+
 #include "sockets-config.h"
 #include "StdLog.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /** StdLog implementation, logs to stdout.
     \ingroup logging */
 class StdoutLog : public StdLog
@@ -39,8 +47,12 @@ public:
 };
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_StdoutLog_H
 
+
diff --git a/dep/include/sockets/StreamSocket.h b/dep/include/sockets/StreamSocket.h
index 6abb936b6cd..e839040e2b0 100644
--- a/dep/include/sockets/StreamSocket.h
+++ b/dep/include/sockets/StreamSocket.h
@@ -1,11 +1,14 @@
 #ifndef _StreamSocket_H
 #define _StreamSocket_H
+
 #include "Socket.h"
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /** SOCK_STREAM Socket base class.
     \ingroup basic */
 class StreamSocket : public Socket
@@ -13,70 +16,96 @@ class StreamSocket : public Socket
 public:
     StreamSocket(ISocketHandler& );
     ~StreamSocket();
+
     /** Socket should Check Connect on next write event from select(). */
     void SetConnecting(bool = true);
+
     /** Check connecting flag.
         \return true if the socket is still trying to connect */
     bool Connecting();
+
     /** Returns true when socket file descriptor is valid,
         socket connection is established, and socket is not about to
         be closed. */
     bool Ready();
+
     /** Set timeout to use for connection attempt.
         \param x Timeout in seconds */
     void SetConnectTimeout(int x);
+
     /** Return number of seconds to wait for a connection.
         \return Connection timeout (seconds) */
     int GetConnectTimeout();
+
     /** Set flush before close to make a tcp socket completely empty its
         output buffer before closing the connection. */
     void SetFlushBeforeClose(bool = true);
+
     /** Check flush before status.
         \return true if the socket should send all data before closing */
     bool GetFlushBeforeClose();
+
     /** Define number of connection retries (tcp only).
         n = 0 - no retry
         n > 0 - number of retries
         n = -1 - unlimited retries */
     void SetConnectionRetry(int n);
+
     /** Get number of maximum connection retries (tcp only). */
     int GetConnectionRetry();
+
     /** Increase number of actual connection retries (tcp only). */
     void IncreaseConnectionRetries();
+
     /** Get number of actual connection retries (tcp only). */
     int GetConnectionRetries();
+
     /** Reset actual connection retries (tcp only). */
     void ResetConnectionRetries();
+
     // LIST_CALLONCONNECT
+
     /** Instruct socket to call OnConnect callback next sockethandler cycle. */
     void SetCallOnConnect(bool x = true);
+
     /** Check call on connect flag.
         \return true if OnConnect() should be called a.s.a.p */
     bool CallOnConnect();
+
     // LIST_RETRY
+
     /** Set flag to initiate a connection attempt after a connection timeout. */
     void SetRetryClientConnect(bool x = true);
+
     /** Check if a connection attempt should be made.
         \return true when another attempt should be made */
     bool RetryClientConnect();
+
     /** Called after OnRead if socket is in line protocol mode.
         \sa SetLineProtocol */
     /** Enable the OnLine callback. Do not create your own OnRead
      * callback when using this. */
     virtual void SetLineProtocol(bool = true);
+
     /** Check line protocol mode.
         \return true if socket is in line protocol mode */
     bool LineProtocol();
+
     /** Set shutdown status. */
     void SetShutdown(int);
+
     /** Get shutdown status. */
     int GetShutdown();
+
     /** Returns IPPROTO_TCP or IPPROTO_SCTP */
     virtual int Protocol() = 0;
+
 protected:
     StreamSocket(const StreamSocket& ) {} // copy constructor
+
 private:
     StreamSocket& operator=(const StreamSocket& ) { return *this; } // assignment operator
+
     bool m_bConnecting; ///< Flag indicating connection in progress
     int m_connect_timeout; ///< Connection timeout (seconds)
     bool m_flush_before_close; ///< Send all data before closing (default true)
@@ -88,9 +117,12 @@ private:
     int m_shutdown; ///< Shutdown status
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
 
+
 #endif // _StreamSocket_H
 
+
diff --git a/dep/include/sockets/TcpSocket.h b/dep/include/sockets/TcpSocket.h
index 34561f59cdc..4caeb548aaa 100644
--- a/dep/include/sockets/TcpSocket.h
+++ b/dep/include/sockets/TcpSocket.h
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -30,15 +35,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include 
 #include "SSLInitializer.h"
 #endif
+
 #include 
+
 #define TCP_BUFSIZE_READ 16400
 #define TCP_OUTPUT_CAPACITY 1024000
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 class SocketAddress;
 
+
 /** Socket implementation for TCP.
     \ingroup basic */
 class TcpSocket : public StreamSocket
@@ -52,6 +62,7 @@ protected:
     public:
         CircularBuffer(size_t size);
         ~CircularBuffer();
+
         /** append l bytes from p to buffer */
         bool Write(const char *p,size_t l);
         /** copy l bytes from buffer to dest */
@@ -62,6 +73,7 @@ protected:
         bool Remove(size_t l);
         /** read l bytes from buffer, returns as string. */
         std::string ReadString(size_t l);
+
         /** total buffer length */
         size_t GetLength();
         /** pointer to circular buffer beginning */
@@ -70,8 +82,10 @@ protected:
         size_t GetL();
         /** return free space in buffer, number of bytes until buffer overrun */
         size_t Space();
+
         /** return total number of bytes written to this buffer, ever */
         unsigned long ByteCounter(bool clear = false);
+
     private:
         CircularBuffer(const CircularBuffer& /*s*/) {}
         CircularBuffer& operator=(const CircularBuffer& ) { return *this; }
@@ -114,6 +128,7 @@ protected:
         char _buf[TCP_OUTPUT_CAPACITY];
     };
     typedef std::list output_l;
+
 public:
     /** Constructor with standard values on input/output buffers. */
     TcpSocket(ISocketHandler& );
@@ -123,6 +138,7 @@ public:
         \param osize Output buffer size */
     TcpSocket(ISocketHandler& h,size_t isize,size_t osize);
     ~TcpSocket();
+
     /** Open a connection to a remote server.
         If you want your socket to connect to a server,
         always call Open before Add'ing a socket to the sockethandler.
@@ -147,15 +163,18 @@ public:
         \param host Hostname
         \param port Port number */
     bool Open(const std::string &host,port_t port);
+
     /** Connect timeout callback. */
     void OnConnectTimeout();
 #ifdef _WIN32
     /** Connection failed reported as exception on win32 */
     void OnException();
 #endif
+
     /** Close file descriptor - internal use only.
         \sa SetCloseAndDelete */
     int Close();
+
     /** Send a string.
         \param s String to send
         \param f Dummy flags -- not used */
@@ -171,6 +190,7 @@ public:
         \param buf Pointer to the data
         \param len Length of the data */
     virtual void OnRawData(const char *buf,size_t len);
+
     /** Called when output buffer has been sent.
         Note: Will only be called IF the output buffer has been used.
         Send's that was successful without needing the output buffer
@@ -180,6 +200,7 @@ public:
     size_t GetInputLength();
     /** Number of bytes in output buffer. */
     size_t GetOutputLength();
+
     /** Callback fires when a socket in line protocol has read one full line.
         \param line Line read */
     void OnLine(const std::string& line);
@@ -187,6 +208,7 @@ public:
     uint64_t GetBytesReceived(bool clear = false);
     /** Get counter of number of bytes sent. */
     uint64_t GetBytesSent(bool clear = false);
+
     /** Socks4 specific callback. */
     void OnSocks4Connect();
     /** Socks4 specific callback. */
@@ -194,6 +216,7 @@ public:
     /** Socks4 specific callback.
         \return 'need_more' */
     bool OnSocks4Read();
+
 #ifdef ENABLE_RESOLVER
     /** Callback executed when resolver thread has finished a resolve request. */
     void OnResolved(int id,ipaddr_t a,port_t port);
@@ -213,6 +236,7 @@ public:
         the ssl context for an incoming connection. */
     virtual void InitSSLServer();
 #endif
+
 #ifdef ENABLE_RECONNECT
     /** Flag that says a broken connection will try to reconnect. */
     void SetReconnect(bool = true);
@@ -223,17 +247,24 @@ public:
     /** Socket is reconnecting. */
     bool IsReconnect();
 #endif
+
     void DisableInputBuffer(bool = true);
+
     void OnOptions(int,int,int,SOCKET);
+
     void SetLineProtocol(bool = true);
+
     // TCP options
     bool SetTcpNodelay(bool = true);
+
     virtual int Protocol();
+
     /** Trigger limit for callback OnTransferLimit. */
     void SetTransferLimit(size_t sz);
     /** This callback fires when the output buffer drops below the value
         set by SetTransferLimit. Default: 0 (disabled). */
     virtual void OnTransferLimit();
+
 protected:
     TcpSocket(const TcpSocket& );
     void OnRead();
@@ -265,13 +296,17 @@ static  int SSL_password_cb(char *buf,int num,int rwflag,void *userdata);
     /** SSL; Get ssl password. */
     const std::string& GetPassword();
 #endif
+
     CircularBuffer ibuf; ///< Circular input buffer
+
 private:
     TcpSocket& operator=(const TcpSocket& ) { return *this; }
+
     /** the actual send() */
     int TryWrite(const char *buf, size_t len);
     /** add data to output buffer top */
     void Buffer(const char *buf, size_t len);
+
     //
     bool m_b_input_buffer_disabled;
     uint64_t m_bytes_sent;
@@ -286,6 +321,7 @@ private:
     OUTPUT *m_obuf_top; ///< output buffer on top
     size_t m_transfer_limit;
     size_t m_output_length;
+
 #ifdef HAVE_OPENSSL
 static  SSLInitializer m_ssl_init;
     SSL_CTX *m_ssl_ctx; ///< ssl context
@@ -293,6 +329,7 @@ static  SSLInitializer m_ssl_init;
     BIO *m_sbio; ///< ssl bio
     std::string m_password; ///< ssl password
 #endif
+
 #ifdef ENABLE_SOCKS4
     int m_socks4_state; ///< socks4 support
     char m_socks4_vn; ///< socks4 support, temporary variable
@@ -300,17 +337,23 @@ static  SSLInitializer m_ssl_init;
     unsigned short m_socks4_dstport; ///< socks4 support
     unsigned long m_socks4_dstip; ///< socks4 support
 #endif
+
 #ifdef ENABLE_RESOLVER
     int m_resolver_id; ///< Resolver id (if any) for current Open call
 #endif
+
 #ifdef ENABLE_RECONNECT
     bool m_b_reconnect; ///< Reconnect on lost connection flag
     bool m_b_is_reconnect; ///< Trying to reconnect
 #endif
+
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_TcpSocket_H
 
+
diff --git a/dep/include/sockets/Thread.h b/dep/include/sockets/Thread.h
index 4c649ed14d5..e065a257a85 100644
--- a/dep/include/sockets/Thread.h
+++ b/dep/include/sockets/Thread.h
@@ -4,30 +4,37 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_Thread_H
 #define _SOCKETS_Thread_H
+
 #include "sockets-config.h"
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 #ifdef _WIN32
 // to be
 //typedef DWORD  threadfunc_t;
@@ -38,10 +45,12 @@ typedef void * threadparam_t;
 #define STDPREFIX __stdcall
 #else
 #include 
+
 typedef void * threadfunc_t;
 typedef void * threadparam_t;
 #define STDPREFIX
 #endif
+
 /** \defgroup threading Threading */
 /** Thread base class.
 The Thread class is used by the resolver (ResolvServer) and running a detached socket (SocketThread).
@@ -54,8 +63,11 @@ class Thread
 public:
     Thread(bool release = true);
     virtual ~Thread();
+
     static threadfunc_t STDPREFIX StartThread(threadparam_t);
+
     virtual void Run() = 0;
+
     bool IsRunning();
     void SetRunning(bool x);
     bool IsReleased();
@@ -63,6 +75,7 @@ public:
     bool DeleteOnExit();
     void SetDeleteOnExit(bool x = true);
     bool IsDestructor();
+
 private:
     Thread(const Thread& ) {}
     Thread& operator=(const Thread& ) { return *this; }
@@ -78,8 +91,11 @@ private:
     bool m_b_destructor;
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_Thread_H
 
+
diff --git a/dep/include/sockets/UdpSocket.h b/dep/include/sockets/UdpSocket.h
index 010a7b23143..fd9965e96e8 100644
--- a/dep/include/sockets/UdpSocket.h
+++ b/dep/include/sockets/UdpSocket.h
@@ -4,31 +4,39 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_UdpSocket_H
 #define _SOCKETS_UdpSocket_H
+
 #include "sockets-config.h"
 #include "Socket.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 /** Socket implementation for UDP.
     \ingroup basic */
 class UdpSocket : public Socket
@@ -40,12 +48,14 @@ public:
         \param ipv6 'true' if this is an ipv6 socket */
     UdpSocket(ISocketHandler& h,int ibufsz = 16384,bool ipv6 = false, int retries = 0);
     ~UdpSocket();
+
     /** Called when incoming data has been received.
         \param buf Pointer to data
         \param len Length of data
         \param sa Pointer to sockaddr struct of sender
         \param sa_len Length of sockaddr struct */
     virtual void OnRawData(const char *buf,size_t len,struct sockaddr *sa,socklen_t sa_len);
+
     /** Called when incoming data has been received and read timestamp is enabled.
         \param buf Pointer to data
         \param len Length of data
@@ -53,6 +63,7 @@ public:
         \param sa_len Length of sockaddr struct
         \param ts Timestamp from message */
     virtual void OnRawData(const char *buf,size_t len,struct sockaddr *sa,socklen_t sa_len,struct timeval *ts);
+
     /** To receive incoming data, call Bind to setup an incoming port.
         \param port Incoming port number
         \param range Port range to try if ports already in use
@@ -85,6 +96,7 @@ public:
         \param range Port range
         \return 0 if bind succeeded */
     int Bind(SocketAddress& ad,int range = 1);
+
     /** Define remote host.
         \param l Address of remote host
         \param port Port of remote host
@@ -108,6 +120,7 @@ public:
         \param ad Socket address
         \return true if successful */
     bool Open(SocketAddress& ad);
+
     /** Send to specified host */
     void SendToBuf(const std::string& ,port_t,const char *data,int len,int flags = 0);
     /** Send to specified address */
@@ -120,6 +133,7 @@ public:
 #endif
     /** Send to specified socket address */
     void SendToBuf(SocketAddress& ad,const char *data,int len,int flags = 0);
+
     /** Send string to specified host */
     void SendTo(const std::string&,port_t,const std::string&,int flags = 0);
     /** Send string to specified address */
@@ -132,15 +146,18 @@ public:
 #endif
     /** Send string to specified socket address */
     void SendTo(SocketAddress& ad,const std::string&,int flags = 0);
+
     /** Send to connected address */
     void SendBuf(const char *data,size_t,int flags = 0);
     /** Send string to connected address. */
     void Send(const std::string& ,int flags = 0);
+
     /** Set broadcast */
     void SetBroadcast(bool b = true);
     /** Check broadcast flag.
         \return true broadcast is enabled. */
     bool IsBroadcast();
+
     /** multicast */
     void SetMulticastTTL(int ttl = 1);
     int GetMulticastTTL();
@@ -160,10 +177,14 @@ public:
     bool IsBound();
     /** Return Bind port number */
     port_t GetPort();
+
     void OnOptions(int,int,int,SOCKET) {}
+
     int GetLastSizeWritten();
+
     /** Also read timestamp information from incoming message */
     void SetTimestamp(bool = true);
+
 protected:
     UdpSocket(const UdpSocket& s) : Socket(s) {}
     void OnRead();
@@ -171,6 +192,7 @@ protected:
     /** This method emulates socket recvfrom, but uses messages so we can get the timestamp */
     int ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen_t fromlen, struct timeval *ts);
 #endif
+
 private:
     UdpSocket& operator=(const UdpSocket& ) { return *this; }
     /** create before using sendto methods */
@@ -184,8 +206,11 @@ private:
     bool m_b_read_ts;
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_UdpSocket_H
 
+
diff --git a/dep/include/sockets/Utility.h b/dep/include/sockets/Utility.h
index 8f1c15ab260..be0f6a05498 100644
--- a/dep/include/sockets/Utility.h
+++ b/dep/include/sockets/Utility.h
@@ -4,26 +4,32 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_Utility_H
 #define _SOCKETS_Utility_H
+
 #include "sockets-config.h"
 #include 
 #include 
@@ -31,11 +37,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "socket_include.h"
 #include 
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 #define TWIST_LEN     624
+
 class SocketAddress;
+
 /** Conversion utilities.
     \ingroup util */
 class Utility
@@ -47,7 +57,9 @@ class Utility
     class Rng {
     public:
         Rng(unsigned long seed);
+
         unsigned long Get();
+
     private:
         int m_value;
         unsigned long m_tmp[TWIST_LEN];
@@ -72,13 +84,16 @@ public:
     static unsigned int hex2unsigned(const std::string& str);
     static std::string rfc1738_encode(const std::string& src);
     static std::string rfc1738_decode(const std::string& src);
+
     /** Checks whether a string is a valid ipv4/ipv6 ip number. */
     static bool isipv4(const std::string&);
     /** Checks whether a string is a valid ipv4/ipv6 ip number. */
     static bool isipv6(const std::string&);
+
     /** Hostname to ip resolution ipv4, not asynchronous. */
     static bool u2ip(const std::string&, ipaddr_t&);
     static bool u2ip(const std::string&, struct sockaddr_in& sa, int ai_flags = 0);
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
     /** Hostname to ip resolution ipv6, not asynchronous. */
@@ -86,10 +101,13 @@ public:
     static bool u2ip(const std::string&, struct sockaddr_in6& sa, int ai_flags = 0);
 #endif
 #endif
+
     /** Reverse lookup of address to hostname */
     static bool reverse(struct sockaddr *sa, socklen_t sa_len, std::string&, int flags = 0);
     static bool reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, std::string& service, int flags = 0);
+
     static bool u2service(const std::string& name, int& service, int ai_flags = 0);
+
     /** Convert binary ip address to string: ipv4. */
     static void l2ip(const ipaddr_t,std::string& );
     static void l2ip(const in_addr&,std::string& );
@@ -97,6 +115,7 @@ public:
 #ifdef IPPROTO_IPV6
     /** Convert binary ip address to string: ipv6. */
     static void l2ip(const struct in6_addr&,std::string& ,bool mixed = false);
+
     /** ipv6 address compare. */
     static int in6_addr_compare(in6_addr,in6_addr);
 #endif
@@ -129,15 +148,22 @@ public:
     /** Convert sockaddr struct to human readable string.
         \param sa Ptr to sockaddr struct */
     static std::string Sa2String(struct sockaddr *sa);
+
     /** Get current time in sec/microseconds. */
     static void GetTime(struct timeval *);
+
     static std::auto_ptr CreateAddress(struct sockaddr *,socklen_t);
+
     static unsigned long ThreadID();
+
     static std::string ToLower(const std::string& str);
     static std::string ToUpper(const std::string& str);
+
     static std::string ToString(double d);
+
     /** Returns a random 32-bit integer */
     static unsigned long Rnd();
+
 private:
     static std::string m_host; ///< local hostname
     static ipaddr_t m_ip; ///< local ip address
@@ -151,8 +177,11 @@ private:
     static bool m_local_resolved; ///< ResolveLocal has been called if true
 };
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // _SOCKETS_Utility_H
 
+
diff --git a/dep/include/sockets/socket_include.h b/dep/include/sockets/socket_include.h
index e5a216432b5..dcfd4acfbd6 100644
--- a/dep/include/sockets/socket_include.h
+++ b/dep/include/sockets/socket_include.h
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -25,19 +30,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef _SOCKETS_socket_include_H
 #define _SOCKETS_socket_include_H
 #include "sockets-config.h"
+
 #ifdef _MSC_VER
 #pragma warning(disable:4514)
 #endif
+
 // common defines affecting library and applications using library
+
 /* Define SOCKETS_DYNAMIC_TEMP to use dynamically allocated buffers
    in read operations - helps on ECOS */
 #define SOCKETS_DYNAMIC_TEMP
 
+
 // platform specific stuff
 #if (defined(__unix__) || defined(unix)) && !defined(USG)
 #include 
 #endif
 #include 
+
 // int64
 #ifdef _WIN32
 typedef unsigned __int64 uint64_t;
@@ -49,6 +59,7 @@ typedef unsigned __int64 uint64_t;
 # include 
 #endif
 #endif
+
 #ifndef _WIN32
 // ----------------------------------------
 // common unix includes / defines
@@ -59,35 +70,44 @@ typedef unsigned __int64 uint64_t;
 #include 
 #include 
 //#include 
+
 // all typedefs in this file will be declared outside the sockets namespace,
 // because some os's will already have one or more of the type defined.
 typedef int SOCKET;
 #define Errno errno
 #define StrError strerror
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 // WIN32 adapt
 #define closesocket close
 #define INVALID_SOCKET -1
 #define SOCKET_ERROR -1
+
 #ifndef INADDR_NONE
 #define INADDR_NONE ((unsigned long) -1)
 #endif // INADDR_NONE
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // !_WIN32
 
+
 // ----------------------------------------
 // Generic
 #ifndef SOL_IP
 #define SOL_IP IPPROTO_IP
 #endif
 
+
 // ----------------------------------------
 // OS specific adaptions
+
 #ifdef SOLARIS
 // ----------------------------------------
 // Solaris
@@ -96,11 +116,14 @@ typedef unsigned short port_t;
 namespace SOCKETS_NAMESPACE {
 #endif
 // no defs
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #define s6_addr16 _S6_un._S6_u8
 #define MSG_NOSIGNAL 0
+
 #elif defined __FreeBSD__
 // ----------------------------------------
 // FreeBSD
@@ -116,22 +139,25 @@ typedef in_port_t port_t;
 namespace SOCKETS_NAMESPACE {
 #endif
 // no defs
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #  define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
 #  define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
 # else
 #  error FreeBSD versions prior to 400014 does not support ipv6
 # endif
+
 #elif defined (__NetBSD__) || defined (__OpenBSD__)
-#  if !defined(MSG_NOSIGNAL)
-#   define MSG_NOSIGNAL 0
-#  endif
-#  include 
-typedef in_addr_t ipaddr_t;
-typedef in_port_t port_t;
-#elif defined MACOSX
+#  if !defined(MSG_NOSIGNAL)  
+#   define MSG_NOSIGNAL 0  
+#  endif  
+#  include   
+typedef in_addr_t ipaddr_t;  
+typedef in_port_t port_t;  
+#elif defined MACOSX 
 // ----------------------------------------
 // Mac OS X
 #include 
@@ -145,13 +171,16 @@ typedef unsigned long ipaddr_t;
 namespace SOCKETS_NAMESPACE {
 #endif
 // no defs
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #define s6_addr16 __u6_addr.__u6_addr16
 #define MSG_NOSIGNAL 0 // oops - thanks Derek
 #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
 #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
+
 #elif defined _WIN32
 // ----------------------------------------
 // Win32
@@ -159,6 +188,7 @@ namespace SOCKETS_NAMESPACE {
 #pragma comment(lib, "wsock32.lib")
 #endif
 #define strcasecmp _stricmp
+
 typedef unsigned long ipaddr_t;
 typedef unsigned short port_t;
 typedef int socklen_t;
@@ -166,12 +196,15 @@ typedef int socklen_t;
 namespace SOCKETS_NAMESPACE {
 #endif
 // no defs
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 // 1.8.6: define FD_SETSIZE to something bigger than 64 if there are a lot of
 // simultaneous connections (must be done before including winsock.h)
 #define FD_SETSIZE 1024
+
 // windows 2000 with ipv6 preview installed:
 //    http://msdn.microsoft.com/downloads/sdks/platform/tpipv6.asp
 // see the FAQ on how to install
@@ -186,15 +219,19 @@ namespace SOCKETS_NAMESPACE {
 #endif
 #endif // _MSC_VER < 1200
 
+
 #define MSG_NOSIGNAL 0
 //#define SHUT_RDWR 2
 #define SHUT_WR 1
+
 #define Errno WSAGetLastError()
 const char *StrError(int x);
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 // class WSAInitializer is a part of the Socket class (on win32)
 // as a static instance - so whenever an application uses a Socket,
 // winsock is initialized
@@ -213,9 +250,11 @@ public:
 private:
     WSADATA m_wsadata;
 };
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #else
 // ----------------------------------------
 // LINUX
@@ -225,21 +264,26 @@ typedef unsigned short port_t;
 namespace SOCKETS_NAMESPACE {
 #endif
 // no defs
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
 #endif
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
     /** List type containing file descriptors. */
     typedef std::list socket_v;
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
 // getaddrinfo / getnameinfo replacements
 #ifdef NO_GETADDRINFO
 #ifndef AI_NUMERICHOST
@@ -250,5 +294,7 @@ namespace SOCKETS_NAMESPACE {
 #endif
 #endif
 
+
 #endif // _SOCKETS_socket_include_H
 
+
diff --git a/dep/include/sockets/sockets-config.h b/dep/include/sockets/sockets-config.h
index f2de433756c..464ed34cabb 100644
--- a/dep/include/sockets/sockets-config.h
+++ b/dep/include/sockets/sockets-config.h
@@ -5,20 +5,24 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 _SOCKETS_CONFIG_H
 #define _SOCKETS_CONFIG_H
+
 #ifndef _RUN_DP
 /* First undefine symbols if already defined. */
 #undef HAVE_OPENSSL
@@ -33,51 +37,66 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #undef ENABLE_TRIGGERS
 #undef ENABLE_EXCEPTIONS
 #endif // _RUN_DP
+
 // define MACOSX for internal socket library checks
 #if defined(__APPLE__) && defined(__MACH__) && !defined(MACOSX)
 #define MACOSX
 #endif
+
 /* OpenSSL support. */
 //#define HAVE_OPENSSL
 
+
 /* Ipv6 support. */
 //#define ENABLE_IPV6
 
+
 /* SCTP support. */
 //#define USE_SCTP
 
+
 /* Define NO_GETADDRINFO if your operating system does not support
    the "getaddrinfo" and "getnameinfo" function calls. */
 #define NO_GETADDRINFO
 
+
 /* Connection pool support. */
 #define ENABLE_POOL
 
+
 /* Socks4 client support. */
 //#define ENABLE_SOCKS4
 
+
 /* Asynchronous resolver. */
 #define ENABLE_RESOLVER
 
+
 /* Enable TCP reconnect on lost connection.
     Socket::OnReconnect
     Socket::OnDisconnect
 */
 #define ENABLE_RECONNECT
 
+
 /* Enable socket thread detach functionality. */
 #define ENABLE_DETACH
 
+
 /* Enable socket to socket triggers. Not yet in use. */
 //#define ENABLE_TRIGGERS
 
+
 /* Enabled exceptions. */
 //#define ENABLE_EXCEPTIONS
 
+
 /* Resolver uses the detach function so either enable both or disable both. */
 #ifndef ENABLE_DETACH
 #undef ENABLE_RESOLVER
 #endif
 
+
 #endif // _SOCKETS_CONFIG_H
 
+
diff --git a/dep/src/g3dlite/AABox.cpp b/dep/src/g3dlite/AABox.cpp
index dd4f79394f7..f2f2b70535c 100644
--- a/dep/src/g3dlite/AABox.cpp
+++ b/dep/src/g3dlite/AABox.cpp
@@ -1,47 +1,61 @@
 /**
   @file AABox.cpp
+
   @maintainer Morgan McGuire, matrix@graphics3d.com
+
   @created 2004-01-10
   @edited  2006-01-11
 */
+
 #include "G3D/platform.h"
 #   if defined(_MSC_VER) && (_MSC_VER <= 1200)
         // VC6 std:: has signed/unsigned problems
 #       pragma warning (disable : 4018)
 #   endif
+
 #include 
 #include "G3D/AABox.h"
 #include "G3D/Box.h"
 #include "G3D/Plane.h"
 #include "G3D/Sphere.h"
 
+
 namespace G3D {
+
 Box AABox::toBox() const {
     return Box(lo, hi);
 }
 
+
+
 void AABox::split(const Vector3::Axis& axis, float location, AABox& low, AABox& high) const {
     // Low, medium, and high along the chosen axis
     float L = G3D::min(location, lo[axis]);
     float M = G3D::min(G3D::max(location, lo[axis]), hi[axis]);
     float H = G3D::max(location, hi[axis]);
+
     // Copy over this box.
     high = low = *this;
+
     // Now move the split points along the special axis
     low.lo[axis] = L;
     low.hi[axis] = M;
     high.lo[axis] = M;
     high.hi[axis] = H;
 }
+
 #if 0
 Vector3 AABox::randomSurfacePoint() const {
     Vector3 extent = hi - lo;
     float aXY = extent.x * extent.y;
     float aYZ = extent.y * extent.z;
     float aZX = extent.z * extent.x;
+
     float r = (float)random(0, aXY + aYZ + aZX);
+
     // Choose evenly between positive and negative face planes
     float d = ((float)random(0, 1) < 0.5f) ? 0.0f : 1.0f;
+
     // The probability of choosing a given face is proportional to
     // its area.
     if (r < aXY) {
@@ -68,6 +82,7 @@ Vector3 AABox::randomSurfacePoint() const {
     }
 }
 
+
 Vector3 AABox::randomInteriorPoint() const {
     return Vector3(
         (float)random(lo.x, hi.x),
@@ -76,46 +91,60 @@ Vector3 AABox::randomInteriorPoint() const {
 }
 #endif
 
+
 bool AABox::intersects(const AABox& other) const {
     // Must be overlap along all three axes.
     // Try to find a separating axis.
+
     for (int a = 0; a < 3; ++a) {
+
         //     |--------|
         // |------|
+
         if ((lo[a] > other.hi[a]) ||
             (hi[a] < other.lo[a])) {
             return false;
         }
     }
+
     return true;
 }
 
+
 bool AABox::culledBy(
     const Array&     plane,
     int&                    cullingPlaneIndex,
     const uint32            inMask,
     uint32&                 outMask) const {
+
     return culledBy(plane.getCArray(), plane.size(), cullingPlaneIndex, inMask, outMask);
 }
 
+
 bool AABox::culledBy(
     const Array&     plane,
     int&                    cullingPlaneIndex,
     const uint32            inMask) const {
+
     return culledBy(plane.getCArray(), plane.size(), cullingPlaneIndex, inMask);
 }
 
+
 int AABox::dummy = 0;
 
+
 bool AABox::culledBy(
     const class Plane*  plane,
     int                 numPlanes,
     int&                cullingPlane,
     const uint32        _inMask,
     uint32&             childMask) const {
+
     uint32 inMask = _inMask;
     assert(numPlanes < 31);
+
     childMask = 0;
+
     const bool finite =
         (abs(lo.x) < G3D::inf()) &&
         (abs(hi.x) < G3D::inf()) &&
@@ -123,14 +152,19 @@ bool AABox::culledBy(
         (abs(hi.y) < G3D::inf()) &&
         (abs(lo.z) < G3D::inf()) &&
         (abs(hi.z) < G3D::inf());
+
     // See if there is one plane for which all of the
     // vertices are in the negative half space.
     for (int p = 0; p < numPlanes; p++) {
+
         // Only test planes that are not masked
         if ((inMask & 1) != 0) {
+
             Vector3 corner;
+
             int numContained = 0;
             int v = 0;
+
             // We can early-out only if we have found one point on each
             // side of the plane (i.e. if we are straddling).  That
             // occurs when (numContained < v) && (numContained > 0)
@@ -140,6 +174,7 @@ bool AABox::culledBy(
                 corner.x = (v & 1) ? hi.x : lo.x;
                 corner.y = (v & 2) ? hi.y : lo.y;
                 corner.z = (v & 4) ? hi.z : lo.z;
+
                 if (finite) { // this branch is highly predictable
                     if (plane[p].halfSpaceContainsFinite(corner)) {
                         ++numContained;
@@ -150,36 +185,44 @@ bool AABox::culledBy(
                     }
                 }
             }
+
             if (numContained == 0) {
                 // Plane p culled the box
                 cullingPlane = p;
+
                 // The caller should not recurse into the children,
                 // since the parent is culled.  If they do recurse,
                 // make them only test against this one plane, which
                 // will immediately cull the volume.
                 childMask = 1 << p;
                 return true;
+
             } else if (numContained < v) {
                 // The bounding volume straddled the plane; we have
                 // to keep testing against this plane
                 childMask |= (1 << p);
             }
         }
+
         // Move on to the next bit.
         inMask = inMask >> 1;
     }
+
     // None of the planes could cull this box
     cullingPlane = -1;
     return false;
 }
 
+
 bool AABox::culledBy(
     const class Plane*  plane,
     int                 numPlanes,
     int&                cullingPlane,
     const uint32        _inMask) const {
+
     uint32 inMask = _inMask;
     assert(numPlanes < 31);
+
     const bool finite =
         (abs(lo.x) < G3D::inf()) &&
         (abs(hi.x) < G3D::inf()) &&
@@ -187,45 +230,58 @@ bool AABox::culledBy(
         (abs(hi.y) < G3D::inf()) &&
         (abs(lo.z) < G3D::inf()) &&
         (abs(hi.z) < G3D::inf());
+
     // See if there is one plane for which all of the
     // vertices are in the negative half space.
     for (int p = 0; p < numPlanes; p++) {
+
         // Only test planes that are not masked
         if ((inMask & 1) != 0) {
+
             bool culled = true;
             Vector3 corner;
+
             int v;
+
             // Assume this plane culls all points.  See if there is a point
             // not culled by the plane... early out when at least one point
             // is in the positive half space.
             for (v = 0; (v < 8) && culled; ++v) {
+
                 // Unrolling these 3 if's into a switch decreases performance
                 // by about 2x
                 corner.x = (v & 1) ? hi.x : lo.x;
                 corner.y = (v & 2) ? hi.y : lo.y;
                 corner.z = (v & 4) ? hi.z : lo.z;
+
                 if (finite) { // this branch is highly predictable
                     culled = ! plane[p].halfSpaceContainsFinite(corner);
                 } else {
                     culled = ! plane[p].halfSpaceContains(corner);
                 }
             }
+
             if (culled) {
                 // Plane p culled the box
                 cullingPlane = p;
+
                 return true;
             }
         }
+
         // Move on to the next bit.
         inMask = inMask >> 1;
     }
+
     // None of the planes could cull this box
     cullingPlane = -1;
     return false;
 }
 
+
 bool AABox::intersects(const class Sphere& sphere) const {
     double d = 0;
+
     //find the square of the distance
     //from the sphere to the box
     for (int i = 0; i < 3; ++i) {
@@ -235,8 +291,10 @@ bool AABox::intersects(const class Sphere& sphere) const {
             d += square(sphere.center[i] - hi[i]);
         }
     }
+
     return d <= square(sphere.radius);
 }
 
+
 } // namespace
 
diff --git a/dep/src/g3dlite/Box.cpp b/dep/src/g3dlite/Box.cpp
index 76aea3293fa..fd3067048c0 100644
--- a/dep/src/g3dlite/Box.cpp
+++ b/dep/src/g3dlite/Box.cpp
@@ -1,16 +1,21 @@
 /**
   @file Box.cpp
   Box class
+
   @maintainer Morgan McGuire, matrix@graphics3d.com
+
   @created 2001-06-02
   @edited  2006-02-05
 */
+
 #include "G3D/Box.h"
 #include "G3D/debug.h"
 #include "G3D/Plane.h"
 #include "G3D/AABox.h"
 #include "G3D/CoordinateFrame.h"
+
 namespace G3D {
+
 /**
  Sets a field on four vertices.  Used by the constructor.
  */
@@ -18,119 +23,158 @@ namespace G3D {
     _corner[i0].field = _corner[i1].field = \
     _corner[i2].field = _corner[i3].field = \
     (extreme).field
+
 Box::Box() {
 }
 
+
 Box::Box(const AABox& b) {
     init(b.low(), b.high());
 }
 
+
 Box::Box(
     const Vector3& min,
     const Vector3& max) {
+
     init(min.min(max), min.max(max));
+
 }
+
 void Box::init(
     const Vector3& min,
     const Vector3& max) {
+
     setMany(0, 1, 2, 3, z, max);
     setMany(4, 5, 6, 7, z, min);
+
     setMany(1, 2, 5, 6, x, max);
     setMany(0, 3, 4, 7, x, min);
+
     setMany(3, 2, 6, 7, y, max);
     setMany(0, 1, 5, 4, y, min);
+
     _extent = max - min;
+
     _axis[0] = Vector3::unitX();
     _axis[1] = Vector3::unitY();
     _axis[2] = Vector3::unitZ();
+
     _volume = _extent.x * _extent.y * _extent.z;
-    _area = 2 *
+    _area = 2 * 
         (_extent.x * _extent.y +
          _extent.y * _extent.z +
          _extent.z * _extent.x);
+
     _center = (max + min) / 2;
 }
 
+
 float Box::volume() const {
     return _volume;
 }
 
+
 float Box::surfaceArea() const {
     return _area;
 }
 
+
 void Box::getLocalFrame(CoordinateFrame& frame) const {
+
     frame.rotation = Matrix3(
         _axis[0][0], _axis[1][0], _axis[2][0],
         _axis[0][1], _axis[1][1], _axis[2][1],
         _axis[0][2], _axis[1][2], _axis[2][2]);
+
     frame.translation = _center;
 }
 
+
 CoordinateFrame Box::localFrame() const {
     CoordinateFrame out;
     getLocalFrame(out);
     return out;
 }
 
+
 void Box::getFaceCorners(int f, Vector3& v0, Vector3& v1, Vector3& v2, Vector3& v3) const {
     switch (f) {
     case 0:
         v0 = _corner[0]; v1 = _corner[1]; v2 = _corner[2]; v3 = _corner[3];
         break;
+
     case 1:
         v0 = _corner[1]; v1 = _corner[5]; v2 = _corner[6]; v3 = _corner[2];
         break;
+
     case 2:
         v0 = _corner[7]; v1 = _corner[6]; v2 = _corner[5]; v3 = _corner[4];
         break;
+
     case 3:
         v0 = _corner[2]; v1 = _corner[6]; v2 = _corner[7]; v3 = _corner[3];
         break;
+
     case 4:
         v0 = _corner[3]; v1 = _corner[7]; v2 = _corner[4]; v3 = _corner[0];
         break;
+
     case 5:
         v0 = _corner[1]; v1 = _corner[0]; v2 = _corner[4]; v3 = _corner[5];
         break;
+
     default:
         debugAssert((f >= 0) && (f < 6));
     }
 }
 
+
 bool Box::culledBy(
     const Array&        plane,
     int&                    cullingPlaneIndex,
     const uint32            inMask,
     uint32&                    outMask) const {
+
     return culledBy(plane.getCArray(), plane.size(), cullingPlaneIndex, inMask, outMask);
 }
 
+
 bool Box::culledBy(
     const Array&        plane,
     int&                    cullingPlaneIndex,
     const uint32            inMask) const {
+
     return culledBy(plane.getCArray(), plane.size(), cullingPlaneIndex, inMask);
 }
 
+
 int32 Box::dummy = 0;
+
 bool Box::culledBy(
     const class Plane*  plane,
     int                 numPlanes,
     int&                cullingPlane,
     const uint32        _inMask,
     uint32&             childMask) const {
+
     uint32 inMask = _inMask;
     assert(numPlanes < 31);
+
     childMask = 0;
+
     // See if there is one plane for which all of the
     // vertices are in the negative half space.
     for (int p = 0; p < numPlanes; p++) {
+
         // Only test planes that are not masked
         if ((inMask & 1) != 0) {
+        
             Vector3 corner;
+
             int numContained = 0;
             int v = 0;
+
             // We can early-out only if we have found one point on each
             // side of the plane (i.e. if we are straddling).  That
             // occurs when (numContained < v) && (numContained > 0)
@@ -139,93 +183,120 @@ bool Box::culledBy(
                     ++numContained;
                 }
             }
+
             if (numContained == 0) {
                 // Plane p culled the box
                 cullingPlane = p;
+
                 // The caller should not recurse into the children,
                 // since the parent is culled.  If they do recurse,
                 // make them only test against this one plane, which
                 // will immediately cull the volume.
                 childMask = 1 << p;
                 return true;
+
             } else if (numContained < v) {
                 // The bounding volume straddled the plane; we have
                 // to keep testing against this plane
                 childMask |= (1 << p);
             }
         }
+
         // Move on to the next bit.
         inMask = inMask >> 1;
     }
+
     // None of the planes could cull this box
     cullingPlane = -1;
     return false;
 }
 
+
 bool Box::culledBy(
     const class Plane*  plane,
     int                 numPlanes,
     int&                cullingPlane,
     const uint32        _inMask) const {
+
     uint32 inMask = _inMask;
     assert(numPlanes < 31);
+
     // See if there is one plane for which all of the
     // vertices are in the negative half space.
     for (int p = 0; p < numPlanes; p++) {
+
         // Only test planes that are not masked
         if ((inMask & 1) != 0) {
+        
             bool culled = true;
+
             int v;
+
             // Assume this plane culls all points.  See if there is a point
             // not culled by the plane... early out when at least one point
             // is in the positive half space.
             for (v = 0; (v < 8) && culled; ++v) {
                 culled = ! plane[p].halfSpaceContains(getCorner(v));
             }
+
             if (culled) {
                 // Plane p culled the box
                 cullingPlane = p;
+
                 return true;
             }
         }
+
         // Move on to the next bit.
         inMask = inMask >> 1;
     }
+
     // None of the planes could cull this box
     cullingPlane = -1;
     return false;
 }
 
+
 bool Box::contains(
     const Vector3&      point) const {
+
     // Form axes from three edges, transform the point into that
     // space, and perform 3 interval tests
+
     Vector3 u = _corner[4] - _corner[0];
     Vector3 v = _corner[3] - _corner[0];
     Vector3 w = _corner[1] - _corner[0];
+
     Matrix3 M = Matrix3(u.x, v.x, w.x,
                         u.y, v.y, w.y,
                         u.z, v.z, w.z);
+
     // M^-1 * (point - _corner[0]) = point in unit cube's object space
     // compute the inverse of M
     Vector3 osPoint = M.inverse() * (point - _corner[0]);
+
     return
-        (osPoint.x >= 0) &&
+        (osPoint.x >= 0) && 
         (osPoint.y >= 0) &&
         (osPoint.z >= 0) &&
         (osPoint.x <= 1) &&
         (osPoint.y <= 1) &&
         (osPoint.z <= 1);
 }
+
 #undef setMany
+
 #if 0
 void Box::getRandomSurfacePoint(Vector3& P, Vector3& N) const {
     float aXY = _extent.x * _extent.y;
     float aYZ = _extent.y * _extent.z;
     float aZX = _extent.z * _extent.x;
+
     float r = (float)random(0, aXY + aYZ + aZX);
+
     // Choose evenly between positive and negative face planes
     float d = (random(0, 1) < 0.5f) ? -1.0f : 1.0f;
+
     // The probability of choosing a given face is proportional to
     // its area.
     if (r < aXY) {
@@ -246,25 +317,33 @@ void Box::getRandomSurfacePoint(Vector3& P, Vector3& N) const {
     }
 }
 
+
 Vector3 Box::randomInteriorPoint() const {
     Vector3 sum = _center;
+
     for (int a = 0; a < 3; ++a) {
         sum += _axis[a] * (float)random(-0.5, 0.5) * _extent[a];
     }
+
     return sum;
 }
 #endif
 
+
 void Box::getBounds(class AABox& aabb) const {
+
     Vector3 lo = _corner[0];
     Vector3 hi = lo;
+
     for (int v = 1; v < 8; ++v) {
         const Vector3& C = _corner[v];
         lo = lo.min(C);
         hi = hi.max(C);
     }
+
     aabb = AABox(lo, hi);
 }
 
+
 } // namespace
 
diff --git a/dep/src/g3dlite/Crypto.cpp b/dep/src/g3dlite/Crypto.cpp
index ff8019ad29d..bff3a5a966c 100644
--- a/dep/src/g3dlite/Crypto.cpp
+++ b/dep/src/g3dlite/Crypto.cpp
@@ -1,19 +1,26 @@
 /**
  @file Crypto.cpp
+
  @author Morgan McGuire, matrix@graphics3d.com
 
+
  @created 2006-03-28
  @edited  2006-04-06
  */
+
 #include "G3D/platform.h"
 #include "G3D/Crypto.h"
 #include "G3D/g3dmath.h"
+
 namespace G3D {
 
+
 int Crypto::smallPrime(int n) {
     debugAssert(n < numSmallPrimes() && n >= 0);
+
     // From:
     // http://primes.utm.edu/lists/small/1000.txt
+
     static const int table[] = {
           2,      3,      5,      7,     11,     13,     17,     19,     23,     29,
          31,     37,     41,     43,     47,     53,     59,     61,     67,     71,
@@ -46,12 +53,15 @@ int Crypto::smallPrime(int n) {
        1823,   1831,   1847,   1861,   1867,   1871,   1873,   1877,   1879,   1889,
        1901,   1907,   1913,   1931,   1933,   1949,   1951,   1973,   1979,   1987,
        1993,   1997,   1999};
+
     return table[n];
 }
 
+
 int Crypto::numSmallPrimes() {
     return 303;
 }
+
 uint32 Crypto::crc32(const void* byte, size_t numBytes) {
     static const uint32 crc32Table[256] = {
         0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
@@ -70,6 +80,7 @@ uint32 Crypto::crc32(const void* byte, size_t numBytes) {
         0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
         0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
         0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
+
         0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
         0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
         0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
@@ -86,6 +97,7 @@ uint32 Crypto::crc32(const void* byte, size_t numBytes) {
         0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
         0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
         0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
+
         0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
         0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
         0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
@@ -102,6 +114,7 @@ uint32 Crypto::crc32(const void* byte, size_t numBytes) {
         0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
         0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
         0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
+
         0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
         0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
         0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
@@ -119,12 +132,16 @@ uint32 Crypto::crc32(const void* byte, size_t numBytes) {
         0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
         0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D,
     };
+
     // By definition, initialize to all binary 1's
     uint32 value = 0xFFFFFFFF;
+
     for (size_t i = 0; i < numBytes; ++i) {
         value = (value >> 8 ) ^ crc32Table[static_cast(byte)[i] ^ (value & 0xFF)];
     }
+
     return value;
 }
+
 } // G3D
 
diff --git a/dep/src/g3dlite/Matrix3.cpp b/dep/src/g3dlite/Matrix3.cpp
index 717939c8809..630c1883c0b 100644
--- a/dep/src/g3dlite/Matrix3.cpp
+++ b/dep/src/g3dlite/Matrix3.cpp
@@ -1,10 +1,14 @@
 /**
  @file Matrix3.cpp
+
  3x3 matrix class
+
  @author Morgan McGuire, graphics3d.com
+
  @created 2001-06-02
  @edited  2006-04-06
 */
+
 #include "G3D/platform.h"
 #include "G3D/format.h"
 #include 
@@ -12,21 +16,28 @@
 #include "G3D/Matrix3.h"
 #include "G3D/g3dmath.h"
 #include "G3D/Quat.h"
+
 namespace G3D {
+
 const float Matrix3::EPSILON = 1e-06f;
+
 const Matrix3& Matrix3::zero() {
     static Matrix3 m(0, 0, 0, 0, 0, 0, 0, 0, 0);
     return m;
 }
+
 const Matrix3& Matrix3::identity() {
     static Matrix3 m(1, 0, 0, 0, 1, 0, 0, 0, 1);
     return m;
 }
+
 // Deprecated.
 const Matrix3 Matrix3::ZERO(0, 0, 0, 0, 0, 0, 0, 0, 0);
 const Matrix3 Matrix3::IDENTITY(1, 0, 0, 0, 1, 0, 0, 0, 1);
+
 const float Matrix3::ms_fSvdEpsilon = 1e-04f;
 const int Matrix3::ms_iSvdMaxIterations = 32;
+
 bool Matrix3::fuzzyEq(const Matrix3& b) const {
     for (int r = 0; r < 3; ++r) {
         for (int c = 0; c < 3; ++c) {
@@ -38,10 +49,12 @@ bool Matrix3::fuzzyEq(const Matrix3& b) const {
     return true;
 }
 
+
 bool Matrix3::isOrthonormal() const {
     Vector3 X = getColumn(0);
     Vector3 Y = getColumn(1);
     Vector3 Z = getColumn(2);
+
     return
         (G3D::fuzzyEq(X.dot(Y), 0.0f) &&
          G3D::fuzzyEq(Y.dot(Z), 0.0f) &&
@@ -50,6 +63,7 @@ bool Matrix3::isOrthonormal() const {
          G3D::fuzzyEq(Y.squaredMagnitude(), 1.0f) &&
          G3D::fuzzyEq(Z.squaredMagnitude(), 1.0f));
 }
+
 //----------------------------------------------------------------------------
 Matrix3::Matrix3(const Quat& _q) {
     // Implementation from Watt and Watt, pg 362
@@ -59,23 +73,30 @@ Matrix3::Matrix3(const Quat& _q) {
     float xy = 2.0f * q.x * q.y;
     float xz = 2.0f * q.x * q.z;
     float xw = 2.0f * q.x * q.w;
+
     float yy = 2.0f * q.y * q.y;
     float yz = 2.0f * q.y * q.z;
     float yw = 2.0f * q.y * q.w;
+
     float zz = 2.0f * q.z * q.z;
     float zw = 2.0f * q.z * q.w;
+
     set(1.0f - yy - zz,    xy - zw,        xz + yw,
         xy + zw,          1.0f - xx - zz,  yz - xw,
         xz - yw,          yz + xw,        1.0f - xx - yy);
 }
+
 //----------------------------------------------------------------------------
+
 Matrix3::Matrix3 (const float aafEntry[3][3]) {
     memcpy(elt, aafEntry, 9*sizeof(float));
 }
+
 //----------------------------------------------------------------------------
 Matrix3::Matrix3 (const Matrix3& rkMatrix) {
     memcpy(elt, rkMatrix.elt, 9*sizeof(float));
 }
+
 //----------------------------------------------------------------------------
 Matrix3::Matrix3(
           float fEntry00, float fEntry01, float fEntry02,
@@ -85,10 +106,12 @@ Matrix3::Matrix3(
         fEntry10, fEntry11, fEntry12,
         fEntry20, fEntry21, fEntry22);
 }
+
 void Matrix3::set(
           float fEntry00, float fEntry01, float fEntry02,
           float fEntry10, float fEntry11, float fEntry12,
           float fEntry20, float fEntry21, float fEntry22) {
+
     elt[0][0] = fEntry00;
     elt[0][1] = fEntry01;
     elt[0][2] = fEntry02;
@@ -100,15 +123,18 @@ void Matrix3::set(
     elt[2][2] = fEntry22;
 }
 
+
 //----------------------------------------------------------------------------
 Vector3 Matrix3::getColumn (int iCol) const {
     assert((0 <= iCol) && (iCol < 3));
     return Vector3(elt[0][iCol], elt[1][iCol],
                    elt[2][iCol]);
 }
+
 Vector3 Matrix3::getRow (int iRow) const {
     return Vector3(elt[iRow][0], elt[iRow][1], elt[iRow][2]);
 }
+
 void Matrix3::setColumn(int iCol, const Vector3 &vector) {
     debugAssert((iCol >= 0) && (iCol < 3));
     elt[0][iCol] = vector.x;
@@ -116,6 +142,7 @@ void Matrix3::setColumn(int iCol, const Vector3 &vector) {
     elt[2][iCol] = vector.z;
 }
 
+
 void Matrix3::setRow(int iRow, const Vector3 &vector) {
     debugAssert((iRow >= 0) && (iRow < 3));
     elt[iRow][0] = vector.x;
@@ -123,6 +150,7 @@ void Matrix3::setRow(int iRow, const Vector3 &vector) {
     elt[iRow][2] = vector.z;
 }
 
+
 //----------------------------------------------------------------------------
 bool Matrix3::operator== (const Matrix3& rkMatrix) const {
     for (int iRow = 0; iRow < 3; iRow++) {
@@ -131,37 +159,47 @@ bool Matrix3::operator== (const Matrix3& rkMatrix) const {
                 return false;
         }
     }
+
     return true;
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::operator!= (const Matrix3& rkMatrix) const {
     return !operator==(rkMatrix);
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::operator+ (const Matrix3& rkMatrix) const {
     Matrix3 kSum;
+
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             kSum.elt[iRow][iCol] = elt[iRow][iCol] +
                                           rkMatrix.elt[iRow][iCol];
         }
     }
+
     return kSum;
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::operator- (const Matrix3& rkMatrix) const {
     Matrix3 kDiff;
+
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             kDiff.elt[iRow][iCol] = elt[iRow][iCol] -
                                            rkMatrix.elt[iRow][iCol];
         }
     }
+
     return kDiff;
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::operator* (const Matrix3& rkMatrix) const {
     Matrix3 kProd;
+
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             kProd.elt[iRow][iCol] =
@@ -170,24 +208,30 @@ Matrix3 Matrix3::operator* (const Matrix3& rkMatrix) const {
                 elt[iRow][2] * rkMatrix.elt[2][iCol];
         }
     }
+
     return kProd;
 }
+
 Matrix3& Matrix3::operator+= (const Matrix3& rkMatrix) {
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             elt[iRow][iCol] = elt[iRow][iCol] + rkMatrix.elt[iRow][iCol];
         }
     }
+
     return *this;
 }
+
 Matrix3& Matrix3::operator-= (const Matrix3& rkMatrix) {
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             elt[iRow][iCol] = elt[iRow][iCol] - rkMatrix.elt[iRow][iCol];
         }
     }
+
     return *this;
 }
+
 Matrix3& Matrix3::operator*= (const Matrix3& rkMatrix) {
     Matrix3 mulMat;
     for (int iRow = 0; iRow < 3; iRow++) {
@@ -198,60 +242,76 @@ Matrix3& Matrix3::operator*= (const Matrix3& rkMatrix) {
                 elt[iRow][2] * rkMatrix.elt[2][iCol];
         }
     }
+
     *this = mulMat;
     return *this;
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::operator- () const {
     Matrix3 kNeg;
+
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             kNeg[iRow][iCol] = -elt[iRow][iCol];
         }
     }
+
     return kNeg;
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::operator* (float fScalar) const {
     Matrix3 kProd;
+
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             kProd[iRow][iCol] = fScalar * elt[iRow][iCol];
         }
     }
+
     return kProd;
 }
+
 //----------------------------------------------------------------------------
 Matrix3 operator* (double fScalar, const Matrix3& rkMatrix) {
     Matrix3 kProd;
+
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             kProd[iRow][iCol] = fScalar * rkMatrix.elt[iRow][iCol];
         }
     }
+
     return kProd;
 }
+
 Matrix3 operator* (float fScalar, const Matrix3& rkMatrix) {
     return (double)fScalar * rkMatrix;
 }
 
+
 Matrix3 operator* (int fScalar, const Matrix3& rkMatrix) {
     return (double)fScalar * rkMatrix;
 }
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::transpose () const {
     Matrix3 kTranspose;
+
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++) {
             kTranspose[iRow][iCol] = elt[iCol][iRow];
         }
     }
+
     return kTranspose;
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::inverse (Matrix3& rkInverse, float fTolerance) const {
     // Invert a 3x3 using cofactors.  This is about 8 times faster than
     // the Numerical Recipes code which uses Gaussian elimination.
+
     rkInverse[0][0] = elt[1][1] * elt[2][2] -
                       elt[1][2] * elt[2][1];
     rkInverse[0][1] = elt[0][2] * elt[2][1] -
@@ -270,25 +330,32 @@ bool Matrix3::inverse (Matrix3& rkInverse, float fTolerance) const {
                       elt[0][0] * elt[2][1];
     rkInverse[2][2] = elt[0][0] * elt[1][1] -
                       elt[0][1] * elt[1][0];
+
     float fDet =
         elt[0][0] * rkInverse[0][0] +
         elt[0][1] * rkInverse[1][0] +
         elt[0][2] * rkInverse[2][0];
+
     if ( G3D::abs(fDet) <= fTolerance )
         return false;
+
     float fInvDet = 1.0 / fDet;
+
     for (int iRow = 0; iRow < 3; iRow++) {
         for (int iCol = 0; iCol < 3; iCol++)
             rkInverse[iRow][iCol] *= fInvDet;
     }
+
     return true;
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::inverse (float fTolerance) const {
     Matrix3 kInverse = Matrix3::zero();
     inverse(kInverse, fTolerance);
     return kInverse;
 }
+
 //----------------------------------------------------------------------------
 float Matrix3::determinant () const {
     float fCofactor00 = elt[1][1] * elt[2][2] -
@@ -297,27 +364,33 @@ float Matrix3::determinant () const {
                        elt[1][0] * elt[2][2];
     float fCofactor20 = elt[1][0] * elt[2][1] -
                        elt[1][1] * elt[2][0];
+
     float fDet =
         elt[0][0] * fCofactor00 +
         elt[0][1] * fCofactor10 +
         elt[0][2] * fCofactor20;
+
     return fDet;
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::bidiagonalize (Matrix3& kA, Matrix3& kL,
                              Matrix3& kR) {
     float afV[3], afW[3];
     float fLength, fSign, fT1, fInvT1, fT2;
     bool bIdentity;
+
     // map first column to (*,0,0)
     fLength = sqrt(kA[0][0] * kA[0][0] + kA[1][0] * kA[1][0] +
                          kA[2][0] * kA[2][0]);
+
     if ( fLength > 0.0 ) {
         fSign = (kA[0][0] > 0.0 ? 1.0 : -1.0);
         fT1 = kA[0][0] + fSign * fLength;
         fInvT1 = 1.0 / fT1;
         afV[1] = kA[1][0] * fInvT1;
         afV[2] = kA[2][0] * fInvT1;
+
         fT2 = -2.0 / (1.0 + afV[1] * afV[1] + afV[2] * afV[2]);
         afW[0] = fT2 * (kA[0][0] + kA[1][0] * afV[1] + kA[2][0] * afV[2]);
         afW[1] = fT2 * (kA[0][1] + kA[1][1] * afV[1] + kA[2][1] * afV[2]);
@@ -329,6 +402,7 @@ void Matrix3::bidiagonalize (Matrix3& kA, Matrix3& kL,
         kA[1][2] += afV[1] * afW[2];
         kA[2][1] += afV[2] * afW[1];
         kA[2][2] += afV[2] * afW[2];
+
         kL[0][0] = 1.0 + fT2;
         kL[0][1] = kL[1][0] = fT2 * afV[1];
         kL[0][2] = kL[2][0] = fT2 * afV[2];
@@ -340,12 +414,15 @@ void Matrix3::bidiagonalize (Matrix3& kA, Matrix3& kL,
         kL = Matrix3::identity();
         bIdentity = true;
     }
+
     // map first row to (*,*,0)
     fLength = sqrt(kA[0][1] * kA[0][1] + kA[0][2] * kA[0][2]);
+
     if ( fLength > 0.0 ) {
         fSign = (kA[0][1] > 0.0 ? 1.0 : -1.0);
         fT1 = kA[0][1] + fSign * fLength;
         afV[2] = kA[0][2] / fT1;
+
         fT2 = -2.0 / (1.0 + afV[2] * afV[2]);
         afW[0] = fT2 * (kA[0][1] + kA[0][2] * afV[2]);
         afW[1] = fT2 * (kA[1][1] + kA[1][2] * afV[2]);
@@ -355,6 +432,7 @@ void Matrix3::bidiagonalize (Matrix3& kA, Matrix3& kL,
         kA[1][2] += afW[1] * afV[2];
         kA[2][1] += afW[2];
         kA[2][2] += afW[2] * afV[2];
+
         kR[0][0] = 1.0;
         kR[0][1] = kR[1][0] = 0.0;
         kR[0][2] = kR[2][0] = 0.0;
@@ -364,21 +442,26 @@ void Matrix3::bidiagonalize (Matrix3& kA, Matrix3& kL,
     } else {
         kR = Matrix3::identity();
     }
+
     // map second column to (*,*,0)
     fLength = sqrt(kA[1][1] * kA[1][1] + kA[2][1] * kA[2][1]);
+
     if ( fLength > 0.0 ) {
         fSign = (kA[1][1] > 0.0 ? 1.0 : -1.0);
         fT1 = kA[1][1] + fSign * fLength;
         afV[2] = kA[2][1] / fT1;
+
         fT2 = -2.0 / (1.0 + afV[2] * afV[2]);
         afW[1] = fT2 * (kA[1][1] + kA[2][1] * afV[2]);
         afW[2] = fT2 * (kA[1][2] + kA[2][2] * afV[2]);
         kA[1][1] += afW[1];
         kA[1][2] += afW[2];
         kA[2][2] += afV[2] * afW[2];
+
         float fA = 1.0 + fT2;
         float fB = fT2 * afV[2];
         float fC = 1.0 + fB * afV[2];
+
         if ( bIdentity ) {
             kL[0][0] = 1.0;
             kL[0][1] = kL[1][0] = 0.0;
@@ -396,6 +479,7 @@ void Matrix3::bidiagonalize (Matrix3& kA, Matrix3& kL,
         }
     }
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::golubKahanStep (Matrix3& kA, Matrix3& kL,
                               Matrix3& kR) {
@@ -407,6 +491,7 @@ void Matrix3::golubKahanStep (Matrix3& kA, Matrix3& kL,
     float fDiscr = sqrt(fDiff * fDiff + 4.0 * fT12 * fT12);
     float fRoot1 = 0.5 * (fTrace + fDiscr);
     float fRoot2 = 0.5 * (fTrace - fDiscr);
+
     // adjust right
     float fY = kA[0][0] - (G3D::abs(fRoot1 - fT22) <=
                           G3D::abs(fRoot2 - fT22) ? fRoot1 : fRoot2);
@@ -414,69 +499,110 @@ void Matrix3::golubKahanStep (Matrix3& kA, Matrix3& kL,
     float fInvLength = 1.0 / sqrt(fY * fY + fZ * fZ);
     float fSin = fZ * fInvLength;
     float fCos = -fY * fInvLength;
+
     float fTmp0 = kA[0][0];
     float fTmp1 = kA[0][1];
     kA[0][0] = fCos * fTmp0 - fSin * fTmp1;
     kA[0][1] = fSin * fTmp0 + fCos * fTmp1;
     kA[1][0] = -fSin * kA[1][1];
     kA[1][1] *= fCos;
+
     int iRow;
+
     for (iRow = 0; iRow < 3; iRow++) {
         fTmp0 = kR[0][iRow];
         fTmp1 = kR[1][iRow];
         kR[0][iRow] = fCos * fTmp0 - fSin * fTmp1;
         kR[1][iRow] = fSin * fTmp0 + fCos * fTmp1;
     }
+
     // adjust left
     fY = kA[0][0];
+
     fZ = kA[1][0];
+
     fInvLength = 1.0 / sqrt(fY * fY + fZ * fZ);
+
     fSin = fZ * fInvLength;
+
     fCos = -fY * fInvLength;
+
     kA[0][0] = fCos * kA[0][0] - fSin * kA[1][0];
+
     fTmp0 = kA[0][1];
+
     fTmp1 = kA[1][1];
+
     kA[0][1] = fCos * fTmp0 - fSin * fTmp1;
+
     kA[1][1] = fSin * fTmp0 + fCos * fTmp1;
+
     kA[0][2] = -fSin * kA[1][2];
+
     kA[1][2] *= fCos;
+
     int iCol;
+
     for (iCol = 0; iCol < 3; iCol++) {
         fTmp0 = kL[iCol][0];
         fTmp1 = kL[iCol][1];
         kL[iCol][0] = fCos * fTmp0 - fSin * fTmp1;
         kL[iCol][1] = fSin * fTmp0 + fCos * fTmp1;
     }
+
     // adjust right
     fY = kA[0][1];
+
     fZ = kA[0][2];
+
     fInvLength = 1.0 / sqrt(fY * fY + fZ * fZ);
+
     fSin = fZ * fInvLength;
+
     fCos = -fY * fInvLength;
+
     kA[0][1] = fCos * kA[0][1] - fSin * kA[0][2];
+
     fTmp0 = kA[1][1];
+
     fTmp1 = kA[1][2];
+
     kA[1][1] = fCos * fTmp0 - fSin * fTmp1;
+
     kA[1][2] = fSin * fTmp0 + fCos * fTmp1;
+
     kA[2][1] = -fSin * kA[2][2];
+
     kA[2][2] *= fCos;
+
     for (iRow = 0; iRow < 3; iRow++) {
         fTmp0 = kR[1][iRow];
         fTmp1 = kR[2][iRow];
         kR[1][iRow] = fCos * fTmp0 - fSin * fTmp1;
         kR[2][iRow] = fSin * fTmp0 + fCos * fTmp1;
     }
+
     // adjust left
     fY = kA[1][1];
+
     fZ = kA[2][1];
+
     fInvLength = 1.0 / sqrt(fY * fY + fZ * fZ);
+
     fSin = fZ * fInvLength;
+
     fCos = -fY * fInvLength;
+
     kA[1][1] = fCos * kA[1][1] - fSin * kA[2][1];
+
     fTmp0 = kA[1][2];
+
     fTmp1 = kA[2][2];
+
     kA[1][2] = fCos * fTmp0 - fSin * fTmp1;
+
     kA[2][2] = fSin * fTmp0 + fCos * fTmp1;
+
     for (iCol = 0; iCol < 3; iCol++) {
         fTmp0 = kL[iCol][1];
         fTmp1 = kL[iCol][2];
@@ -484,20 +610,25 @@ void Matrix3::golubKahanStep (Matrix3& kA, Matrix3& kL,
         kL[iCol][2] = fSin * fTmp0 + fCos * fTmp1;
     }
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::singularValueDecomposition (Matrix3& kL, Vector3& kS,
         Matrix3& kR) const {
     int iRow, iCol;
+
     Matrix3 kA = *this;
     bidiagonalize(kA, kL, kR);
+
     for (int i = 0; i < ms_iSvdMaxIterations; i++) {
         float fTmp, fTmp0, fTmp1;
         float fSin0, fCos0, fTan0;
         float fSin1, fCos1, fTan1;
+
         bool bTest1 = (G3D::abs(kA[0][1]) <=
                        ms_fSvdEpsilon * (G3D::abs(kA[0][0]) + G3D::abs(kA[1][1])));
         bool bTest2 = (G3D::abs(kA[1][2]) <=
                        ms_fSvdEpsilon * (G3D::abs(kA[1][1]) + G3D::abs(kA[2][2])));
+
         if ( bTest1 ) {
             if ( bTest2 ) {
                 kS[0] = kA[0][0];
@@ -511,21 +642,25 @@ void Matrix3::singularValueDecomposition (Matrix3& kL, Vector3& kS,
                 fTan0 = 0.5 * (fTmp + sqrt(fTmp * fTmp + 4.0));
                 fCos0 = 1.0 / sqrt(1.0 + fTan0 * fTan0);
                 fSin0 = fTan0 * fCos0;
+
                 for (iCol = 0; iCol < 3; iCol++) {
                     fTmp0 = kL[iCol][1];
                     fTmp1 = kL[iCol][2];
                     kL[iCol][1] = fCos0 * fTmp0 - fSin0 * fTmp1;
                     kL[iCol][2] = fSin0 * fTmp0 + fCos0 * fTmp1;
                 }
+
                 fTan1 = (kA[1][2] - kA[2][2] * fTan0) / kA[1][1];
                 fCos1 = 1.0 / sqrt(1.0 + fTan1 * fTan1);
                 fSin1 = -fTan1 * fCos1;
+
                 for (iRow = 0; iRow < 3; iRow++) {
                     fTmp0 = kR[1][iRow];
                     fTmp1 = kR[2][iRow];
                     kR[1][iRow] = fCos1 * fTmp0 - fSin1 * fTmp1;
                     kR[2][iRow] = fSin1 * fTmp0 + fCos1 * fTmp1;
                 }
+
                 kS[0] = kA[0][0];
                 kS[1] = fCos0 * fCos1 * kA[1][1] -
                         fSin1 * (fCos0 * kA[1][2] - fSin0 * kA[2][2]);
@@ -541,21 +676,25 @@ void Matrix3::singularValueDecomposition (Matrix3& kL, Vector3& kS,
                 fTan0 = 0.5 * ( -fTmp + sqrt(fTmp * fTmp + 4.0));
                 fCos0 = 1.0 / sqrt(1.0 + fTan0 * fTan0);
                 fSin0 = fTan0 * fCos0;
+
                 for (iCol = 0; iCol < 3; iCol++) {
                     fTmp0 = kL[iCol][0];
                     fTmp1 = kL[iCol][1];
                     kL[iCol][0] = fCos0 * fTmp0 - fSin0 * fTmp1;
                     kL[iCol][1] = fSin0 * fTmp0 + fCos0 * fTmp1;
                 }
+
                 fTan1 = (kA[0][1] - kA[1][1] * fTan0) / kA[0][0];
                 fCos1 = 1.0 / sqrt(1.0 + fTan1 * fTan1);
                 fSin1 = -fTan1 * fCos1;
+
                 for (iRow = 0; iRow < 3; iRow++) {
                     fTmp0 = kR[0][iRow];
                     fTmp1 = kR[1][iRow];
                     kR[0][iRow] = fCos1 * fTmp0 - fSin1 * fTmp1;
                     kR[1][iRow] = fSin1 * fTmp0 + fCos1 * fTmp1;
                 }
+
                 kS[0] = fCos0 * fCos1 * kA[0][0] -
                         fSin1 * (fCos0 * kA[0][1] - fSin0 * kA[1][1]);
                 kS[1] = fSin0 * fSin1 * kA[0][0] +
@@ -567,34 +706,41 @@ void Matrix3::singularValueDecomposition (Matrix3& kL, Vector3& kS,
             }
         }
     }
+
     // positize diagonal
     for (iRow = 0; iRow < 3; iRow++) {
         if ( kS[iRow] < 0.0 ) {
             kS[iRow] = -kS[iRow];
+
             for (iCol = 0; iCol < 3; iCol++)
                 kR[iRow][iCol] = -kR[iRow][iCol];
         }
     }
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::singularValueComposition (const Matrix3& kL,
                                         const Vector3& kS, const Matrix3& kR) {
     int iRow, iCol;
     Matrix3 kTmp;
+
     // product S*R
     for (iRow = 0; iRow < 3; iRow++) {
         for (iCol = 0; iCol < 3; iCol++)
             kTmp[iRow][iCol] = kS[iRow] * kR[iRow][iCol];
     }
+
     // product L*S*R
     for (iRow = 0; iRow < 3; iRow++) {
         for (iCol = 0; iCol < 3; iCol++) {
             elt[iRow][iCol] = 0.0;
+
             for (int iMid = 0; iMid < 3; iMid++)
                 elt[iRow][iCol] += kL[iRow][iMid] * kTmp[iMid][iCol];
         }
     }
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::orthonormalize () {
     // Algorithm uses Gram-Schmidt orthogonalization.  If 'this' matrix is
@@ -606,46 +752,58 @@ void Matrix3::orthonormalize () {
     //
     // where |V| indicates length of vector V and A*B indicates dot
     // product of vectors A and B.
+
     // compute q0
     float fInvLength = 1.0 / sqrt(elt[0][0] * elt[0][0]
                                        + elt[1][0] * elt[1][0] +
                                        elt[2][0] * elt[2][0]);
+
     elt[0][0] *= fInvLength;
     elt[1][0] *= fInvLength;
     elt[2][0] *= fInvLength;
+
     // compute q1
     float fDot0 =
         elt[0][0] * elt[0][1] +
         elt[1][0] * elt[1][1] +
         elt[2][0] * elt[2][1];
+
     elt[0][1] -= fDot0 * elt[0][0];
     elt[1][1] -= fDot0 * elt[1][0];
     elt[2][1] -= fDot0 * elt[2][0];
+
     fInvLength = 1.0 / sqrt(elt[0][1] * elt[0][1] +
                                   elt[1][1] * elt[1][1] +
                                   elt[2][1] * elt[2][1]);
+
     elt[0][1] *= fInvLength;
     elt[1][1] *= fInvLength;
     elt[2][1] *= fInvLength;
+
     // compute q2
     float fDot1 =
         elt[0][1] * elt[0][2] +
         elt[1][1] * elt[1][2] +
         elt[2][1] * elt[2][2];
+
     fDot0 =
         elt[0][0] * elt[0][2] +
         elt[1][0] * elt[1][2] +
         elt[2][0] * elt[2][2];
+
     elt[0][2] -= fDot0 * elt[0][0] + fDot1 * elt[0][1];
     elt[1][2] -= fDot0 * elt[1][0] + fDot1 * elt[1][1];
     elt[2][2] -= fDot0 * elt[2][0] + fDot1 * elt[2][1];
+
     fInvLength = 1.0 / sqrt(elt[0][2] * elt[0][2] +
                                   elt[1][2] * elt[1][2] +
                                   elt[2][2] * elt[2][2]);
+
     elt[0][2] *= fInvLength;
     elt[1][2] *= fInvLength;
     elt[2][2] *= fInvLength;
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::qDUDecomposition (Matrix3& kQ,
                                 Vector3& kD, Vector3& kU) const {
@@ -668,11 +826,14 @@ void Matrix3::qDUDecomposition (Matrix3& kQ,
     //
     // so D = diag(r00,r11,r22) and U has entries u01 = r01/r00,
     // u02 = r02/r00, and u12 = r12/r11.
+
     // Q = rotation
     // D = scaling
     // U = shear
+
     // D stores the three diagonal entries r00, r11, r22
     // U stores the entries U[0] = u01, U[1] = u02, U[2] = u12
+
     // build orthogonal matrix Q
     float fInvLength = 1.0 / sqrt(elt[0][0] * elt[0][0]
                                        + elt[1][0] * elt[1][0] +
@@ -680,6 +841,7 @@ void Matrix3::qDUDecomposition (Matrix3& kQ,
     kQ[0][0] = elt[0][0] * fInvLength;
     kQ[1][0] = elt[1][0] * fInvLength;
     kQ[2][0] = elt[2][0] * fInvLength;
+
     float fDot = kQ[0][0] * elt[0][1] + kQ[1][0] * elt[1][1] +
                 kQ[2][0] * elt[2][1];
     kQ[0][1] = elt[0][1] - fDot * kQ[0][0];
@@ -690,6 +852,7 @@ void Matrix3::qDUDecomposition (Matrix3& kQ,
     kQ[0][1] *= fInvLength;
     kQ[1][1] *= fInvLength;
     kQ[2][1] *= fInvLength;
+
     fDot = kQ[0][0] * elt[0][2] + kQ[1][0] * elt[1][2] +
            kQ[2][0] * elt[2][2];
     kQ[0][2] = elt[0][2] - fDot * kQ[0][0];
@@ -705,96 +868,134 @@ void Matrix3::qDUDecomposition (Matrix3& kQ,
     kQ[0][2] *= fInvLength;
     kQ[1][2] *= fInvLength;
     kQ[2][2] *= fInvLength;
+
     // guarantee that orthogonal matrix has determinant 1 (no reflections)
     float fDet = kQ[0][0] * kQ[1][1] * kQ[2][2] + kQ[0][1] * kQ[1][2] * kQ[2][0] +
                 kQ[0][2] * kQ[1][0] * kQ[2][1] - kQ[0][2] * kQ[1][1] * kQ[2][0] -
                 kQ[0][1] * kQ[1][0] * kQ[2][2] - kQ[0][0] * kQ[1][2] * kQ[2][1];
+
     if ( fDet < 0.0 ) {
         for (int iRow = 0; iRow < 3; iRow++)
             for (int iCol = 0; iCol < 3; iCol++)
                 kQ[iRow][iCol] = -kQ[iRow][iCol];
     }
+
     // build "right" matrix R
     Matrix3 kR;
+
     kR[0][0] = kQ[0][0] * elt[0][0] + kQ[1][0] * elt[1][0] +
                kQ[2][0] * elt[2][0];
+
     kR[0][1] = kQ[0][0] * elt[0][1] + kQ[1][0] * elt[1][1] +
                kQ[2][0] * elt[2][1];
+
     kR[1][1] = kQ[0][1] * elt[0][1] + kQ[1][1] * elt[1][1] +
                kQ[2][1] * elt[2][1];
+
     kR[0][2] = kQ[0][0] * elt[0][2] + kQ[1][0] * elt[1][2] +
                kQ[2][0] * elt[2][2];
+
     kR[1][2] = kQ[0][1] * elt[0][2] + kQ[1][1] * elt[1][2] +
                kQ[2][1] * elt[2][2];
+
     kR[2][2] = kQ[0][2] * elt[0][2] + kQ[1][2] * elt[1][2] +
                kQ[2][2] * elt[2][2];
+
     // the scaling component
     kD[0] = kR[0][0];
+
     kD[1] = kR[1][1];
+
     kD[2] = kR[2][2];
+
     // the shear component
     float fInvD0 = 1.0 / kD[0];
+
     kU[0] = kR[0][1] * fInvD0;
+
     kU[1] = kR[0][2] * fInvD0;
+
     kU[2] = kR[1][2] / kD[1];
 }
+
 //----------------------------------------------------------------------------
 float Matrix3::maxCubicRoot (float afCoeff[3]) {
     // Spectral norm is for A^T*A, so characteristic polynomial
     // P(x) = c[0]+c[1]*x+c[2]*x^2+x^3 has three positive float roots.
     // This yields the assertions c[0] < 0 and c[2]*c[2] >= 3*c[1].
+
     // quick out for uniform scale (triple root)
     const float fOneThird = 1.0f / 3.0f;
     const float fEpsilon = 1e-06f;
     float fDiscr = afCoeff[2] * afCoeff[2] - 3.0f * afCoeff[1];
+
     if ( fDiscr <= fEpsilon )
         return -fOneThird*afCoeff[2];
+
     // Compute an upper bound on roots of P(x).  This assumes that A^T*A
     // has been scaled by its largest entry.
     float fX = 1.0f;
+
     float fPoly = afCoeff[0] + fX * (afCoeff[1] + fX * (afCoeff[2] + fX));
+
     if ( fPoly < 0.0f ) {
         // uses a matrix norm to find an upper bound on maximum root
         fX = G3D::abs(afCoeff[0]);
         float fTmp = 1.0 + G3D::abs(afCoeff[1]);
+
         if ( fTmp > fX )
             fX = fTmp;
+
         fTmp = 1.0 + G3D::abs(afCoeff[2]);
+
         if ( fTmp > fX )
             fX = fTmp;
     }
+
     // Newton's method to find root
     float fTwoC2 = 2.0f * afCoeff[2];
+
     for (int i = 0; i < 16; i++) {
         fPoly = afCoeff[0] + fX * (afCoeff[1] + fX * (afCoeff[2] + fX));
+
         if ( G3D::abs(fPoly) <= fEpsilon )
             return fX;
+
         float fDeriv = afCoeff[1] + fX * (fTwoC2 + 3.0f * fX);
+
         fX -= fPoly / fDeriv;
     }
+
     return fX;
 }
+
 //----------------------------------------------------------------------------
 float Matrix3::spectralNorm () const {
     Matrix3 kP;
     int iRow, iCol;
     float fPmax = 0.0;
+
     for (iRow = 0; iRow < 3; iRow++) {
         for (iCol = 0; iCol < 3; iCol++) {
             kP[iRow][iCol] = 0.0;
+
             for (int iMid = 0; iMid < 3; iMid++) {
                 kP[iRow][iCol] +=
                     elt[iMid][iRow] * elt[iMid][iCol];
             }
+
             if ( kP[iRow][iCol] > fPmax )
                 fPmax = kP[iRow][iCol];
         }
     }
+
     float fInvPmax = 1.0 / fPmax;
+
     for (iRow = 0; iRow < 3; iRow++) {
         for (iCol = 0; iCol < 3; iCol++)
             kP[iRow][iCol] *= fInvPmax;
     }
+
     float afCoeff[3];
     afCoeff[0] = -(kP[0][0] * (kP[1][1] * kP[2][2] - kP[1][2] * kP[2][1]) +
                    kP[0][1] * (kP[2][0] * kP[1][2] - kP[1][0] * kP[2][2]) +
@@ -803,10 +1004,12 @@ float Matrix3::spectralNorm () const {
                  kP[0][0] * kP[2][2] - kP[0][2] * kP[2][0] +
                  kP[1][1] * kP[2][2] - kP[1][2] * kP[2][1];
     afCoeff[2] = -(kP[0][0] + kP[1][1] + kP[2][2]);
+
     float fRoot = maxCubicRoot(afCoeff);
     float fNorm = sqrt(fPmax * fRoot);
     return fNorm;
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::toAxisAngle (Vector3& rkAxis, float& rfRadians) const {
     // Let (x,y,z) be the unit-length axis and let A be an angle of rotation.
@@ -830,9 +1033,11 @@ void Matrix3::toAxisAngle (Vector3& rkAxis, float& rfRadians) const {
     // P^2 = (R-I)/2.  The diagonal entries of P^2 are x^2-1, y^2-1, and
     // z^2-1.  We can solve these for axis (x,y,z).  Because the angle is pi,
     // it does not matter which sign you choose on the square roots.
+
     float fTrace = elt[0][0] + elt[1][1] + elt[2][2];
     float fCos = 0.5 * (fTrace - 1.0);
     rfRadians = G3D::aCos(fCos);  // in [0,PI]
+
     if ( rfRadians > 0.0 ) {
         if ( rfRadians < G3D_PI ) {
             rkAxis.x = elt[2][1] - elt[1][2];
@@ -842,6 +1047,7 @@ void Matrix3::toAxisAngle (Vector3& rkAxis, float& rfRadians) const {
         } else {
             // angle is PI
             float fHalfInverse;
+
             if ( elt[0][0] >= elt[1][1] ) {
                 // r00 >= r11
                 if ( elt[0][0] >= elt[2][2] ) {
@@ -886,9 +1092,11 @@ void Matrix3::toAxisAngle (Vector3& rkAxis, float& rfRadians) const {
         rkAxis.z = 0.0;
     }
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::fromAxisAngle (const Vector3& rkAxis, float fRadians) {
     Matrix3 m;
+
     float fCos = cos(fRadians);
     float fSin = sin(fRadians);
     float fOneMinusCos = 1.0 - fCos;
@@ -901,6 +1109,7 @@ Matrix3 Matrix3::fromAxisAngle (const Vector3& rkAxis, float fRadians) {
     float fXSin = rkAxis.x * fSin;
     float fYSin = rkAxis.y * fSin;
     float fZSin = rkAxis.z * fSin;
+
     m.elt[0][0] = fX2 * fOneMinusCos + fCos;
     m.elt[0][1] = fXYM - fZSin;
     m.elt[0][2] = fXZM + fYSin;
@@ -910,14 +1119,17 @@ Matrix3 Matrix3::fromAxisAngle (const Vector3& rkAxis, float fRadians) {
     m.elt[2][0] = fXZM - fYSin;
     m.elt[2][1] = fYZM + fXSin;
     m.elt[2][2] = fZ2 * fOneMinusCos + fCos;
+
     return m;
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::toEulerAnglesXYZ (float& rfXAngle, float& rfYAngle,
                                 float& rfZAngle) const {
     // rot =  cy*cz          -cy*sz           sy
     //        cz*sx*sy+cx*sz  cx*cz-sx*sy*sz -cy*sx
     //       -cx*cz*sy+sx*sz  cz*sx+cx*sy*sz  cx*cy
+
     if ( elt[0][2] < 1.0f ) {
         if ( elt[0][2] > -1.0f ) {
             rfXAngle = G3D::aTan2( -elt[1][2], elt[2][2]);
@@ -939,12 +1151,14 @@ bool Matrix3::toEulerAnglesXYZ (float& rfXAngle, float& rfYAngle,
         return false;
     }
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::toEulerAnglesXZY (float& rfXAngle, float& rfZAngle,
                                 float& rfYAngle) const {
     // rot =  cy*cz          -sz              cz*sy
     //        sx*sy+cx*cy*sz  cx*cz          -cy*sx+cx*sy*sz
     //       -cx*sy+cy*sx*sz  cz*sx           cx*cy+sx*sy*sz
+
     if ( elt[0][1] < 1.0f ) {
         if ( elt[0][1] > -1.0f ) {
             rfXAngle = G3D::aTan2(elt[2][1], elt[1][1]);
@@ -966,12 +1180,14 @@ bool Matrix3::toEulerAnglesXZY (float& rfXAngle, float& rfZAngle,
         return false;
     }
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::toEulerAnglesYXZ (float& rfYAngle, float& rfXAngle,
                                 float& rfZAngle) const {
     // rot =  cy*cz+sx*sy*sz  cz*sx*sy-cy*sz  cx*sy
     //        cx*sz           cx*cz          -sx
     //       -cz*sy+cy*sx*sz  cy*cz*sx+sy*sz  cx*cy
+
     if ( elt[1][2] < 1.0 ) {
         if ( elt[1][2] > -1.0 ) {
             rfYAngle = G3D::aTan2(elt[0][2], elt[2][2]);
@@ -993,12 +1209,14 @@ bool Matrix3::toEulerAnglesYXZ (float& rfYAngle, float& rfXAngle,
         return false;
     }
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::toEulerAnglesYZX (float& rfYAngle, float& rfZAngle,
                                 float& rfXAngle) const {
     // rot =  cy*cz           sx*sy-cx*cy*sz  cx*sy+cy*sx*sz
     //        sz              cx*cz          -cz*sx
     //       -cz*sy           cy*sx+cx*sy*sz  cx*cy-sx*sy*sz
+
     if ( elt[1][0] < 1.0 ) {
         if ( elt[1][0] > -1.0 ) {
             rfYAngle = G3D::aTan2( -elt[2][0], elt[0][0]);
@@ -1020,12 +1238,14 @@ bool Matrix3::toEulerAnglesYZX (float& rfYAngle, float& rfZAngle,
         return false;
     }
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::toEulerAnglesZXY (float& rfZAngle, float& rfXAngle,
                                 float& rfYAngle) const {
     // rot =  cy*cz-sx*sy*sz -cx*sz           cz*sy+cy*sx*sz
     //        cz*sx*sy+cy*sz  cx*cz          -cy*cz*sx+sy*sz
     //       -cx*sy           sx              cx*cy
+
     if ( elt[2][1] < 1.0 ) {
         if ( elt[2][1] > -1.0 ) {
             rfZAngle = G3D::aTan2( -elt[0][1], elt[1][1]);
@@ -1047,12 +1267,14 @@ bool Matrix3::toEulerAnglesZXY (float& rfZAngle, float& rfXAngle,
         return false;
     }
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::toEulerAnglesZYX (float& rfZAngle, float& rfYAngle,
                                 float& rfXAngle) const {
     // rot =  cy*cz           cz*sx*sy-cx*sz  cx*cz*sy+sx*sz
     //        cy*sz           cx*cz+sx*sy*sz -cz*sx+cx*sy*sz
     //       -sy              cy*sx           cx*cy
+
     if ( elt[2][0] < 1.0 ) {
         if ( elt[2][0] > -1.0 ) {
             rfZAngle = atan2f(elt[1][0], elt[0][0]);
@@ -1074,100 +1296,134 @@ bool Matrix3::toEulerAnglesZYX (float& rfZAngle, float& rfYAngle,
         return false;
     }
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::fromEulerAnglesXYZ (float fYAngle, float fPAngle,
                                   float fRAngle) {
     float fCos, fSin;
+
     fCos = cosf(fYAngle);
     fSin = sinf(fYAngle);
     Matrix3 kXMat(1.0f, 0.0f, 0.0f, 0.0f, fCos, -fSin, 0.0, fSin, fCos);
+
     fCos = cosf(fPAngle);
     fSin = sinf(fPAngle);
     Matrix3 kYMat(fCos, 0.0f, fSin, 0.0f, 1.0f, 0.0f, -fSin, 0.0f, fCos);
+
     fCos = cosf(fRAngle);
     fSin = sinf(fRAngle);
     Matrix3 kZMat(fCos, -fSin, 0.0f, fSin, fCos, 0.0f, 0.0f, 0.0f, 1.0f);
+
     return kXMat * (kYMat * kZMat);
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::fromEulerAnglesXZY (float fYAngle, float fPAngle,
                                   float fRAngle) {
+
     float fCos, fSin;
+
     fCos = cosf(fYAngle);
     fSin = sinf(fYAngle);
     Matrix3 kXMat(1.0, 0.0, 0.0, 0.0, fCos, -fSin, 0.0, fSin, fCos);
+
     fCos = cosf(fPAngle);
     fSin = sinf(fPAngle);
     Matrix3 kZMat(fCos, -fSin, 0.0, fSin, fCos, 0.0, 0.0, 0.0, 1.0);
+
     fCos = cosf(fRAngle);
     fSin = sinf(fRAngle);
     Matrix3 kYMat(fCos, 0.0, fSin, 0.0, 1.0, 0.0, -fSin, 0.0, fCos);
+
     return kXMat * (kZMat * kYMat);
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::fromEulerAnglesYXZ(
     float fYAngle,
     float fPAngle,
     float fRAngle) {
+
     float fCos, fSin;
+
     fCos = cos(fYAngle);
     fSin = sin(fYAngle);
     Matrix3 kYMat(fCos, 0.0f, fSin, 0.0f, 1.0f, 0.0f, -fSin, 0.0f, fCos);
+
     fCos = cos(fPAngle);
     fSin = sin(fPAngle);
     Matrix3 kXMat(1.0f, 0.0f, 0.0f, 0.0f, fCos, -fSin, 0.0f, fSin, fCos);
+
     fCos = cos(fRAngle);
     fSin = sin(fRAngle);
     Matrix3 kZMat(fCos, -fSin, 0.0f, fSin, fCos, 0.0f, 0.0f, 0.0f, 1.0f);
+
     return kYMat * (kXMat * kZMat);
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::fromEulerAnglesYZX(
     float fYAngle,
     float fPAngle,
     float fRAngle) {
+
     float fCos, fSin;
+
     fCos = cos(fYAngle);
     fSin = sin(fYAngle);
     Matrix3 kYMat(fCos, 0.0f, fSin, 0.0f, 1.0f, 0.0f, -fSin, 0.0f, fCos);
+
     fCos = cos(fPAngle);
     fSin = sin(fPAngle);
     Matrix3 kZMat(fCos, -fSin, 0.0f, fSin, fCos, 0.0f, 0.0f, 0.0f, 1.0f);
+
     fCos = cos(fRAngle);
     fSin = sin(fRAngle);
     Matrix3 kXMat(1.0f, 0.0f, 0.0f, 0.0f, fCos, -fSin, 0.0f, fSin, fCos);
+
     return kYMat * (kZMat * kXMat);
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::fromEulerAnglesZXY (float fYAngle, float fPAngle,
                                   float fRAngle) {
     float fCos, fSin;
+
     fCos = cos(fYAngle);
     fSin = sin(fYAngle);
     Matrix3 kZMat(fCos, -fSin, 0.0, fSin, fCos, 0.0, 0.0, 0.0, 1.0);
+
     fCos = cos(fPAngle);
     fSin = sin(fPAngle);
     Matrix3 kXMat(1.0, 0.0, 0.0, 0.0, fCos, -fSin, 0.0, fSin, fCos);
+
     fCos = cos(fRAngle);
     fSin = sin(fRAngle);
     Matrix3 kYMat(fCos, 0.0, fSin, 0.0, 1.0, 0.0, -fSin, 0.0, fCos);
+
     return kZMat * (kXMat * kYMat);
 }
+
 //----------------------------------------------------------------------------
 Matrix3 Matrix3::fromEulerAnglesZYX (float fYAngle, float fPAngle,
                                   float fRAngle) {
     float fCos, fSin;
+
     fCos = cos(fYAngle);
     fSin = sin(fYAngle);
     Matrix3 kZMat(fCos, -fSin, 0.0, fSin, fCos, 0.0, 0.0, 0.0, 1.0);
+
     fCos = cos(fPAngle);
     fSin = sin(fPAngle);
     Matrix3 kYMat(fCos, 0.0, fSin, 0.0, 1.0, 0.0, -fSin, 0.0, fCos);
+
     fCos = cos(fRAngle);
     fSin = sin(fRAngle);
     Matrix3 kXMat(1.0, 0.0, 0.0, 0.0, fCos, -fSin, 0.0, fSin, fCos);
+
     return kZMat * (kYMat * kXMat);
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::tridiagonal (float afDiag[3], float afSubDiag[3]) {
     // Householder reduction T = Q^t M Q
@@ -1177,14 +1433,17 @@ void Matrix3::tridiagonal (float afDiag[3], float afSubDiag[3]) {
     //     mat, orthogonal matrix Q
     //     diag, diagonal entries of T
     //     subd, subdiagonal entries of T (T is symmetric)
+
     float fA = elt[0][0];
     float fB = elt[0][1];
     float fC = elt[0][2];
     float fD = elt[1][1];
     float fE = elt[1][2];
     float fF = elt[2][2];
+
     afDiag[0] = fA;
     afSubDiag[2] = 0.0;
+
     if ( G3D::abs(fC) >= EPSILON ) {
         float fLength = sqrt(fB * fB + fC * fC);
         float fInvLength = 1.0 / fLength;
@@ -1220,35 +1479,49 @@ void Matrix3::tridiagonal (float afDiag[3], float afSubDiag[3]) {
         elt[2][2] = 1.0;
     }
 }
+
 //----------------------------------------------------------------------------
 bool Matrix3::qLAlgorithm (float afDiag[3], float afSubDiag[3]) {
     // QL iteration with implicit shifting to reduce matrix from tridiagonal
     // to diagonal
+
     for (int i0 = 0; i0 < 3; i0++) {
         const int iMaxIter = 32;
         int iIter;
+
         for (iIter = 0; iIter < iMaxIter; iIter++) {
             int i1;
+
             for (i1 = i0; i1 <= 1; i1++) {
                 float fSum = G3D::abs(afDiag[i1]) +
                             G3D::abs(afDiag[i1 + 1]);
+
                 if ( G3D::abs(afSubDiag[i1]) + fSum == fSum )
                     break;
             }
+
             if ( i1 == i0 )
                 break;
+
             float fTmp0 = (afDiag[i0 + 1] - afDiag[i0]) / (2.0 * afSubDiag[i0]);
+
             float fTmp1 = sqrt(fTmp0 * fTmp0 + 1.0);
+
             if ( fTmp0 < 0.0 )
                 fTmp0 = afDiag[i1] - afDiag[i0] + afSubDiag[i0] / (fTmp0 - fTmp1);
             else
                 fTmp0 = afDiag[i1] - afDiag[i0] + afSubDiag[i0] / (fTmp0 + fTmp1);
+
             float fSin = 1.0;
+
             float fCos = 1.0;
+
             float fTmp2 = 0.0;
+
             for (int i2 = i1 - 1; i2 >= i0; i2--) {
                 float fTmp3 = fSin * afSubDiag[i2];
                 float fTmp4 = fCos * afSubDiag[i2];
+
                 if (G3D::abs(fTmp3) >= G3D::abs(fTmp0)) {
                     fCos = fTmp0 / fTmp3;
                     fTmp1 = sqrt(fCos * fCos + 1.0);
@@ -1262,11 +1535,13 @@ bool Matrix3::qLAlgorithm (float afDiag[3], float afSubDiag[3]) {
                     fCos = 1.0 / fTmp1;
                     fSin *= fCos;
                 }
+
                 fTmp0 = afDiag[i2 + 1] - fTmp2;
                 fTmp1 = (afDiag[i2] - fTmp0) * fSin + 2.0 * fTmp4 * fCos;
                 fTmp2 = fSin * fTmp1;
                 afDiag[i2 + 1] = fTmp0 + fTmp2;
                 fTmp0 = fCos * fTmp1 - fTmp4;
+
                 for (int iRow = 0; iRow < 3; iRow++) {
                     fTmp3 = elt[iRow][i2 + 1];
                     elt[iRow][i2 + 1] = fSin * elt[iRow][i2] +
@@ -1275,17 +1550,21 @@ bool Matrix3::qLAlgorithm (float afDiag[3], float afSubDiag[3]) {
                                            fSin * fTmp3;
                 }
             }
+
             afDiag[i0] -= fTmp2;
             afSubDiag[i0] = fTmp0;
             afSubDiag[i1] = 0.0;
         }
+
         if ( iIter == iMaxIter ) {
             // should not get here under normal circumstances
             return false;
         }
     }
+
     return true;
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::eigenSolveSymmetric (float afEigenvalue[3],
                                    Vector3 akEigenvector[3]) const {
@@ -1293,20 +1572,25 @@ void Matrix3::eigenSolveSymmetric (float afEigenvalue[3],
     float afSubDiag[3];
     kMatrix.tridiagonal(afEigenvalue, afSubDiag);
     kMatrix.qLAlgorithm(afEigenvalue, afSubDiag);
+
     for (int i = 0; i < 3; i++) {
         akEigenvector[i][0] = kMatrix[0][i];
         akEigenvector[i][1] = kMatrix[1][i];
         akEigenvector[i][2] = kMatrix[2][i];
     }
+
     // make eigenvectors form a right--handed system
     Vector3 kCross = akEigenvector[1].cross(akEigenvector[2]);
+
     float fDet = akEigenvector[0].dot(kCross);
+
     if ( fDet < 0.0 ) {
         akEigenvector[2][0] = - akEigenvector[2][0];
         akEigenvector[2][1] = - akEigenvector[2][1];
         akEigenvector[2][2] = - akEigenvector[2][2];
     }
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::tensorProduct (const Vector3& rkU, const Vector3& rkV,
                              Matrix3& rkProduct) {
@@ -1316,7 +1600,9 @@ void Matrix3::tensorProduct (const Vector3& rkU, const Vector3& rkV,
         }
     }
 }
+
 //----------------------------------------------------------------------------
+
 // Runs in 52 cycles on AMD, 76 cycles on Intel Centrino
 //
 // The loop unrolling is necessary for performance.
@@ -1339,8 +1625,10 @@ void Matrix3::_mul(const Matrix3& A, const Matrix3& B, Matrix3& out) {
             ARowPtr[0] * B.elt[0][2] +
             ARowPtr[1] * B.elt[1][2] +
             ARowPtr[2] * B.elt[2][2];
+
     ARowPtr       = A.elt[1];
     outRowPtr     = out.elt[1];
+
         outRowPtr[0] =
             ARowPtr[0] * B.elt[0][0] +
             ARowPtr[1] * B.elt[1][0] +
@@ -1353,8 +1641,10 @@ void Matrix3::_mul(const Matrix3& A, const Matrix3& B, Matrix3& out) {
             ARowPtr[0] * B.elt[0][2] +
             ARowPtr[1] * B.elt[1][2] +
             ARowPtr[2] * B.elt[2][2];
+
     ARowPtr       = A.elt[2];
     outRowPtr     = out.elt[2];
+
         outRowPtr[0] =
             ARowPtr[0] * B.elt[0][0] +
             ARowPtr[1] * B.elt[1][0] +
@@ -1368,6 +1658,7 @@ void Matrix3::_mul(const Matrix3& A, const Matrix3& B, Matrix3& out) {
             ARowPtr[1] * B.elt[1][2] +
             ARowPtr[2] * B.elt[2][2];
 }
+
 //----------------------------------------------------------------------------
 void Matrix3::_transpose(const Matrix3& A, Matrix3& out) {
     out[0][0] = A.elt[0][0];
@@ -1380,6 +1671,7 @@ void Matrix3::_transpose(const Matrix3& A, Matrix3& out) {
     out[2][1] = A.elt[1][2];
     out[2][2] = A.elt[2][2];
 }
+
 //-----------------------------------------------------------------------------
 std::string Matrix3::toString() const {
     return G3D::format("[%g, %g, %g; %g, %g, %g; %g, %g, %g]",
@@ -1388,5 +1680,8 @@ std::string Matrix3::toString() const {
             elt[2][0], elt[2][1], elt[2][2]);
 }
 
+
+
 } // namespace
 
+
diff --git a/dep/src/g3dlite/Plane.cpp b/dep/src/g3dlite/Plane.cpp
index 86ca12c934b..10ee7ff0f0c 100644
--- a/dep/src/g3dlite/Plane.cpp
+++ b/dep/src/g3dlite/Plane.cpp
@@ -1,24 +1,32 @@
 /**
  @file Plane.cpp
+
  @maintainer Morgan McGuire, matrix@graphics3d.com
+
  @created 2003-02-06
  @edited  2006-01-29
  */
+
 #include "G3D/platform.h"
 #include "G3D/format.h"
 #include "G3D/Plane.h"
 #include "G3D/stringutils.h"
+
 namespace G3D {
+
 Plane::Plane(
     Vector4      point0,
     Vector4      point1,
     Vector4      point2) {
+
     debugAssertM(
         point0.w != 0 ||
         point1.w != 0 ||
         point2.w != 0,
         "At least one point must be finite.");
+
     // Rotate the points around so that the finite points come first.
+
     while ((point0.w == 0) &&
            ((point1.w == 0) || (point2.w != 0))) {
         Vector4 temp = point0;
@@ -26,8 +34,10 @@ Plane::Plane(
         point1 = point2;
         point2 = temp;
     }
+
     Vector3 dir1;
     Vector3 dir2;
+
     if (point1.w == 0) {
         // 1 finite, 2 infinite points; the plane must contain
         // the direction of the two direcitons
@@ -45,25 +55,31 @@ Plane::Plane(
         dir1 = point1.xyz() - point0.xyz();
         dir2 = point2.xyz();
     }
+
     _normal   = dir1.cross(dir2).direction();
     _distance = _normal.dot(point0.xyz());
 }
 
+
 Plane::Plane(
     const Vector3&      point0,
     const Vector3&      point1,
     const Vector3&      point2) {
+
     _normal   = (point1 - point0).cross(point2 - point0).direction();
     _distance = _normal.dot(point0);
 }
 
+
 Plane::Plane(
     const Vector3&      __normal,
     const Vector3&      point) {
+
     _normal   = __normal.direction();
     _distance  = _normal.dot(point);
 }
 
+
 Plane Plane::fromEquation(float a, float b, float c, float d) {
     Vector3 n(a, b, c);
     float magnitude = n.magnitude();
@@ -72,21 +88,25 @@ Plane Plane::fromEquation(float a, float b, float c, float d) {
     return Plane(n, -d);
 }
 
+
 void Plane::flip() {
     _normal   = -_normal;
     _distance  = -_distance;
 }
 
+
 void Plane::getEquation(Vector3& n, float& d) const {
     double _d;
     getEquation(n, _d);
     d = (float)_d;
 }
+
 void Plane::getEquation(Vector3& n, double& d) const {
     n = _normal;
     d = -_distance;
 }
 
+
 void Plane::getEquation(float& a, float& b, float& c, float& d) const {
     double _a, _b, _c, _d;
     getEquation(_a, _b, _c, _d);
@@ -95,6 +115,7 @@ void Plane::getEquation(float& a, float& b, float& c, float& d) const {
     c = (float)_c;
     d = (float)_d;
 }
+
 void Plane::getEquation(double& a, double& b, double& c, double& d) const {
     a = _normal.x;
     b = _normal.y;
@@ -102,8 +123,10 @@ void Plane::getEquation(double& a, double& b, double& c, double& d) const {
     d = -_distance;
 }
 
+
 std::string Plane::toString() const {
     return format("Plane(%g, %g, %g, %g)", _normal.x, _normal.y, _normal.z, _distance);
 }
+
 }
 
diff --git a/dep/src/g3dlite/System.cpp b/dep/src/g3dlite/System.cpp
index c81eaa3a919..88fd39b52ca 100644
--- a/dep/src/g3dlite/System.cpp
+++ b/dep/src/g3dlite/System.cpp
@@ -1,29 +1,40 @@
 /**
   @file System.cpp
+
   @maintainer Morgan McGuire, matrix@graphics3d.com
+
   Note: every routine must call init() first.
+
   There are two kinds of detection used in this file.  At compile
   time, the _MSC_VER #define is used to determine whether x86 assembly
   can be used at all.  At runtime, processor detection is used to
   determine if we can safely call the routines that use that assembly.
+
   @cite Rob Wyatt http://www.gamasutra.com/features/wyatts_world/19990709/processor_detection_01.htm
   @cite Benjamin Jurke http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-ProcessorDetectionClass&forum=cotd&id=-1
   @cite Michael Herf http://www.stereopsis.com/memcpy.html
+
   @created 2003-01-25
   @edited  2006-05-17
  */
+
 #include "G3D/platform.h"
 #include "G3D/System.h"
 #include "G3D/debug.h"
 #include "G3D/format.h"
+
 #if defined(__OpenBSD__)
     #include 
 #endif
+
 #ifdef G3D_WIN32
+
     #include 
     #include 
     #include "G3D/RegistryUtil.h"
+
 #elif defined(G3D_LINUX)
+
     #include 
     #include 
     #include 
@@ -35,8 +46,11 @@
     #include 
     #include 
     #include 
+
     // #include 
+
 #elif defined(G3D_OSX)
+
     #include 
     #include 
     #include 
@@ -48,24 +62,33 @@
     #include 
     #include 
     #include 
+
     #include 
     #include 
 #endif
+
 #if defined(SSE)
     #include 
 #endif
+
 namespace G3D {
+
 static char                                     versionCstr[1024];
 System::OutOfMemoryCallback                     System::outOfMemoryCallback = NULL;
 
+
 void System::init() {
     // Cannot use most G3D data structures or utility functions in here because
     // they are not initialized.
+
     static bool initialized = false;
+
     if (initialized) {
         return;
     }
+
     initialized = true;
+
     if ((G3D_VER % 100) != 0) {
         sprintf(versionCstr, "G3D %d.%02d beta %d",
             G3D_VER / 10000,
@@ -76,26 +99,36 @@ void System::init() {
             G3D_VER / 10000,
             (G3D_VER / 100) % 100);
     }
+
 }
 
+
+
 void System::memcpy(void* dst, const void* src, size_t numBytes) {
         ::memcpy(dst, src, numBytes);
 }
 
+
 void System::memset(void* dst, uint8 value, size_t numBytes) {
         ::memset(dst, value, numBytes);
 }
 
 
+
+
+
 ////////////////////////////////////////////////////////////////
 class BufferPool {
 public:
+
     /** Only store buffers up to these sizes (in bytes) in each pool->
         Different pools have different management strategies.
+
         A large block is preallocated for tiny buffers; they are used with
         tremendous frequency.  Other buffers are allocated as demanded.
       */
     enum {tinyBufferSize = 128, smallBufferSize = 1024, medBufferSize = 4096};
+
     /**
        Most buffers we're allowed to store.
        64000 * 128  = 8 MB (preallocated)
@@ -103,31 +136,40 @@ public:
         1024 * 4096 = 4 MB (allocated on demand)
      */
     enum {maxTinyBuffers = 64000, maxSmallBuffers = 1024, maxMedBuffers = 1024};
+
 private:
+
     class MemBlock {
     public:
         void*           ptr;
         size_t          bytes;
+
         inline MemBlock() : ptr(NULL), bytes(0) {}
         inline MemBlock(void* p, size_t b) : ptr(p), bytes(b) {}
     };
+
     MemBlock smallPool[maxSmallBuffers];
     int smallPoolSize;
+
     MemBlock medPool[maxMedBuffers];
     int medPoolSize;
+
     /** The tiny pool is a single block of storage into which all tiny
         objects are allocated.  This provides better locality for
         small objects and avoids the search time, since all tiny
         blocks are exactly the same size. */
     void* tinyPool[maxTinyBuffers];
     int tinyPoolSize;
+
     /** Pointer to the data in the tiny pool */
     void* tinyHeap;
+
 #   ifdef G3D_WIN32
     CRITICAL_SECTION    mutex;
 #   else
     pthread_mutex_t     mutex;
 #   endif
+
     /** Provide synchronization between threads */
     void lock() {
 #       ifdef G3D_WIN32
@@ -136,6 +178,7 @@ private:
             pthread_mutex_lock(&mutex);
 #       endif
     }
+
     void unlock() {
 #       ifdef G3D_WIN32
             LeaveCriticalSection(&mutex);
@@ -143,6 +186,7 @@ private:
             pthread_mutex_unlock(&mutex);
 #       endif
     }
+
     /**
      Malloc out of the tiny heap.
      */
@@ -151,25 +195,33 @@ private:
         // and create a constant size block.
         (void)bytes;
         debugAssert(tinyBufferSize >= bytes);
+
         void* ptr = NULL;
+
         if (tinyPoolSize > 0) {
             --tinyPoolSize;
             // Return the last one
             ptr = tinyPool[tinyPoolSize];
         }
+
         return ptr;
     }
+
     /** Returns true if this is a pointer into the tiny heap. */
     bool inTinyHeap(void* ptr) {
         return (ptr >= tinyHeap) &&
                (ptr < (uint8*)tinyHeap + maxTinyBuffers * tinyBufferSize);
     }
+
     void tinyFree(void* ptr) {
         debugAssert(tinyPoolSize < maxTinyBuffers);
+
         // Put the pointer back into the free list
         tinyPool[tinyPoolSize] = ptr;
         ++tinyPoolSize;
+
     }
+
     void flushPool(MemBlock* pool, int& poolSize) {
         for (int i = 0; i < poolSize; ++i) {
             ::free(pool->ptr);
@@ -179,32 +231,43 @@ private:
         poolSize = 0;
     }
 
+
     /**  Allocate out of a specific pool->  Return NULL if no suitable
          memory was found.
+
          */
     void* malloc(MemBlock* pool, int& poolSize, size_t bytes) {
+
         // OPT: find the smallest block that satisfies the request.
+
         // See if there's something we can use in the buffer pool->
         // Search backwards since usually we'll re-use the last one.
         for (int i = (int)poolSize - 1; i >= 0; --i) {
             if (pool[i].bytes >= bytes) {
                 // We found a suitable entry in the pool->
+
                 // No need to offset the pointer; it is already offset
                 void* ptr = pool[i].ptr;
+
                 // Remove this element from the pool
                 --poolSize;
                 pool[i] = pool[poolSize];
+
                 return ptr;
             }
         }
+
         return NULL;
     }
+
 public:
+
     /** Count of memory allocations that have occurred. */
     int totalMallocs;
     int mallocsFromTinyPool;
     int mallocsFromSmallPool;
     int mallocsFromMedPool;
+
     /** Amount of memory currently allocated (according to the application).
         This does not count the memory still remaining in the buffer pool,
         but does count extra memory required for rounding off to the size
@@ -212,17 +275,24 @@ public:
         Primarily useful for detecting leaks.*/
     // TODO: make me an atomic int!
     int bytesAllocated;
+
     BufferPool() {
         totalMallocs         = 0;
+
         mallocsFromTinyPool  = 0;
         mallocsFromSmallPool = 0;
         mallocsFromMedPool   = 0;
+
         bytesAllocated       = true;
+
         tinyPoolSize         = 0;
         tinyHeap             = NULL;
+
         smallPoolSize        = 0;
+
         medPoolSize          = 0;
 
+
         // Initialize the tiny heap as a bunch of pointers into one
         // pre-allocated buffer.
         tinyHeap = ::malloc(maxTinyBuffers * tinyBufferSize);
@@ -230,6 +300,7 @@ public:
             tinyPool[i] = (uint8*)tinyHeap + (tinyBufferSize * i);
         }
         tinyPoolSize = maxTinyBuffers;
+
 #       ifdef G3D_WIN32
             InitializeCriticalSection(&mutex);
 #       else
@@ -237,6 +308,7 @@ public:
 #       endif
     }
 
+
     ~BufferPool() {
         ::free(tinyHeap);
 #       ifdef G3D_WIN32
@@ -246,29 +318,35 @@ public:
 #       endif
     }
 
+
     void* realloc(void* ptr, size_t bytes) {
         if (ptr == NULL) {
             return malloc(bytes);
         }
+
         if (inTinyHeap(ptr)) {
             if (bytes <= tinyBufferSize) {
                 // The old pointer actually had enough space.
                 return ptr;
             } else {
                 // Free the old pointer and malloc
+
                 void* newPtr = malloc(bytes);
                 System::memcpy(newPtr, ptr, tinyBufferSize);
                 tinyFree(ptr);
                 return newPtr;
+
             }
         } else {
             // In one of our heaps.
+
             // See how big the block really was
             size_t realSize = ((uint32*)ptr)[-1];
             if (bytes <= realSize) {
                 // The old block was big enough.
                 return ptr;
             }
+
             // Need to reallocate
             void* newPtr = malloc(bytes);
             System::memcpy(newPtr, ptr, realSize);
@@ -277,43 +355,58 @@ public:
         }
     }
 
+
     void* malloc(size_t bytes) {
         lock();
         ++totalMallocs;
+
         if (bytes <= tinyBufferSize) {
+
             void* ptr = tinyMalloc(bytes);
+
             if (ptr) {
                 ++mallocsFromTinyPool;
                 unlock();
                 return ptr;
             }
+
         }
+
         // Failure to allocate a tiny buffer is allowed to flow
         // through to a small buffer
         if (bytes <= smallBufferSize) {
+
             void* ptr = malloc(smallPool, smallPoolSize, bytes);
+
             if (ptr) {
                 ++mallocsFromSmallPool;
                 unlock();
                 return ptr;
             }
+
         } else  if (bytes <= medBufferSize) {
             // Note that a small allocation failure does *not* fall
             // through into a medium allocation because that would
             // waste the medium buffer's resources.
+
             void* ptr = malloc(medPool, medPoolSize, bytes);
+
             if (ptr) {
                 ++mallocsFromMedPool;
                 unlock();
                 return ptr;
             }
         }
+
         bytesAllocated += 4 + (int) bytes;
         unlock();
+
         // Heap allocate
+
         // Allocate 4 extra bytes for our size header (unfortunate,
         // since malloc already added its own header).
         void* ptr = ::malloc(bytes + 4);
+
         if (ptr == NULL) {
             // Flush memory pools to try and recover space
             flushPool(smallPool, smallPoolSize);
@@ -321,6 +414,7 @@ public:
             ptr = ::malloc(bytes + 4);
         }
 
+
         if (ptr == NULL) {
             if ((System::outOfMemoryCallback != NULL) &&
                 (System::outOfMemoryCallback(bytes + 4, true) == true)) {
@@ -328,6 +422,7 @@ public:
                 ptr = ::malloc(bytes + 4);
             }
         }
+
         if (ptr == NULL) {
             if (System::outOfMemoryCallback != NULL) {
                 // Notify the application
@@ -335,23 +430,30 @@ public:
             }
             return NULL;
         }
+
         *(uint32*)ptr = (uint32)bytes;
+
         return (uint8*)ptr + 4;
     }
 
+
     void free(void* ptr) {
         if (ptr == NULL) {
             // Free does nothing on null pointers
             return;
         }
+
         debugAssert(isValidPointer(ptr));
+
         if (inTinyHeap(ptr)) {
             lock();
             tinyFree(ptr);
             unlock();
             return;
         }
+
         uint32 bytes = ((uint32*)ptr)[-1];
+
         lock();
         if (bytes <= smallBufferSize) {
             if (smallPoolSize < maxSmallBuffers) {
@@ -370,15 +472,19 @@ public:
         }
         bytesAllocated -= bytes + 4;
         unlock();
+
         // Free; the buffer pools are full or this is too big to store.
         ::free((uint8*)ptr - 4);
     }
+
     std::string performance() const {
         if (totalMallocs > 0) {
             int pooled = mallocsFromTinyPool +
                          mallocsFromSmallPool +
                          mallocsFromMedPool;
+
             int total = totalMallocs;
+
             return format("malloc performance: %5.1f%% <= %db, %5.1f%% <= %db, "
                           "%5.1f%% <= %db, %5.1f%% > %db",
                           100.0 * mallocsFromTinyPool  / total,
@@ -393,15 +499,18 @@ public:
             return "No System::malloc calls made yet.";
         }
     }
+
     std::string status() const {
         return format("preallocated shared buffers: %5d/%d x %db",
             maxTinyBuffers - tinyPoolSize, maxTinyBuffers, tinyBufferSize);
     }
 };
+
 // Dynamically allocated because we need to ensure that
 // the buffer pool is still around when the last global variable
 // is deallocated.
 static BufferPool* bufferpool = NULL;
+
 std::string System::mallocPerformance() {
 #ifndef NO_BUFFERPOOL
     return bufferpool->performance();
@@ -409,6 +518,7 @@ std::string System::mallocPerformance() {
     return "NO_BUFFERPOOL";
 #endif
 }
+
 std::string System::mallocStatus() {
 #ifndef NO_BUFFERPOOL
     return bufferpool->status();
@@ -417,6 +527,7 @@ std::string System::mallocStatus() {
 #endif
 }
 
+
 void System::resetMallocPerformanceCounters() {
 #ifndef NO_BUFFERPOOL
     bufferpool->totalMallocs         = 0;
@@ -426,6 +537,7 @@ void System::resetMallocPerformanceCounters() {
 #endif
 }
 
+
 #ifndef NO_BUFFERPOOL
 inline void initMem() {
     // Putting the test here ensures that the system is always
@@ -438,6 +550,7 @@ inline void initMem() {
 }
 #endif
 
+
 void* System::malloc(size_t bytes) {
 #ifndef NO_BUFFERPOOL
     initMem();
@@ -446,6 +559,7 @@ void* System::malloc(size_t bytes) {
     return ::malloc(bytes);
 #endif
 }
+
 void* System::calloc(size_t n, size_t x) {
 #ifndef NO_BUFFERPOOL
     void* b = System::malloc(n * x);
@@ -456,6 +570,7 @@ void* System::calloc(size_t n, size_t x) {
 #endif
 }
 
+
 void* System::realloc(void* block, size_t bytes) {
 #ifndef NO_BUFFERPOOL
     initMem();
@@ -465,6 +580,7 @@ void* System::realloc(void* block, size_t bytes) {
 #endif
 }
 
+
 void System::free(void* p) {
 #ifndef NO_BUFFERPOOL
     bufferpool->free(p);
@@ -473,30 +589,39 @@ void System::free(void* p) {
 #endif
 }
 
+
 void* System::alignedMalloc(size_t bytes, size_t alignment) {
     alwaysAssertM(isPow2(alignment), "alignment must be a power of 2");
+
     // We must align to at least a word boundary.
     alignment = iMax((int)alignment, sizeof(void *));
+
     // Pad the allocation size with the alignment size and the
     // size of the redirect pointer.
     size_t totalBytes = bytes + alignment + sizeof(intptr_t);
+
     void* truePtr = System::malloc(totalBytes);
+
     if (!truePtr) {
         // malloc returned NULL
         return NULL;
     }
+
     debugAssert(isValidHeapPointer(truePtr));
     #ifdef G3D_WIN32
     // The blocks we return will not be valid Win32 debug heap
     // pointers because they are offset
     //  debugAssert(_CrtIsValidPointer(truePtr, totalBytes, TRUE) );
     #endif
+
     // The return pointer will be the next aligned location (we must at least
     // leave space for the redirect pointer, however).
     char* alignedPtr = ((char*)truePtr)+ sizeof(intptr_t);
+
 #if 0
     // 2^n - 1 has the form 1111... in binary.
     uint32 bitMask = (alignment - 1);
+
     // Advance forward until we reach an aligned location.
     while ((((intptr_t)alignedPtr) & bitMask) != 0) {
         alignedPtr += sizeof(void*);
@@ -505,32 +630,42 @@ void* System::alignedMalloc(size_t bytes, size_t alignment) {
     alignedPtr += alignment - (((intptr_t)alignedPtr) & (alignment - 1));
     // assert((alignedPtr - truePtr) + bytes <= totalBytes);
 #endif
+
     debugAssert((alignedPtr - truePtr) + bytes <= totalBytes);
+
     // Immediately before the aligned location, write the true array location
     // so that we can free it correctly.
     intptr_t* redirectPtr = (intptr_t*)(alignedPtr - sizeof(intptr_t));
     redirectPtr[0] = (intptr_t)truePtr;
+
     debugAssert(isValidHeapPointer(truePtr));
+
     #ifdef G3D_WIN32
         debugAssert( _CrtIsValidPointer(alignedPtr, bytes, TRUE) );
     #endif
     return (void*)alignedPtr;
 }
 
+
 void System::alignedFree(void* _ptr) {
     if (_ptr == NULL) {
         return;
     }
+
     char* alignedPtr = (char*)_ptr;
+
     // Back up one word from the pointer the user passed in.
     // We now have a pointer to a pointer to the true start
     // of the memory block.
     intptr_t* redirectPtr = (intptr_t*)(alignedPtr - sizeof(intptr_t));
+
     // Dereference that pointer so that ptr = true start
     void* truePtr = (void*)(redirectPtr[0]);
+
     debugAssert(isValidHeapPointer(truePtr));
     System::free(truePtr);
 }
 
+
 }  // namespace
 
diff --git a/dep/src/g3dlite/Triangle.cpp b/dep/src/g3dlite/Triangle.cpp
index 06c586aa5bc..bb5b8f94635 100644
--- a/dep/src/g3dlite/Triangle.cpp
+++ b/dep/src/g3dlite/Triangle.cpp
@@ -1,85 +1,113 @@
 /**
  @file Triangle.cpp
+
  @maintainer Morgan McGuire, graphics3d.com
+
  @created 2001-04-06
  @edited  2006-01-20
+
  Copyright 2000-2006, Morgan McGuire.
  All rights reserved.
  */
+
 #include "G3D/platform.h"
 #include "G3D/Triangle.h"
 #include "G3D/Plane.h"
 #include "G3D/AABox.h"
+
 namespace G3D {
 
+
 void Triangle::init(const Vector3& v0, const Vector3& v1, const Vector3& v2) {
+
     _plane = Plane(v0, v1, v2);
     _vertex[0] = v0;
     _vertex[1] = v1;
     _vertex[2] = v2;
+
     static int next[] = {1,2,0};
+
     for (int i = 0; i < 3; ++i) {
         const Vector3 e  = _vertex[next[i]] - _vertex[i];
         edgeMagnitude[i]    = e.magnitude();
+
         if (edgeMagnitude[i] == 0) {
             edgeDirection[i] = Vector3::zero();
         } else {
             edgeDirection[i] = e / (float)edgeMagnitude[i];
         }
     }
+
     edge01 = _vertex[1] - _vertex[0];
     edge02 = _vertex[2] - _vertex[0];
+
     _primaryAxis = _plane.normal().primaryAxis();
     _area = (float)edgeDirection[0].cross(edgeDirection[2]).magnitude() * (edgeMagnitude[0] * edgeMagnitude[2]);
+
 }
 
+
 Triangle::Triangle() {
     init(Vector3::zero(), Vector3::zero(), Vector3::zero());
 }
 
+
 Triangle::Triangle(const Vector3& v0, const Vector3& v1, const Vector3& v2) {
     init(v0, v1, v2);
 }
 
+
 Triangle::~Triangle() {
 }
 
+
 double Triangle::area() const {
     return _area;
 }
 
+
 const Vector3& Triangle::normal() const {
     return _plane.normal();
 }
 
+
 const Plane& Triangle::plane() const {
     return _plane;
 }
 
+
 Vector3 Triangle::center() const {
     return (_vertex[0] + _vertex[1] + _vertex[2]) / 3.0;
 }
+
 Vector3 Triangle::randomPoint() const {
     // Choose a random point in the parallelogram
+
     float s = uniformRandom();
     float t = uniformRandom();
+
     if (t > 1.0f - s) {
         // Outside the triangle; reflect about the
         // diagonal of the parallelogram
         t = 1.0f - t;
         s = 1.0f - s;
     }
+
     return edge01 * s + edge02 * t + _vertex[0];
 }
 
+
 void Triangle::getBounds(AABox& out) const {
     Vector3 lo = _vertex[0];
     Vector3 hi = lo;
+
     for (int i = 1; i < 3; ++i) {
         lo = lo.min(_vertex[i]);
         hi = hi.max(_vertex[i]);
     }
+
     out = AABox(lo, hi);
 }
+
 } // G3D
 
diff --git a/dep/src/g3dlite/Vector3.cpp b/dep/src/g3dlite/Vector3.cpp
index 3346037e868..09c3003888b 100644
--- a/dep/src/g3dlite/Vector3.cpp
+++ b/dep/src/g3dlite/Vector3.cpp
@@ -1,11 +1,16 @@
 /**
  @file Vector3.cpp
+
  3D vector class
+
  @maintainer Morgan McGuire, matrix@graphics3d.com
+
  @cite Portions based on Dave Eberly's Magic Software Library at http://www.magic-software.com
+
  @created 2001-06-02
  @edited  2006-01-30
  */
+
 #include 
 #include 
 #include "G3D/Vector3.h"
@@ -15,8 +20,11 @@
 #include "G3D/Vector3int16.h"
 #include "G3D/Matrix3.h"
 #include "G3D/Vector2.h"
+
 namespace G3D {
+
 Vector3 Vector3::dummy;
+
 // Deprecated.
 const Vector3 Vector3::ZERO(0, 0, 0);
 const Vector3 Vector3::ZERO3(0, 0, 0);
@@ -25,13 +33,18 @@ const Vector3 Vector3::UNIT_Y(0, 1, 0);
 const Vector3 Vector3::UNIT_Z(0, 0, 1);
 const Vector3 Vector3::INF3((float)G3D::inf(), (float)G3D::inf(), (float)G3D::inf());
 const Vector3 Vector3::NAN3((float)G3D::nan(), (float)G3D::nan(), (float)G3D::nan());
+
 Vector3::Vector3(const class Vector2& v, float _z) : x(v.x), y(v.y), z(_z) {
 }
+
 Vector3::Axis Vector3::primaryAxis() const {
+
     Axis a = X_AXIS;
+
     double nx = abs(x);
     double ny = abs(y);
     double nz = abs(z);
+
     if (nx > ny) {
         if (nx > nz) {
             a = X_AXIS;
@@ -45,43 +58,56 @@ Vector3::Axis Vector3::primaryAxis() const {
             a = Z_AXIS;
         }
     }
+
     return a;
 }
 
+
 unsigned int Vector3::hashCode() const {
     unsigned int xhash = (*(int*)(void*)(&x));
     unsigned int yhash = (*(int*)(void*)(&y));
     unsigned int zhash = (*(int*)(void*)(&z));
+
     return xhash + (yhash * 37) + (zhash * 101);
 }
+
 std::ostream& operator<<(std::ostream& os, const Vector3& v) {
     return os << v.toString();
 }
 
+
 //----------------------------------------------------------------------------
+
 double frand() {
     return rand() / (double) RAND_MAX;
 }
 
+
 Vector3::Vector3(const class Vector3int16& v) {
     x = v.x;
     y = v.y;
     z = v.z;
 }
 
+
 Vector3 Vector3::random() {
     Vector3 result;
+
     do {
         result = Vector3(uniformRandom(-1.0, 1.0),
                          uniformRandom(-1.0, 1.0),
                          uniformRandom(-1.0, 1.0));
     } while (result.squaredMagnitude() >= 1.0f);
+
     result.unitize();
+
     return result;
 }
+
 //----------------------------------------------------------------------------
 Vector3 Vector3::operator/ (float fScalar) const {
     Vector3 kQuot;
+
     if ( fScalar != 0.0 ) {
         float fInvScalar = 1.0f / fScalar;
         kQuot.x = fInvScalar * x;
@@ -92,6 +118,7 @@ Vector3 Vector3::operator/ (float fScalar) const {
         return Vector3::inf();
     }
 }
+
 //----------------------------------------------------------------------------
 Vector3& Vector3::operator/= (float fScalar) {
     if (fScalar != 0.0) {
@@ -104,11 +131,14 @@ Vector3& Vector3::operator/= (float fScalar) {
         y = (float)G3D::inf();
         z = (float)G3D::inf();
     }
+
     return *this;
 }
+
 //----------------------------------------------------------------------------
 float Vector3::unitize (float fTolerance) {
     float fMagnitude = magnitude();
+
     if (fMagnitude > fTolerance) {
         float fInvMagnitude = 1.0f / fMagnitude;
         x *= fInvMagnitude;
@@ -117,38 +147,53 @@ float Vector3::unitize (float fTolerance) {
     } else {
         fMagnitude = 0.0f;
     }
+
     return fMagnitude;
 }
+
 //----------------------------------------------------------------------------
+
 Vector3 Vector3::reflectAbout(const Vector3& normal) const {
+
     Vector3 out;
+
     Vector3 N = normal.direction();
+
     // 2 * normal.dot(this) * normal - this
     return N * 2 * this->dot(N) - *this;
 }
+
 //----------------------------------------------------------------------------
 #if 0
 Vector3 Vector3::cosRandom(const Vector3& normal) {
     double e1 = G3D::random(0, 1);
     double e2 = G3D::random(0, 1);
+
     // Angle from normal
     double theta = acos(sqrt(e1));
+
     // Angle about normal
     double phi   = 2 * G3D_PI * e2;
+
     // Make a coordinate system
     Vector3 U = normal.direction();
     Vector3 V = Vector3::unitX();
+
     if (abs(U.dot(V)) > .9) {
         V = Vector3::unitY();
     }
+
     Vector3 W = U.cross(V).direction();
     V = W.cross(U);
+
     // Convert to rectangular form
     return cos(theta) * U + sin(theta) * (cos(phi) * V + sin(phi) * W);
 }
 //----------------------------------------------------------------------------
+
 Vector3 Vector3::hemiRandom(const Vector3& normal) {
     Vector3 V = Vector3::random();
+
     if (V.dot(normal) < 0) {
         return -V;
     } else {
@@ -157,30 +202,40 @@ Vector3 Vector3::hemiRandom(const Vector3& normal) {
 }
 #endif
 //----------------------------------------------------------------------------
+
 Vector3 Vector3::reflectionDirection(const Vector3& normal) const {
     return -reflectAbout(normal).direction();
 }
+
 //----------------------------------------------------------------------------
+
 Vector3 Vector3::refractionDirection(
     const Vector3&  normal,
     float           iInside,
     float           iOutside) const {
+
     // From pg. 24 of Henrik Wann Jensen. Realistic Image Synthesis
     // Using Photon Mapping.  AK Peters. ISBN: 1568811470. July 2001.
+
     // Invert the directions from Wann Jensen's formulation
     // and normalize the vectors.
     const Vector3 W = -direction();
     Vector3 N = normal.direction();
+
     float h1 = iOutside;
     float h2 = iInside;
+
     if (normal.dot(*this) > 0.0f) {
         h1 = iInside;
         h2 = iOutside;
         N  = -N;
     }
+
     const float hRatio = h1 / h2;
     const float WdotN = W.dot(N);
+
     float det = 1.0f - (float)square(hRatio) * (1.0f - (float)square(WdotN));
+
     if (det < 0) {
         // Total internal reflection
         return Vector3::zero();
@@ -188,6 +243,7 @@ Vector3 Vector3::refractionDirection(
         return -hRatio * (W - WdotN * N) - N * sqrt(det);
     }
 }
+
 //----------------------------------------------------------------------------
 void Vector3::orthonormalize (Vector3 akVector[3]) {
     // If the input vectors are v0, v1, and v2, then the Gram-Schmidt
@@ -199,23 +255,28 @@ void Vector3::orthonormalize (Vector3 akVector[3]) {
     //
     // where |A| indicates length of vector A and A*B indicates dot
     // product of vectors A and B.
+
     // compute u0
     akVector[0].unitize();
+
     // compute u1
     float fDot0 = akVector[0].dot(akVector[1]);
     akVector[1] -= akVector[0] * fDot0;
     akVector[1].unitize();
+
     // compute u2
     float fDot1 = akVector[1].dot(akVector[2]);
     fDot0 = akVector[0].dot(akVector[2]);
     akVector[2] -= akVector[0] * fDot0 + akVector[1] * fDot1;
     akVector[2].unitize();
 }
+
 //----------------------------------------------------------------------------
 void Vector3::generateOrthonormalBasis (Vector3& rkU, Vector3& rkV,
                                         Vector3& rkW, bool bUnitLengthW) {
     if ( !bUnitLengthW )
         rkW.unitize();
+
     if ( G3D::abs(rkW.x) >= G3D::abs(rkW.y)
             && G3D::abs(rkW.x) >= G3D::abs(rkW.z) ) {
         rkU.x = -rkW.y;
@@ -226,23 +287,30 @@ void Vector3::generateOrthonormalBasis (Vector3& rkU, Vector3& rkV,
         rkU.y = + rkW.z;
         rkU.z = -rkW.y;
     }
+
     rkU.unitize();
     rkV = rkW.cross(rkU);
 }
+
 //----------------------------------------------------------------------------
+
 std::string Vector3::toString() const {
     return G3D::format("(%g, %g, %g)", x, y, z);
 }
 
+
 //----------------------------------------------------------------------------
+
 Matrix3 Vector3::cross() const {
     return Matrix3( 0, -z,  y,
                     z,  0, -x,
                    -y,  x,  0);
 }
 
+
 //----------------------------------------------------------------------------
 // 2-char swizzles
+
 Vector2 Vector3::xx() const  { return Vector2       (x, x); }
 Vector2 Vector3::yx() const  { return Vector2       (y, x); }
 Vector2 Vector3::zx() const  { return Vector2       (z, x); }
@@ -252,7 +320,9 @@ Vector2 Vector3::zy() const  { return Vector2       (z, y); }
 Vector2 Vector3::xz() const  { return Vector2       (x, z); }
 Vector2 Vector3::yz() const  { return Vector2       (y, z); }
 Vector2 Vector3::zz() const  { return Vector2       (z, z); }
+
 // 3-char swizzles
+
 Vector3 Vector3::xxx() const  { return Vector3       (x, x, x); }
 Vector3 Vector3::yxx() const  { return Vector3       (y, x, x); }
 Vector3 Vector3::zxx() const  { return Vector3       (z, x, x); }
@@ -280,7 +350,9 @@ Vector3 Vector3::zyz() const  { return Vector3       (z, y, z); }
 Vector3 Vector3::xzz() const  { return Vector3       (x, z, z); }
 Vector3 Vector3::yzz() const  { return Vector3       (y, z, z); }
 Vector3 Vector3::zzz() const  { return Vector3       (z, z, z); }
+
 // 4-char swizzles
+
 Vector4 Vector3::xxxx() const  { return Vector4       (x, x, x, x); }
 Vector4 Vector3::yxxx() const  { return Vector4       (y, x, x, x); }
 Vector4 Vector3::zxxx() const  { return Vector4       (z, x, x, x); }
@@ -365,5 +437,8 @@ Vector4 Vector3::zzzz() const  { return Vector4       (z, z, z, z); }
 
 
 
+
+
+
 } // namespace
 
diff --git a/dep/src/g3dlite/Vector4.cpp b/dep/src/g3dlite/Vector4.cpp
index fbab13ea0ae..91f916d1040 100644
--- a/dep/src/g3dlite/Vector4.cpp
+++ b/dep/src/g3dlite/Vector4.cpp
@@ -1,9 +1,12 @@
 /**
  @file Vector4.cpp
+
  @maintainer Morgan McGuire, matrix@graphics3d.com
+
  @created 2001-07-09
  @edited  2003-09-29
  */
+
 #include 
 #include 
 #include "G3D/Vector4.h"
@@ -11,14 +14,18 @@
 #include "G3D/g3dmath.h"
 #include "G3D/format.h"
 #include "G3D/stringutils.h"
+
 namespace G3D {
+
 unsigned int Vector4::hashCode() const {
     unsigned int xhash = (*(int*)(void*)(&x));
     unsigned int yhash = (*(int*)(void*)(&y));
     unsigned int zhash = (*(int*)(void*)(&z));
     unsigned int whash = (*(int*)(void*)(&w));
+
     return xhash + (yhash * 37) + (zhash * 101) + (whash * 241);
 }
+
 #if 0
 Vector4::Vector4(const class Color4& c) {
     x = c.r;
@@ -28,6 +35,7 @@ Vector4::Vector4(const class Color4& c) {
 }
 #endif
 
+
 Vector4::Vector4(const Vector2& v1, const Vector2& v2) {
     x = v1.x;
     y = v1.y;
@@ -35,15 +43,19 @@ Vector4::Vector4(const Vector2& v1, const Vector2& v2) {
     w = v2.y;
 }
 
+
 Vector4::Vector4(const Vector2& v1, float fz, float fw) {
     x = v1.x;
     y = v1.y;
     z = fz;
     w = fw;
 }
+
 //----------------------------------------------------------------------------
+
 Vector4 Vector4::operator/ (float fScalar) const {
     Vector4 kQuot;
+
     if ( fScalar != 0.0 ) {
         float fInvScalar = 1.0f / fScalar;
         kQuot.x = fInvScalar * x;
@@ -55,6 +67,7 @@ Vector4 Vector4::operator/ (float fScalar) const {
         return Vector4::inf();
     }
 }
+
 //----------------------------------------------------------------------------
 Vector4& Vector4::operator/= (float fScalar) {
     if (fScalar != 0.0f) {
@@ -66,14 +79,18 @@ Vector4& Vector4::operator/= (float fScalar) {
     } else {
         *this = Vector4::inf();
     }
+
     return *this;
 }
 
+
 //----------------------------------------------------------------------------
+
 std::string Vector4::toString() const {
     return G3D::format("(%g, %g, %g, %g)", x, y, z, w);
 }
 // 2-char swizzles
+
 Vector2 Vector4::xx() const  { return Vector2       (x, x); }
 Vector2 Vector4::yx() const  { return Vector2       (y, x); }
 Vector2 Vector4::zx() const  { return Vector2       (z, x); }
@@ -90,7 +107,9 @@ Vector2 Vector4::xw() const  { return Vector2       (x, w); }
 Vector2 Vector4::yw() const  { return Vector2       (y, w); }
 Vector2 Vector4::zw() const  { return Vector2       (z, w); }
 Vector2 Vector4::ww() const  { return Vector2       (w, w); }
+
 // 3-char swizzles
+
 Vector3 Vector4::xxx() const  { return Vector3       (x, x, x); }
 Vector3 Vector4::yxx() const  { return Vector3       (y, x, x); }
 Vector3 Vector4::zxx() const  { return Vector3       (z, x, x); }
@@ -155,7 +174,9 @@ Vector3 Vector4::xww() const  { return Vector3       (x, w, w); }
 Vector3 Vector4::yww() const  { return Vector3       (y, w, w); }
 Vector3 Vector4::zww() const  { return Vector3       (z, w, w); }
 Vector3 Vector4::www() const  { return Vector3       (w, w, w); }
+
 // 4-char swizzles
+
 Vector4 Vector4::xxxx() const  { return Vector4       (x, x, x, x); }
 Vector4 Vector4::yxxx() const  { return Vector4       (y, x, x, x); }
 Vector4 Vector4::zxxx() const  { return Vector4       (z, x, x, x); }
@@ -413,5 +434,6 @@ Vector4 Vector4::ywww() const  { return Vector4       (y, w, w, w); }
 Vector4 Vector4::zwww() const  { return Vector4       (z, w, w, w); }
 Vector4 Vector4::wwww() const  { return Vector4       (w, w, w, w); }
 
+
 }; // namespace
 
diff --git a/dep/src/g3dlite/format.cpp b/dep/src/g3dlite/format.cpp
index 276bf4dcee1..13f01e26e6b 100644
--- a/dep/src/g3dlite/format.cpp
+++ b/dep/src/g3dlite/format.cpp
@@ -1,12 +1,16 @@
 /**
  @file format.cpp
+
  @author Morgan McGuire, graphics3d.com
+
  @created 2000-09-09
  @edited  2006-04-30
 */
+
 #include "G3D/format.h"
 #include "G3D/platform.h"
 #include "G3D/System.h"
+
 #ifdef G3D_WIN32
     #include 
     #define vsnprintf _vsnprintf
@@ -15,21 +19,27 @@
     #include 
     #define NEWLINE "\n"
 #endif
+
 #ifdef _MSC_VER
     // disable: "C++ exception handler used"
 #   pragma warning (push)
 #   pragma warning (disable : 4530)
 #endif // _MSC_VER
+
 // If your platform does not have vsnprintf, you can find a
 // implementation at http://www.ijs.si/software/snprintf/
+
 namespace G3D {
+
 std::string format(const char* fmt,...) {
     va_list argList;
     va_start(argList,fmt);
     std::string result = vformat(fmt, argList);
     va_end(argList);
+
     return result;
 }
+
 #if defined(G3D_WIN32) && (_MSC_VER >= 1300)
 // Both MSVC6 and 7 seem to use the non-standard vsnprintf
 // so we are using vscprintf to determine buffer size, however
@@ -37,16 +47,22 @@ std::string format(const char* fmt,...) {
 std::string vformat(const char *fmt, va_list argPtr) {
     // We draw the line at a 1MB string.
     const int maxSize = 1000000;
+
     // If the string is less than 161 characters,
     // allocate it on the stack because this saves
     // the malloc/free time.
     const int bufSize = 161;
     char stackBuffer[bufSize];
+
     int actualSize = _vscprintf(fmt, argPtr) + 1;
+
     if (actualSize > bufSize) {
+
         // Now use the heap.
         char* heapBuffer = NULL;
+
         if (actualSize < maxSize) {
+
             heapBuffer = (char*)System::malloc(maxSize + 1);
             vsnprintf(heapBuffer, maxSize, fmt, argPtr);
             heapBuffer[maxSize] = '\0';
@@ -54,43 +70,59 @@ std::string vformat(const char *fmt, va_list argPtr) {
             heapBuffer = (char*)System::malloc(actualSize);
             vsprintf(heapBuffer, fmt, argPtr);
         }
+
         std::string formattedString(heapBuffer);
         System::free(heapBuffer);
         return formattedString;
     } else {
+
         vsprintf(stackBuffer, fmt, argPtr);
         return std::string(stackBuffer);
     }
 }
+
 #elif defined(G3D_WIN32) && (_MSC_VER < 1300)
+
 std::string vformat(const char *fmt, va_list argPtr) {
     // We draw the line at a 1MB string.
     const int maxSize = 1000000;
+
     // If the string is less than 161 characters,
     // allocate it on the stack because this saves
     // the malloc/free time.
     const int bufSize = 161;
     char stackBuffer[bufSize];
+
     int actualWritten = vsnprintf(stackBuffer, bufSize, fmt, argPtr);
+
     // Not a big enough buffer, bufSize characters written
     if (actualWritten == -1) {
+
         int heapSize = 512;
         double powSize = 1.0;
         char* heapBuffer = (char*)System::malloc(heapSize);
+
         while ((vsnprintf(heapBuffer, heapSize, fmt, argPtr) == -1) &&
             (heapSize  < maxSize)) {
+
             heapSize = iCeil(heapSize * ::pow((double)2.0, powSize++));
             heapBuffer = (char*)System::realloc(heapBuffer, heapSize);
         }
+
         heapBuffer[heapSize-1] = '\0';
+
         std::string heapString(heapBuffer);
         System::free(heapBuffer);
+
         return heapString;
     } else {
+
         return std::string(stackBuffer);
     }
 }
+
 #else
+
 // glibc 2.1 has been updated to the C99 standard
 std::string vformat(const char* fmt, va_list argPtr) {
     // If the string is less than 161 characters,
@@ -100,27 +132,41 @@ std::string vformat(const char* fmt, va_list argPtr) {
     // console (plus the null terminator).
     const int bufSize = 161;
     char stackBuffer[bufSize];
+
     int numChars = vsnprintf(stackBuffer, bufSize, fmt, argPtr);
+
     if (numChars >= bufSize) {
       // We didn't allocate a big enough string.
       char* heapBuffer = (char*)System::malloc((numChars + 1) * sizeof(char));
+
       assert(heapBuffer);
       int numChars2 = vsnprintf(heapBuffer, numChars + 1, fmt, argPtr);
       assert(numChars2 == numChars);
+
       std::string result(heapBuffer);
+
       System::free(heapBuffer);
+
       return result;
+
     } else {
+
       return std::string(stackBuffer);
+
     }
 }
+
 #endif
+
 } // namespace
+
 #ifdef G3D_WIN32
 #   undef vsnprintf
 #endif
+
 #ifdef _MSC_VER
 #   pragma warning (pop)
 #endif
+
 #undef NEWLINE
 
diff --git a/dep/src/sockets/Base64.cpp b/dep/src/sockets/Base64.cpp
index a6a6992798c..cb66b93af6f 100644
--- a/dep/src/sockets/Base64.cpp
+++ b/dep/src/sockets/Base64.cpp
@@ -4,34 +4,42 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 "Base64.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 const char *Base64::bstr =
     "ABCDEFGHIJKLMNOPQ"
     "RSTUVWXYZabcdefgh"
     "ijklmnopqrstuvwxy"
     "z0123456789+/";
+
 const char Base64::rstr[] = {
       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
@@ -42,16 +50,19 @@ const char Base64::rstr[] = {
       0,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,
      41,  42,  43,  44,  45,  46,  47,  48,  49,  50,  51,   0,   0,   0,   0,   0};
 
+
 Base64::Base64()
 {
 }
 
+
 void Base64::encode(FILE *fil, std::string& output, bool add_crlf)
 {
     size_t remain;
     size_t i = 0;
     size_t o = 0;
     char input[4];
+
     output = "";
     remain = fread(input,1,3,fil);
     while (remain > 0)
@@ -83,15 +94,18 @@ void Base64::encode(FILE *fil, std::string& output, bool add_crlf)
     }
 }
 
+
 void Base64::encode(const std::string& str_in, std::string& str_out, bool add_crlf)
 {
     encode(str_in.c_str(), str_in.size(), str_out, add_crlf);
 }
 
+
 void Base64::encode(const char* input,size_t l,std::string& output, bool add_crlf)
 {
     size_t i = 0;
     size_t o = 0;
+
     output = "";
     while (i < l)
     {
@@ -122,10 +136,12 @@ void Base64::encode(const char* input,size_t l,std::string& output, bool add_crl
     }
 }
 
+
 void Base64::encode(const unsigned char* input,size_t l,std::string& output,bool add_crlf)
 {
     size_t i = 0;
     size_t o = 0;
+
     output = "";
     while (i < l)
     {
@@ -156,10 +172,12 @@ void Base64::encode(const unsigned char* input,size_t l,std::string& output,bool
     }
 }
 
+
 void Base64::decode(const std::string& input,std::string& output)
 {
     size_t i = 0;
     size_t l = input.size();
+
     output = "";
     while (i < l)
     {
@@ -187,11 +205,13 @@ void Base64::decode(const std::string& input,std::string& output)
     }
 }
 
+
 void Base64::decode(const std::string& input, unsigned char *output, size_t& sz)
 {
     size_t i = 0;
     size_t l = input.size();
     size_t j = 0;
+
     while (i < l)
     {
         while (i < l && (input[i] == 13 || input[i] == 10))
@@ -231,6 +251,7 @@ void Base64::decode(const std::string& input, unsigned char *output, size_t& sz)
     sz = j;
 }
 
+
 size_t Base64::decode_length(const std::string& str64)
 {
     if (str64.empty() || str64.size() % 4)
@@ -243,8 +264,10 @@ size_t Base64::decode_length(const std::string& str64)
     return l;
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
 
+
diff --git a/dep/src/sockets/Exception.cpp b/dep/src/sockets/Exception.cpp
index 9c8a7fe3b58..33a7b4a133c 100644
--- a/dep/src/sockets/Exception.cpp
+++ b/dep/src/sockets/Exception.cpp
@@ -5,14 +5,17 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -21,20 +24,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #pragma warning(disable:4786)
 #endif
 #include "Exception.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
+
 Exception::Exception(const std::string& description) : m_description(description)
 {
 }
 
+
 const std::string Exception::ToString() const
 {
     return m_description;
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
 
+
diff --git a/dep/src/sockets/Ipv4Address.cpp b/dep/src/sockets/Ipv4Address.cpp
index edd56ece048..b89cc2a449b 100644
--- a/dep/src/sockets/Ipv4Address.cpp
+++ b/dep/src/sockets/Ipv4Address.cpp
@@ -5,14 +5,17 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -24,10 +27,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include 
 #endif
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
+
 Ipv4Address::Ipv4Address(port_t port) : m_valid(true)
 {
     memset(&m_addr, 0, sizeof(m_addr));
@@ -35,6 +41,7 @@ Ipv4Address::Ipv4Address(port_t port) : m_valid(true)
     m_addr.sin_port = htons( port );
 }
 
+
 Ipv4Address::Ipv4Address(ipaddr_t a,port_t port) : m_valid(true)
 {
     memset(&m_addr, 0, sizeof(m_addr));
@@ -43,6 +50,7 @@ Ipv4Address::Ipv4Address(ipaddr_t a,port_t port) : m_valid(true)
     memcpy(&m_addr.sin_addr, &a, sizeof(struct in_addr));
 }
 
+
 Ipv4Address::Ipv4Address(struct in_addr& a,port_t port) : m_valid(true)
 {
     memset(&m_addr, 0, sizeof(m_addr));
@@ -51,6 +59,7 @@ Ipv4Address::Ipv4Address(struct in_addr& a,port_t port) : m_valid(true)
     m_addr.sin_addr = a;
 }
 
+
 Ipv4Address::Ipv4Address(const std::string& host,port_t port) : m_valid(false)
 {
     memset(&m_addr, 0, sizeof(m_addr));
@@ -66,36 +75,43 @@ Ipv4Address::Ipv4Address(const std::string& host,port_t port) : m_valid(false)
     }
 }
 
+
 Ipv4Address::Ipv4Address(struct sockaddr_in& sa)
 {
     m_addr = sa;
     m_valid = sa.sin_family == AF_INET;
 }
 
+
 Ipv4Address::~Ipv4Address()
 {
 }
 
+
 Ipv4Address::operator struct sockaddr *()
 {
     return (struct sockaddr *)&m_addr;
 }
 
+
 Ipv4Address::operator socklen_t()
 {
     return sizeof(struct sockaddr_in);
 }
 
+
 void Ipv4Address::SetPort(port_t port)
 {
     m_addr.sin_port = htons( port );
 }
 
+
 port_t Ipv4Address::GetPort()
 {
     return ntohs( m_addr.sin_port );
 }
 
+
 bool Ipv4Address::Resolve(const std::string& hostname,struct in_addr& a)
 {
     struct sockaddr_in sa;
@@ -113,6 +129,7 @@ bool Ipv4Address::Resolve(const std::string& hostname,struct in_addr& a)
     return true;
 }
 
+
 bool Ipv4Address::Reverse(struct in_addr& a,std::string& name)
 {
     struct sockaddr_in sa;
@@ -122,6 +139,7 @@ bool Ipv4Address::Reverse(struct in_addr& a,std::string& name)
     return Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name);
 }
 
+
 std::string Ipv4Address::Convert(bool include_port)
 {
     if (include_port)
@@ -129,6 +147,7 @@ std::string Ipv4Address::Convert(bool include_port)
     return Convert(m_addr.sin_addr);
 }
 
+
 std::string Ipv4Address::Convert(struct in_addr& a)
 {
     struct sockaddr_in sa;
@@ -140,21 +159,25 @@ std::string Ipv4Address::Convert(struct in_addr& a)
     return name;
 }
 
+
 void Ipv4Address::SetAddress(struct sockaddr *sa)
 {
     memcpy(&m_addr, sa, sizeof(struct sockaddr_in));
 }
 
+
 int Ipv4Address::GetFamily()
 {
     return m_addr.sin_family;
 }
 
+
 bool Ipv4Address::IsValid()
 {
     return m_valid;
 }
 
+
 bool Ipv4Address::operator==(SocketAddress& a)
 {
     if (a.GetFamily() != GetFamily())
@@ -170,11 +193,13 @@ bool Ipv4Address::operator==(SocketAddress& a)
     return true;
 }
 
+
 std::auto_ptr Ipv4Address::GetCopy()
 {
     return std::auto_ptr(new Ipv4Address(m_addr));
 }
 
+
 std::string Ipv4Address::Reverse()
 {
     std::string tmp;
@@ -182,7 +207,9 @@ std::string Ipv4Address::Reverse()
     return tmp;
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
 
+
diff --git a/dep/src/sockets/Ipv6Address.cpp b/dep/src/sockets/Ipv6Address.cpp
index 3e6d4b09805..6c92de24871 100644
--- a/dep/src/sockets/Ipv6Address.cpp
+++ b/dep/src/sockets/Ipv6Address.cpp
@@ -5,30 +5,36 @@
 **/
 /*
 Copyright (C) 2007  Anders Hedstrom
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 "Ipv6Address.h"
 #ifdef ENABLE_IPV6
+
 #include "Utility.h"
 #include "Parse.h"
 #ifndef _WIN32
 #include 
 #endif
 #ifdef IPPROTO_IPV6
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 Ipv6Address::Ipv6Address(port_t port) : m_valid(true)
 {
     memset(&m_addr, 0, sizeof(m_addr));
@@ -36,6 +42,7 @@ Ipv6Address::Ipv6Address(port_t port) : m_valid(true)
     m_addr.sin6_port = htons( port );
 }
 
+
 Ipv6Address::Ipv6Address(struct in6_addr& a,port_t port) : m_valid(true)
 {
     memset(&m_addr, 0, sizeof(m_addr));
@@ -44,6 +51,7 @@ Ipv6Address::Ipv6Address(struct in6_addr& a,port_t port) : m_valid(true)
     m_addr.sin6_addr = a;
 }
 
+
 Ipv6Address::Ipv6Address(const std::string& host,port_t port) : m_valid(false)
 {
     memset(&m_addr, 0, sizeof(m_addr));
@@ -59,36 +67,43 @@ Ipv6Address::Ipv6Address(const std::string& host,port_t port) : m_valid(false)
     }
 }
 
+
 Ipv6Address::Ipv6Address(struct sockaddr_in6& sa)
 {
     m_addr = sa;
     m_valid = sa.sin6_family == AF_INET6;
 }
 
+
 Ipv6Address::~Ipv6Address()
 {
 }
 
+
 Ipv6Address::operator struct sockaddr *()
 {
     return (struct sockaddr *)&m_addr;
 }
 
+
 Ipv6Address::operator socklen_t()
 {
     return sizeof(struct sockaddr_in6);
 }
 
+
 void Ipv6Address::SetPort(port_t port)
 {
     m_addr.sin6_port = htons( port );
 }
 
+
 port_t Ipv6Address::GetPort()
 {
     return ntohs( m_addr.sin6_port );
 }
 
+
 bool Ipv6Address::Resolve(const std::string& hostname,struct in6_addr& a)
 {
     struct sockaddr_in6 sa;
@@ -106,6 +121,7 @@ bool Ipv6Address::Resolve(const std::string& hostname,struct in6_addr& a)
     return true;
 }
 
+
 bool Ipv6Address::Reverse(struct in6_addr& a,std::string& name)
 {
     struct sockaddr_in6 sa;
@@ -115,6 +131,7 @@ bool Ipv6Address::Reverse(struct in6_addr& a,std::string& name)
     return Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name);
 }
 
+
 std::string Ipv6Address::Convert(bool include_port)
 {
     if (include_port)
@@ -122,6 +139,7 @@ std::string Ipv6Address::Convert(bool include_port)
     return Convert(m_addr.sin6_addr);
 }
 
+
 std::string Ipv6Address::Convert(struct in6_addr& a,bool mixed)
 {
     char slask[100]; // l2ip temporary
@@ -169,43 +187,51 @@ std::string Ipv6Address::Convert(struct in6_addr& a,bool mixed)
     return slask;
 }
 
+
 void Ipv6Address::SetAddress(struct sockaddr *sa)
 {
     memcpy(&m_addr, sa, sizeof(struct sockaddr_in6));
 }
 
+
 int Ipv6Address::GetFamily()
 {
     return m_addr.sin6_family;
 }
 
+
 void Ipv6Address::SetFlowinfo(uint32_t x)
 {
     m_addr.sin6_flowinfo = x;
 }
 
+
 uint32_t Ipv6Address::GetFlowinfo()
 {
     return m_addr.sin6_flowinfo;
 }
 
+
 #ifndef _WIN32
 void Ipv6Address::SetScopeId(uint32_t x)
 {
     m_addr.sin6_scope_id = x;
 }
 
+
 uint32_t Ipv6Address::GetScopeId()
 {
     return m_addr.sin6_scope_id;
 }
 #endif
 
+
 bool Ipv6Address::IsValid()
 {
     return m_valid;
 }
 
+
 bool Ipv6Address::operator==(SocketAddress& a)
 {
     if (a.GetFamily() != GetFamily())
@@ -221,11 +247,13 @@ bool Ipv6Address::operator==(SocketAddress& a)
     return true;
 }
 
+
 std::auto_ptr Ipv6Address::GetCopy()
 {
     return std::auto_ptr(new Ipv6Address(m_addr));
 }
 
+
 std::string Ipv6Address::Reverse()
 {
     std::string tmp;
@@ -233,9 +261,11 @@ std::string Ipv6Address::Reverse()
     return tmp;
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
 #endif // IPPROTO_IPV6
 #endif // ENABLE_IPV6
 
+
diff --git a/dep/src/sockets/Lock.cpp b/dep/src/sockets/Lock.cpp
index 1abda3bebeb..597ca30afc6 100644
--- a/dep/src/sockets/Lock.cpp
+++ b/dep/src/sockets/Lock.cpp
@@ -4,42 +4,53 @@
 **/
 /*
 Copyright (C) 2005,2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 "Mutex.h"
 #include "Lock.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 Lock::Lock(Mutex& m) : m_mutex(m)
 {
     m_mutex.Lock();
 }
 
+
 Lock::~Lock()
 {
     m_mutex.Unlock();
 }
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
diff --git a/dep/src/sockets/Mutex.cpp b/dep/src/sockets/Mutex.cpp
index 4f6ec98b5e1..3bfe64d04c7 100644
--- a/dep/src/sockets/Mutex.cpp
+++ b/dep/src/sockets/Mutex.cpp
@@ -4,29 +4,36 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 "Mutex.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 Mutex::Mutex()
 {
 #ifdef _WIN32
@@ -36,6 +43,7 @@ Mutex::Mutex()
 #endif
 }
 
+
 Mutex::~Mutex()
 {
 #ifdef _WIN32
@@ -45,6 +53,7 @@ Mutex::~Mutex()
 #endif
 }
 
+
 void Mutex::Lock()
 {
 #ifdef _WIN32
@@ -55,6 +64,7 @@ void Mutex::Lock()
 #endif
 }
 
+
 void Mutex::Unlock()
 {
 #ifdef _WIN32
@@ -64,7 +74,9 @@ void Mutex::Unlock()
 #endif
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
diff --git a/dep/src/sockets/Parse.cpp b/dep/src/sockets/Parse.cpp
index b0d51e187c8..ccbd553b0e6 100644
--- a/dep/src/sockets/Parse.cpp
+++ b/dep/src/sockets/Parse.cpp
@@ -2,35 +2,45 @@
  **
  ** Written: 1999-Feb-10 grymse@alhem.net
  **/
+
 /*
 Copyright (C) 1999-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 
 #include 
+
 #include "Parse.h"
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 /* implementation of class Parse */
+
 Parse::Parse()
 :pa_the_str("")
 ,pa_splits("")
@@ -43,6 +53,7 @@ Parse::Parse()
 ,pa_quote(false)
 {
 }
+
 Parse::Parse(const std::string&s)
 :pa_the_str(s)
 ,pa_splits("")
@@ -55,6 +66,7 @@ Parse::Parse(const std::string&s)
 ,pa_quote(false)
 {
 }
+
 Parse::Parse(const std::string&s,const std::string&sp)
 :pa_the_str(s)
 ,pa_splits(sp)
@@ -67,6 +79,7 @@ Parse::Parse(const std::string&s,const std::string&sp)
 ,pa_quote(false)
 {
 }
+
 Parse::Parse(const std::string&s,const std::string&sp,short /*nospace*/)
 :pa_the_str(s)
 ,pa_splits(sp)
@@ -80,10 +93,13 @@ Parse::Parse(const std::string&s,const std::string&sp,short /*nospace*/)
 {
 }
 
+
 Parse::~Parse()
 {
 }
+
 #define C ((pa_the_ptr l(h);
+
     if (l.Bind("127.0.0.1", m_port))
     {
         return;
     }
     h.Add(&l);
+
     m_ready = true;
     while (!m_quit && IsRunning() )
     {
@@ -65,18 +76,23 @@ void ResolvServer::Run()
     SetRunning(false);
 }
 
+
 void ResolvServer::Quit()
 {
     m_quit = true;
 }
 
+
 bool ResolvServer::Ready()
 {
     return m_ready;
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // ENABLE_RESOLVER
 
+
diff --git a/dep/src/sockets/ResolvSocket.cpp b/dep/src/sockets/ResolvSocket.cpp
index f97be03cd06..236e93f9704 100644
--- a/dep/src/sockets/ResolvSocket.cpp
+++ b/dep/src/sockets/ResolvSocket.cpp
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -37,20 +42,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "ISocketHandler.h"
 #include "Lock.h"
 #include "Mutex.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
+
 //#ifdef _DEBUG
 //#define DEB(x) x
 //#else
 #define DEB(x)
 //#endif
 
+
 // static
 ResolvSocket::cache_t ResolvSocket::m_cache;
 ResolvSocket::timeout_t ResolvSocket::m_cache_to;
 Mutex ResolvSocket::m_cache_mutex;
 
+
 ResolvSocket::ResolvSocket(ISocketHandler& h)
 :TcpSocket(h)
 ,m_bServer(false)
@@ -63,6 +72,7 @@ ResolvSocket::ResolvSocket(ISocketHandler& h)
     SetLineProtocol();
 }
 
+
 ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, const std::string& host, port_t port, bool ipv6)
 :TcpSocket(h)
 ,m_bServer(false)
@@ -77,6 +87,7 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, const std::string&
     SetLineProtocol();
 }
 
+
 ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, ipaddr_t a)
 :TcpSocket(h)
 ,m_bServer(false)
@@ -91,6 +102,7 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, ipaddr_t a)
     SetLineProtocol();
 }
 
+
 #ifdef ENABLE_IPV6
 ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, in6_addr& a)
 :TcpSocket(h)
@@ -105,10 +117,12 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, in6_addr& a)
 }
 #endif
 
+
 ResolvSocket::~ResolvSocket()
 {
 }
 
+
 void ResolvSocket::OnLine(const std::string& line)
 {
     Parse pa(line, ":");
@@ -170,6 +184,7 @@ DEB(fprintf(stderr, " *** Returning cache for [%s][%s] = '%s'\n", m_query.c_str(
     std::string key = pa.getword();
     std::string value = pa.getrest();
 DEB(    fprintf(stderr, " *** ResolvSocket response;  %s: %s\n", key.c_str(), value.c_str());)
+
     if (key == "Cached")
     {
         m_cached = true;
@@ -253,6 +268,7 @@ DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(),
 #endif
 }
 
+
 void ResolvSocket::OnDetached()
 {
 DEB(    fprintf(stderr, " *** ResolvSocket::OnDetached(); query=%s, data=%s\n", m_query.c_str(), m_data.c_str());)
@@ -354,6 +370,7 @@ DEB(    fprintf(stderr, " *** ResolvSocket::OnDetached(); query=%s, data=%s\n",
     SetCloseAndDelete();
 }
 
+
 void ResolvSocket::OnConnect()
 {
     if (!m_resolv_host.empty())
@@ -388,6 +405,7 @@ void ResolvSocket::OnConnect()
     Send( msg );
 }
 
+
 void ResolvSocket::OnDelete()
 {
     if (m_parent)
@@ -409,8 +427,11 @@ DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(),
     }
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
+
 #endif // ENABLE_RESOLVER
 
+
diff --git a/dep/src/sockets/Socket.cpp b/dep/src/sockets/Socket.cpp
index a0544c37db5..bf1a73abf6e 100644
--- a/dep/src/sockets/Socket.cpp
+++ b/dep/src/sockets/Socket.cpp
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -34,28 +39,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #endif
 #include 
 #include 
+
 #include "ISocketHandler.h"
 #include "Utility.h"
+
 #include "SocketAddress.h"
 #include "SocketHandler.h"
 #ifdef ENABLE_EXCEPTIONS
 #include "Exception.h"
 #endif
 #include "Ipv4Address.h"
+
 //#ifdef _DEBUG
 //#define DEB(x) x; fflush(stderr);
 //#else
 #define DEB(x)
 //#endif
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 // statics
 #ifdef _WIN32
 WSAInitializer Socket::m_winsock_init;
 #endif
 
+
 Socket::Socket(ISocketHandler& h)
 //:m_flags(0)
 :m_handler(h)
@@ -100,6 +111,7 @@ Socket::Socket(ISocketHandler& h)
 {
 }
 
+
 Socket::~Socket()
 {
     Handler().Remove(this);
@@ -113,18 +125,22 @@ Socket::~Socket()
     }
 }
 
+
 void Socket::Init()
 {
 }
 
+
 void Socket::OnRead()
 {
 }
 
+
 void Socket::OnWrite()
 {
 }
 
+
 void Socket::OnException()
 {
     // %! exception doesn't always mean something bad happened, this code should be reworked
@@ -134,18 +150,22 @@ void Socket::OnException()
     SetCloseAndDelete();
 }
 
+
 void Socket::OnDelete()
 {
 }
 
+
 void Socket::OnConnect()
 {
 }
 
+
 void Socket::OnAccept()
 {
 }
 
+
 int Socket::Close()
 {
     if (m_socket == INVALID_SOCKET) // this could happen
@@ -171,10 +191,12 @@ int Socket::Close()
     return n;
 }
 
+
 SOCKET Socket::CreateSocket(int af,int type, const std::string& protocol)
 {
     struct protoent *p = NULL;
     SOCKET s;
+
 #ifdef ENABLE_POOL
     m_socket_type = type;
     m_socket_protocol = protocol;
@@ -193,6 +215,7 @@ SOCKET Socket::CreateSocket(int af,int type, const std::string& protocol)
         }
     }
     int protno = p ? p -> p_proto : 0;
+
     s = socket(af, type, protno);
     if (s == INVALID_SOCKET)
     {
@@ -209,26 +232,31 @@ SOCKET Socket::CreateSocket(int af,int type, const std::string& protocol)
     return s;
 }
 
+
 void Socket::Attach(SOCKET s)
 {
     m_socket = s;
 }
 
+
 SOCKET Socket::GetSocket()
 {
     return m_socket;
 }
 
+
 void Socket::SetDeleteByHandler(bool x)
 {
     m_bDel = x;
 }
 
+
 bool Socket::DeleteByHandler()
 {
     return m_bDel;
 }
 
+
 void Socket::SetCloseAndDelete(bool x)
 {
     if (x != m_bClose)
@@ -242,21 +270,25 @@ void Socket::SetCloseAndDelete(bool x)
     }
 }
 
+
 bool Socket::CloseAndDelete()
 {
     return m_bClose;
 }
 
+
 void Socket::SetRemoteAddress(SocketAddress& ad) //struct sockaddr* sa, socklen_t l)
 {
     m_remote_address = ad.GetCopy();
 }
 
+
 std::auto_ptr Socket::GetRemoteSocketAddress()
 {
     return m_remote_address -> GetCopy();
 }
 
+
 ISocketHandler& Socket::Handler() const
 {
 #ifdef ENABLE_DETACH
@@ -266,11 +298,13 @@ ISocketHandler& Socket::Handler() const
     return m_handler;
 }
 
+
 ISocketHandler& Socket::MasterHandler() const
 {
     return m_handler;
 }
 
+
 ipaddr_t Socket::GetRemoteIP4()
 {
     ipaddr_t l = 0;
@@ -289,6 +323,7 @@ ipaddr_t Socket::GetRemoteIP4()
     return l;
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 struct in6_addr Socket::GetRemoteIP6()
@@ -312,6 +347,7 @@ struct in6_addr Socket::GetRemoteIP6()
 #endif
 #endif
 
+
 port_t Socket::GetRemotePort()
 {
     if (!m_remote_address.get())
@@ -321,6 +357,7 @@ port_t Socket::GetRemotePort()
     return m_remote_address -> GetPort();
 }
 
+
 std::string Socket::GetRemoteAddress()
 {
     if (!m_remote_address.get())
@@ -330,6 +367,7 @@ std::string Socket::GetRemoteAddress()
     return m_remote_address -> Convert(false);
 }
 
+
 std::string Socket::GetRemoteHostname()
 {
     if (!m_remote_address.get())
@@ -339,6 +377,7 @@ std::string Socket::GetRemoteHostname()
     return m_remote_address -> Reverse();
 }
 
+
 bool Socket::SetNonblocking(bool bNb)
 {
 #ifdef _WIN32
@@ -371,6 +410,7 @@ bool Socket::SetNonblocking(bool bNb)
 #endif
 }
 
+
 bool Socket::SetNonblocking(bool bNb, SOCKET s)
 {
 #ifdef _WIN32
@@ -403,11 +443,13 @@ bool Socket::SetNonblocking(bool bNb, SOCKET s)
 #endif
 }
 
+
 void Socket::Set(bool bRead, bool bWrite, bool bException)
 {
     Handler().Set(m_socket, bRead, bWrite, bException);
 }
 
+
 bool Socket::Ready()
 {
     if (m_socket != INVALID_SOCKET && !CloseAndDelete())
@@ -415,115 +457,138 @@ bool Socket::Ready()
     return false;
 }
 
+
 void Socket::OnLine(const std::string& )
 {
 }
 
+
 void Socket::OnConnectFailed()
 {
 }
 
+
 Socket *Socket::GetParent()
 {
     return m_parent;
 }
 
+
 void Socket::SetParent(Socket *x)
 {
     m_parent = x;
 }
 
+
 port_t Socket::GetPort()
 {
     Handler().LogError(this, "GetPort", 0, "GetPort only implemented for ListenSocket", LOG_LEVEL_WARNING);
     return 0;
 }
 
+
 bool Socket::OnConnectRetry()
 {
     return true;
 }
 
+
 #ifdef ENABLE_RECONNECT
 void Socket::OnReconnect()
 {
 }
 #endif
 
+
 time_t Socket::Uptime()
 {
     return time(NULL) - m_tCreate;
 }
 
+
 #ifdef ENABLE_IPV6
 void Socket::SetIpv6(bool x)
 {
     m_ipv6 = x;
 }
 
+
 bool Socket::IsIpv6()
 {
     return m_ipv6;
 }
 #endif
 
+
 void Socket::DisableRead(bool x)
 {
     m_b_disable_read = x;
 }
 
+
 bool Socket::IsDisableRead()
 {
     return m_b_disable_read;
 }
 
+
 void Socket::SendBuf(const char *,size_t,int)
 {
 }
 
+
 void Socket::Send(const std::string&,int)
 {
 }
 
+
 void Socket::SetConnected(bool x)
 {
     m_connected = x;
 }
 
+
 bool Socket::IsConnected()
 {
     return m_connected;
 }
 
+
 void Socket::OnDisconnect()
 {
 }
 
+
 void Socket::SetLost()
 {
     m_bLost = true;
 }
 
+
 bool Socket::Lost()
 {
     return m_bLost;
 }
 
+
 void Socket::SetErasedByHandler(bool x)
 {
     m_b_erased_by_handler = x;
 }
 
+
 bool Socket::ErasedByHandler()
 {
     return m_b_erased_by_handler;
 }
 
+
 time_t Socket::TimeSinceClose()
 {
     return time(NULL) - m_tClose;
 }
 
+
 void Socket::SetClientRemoteAddress(SocketAddress& ad)
 {
     if (!ad.IsValid())
@@ -533,6 +598,7 @@ void Socket::SetClientRemoteAddress(SocketAddress& ad)
     m_client_remote_address = ad.GetCopy();
 }
 
+
 std::auto_ptr Socket::GetClientRemoteAddress()
 {
     if (!m_client_remote_address.get())
@@ -542,69 +608,83 @@ std::auto_ptr Socket::GetClientRemoteAddress()
     return m_client_remote_address -> GetCopy();
 }
 
+
 uint64_t Socket::GetBytesSent(bool)
 {
     return 0;
 }
 
+
 uint64_t Socket::GetBytesReceived(bool)
 {
     return 0;
 }
 
+
 #ifdef HAVE_OPENSSL
 void Socket::OnSSLConnect()
 {
 }
 
+
 void Socket::OnSSLAccept()
 {
 }
 
+
 bool Socket::SSLNegotiate()
 {
     return false;
 }
 
+
 bool Socket::IsSSL()
 {
     return m_b_enable_ssl;
 }
 
+
 void Socket::EnableSSL(bool x)
 {
     m_b_enable_ssl = x;
 }
 
+
 bool Socket::IsSSLNegotiate()
 {
     return m_b_ssl;
 }
 
+
 void Socket::SetSSLNegotiate(bool x)
 {
     m_b_ssl = x;
 }
 
+
 bool Socket::IsSSLServer()
 {
     return m_b_ssl_server;
 }
 
+
 void Socket::SetSSLServer(bool x)
 {
     m_b_ssl_server = x;
 }
 
+
 void Socket::OnSSLConnectFailed()
 {
 }
 
+
 void Socket::OnSSLAcceptFailed()
 {
 }
 #endif // HAVE_OPENSSL
 
+
 #ifdef ENABLE_POOL
 void Socket::CopyConnection(Socket *sock)
 {
@@ -614,110 +694,132 @@ void Socket::CopyConnection(Socket *sock)
 #endif
     SetSocketType( sock -> GetSocketType() );
     SetSocketProtocol( sock -> GetSocketProtocol() );
+
     SetClientRemoteAddress( *sock -> GetClientRemoteAddress() );
     SetRemoteAddress( *sock -> GetRemoteSocketAddress() );
 }
 
+
 void Socket::SetIsClient()
 {
     m_bClient = true;
 }
 
+
 void Socket::SetSocketType(int x)
 {
     m_socket_type = x;
 }
 
+
 int Socket::GetSocketType()
 {
     return m_socket_type;
 }
 
+
 void Socket::SetSocketProtocol(const std::string& x)
 {
     m_socket_protocol = x;
 }
 
+
 const std::string& Socket::GetSocketProtocol()
 {
     return m_socket_protocol;
 }
 
+
 void Socket::SetRetain()
 {
     if (m_bClient) m_bRetain = true;
 }
 
+
 bool Socket::Retain()
 {
     return m_bRetain;
 }
 
+
 #endif // ENABLE_POOL
 
+
 #ifdef ENABLE_SOCKS4
 void Socket::OnSocks4Connect()
 {
     Handler().LogError(this, "OnSocks4Connect", 0, "Use with TcpSocket only");
 }
 
+
 void Socket::OnSocks4ConnectFailed()
 {
     Handler().LogError(this, "OnSocks4ConnectFailed", 0, "Use with TcpSocket only");
 }
 
+
 bool Socket::OnSocks4Read()
 {
     Handler().LogError(this, "OnSocks4Read", 0, "Use with TcpSocket only");
     return true;
 }
 
+
 void Socket::SetSocks4Host(const std::string& host)
 {
     Utility::u2ip(host, m_socks4_host);
 }
 
+
 bool Socket::Socks4()
 {
     return m_bSocks4;
 }
 
+
 void Socket::SetSocks4(bool x)
 {
     m_bSocks4 = x;
 }
 
+
 void Socket::SetSocks4Host(ipaddr_t a)
 {
     m_socks4_host = a;
 }
 
+
 void Socket::SetSocks4Port(port_t p)
 {
     m_socks4_port = p;
 }
 
+
 void Socket::SetSocks4Userid(const std::string& x)
 {
     m_socks4_userid = x;
 }
 
+
 ipaddr_t Socket::GetSocks4Host()
 {
     return m_socks4_host;
 }
 
+
 port_t Socket::GetSocks4Port()
 {
     return m_socks4_port;
 }
 
+
 const std::string& Socket::GetSocks4Userid()
 {
     return m_socks4_userid;
 }
 #endif // ENABLE_SOCKS4
 
+
 #ifdef ENABLE_DETACH
 bool Socket::Detach()
 {
@@ -731,6 +833,7 @@ bool Socket::Detach()
     return true;
 }
 
+
 void Socket::DetachSocket()
 {
     SetDetached();
@@ -738,36 +841,43 @@ void Socket::DetachSocket()
     m_pThread -> SetRelease(true);
 }
 
+
 void Socket::OnDetached()
 {
 }
 
+
 void Socket::SetDetach(bool x)
 {
     Handler().AddList(m_socket, LIST_DETACH, x);
     m_detach = x;
 }
 
+
 bool Socket::IsDetach()
 {
     return m_detach;
 }
 
+
 void Socket::SetDetached(bool x)
 {
     m_detached = x;
 }
 
+
 const bool Socket::IsDetached() const
 {
     return m_detached;
 }
 
+
 void Socket::SetSlaveHandler(ISocketHandler *p)
 {
     m_slave_handler = p;
 }
 
+
 Socket::SocketThread::SocketThread(Socket *p)
 :Thread(false)
 ,m_socket(p)
@@ -775,6 +885,7 @@ Socket::SocketThread::SocketThread(Socket *p)
     // Creator will release
 }
 
+
 Socket::SocketThread::~SocketThread()
 {
     if (IsRunning())
@@ -789,6 +900,7 @@ Socket::SocketThread::~SocketThread()
     }
 }
 
+
 void Socket::SocketThread::Run()
 {
     SocketHandler h;
@@ -807,12 +919,14 @@ void Socket::SocketThread::Run()
 }
 #endif // ENABLE_DETACH
 
+
 #ifdef ENABLE_RESOLVER
 int Socket::Resolve(const std::string& host,port_t port)
 {
     return Handler().Resolve(this, host, port);
 }
 
+
 #ifdef ENABLE_IPV6
 int Socket::Resolve6(const std::string& host,port_t port)
 {
@@ -820,11 +934,13 @@ int Socket::Resolve6(const std::string& host,port_t port)
 }
 #endif
 
+
 int Socket::Resolve(ipaddr_t a)
 {
     return Handler().Resolve(this, a);
 }
 
+
 #ifdef ENABLE_IPV6
 int Socket::Resolve(in6_addr& a)
 {
@@ -832,27 +948,33 @@ int Socket::Resolve(in6_addr& a)
 }
 #endif
 
+
 void Socket::OnResolved(int,ipaddr_t,port_t)
 {
 }
 
+
 #ifdef ENABLE_IPV6
 void Socket::OnResolved(int,in6_addr&,port_t)
 {
 }
 #endif
 
+
 void Socket::OnReverseResolved(int,const std::string&)
 {
 }
 
+
 void Socket::OnResolveFailed(int)
 {
 }
 #endif // ENABLE_RESOLVER
 
+
 /* IP options */
 
+
 bool Socket::SetIpOptions(const void *p, socklen_t len)
 {
 #ifdef IP_OPTIONS
@@ -868,6 +990,7 @@ bool Socket::SetIpOptions(const void *p, socklen_t len)
 #endif
 }
 
+
 #ifdef IP_PKTINFO
 bool Socket::SetIpPktinfo(bool x)
 {
@@ -881,6 +1004,7 @@ bool Socket::SetIpPktinfo(bool x)
 }
 #endif
 
+
 #ifdef IP_RECVTOS
 bool Socket::SetIpRecvTOS(bool x)
 {
@@ -894,6 +1018,7 @@ bool Socket::SetIpRecvTOS(bool x)
 }
 #endif
 
+
 #ifdef IP_RECVTTL
 bool Socket::SetIpRecvTTL(bool x)
 {
@@ -907,6 +1032,7 @@ bool Socket::SetIpRecvTTL(bool x)
 }
 #endif
 
+
 #ifdef IP_RECVOPTS
 bool Socket::SetIpRecvopts(bool x)
 {
@@ -920,6 +1046,7 @@ bool Socket::SetIpRecvopts(bool x)
 }
 #endif
 
+
 #ifdef IP_RETOPTS
 bool Socket::SetIpRetopts(bool x)
 {
@@ -933,6 +1060,7 @@ bool Socket::SetIpRetopts(bool x)
 }
 #endif
 
+
 bool Socket::SetIpTOS(unsigned char tos)
 {
 #ifdef IP_TOS
@@ -948,6 +1076,7 @@ bool Socket::SetIpTOS(unsigned char tos)
 #endif
 }
 
+
 unsigned char Socket::IpTOS()
 {
     unsigned char tos = 0;
@@ -963,6 +1092,7 @@ unsigned char Socket::IpTOS()
     return tos;
 }
 
+
 bool Socket::SetIpTTL(int ttl)
 {
 #ifdef IP_TTL
@@ -978,6 +1108,7 @@ bool Socket::SetIpTTL(int ttl)
 #endif
 }
 
+
 int Socket::IpTTL()
 {
     int ttl = 0;
@@ -993,6 +1124,7 @@ int Socket::IpTTL()
     return ttl;
 }
 
+
 bool Socket::SetIpHdrincl(bool x)
 {
 #ifdef IP_HDRINCL
@@ -1009,6 +1141,7 @@ bool Socket::SetIpHdrincl(bool x)
 #endif
 }
 
+
 #ifdef IP_RECVERR
 bool Socket::SetIpRecverr(bool x)
 {
@@ -1022,6 +1155,7 @@ bool Socket::SetIpRecverr(bool x)
 }
 #endif
 
+
 #ifdef IP_MTU_DISCOVER
 bool Socket::SetIpMtudiscover(bool x)
 {
@@ -1035,6 +1169,7 @@ bool Socket::SetIpMtudiscover(bool x)
 }
 #endif
 
+
 #ifdef IP_MTU
 int Socket::IpMtu()
 {
@@ -1048,6 +1183,7 @@ int Socket::IpMtu()
 }
 #endif
 
+
 #ifdef IP_ROUTER_ALERT
 bool Socket::SetIpRouterAlert(bool x)
 {
@@ -1061,6 +1197,7 @@ bool Socket::SetIpRouterAlert(bool x)
 }
 #endif
 
+
 bool Socket::SetIpMulticastTTL(int ttl)
 {
 #ifdef IP_MULTICAST_TTL
@@ -1076,6 +1213,7 @@ bool Socket::SetIpMulticastTTL(int ttl)
 #endif
 }
 
+
 int Socket::IpMulticastTTL()
 {
     int ttl = 0;
@@ -1091,6 +1229,7 @@ int Socket::IpMulticastTTL()
     return ttl;
 }
 
+
 bool Socket::SetMulticastLoop(bool x)
 {
 #ifdef IP_MULTICAST_LOOP
@@ -1107,6 +1246,7 @@ bool Socket::SetMulticastLoop(bool x)
 #endif
 }
 
+
 #ifdef LINUX
 bool Socket::IpAddMembership(struct ip_mreqn& ref)
 {
@@ -1124,6 +1264,7 @@ bool Socket::IpAddMembership(struct ip_mreqn& ref)
 }
 #endif
 
+
 bool Socket::IpAddMembership(struct ip_mreq& ref)
 {
 #ifdef IP_ADD_MEMBERSHIP
@@ -1139,6 +1280,7 @@ bool Socket::IpAddMembership(struct ip_mreq& ref)
 #endif
 }
 
+
 #ifdef LINUX
 bool Socket::IpDropMembership(struct ip_mreqn& ref)
 {
@@ -1156,6 +1298,7 @@ bool Socket::IpDropMembership(struct ip_mreqn& ref)
 }
 #endif
 
+
 bool Socket::IpDropMembership(struct ip_mreq& ref)
 {
 #ifdef IP_DROP_MEMBERSHIP
@@ -1171,8 +1314,10 @@ bool Socket::IpDropMembership(struct ip_mreq& ref)
 #endif
 }
 
+
 /* SOCKET options */
 
+
 bool Socket::SetSoReuseaddr(bool x)
 {
 #ifdef SO_REUSEADDR
@@ -1189,6 +1334,7 @@ bool Socket::SetSoReuseaddr(bool x)
 #endif
 }
 
+
 bool Socket::SetSoKeepalive(bool x)
 {
 #ifdef SO_KEEPALIVE
@@ -1205,6 +1351,7 @@ bool Socket::SetSoKeepalive(bool x)
 #endif
 }
 
+
 #ifdef SO_NOSIGPIPE
 bool Socket::SetSoNosigpipe(bool x)
 {
@@ -1218,6 +1365,7 @@ bool Socket::SetSoNosigpipe(bool x)
 }
 #endif
 
+
 bool Socket::SoAcceptconn()
 {
     int value = 0;
@@ -1233,6 +1381,7 @@ bool Socket::SoAcceptconn()
     return value ? true : false;
 }
 
+
 #ifdef SO_BSDCOMPAT
 bool Socket::SetSoBsdcompat(bool x)
 {
@@ -1246,6 +1395,7 @@ bool Socket::SetSoBsdcompat(bool x)
 }
 #endif
 
+
 #ifdef SO_BINDTODEVICE
 bool Socket::SetSoBindtodevice(const std::string& intf)
 {
@@ -1258,6 +1408,7 @@ bool Socket::SetSoBindtodevice(const std::string& intf)
 }
 #endif
 
+
 bool Socket::SetSoBroadcast(bool x)
 {
 #ifdef SO_BROADCAST
@@ -1274,6 +1425,7 @@ bool Socket::SetSoBroadcast(bool x)
 #endif
 }
 
+
 bool Socket::SetSoDebug(bool x)
 {
 #ifdef SO_DEBUG
@@ -1290,6 +1442,7 @@ bool Socket::SetSoDebug(bool x)
 #endif
 }
 
+
 int Socket::SoError()
 {
     int value = 0;
@@ -1305,6 +1458,7 @@ int Socket::SoError()
     return value;
 }
 
+
 bool Socket::SetSoDontroute(bool x)
 {
 #ifdef SO_DONTROUTE
@@ -1321,6 +1475,7 @@ bool Socket::SetSoDontroute(bool x)
 #endif
 }
 
+
 bool Socket::SetSoLinger(int onoff, int linger)
 {
 #ifdef SO_LINGER
@@ -1339,6 +1494,7 @@ bool Socket::SetSoLinger(int onoff, int linger)
 #endif
 }
 
+
 bool Socket::SetSoOobinline(bool x)
 {
 #ifdef SO_OOBINLINE
@@ -1355,6 +1511,7 @@ bool Socket::SetSoOobinline(bool x)
 #endif
 }
 
+
 #ifdef SO_PASSCRED
 bool Socket::SetSoPasscred(bool x)
 {
@@ -1368,6 +1525,7 @@ bool Socket::SetSoPasscred(bool x)
 }
 #endif
 
+
 #ifdef SO_PEERCRED
 bool Socket::SoPeercred(struct ucred& ucr)
 {
@@ -1380,6 +1538,7 @@ bool Socket::SoPeercred(struct ucred& ucr)
 }
 #endif
 
+
 #ifdef SO_PRIORITY
 bool Socket::SetSoPriority(int x)
 {
@@ -1392,6 +1551,7 @@ bool Socket::SetSoPriority(int x)
 }
 #endif
 
+
 bool Socket::SetSoRcvlowat(int x)
 {
 #ifdef SO_RCVLOWAT
@@ -1407,6 +1567,7 @@ bool Socket::SetSoRcvlowat(int x)
 #endif
 }
 
+
 bool Socket::SetSoSndlowat(int x)
 {
 #ifdef SO_SNDLOWAT
@@ -1422,6 +1583,7 @@ bool Socket::SetSoSndlowat(int x)
 #endif
 }
 
+
 bool Socket::SetSoRcvtimeo(struct timeval& tv)
 {
 #ifdef SO_RCVTIMEO
@@ -1437,6 +1599,7 @@ bool Socket::SetSoRcvtimeo(struct timeval& tv)
 #endif
 }
 
+
 bool Socket::SetSoSndtimeo(struct timeval& tv)
 {
 #ifdef SO_SNDTIMEO
@@ -1452,6 +1615,7 @@ bool Socket::SetSoSndtimeo(struct timeval& tv)
 #endif
 }
 
+
 bool Socket::SetSoRcvbuf(int x)
 {
 #ifdef SO_RCVBUF
@@ -1467,6 +1631,7 @@ bool Socket::SetSoRcvbuf(int x)
 #endif
 }
 
+
 int Socket::SoRcvbuf()
 {
     int value = 0;
@@ -1482,6 +1647,7 @@ int Socket::SoRcvbuf()
     return value;
 }
 
+
 #ifdef SO_RCVBUFFORCE
 bool Socket::SetSoRcvbufforce(int x)
 {
@@ -1494,6 +1660,7 @@ bool Socket::SetSoRcvbufforce(int x)
 }
 #endif
 
+
 bool Socket::SetSoSndbuf(int x)
 {
 #ifdef SO_SNDBUF
@@ -1509,6 +1676,7 @@ bool Socket::SetSoSndbuf(int x)
 #endif
 }
 
+
 int Socket::SoSndbuf()
 {
     int value = 0;
@@ -1524,6 +1692,7 @@ int Socket::SoSndbuf()
     return value;
 }
 
+
 #ifdef SO_SNDBUFFORCE
 bool Socket::SetSoSndbufforce(int x)
 {
@@ -1536,6 +1705,7 @@ bool Socket::SetSoSndbufforce(int x)
 }
 #endif
 
+
 #ifdef SO_TIMESTAMP
 bool Socket::SetSoTimestamp(bool x)
 {
@@ -1549,6 +1719,7 @@ bool Socket::SetSoTimestamp(bool x)
 }
 #endif
 
+
 int Socket::SoType()
 {
     int value = 0;
@@ -1564,26 +1735,31 @@ int Socket::SoType()
     return value;
 }
 
+
 #ifdef ENABLE_TRIGGERS
 void Socket::Subscribe(int id)
 {
     Handler().Subscribe(id, this);
 }
 
+
 void Socket::Unsubscribe(int id)
 {
     Handler().Unsubscribe(id, this);
 }
 
+
 void Socket::OnTrigger(int, const TriggerData&)
 {
 }
 
+
 void Socket::OnCancelled(int)
 {
 }
 #endif
 
+
 void Socket::SetTimeout(time_t secs)
 {
     if (!secs)
@@ -1596,14 +1772,17 @@ void Socket::SetTimeout(time_t secs)
     m_timeout_limit = secs;
 }
 
+
 void Socket::OnTimeout()
 {
 }
 
+
 void Socket::OnConnectTimeout()
 {
 }
 
+
 bool Socket::Timeout(time_t tnow)
 {
     if (tnow - m_timeout_start > m_timeout_limit)
@@ -1611,6 +1790,7 @@ bool Socket::Timeout(time_t tnow)
     return false;
 }
 
+
 /** Returns local port number for bound socket file descriptor. */
 port_t Socket::GetSockPort()
 {
@@ -1633,6 +1813,7 @@ port_t Socket::GetSockPort()
     return ntohs(sa.sin_port);
 }
 
+
 /** Returns local ipv4 address for bound socket file descriptor. */
 ipaddr_t Socket::GetSockIP4()
 {
@@ -1653,6 +1834,7 @@ ipaddr_t Socket::GetSockIP4()
     return a;
 }
 
+
 /** Returns local ipv4 address as text for bound socket file descriptor. */
 std::string Socket::GetSockAddress()
 {
@@ -1672,6 +1854,7 @@ std::string Socket::GetSockAddress()
     return addr.Convert();
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 /** Returns local ipv6 address for bound socket file descriptor. */
@@ -1690,6 +1873,7 @@ struct in6_addr Socket::GetSockIP6()
     return a;
 }
 
+
 /** Returns local ipv6 address as text for bound socket file descriptor. */
 std::string Socket::GetSockAddress6()
 {
@@ -1707,7 +1891,9 @@ std::string Socket::GetSockAddress6()
 #endif
 #endif
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
diff --git a/dep/src/sockets/SocketHandler.cpp b/dep/src/sockets/SocketHandler.cpp
index ff6d4b36d64..84d110cfe72 100644
--- a/dep/src/sockets/SocketHandler.cpp
+++ b/dep/src/sockets/SocketHandler.cpp
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -31,6 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include 
 #include 
 #include 
+
 #include "SocketHandler.h"
 #include "UdpSocket.h"
 #include "ResolvSocket.h"
@@ -39,16 +45,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Mutex.h"
 #include "Utility.h"
 #include "SocketAddress.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 //#ifdef _DEBUG
 //#define DEB(x) x; fflush(stderr);
 //#else
 #define DEB(x)
 //#endif
 
+
 SocketHandler::SocketHandler(StdLog *p)
 :m_stdlog(p)
 ,m_mutex(m_mutex)
@@ -81,6 +90,7 @@ SocketHandler::SocketHandler(StdLog *p)
     FD_ZERO(&m_efds);
 }
 
+
 SocketHandler::SocketHandler(Mutex& mutex,StdLog *p)
 :m_stdlog(p)
 ,m_mutex(mutex)
@@ -114,6 +124,7 @@ SocketHandler::SocketHandler(Mutex& mutex,StdLog *p)
     FD_ZERO(&m_efds);
 }
 
+
 SocketHandler::~SocketHandler()
 {
 #ifdef ENABLE_RESOLVER
@@ -136,6 +147,7 @@ DEB(                fprintf(stderr, "  fd closed %d\n", p -> GetSocket());)
 //              p -> OnDelete(); // hey, I turn this back on. what's the worst that could happen??!!
                 // MinionSocket breaks, calling MinderHandler methods in OnDelete -
                 // MinderHandler is already gone when that happens...
+
                 // only delete socket when controlled
                 // ie master sockethandler can delete non-detached sockets
                 // and a slave sockethandler can only delete a detach socket
@@ -170,28 +182,33 @@ DEB(        fprintf(stderr, "/Emptying sockets list in SocketHandler destructor,
     }
 }
 
+
 Mutex& SocketHandler::GetMutex() const
 {
     return m_mutex;
 }
 
+
 #ifdef ENABLE_DETACH
 void SocketHandler::SetSlave(bool x)
 {
     m_slave = x;
 }
 
+
 bool SocketHandler::IsSlave()
 {
     return m_slave;
 }
 #endif
 
+
 void SocketHandler::RegStdLog(StdLog *log)
 {
     m_stdlog = log;
 }
 
+
 void SocketHandler::LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t)
 {
     if (m_stdlog)
@@ -200,6 +217,7 @@ void SocketHandler::LogError(Socket *p,const std::string& user_text,int err,cons
     }
 }
 
+
 void SocketHandler::Add(Socket *p)
 {
     if (p -> GetSocket() == INVALID_SOCKET)
@@ -220,6 +238,7 @@ void SocketHandler::Add(Socket *p)
     m_add[p -> GetSocket()] = p;
 }
 
+
 void SocketHandler::Get(SOCKET s,bool& r,bool& w,bool& e)
 {
     if (s >= 0)
@@ -230,6 +249,7 @@ void SocketHandler::Get(SOCKET s,bool& r,bool& w,bool& e)
     }
 }
 
+
 void SocketHandler::Set(SOCKET s,bool bRead,bool bWrite,bool bException)
 {
 DEB(    fprintf(stderr, "Set(%d, %s, %s, %s)\n", s, bRead ? "true" : "false", bWrite ? "true" : "false", bException ? "true" : "false");)
@@ -271,6 +291,7 @@ DEB(    fprintf(stderr, "Set(%d, %s, %s, %s)\n", s, bRead ? "true" : "false", bW
     }
 }
 
+
 int SocketHandler::Select(long sec,long usec)
 {
     struct timeval tv;
@@ -279,6 +300,7 @@ int SocketHandler::Select(long sec,long usec)
     return Select(&tv);
 }
 
+
 int SocketHandler::Select()
 {
     if (!m_fds_callonconnect.empty() ||
@@ -295,6 +317,7 @@ int SocketHandler::Select()
     return Select(NULL);
 }
 
+
 int SocketHandler::Select(struct timeval *tsel)
 {
     size_t ignore = 0;
@@ -505,6 +528,7 @@ DEB(            fprintf(stderr, "m_maxsock: %d\n", m_maxsock);
         } // m_fds loop
         m_preverror = -1;
     } // if (n > 0)
+
     // check CallOnConnect - EVENT
     if (!m_fds_callonconnect.empty())
     {
@@ -802,6 +826,7 @@ DEB(                            fprintf(stderr, "Close() before OnDelete\n");)
             }
         }
     }
+
     // check erased sockets
     bool check_max_fd = false;
     while (!m_fds_erase.empty())
@@ -940,6 +965,7 @@ DEB(                            fprintf(stderr, "Close() before OnDelete\n");)
     return n;
 }
 
+
 #ifdef ENABLE_RESOLVER
 bool SocketHandler::Resolving(Socket *p0)
 {
@@ -948,6 +974,7 @@ bool SocketHandler::Resolving(Socket *p0)
 }
 #endif
 
+
 bool SocketHandler::Valid(Socket *p0)
 {
     for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
@@ -959,11 +986,13 @@ bool SocketHandler::Valid(Socket *p0)
     return false;
 }
 
+
 bool SocketHandler::OkToAccept(Socket *)
 {
     return true;
 }
 
+
 size_t SocketHandler::GetCount()
 {
 /*
@@ -974,28 +1003,33 @@ printf(" m_delete  : %d\n", m_delete.size());
     return m_sockets.size() + m_add.size() + m_delete.size();
 }
 
+
 #ifdef ENABLE_SOCKS4
 void SocketHandler::SetSocks4Host(ipaddr_t a)
 {
     m_socks4_host = a;
 }
 
+
 void SocketHandler::SetSocks4Host(const std::string& host)
 {
     Utility::u2ip(host, m_socks4_host);
 }
 
+
 void SocketHandler::SetSocks4Port(port_t port)
 {
     m_socks4_port = port;
 }
 
+
 void SocketHandler::SetSocks4Userid(const std::string& id)
 {
     m_socks4_userid = id;
 }
 #endif
 
+
 #ifdef ENABLE_RESOLVER
 int SocketHandler::Resolve(Socket *p,const std::string& host,port_t port)
 {
@@ -1015,6 +1049,7 @@ DEB(    fprintf(stderr, " *** Resolve '%s:%d' id#%d  m_resolve_q size: %d  p: %p
     return resolv -> GetId();
 }
 
+
 #ifdef ENABLE_IPV6
 int SocketHandler::Resolve6(Socket *p,const std::string& host,port_t port)
 {
@@ -1034,6 +1069,7 @@ int SocketHandler::Resolve6(Socket *p,const std::string& host,port_t port)
 }
 #endif
 
+
 int SocketHandler::Resolve(Socket *p,ipaddr_t a)
 {
     // check cache
@@ -1051,6 +1087,7 @@ int SocketHandler::Resolve(Socket *p,ipaddr_t a)
     return resolv -> GetId();
 }
 
+
 #ifdef ENABLE_IPV6
 int SocketHandler::Resolve(Socket *p,in6_addr& a)
 {
@@ -1070,6 +1107,7 @@ int SocketHandler::Resolve(Socket *p,in6_addr& a)
 }
 #endif
 
+
 void SocketHandler::EnableResolver(port_t port)
 {
     if (!m_resolver)
@@ -1079,51 +1117,60 @@ void SocketHandler::EnableResolver(port_t port)
     }
 }
 
+
 bool SocketHandler::ResolverReady()
 {
     return m_resolver ? m_resolver -> Ready() : false;
 }
 #endif // ENABLE_RESOLVER
 
+
 #ifdef ENABLE_SOCKS4
 void SocketHandler::SetSocks4TryDirect(bool x)
 {
     m_bTryDirect = x;
 }
 
+
 ipaddr_t SocketHandler::GetSocks4Host()
 {
     return m_socks4_host;
 }
 
+
 port_t SocketHandler::GetSocks4Port()
 {
     return m_socks4_port;
 }
 
+
 const std::string& SocketHandler::GetSocks4Userid()
 {
     return m_socks4_userid;
 }
 
+
 bool SocketHandler::Socks4TryDirect()
 {
     return m_bTryDirect;
 }
 #endif
 
+
 #ifdef ENABLE_RESOLVER
 bool SocketHandler::ResolverEnabled()
 {
     return m_resolver ? true : false;
 }
 
+
 port_t SocketHandler::GetResolverPort()
 {
     return m_resolver_port;
 }
 #endif // ENABLE_RESOLVER
 
+
 #ifdef ENABLE_POOL
 ISocketHandler::PoolSocket *SocketHandler::FindConnection(int type,const std::string& protocol,SocketAddress& ad)
 {
@@ -1146,17 +1193,20 @@ ISocketHandler::PoolSocket *SocketHandler::FindConnection(int type,const std::st
     return NULL;
 }
 
+
 void SocketHandler::EnablePool(bool x)
 {
     m_b_enable_pool = x;
 }
 
+
 bool SocketHandler::PoolEnabled()
 {
     return m_b_enable_pool;
 }
 #endif
 
+
 void SocketHandler::Remove(Socket *p)
 {
 #ifdef ENABLE_RESOLVER
@@ -1197,6 +1247,7 @@ void SocketHandler::Remove(Socket *p)
     }
 }
 
+
 void SocketHandler::CheckSanity()
 {
     CheckList(m_fds, "active sockets"); // active sockets
@@ -1210,6 +1261,7 @@ void SocketHandler::CheckSanity()
     CheckList(m_fds_close, "checklist close and delete");
 }
 
+
 void SocketHandler::CheckList(socket_v& ref,const std::string& listname)
 {
     for (socket_v::iterator it = ref.begin(); it != ref.end(); it++)
@@ -1236,6 +1288,7 @@ void SocketHandler::CheckList(socket_v& ref,const std::string& listname)
     }
 }
 
+
 void SocketHandler::AddList(SOCKET s,list_t which_one,bool add)
 {
     if (s == INVALID_SOCKET)
@@ -1292,6 +1345,7 @@ DEB(    fprintf(stderr, "AddList;  %5d: %s: %s\n", s, (which_one == LIST_CALLONC
 //DEB(  fprintf(stderr, "/AddList\n");)
 }
 
+
 #ifdef ENABLE_TRIGGERS
 int SocketHandler::TriggerID(Socket *src)
 {
@@ -1300,6 +1354,7 @@ int SocketHandler::TriggerID(Socket *src)
     return id;
 }
 
+
 bool SocketHandler::Subscribe(int id, Socket *dst)
 {
     if (m_trigger_src.find(id) != m_trigger_src.end())
@@ -1317,6 +1372,7 @@ bool SocketHandler::Subscribe(int id, Socket *dst)
     return false;
 }
 
+
 bool SocketHandler::Unsubscribe(int id, Socket *dst)
 {
     if (m_trigger_src.find(id) != m_trigger_src.end())
@@ -1334,6 +1390,7 @@ bool SocketHandler::Unsubscribe(int id, Socket *dst)
     return false;
 }
 
+
 void SocketHandler::Trigger(int id, Socket::TriggerData& data, bool erase)
 {
     if (m_trigger_src.find(id) != m_trigger_src.end())
@@ -1360,7 +1417,9 @@ void SocketHandler::Trigger(int id, Socket::TriggerData& data, bool erase)
 }
 #endif // ENABLE_TRIGGERS
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
diff --git a/dep/src/sockets/StdoutLog.cpp b/dep/src/sockets/StdoutLog.cpp
index 44743c729f7..998613f0fb2 100644
--- a/dep/src/sockets/StdoutLog.cpp
+++ b/dep/src/sockets/StdoutLog.cpp
@@ -4,37 +4,48 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 
+
 #ifdef _MSC_VER
 #pragma warning(disable:4786)
 #endif
+
 #include 
+
 #include "ISocketHandler.h"
 #include "Socket.h"
 #include "StdoutLog.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
 
+
+
 void StdoutLog::error(ISocketHandler *,Socket *sock,const std::string& call,int err,const std::string& sys_err,loglevel_t lvl)
 {
     time_t t = time(NULL);
@@ -45,6 +56,7 @@ void StdoutLog::error(ISocketHandler *,Socket *sock,const std::string& call,int
     localtime_r(&t, &tp);
 #endif
     std::string level;
+
     switch (lvl)
     {
     case LOG_LEVEL_WARNING:
@@ -81,8 +93,10 @@ void StdoutLog::error(ISocketHandler *,Socket *sock,const std::string& call,int
     }
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
 
+
diff --git a/dep/src/sockets/StreamSocket.cpp b/dep/src/sockets/StreamSocket.cpp
index 84bcf7bdca1..c8a3c32e496 100644
--- a/dep/src/sockets/StreamSocket.cpp
+++ b/dep/src/sockets/StreamSocket.cpp
@@ -1,10 +1,12 @@
 #include "StreamSocket.h"
 #include "ISocketHandler.h"
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 StreamSocket::StreamSocket(ISocketHandler& h) : Socket(h)
 ,m_bConnecting(false)
 ,m_connect_timeout(5)
@@ -18,10 +20,12 @@ StreamSocket::StreamSocket(ISocketHandler& h) : Socket(h)
 {
 }
 
+
 StreamSocket::~StreamSocket()
 {
 }
 
+
 void StreamSocket::SetConnecting(bool x)
 {
     if (x != m_bConnecting)
@@ -38,11 +42,13 @@ void StreamSocket::SetConnecting(bool x)
     }
 }
 
+
 bool StreamSocket::Connecting()
 {
     return m_bConnecting;
 }
 
+
 bool StreamSocket::Ready()
 {
     if (GetSocket() != INVALID_SOCKET && !Connecting() && !CloseAndDelete())
@@ -50,95 +56,115 @@ bool StreamSocket::Ready()
     return false;
 }
 
+
 void StreamSocket::SetConnectTimeout(int x)
 {
     m_connect_timeout = x;
 }
 
+
 int StreamSocket::GetConnectTimeout()
 {
     return m_connect_timeout;
 }
 
+
 void StreamSocket::SetFlushBeforeClose(bool x)
 {
     m_flush_before_close = x;
 }
 
+
 bool StreamSocket::GetFlushBeforeClose()
 {
     return m_flush_before_close;
 }
 
+
 int StreamSocket::GetConnectionRetry()
 {
     return m_connection_retry;
 }
 
+
 void StreamSocket::SetConnectionRetry(int x)
 {
     m_connection_retry = x;
 }
 
+
 int StreamSocket::GetConnectionRetries()
 {
     return m_retries;
 }
 
+
 void StreamSocket::IncreaseConnectionRetries()
 {
     m_retries++;
 }
 
+
 void StreamSocket::ResetConnectionRetries()
 {
     m_retries = 0;
 }
 
+
 void StreamSocket::SetCallOnConnect(bool x)
 {
     Handler().AddList(GetSocket(), LIST_CALLONCONNECT, x);
     m_call_on_connect = x;
 }
 
+
 bool StreamSocket::CallOnConnect()
 {
     return m_call_on_connect;
 }
 
+
 void StreamSocket::SetRetryClientConnect(bool x)
 {
     Handler().AddList(GetSocket(), LIST_RETRY, x);
     m_b_retry_connect = x;
 }
 
+
 bool StreamSocket::RetryClientConnect()
 {
     return m_b_retry_connect;
 }
 
+
 void StreamSocket::SetLineProtocol(bool x)
 {
     m_line_protocol = x;
 }
 
+
 bool StreamSocket::LineProtocol()
 {
     return m_line_protocol;
 }
 
+
 void StreamSocket::SetShutdown(int x)
 {
     m_shutdown = x;
 }
 
+
 int StreamSocket::GetShutdown()
 {
     return m_shutdown;
 }
 
 
+
+
 #ifdef SOCKETS_NAMESPACE
 } // namespace SOCKETS_NAMESPACE {
 #endif
 
+
diff --git a/dep/src/sockets/TcpSocket.cpp b/dep/src/sockets/TcpSocket.cpp
index 902f631a6af..c4efa05d5bf 100644
--- a/dep/src/sockets/TcpSocket.cpp
+++ b/dep/src/sockets/TcpSocket.cpp
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -41,27 +46,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #endif
 #include 
 #include 
+
 #include "TcpSocket.h"
 #include "Utility.h"
 #include "Ipv4Address.h"
 #include "Ipv6Address.h"
 #include "Mutex.h"
 #include "IFile.h"
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 //#ifdef _DEBUG
 //#define DEB(x) x
 //#else
 #define DEB(x)
 //#endif
 
+
 // statics
 #ifdef HAVE_OPENSSL
 SSLInitializer TcpSocket::m_ssl_init;
 #endif
 
+
 // thanks, q
 #ifdef _MSC_VER
 #pragma warning(disable:4355)
@@ -99,6 +109,7 @@ TcpSocket::TcpSocket(ISocketHandler& h) : StreamSocket(h)
 #pragma warning(default:4355)
 #endif
 
+
 #ifdef _MSC_VER
 #pragma warning(disable:4355)
 #endif
@@ -135,6 +146,7 @@ TcpSocket::TcpSocket(ISocketHandler& h,size_t isize,size_t osize) : StreamSocket
 #pragma warning(default:4355)
 #endif
 
+
 TcpSocket::~TcpSocket()
 {
 #ifdef SOCKETS_DYNAMIC_TEMP
@@ -156,6 +168,7 @@ TcpSocket::~TcpSocket()
 #endif
 }
 
+
 bool TcpSocket::Open(ipaddr_t ip,port_t port,bool skip_socks)
 {
     Ipv4Address ad(ip, port);
@@ -163,6 +176,7 @@ bool TcpSocket::Open(ipaddr_t ip,port_t port,bool skip_socks)
     return Open(ad, local, skip_socks);
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 bool TcpSocket::Open(in6_addr ip,port_t port,bool skip_socks)
@@ -173,12 +187,14 @@ bool TcpSocket::Open(in6_addr ip,port_t port,bool skip_socks)
 #endif
 #endif
 
+
 bool TcpSocket::Open(SocketAddress& ad,bool skip_socks)
 {
     Ipv4Address bind_ad("0.0.0.0", 0);
     return Open(ad, bind_ad, skip_socks);
 }
 
+
 bool TcpSocket::Open(SocketAddress& ad,SocketAddress& bind_ad,bool skip_socks)
 {
     if (!ad.IsValid())
@@ -206,6 +222,7 @@ bool TcpSocket::Open(SocketAddress& ad,SocketAddress& bind_ad,bool skip_socks)
         {
             CopyConnection( pools );
             delete pools;
+
             SetIsClient();
             SetCallOnConnect(); // ISocketHandler must call OnConnect
             Handler().LogError(this, "SetCallOnConnect", 0, "Found pooled connection", LOG_LEVEL_INFO);
@@ -297,11 +314,13 @@ bool TcpSocket::Open(SocketAddress& ad,SocketAddress& bind_ad,bool skip_socks)
         Attach(s);
         SetCallOnConnect(); // ISocketHandler must call OnConnect
     }
+
     // 'true' means connected or connecting(not yet connected)
     // 'false' means something failed
     return true; //!Connecting();
 }
 
+
 bool TcpSocket::Open(const std::string &host,port_t port)
 {
 #ifdef ENABLE_IPV6
@@ -350,6 +369,7 @@ bool TcpSocket::Open(const std::string &host,port_t port)
 #endif
 }
 
+
 #ifdef ENABLE_RESOLVER
 void TcpSocket::OnResolved(int id,ipaddr_t a,port_t port)
 {
@@ -381,6 +401,7 @@ DEB(    fprintf(stderr, "TcpSocket::OnResolved id %d addr %x port %d\n", id, a,
     }
 }
 
+
 #ifdef ENABLE_IPV6
 void TcpSocket::OnResolved(int id,in6_addr& a,port_t port)
 {
@@ -408,6 +429,7 @@ void TcpSocket::OnResolved(int id,in6_addr& a,port_t port)
 #endif
 #endif
 
+
 void TcpSocket::OnRead()
 {
     int n = 0;
@@ -520,6 +542,7 @@ DEB(                fprintf(stderr, "SSL read problem, errcode = %d\n",n);)
     OnRead( buf, n );
 }
 
+
 void TcpSocket::OnRead( char *buf, size_t n )
 {
     // unbuffered
@@ -597,15 +620,18 @@ void TcpSocket::OnRead( char *buf, size_t n )
 #endif
 }
 
+
 void TcpSocket::OnWriteComplete()
 {
 }
 
+
 void TcpSocket::OnWrite()
 {
     if (Connecting())
     {
         int err = SoError();
+
         // don't reset connecting flag on error here, we want the OnConnectFailed timeout later on
         if (!err) // ok
         {
@@ -616,6 +642,7 @@ void TcpSocket::OnWrite()
         }
         Handler().LogError(this, "tcp: connect failed", err, StrError(err), LOG_LEVEL_FATAL);
         Set(false, false); // no more monitoring because connection failed
+
         // failed
 #ifdef ENABLE_SOCKS4
         if (Socks4())
@@ -643,6 +670,7 @@ void TcpSocket::OnWrite()
     // try send next block in buffer
     // if full block is sent, repeat
     // if all blocks are sent, reset m_wfds
+
     bool repeat = false;
     size_t sz = m_transfer_limit ? GetOutputLength() : 0;
     do
@@ -671,10 +699,12 @@ void TcpSocket::OnWrite()
             }
         }
     } while (repeat);
+
     if (m_transfer_limit && sz > m_transfer_limit && GetOutputLength() < m_transfer_limit)
     {
         OnTransferLimit();
     }
+
     // check output buffer set, set/reset m_wfds accordingly
     {
         bool br;
@@ -688,6 +718,7 @@ void TcpSocket::OnWrite()
     }
 }
 
+
 int TcpSocket::TryWrite(const char *buf, size_t len)
 {
     int n = 0;
@@ -756,6 +787,7 @@ DEB(            int errnr = SSL_get_error(m_ssl, n);
     return n;
 }
 
+
 void TcpSocket::Buffer(const char *buf, size_t len)
 {
     size_t ptr = 0;
@@ -787,11 +819,13 @@ void TcpSocket::Buffer(const char *buf, size_t len)
     }
 }
 
+
 void TcpSocket::Send(const std::string &str,int i)
 {
     SendBuf(str.c_str(),str.size(),i);
 }
 
+
 void TcpSocket::SendBuf(const char *buf,size_t len,int)
 {
     if (!Ready() && !Connecting())
@@ -828,6 +862,7 @@ void TcpSocket::SendBuf(const char *buf,size_t len,int)
     // else
     // try_send
     // if any data is unsent, buffer it and set m_wfds
+
     // check output buffer set, set/reset m_wfds accordingly
     {
         bool br;
@@ -841,10 +876,12 @@ void TcpSocket::SendBuf(const char *buf,size_t len,int)
     }
 }
 
+
 void TcpSocket::OnLine(const std::string& )
 {
 }
 
+
 #ifdef _MSC_VER
 #pragma warning(disable:4355)
 #endif
@@ -857,6 +894,7 @@ TcpSocket::TcpSocket(const TcpSocket& s)
 #pragma warning(default:4355)
 #endif
 
+
 #ifdef ENABLE_SOCKS4
 void TcpSocket::OnSocks4Connect()
 {
@@ -891,6 +929,7 @@ void TcpSocket::OnSocks4Connect()
     m_socks4_state = 0;
 }
 
+
 void TcpSocket::OnSocks4ConnectFailed()
 {
     Handler().LogError(this,"OnSocks4ConnectFailed",0,"connection to socks4 server failed, trying direct connection",LOG_LEVEL_WARNING);
@@ -906,6 +945,7 @@ void TcpSocket::OnSocks4ConnectFailed()
     }
 }
 
+
 bool TcpSocket::OnSocks4Read()
 {
     switch (m_socks4_state)
@@ -934,6 +974,7 @@ bool TcpSocket::OnSocks4Read()
         {
             ibuf.Read( (char *)&m_socks4_dstip, 4);
             SetSocks4(false);
+
             switch (m_socks4_cd)
             {
             case 90:
@@ -964,6 +1005,7 @@ bool TcpSocket::OnSocks4Read()
 }
 #endif
 
+
 void TcpSocket::Sendf(const char *format, ...)
 {
     va_list ap;
@@ -978,6 +1020,7 @@ void TcpSocket::Sendf(const char *format, ...)
     Send( slask );
 }
 
+
 #ifdef HAVE_OPENSSL
 void TcpSocket::OnSSLConnect()
 {
@@ -1021,6 +1064,7 @@ DEB(            fprintf(stderr, " m_sbio is NULL\n");)
     }
 }
 
+
 void TcpSocket::OnSSLAccept()
 {
     SetNonblocking(true);
@@ -1059,6 +1103,7 @@ DEB(            fprintf(stderr, " m_sbio is NULL\n");)
     }
 }
 
+
 bool TcpSocket::SSLNegotiate()
 {
     if (!IsSSLServer()) // client
@@ -1155,17 +1200,20 @@ DEB(                fprintf(stderr, "SSL_accept() failed - closing socket, retur
     return false;
 }
 
+
 void TcpSocket::InitSSLClient()
 {
     InitializeContext("", SSLv23_method());
 }
 
+
 void TcpSocket::InitSSLServer()
 {
     Handler().LogError(this, "InitSSLServer", 0, "You MUST implement your own InitSSLServer method", LOG_LEVEL_FATAL);
     SetCloseAndDelete();
 }
 
+
 void TcpSocket::InitializeContext(const std::string& context, SSL_METHOD *meth_in)
 {
     /* Create our context*/
@@ -1182,6 +1230,7 @@ void TcpSocket::InitializeContext(const std::string& context, SSL_METHOD *meth_i
     }
 }
 
+
 void TcpSocket::InitializeContext(const std::string& context,const std::string& keyfile,const std::string& password,SSL_METHOD *meth_in)
 {
     /* Create our context*/
@@ -1201,11 +1250,13 @@ void TcpSocket::InitializeContext(const std::string& context,const std::string&
     {
         m_ssl_ctx = server_contexts[context];
     }
+
     /* Load our keys and certificates*/
     if (!(SSL_CTX_use_certificate_file(m_ssl_ctx, keyfile.c_str(), SSL_FILETYPE_PEM)))
     {
         Handler().LogError(this, "TcpSocket InitializeContext", 0, "Couldn't read certificate file " + keyfile, LOG_LEVEL_FATAL);
     }
+
     m_password = password;
     SSL_CTX_set_default_passwd_cb(m_ssl_ctx, SSL_password_cb);
     SSL_CTX_set_default_passwd_cb_userdata(m_ssl_ctx, this);
@@ -1215,6 +1266,7 @@ void TcpSocket::InitializeContext(const std::string& context,const std::string&
     }
 }
 
+
 void TcpSocket::InitializeContext(const std::string& context,const std::string& certfile,const std::string& keyfile,const std::string& password,SSL_METHOD *meth_in)
 {
     /* Create our context*/
@@ -1234,11 +1286,13 @@ void TcpSocket::InitializeContext(const std::string& context,const std::string&
     {
         m_ssl_ctx = server_contexts[context];
     }
+
     /* Load our keys and certificates*/
     if (!(SSL_CTX_use_certificate_file(m_ssl_ctx, certfile.c_str(), SSL_FILETYPE_PEM)))
     {
         Handler().LogError(this, "TcpSocket InitializeContext", 0, "Couldn't read certificate file " + keyfile, LOG_LEVEL_FATAL);
     }
+
     m_password = password;
     SSL_CTX_set_default_passwd_cb(m_ssl_ctx, SSL_password_cb);
     SSL_CTX_set_default_passwd_cb_userdata(m_ssl_ctx, this);
@@ -1248,6 +1302,7 @@ void TcpSocket::InitializeContext(const std::string& context,const std::string&
     }
 }
 
+
 int TcpSocket::SSL_password_cb(char *buf,int num,int rwflag,void *userdata)
 {
     Socket *p0 = static_cast(userdata);
@@ -1262,6 +1317,7 @@ int TcpSocket::SSL_password_cb(char *buf,int num,int rwflag,void *userdata)
 }
 #endif // HAVE_OPENSSL
 
+
 int TcpSocket::Close()
 {
     if (GetSocket() == INVALID_SOCKET) // this could happen
@@ -1300,6 +1356,7 @@ int TcpSocket::Close()
     return Socket::Close();
 }
 
+
 #ifdef HAVE_OPENSSL
 SSL_CTX *TcpSocket::GetSslContext()
 {
@@ -1307,6 +1364,7 @@ SSL_CTX *TcpSocket::GetSslContext()
         Handler().LogError(this, "GetSslContext", 0, "SSL Context is NULL; check InitSSLServer/InitSSLClient", LOG_LEVEL_WARNING);
     return m_ssl_ctx;
 }
+
 SSL *TcpSocket::GetSsl()
 {
     if (!m_ssl)
@@ -1315,6 +1373,7 @@ SSL *TcpSocket::GetSsl()
 }
 #endif
 
+
 #ifdef ENABLE_RECONNECT
 void TcpSocket::SetReconnect(bool x)
 {
@@ -1322,20 +1381,24 @@ void TcpSocket::SetReconnect(bool x)
 }
 #endif
 
+
 void TcpSocket::OnRawData(const char *buf_in,size_t len)
 {
 }
 
+
 size_t TcpSocket::GetInputLength()
 {
     return ibuf.GetLength();
 }
 
+
 size_t TcpSocket::GetOutputLength()
 {
     return m_output_length;
 }
 
+
 uint64_t TcpSocket::GetBytesReceived(bool clear)
 {
     uint64_t z = m_bytes_received;
@@ -1344,6 +1407,7 @@ uint64_t TcpSocket::GetBytesReceived(bool clear)
     return z;
 }
 
+
 uint64_t TcpSocket::GetBytesSent(bool clear)
 {
     uint64_t z = m_bytes_sent;
@@ -1352,23 +1416,27 @@ uint64_t TcpSocket::GetBytesSent(bool clear)
     return z;
 }
 
+
 #ifdef ENABLE_RECONNECT
 bool TcpSocket::Reconnect()
 {
     return m_b_reconnect;
 }
 
+
 void TcpSocket::SetIsReconnect(bool x)
 {
     m_b_is_reconnect = x;
 }
 
+
 bool TcpSocket::IsReconnect()
 {
     return m_b_is_reconnect;
 }
 #endif
 
+
 #ifdef HAVE_OPENSSL
 const std::string& TcpSocket::GetPassword()
 {
@@ -1376,11 +1444,13 @@ const std::string& TcpSocket::GetPassword()
 }
 #endif
 
+
 void TcpSocket::DisableInputBuffer(bool x)
 {
     m_b_input_buffer_disabled = x;
 }
 
+
 void TcpSocket::OnOptions(int family,int type,int protocol,SOCKET s)
 {
 DEB(    fprintf(stderr, "Socket::OnOptions()\n");)
@@ -1391,12 +1461,14 @@ DEB(    fprintf(stderr, "Socket::OnOptions()\n");)
     SetSoKeepalive(true);
 }
 
+
 void TcpSocket::SetLineProtocol(bool x)
 {
     StreamSocket::SetLineProtocol(x);
     DisableInputBuffer(x);
 }
 
+
 bool TcpSocket::SetTcpNodelay(bool x)
 {
 #ifdef TCP_NODELAY
@@ -1413,6 +1485,7 @@ bool TcpSocket::SetTcpNodelay(bool x)
 #endif
 }
 
+
 TcpSocket::CircularBuffer::CircularBuffer(size_t size)
 :buf(new char[2 * size])
 ,m_max(size)
@@ -1423,11 +1496,13 @@ TcpSocket::CircularBuffer::CircularBuffer(size_t size)
 {
 }
 
+
 TcpSocket::CircularBuffer::~CircularBuffer()
 {
     delete[] buf;
 }
 
+
 bool TcpSocket::CircularBuffer::Write(const char *s,size_t l)
 {
     if (m_q + l > m_max)
@@ -1457,6 +1532,7 @@ bool TcpSocket::CircularBuffer::Write(const char *s,size_t l)
     return true;
 }
 
+
 bool TcpSocket::CircularBuffer::Read(char *s,size_t l)
 {
     if (l > m_q)
@@ -1491,6 +1567,7 @@ bool TcpSocket::CircularBuffer::Read(char *s,size_t l)
     }
     return true;
 }
+
 bool TcpSocket::CircularBuffer::SoftRead(char *s, size_t l)
 {
     if (l > m_q)
@@ -1515,31 +1592,37 @@ bool TcpSocket::CircularBuffer::SoftRead(char *s, size_t l)
     }
     return true;
 }
+
 bool TcpSocket::CircularBuffer::Remove(size_t l)
 {
     return Read(NULL, l);
 }
 
+
 size_t TcpSocket::CircularBuffer::GetLength()
 {
     return m_q;
 }
 
+
 const char *TcpSocket::CircularBuffer::GetStart()
 {
     return buf + m_b;
 }
 
+
 size_t TcpSocket::CircularBuffer::GetL()
 {
     return (m_b + m_q > m_max) ? m_max - m_b : m_q;
 }
 
+
 size_t TcpSocket::CircularBuffer::Space()
 {
     return m_max - m_q;
 }
 
+
 unsigned long TcpSocket::CircularBuffer::ByteCounter(bool clear)
 {
     if (clear)
@@ -1551,6 +1634,7 @@ unsigned long TcpSocket::CircularBuffer::ByteCounter(bool clear)
     return m_count;
 }
 
+
 std::string TcpSocket::CircularBuffer::ReadString(size_t l)
 {
     char *sz = new char[l + 1];
@@ -1565,6 +1649,7 @@ std::string TcpSocket::CircularBuffer::ReadString(size_t l)
     return tmp;
 }
 
+
 void TcpSocket::OnConnectTimeout()
 {
     Handler().LogError(this, "connect", -1, "connect timeout", LOG_LEVEL_FATAL);
@@ -1602,6 +1687,7 @@ void TcpSocket::OnConnectTimeout()
     SetConnecting(false);
 }
 
+
 #ifdef _WIN32
 void TcpSocket::OnException()
 {
@@ -1637,21 +1723,26 @@ void TcpSocket::OnException()
 }
 #endif // _WIN32
 
+
 int TcpSocket::Protocol()
 {
     return IPPROTO_TCP;
 }
 
+
 void TcpSocket::SetTransferLimit(size_t sz)
 {
     m_transfer_limit = sz;
 }
 
+
 void TcpSocket::OnTransferLimit()
 {
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
diff --git a/dep/src/sockets/Thread.cpp b/dep/src/sockets/Thread.cpp
index 713c02b3f52..a387a7e3824 100644
--- a/dep/src/sockets/Thread.cpp
+++ b/dep/src/sockets/Thread.cpp
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -29,12 +34,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #else
 #include 
 #endif
+
 #include "Thread.h"
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 Thread::Thread(bool release)
 :m_thread(0)
 ,m_running(true)
@@ -47,6 +55,7 @@ Thread::Thread(bool release)
     m_thread = (HANDLE)_beginthreadex(NULL, 0, &StartThread, this, 0, &m_dwThreadId);
 #else
     pthread_attr_t attr;
+
     pthread_attr_init(&attr);
     pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
     if (pthread_create(&m_thread,&attr, StartThread,this) == -1)
@@ -59,6 +68,7 @@ Thread::Thread(bool release)
     m_release = release;
 }
 
+
 Thread::~Thread()
 {
     m_b_destructor = true;
@@ -78,9 +88,11 @@ Thread::~Thread()
 #endif
 }
 
+
 threadfunc_t STDPREFIX Thread::StartThread(threadparam_t zz)
 {
     Thread *p = (Thread *)zz;
+
     while (p -> m_running && !p -> m_release)
     {
 #ifdef _WIN32
@@ -104,43 +116,52 @@ threadfunc_t STDPREFIX Thread::StartThread(threadparam_t zz)
     return (threadfunc_t)NULL;
 }
 
+
 bool Thread::IsRunning()
 {
     return m_running;
 }
 
+
 void Thread::SetRunning(bool x)
 {
     m_running = x;
 }
 
+
 bool Thread::IsReleased()
 {
     return m_release;
 }
 
+
 void Thread::SetRelease(bool x)
 {
     m_release = x;
 }
 
+
 bool Thread::DeleteOnExit()
 {
     return m_b_delete_on_exit;
 }
 
+
 void Thread::SetDeleteOnExit(bool x)
 {
     m_b_delete_on_exit = x;
 }
 
+
 bool Thread::IsDestructor()
 {
     return m_b_destructor;
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
 
+
diff --git a/dep/src/sockets/UdpSocket.cpp b/dep/src/sockets/UdpSocket.cpp
index f1abe54a1a8..f4c3d2f9657 100644
--- a/dep/src/sockets/UdpSocket.cpp
+++ b/dep/src/sockets/UdpSocket.cpp
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -30,6 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #else
 #include 
 #endif
+
 #include "ISocketHandler.h"
 #include "UdpSocket.h"
 #include "Utility.h"
@@ -41,10 +47,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // include this to see strange sights
 //#include 
 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 UdpSocket::UdpSocket(ISocketHandler& h, int ibufsz, bool ipv6, int retries) : Socket(h)
 , m_ibuf(new char[ibufsz])
 , m_ibufsz(ibufsz)
@@ -61,12 +69,14 @@ UdpSocket::UdpSocket(ISocketHandler& h, int ibufsz, bool ipv6, int retries) : So
 #endif
 }
 
+
 UdpSocket::~UdpSocket()
 {
     Close();
     delete[] m_ibuf;
 }
 
+
 int UdpSocket::Bind(port_t &port, int range)
 {
 #ifdef ENABLE_IPV6
@@ -82,6 +92,7 @@ int UdpSocket::Bind(port_t &port, int range)
     return Bind(ad, range);
 }
 
+
 int UdpSocket::Bind(const std::string& intf, port_t &port, int range)
 {
 #ifdef ENABLE_IPV6
@@ -107,12 +118,14 @@ int UdpSocket::Bind(const std::string& intf, port_t &port, int range)
     return -1;
 }
 
+
 int UdpSocket::Bind(ipaddr_t a, port_t &port, int range)
 {
     Ipv4Address ad(a, port);
     return Bind(ad, range);
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 int UdpSocket::Bind(in6_addr a, port_t &port, int range)
@@ -123,6 +136,7 @@ int UdpSocket::Bind(in6_addr a, port_t &port, int range)
 #endif
 #endif
 
+
 int UdpSocket::Bind(SocketAddress& ad, int range)
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -155,6 +169,7 @@ int UdpSocket::Bind(SocketAddress& ad, int range)
     return -1;
 }
 
+
 /** if you wish to use Send, first Open a connection */
 bool UdpSocket::Open(ipaddr_t l, port_t port)
 {
@@ -162,6 +177,7 @@ bool UdpSocket::Open(ipaddr_t l, port_t port)
     return Open(ad);
 }
 
+
 bool UdpSocket::Open(const std::string& host, port_t port)
 {
 #ifdef ENABLE_IPV6
@@ -185,6 +201,7 @@ bool UdpSocket::Open(const std::string& host, port_t port)
     return false;
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 bool UdpSocket::Open(struct in6_addr& a, port_t port)
@@ -195,6 +212,7 @@ bool UdpSocket::Open(struct in6_addr& a, port_t port)
 #endif
 #endif
 
+
 bool UdpSocket::Open(SocketAddress& ad)
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -216,6 +234,7 @@ bool UdpSocket::Open(SocketAddress& ad)
     return false;
 }
 
+
 void UdpSocket::CreateConnection()
 {
 #ifdef ENABLE_IPV6
@@ -248,6 +267,7 @@ void UdpSocket::CreateConnection()
     }
 }
 
+
 /** send to specified address */
 void UdpSocket::SendToBuf(const std::string& h, port_t p, const char *data, int len, int flags)
 {
@@ -271,6 +291,7 @@ void UdpSocket::SendToBuf(const std::string& h, port_t p, const char *data, int
     }
 }
 
+
 /** send to specified address */
 void UdpSocket::SendToBuf(ipaddr_t a, port_t p, const char *data, int len, int flags)
 {
@@ -278,6 +299,7 @@ void UdpSocket::SendToBuf(ipaddr_t a, port_t p, const char *data, int len, int f
     SendToBuf(ad, data, len, flags);
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 void UdpSocket::SendToBuf(in6_addr a, port_t p, const char *data, int len, int flags)
@@ -288,6 +310,7 @@ void UdpSocket::SendToBuf(in6_addr a, port_t p, const char *data, int len, int f
 #endif
 #endif
 
+
 void UdpSocket::SendToBuf(SocketAddress& ad, const char *data, int len, int flags)
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -304,16 +327,19 @@ void UdpSocket::SendToBuf(SocketAddress& ad, const char *data, int len, int flag
     }
 }
 
+
 void UdpSocket::SendTo(const std::string& a, port_t p, const std::string& str, int flags)
 {
     SendToBuf(a, p, str.c_str(), (int)str.size(), flags);
 }
 
+
 void UdpSocket::SendTo(ipaddr_t a, port_t p, const std::string& str, int flags)
 {
     SendToBuf(a, p, str.c_str(), (int)str.size(), flags);
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 void UdpSocket::SendTo(in6_addr a, port_t p, const std::string& str, int flags)
@@ -323,11 +349,13 @@ void UdpSocket::SendTo(in6_addr a, port_t p, const std::string& str, int flags)
 #endif
 #endif
 
+
 void UdpSocket::SendTo(SocketAddress& ad, const std::string& str, int flags)
 {
     SendToBuf(ad, str.c_str(), (int)str.size(), flags);
 }
 
+
 /** send to connected address */
 void UdpSocket::SendBuf(const char *data, size_t len, int flags)
 {
@@ -342,11 +370,13 @@ void UdpSocket::SendBuf(const char *data, size_t len, int flags)
     }
 }
 
+
 void UdpSocket::Send(const std::string& str, int flags)
 {
     SendBuf(str.c_str(), (int)str.size(), flags);
 }
 
+
 #if defined(LINUX) || defined(MACOSX)
 int UdpSocket::ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen_t fromlen, struct timeval *ts)
 {
@@ -367,12 +397,15 @@ int UdpSocket::ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen
     } cmsg_un;
     struct cmsghdr *cmsg;
     struct timeval *tv;
+
     vec[0].iov_base = ioBuf;
     vec[0].iov_len = inBufSize;
+
     memset(&msg, 0, sizeof(msg));
     memset(from, 0, fromlen);
     memset(ioBuf, 0, inBufSize);
     memset(&cmsg_un, 0, sizeof(cmsg_un));
+
     msg.msg_name = (caddr_t)from;
     msg.msg_namelen = fromlen;
     msg.msg_iov = vec;
@@ -380,10 +413,14 @@ int UdpSocket::ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen
     msg.msg_control = cmsg_un.data;
     msg.msg_controllen = sizeof(cmsg_un.data);
     msg.msg_flags = 0;
+
     // Original version - for reference only
     //int n = recvfrom(GetSocket(), m_ibuf, m_ibufsz, 0, (struct sockaddr *)&sa, &sa_len);
+
     int n = recvmsg(GetSocket(), &msg, MSG_DONTWAIT);
+
     // now ioBuf will contain the data, as if we used recvfrom
+
     // Now get the time
     if(n != -1 && msg.msg_controllen >= sizeof(struct cmsghdr) && !(msg.msg_flags & MSG_CTRUNC))
     {
@@ -405,6 +442,7 @@ int UdpSocket::ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen
 }
 #endif
 
+
 void UdpSocket::OnRead()
 {
 #ifdef ENABLE_IPV6
@@ -517,10 +555,12 @@ void UdpSocket::OnRead()
     }
 }
 
+
 void UdpSocket::SetBroadcast(bool b)
 {
     int one = 1;
     int zero = 0;
+
     if (GetSocket() == INVALID_SOCKET)
     {
         CreateConnection();
@@ -541,10 +581,12 @@ void UdpSocket::SetBroadcast(bool b)
     }
 }
 
+
 bool UdpSocket::IsBroadcast()
 {
     int is_broadcast = 0;
     socklen_t size;
+
     if (GetSocket() == INVALID_SOCKET)
     {
         CreateConnection();
@@ -556,6 +598,7 @@ bool UdpSocket::IsBroadcast()
     return is_broadcast != 0;
 }
 
+
 void UdpSocket::SetMulticastTTL(int ttl)
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -568,10 +611,12 @@ void UdpSocket::SetMulticastTTL(int ttl)
     }
 }
 
+
 int UdpSocket::GetMulticastTTL()
 {
     int ttl = 0;
     socklen_t size = sizeof(int);
+
     if (GetSocket() == INVALID_SOCKET)
     {
         CreateConnection();
@@ -583,6 +628,7 @@ int UdpSocket::GetMulticastTTL()
     return ttl;
 }
 
+
 void UdpSocket::SetMulticastLoop(bool x)
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -609,6 +655,7 @@ void UdpSocket::SetMulticastLoop(bool x)
     }
 }
 
+
 bool UdpSocket::IsMulticastLoop()
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -638,6 +685,7 @@ bool UdpSocket::IsMulticastLoop()
     return is_loop ? true : false;
 }
 
+
 void UdpSocket::AddMulticastMembership(const std::string& group, const std::string& local_if, int if_index)
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -678,6 +726,7 @@ void UdpSocket::AddMulticastMembership(const std::string& group, const std::stri
     }
 }
 
+
 void UdpSocket::DropMulticastMembership(const std::string& group, const std::string& local_if, int if_index)
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -718,6 +767,7 @@ void UdpSocket::DropMulticastMembership(const std::string& group, const std::str
     }
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 void UdpSocket::SetMulticastHops(int hops)
@@ -737,6 +787,7 @@ void UdpSocket::SetMulticastHops(int hops)
     }
 }
 
+
 int UdpSocket::GetMulticastHops()
 {
     if (GetSocket() == INVALID_SOCKET)
@@ -759,36 +810,44 @@ int UdpSocket::GetMulticastHops()
 #endif // IPPROTO_IPV6
 #endif
 
+
 bool UdpSocket::IsBound()
 {
     return m_bind_ok;
 }
 
+
 void UdpSocket::OnRawData(const char *buf, size_t len, struct sockaddr *sa, socklen_t sa_len)
 {
 }
 
+
 void UdpSocket::OnRawData(const char *buf, size_t len, struct sockaddr *sa, socklen_t sa_len, struct timeval *ts)
 {
 }
 
+
 port_t UdpSocket::GetPort()
 {
     return m_port;
 }
 
+
 int UdpSocket::GetLastSizeWritten()
 {
     return m_last_size_written;
 }
 
+
 void UdpSocket::SetTimestamp(bool x)
 {
     m_b_read_ts = x;
 }
 
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
 
+
diff --git a/dep/src/sockets/Utility.cpp b/dep/src/sockets/Utility.cpp
index 70dbfc83595..6473f0a2564 100644
--- a/dep/src/sockets/Utility.cpp
+++ b/dep/src/sockets/Utility.cpp
@@ -4,20 +4,25 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -35,10 +40,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include 
 #endif
 #include 
+
 #ifdef SOCKETS_NAMESPACE
 namespace SOCKETS_NAMESPACE {
 #endif
 
+
 // defines for the random number generator
 #define TWIST_IA        397
 #define TWIST_IB       (TWIST_LEN - TWIST_IA)
@@ -48,6 +55,7 @@ namespace SOCKETS_NAMESPACE {
 #define TWIST(b,i,j)   ((b)[i] & UMASK) | ((b)[j] & LMASK)
 #define MAGIC_TWIST(s) (((s) & 1) * MATRIX_A)
 
+
 // statics
 std::string Utility::m_host;
 bool Utility::m_local_resolved = false;
@@ -60,6 +68,7 @@ std::string Utility::m_local_addr6;
 #endif
 #endif
 
+
 std::string Utility::base64(const std::string& str_in)
 {
     std::string str;
@@ -68,6 +77,7 @@ std::string Utility::base64(const std::string& str_in)
     return str;
 }
 
+
 std::string Utility::base64d(const std::string& str_in)
 {
     std::string str;
@@ -76,6 +86,7 @@ std::string Utility::base64d(const std::string& str_in)
     return str;
 }
 
+
 std::string Utility::l2string(long l)
 {
     std::string str;
@@ -85,6 +96,7 @@ std::string Utility::l2string(long l)
     return str;
 }
 
+
 std::string Utility::bigint2string(uint64_t l)
 {
     std::string str;
@@ -102,6 +114,7 @@ std::string Utility::bigint2string(uint64_t l)
     return str;
 }
 
+
 uint64_t Utility::atoi64(const std::string& str)
 {
     uint64_t l = 0;
@@ -112,6 +125,7 @@ uint64_t Utility::atoi64(const std::string& str)
     return l;
 }
 
+
 unsigned int Utility::hex2unsigned(const std::string& str)
 {
     unsigned int r = 0;
@@ -122,6 +136,7 @@ unsigned int Utility::hex2unsigned(const std::string& str)
     return r;
 }
 
+
 /*
 * Encode string per RFC1738 URL encoding rules
 * tnx rstaveley
@@ -152,6 +167,7 @@ static  char hex[] = "0123456789ABCDEF";
     return dst;
 } // rfc1738_encode
 
+
 /*
 * Decode string per RFC1738 URL encoding rules
 * tnx rstaveley
@@ -182,6 +198,7 @@ std::string Utility::rfc1738_decode(const std::string& src)
     return dst;
 } // rfc1738_decode
 
+
 bool Utility::isipv4(const std::string& str)
 {
     int dots = 0;
@@ -199,6 +216,7 @@ bool Utility::isipv4(const std::string& str)
     return true;
 }
 
+
 bool Utility::isipv6(const std::string& str)
 {
     size_t qc = 0;
@@ -238,6 +256,7 @@ bool Utility::isipv6(const std::string& str)
     return true;
 }
 
+
 bool Utility::u2ip(const std::string& str, ipaddr_t& l)
 {
     struct sockaddr_in sa;
@@ -246,6 +265,7 @@ bool Utility::u2ip(const std::string& str, ipaddr_t& l)
     return r;
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 bool Utility::u2ip(const std::string& str, struct in6_addr& l)
@@ -258,6 +278,7 @@ bool Utility::u2ip(const std::string& str, struct in6_addr& l)
 #endif
 #endif
 
+
 void Utility::l2ip(const ipaddr_t ip, std::string& str)
 {
     struct sockaddr_in sa;
@@ -267,6 +288,7 @@ void Utility::l2ip(const ipaddr_t ip, std::string& str)
     Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), str, NI_NUMERICHOST);
 }
 
+
 void Utility::l2ip(const in_addr& ip, std::string& str)
 {
     struct sockaddr_in sa;
@@ -276,6 +298,7 @@ void Utility::l2ip(const in_addr& ip, std::string& str)
     Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), str, NI_NUMERICHOST);
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 void Utility::l2ip(const struct in6_addr& ip, std::string& str,bool mixed)
@@ -324,6 +347,7 @@ void Utility::l2ip(const struct in6_addr& ip, std::string& str,bool mixed)
     str = slask;
 }
 
+
 int Utility::in6_addr_compare(in6_addr a,in6_addr b)
 {
     for (size_t i = 0; i < 16; i++)
@@ -338,9 +362,11 @@ int Utility::in6_addr_compare(in6_addr a,in6_addr b)
 #endif
 #endif
 
+
 void Utility::ResolveLocal()
 {
     char h[256];
+
     // get local hostname and translate into ip-address
     *h = 0;
     gethostname(h,255);
@@ -365,6 +391,7 @@ void Utility::ResolveLocal()
     m_local_resolved = true;
 }
 
+
 const std::string& Utility::GetLocalHostname()
 {
     if (!m_local_resolved)
@@ -374,6 +401,7 @@ const std::string& Utility::GetLocalHostname()
     return m_host;
 }
 
+
 ipaddr_t Utility::GetLocalIP()
 {
     if (!m_local_resolved)
@@ -383,6 +411,7 @@ ipaddr_t Utility::GetLocalIP()
     return m_ip;
 }
 
+
 const std::string& Utility::GetLocalAddress()
 {
     if (!m_local_resolved)
@@ -392,6 +421,7 @@ const std::string& Utility::GetLocalAddress()
     return m_addr;
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 const struct in6_addr& Utility::GetLocalIP6()
@@ -403,6 +433,7 @@ const struct in6_addr& Utility::GetLocalIP6()
     return m_local_ip6;
 }
 
+
 const std::string& Utility::GetLocalAddress6()
 {
     if (!m_local_resolved)
@@ -414,6 +445,7 @@ const std::string& Utility::GetLocalAddress6()
 #endif
 #endif
 
+
 void Utility::SetEnv(const std::string& var,const std::string& value)
 {
 #if (defined(SOLARIS8) || defined(SOLARIS))
@@ -437,6 +469,7 @@ void Utility::SetEnv(const std::string& var,const std::string& value)
 #endif
 }
 
+
 std::string Utility::Sa2String(struct sockaddr *sa)
 {
 #ifdef ENABLE_IPV6
@@ -462,6 +495,7 @@ std::string Utility::Sa2String(struct sockaddr *sa)
     return "";
 }
 
+
 void Utility::GetTime(struct timeval *p)
 {
 #ifdef _WIN32
@@ -477,6 +511,7 @@ void Utility::GetTime(struct timeval *p)
 #endif
 }
 
+
 std::auto_ptr Utility::CreateAddress(struct sockaddr *sa,socklen_t sa_len)
 {
     switch (sa -> sa_family)
@@ -503,6 +538,7 @@ std::auto_ptr Utility::CreateAddress(struct sockaddr *sa,socklen_
     return std::auto_ptr(NULL);
 }
 
+
 bool Utility::u2ip(const std::string& host, struct sockaddr_in& sa, int ai_flags)
 {
     memset(&sa, 0, sizeof(sa));
@@ -595,6 +631,7 @@ bool Utility::u2ip(const std::string& host, struct sockaddr_in& sa, int ai_flags
 #endif // NO_GETADDRINFO
 }
 
+
 #ifdef ENABLE_IPV6
 #ifdef IPPROTO_IPV6
 bool Utility::u2ip(const std::string& host, struct sockaddr_in6& sa, int ai_flags)
@@ -710,12 +747,14 @@ bool Utility::u2ip(const std::string& host, struct sockaddr_in6& sa, int ai_flag
 #endif // IPPROTO_IPV6
 #endif // ENABLE_IPV6
 
+
 bool Utility::reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, int flags)
 {
     std::string service;
     return Utility::reverse(sa, sa_len, hostname, service, flags);
 }
 
+
 bool Utility::reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, std::string& service, int flags)
 {
     hostname = "";
@@ -831,6 +870,7 @@ bool Utility::reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostna
 #endif // NO_GETADDRINFO
 }
 
+
 bool Utility::u2service(const std::string& name, int& service, int ai_flags)
 {
 #ifdef NO_GETADDRINFO
@@ -863,6 +903,7 @@ bool Utility::u2service(const std::string& name, int& service, int ai_flags)
 #endif // NO_GETADDRINFO
 }
 
+
 unsigned long Utility::ThreadID()
 {
 #ifdef _WIN32
@@ -872,6 +913,7 @@ unsigned long Utility::ThreadID()
 #endif
 }
 
+
 std::string Utility::ToLower(const std::string& str)
 {
     std::string r;
@@ -885,6 +927,7 @@ std::string Utility::ToLower(const std::string& str)
     return r;
 }
 
+
 std::string Utility::ToUpper(const std::string& str)
 {
     std::string r;
@@ -898,6 +941,7 @@ std::string Utility::ToUpper(const std::string& str)
     return r;
 }
 
+
 std::string Utility::ToString(double d)
 {
     char tmp[100];
@@ -905,12 +949,14 @@ std::string Utility::ToString(double d)
     return tmp;
 }
 
+
 unsigned long Utility::Rnd()
 {
 static  Utility::Rng generator( (unsigned long)time(NULL) );
     return generator.Get();
 }
 
+
 Utility::Rng::Rng(unsigned long seed) : m_value( 0 )
 {
     m_tmp[0]= seed & 0xffffffffUL;
@@ -920,6 +966,7 @@ Utility::Rng::Rng(unsigned long seed) : m_value( 0 )
     }
 }
 
+
 unsigned long Utility::Rng::Get()
 {
     unsigned long val = m_tmp[m_value];
@@ -940,11 +987,14 @@ unsigned long Utility::Rng::Get()
         }
         unsigned long s = TWIST(m_tmp, TWIST_LEN - 1, 0);
         m_tmp[TWIST_LEN - 1] = m_tmp[TWIST_IA - 1] ^ (s >> 1) ^ MAGIC_TWIST(s);
+
         m_value = 0;
     }
     return val;
 }
+
 #ifdef SOCKETS_NAMESPACE
 }
 #endif
 
+
diff --git a/dep/src/sockets/socket_include.cpp b/dep/src/sockets/socket_include.cpp
index 171b5c39a23..133ff745d91 100644
--- a/dep/src/sockets/socket_include.cpp
+++ b/dep/src/sockets/socket_include.cpp
@@ -4,25 +4,31 @@
 **/
 /*
 Copyright (C) 2004-2007  Anders Hedstrom
+
 This library is made available under the terms of the GNU GPL.
+
 If you would like to use this library in a closed-source application,
 a separate license agreement is available. For information about
 the closed-source license agreement for the C++ sockets library,
 please visit http://www.alhem.net/Sockets/license.html and/or
 email license@alhem.net.
+
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
+
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
+
 You should have received a copy of the GNU General Public 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 
+
 // only to be included in win32 projects
 const char *StrError(int x)
 {
@@ -72,6 +78,7 @@ static  char tmp[100];
     case 11002: return "Nonauthoritative host not found.";
     case 11003: return "This is a nonrecoverable error.";
     case 11004: return "Valid name, no data record of requested type.";
+
     default:
         break;
     }
@@ -80,3 +87,5 @@ static  char tmp[100];
 }
 
 
+
+
diff --git a/dep/src/zlib/adler32.c b/dep/src/zlib/adler32.c
index 483da9c58c0..007ba26277c 100644
--- a/dep/src/zlib/adler32.c
+++ b/dep/src/zlib/adler32.c
@@ -2,17 +2,22 @@
  * Copyright (C) 1995-2004 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* @(#) $Id$ */
+
 #define ZLIB_INTERNAL
 #include "zlib.h"
+
 #define BASE 65521UL    /* largest prime smaller than 65536 */
 #define NMAX 5552
 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
+
 #define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
 #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
 #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
 #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
 #define DO16(buf)   DO8(buf,0); DO8(buf,8);
+
 /* use NO_DIVIDE if your processor does not do division in hardware */
 #ifdef NO_DIVIDE
 #  define MOD(a) \
@@ -47,6 +52,7 @@
 #  define MOD(a) a %= BASE
 #  define MOD4(a) a %= BASE
 #endif
+
 /* ========================================================================= */
 uLong ZEXPORT adler32(adler, buf, len)
     uLong adler;
@@ -55,9 +61,11 @@ uLong ZEXPORT adler32(adler, buf, len)
 {
     unsigned long sum2;
     unsigned n;
+
     /* split Adler-32 into component sums */
     sum2 = (adler >> 16) & 0xffff;
     adler &= 0xffff;
+
     /* in case user likes doing a byte at a time, keep it fast */
     if (len == 1) {
         adler += buf[0];
@@ -68,9 +76,11 @@ uLong ZEXPORT adler32(adler, buf, len)
             sum2 -= BASE;
         return adler | (sum2 << 16);
     }
+
     /* initial Adler-32 value (deferred check for len == 1 speed) */
     if (buf == Z_NULL)
         return 1L;
+
     /* in case short lengths are provided, keep it somewhat fast */
     if (len < 16) {
         while (len--) {
@@ -82,6 +92,7 @@ uLong ZEXPORT adler32(adler, buf, len)
         MOD4(sum2);             /* only added so many BASE's */
         return adler | (sum2 << 16);
     }
+
     /* do length NMAX blocks -- requires just one modulo operation */
     while (len >= NMAX) {
         len -= NMAX;
@@ -93,6 +104,7 @@ uLong ZEXPORT adler32(adler, buf, len)
         MOD(adler);
         MOD(sum2);
     }
+
     /* do remaining bytes (less than NMAX, still just one modulo) */
     if (len) {                  /* avoid modulos if none remaining */
         while (len >= 16) {
@@ -107,9 +119,11 @@ uLong ZEXPORT adler32(adler, buf, len)
         MOD(adler);
         MOD(sum2);
     }
+
     /* return recombined sums */
     return adler | (sum2 << 16);
 }
+
 /* ========================================================================= */
 uLong ZEXPORT adler32_combine(adler1, adler2, len2)
     uLong adler1;
@@ -119,6 +133,7 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
     unsigned long sum1;
     unsigned long sum2;
     unsigned rem;
+
     /* the derivation of this formula is left as an exercise for the reader */
     rem = (unsigned)(len2 % BASE);
     sum1 = adler1 & 0xffff;
diff --git a/dep/src/zlib/compress.c b/dep/src/zlib/compress.c
index 488bfa6cda9..df04f0148e6 100644
--- a/dep/src/zlib/compress.c
+++ b/dep/src/zlib/compress.c
@@ -2,15 +2,19 @@
  * Copyright (C) 1995-2003 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* @(#) $Id$ */
+
 #define ZLIB_INTERNAL
 #include "zlib.h"
+
 /* ===========================================================================
      Compresses the source buffer into the destination buffer. The level
    parameter has the same meaning as in deflateInit.  sourceLen is the byte
    length of the source buffer. Upon entry, destLen is the total size of the
    destination buffer, which must be at least 0.1% larger than sourceLen plus
    12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
+
      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
    Z_STREAM_ERROR if the level parameter is invalid.
@@ -24,6 +28,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
 {
     z_stream stream;
     int err;
+
     stream.next_in = (Bytef*)source;
     stream.avail_in = (uInt)sourceLen;
 #ifdef MAXSEG_64K
@@ -33,20 +38,25 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
     stream.next_out = dest;
     stream.avail_out = (uInt)*destLen;
     if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+
     stream.zalloc = (alloc_func)0;
     stream.zfree = (free_func)0;
     stream.opaque = (voidpf)0;
+
     err = deflateInit(&stream, level);
     if (err != Z_OK) return err;
+
     err = deflate(&stream, Z_FINISH);
     if (err != Z_STREAM_END) {
         deflateEnd(&stream);
         return err == Z_OK ? Z_BUF_ERROR : err;
     }
     *destLen = stream.total_out;
+
     err = deflateEnd(&stream);
     return err;
 }
+
 /* ===========================================================================
  */
 int ZEXPORT compress (dest, destLen, source, sourceLen)
@@ -57,6 +67,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
 {
     return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
 }
+
 /* ===========================================================================
      If the default memLevel or windowBits for deflateInit() is changed, then
    this function needs to be updated.
diff --git a/dep/src/zlib/crc32.c b/dep/src/zlib/crc32.c
index 8838c354a4e..f658a9ef55e 100644
--- a/dep/src/zlib/crc32.c
+++ b/dep/src/zlib/crc32.c
@@ -8,7 +8,9 @@
  * instead of four steps with four exclusive-ors.  This results in about a
  * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
  */
+
 /* @(#) $Id$ */
+
 /*
   Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
   protection on the static variables used to control the first-use generation
@@ -16,14 +18,18 @@
   first call get_crc_table() to initialize the tables before allowing more than
   one thread to use crc32().
  */
+
 #ifdef MAKECRCH
 #  include 
 #  ifndef DYNAMIC_CRC_TABLE
 #    define DYNAMIC_CRC_TABLE
 #  endif /* !DYNAMIC_CRC_TABLE */
 #endif /* MAKECRCH */
+
 #include "zutil.h"      /* for STDC and FAR definitions */
+
 #define local static
+
 /* Find a four-byte integer type for crc32_little() and crc32_big(). */
 #ifndef NOBYFOUR
 #  ifdef STDC           /* need ANSI C limits.h to determine sizes */
@@ -44,6 +50,7 @@
 #    endif
 #  endif /* STDC */
 #endif /* !NOBYFOUR */
+
 /* Definitions for doing the crc four data bytes at a time. */
 #ifdef BYFOUR
 #  define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
@@ -56,11 +63,14 @@
 #else
 #  define TBLS 1
 #endif /* BYFOUR */
+
 /* Local functions for crc concatenation */
 local unsigned long gf2_matrix_times OF((unsigned long *mat,
                                          unsigned long vec));
 local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
+
 #ifdef DYNAMIC_CRC_TABLE
+
 local volatile int crc_table_empty = 1;
 local unsigned long FAR crc_table[TBLS][256];
 local void make_crc_table OF((void));
@@ -70,6 +80,7 @@ local void make_crc_table OF((void));
 /*
   Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
   x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
+
   Polynomials over GF(2) are represented in binary, one bit per coefficient,
   with the lowest powers in the most significant bit.  Then adding polynomials
   is just exclusive-or, and multiplying a polynomial by x is a right shift by
@@ -77,6 +88,7 @@ local void make_crc_table OF((void));
   polynomial q, also with the lowest power in the most significant bit (so the
   byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
   where a mod b means the remainder after dividing a by b.
+
   This calculation is done using the shift-register method of multiplying and
   taking the remainder.  The register is initialized to zero, and for each
   incoming bit, x^32 is added mod p to the register if the bit is a one (where
@@ -84,6 +96,7 @@ local void make_crc_table OF((void));
   x (which is shifting right by one and adding x^32 mod p if the bit shifted
   out is a one).  We start with the highest power (least significant bit) of
   q and repeat for all eight bits of q.
+
   The first table is simply the CRC of all possible eight bit values.  This is
   all the information needed to generate CRCs on data a byte at a time for all
   combinations of CRC register values and incoming bytes.  The remaining tables
@@ -98,15 +111,18 @@ local void make_crc_table()
     /* terms of polynomial defining this crc (except x^32): */
     static volatile int first = 1;      /* flag to limit concurrent making */
     static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
+
     /* See if another task is already doing this (not thread-safe, but better
        than nothing -- significantly reduces duration of vulnerability in
        case the advice about DYNAMIC_CRC_TABLE is ignored) */
     if (first) {
         first = 0;
+
         /* make exclusive-or pattern from polynomial (0xedb88320UL) */
         poly = 0UL;
         for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
             poly |= 1UL << (31 - p[n]);
+
         /* generate a crc for every 8-bit value */
         for (n = 0; n < 256; n++) {
             c = (unsigned long)n;
@@ -114,6 +130,7 @@ local void make_crc_table()
                 c = c & 1 ? poly ^ (c >> 1) : c >> 1;
             crc_table[0][n] = c;
         }
+
 #ifdef BYFOUR
         /* generate crc for each value followed by one, two, and three zeros,
            and then the byte reversal of those as well as the first table */
@@ -127,6 +144,7 @@ local void make_crc_table()
             }
         }
 #endif /* BYFOUR */
+
         crc_table_empty = 0;
     }
     else {      /* not first */
@@ -134,10 +152,12 @@ local void make_crc_table()
         while (crc_table_empty)
             ;
     }
+
 #ifdef MAKECRCH
     /* write out CRC tables to crc32.h */
     {
         FILE *out;
+
         out = fopen("crc32.h", "w");
         if (out == NULL) return;
         fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
@@ -158,23 +178,27 @@ local void make_crc_table()
     }
 #endif /* MAKECRCH */
 }
+
 #ifdef MAKECRCH
 local void write_table(out, table)
     FILE *out;
     const unsigned long FAR *table;
 {
     int n;
+
     for (n = 0; n < 256; n++)
         fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : "    ", table[n],
                 n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
 }
 #endif /* MAKECRCH */
+
 #else /* !DYNAMIC_CRC_TABLE */
 /* ========================================================================
  * Tables of CRC-32s of all single-byte values, made by make_crc_table().
  */
 #include "crc32.h"
 #endif /* DYNAMIC_CRC_TABLE */
+
 /* =========================================================================
  * This function can be used by asm versions of crc32()
  */
@@ -186,9 +210,11 @@ const unsigned long FAR * ZEXPORT get_crc_table()
 #endif /* DYNAMIC_CRC_TABLE */
     return (const unsigned long FAR *)crc_table;
 }
+
 /* ========================================================================= */
 #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
 #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
+
 /* ========================================================================= */
 unsigned long ZEXPORT crc32(crc, buf, len)
     unsigned long crc;
@@ -196,13 +222,16 @@ unsigned long ZEXPORT crc32(crc, buf, len)
     unsigned len;
 {
     if (buf == Z_NULL) return 0UL;
+
 #ifdef DYNAMIC_CRC_TABLE
     if (crc_table_empty)
         make_crc_table();
 #endif /* DYNAMIC_CRC_TABLE */
+
 #ifdef BYFOUR
     if (sizeof(void *) == sizeof(ptrdiff_t)) {
         u4 endian;
+
         endian = 1;
         if (*((unsigned char *)(&endian)))
             return crc32_little(crc, buf, len);
@@ -220,12 +249,15 @@ unsigned long ZEXPORT crc32(crc, buf, len)
     } while (--len);
     return crc ^ 0xffffffffUL;
 }
+
 #ifdef BYFOUR
+
 /* ========================================================================= */
 #define DOLIT4 c ^= *buf4++; \
         c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
             crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
 #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
+
 /* ========================================================================= */
 local unsigned long crc32_little(crc, buf, len)
     unsigned long crc;
@@ -234,12 +266,14 @@ local unsigned long crc32_little(crc, buf, len)
 {
     register u4 c;
     register const u4 FAR *buf4;
+
     c = (u4)crc;
     c = ~c;
     while (len && ((ptrdiff_t)buf & 3)) {
         c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
         len--;
     }
+
     buf4 = (const u4 FAR *)(const void FAR *)buf;
     while (len >= 32) {
         DOLIT32;
@@ -250,17 +284,20 @@ local unsigned long crc32_little(crc, buf, len)
         len -= 4;
     }
     buf = (const unsigned char FAR *)buf4;
+
     if (len) do {
         c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
     } while (--len);
     c = ~c;
     return (unsigned long)c;
 }
+
 /* ========================================================================= */
 #define DOBIG4 c ^= *++buf4; \
         c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
             crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
 #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
+
 /* ========================================================================= */
 local unsigned long crc32_big(crc, buf, len)
     unsigned long crc;
@@ -269,12 +306,14 @@ local unsigned long crc32_big(crc, buf, len)
 {
     register u4 c;
     register const u4 FAR *buf4;
+
     c = REV((u4)crc);
     c = ~c;
     while (len && ((ptrdiff_t)buf & 3)) {
         c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
         len--;
     }
+
     buf4 = (const u4 FAR *)(const void FAR *)buf;
     buf4--;
     while (len >= 32) {
@@ -287,20 +326,25 @@ local unsigned long crc32_big(crc, buf, len)
     }
     buf4++;
     buf = (const unsigned char FAR *)buf4;
+
     if (len) do {
         c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
     } while (--len);
     c = ~c;
     return (unsigned long)(REV(c));
 }
+
 #endif /* BYFOUR */
+
 #define GF2_DIM 32      /* dimension of GF(2) vectors (length of CRC) */
+
 /* ========================================================================= */
 local unsigned long gf2_matrix_times(mat, vec)
     unsigned long *mat;
     unsigned long vec;
 {
     unsigned long sum;
+
     sum = 0;
     while (vec) {
         if (vec & 1)
@@ -310,15 +354,18 @@ local unsigned long gf2_matrix_times(mat, vec)
     }
     return sum;
 }
+
 /* ========================================================================= */
 local void gf2_matrix_square(square, mat)
     unsigned long *square;
     unsigned long *mat;
 {
     int n;
+
     for (n = 0; n < GF2_DIM; n++)
         square[n] = gf2_matrix_times(mat, mat[n]);
 }
+
 /* ========================================================================= */
 uLong ZEXPORT crc32_combine(crc1, crc2, len2)
     uLong crc1;
@@ -329,9 +376,11 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
     unsigned long row;
     unsigned long even[GF2_DIM];    /* even-power-of-two zeros operator */
     unsigned long odd[GF2_DIM];     /* odd-power-of-two zeros operator */
+
     /* degenerate case */
     if (len2 == 0)
         return crc1;
+
     /* put operator for one zero bit in odd */
     odd[0] = 0xedb88320L;           /* CRC-32 polynomial */
     row = 1;
@@ -339,10 +388,13 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
         odd[n] = row;
         row <<= 1;
     }
+
     /* put operator for two zero bits in even */
     gf2_matrix_square(even, odd);
+
     /* put operator for four zero bits in odd */
     gf2_matrix_square(odd, even);
+
     /* apply len2 zeros to crc1 (first square will put the operator for one
        zero byte, eight zero bits, in even) */
     do {
@@ -351,16 +403,20 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
         if (len2 & 1)
             crc1 = gf2_matrix_times(even, crc1);
         len2 >>= 1;
+
         /* if no more bits set, then done */
         if (len2 == 0)
             break;
+
         /* another iteration of the loop with odd and even swapped */
         gf2_matrix_square(odd, even);
         if (len2 & 1)
             crc1 = gf2_matrix_times(odd, crc1);
         len2 >>= 1;
+
         /* if no more bits set, then done */
     } while (len2 != 0);
+
     /* return combined crc */
     crc1 ^= crc2;
     return crc1;
diff --git a/dep/src/zlib/crc32.h b/dep/src/zlib/crc32.h
index 05ffb21364b..dfd1deaa522 100644
--- a/dep/src/zlib/crc32.h
+++ b/dep/src/zlib/crc32.h
@@ -1,6 +1,7 @@
 /* crc32.h -- tables for rapid CRC calculation
  * Generated automatically by crc32.c
  */
+
 local const unsigned long FAR crc_table[TBLS][256] =
 {
   {
diff --git a/dep/src/zlib/deflate.c b/dep/src/zlib/deflate.c
index 0651ae4cd8a..29ce1f64a57 100644
--- a/dep/src/zlib/deflate.c
+++ b/dep/src/zlib/deflate.c
@@ -2,6 +2,7 @@
  * Copyright (C) 1995-2005 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /*
  *  ALGORITHM
  *
@@ -45,8 +46,11 @@
  *         Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
  *
  */
+
 /* @(#) $Id$ */
+
 #include "deflate.h"
+
 const char deflate_copyright[] =
    " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
 /*
@@ -55,6 +59,7 @@ const char deflate_copyright[] =
   include such an acknowledgment, I would appreciate that you keep this
   copyright string in the executable of your product.
  */
+
 /* ===========================================================================
  *  Function prototypes.
  */
@@ -64,8 +69,10 @@ typedef enum {
     finish_started, /* finish started, need only more output at next deflate */
     finish_done     /* finish done, accept no more input or output */
 } block_state;
+
 typedef block_state (*compress_func) OF((deflate_state *s, int flush));
 /* Compression function. Returns the block state after the call. */
+
 local void fill_window    OF((deflate_state *s));
 local block_state deflate_stored OF((deflate_state *s, int flush));
 local block_state deflate_fast   OF((deflate_state *s, int flush));
@@ -85,23 +92,29 @@ local uInt longest_match  OF((deflate_state *s, IPos cur_match));
 #endif
 #endif
 local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
+
 #ifdef DEBUG
 local  void check_match OF((deflate_state *s, IPos start, IPos match,
                             int length));
 #endif
+
 /* ===========================================================================
  * Local data
  */
+
 #define NIL 0
 /* Tail of hash chains */
+
 #ifndef TOO_FAR
 #  define TOO_FAR 4096
 #endif
 /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
+
 #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
 /* Minimum amount of lookahead, except at the end of the input file.
  * See deflate.c for comments about the MIN_MATCH+1.
  */
+
 /* Values for max_lazy_match, good_match and max_chain_length, depending on
  * the desired pack level (0..9). The values given below have been tuned to
  * exclude worst case performance for pathological files. Better values may be
@@ -114,6 +127,7 @@ typedef struct config_s {
    ush max_chain;
    compress_func func;
 } config;
+
 #ifdef FASTEST
 local const config configuration_table[2] = {
 /*      good lazy nice chain */
@@ -126,6 +140,7 @@ local const config configuration_table[10] = {
 /* 1 */ {4,    4,  8,    4, deflate_fast}, /* max speed, no lazy matches */
 /* 2 */ {4,    5, 16,    8, deflate_fast},
 /* 3 */ {4,    6, 32,   32, deflate_fast},
+
 /* 4 */ {4,    4, 16,   16, deflate_slow},  /* lazy matches */
 /* 5 */ {8,   16, 32,   32, deflate_slow},
 /* 6 */ {8,   16, 128, 128, deflate_slow},
@@ -133,15 +148,19 @@ local const config configuration_table[10] = {
 /* 8 */ {32, 128, 258, 1024, deflate_slow},
 /* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
 #endif
+
 /* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
  * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
  * meaning.
  */
+
 #define EQUAL 0
 /* result of memcmp for equal strings */
+
 #ifndef NO_DUMMY_DECL
 struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
 #endif
+
 /* ===========================================================================
  * Update a hash value with the given input byte
  * IN  assertion: all calls to to UPDATE_HASH are made with consecutive
@@ -150,6 +169,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
  */
 #define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask)
 
+
 /* ===========================================================================
  * Insert string str in the dictionary and set match_head to the previous head
  * of the hash chain (the most recent string with same hash key). Return
@@ -171,6 +191,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
     match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
     s->head[s->ins_h] = (Pos)(str))
 #endif
+
 /* ===========================================================================
  * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
  * prev[] will be initialized on the fly.
@@ -178,6 +199,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
 #define CLEAR_HASH(s) \
     s->head[s->hash_size-1] = NIL; \
     zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+
 /* ========================================================================= */
 int ZEXPORT deflateInit_(strm, level, version, stream_size)
     z_streamp strm;
@@ -189,6 +211,7 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size)
                          Z_DEFAULT_STRATEGY, version, stream_size);
     /* To do: ignore strm->next_in if we use it as window */
 }
+
 /* ========================================================================= */
 int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
                   version, stream_size)
@@ -204,26 +227,31 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
     deflate_state *s;
     int wrap = 1;
     static const char my_version[] = ZLIB_VERSION;
+
     ushf *overlay;
     /* We overlay pending_buf and d_buf+l_buf. This works since the average
      * output size for (length,distance) codes is <= 24 bits.
      */
+
     if (version == Z_NULL || version[0] != my_version[0] ||
         stream_size != sizeof(z_stream)) {
         return Z_VERSION_ERROR;
     }
     if (strm == Z_NULL) return Z_STREAM_ERROR;
+
     strm->msg = Z_NULL;
     if (strm->zalloc == (alloc_func)0) {
         strm->zalloc = zcalloc;
         strm->opaque = (voidpf)0;
     }
     if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+
 #ifdef FASTEST
     if (level != 0) level = 1;
 #else
     if (level == Z_DEFAULT_COMPRESSION) level = 6;
 #endif
+
     if (windowBits < 0) { /* suppress zlib wrapper */
         wrap = 0;
         windowBits = -windowBits;
@@ -244,22 +272,28 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
     if (s == Z_NULL) return Z_MEM_ERROR;
     strm->state = (struct internal_state FAR *)s;
     s->strm = strm;
+
     s->wrap = wrap;
     s->gzhead = Z_NULL;
     s->w_bits = windowBits;
     s->w_size = 1 << s->w_bits;
     s->w_mask = s->w_size - 1;
+
     s->hash_bits = memLevel + 7;
     s->hash_size = 1 << s->hash_bits;
     s->hash_mask = s->hash_size - 1;
     s->hash_shift =  ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
+
     s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
     s->prev   = (Posf *)  ZALLOC(strm, s->w_size, sizeof(Pos));
     s->head   = (Posf *)  ZALLOC(strm, s->hash_size, sizeof(Pos));
+
     s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
+
     overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
     s->pending_buf = (uchf *) overlay;
     s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
+
     if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
         s->pending_buf == Z_NULL) {
         s->status = FINISH_STATE;
@@ -269,11 +303,14 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
     }
     s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
     s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
+
     s->level = level;
     s->strategy = strategy;
     s->method = (Byte)method;
+
     return deflateReset(strm);
 }
+
 /* ========================================================================= */
 int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
     z_streamp strm;
@@ -284,13 +321,16 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
     uInt length = dictLength;
     uInt n;
     IPos hash_head = 0;
+
     if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
         strm->state->wrap == 2 ||
         (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
         return Z_STREAM_ERROR;
+
     s = strm->state;
     if (s->wrap)
         strm->adler = adler32(strm->adler, dictionary, dictLength);
+
     if (length < MIN_MATCH) return Z_OK;
     if (length > MAX_DIST(s)) {
         length = MAX_DIST(s);
@@ -299,6 +339,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
     zmemcpy(s->window, dictionary, length);
     s->strstart = length;
     s->block_start = (long)length;
+
     /* Insert all strings in the hash table (except for the last two bytes).
      * s->lookahead stays null, so s->ins_h will be recomputed at the next
      * call of fill_window.
@@ -311,21 +352,26 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
     if (hash_head) hash_head = 0;  /* to make compiler happy */
     return Z_OK;
 }
+
 /* ========================================================================= */
 int ZEXPORT deflateReset (strm)
     z_streamp strm;
 {
     deflate_state *s;
+
     if (strm == Z_NULL || strm->state == Z_NULL ||
         strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
         return Z_STREAM_ERROR;
     }
+
     strm->total_in = strm->total_out = 0;
     strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
     strm->data_type = Z_UNKNOWN;
+
     s = (deflate_state *)strm->state;
     s->pending = 0;
     s->pending_out = s->pending_buf;
+
     if (s->wrap < 0) {
         s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
     }
@@ -336,10 +382,13 @@ int ZEXPORT deflateReset (strm)
 #endif
         adler32(0L, Z_NULL, 0);
     s->last_flush = Z_NO_FLUSH;
+
     _tr_init(s);
     lm_init(s);
+
     return Z_OK;
 }
+
 /* ========================================================================= */
 int ZEXPORT deflateSetHeader (strm, head)
     z_streamp strm;
@@ -350,6 +399,7 @@ int ZEXPORT deflateSetHeader (strm, head)
     strm->state->gzhead = head;
     return Z_OK;
 }
+
 /* ========================================================================= */
 int ZEXPORT deflatePrime (strm, bits, value)
     z_streamp strm;
@@ -361,6 +411,7 @@ int ZEXPORT deflatePrime (strm, bits, value)
     strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
     return Z_OK;
 }
+
 /* ========================================================================= */
 int ZEXPORT deflateParams(strm, level, strategy)
     z_streamp strm;
@@ -370,8 +421,10 @@ int ZEXPORT deflateParams(strm, level, strategy)
     deflate_state *s;
     compress_func func;
     int err = Z_OK;
+
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     s = strm->state;
+
 #ifdef FASTEST
     if (level != 0) level = 1;
 #else
@@ -381,6 +434,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
         return Z_STREAM_ERROR;
     }
     func = configuration_table[s->level].func;
+
     if (func != configuration_table[level].func && strm->total_in != 0) {
         /* Flush the last buffer: */
         err = deflate(strm, Z_PARTIAL_FLUSH);
@@ -395,6 +449,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
     s->strategy = strategy;
     return err;
 }
+
 /* ========================================================================= */
 int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
     z_streamp strm;
@@ -404,6 +459,7 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
     int max_chain;
 {
     deflate_state *s;
+
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     s = strm->state;
     s->good_match = good_length;
@@ -412,6 +468,7 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
     s->max_chain_length = max_chain;
     return Z_OK;
 }
+
 /* =========================================================================
  * For the default windowBits of 15 and memLevel of 8, this function returns
  * a close to exact, as well as small, upper bound on the compressed size.
@@ -435,19 +492,24 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
 {
     deflate_state *s;
     uLong destLen;
+
     /* conservative upper bound */
     destLen = sourceLen +
               ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
+
     /* if can't get parameters, return conservative bound */
     if (strm == Z_NULL || strm->state == Z_NULL)
         return destLen;
+
     /* if not default parameters, return conservative bound */
     s = strm->state;
     if (s->w_bits != 15 || s->hash_bits != 8 + 7)
         return destLen;
+
     /* default settings: return tight bound for that case */
     return compressBound(sourceLen);
 }
+
 /* =========================================================================
  * Put a short in the pending buffer. The 16-bit value is put in MSB order.
  * IN assertion: the stream state is correct and there is enough room in
@@ -460,6 +522,7 @@ local void putShortMSB (s, b)
     put_byte(s, (Byte)(b >> 8));
     put_byte(s, (Byte)(b & 0xff));
 }
+
 /* =========================================================================
  * Flush as much pending output as possible. All deflate() output goes
  * through this function so some applications may wish to modify it
@@ -470,8 +533,10 @@ local void flush_pending(strm)
     z_streamp strm;
 {
     unsigned len = strm->state->pending;
+
     if (len > strm->avail_out) len = strm->avail_out;
     if (len == 0) return;
+
     zmemcpy(strm->next_out, strm->state->pending_out, len);
     strm->next_out  += len;
     strm->state->pending_out  += len;
@@ -482,6 +547,7 @@ local void flush_pending(strm)
         strm->state->pending_out = strm->state->pending_buf;
     }
 }
+
 /* ========================================================================= */
 int ZEXPORT deflate (strm, flush)
     z_streamp strm;
@@ -489,20 +555,24 @@ int ZEXPORT deflate (strm, flush)
 {
     int old_flush; /* value of flush param for previous deflate call */
     deflate_state *s;
+
     if (strm == Z_NULL || strm->state == Z_NULL ||
         flush > Z_FINISH || flush < 0) {
         return Z_STREAM_ERROR;
     }
     s = strm->state;
+
     if (strm->next_out == Z_NULL ||
         (strm->next_in == Z_NULL && strm->avail_in != 0) ||
         (s->status == FINISH_STATE && flush != Z_FINISH)) {
         ERR_RETURN(strm, Z_STREAM_ERROR);
     }
     if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
+
     s->strm = strm; /* just in case */
     old_flush = s->last_flush;
     s->last_flush = flush;
+
     /* Write the header */
     if (s->status == INIT_STATE) {
 #ifdef GZIP
@@ -554,6 +624,7 @@ int ZEXPORT deflate (strm, flush)
         {
             uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
             uInt level_flags;
+
             if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
                 level_flags = 0;
             else if (s->level < 6)
@@ -565,8 +636,10 @@ int ZEXPORT deflate (strm, flush)
             header |= (level_flags << 6);
             if (s->strstart != 0) header |= PRESET_DICT;
             header += 31 - (header % 31);
+
             s->status = BUSY_STATE;
             putShortMSB(s, header);
+
             /* Save the adler32 of the preset dictionary: */
             if (s->strstart != 0) {
                 putShortMSB(s, (uInt)(strm->adler >> 16));
@@ -579,6 +652,7 @@ int ZEXPORT deflate (strm, flush)
     if (s->status == EXTRA_STATE) {
         if (s->gzhead->extra != NULL) {
             uInt beg = s->pending;  /* start of bytes to update crc */
+
             while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
                 if (s->pending == s->pending_buf_size) {
                     if (s->gzhead->hcrc && s->pending > beg)
@@ -607,6 +681,7 @@ int ZEXPORT deflate (strm, flush)
         if (s->gzhead->name != NULL) {
             uInt beg = s->pending;  /* start of bytes to update crc */
             int val;
+
             do {
                 if (s->pending == s->pending_buf_size) {
                     if (s->gzhead->hcrc && s->pending > beg)
@@ -637,6 +712,7 @@ int ZEXPORT deflate (strm, flush)
         if (s->gzhead->comment != NULL) {
             uInt beg = s->pending;  /* start of bytes to update crc */
             int val;
+
             do {
                 if (s->pending == s->pending_buf_size) {
                     if (s->gzhead->hcrc && s->pending > beg)
@@ -676,6 +752,7 @@ int ZEXPORT deflate (strm, flush)
             s->status = BUSY_STATE;
     }
 #endif
+
     /* Flush as much pending output as possible */
     if (s->pending != 0) {
         flush_pending(strm);
@@ -689,6 +766,7 @@ int ZEXPORT deflate (strm, flush)
             s->last_flush = -1;
             return Z_OK;
         }
+
     /* Make sure there is something to do and avoid duplicate consecutive
      * flushes. For repeated and useless calls with Z_FINISH, we keep
      * returning Z_STREAM_END instead of Z_BUF_ERROR.
@@ -697,16 +775,20 @@ int ZEXPORT deflate (strm, flush)
                flush != Z_FINISH) {
         ERR_RETURN(strm, Z_BUF_ERROR);
     }
+
     /* User must not provide more input after the first FINISH: */
     if (s->status == FINISH_STATE && strm->avail_in != 0) {
         ERR_RETURN(strm, Z_BUF_ERROR);
     }
+
     /* Start a new block or continue the current one.
      */
     if (strm->avail_in != 0 || s->lookahead != 0 ||
         (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
         block_state bstate;
+
         bstate = (*(configuration_table[s->level].func))(s, flush);
+
         if (bstate == finish_started || bstate == finish_done) {
             s->status = FINISH_STATE;
         }
@@ -743,8 +825,10 @@ int ZEXPORT deflate (strm, flush)
         }
     }
     Assert(strm->avail_out > 0, "bug2");
+
     if (flush != Z_FINISH) return Z_OK;
     if (s->wrap <= 0) return Z_STREAM_END;
+
     /* Write the trailer */
 #ifdef GZIP
     if (s->wrap == 2) {
@@ -770,12 +854,15 @@ int ZEXPORT deflate (strm, flush)
     if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
     return s->pending != 0 ? Z_OK : Z_STREAM_END;
 }
+
 /* ========================================================================= */
 int ZEXPORT deflateEnd (strm)
     z_streamp strm;
 {
     int status;
+
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+
     status = strm->state->status;
     if (status != INIT_STATE &&
         status != EXTRA_STATE &&
@@ -786,15 +873,19 @@ int ZEXPORT deflateEnd (strm)
         status != FINISH_STATE) {
       return Z_STREAM_ERROR;
     }
+
     /* Deallocate in reverse order of allocations: */
     TRY_FREE(strm, strm->state->pending_buf);
     TRY_FREE(strm, strm->state->head);
     TRY_FREE(strm, strm->state->prev);
     TRY_FREE(strm, strm->state->window);
+
     ZFREE(strm, strm->state);
     strm->state = Z_NULL;
+
     return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
 }
+
 /* =========================================================================
  * Copy the source state to the destination state.
  * To simplify the source, this is not supported for 16-bit MSDOS (which
@@ -811,21 +902,27 @@ int ZEXPORT deflateCopy (dest, source)
     deflate_state *ss;
     ushf *overlay;
 
+
     if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
         return Z_STREAM_ERROR;
     }
+
     ss = source->state;
+
     zmemcpy(dest, source, sizeof(z_stream));
+
     ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
     if (ds == Z_NULL) return Z_MEM_ERROR;
     dest->state = (struct internal_state FAR *) ds;
     zmemcpy(ds, ss, sizeof(deflate_state));
     ds->strm = dest;
+
     ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
     ds->prev   = (Posf *)  ZALLOC(dest, ds->w_size, sizeof(Pos));
     ds->head   = (Posf *)  ZALLOC(dest, ds->hash_size, sizeof(Pos));
     overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
     ds->pending_buf = (uchf *) overlay;
+
     if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
         ds->pending_buf == Z_NULL) {
         deflateEnd (dest);
@@ -836,15 +933,19 @@ int ZEXPORT deflateCopy (dest, source)
     zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
     zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
     zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
+
     ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
     ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
     ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
+
     ds->l_desc.dyn_tree = ds->dyn_ltree;
     ds->d_desc.dyn_tree = ds->dyn_dtree;
     ds->bl_desc.dyn_tree = ds->bl_tree;
+
     return Z_OK;
 #endif /* MAXSEG_64K */
 }
+
 /* ===========================================================================
  * Read a new buffer from the current input stream, update the adler32
  * and total number of bytes read.  All deflate() input goes through
@@ -858,9 +959,12 @@ local int read_buf(strm, buf, size)
     unsigned size;
 {
     unsigned len = strm->avail_in;
+
     if (len > size) len = size;
     if (len == 0) return 0;
+
     strm->avail_in  -= len;
+
     if (strm->state->wrap == 1) {
         strm->adler = adler32(strm->adler, strm->next_in, len);
     }
@@ -872,8 +976,10 @@ local int read_buf(strm, buf, size)
     zmemcpy(buf, strm->next_in, len);
     strm->next_in  += len;
     strm->total_in += len;
+
     return (int)len;
 }
+
 /* ===========================================================================
  * Initialize the "longest match" routines for a new zlib stream
  */
@@ -881,13 +987,16 @@ local void lm_init (s)
     deflate_state *s;
 {
     s->window_size = (ulg)2L*s->w_size;
+
     CLEAR_HASH(s);
+
     /* Set the default configuration parameters:
      */
     s->max_lazy_match   = configuration_table[s->level].max_lazy;
     s->good_match       = configuration_table[s->level].good_length;
     s->nice_match       = configuration_table[s->level].nice_length;
     s->max_chain_length = configuration_table[s->level].max_chain;
+
     s->strstart = 0;
     s->block_start = 0L;
     s->lookahead = 0;
@@ -900,6 +1009,7 @@ local void lm_init (s)
 #endif
 #endif
 }
+
 #ifndef FASTEST
 /* ===========================================================================
  * Set match_start to the longest match starting at the given string and
@@ -931,6 +1041,7 @@ local uInt longest_match(s, cur_match)
      */
     Posf *prev = s->prev;
     uInt wmask = s->w_mask;
+
 #ifdef UNALIGNED_OK
     /* Compare two bytes at a time. Note: this is not always beneficial.
      * Try with and without -DUNALIGNED_OK to check.
@@ -943,10 +1054,12 @@ local uInt longest_match(s, cur_match)
     register Byte scan_end1  = scan[best_len-1];
     register Byte scan_end   = scan[best_len];
 #endif
+
     /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
      * It is easy to get rid of this optimization if necessary.
      */
     Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
+
     /* Do not waste too much time if we already have a good match: */
     if (s->prev_length >= s->good_match) {
         chain_length >>= 2;
@@ -955,10 +1068,13 @@ local uInt longest_match(s, cur_match)
      * to make deflate deterministic.
      */
     if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
+
     Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
+
     do {
         Assert(cur_match < s->strstart, "no future");
         match = s->window + cur_match;
+
         /* Skip to next match if the match length cannot increase
          * or if the match length is less than 2.  Note that the checks below
          * for insufficient lookahead only occur occasionally for performance
@@ -973,6 +1089,7 @@ local uInt longest_match(s, cur_match)
          */
         if (*(ushf*)(match+best_len-1) != scan_end ||
             *(ushf*)match != scan_start) continue;
+
         /* It is not necessary to compare scan[2] and match[2] since they are
          * always equal when the other bytes match, given that the hash keys
          * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
@@ -991,16 +1108,21 @@ local uInt longest_match(s, cur_match)
                  *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
                  scan < strend);
         /* The funny "do {}" generates better code on most compilers */
+
         /* Here, scan <= window+strstart+257 */
         Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
         if (*scan == *match) scan++;
+
         len = (MAX_MATCH - 1) - (int)(strend-scan);
         scan = strend - (MAX_MATCH-1);
+
 #else /* UNALIGNED_OK */
+
         if (match[best_len]   != scan_end  ||
             match[best_len-1] != scan_end1 ||
             *match            != *scan     ||
             *++match          != scan[1])      continue;
+
         /* The check at best_len-1 can be removed because it will be made
          * again later. (This heuristic is not always a win.)
          * It is not necessary to compare scan[2] and match[2] since they
@@ -1009,6 +1131,7 @@ local uInt longest_match(s, cur_match)
          */
         scan += 2, match++;
         Assert(*scan == *match, "match[2]?");
+
         /* We check for insufficient lookahead only every 8th comparison;
          * the 256th check will be made at strstart+258.
          */
@@ -1018,10 +1141,14 @@ local uInt longest_match(s, cur_match)
                  *++scan == *++match && *++scan == *++match &&
                  *++scan == *++match && *++scan == *++match &&
                  scan < strend);
+
         Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
+
         len = MAX_MATCH - (int)(strend - scan);
         scan = strend - MAX_MATCH;
+
 #endif /* UNALIGNED_OK */
+
         if (len > best_len) {
             s->match_start = cur_match;
             best_len = len;
@@ -1035,11 +1162,13 @@ local uInt longest_match(s, cur_match)
         }
     } while ((cur_match = prev[cur_match & wmask]) > limit
              && --chain_length != 0);
+
     if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
     return s->lookahead;
 }
 #endif /* ASMV */
 #endif /* FASTEST */
+
 /* ---------------------------------------------------------------------------
  * Optimized version for level == 1 or strategy == Z_RLE only
  */
@@ -1051,16 +1180,22 @@ local uInt longest_match_fast(s, cur_match)
     register Bytef *match;                       /* matched string */
     register int len;                           /* length of current match */
     register Bytef *strend = s->window + s->strstart + MAX_MATCH;
+
     /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
      * It is easy to get rid of this optimization if necessary.
      */
     Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
+
     Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
+
     Assert(cur_match < s->strstart, "no future");
+
     match = s->window + cur_match;
+
     /* Return failure if the match length is less than 2:
      */
     if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
+
     /* The check at best_len-1 can be removed because it will be made
      * again later. (This heuristic is not always a win.)
      * It is not necessary to compare scan[2] and match[2] since they
@@ -1069,6 +1204,7 @@ local uInt longest_match_fast(s, cur_match)
      */
     scan += 2, match += 2;
     Assert(*scan == *match, "match[2]?");
+
     /* We check for insufficient lookahead only every 8th comparison;
      * the 256th check will be made at strstart+258.
      */
@@ -1078,12 +1214,17 @@ local uInt longest_match_fast(s, cur_match)
              *++scan == *++match && *++scan == *++match &&
              *++scan == *++match && *++scan == *++match &&
              scan < strend);
+
     Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
+
     len = MAX_MATCH - (int)(strend - scan);
+
     if (len < MIN_MATCH) return MIN_MATCH - 1;
+
     s->match_start = cur_match;
     return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
 }
+
 #ifdef DEBUG
 /* ===========================================================================
  * Check that the match at match_start is indeed a match.
@@ -1111,6 +1252,7 @@ local void check_match(s, start, match, length)
 #else
 #  define check_match(s, start, match, length)
 #endif /* DEBUG */
+
 /* ===========================================================================
  * Fill the window when the lookahead becomes insufficient.
  * Updates strstart and lookahead.
@@ -1128,12 +1270,15 @@ local void fill_window(s)
     register Posf *p;
     unsigned more;    /* Amount of free space at the end of the window. */
     uInt wsize = s->w_size;
+
     do {
         more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
+
         /* Deal with !@#$% 64K limit: */
         if (sizeof(int) <= 2) {
             if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
                 more = wsize;
+
             } else if (more == (unsigned)(-1)) {
                 /* Very unlikely, but possible on 16 bit machine if
                  * strstart == 0 && lookahead == 1 (input done a byte at time)
@@ -1141,14 +1286,17 @@ local void fill_window(s)
                 more--;
             }
         }
+
         /* If the window is almost full and there is insufficient lookahead,
          * move the upper half to the lower one to make room in the upper half.
          */
         if (s->strstart >= wsize+MAX_DIST(s)) {
+
             zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
             s->match_start -= wsize;
             s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
             s->block_start -= (long) wsize;
+
             /* Slide the hash table (could be avoided with 32 bit values
                at the expense of memory usage). We slide even when level == 0
                to keep the hash table consistent if we switch back to level > 0
@@ -1162,6 +1310,7 @@ local void fill_window(s)
                 m = *--p;
                 *p = (Pos)(m >= wsize ? m-wsize : NIL);
             } while (--n);
+
             n = wsize;
 #ifndef FASTEST
             p = &s->prev[n];
@@ -1176,6 +1325,7 @@ local void fill_window(s)
             more += wsize;
         }
         if (s->strm->avail_in == 0) return;
+
         /* If there was no sliding:
          *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
          *    more == window_size - lookahead - strstart
@@ -1188,8 +1338,10 @@ local void fill_window(s)
          * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
          */
         Assert(more >= 2, "more < 2");
+
         n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
         s->lookahead += n;
+
         /* Initialize the hash value now that we have some input: */
         if (s->lookahead >= MIN_MATCH) {
             s->ins_h = s->window[s->strstart];
@@ -1201,8 +1353,10 @@ local void fill_window(s)
         /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
          * but this is not important since only literal bytes will be emitted.
          */
+
     } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
 }
+
 /* ===========================================================================
  * Flush the current block, with given end-of-file flag.
  * IN assertion: strstart is set to the end of the current match.
@@ -1217,11 +1371,13 @@ local void fill_window(s)
    flush_pending(s->strm); \
    Tracev((stderr,"[FLUSH]")); \
 }
+
 /* Same but force premature exit if necessary. */
 #define FLUSH_BLOCK(s, eof) { \
    FLUSH_BLOCK_ONLY(s, eof); \
    if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
 }
+
 /* ===========================================================================
  * Copy without compression as much as possible from the input stream, return
  * the current block state.
@@ -1240,22 +1396,29 @@ local block_state deflate_stored(s, flush)
      */
     ulg max_block_size = 0xffff;
     ulg max_start;
+
     if (max_block_size > s->pending_buf_size - 5) {
         max_block_size = s->pending_buf_size - 5;
     }
+
     /* Copy as much as possible from input to output: */
     for (;;) {
         /* Fill the window as much as possible: */
         if (s->lookahead <= 1) {
+
             Assert(s->strstart < s->w_size+MAX_DIST(s) ||
                    s->block_start >= (long)s->w_size, "slide too late");
+
             fill_window(s);
             if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
+
             if (s->lookahead == 0) break; /* flush the current block */
         }
         Assert(s->block_start >= 0L, "block gone");
+
         s->strstart += s->lookahead;
         s->lookahead = 0;
+
         /* Emit a stored block if pending_buf will be full: */
         max_start = s->block_start + max_block_size;
         if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
@@ -1274,6 +1437,7 @@ local block_state deflate_stored(s, flush)
     FLUSH_BLOCK(s, flush == Z_FINISH);
     return flush == Z_FINISH ? finish_done : block_done;
 }
+
 /* ===========================================================================
  * Compress as much as possible from the input stream, return the current
  * block state.
@@ -1287,6 +1451,7 @@ local block_state deflate_fast(s, flush)
 {
     IPos hash_head = NIL; /* head of the hash chain */
     int bflush;           /* set if current block must be flushed */
+
     for (;;) {
         /* Make sure that we always have enough lookahead, except
          * at the end of the input file. We need MAX_MATCH bytes
@@ -1300,12 +1465,14 @@ local block_state deflate_fast(s, flush)
             }
             if (s->lookahead == 0) break; /* flush the current block */
         }
+
         /* Insert the string window[strstart .. strstart+2] in the
          * dictionary, and set hash_head to the head of the hash chain:
          */
         if (s->lookahead >= MIN_MATCH) {
             INSERT_STRING(s, s->strstart, hash_head);
         }
+
         /* Find the longest match, discarding those <= prev_length.
          * At this point we have always match_length < MIN_MATCH
          */
@@ -1330,9 +1497,12 @@ local block_state deflate_fast(s, flush)
         }
         if (s->match_length >= MIN_MATCH) {
             check_match(s, s->strstart, s->match_start, s->match_length);
+
             _tr_tally_dist(s, s->strstart - s->match_start,
                            s->match_length - MIN_MATCH, bflush);
+
             s->lookahead -= s->match_length;
+
             /* Insert new strings in the hash table only if the match length
              * is not too large. This saves time but degrades compression.
              */
@@ -1374,6 +1544,7 @@ local block_state deflate_fast(s, flush)
     FLUSH_BLOCK(s, flush == Z_FINISH);
     return flush == Z_FINISH ? finish_done : block_done;
 }
+
 #ifndef FASTEST
 /* ===========================================================================
  * Same as above, but achieves better compression. We use a lazy
@@ -1386,6 +1557,7 @@ local block_state deflate_slow(s, flush)
 {
     IPos hash_head = NIL;    /* head of hash chain */
     int bflush;              /* set if current block must be flushed */
+
     /* Process the input block. */
     for (;;) {
         /* Make sure that we always have enough lookahead, except
@@ -1400,16 +1572,19 @@ local block_state deflate_slow(s, flush)
             }
             if (s->lookahead == 0) break; /* flush the current block */
         }
+
         /* Insert the string window[strstart .. strstart+2] in the
          * dictionary, and set hash_head to the head of the hash chain:
          */
         if (s->lookahead >= MIN_MATCH) {
             INSERT_STRING(s, s->strstart, hash_head);
         }
+
         /* Find the longest match, discarding those <= prev_length.
          */
         s->prev_length = s->match_length, s->prev_match = s->match_start;
         s->match_length = MIN_MATCH-1;
+
         if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
             s->strstart - hash_head <= MAX_DIST(s)) {
             /* To simplify the code, we prevent matches with the string
@@ -1422,12 +1597,14 @@ local block_state deflate_slow(s, flush)
                 s->match_length = longest_match_fast (s, hash_head);
             }
             /* longest_match() or longest_match_fast() sets match_start */
+
             if (s->match_length <= 5 && (s->strategy == Z_FILTERED
 #if TOO_FAR <= 32767
                 || (s->match_length == MIN_MATCH &&
                     s->strstart - s->match_start > TOO_FAR)
 #endif
                 )) {
+
                 /* If prev_match is also MIN_MATCH, match_start is garbage
                  * but we will ignore the current match anyway.
                  */
@@ -1440,9 +1617,12 @@ local block_state deflate_slow(s, flush)
         if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
             uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
             /* Do not insert strings in hash table beyond this. */
+
             check_match(s, s->strstart-1, s->prev_match, s->prev_length);
+
             _tr_tally_dist(s, s->strstart -1 - s->prev_match,
                            s->prev_length - MIN_MATCH, bflush);
+
             /* Insert in hash table all strings up to the end of the match.
              * strstart-1 and strstart are already inserted. If there is not
              * enough lookahead, the last two strings are not inserted in
@@ -1458,7 +1638,9 @@ local block_state deflate_slow(s, flush)
             s->match_available = 0;
             s->match_length = MIN_MATCH-1;
             s->strstart++;
+
             if (bflush) FLUSH_BLOCK(s, 0);
+
         } else if (s->match_available) {
             /* If there was no match at the previous position, output a
              * single literal. If there was a match but the current match
@@ -1491,6 +1673,7 @@ local block_state deflate_slow(s, flush)
     return flush == Z_FINISH ? finish_done : block_done;
 }
 #endif /* FASTEST */
+
 #if 0
 /* ===========================================================================
  * For Z_RLE, simply look for runs of bytes, generate matches only of distance
@@ -1506,6 +1689,7 @@ local block_state deflate_rle(s, flush)
     uInt max;           /* maximum length of run */
     uInt prev;          /* byte at distance one to match */
     Bytef *scan;        /* scan for end of run */
+
     for (;;) {
         /* Make sure that we always have enough lookahead, except
          * at the end of the input file. We need MAX_MATCH bytes
@@ -1518,6 +1702,7 @@ local block_state deflate_rle(s, flush)
             }
             if (s->lookahead == 0) break; /* flush the current block */
         }
+
         /* See how many times the previous byte repeats */
         run = 0;
         if (s->strstart > 0) {      /* if there is a previous byte, that is */
@@ -1529,6 +1714,7 @@ local block_state deflate_rle(s, flush)
                     break;
             } while (++run < max);
         }
+
         /* Emit match if have run of MIN_MATCH or longer, else emit literal */
         if (run >= MIN_MATCH) {
             check_match(s, s->strstart, s->strstart - 1, run);
diff --git a/dep/src/zlib/deflate.h b/dep/src/zlib/deflate.h
index 8f3d217b13f..d56e97db4cb 100644
--- a/dep/src/zlib/deflate.h
+++ b/dep/src/zlib/deflate.h
@@ -2,14 +2,19 @@
  * Copyright (C) 1995-2004 Jean-loup Gailly
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* WARNING: this file should *not* be used by applications. It is
    part of the implementation of the compression library and is
    subject to change. Applications should only use zlib.h.
  */
+
 /* @(#) $Id$ */
+
 #ifndef DEFLATE_H
 #define DEFLATE_H
+
 #include "zutil.h"
+
 /* define NO_GZIP when compiling if you want to disable gzip header and
    trailer creation by deflate().  NO_GZIP would be used to avoid linking in
    the crc code when it is not needed.  For shared libraries, gzip encoding
@@ -17,23 +22,32 @@
 #ifndef NO_GZIP
 #  define GZIP
 #endif
+
 /* ===========================================================================
  * Internal compression state.
  */
+
 #define LENGTH_CODES 29
 /* number of length codes, not counting the special END_BLOCK code */
+
 #define LITERALS  256
 /* number of literal bytes 0..255 */
+
 #define L_CODES (LITERALS+1+LENGTH_CODES)
 /* number of Literal or Length codes, including the END_BLOCK code */
+
 #define D_CODES   30
 /* number of distance codes */
+
 #define BL_CODES  19
 /* number of codes used to transfer the bit lengths */
+
 #define HEAP_SIZE (2*L_CODES+1)
 /* maximum heap size */
+
 #define MAX_BITS 15
 /* All codes must not exceed MAX_BITS bits */
+
 #define INIT_STATE    42
 #define EXTRA_STATE   69
 #define NAME_STATE    73
@@ -43,6 +57,7 @@
 #define FINISH_STATE 666
 /* Stream status */
 
+
 /* Data structure describing a single value and its code string. */
 typedef struct ct_data_s {
     union {
@@ -54,22 +69,28 @@ typedef struct ct_data_s {
         ush  len;        /* length of bit string */
     } dl;
 } FAR ct_data;
+
 #define Freq fc.freq
 #define Code fc.code
 #define Dad  dl.dad
 #define Len  dl.len
+
 typedef struct static_tree_desc_s  static_tree_desc;
+
 typedef struct tree_desc_s {
     ct_data *dyn_tree;           /* the dynamic tree */
     int     max_code;            /* largest code with non zero frequency */
     static_tree_desc *stat_desc; /* the corresponding static tree */
 } FAR tree_desc;
+
 typedef ush Pos;
 typedef Pos FAR Posf;
 typedef unsigned IPos;
+
 /* A Pos is an index in the character window. We use short instead of int to
  * save space in the various tables. IPos is used only for parameter passing.
  */
+
 typedef struct internal_state {
     z_streamp strm;      /* pointer back to this zlib stream */
     int   status;        /* as the name implies */
@@ -82,10 +103,13 @@ typedef struct internal_state {
     uInt   gzindex;      /* where in extra, name, or comment */
     Byte  method;        /* STORED (for zip only) or DEFLATED */
     int   last_flush;    /* value of flush param for previous deflate call */
+
                 /* used by deflate.c: */
+
     uInt  w_size;        /* LZ77 window size (32K by default) */
     uInt  w_bits;        /* log2(w_size)  (8..16) */
     uInt  w_mask;        /* w_size - 1 */
+
     Bytef *window;
     /* Sliding window. Input bytes are read into the second half of the window,
      * and move to the first half later to keep a dictionary of at least wSize
@@ -95,45 +119,55 @@ typedef struct internal_state {
      * the window size to 64K, which is quite useful on MSDOS.
      * To do: use the user input buffer as sliding window.
      */
+
     ulg window_size;
     /* Actual size of window: 2*wSize, except when the user input buffer
      * is directly used as sliding window.
      */
+
     Posf *prev;
     /* Link to older string with same hash index. To limit the size of this
      * array to 64K, this link is maintained only for the last 32K strings.
      * An index in this array is thus a window index modulo 32K.
      */
+
     Posf *head; /* Heads of the hash chains or NIL. */
+
     uInt  ins_h;          /* hash index of string to be inserted */
     uInt  hash_size;      /* number of elements in hash table */
     uInt  hash_bits;      /* log2(hash_size) */
     uInt  hash_mask;      /* hash_size-1 */
+
     uInt  hash_shift;
     /* Number of bits by which ins_h must be shifted at each input
      * step. It must be such that after MIN_MATCH steps, the oldest
      * byte no longer takes part in the hash key, that is:
      *   hash_shift * MIN_MATCH >= hash_bits
      */
+
     long block_start;
     /* Window position at the beginning of the current output block. Gets
      * negative when the window is moved backwards.
      */
+
     uInt match_length;           /* length of best match */
     IPos prev_match;             /* previous match */
     int match_available;         /* set if previous match exists */
     uInt strstart;               /* start of string to insert */
     uInt match_start;            /* start of matching string */
     uInt lookahead;              /* number of valid bytes ahead in window */
+
     uInt prev_length;
     /* Length of the best match at previous step. Matches not greater than this
      * are discarded. This is used in the lazy match evaluation.
      */
+
     uInt max_chain_length;
     /* To speed up deflation, hash chains are never searched beyond this
      * length.  A higher limit improves compression ratio but degrades the
      * speed.
      */
+
     uInt max_lazy_match;
     /* Attempt to find a better match only when the current match is strictly
      * smaller than this value. This mechanism is used only for compression
@@ -144,31 +178,41 @@ typedef struct internal_state {
      * greater than this length. This saves time but degrades compression.
      * max_insert_length is used only for compression levels <= 3.
      */
+
     int level;    /* compression level (1..9) */
     int strategy; /* favor or force Huffman coding*/
+
     uInt good_match;
     /* Use a faster search when the previous match is longer than this */
+
     int nice_match; /* Stop searching when current match exceeds this */
+
                 /* used by trees.c: */
     /* Didn't use ct_data typedef below to supress compiler warning */
     struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */
     struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
     struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */
+
     struct tree_desc_s l_desc;               /* desc. for literal tree */
     struct tree_desc_s d_desc;               /* desc. for distance tree */
     struct tree_desc_s bl_desc;              /* desc. for bit length tree */
+
     ush bl_count[MAX_BITS+1];
     /* number of codes at each bit length for an optimal tree */
+
     int heap[2*L_CODES+1];      /* heap used to build the Huffman trees */
     int heap_len;               /* number of elements in the heap */
     int heap_max;               /* element of largest frequency */
     /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
      * The same heap array is used to build all trees.
      */
+
     uch depth[2*L_CODES+1];
     /* Depth of each subtree used as tie breaker for trees of equal frequency
      */
+
     uchf *l_buf;          /* buffer for literals or lengths */
+
     uInt  lit_bufsize;
     /* Size of match buffer for literals/lengths.  There are 4 reasons for
      * limiting lit_bufsize to 64K:
@@ -188,20 +232,25 @@ typedef struct internal_state {
      *     trees more frequently.
      *   - I can't count above 4
      */
+
     uInt last_lit;      /* running index in l_buf */
+
     ushf *d_buf;
     /* Buffer for distances. To simplify the code, d_buf and l_buf have
      * the same number of elements. To use different lengths, an extra flag
      * array would be necessary.
      */
+
     ulg opt_len;        /* bit length of current block with optimal trees */
     ulg static_len;     /* bit length of current block with static trees */
     uInt matches;       /* number of string matches in current block */
     int last_eob_len;   /* bit length of EOB code for last block */
+
 #ifdef DEBUG
     ulg compressed_len; /* total bit length of compressed file mod 2^32 */
     ulg bits_sent;      /* bit length of compressed data sent mod 2^32 */
 #endif
+
     ush bi_buf;
     /* Output buffer. bits are inserted starting at the bottom (least
      * significant bits).
@@ -210,20 +259,25 @@ typedef struct internal_state {
     /* Number of valid bits in bi_buf.  All bits above the last valid bit
      * are always zero.
      */
+
 } FAR deflate_state;
+
 /* Output a byte on the stream.
  * IN assertion: there is enough room in pending_buf.
  */
 #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
 
+
 #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
 /* Minimum amount of lookahead, except at the end of the input file.
  * See deflate.c for comments about the MIN_MATCH+1.
  */
+
 #define MAX_DIST(s)  ((s)->w_size-MIN_LOOKAHEAD)
 /* In order to simplify the code, particularly on 16 bit machines, match
  * distances are limited to MAX_DIST instead of WSIZE.
  */
+
         /* in trees.c */
 void _tr_init         OF((deflate_state *s));
 int  _tr_tally        OF((deflate_state *s, unsigned dist, unsigned lc));
@@ -232,14 +286,17 @@ void _tr_flush_block  OF((deflate_state *s, charf *buf, ulg stored_len,
 void _tr_align        OF((deflate_state *s));
 void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
                           int eof));
+
 #define d_code(dist) \
    ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
 /* Mapping from a distance to a distance code. dist is the distance - 1 and
  * must not have side effects. _dist_code[256] and _dist_code[257] are never
  * used.
  */
+
 #ifndef DEBUG
 /* Inline versions of _tr_tally for speed: */
+
 #if defined(GEN_TREES_H) || !defined(STDC)
   extern uch _length_code[];
   extern uch _dist_code[];
@@ -247,6 +304,7 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
   extern const uch _length_code[];
   extern const uch _dist_code[];
 #endif
+
 # define _tr_tally_lit(s, c, flush) \
   { uch cc = (c); \
     s->d_buf[s->last_lit] = 0; \
@@ -269,5 +327,6 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
 # define _tr_tally_dist(s, distance, length, flush) \
               flush = _tr_tally(s, distance, length)
 #endif
+
 #endif /* DEFLATE_H */
 
diff --git a/dep/src/zlib/example.c b/dep/src/zlib/example.c
index 7cf0a92a135..6c8a0ee7633 100644
--- a/dep/src/zlib/example.c
+++ b/dep/src/zlib/example.c
@@ -2,30 +2,38 @@
  * Copyright (C) 1995-2004 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* @(#) $Id$ */
+
 #include 
 #include "zlib.h"
+
 #ifdef STDC
 #  include 
 #  include 
 #endif
+
 #if defined(VMS) || defined(RISCOS)
 #  define TESTFILE "foo-gz"
 #else
 #  define TESTFILE "foo.gz"
 #endif
+
 #define CHECK_ERR(err, msg) { \
     if (err != Z_OK) { \
         fprintf(stderr, "%s error: %d\n", msg, err); \
         exit(1); \
     } \
 }
+
 const char hello[] = "hello, hello!";
 /* "hello world" would be more standard, but the repeated "hello"
  * stresses the compression code better, sorry...
  */
+
 const char dictionary[] = "hello";
 uLong dictId; /* Adler32 value of the dictionary */
+
 void test_compress      OF((Byte *compr, uLong comprLen,
                             Byte *uncompr, uLong uncomprLen));
 void test_gzio          OF((const char *fname,
@@ -44,6 +52,7 @@ void test_dict_deflate  OF((Byte *compr, uLong comprLen));
 void test_dict_inflate  OF((Byte *compr, uLong comprLen,
                             Byte *uncompr, uLong uncomprLen));
 int  main               OF((int argc, char *argv[]));
+
 /* ===========================================================================
  * Test compress() and uncompress()
  */
@@ -53,11 +62,15 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
 {
     int err;
     uLong len = (uLong)strlen(hello)+1;
+
     err = compress(compr, &comprLen, (const Bytef*)hello, len);
     CHECK_ERR(err, "compress");
+
     strcpy((char*)uncompr, "garbage");
+
     err = uncompress(uncompr, &uncomprLen, compr, comprLen);
     CHECK_ERR(err, "uncompress");
+
     if (strcmp((char*)uncompr, hello)) {
         fprintf(stderr, "bad uncompress\n");
         exit(1);
@@ -65,6 +78,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
         printf("uncompress(): %s\n", (char *)uncompr);
     }
 }
+
 /* ===========================================================================
  * Test read/write of .gz files
  */
@@ -80,6 +94,7 @@ void test_gzio(fname, uncompr, uncomprLen)
     int len = (int)strlen(hello)+1;
     gzFile file;
     z_off_t pos;
+
     file = gzopen(fname, "wb");
     if (file == NULL) {
         fprintf(stderr, "gzopen error\n");
@@ -96,12 +111,14 @@ void test_gzio(fname, uncompr, uncomprLen)
     }
     gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
     gzclose(file);
+
     file = gzopen(fname, "rb");
     if (file == NULL) {
         fprintf(stderr, "gzopen error\n");
         exit(1);
     }
     strcpy((char*)uncompr, "garbage");
+
     if (gzread(file, uncompr, (unsigned)uncomprLen) != len) {
         fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
         exit(1);
@@ -112,20 +129,24 @@ void test_gzio(fname, uncompr, uncomprLen)
     } else {
         printf("gzread(): %s\n", (char*)uncompr);
     }
+
     pos = gzseek(file, -8L, SEEK_CUR);
     if (pos != 6 || gztell(file) != pos) {
         fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
                 (long)pos, (long)gztell(file));
         exit(1);
     }
+
     if (gzgetc(file) != ' ') {
         fprintf(stderr, "gzgetc error\n");
         exit(1);
     }
+
     if (gzungetc(' ', file) != ' ') {
         fprintf(stderr, "gzungetc error\n");
         exit(1);
     }
+
     gzgets(file, (char*)uncompr, (int)uncomprLen);
     if (strlen((char*)uncompr) != 7) { /* " hello!" */
         fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
@@ -137,9 +158,11 @@ void test_gzio(fname, uncompr, uncomprLen)
     } else {
         printf("gzgets() after gzseek: %s\n", (char*)uncompr);
     }
+
     gzclose(file);
 #endif
 }
+
 /* ===========================================================================
  * Test deflate() with small buffers
  */
@@ -150,13 +173,17 @@ void test_deflate(compr, comprLen)
     z_stream c_stream; /* compression stream */
     int err;
     uLong len = (uLong)strlen(hello)+1;
+
     c_stream.zalloc = (alloc_func)0;
     c_stream.zfree = (free_func)0;
     c_stream.opaque = (voidpf)0;
+
     err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
     CHECK_ERR(err, "deflateInit");
+
     c_stream.next_in  = (Bytef*)hello;
     c_stream.next_out = compr;
+
     while (c_stream.total_in != len && c_stream.total_out < comprLen) {
         c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
         err = deflate(&c_stream, Z_NO_FLUSH);
@@ -169,9 +196,11 @@ void test_deflate(compr, comprLen)
         if (err == Z_STREAM_END) break;
         CHECK_ERR(err, "deflate");
     }
+
     err = deflateEnd(&c_stream);
     CHECK_ERR(err, "deflateEnd");
 }
+
 /* ===========================================================================
  * Test inflate() with small buffers
  */
@@ -181,23 +210,30 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
 {
     int err;
     z_stream d_stream; /* decompression stream */
+
     strcpy((char*)uncompr, "garbage");
+
     d_stream.zalloc = (alloc_func)0;
     d_stream.zfree = (free_func)0;
     d_stream.opaque = (voidpf)0;
+
     d_stream.next_in  = compr;
     d_stream.avail_in = 0;
     d_stream.next_out = uncompr;
+
     err = inflateInit(&d_stream);
     CHECK_ERR(err, "inflateInit");
+
     while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) {
         d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */
         err = inflate(&d_stream, Z_NO_FLUSH);
         if (err == Z_STREAM_END) break;
         CHECK_ERR(err, "inflate");
     }
+
     err = inflateEnd(&d_stream);
     CHECK_ERR(err, "inflateEnd");
+
     if (strcmp((char*)uncompr, hello)) {
         fprintf(stderr, "bad inflate\n");
         exit(1);
@@ -205,6 +241,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
         printf("inflate(): %s\n", (char *)uncompr);
     }
 }
+
 /* ===========================================================================
  * Test deflate() with large buffers and dynamic change of compression level
  */
@@ -214,13 +251,17 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
 {
     z_stream c_stream; /* compression stream */
     int err;
+
     c_stream.zalloc = (alloc_func)0;
     c_stream.zfree = (free_func)0;
     c_stream.opaque = (voidpf)0;
+
     err = deflateInit(&c_stream, Z_BEST_SPEED);
     CHECK_ERR(err, "deflateInit");
+
     c_stream.next_out = compr;
     c_stream.avail_out = (uInt)comprLen;
+
     /* At this point, uncompr is still mostly zeroes, so it should compress
      * very well:
      */
@@ -232,18 +273,21 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
         fprintf(stderr, "deflate not greedy\n");
         exit(1);
     }
+
     /* Feed in already compressed data and switch to no compression: */
     deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
     c_stream.next_in = compr;
     c_stream.avail_in = (uInt)comprLen/2;
     err = deflate(&c_stream, Z_NO_FLUSH);
     CHECK_ERR(err, "deflate");
+
     /* Switch back to compressing mode: */
     deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
     c_stream.next_in = uncompr;
     c_stream.avail_in = (uInt)uncomprLen;
     err = deflate(&c_stream, Z_NO_FLUSH);
     CHECK_ERR(err, "deflate");
+
     err = deflate(&c_stream, Z_FINISH);
     if (err != Z_STREAM_END) {
         fprintf(stderr, "deflate should report Z_STREAM_END\n");
@@ -252,6 +296,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
     err = deflateEnd(&c_stream);
     CHECK_ERR(err, "deflateEnd");
 }
+
 /* ===========================================================================
  * Test inflate() with large buffers
  */
@@ -261,14 +306,19 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
 {
     int err;
     z_stream d_stream; /* decompression stream */
+
     strcpy((char*)uncompr, "garbage");
+
     d_stream.zalloc = (alloc_func)0;
     d_stream.zfree = (free_func)0;
     d_stream.opaque = (voidpf)0;
+
     d_stream.next_in  = compr;
     d_stream.avail_in = (uInt)comprLen;
+
     err = inflateInit(&d_stream);
     CHECK_ERR(err, "inflateInit");
+
     for (;;) {
         d_stream.next_out = uncompr;            /* discard the output */
         d_stream.avail_out = (uInt)uncomprLen;
@@ -276,8 +326,10 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
         if (err == Z_STREAM_END) break;
         CHECK_ERR(err, "large inflate");
     }
+
     err = inflateEnd(&d_stream);
     CHECK_ERR(err, "inflateEnd");
+
     if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
         fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
         exit(1);
@@ -285,6 +337,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
         printf("large_inflate(): OK\n");
     }
 }
+
 /* ===========================================================================
  * Test deflate() with full flush
  */
@@ -295,27 +348,34 @@ void test_flush(compr, comprLen)
     z_stream c_stream; /* compression stream */
     int err;
     uInt len = (uInt)strlen(hello)+1;
+
     c_stream.zalloc = (alloc_func)0;
     c_stream.zfree = (free_func)0;
     c_stream.opaque = (voidpf)0;
+
     err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
     CHECK_ERR(err, "deflateInit");
+
     c_stream.next_in  = (Bytef*)hello;
     c_stream.next_out = compr;
     c_stream.avail_in = 3;
     c_stream.avail_out = (uInt)*comprLen;
     err = deflate(&c_stream, Z_FULL_FLUSH);
     CHECK_ERR(err, "deflate");
+
     compr[3]++; /* force an error in first compressed block */
     c_stream.avail_in = len - 3;
+
     err = deflate(&c_stream, Z_FINISH);
     if (err != Z_STREAM_END) {
         CHECK_ERR(err, "deflate");
     }
     err = deflateEnd(&c_stream);
     CHECK_ERR(err, "deflateEnd");
+
     *comprLen = c_stream.total_out;
 }
+
 /* ===========================================================================
  * Test inflateSync()
  */
@@ -325,21 +385,29 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
 {
     int err;
     z_stream d_stream; /* decompression stream */
+
     strcpy((char*)uncompr, "garbage");
+
     d_stream.zalloc = (alloc_func)0;
     d_stream.zfree = (free_func)0;
     d_stream.opaque = (voidpf)0;
+
     d_stream.next_in  = compr;
     d_stream.avail_in = 2; /* just read the zlib header */
+
     err = inflateInit(&d_stream);
     CHECK_ERR(err, "inflateInit");
+
     d_stream.next_out = uncompr;
     d_stream.avail_out = (uInt)uncomprLen;
+
     inflate(&d_stream, Z_NO_FLUSH);
     CHECK_ERR(err, "inflate");
+
     d_stream.avail_in = (uInt)comprLen-2;   /* read all compressed data */
     err = inflateSync(&d_stream);           /* but skip the damaged part */
     CHECK_ERR(err, "inflateSync");
+
     err = inflate(&d_stream, Z_FINISH);
     if (err != Z_DATA_ERROR) {
         fprintf(stderr, "inflate should report DATA_ERROR\n");
@@ -348,8 +416,10 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
     }
     err = inflateEnd(&d_stream);
     CHECK_ERR(err, "inflateEnd");
+
     printf("after inflateSync(): hel%s\n", (char *)uncompr);
 }
+
 /* ===========================================================================
  * Test deflate() with preset dictionary
  */
@@ -359,19 +429,25 @@ void test_dict_deflate(compr, comprLen)
 {
     z_stream c_stream; /* compression stream */
     int err;
+
     c_stream.zalloc = (alloc_func)0;
     c_stream.zfree = (free_func)0;
     c_stream.opaque = (voidpf)0;
+
     err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
     CHECK_ERR(err, "deflateInit");
+
     err = deflateSetDictionary(&c_stream,
                                (const Bytef*)dictionary, sizeof(dictionary));
     CHECK_ERR(err, "deflateSetDictionary");
+
     dictId = c_stream.adler;
     c_stream.next_out = compr;
     c_stream.avail_out = (uInt)comprLen;
+
     c_stream.next_in = (Bytef*)hello;
     c_stream.avail_in = (uInt)strlen(hello)+1;
+
     err = deflate(&c_stream, Z_FINISH);
     if (err != Z_STREAM_END) {
         fprintf(stderr, "deflate should report Z_STREAM_END\n");
@@ -380,6 +456,7 @@ void test_dict_deflate(compr, comprLen)
     err = deflateEnd(&c_stream);
     CHECK_ERR(err, "deflateEnd");
 }
+
 /* ===========================================================================
  * Test inflate() with a preset dictionary
  */
@@ -389,16 +466,22 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
 {
     int err;
     z_stream d_stream; /* decompression stream */
+
     strcpy((char*)uncompr, "garbage");
+
     d_stream.zalloc = (alloc_func)0;
     d_stream.zfree = (free_func)0;
     d_stream.opaque = (voidpf)0;
+
     d_stream.next_in  = compr;
     d_stream.avail_in = (uInt)comprLen;
+
     err = inflateInit(&d_stream);
     CHECK_ERR(err, "inflateInit");
+
     d_stream.next_out = uncompr;
     d_stream.avail_out = (uInt)uncomprLen;
+
     for (;;) {
         err = inflate(&d_stream, Z_NO_FLUSH);
         if (err == Z_STREAM_END) break;
@@ -412,8 +495,10 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
         }
         CHECK_ERR(err, "inflate with dict");
     }
+
     err = inflateEnd(&d_stream);
     CHECK_ERR(err, "inflateEnd");
+
     if (strcmp((char*)uncompr, hello)) {
         fprintf(stderr, "bad inflate with dict\n");
         exit(1);
@@ -421,9 +506,11 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
         printf("inflate with dictionary: %s\n", (char *)uncompr);
     }
 }
+
 /* ===========================================================================
  * Usage:  example [output.gz  [input.gz]]
  */
+
 int main(argc, argv)
     int argc;
     char *argv[];
@@ -432,14 +519,18 @@ int main(argc, argv)
     uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
     uLong uncomprLen = comprLen;
     static const char* myVersion = ZLIB_VERSION;
+
     if (zlibVersion()[0] != myVersion[0]) {
         fprintf(stderr, "incompatible zlib version\n");
         exit(1);
+
     } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
         fprintf(stderr, "warning: different zlib version\n");
     }
+
     printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
             ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
+
     compr    = (Byte*)calloc((uInt)comprLen, 1);
     uncompr  = (Byte*)calloc((uInt)uncomprLen, 1);
     /* compr and uncompr are cleared to avoid reading uninitialized
@@ -450,18 +541,25 @@ int main(argc, argv)
         exit(1);
     }
     test_compress(compr, comprLen, uncompr, uncomprLen);
+
     test_gzio((argc > 1 ? argv[1] : TESTFILE),
               uncompr, uncomprLen);
+
     test_deflate(compr, comprLen);
     test_inflate(compr, comprLen, uncompr, uncomprLen);
+
     test_large_deflate(compr, comprLen, uncompr, uncomprLen);
     test_large_inflate(compr, comprLen, uncompr, uncomprLen);
+
     test_flush(compr, &comprLen);
     test_sync(compr, comprLen, uncompr, uncomprLen);
     comprLen = uncomprLen;
+
     test_dict_deflate(compr, comprLen);
     test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
+
     free(compr);
     free(uncompr);
+
     return 0;
 }
diff --git a/dep/src/zlib/gzio.c b/dep/src/zlib/gzio.c
index 7143aabebe3..7e90f4928fc 100644
--- a/dep/src/zlib/gzio.c
+++ b/dep/src/zlib/gzio.c
@@ -4,15 +4,21 @@
  *
  * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
  */
+
 /* @(#) $Id$ */
+
 #include 
+
 #include "zutil.h"
+
 #ifdef NO_DEFLATE       /* for compatibility with old definition */
 #  define NO_GZCOMPRESS
 #endif
+
 #ifndef NO_DUMMY_DECL
 struct internal_state {int dummy;}; /* for buggy compilers */
 #endif
+
 #ifndef Z_BUFSIZE
 #  ifdef MAXSEG_64K
 #    define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
@@ -23,17 +29,22 @@ struct internal_state {int dummy;}; /* for buggy compilers */
 #ifndef Z_PRINTF_BUFSIZE
 #  define Z_PRINTF_BUFSIZE 4096
 #endif
+
 #ifdef __MVS__
 #  pragma map (fdopen , "\174\174FDOPEN")
    FILE *fdopen(int, const char *);
 #endif
+
 #ifndef STDC
 extern voidp  malloc OF((uInt size));
 extern void   free   OF((voidpf ptr));
 #endif
+
 #define ALLOC(size) malloc(size)
 #define TRYFREE(p) {if (p) free(p);}
+
 static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
+
 /* gzip flag byte */
 #define ASCII_FLAG   0x01 /* bit 0 set: file probably ascii text */
 #define HEAD_CRC     0x02 /* bit 1 set: header CRC present */
@@ -41,6 +52,7 @@ static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
 #define ORIG_NAME    0x08 /* bit 3 set: original file name present */
 #define COMMENT      0x10 /* bit 4 set: file comment present */
 #define RESERVED     0xE0 /* bits 5..7: reserved */
+
 typedef struct gz_stream {
     z_stream stream;
     int      z_err;   /* error code for last stream operation */
@@ -60,6 +72,7 @@ typedef struct gz_stream {
     int      last;    /* true if push-back is last character */
 } gz_stream;
 
+
 local gzFile gz_open      OF((const char *path, const char *mode, int  fd));
 local int do_flush        OF((gzFile file, int flush));
 local int    get_byte     OF((gz_stream *s));
@@ -67,6 +80,7 @@ local void   check_header OF((gz_stream *s));
 local int    destroy      OF((gz_stream *s));
 local void   putLong      OF((FILE *file, uLong x));
 local uLong  getLong      OF((gz_stream *s));
+
 /* ===========================================================================
      Opens a gzip (.gz) file for reading or writing. The mode parameter
    is as in fopen ("rb" or "wb"). The file is given either by file descriptor
@@ -88,9 +102,12 @@ local gzFile gz_open (path, mode, fd)
     gz_stream *s;
     char fmode[80]; /* copy of mode, without the compression level */
     char *m = fmode;
+
     if (!path || !mode) return Z_NULL;
+
     s = (gz_stream *)ALLOC(sizeof(gz_stream));
     if (!s) return Z_NULL;
+
     s->stream.zalloc = (alloc_func)0;
     s->stream.zfree = (free_func)0;
     s->stream.opaque = (voidpf)0;
@@ -106,11 +123,13 @@ local gzFile gz_open (path, mode, fd)
     s->crc = crc32(0L, Z_NULL, 0);
     s->msg = NULL;
     s->transparent = 0;
+
     s->path = (char*)ALLOC(strlen(path)+1);
     if (s->path == NULL) {
         return destroy(s), (gzFile)Z_NULL;
     }
     strcpy(s->path, path); /* do this early for debugging */
+
     s->mode = '\0';
     do {
         if (*p == 'r') s->mode = 'r';
@@ -128,6 +147,7 @@ local gzFile gz_open (path, mode, fd)
         }
     } while (*p++ && m != fmode + sizeof(fmode));
     if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
+
     if (s->mode == 'w') {
 #ifdef NO_GZCOMPRESS
         err = Z_STREAM_ERROR;
@@ -135,6 +155,7 @@ local gzFile gz_open (path, mode, fd)
         err = deflateInit2(&(s->stream), level,
                            Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
         /* windowBits is passed < 0 to suppress zlib header */
+
         s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
 #endif
         if (err != Z_OK || s->outbuf == Z_NULL) {
@@ -142,6 +163,7 @@ local gzFile gz_open (path, mode, fd)
         }
     } else {
         s->stream.next_in  = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
+
         err = inflateInit2(&(s->stream), -MAX_WBITS);
         /* windowBits is passed < 0 to tell that there is no zlib header.
          * Note that in this case inflate *requires* an extra "dummy" byte
@@ -154,8 +176,10 @@ local gzFile gz_open (path, mode, fd)
         }
     }
     s->stream.avail_out = Z_BUFSIZE;
+
     errno = 0;
     s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
+
     if (s->file == NULL) {
         return destroy(s), (gzFile)Z_NULL;
     }
@@ -174,8 +198,10 @@ local gzFile gz_open (path, mode, fd)
         check_header(s); /* skip the .gz header */
         s->start = ftell(s->file) - s->stream.avail_in;
     }
+
     return (gzFile)s;
 }
+
 /* ===========================================================================
      Opens a gzip (.gz) file for reading or writing.
 */
@@ -185,6 +211,7 @@ gzFile ZEXPORT gzopen (path, mode)
 {
     return gz_open (path, mode, -1);
 }
+
 /* ===========================================================================
      Associate a gzFile with the file descriptor fd. fd is not dup'ed here
    to mimic the behavio(u)r of fdopen.
@@ -194,10 +221,13 @@ gzFile ZEXPORT gzdopen (fd, mode)
     const char *mode;
 {
     char name[46];      /* allow for up to 128-bit integers */
+
     if (fd < 0) return (gzFile)Z_NULL;
     sprintf(name, "", fd); /* for debugging */
+
     return gz_open (name, mode, fd);
 }
+
 /* ===========================================================================
  * Update the compression level and strategy
  */
@@ -207,17 +237,22 @@ int ZEXPORT gzsetparams (file, level, strategy)
     int strategy;
 {
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
+
     /* Make room to allow flushing */
     if (s->stream.avail_out == 0) {
+
         s->stream.next_out = s->outbuf;
         if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
             s->z_err = Z_ERRNO;
         }
         s->stream.avail_out = Z_BUFSIZE;
     }
+
     return deflateParams (&(s->stream), level, strategy);
 }
+
 /* ===========================================================================
      Read a byte from a gz_stream; update next_in and avail_in. Return EOF
    for end of file.
@@ -240,6 +275,7 @@ local int get_byte(s)
     s->stream.avail_in--;
     return *(s->stream.next_in)++;
 }
+
 /* ===========================================================================
       Check the gzip header of a gz_stream opened for reading. Set the stream
     mode to transparent if the gzip magic header is not present; set s->err
@@ -256,6 +292,7 @@ local void check_header(s)
     int flags;  /* flags byte */
     uInt len;
     int c;
+
     /* Assure two bytes in the buffer so we can peek ahead -- handle case
        where first byte of header is at the end of the buffer after the last
        gzip segment */
@@ -272,6 +309,7 @@ local void check_header(s)
             return;
         }
     }
+
     /* Peek ahead to check the gzip magic header */
     if (s->stream.next_in[0] != gz_magic[0] ||
         s->stream.next_in[1] != gz_magic[1]) {
@@ -280,6 +318,7 @@ local void check_header(s)
     }
     s->stream.avail_in -= 2;
     s->stream.next_in += 2;
+
     /* Check the rest of the gzip header */
     method = get_byte(s);
     flags = get_byte(s);
@@ -287,8 +326,10 @@ local void check_header(s)
         s->z_err = Z_DATA_ERROR;
         return;
     }
+
     /* Discard time, xflags and OS code: */
     for (len = 0; len < 6; len++) (void)get_byte(s);
+
     if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
         len  =  (uInt)get_byte(s);
         len += ((uInt)get_byte(s))<<8;
@@ -306,6 +347,7 @@ local void check_header(s)
     }
     s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
 }
+
  /* ===========================================================================
  * Cleanup then free the given gz_stream. Return a zlib error code.
    Try freeing in the reverse order of allocations.
@@ -314,8 +356,11 @@ local int destroy (s)
     gz_stream *s;
 {
     int err = Z_OK;
+
     if (!s) return Z_STREAM_ERROR;
+
     TRYFREE(s->msg);
+
     if (s->stream.state != NULL) {
         if (s->mode == 'w') {
 #ifdef NO_GZCOMPRESS
@@ -334,12 +379,14 @@ local int destroy (s)
             err = Z_ERRNO;
     }
     if (s->z_err < 0) err = s->z_err;
+
     TRYFREE(s->inbuf);
     TRYFREE(s->outbuf);
     TRYFREE(s->path);
     TRYFREE(s);
     return err;
 }
+
 /* ===========================================================================
      Reads the given number of uncompressed bytes from the compressed file.
    gzread returns the number of bytes actually read (0 for end of file).
@@ -352,12 +399,16 @@ int ZEXPORT gzread (file, buf, len)
     gz_stream *s = (gz_stream*)file;
     Bytef *start = (Bytef*)buf; /* starting point for crc computation */
     Byte  *next_out; /* == stream.next_out but not forced far (for MSDOS) */
+
     if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
+
     if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
     if (s->z_err == Z_STREAM_END) return 0;  /* EOF */
+
     next_out = (Byte*)buf;
     s->stream.next_out = (Bytef*)buf;
     s->stream.avail_out = len;
+
     if (s->stream.avail_out && s->back != EOF) {
         *next_out++ = s->back;
         s->stream.next_out++;
@@ -370,7 +421,9 @@ int ZEXPORT gzread (file, buf, len)
             return 1;
         }
     }
+
     while (s->stream.avail_out != 0) {
+
         if (s->transparent) {
             /* Copy first the lookahead bytes: */
             uInt n = s->stream.avail_in;
@@ -394,6 +447,7 @@ int ZEXPORT gzread (file, buf, len)
             return (int)len;
         }
         if (s->stream.avail_in == 0 && !s->z_eof) {
+
             errno = 0;
             s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
             if (s->stream.avail_in == 0) {
@@ -410,10 +464,12 @@ int ZEXPORT gzread (file, buf, len)
         s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
         s->in -= s->stream.avail_in;
         s->out -= s->stream.avail_out;
+
         if (s->z_err == Z_STREAM_END) {
             /* Check CRC and original size */
             s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
             start = s->stream.next_out;
+
             if (getLong(s) != s->crc) {
                 s->z_err = Z_DATA_ERROR;
             } else {
@@ -432,12 +488,14 @@ int ZEXPORT gzread (file, buf, len)
         if (s->z_err != Z_OK || s->z_eof) break;
     }
     s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
+
     if (len == s->stream.avail_out &&
         (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
         return -1;
     return (int)(len - s->stream.avail_out);
 }
 
+
 /* ===========================================================================
       Reads one byte from the compressed file. gzgetc returns this byte
    or -1 in case of end of file or error.
@@ -446,9 +504,11 @@ int ZEXPORT gzgetc(file)
     gzFile file;
 {
     unsigned char c;
+
     return gzread(file, &c, 1) == 1 ? c : -1;
 }
 
+
 /* ===========================================================================
       Push one byte back onto the stream.
 */
@@ -457,6 +517,7 @@ int ZEXPORT gzungetc(c, file)
     gzFile file;
 {
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
     s->back = c;
     s->out--;
@@ -466,12 +527,14 @@ int ZEXPORT gzungetc(c, file)
     return c;
 }
 
+
 /* ===========================================================================
       Reads bytes from the compressed file until len-1 characters are
    read, or a newline character is read and transferred to buf, or an
    end-of-file condition is encountered.  The string is then terminated
    with a null character.
       gzgets returns buf, or Z_NULL in case of error.
+
       The current implementation is not optimized at all.
 */
 char * ZEXPORT gzgets(file, buf, len)
@@ -481,11 +544,13 @@ char * ZEXPORT gzgets(file, buf, len)
 {
     char *b = buf;
     if (buf == Z_NULL || len <= 0) return Z_NULL;
+
     while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
     *buf = '\0';
     return b == buf && len > 0 ? Z_NULL : b;
 }
 
+
 #ifndef NO_GZCOMPRESS
 /* ===========================================================================
      Writes the given number of uncompressed bytes into the compressed file.
@@ -497,11 +562,16 @@ int ZEXPORT gzwrite (file, buf, len)
     unsigned len;
 {
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
+
     s->stream.next_in = (Bytef*)buf;
     s->stream.avail_in = len;
+
     while (s->stream.avail_in != 0) {
+
         if (s->stream.avail_out == 0) {
+
             s->stream.next_out = s->outbuf;
             if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
                 s->z_err = Z_ERRNO;
@@ -517,9 +587,11 @@ int ZEXPORT gzwrite (file, buf, len)
         if (s->z_err != Z_OK) break;
     }
     s->crc = crc32(s->crc, (const Bytef *)buf, len);
+
     return (int)(len - s->stream.avail_in);
 }
 
+
 /* ===========================================================================
      Converts, formats, and writes the args to the compressed file under
    control of the format string, as in fprintf. gzprintf returns the number of
@@ -527,11 +599,13 @@ int ZEXPORT gzwrite (file, buf, len)
 */
 #ifdef STDC
 #include 
+
 int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
 {
     char buf[Z_PRINTF_BUFSIZE];
     va_list va;
     int len;
+
     buf[sizeof(buf) - 1] = 0;
     va_start(va, format);
 #ifdef NO_vsnprintf
@@ -559,6 +633,7 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
     return gzwrite(file, buf, (unsigned)len);
 }
 #else /* not ANSI C */
+
 int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
                        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
     gzFile file;
@@ -568,6 +643,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
 {
     char buf[Z_PRINTF_BUFSIZE];
     int len;
+
     buf[sizeof(buf) - 1] = 0;
 #ifdef NO_snprintf
 #  ifdef HAS_sprintf_void
@@ -594,6 +670,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
     return gzwrite(file, buf, len);
 }
 #endif
+
 /* ===========================================================================
       Writes c, converted to an unsigned char, into the compressed file.
    gzputc returns the value that was written, or -1 in case of error.
@@ -603,9 +680,11 @@ int ZEXPORT gzputc(file, c)
     int c;
 {
     unsigned char cc = (unsigned char) c; /* required for big endian systems */
+
     return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
 }
 
+
 /* ===========================================================================
       Writes the given null-terminated string to the compressed file, excluding
    the terminating null character.
@@ -618,6 +697,7 @@ int ZEXPORT gzputs(file, s)
     return gzwrite(file, (char*)s, (unsigned)strlen(s));
 }
 
+
 /* ===========================================================================
      Flushes all pending output into the compressed file. The parameter
    flush is as in the deflate() function.
@@ -629,10 +709,14 @@ local int do_flush (file, flush)
     uInt len;
     int done = 0;
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
+
     s->stream.avail_in = 0; /* should be zero already anyway */
+
     for (;;) {
         len = Z_BUFSIZE - s->stream.avail_out;
+
         if (len != 0) {
             if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
                 s->z_err = Z_ERRNO;
@@ -645,27 +729,33 @@ local int do_flush (file, flush)
         s->out += s->stream.avail_out;
         s->z_err = deflate(&(s->stream), flush);
         s->out -= s->stream.avail_out;
+
         /* Ignore the second of two consecutive flushes: */
         if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
+
         /* deflate has finished flushing only when it hasn't used up
          * all the available space in the output buffer:
          */
         done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
+
         if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
     }
     return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
 }
+
 int ZEXPORT gzflush (file, flush)
      gzFile file;
      int flush;
 {
     gz_stream *s = (gz_stream*)file;
     int err = do_flush (file, flush);
+
     if (err) return err;
     fflush(s->file);
     return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
 }
 #endif /* NO_GZCOMPRESS */
+
 /* ===========================================================================
       Sets the starting position for the next gzread or gzwrite on the given
    compressed file. The offset represents a number of bytes in the
@@ -680,10 +770,12 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
     int whence;
 {
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL || whence == SEEK_END ||
         s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
         return -1L;
     }
+
     if (s->mode == 'w') {
 #ifdef NO_GZCOMPRESS
         return -1L;
@@ -692,6 +784,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
             offset -= s->in;
         }
         if (offset < 0) return -1L;
+
         /* At this point, offset is the number of zero bytes to write. */
         if (s->inbuf == Z_NULL) {
             s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
@@ -701,28 +794,34 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
         while (offset > 0)  {
             uInt size = Z_BUFSIZE;
             if (offset < Z_BUFSIZE) size = (uInt)offset;
+
             size = gzwrite(file, s->inbuf, size);
             if (size == 0) return -1L;
+
             offset -= size;
         }
         return s->in;
 #endif
     }
     /* Rest of function is for reading only */
+
     /* compute absolute position */
     if (whence == SEEK_CUR) {
         offset += s->out;
     }
     if (offset < 0) return -1L;
+
     if (s->transparent) {
         /* map to fseek */
         s->back = EOF;
         s->stream.avail_in = 0;
         s->stream.next_in = s->inbuf;
         if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
+
         s->in = s->out = offset;
         return offset;
     }
+
     /* For a negative seek, rewind and use positive seek */
     if (offset >= s->out) {
         offset -= s->out;
@@ -730,6 +829,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
         return -1L;
     }
     /* offset is now the number of bytes to skip. */
+
     if (offset != 0 && s->outbuf == Z_NULL) {
         s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
         if (s->outbuf == Z_NULL) return -1L;
@@ -743,12 +843,14 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
     while (offset > 0)  {
         int size = Z_BUFSIZE;
         if (offset < Z_BUFSIZE) size = (int)offset;
+
         size = gzread(file, s->outbuf, (uInt)size);
         if (size <= 0) return -1L;
         offset -= size;
     }
     return s->out;
 }
+
 /* ===========================================================================
      Rewinds input file.
 */
@@ -756,7 +858,9 @@ int ZEXPORT gzrewind (file)
     gzFile file;
 {
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL || s->mode != 'r') return -1;
+
     s->z_err = Z_OK;
     s->z_eof = 0;
     s->back = EOF;
@@ -768,6 +872,7 @@ int ZEXPORT gzrewind (file)
     s->out = 0;
     return fseek(s->file, s->start, SEEK_SET);
 }
+
 /* ===========================================================================
      Returns the starting position for the next gzread or gzwrite on the
    given compressed file. This position represents a number of bytes in the
@@ -778,6 +883,7 @@ z_off_t ZEXPORT gztell (file)
 {
     return gzseek(file, 0L, SEEK_CUR);
 }
+
 /* ===========================================================================
      Returns 1 when EOF has previously been detected reading the given
    input stream, otherwise zero.
@@ -786,6 +892,7 @@ int ZEXPORT gzeof (file)
     gzFile file;
 {
     gz_stream *s = (gz_stream*)file;
+
     /* With concatenated compressed files that can have embedded
      * crc trailers, z_eof is no longer the only/best indicator of EOF
      * on a gz_stream. Handle end-of-stream error explicitly here.
@@ -794,6 +901,7 @@ int ZEXPORT gzeof (file)
     if (s->z_eof) return 1;
     return s->z_err == Z_STREAM_END;
 }
+
 /* ===========================================================================
      Returns 1 if reading and doing so transparently, otherwise zero.
 */
@@ -801,9 +909,11 @@ int ZEXPORT gzdirect (file)
     gzFile file;
 {
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL || s->mode != 'r') return 0;
     return s->transparent;
 }
+
 /* ===========================================================================
    Outputs a long in LSB order to the given file
 */
@@ -817,6 +927,7 @@ local void putLong (file, x)
         x >>= 8;
     }
 }
+
 /* ===========================================================================
    Reads a long in LSB order from the given gz_stream. Sets z_err in case
    of error.
@@ -826,6 +937,7 @@ local uLong getLong (s)
 {
     uLong x = (uLong)get_byte(s);
     int c;
+
     x += ((uLong)get_byte(s))<<8;
     x += ((uLong)get_byte(s))<<16;
     c = get_byte(s);
@@ -833,6 +945,7 @@ local uLong getLong (s)
     x += ((uLong)c)<<24;
     return x;
 }
+
 /* ===========================================================================
      Flushes all pending output if necessary, closes the compressed file
    and deallocates all the (de)compression state.
@@ -841,24 +954,29 @@ int ZEXPORT gzclose (file)
     gzFile file;
 {
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL) return Z_STREAM_ERROR;
+
     if (s->mode == 'w') {
 #ifdef NO_GZCOMPRESS
         return Z_STREAM_ERROR;
 #else
         if (do_flush (file, Z_FINISH) != Z_OK)
             return destroy((gz_stream*)file);
+
         putLong (s->file, s->crc);
         putLong (s->file, (uLong)(s->in & 0xffffffff));
 #endif
     }
     return destroy((gz_stream*)file);
 }
+
 #ifdef STDC
 #  define zstrerror(errnum) strerror(errnum)
 #else
 #  define zstrerror(errnum) ""
 #endif
+
 /* ===========================================================================
      Returns the error message for the last error which occurred on the
    given compressed file. errnum is set to zlib error number. If an
@@ -872,14 +990,18 @@ const char * ZEXPORT gzerror (file, errnum)
 {
     char *m;
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL) {
         *errnum = Z_STREAM_ERROR;
         return (const char*)ERR_MSG(Z_STREAM_ERROR);
     }
     *errnum = s->z_err;
     if (*errnum == Z_OK) return (const char*)"";
+
     m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
+
     if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
+
     TRYFREE(s->msg);
     s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
     if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
@@ -888,6 +1010,7 @@ const char * ZEXPORT gzerror (file, errnum)
     strcat(s->msg, m);
     return (const char*)s->msg;
 }
+
 /* ===========================================================================
      Clear the error and end-of-file flags, and do the same for the real file.
 */
@@ -895,6 +1018,7 @@ void ZEXPORT gzclearerr (file)
     gzFile file;
 {
     gz_stream *s = (gz_stream*)file;
+
     if (s == NULL) return;
     if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
     s->z_eof = 0;
diff --git a/dep/src/zlib/infback.c b/dep/src/zlib/infback.c
index 80f35cc59ac..455dbc9ee84 100644
--- a/dep/src/zlib/infback.c
+++ b/dep/src/zlib/infback.c
@@ -2,21 +2,26 @@
  * Copyright (C) 1995-2005 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /*
    This code is largely copied from inflate.c.  Normally either infback.o or
    inflate.o would be linked into an application--not both.  The interface
    with inffast.c is retained so that optimized assembler-coded versions of
    inflate_fast() can be used with either inflate.c or infback.c.
  */
+
 #include "zutil.h"
 #include "inftrees.h"
 #include "inflate.h"
 #include "inffast.h"
+
 /* function prototypes */
 local void fixedtables OF((struct inflate_state FAR *state));
+
 /*
    strm provides memory allocation functions in zalloc and zfree, or
    Z_NULL to use the library memory allocation functions.
+
    windowBits is in the range 8..15, and window is a user-supplied
    window and output buffer that is 2**windowBits bytes.
  */
@@ -28,6 +33,7 @@ const char *version;
 int stream_size;
 {
     struct inflate_state FAR *state;
+
     if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
         stream_size != (int)(sizeof(z_stream)))
         return Z_VERSION_ERROR;
@@ -53,6 +59,7 @@ int stream_size;
     state->whave = 0;
     return Z_OK;
 }
+
 /*
    Return state with length and distance decoding tables and index sizes set to
    fixed code decoding.  Normally this returns fixed tables from inffixed.h.
@@ -70,10 +77,12 @@ struct inflate_state FAR *state;
     static int virgin = 1;
     static code *lenfix, *distfix;
     static code fixed[544];
+
     /* build fixed huffman tables if first call (may not be thread safe) */
     if (virgin) {
         unsigned sym, bits;
         static code *next;
+
         /* literal/length table */
         sym = 0;
         while (sym < 144) state->lens[sym++] = 8;
@@ -84,12 +93,14 @@ struct inflate_state FAR *state;
         lenfix = next;
         bits = 9;
         inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
+
         /* distance table */
         sym = 0;
         while (sym < 32) state->lens[sym++] = 5;
         distfix = next;
         bits = 5;
         inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
+
         /* do this just once */
         virgin = 0;
     }
@@ -101,7 +112,9 @@ struct inflate_state FAR *state;
     state->distcode = distfix;
     state->distbits = 5;
 }
+
 /* Macros for inflateBack(): */
+
 /* Load returned state from inflate_fast() */
 #define LOAD() \
     do { \
@@ -112,6 +125,7 @@ struct inflate_state FAR *state;
         hold = state->hold; \
         bits = state->bits; \
     } while (0)
+
 /* Set state from registers for inflate_fast() */
 #define RESTORE() \
     do { \
@@ -122,12 +136,14 @@ struct inflate_state FAR *state;
         state->hold = hold; \
         state->bits = bits; \
     } while (0)
+
 /* Clear the input bit accumulator */
 #define INITBITS() \
     do { \
         hold = 0; \
         bits = 0; \
     } while (0)
+
 /* Assure that some input is available.  If input is requested, but denied,
    then return a Z_BUF_ERROR from inflateBack(). */
 #define PULL() \
@@ -141,6 +157,7 @@ struct inflate_state FAR *state;
             } \
         } \
     } while (0)
+
 /* Get a byte of input into the bit accumulator, or return from inflateBack()
    with an error if there is no input available. */
 #define PULLBYTE() \
@@ -150,6 +167,7 @@ struct inflate_state FAR *state;
         hold += (unsigned long)(*next++) << bits; \
         bits += 8; \
     } while (0)
+
 /* Assure that there are at least n bits in the bit accumulator.  If there is
    not enough available input to do that, then return from inflateBack() with
    an error. */
@@ -158,21 +176,25 @@ struct inflate_state FAR *state;
         while (bits < (unsigned)(n)) \
             PULLBYTE(); \
     } while (0)
+
 /* Return the low n bits of the bit accumulator (n < 16) */
 #define BITS(n) \
     ((unsigned)hold & ((1U << (n)) - 1))
+
 /* Remove n bits from the bit accumulator */
 #define DROPBITS(n) \
     do { \
         hold >>= (n); \
         bits -= (unsigned)(n); \
     } while (0)
+
 /* Remove zero to seven bits as needed to go to a byte boundary */
 #define BYTEBITS() \
     do { \
         hold >>= bits & 7; \
         bits -= bits & 7; \
     } while (0)
+
 /* Assure that some output space is available, by writing out the window
    if it's full.  If the write fails, return from inflateBack() with a
    Z_BUF_ERROR. */
@@ -188,10 +210,12 @@ struct inflate_state FAR *state;
             } \
         } \
     } while (0)
+
 /*
    strm provides the memory allocation functions and window buffer on input,
    and provides information on the unused input on return.  For Z_DATA_ERROR
    returns, strm will also provide an error message.
+
    in() and out() are the call-back input and output functions.  When
    inflateBack() needs more input, it calls in().  When inflateBack() has
    filled the window with output, or when it completes with data in the
@@ -199,10 +223,12 @@ struct inflate_state FAR *state;
    change the provided input until in() is called again or inflateBack()
    returns.  The application must not change the window/output buffer until
    inflateBack() returns.
+
    in() and out() are called with a descriptor parameter provided in the
    inflateBack() call.  This parameter can be a structure that provides the
    information required to do the read or write, as well as accumulated
    information on the input and output such as totals and check values.
+
    in() should return zero on failure.  out() should return non-zero on
    failure.  If either in() or out() fails, than inflateBack() returns a
    Z_BUF_ERROR.  strm->next_in can be checked for Z_NULL to see whether it
@@ -233,10 +259,12 @@ void FAR *out_desc;
     int ret;                    /* return code */
     static const unsigned short order[19] = /* permutation of code lengths */
         {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
+
     /* Check that the strm exists and that the state was initialized */
     if (strm == Z_NULL || strm->state == Z_NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
+
     /* Reset the state */
     strm->msg = Z_NULL;
     state->mode = TYPE;
@@ -248,6 +276,7 @@ void FAR *out_desc;
     bits = 0;
     put = state->window;
     left = state->wsize;
+
     /* Inflate until end of block marked as last */
     for (;;)
         switch (state->mode) {
@@ -284,6 +313,7 @@ void FAR *out_desc;
             }
             DROPBITS(2);
             break;
+
         case STORED:
             /* get and verify stored block length */
             BYTEBITS();                         /* go to byte boundary */
@@ -297,6 +327,7 @@ void FAR *out_desc;
             Tracev((stderr, "inflate:       stored length %u\n",
                     state->length));
             INITBITS();
+
             /* copy stored block from input to output */
             while (state->length != 0) {
                 copy = state->length;
@@ -314,6 +345,7 @@ void FAR *out_desc;
             Tracev((stderr, "inflate:       stored end\n"));
             state->mode = TYPE;
             break;
+
         case TABLE:
             /* get dynamic table entries descriptor */
             NEEDBITS(14);
@@ -331,6 +363,7 @@ void FAR *out_desc;
             }
 #endif
             Tracev((stderr, "inflate:       table sizes ok\n"));
+
             /* get code length code lengths (not a typo) */
             state->have = 0;
             while (state->have < state->ncode) {
@@ -351,6 +384,7 @@ void FAR *out_desc;
                 break;
             }
             Tracev((stderr, "inflate:       code lengths ok\n"));
+
             /* get length and distance code code lengths */
             state->have = 0;
             while (state->have < state->nlen + state->ndist) {
@@ -400,8 +434,10 @@ void FAR *out_desc;
                         state->lens[state->have++] = (unsigned short)len;
                 }
             }
+
             /* handle error breaks in while */
             if (state->mode == BAD) break;
+
             /* build code tables */
             state->next = state->codes;
             state->lencode = (code const FAR *)(state->next);
@@ -424,6 +460,7 @@ void FAR *out_desc;
             }
             Tracev((stderr, "inflate:       codes ok\n"));
             state->mode = LEN;
+
         case LEN:
             /* use inflate_fast() if we have enough input and output */
             if (have >= 6 && left >= 258) {
@@ -434,6 +471,7 @@ void FAR *out_desc;
                 LOAD();
                 break;
             }
+
             /* get a literal, length, or end-of-block code */
             for (;;) {
                 this = state->lencode[BITS(state->lenbits)];
@@ -452,6 +490,7 @@ void FAR *out_desc;
             }
             DROPBITS(this.bits);
             state->length = (unsigned)this.val;
+
             /* process literal */
             if (this.op == 0) {
                 Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
@@ -463,18 +502,21 @@ void FAR *out_desc;
                 state->mode = LEN;
                 break;
             }
+
             /* process end of block */
             if (this.op & 32) {
                 Tracevv((stderr, "inflate:         end of block\n"));
                 state->mode = TYPE;
                 break;
             }
+
             /* invalid code */
             if (this.op & 64) {
                 strm->msg = (char *)"invalid literal/length code";
                 state->mode = BAD;
                 break;
             }
+
             /* length code -- get extra bits, if any */
             state->extra = (unsigned)(this.op) & 15;
             if (state->extra != 0) {
@@ -483,6 +525,7 @@ void FAR *out_desc;
                 DROPBITS(state->extra);
             }
             Tracevv((stderr, "inflate:         length %u\n", state->length));
+
             /* get distance code */
             for (;;) {
                 this = state->distcode[BITS(state->distbits)];
@@ -506,6 +549,7 @@ void FAR *out_desc;
                 break;
             }
             state->offset = (unsigned)this.val;
+
             /* get distance extra bits, if any */
             state->extra = (unsigned)(this.op) & 15;
             if (state->extra != 0) {
@@ -520,6 +564,7 @@ void FAR *out_desc;
                 break;
             }
             Tracevv((stderr, "inflate:         distance %u\n", state->offset));
+
             /* copy match from window to output */
             do {
                 ROOM();
@@ -540,6 +585,7 @@ void FAR *out_desc;
                 } while (--copy);
             } while (state->length != 0);
             break;
+
         case DONE:
             /* inflate stream terminated properly -- write leftover output */
             ret = Z_STREAM_END;
@@ -548,19 +594,23 @@ void FAR *out_desc;
                     ret = Z_BUF_ERROR;
             }
             goto inf_leave;
+
         case BAD:
             ret = Z_DATA_ERROR;
             goto inf_leave;
+
         default:                /* can't happen, but makes compilers happy */
             ret = Z_STREAM_ERROR;
             goto inf_leave;
         }
+
     /* Return unused input */
   inf_leave:
     strm->next_in = next;
     strm->avail_in = have;
     return ret;
 }
+
 int ZEXPORT inflateBackEnd(strm)
 z_streamp strm;
 {
diff --git a/dep/src/zlib/inffast.c b/dep/src/zlib/inffast.c
index 25f57b424c0..bbee92ed1e6 100644
--- a/dep/src/zlib/inffast.c
+++ b/dep/src/zlib/inffast.c
@@ -2,11 +2,14 @@
  * Copyright (C) 1995-2004 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 #include "zutil.h"
 #include "inftrees.h"
 #include "inflate.h"
 #include "inffast.h"
+
 #ifndef ASMINF
+
 /* Allow machine dependent optimization for post-increment or pre-increment.
    Based on testing to date,
    Pre-increment preferred for:
@@ -25,6 +28,7 @@
 #  define OFF 1
 #  define PUP(a) *++(a)
 #endif
+
 /*
    Decode literal, length, and distance codes and write out the resulting
    literal and match bytes until either not enough input or output is
@@ -32,22 +36,29 @@
    When large enough input and output buffers are supplied to inflate(), for
    example, a 16K input buffer and a 64K output buffer, more than 95% of the
    inflate execution time is spent in this routine.
+
    Entry assumptions:
+
         state->mode == LEN
         strm->avail_in >= 6
         strm->avail_out >= 258
         start >= strm->avail_out
         state->bits < 8
+
    On return, state->mode is one of:
+
         LEN -- ran out of enough output space or enough available input
         TYPE -- reached end of block code, inflate() to interpret next block
         BAD -- error in block data
+
    Notes:
+
     - The maximum input bits used by a length/distance pair is 15 bits for the
       length code, 5 bits for the length extra, 15 bits for the distance code,
       and 13 bits for the distance extra.  This totals 48 bits, or six bytes.
       Therefore if strm->avail_in >= 6, then there is enough input to avoid
       checking for available input while decoding.
+
     - The maximum bytes that a single length/distance pair can output is 258
       bytes, which is the maximum length that can be coded.  inflate_fast()
       requires strm->avail_out >= 258 for each loop to avoid checking for
@@ -82,6 +93,7 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
     unsigned len;               /* match length, unused bytes */
     unsigned dist;              /* match distance */
     unsigned char FAR *from;    /* where to copy match from */
+
     /* copy state to local variables */
     state = (struct inflate_state FAR *)strm->state;
     in = strm->next_in - OFF;
@@ -102,6 +114,7 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
     dcode = state->distcode;
     lmask = (1U << state->lenbits) - 1;
     dmask = (1U << state->distbits) - 1;
+
     /* decode literals and length/distances until end-of-block or not enough
        input data or output space */
     do {
@@ -270,11 +283,13 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
             break;
         }
     } while (in < last && out < end);
+
     /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
     len = bits >> 3;
     in -= len;
     bits -= len << 3;
     hold &= (1U << bits) - 1;
+
     /* update state and return */
     strm->next_in = in + OFF;
     strm->next_out = out + OFF;
@@ -285,6 +300,7 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
     state->bits = bits;
     return;
 }
+
 /*
    inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
    - Using bit fields for code structure
@@ -298,4 +314,5 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
    - Larger unrolled copy loops (three is about right)
    - Moving len -= 3 statement into middle of loop
  */
+
 #endif /* !ASMINF */
diff --git a/dep/src/zlib/inffast.h b/dep/src/zlib/inffast.h
index 2b59deac282..c66fae6da2c 100644
--- a/dep/src/zlib/inffast.h
+++ b/dep/src/zlib/inffast.h
@@ -2,9 +2,11 @@
  * Copyright (C) 1995-2003 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* WARNING: this file should *not* be used by applications. It is
    part of the implementation of the compression library and is
    subject to change. Applications should only use zlib.h.
  */
+
 void inflate_fast OF((z_streamp strm, unsigned start));
 
diff --git a/dep/src/zlib/inffixed.h b/dep/src/zlib/inffixed.h
index 16b7e6f4cda..3757019557f 100644
--- a/dep/src/zlib/inffixed.h
+++ b/dep/src/zlib/inffixed.h
@@ -1,10 +1,12 @@
     /* inffixed.h -- table for decoding fixed codes
      * Generated automatically by makefixed().
      */
+
     /* WARNING: this file should *not* be used by applications. It
        is part of the implementation of the compression library and
        is subject to change. Applications should only use zlib.h.
      */
+
     static const code lenfix[512] = {
         {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
         {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
@@ -81,6 +83,7 @@
         {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
         {0,9,255}
     };
+
     static const code distfix[32] = {
         {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
         {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
diff --git a/dep/src/zlib/inflate.c b/dep/src/zlib/inflate.c
index 733563d5e5a..792fdee8e9c 100644
--- a/dep/src/zlib/inflate.c
+++ b/dep/src/zlib/inflate.c
@@ -2,6 +2,7 @@
  * Copyright (C) 1995-2005 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /*
  * Change history:
  *
@@ -78,15 +79,18 @@
  *
  * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
  */
+
 #include "zutil.h"
 #include "inftrees.h"
 #include "inflate.h"
 #include "inffast.h"
+
 #ifdef MAKEFIXED
 #  ifndef BUILDFIXED
 #    define BUILDFIXED
 #  endif
 #endif
+
 /* function prototypes */
 local void fixedtables OF((struct inflate_state FAR *state));
 local int updatewindow OF((z_streamp strm, unsigned out));
@@ -95,10 +99,12 @@ local int updatewindow OF((z_streamp strm, unsigned out));
 #endif
 local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
                               unsigned len));
+
 int ZEXPORT inflateReset(strm)
 z_streamp strm;
 {
     struct inflate_state FAR *state;
+
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
     strm->total_in = strm->total_out = state->total = 0;
@@ -118,12 +124,14 @@ z_streamp strm;
     Tracev((stderr, "inflate: reset\n"));
     return Z_OK;
 }
+
 int ZEXPORT inflatePrime(strm, bits, value)
 z_streamp strm;
 int bits;
 int value;
 {
     struct inflate_state FAR *state;
+
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
     if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
@@ -132,6 +140,7 @@ int value;
     state->bits += bits;
     return Z_OK;
 }
+
 int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
 z_streamp strm;
 int windowBits;
@@ -139,6 +148,7 @@ const char *version;
 int stream_size;
 {
     struct inflate_state FAR *state;
+
     if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
         stream_size != (int)(sizeof(z_stream)))
         return Z_VERSION_ERROR;
@@ -173,6 +183,7 @@ int stream_size;
     state->window = Z_NULL;
     return inflateReset(strm);
 }
+
 int ZEXPORT inflateInit_(strm, version, stream_size)
 z_streamp strm;
 const char *version;
@@ -180,6 +191,7 @@ int stream_size;
 {
     return inflateInit2_(strm, DEF_WBITS, version, stream_size);
 }
+
 /*
    Return state with length and distance decoding tables and index sizes set to
    fixed code decoding.  Normally this returns fixed tables from inffixed.h.
@@ -197,10 +209,12 @@ struct inflate_state FAR *state;
     static int virgin = 1;
     static code *lenfix, *distfix;
     static code fixed[544];
+
     /* build fixed huffman tables if first call (may not be thread safe) */
     if (virgin) {
         unsigned sym, bits;
         static code *next;
+
         /* literal/length table */
         sym = 0;
         while (sym < 144) state->lens[sym++] = 8;
@@ -211,12 +225,14 @@ struct inflate_state FAR *state;
         lenfix = next;
         bits = 9;
         inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
+
         /* distance table */
         sym = 0;
         while (sym < 32) state->lens[sym++] = 5;
         distfix = next;
         bits = 5;
         inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
+
         /* do this just once */
         virgin = 0;
     }
@@ -228,26 +244,33 @@ struct inflate_state FAR *state;
     state->distcode = distfix;
     state->distbits = 5;
 }
+
 #ifdef MAKEFIXED
 #include 
+
 /*
    Write out the inffixed.h that is #include'd above.  Defining MAKEFIXED also
    defines BUILDFIXED, so the tables are built on the fly.  makefixed() writes
    those tables to stdout, which would be piped to inffixed.h.  A small program
    can simply call makefixed to do this:
+
     void makefixed(void);
+
     int main(void)
     {
         makefixed();
         return 0;
     }
+
    Then that can be linked with zlib built with MAKEFIXED defined and run:
+
     a.out > inffixed.h
  */
 void makefixed()
 {
     unsigned low, size;
     struct inflate_state state;
+
     fixedtables(&state);
     puts("    /* inffixed.h -- table for decoding fixed codes");
     puts("     * Generated automatically by makefixed().");
@@ -282,6 +305,7 @@ void makefixed()
     puts("\n    };");
 }
 #endif /* MAKEFIXED */
+
 /*
    Update the window with the last wsize (normally 32K) bytes written before
    returning.  If window does not exist yet, create it.  This is only called
@@ -289,6 +313,7 @@ void makefixed()
    inflate call, but the end of the deflate stream has not been reached yet.
    It is also called to create a window for dictionary data when a dictionary
    is loaded.
+
    Providing output buffers larger than 32K to inflate() should provide a speed
    advantage, since only the last 32K of output is copied to the sliding window
    upon return from inflate(), and since all distances after the first 32K of
@@ -301,7 +326,9 @@ unsigned out;
 {
     struct inflate_state FAR *state;
     unsigned copy, dist;
+
     state = (struct inflate_state FAR *)strm->state;
+
     /* if it hasn't been done already, allocate space for the window */
     if (state->window == Z_NULL) {
         state->window = (unsigned char FAR *)
@@ -309,12 +336,14 @@ unsigned out;
                                sizeof(unsigned char));
         if (state->window == Z_NULL) return 1;
     }
+
     /* if window not in use yet, initialize */
     if (state->wsize == 0) {
         state->wsize = 1U << state->wbits;
         state->write = 0;
         state->whave = 0;
     }
+
     /* copy state->wsize or less output bytes into the circular window */
     copy = out - strm->avail_out;
     if (copy >= state->wsize) {
@@ -340,7 +369,9 @@ unsigned out;
     }
     return 0;
 }
+
 /* Macros for inflate(): */
+
 /* check function to use adler32() for zlib or crc32() for gzip */
 #ifdef GUNZIP
 #  define UPDATE(check, buf, len) \
@@ -348,6 +379,7 @@ unsigned out;
 #else
 #  define UPDATE(check, buf, len) adler32(check, buf, len)
 #endif
+
 /* check macros for header crc */
 #ifdef GUNZIP
 #  define CRC2(check, word) \
@@ -356,6 +388,7 @@ unsigned out;
         hbuf[1] = (unsigned char)((word) >> 8); \
         check = crc32(check, hbuf, 2); \
     } while (0)
+
 #  define CRC4(check, word) \
     do { \
         hbuf[0] = (unsigned char)(word); \
@@ -365,6 +398,7 @@ unsigned out;
         check = crc32(check, hbuf, 4); \
     } while (0)
 #endif
+
 /* Load registers with state in inflate() for speed */
 #define LOAD() \
     do { \
@@ -375,6 +409,7 @@ unsigned out;
         hold = state->hold; \
         bits = state->bits; \
     } while (0)
+
 /* Restore state from registers in inflate() */
 #define RESTORE() \
     do { \
@@ -385,12 +420,14 @@ unsigned out;
         state->hold = hold; \
         state->bits = bits; \
     } while (0)
+
 /* Clear the input bit accumulator */
 #define INITBITS() \
     do { \
         hold = 0; \
         bits = 0; \
     } while (0)
+
 /* Get a byte of input into the bit accumulator, or return from inflate()
    if there is no input available. */
 #define PULLBYTE() \
@@ -400,6 +437,7 @@ unsigned out;
         hold += (unsigned long)(*next++) << bits; \
         bits += 8; \
     } while (0)
+
 /* Assure that there are at least n bits in the bit accumulator.  If there is
    not enough available input to do that, then return from inflate(). */
 #define NEEDBITS(n) \
@@ -407,29 +445,35 @@ unsigned out;
         while (bits < (unsigned)(n)) \
             PULLBYTE(); \
     } while (0)
+
 /* Return the low n bits of the bit accumulator (n < 16) */
 #define BITS(n) \
     ((unsigned)hold & ((1U << (n)) - 1))
+
 /* Remove n bits from the bit accumulator */
 #define DROPBITS(n) \
     do { \
         hold >>= (n); \
         bits -= (unsigned)(n); \
     } while (0)
+
 /* Remove zero to seven bits as needed to go to a byte boundary */
 #define BYTEBITS() \
     do { \
         hold >>= bits & 7; \
         bits -= bits & 7; \
     } while (0)
+
 /* Reverse the bytes in a 32-bit value */
 #define REVERSE(q) \
     ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
      (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
+
 /*
    inflate() uses a state machine to process as much input data and generate as
    much output data as possible before returning.  The state machine is
    structured roughly as follows:
+
     for (;;) switch (state) {
     ...
     case STATEn:
@@ -440,15 +484,18 @@ unsigned out;
         break;
     ...
     }
+
    so when inflate() is called again, the same case is attempted again, and
    if the appropriate resources are provided, the machine proceeds to the
    next state.  The NEEDBITS() macro is usually the way the state evaluates
    whether it can proceed or should return.  NEEDBITS() does the return if
    the requested bits are not available.  The typical use of the BITS macros
    is:
+
         NEEDBITS(n);
         ... do something with BITS(n) ...
         DROPBITS(n);
+
    where NEEDBITS(n) either returns from inflate() if there isn't enough
    input left to load n bits into the accumulator, or it continues.  BITS(n)
    gives the low n bits in the accumulator.  When done, DROPBITS(n) drops
@@ -456,15 +503,18 @@ unsigned out;
    and sets the number of available bits to zero.  BYTEBITS() discards just
    enough bits to put the accumulator on a byte boundary.  After BYTEBITS()
    and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
+
    NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
    if there is no input available.  The decoding of variable length codes uses
    PULLBYTE() directly in order to pull just enough bytes to decode the next
    code, and no more.
+
    Some states loop until they get enough input, making sure that enough
    state information is maintained to continue the loop where it left off
    if NEEDBITS() returns in the loop.  For example, want, need, and keep
    would all have to actually be part of the saved state in case NEEDBITS()
    returns:
+
     case STATEw:
         while (want < need) {
             NEEDBITS(n);
@@ -473,11 +523,14 @@ unsigned out;
         }
         state = STATEx;
     case STATEx:
+
    As shown above, if the next state is also the next case, then the break
    is omitted.
+
    A state may also return if there is not enough output space available to
    complete that state.  Those states are copying stored data, writing a
    literal byte, and copying a matching string.
+
    When returning, a "goto inf_leave" is used to update the total counters,
    update the check value, and determine whether any progress has been made
    during that inflate() call in order to return the proper return code.
@@ -486,6 +539,7 @@ unsigned out;
    output written.  If a goto inf_leave occurs in the middle of decompression
    and there is no window currently, goto inf_leave will create one and copy
    output to the window for the next call of inflate().
+
    In this implementation, the flush parameter of inflate() only affects the
    return code (per zlib.h).  inflate() always writes as much as possible to
    strm->next_out, given the space available and the provided input--the effect
@@ -496,6 +550,7 @@ unsigned out;
    when flush is set to Z_FINISH, inflate() cannot return Z_OK.  Instead it
    will return Z_BUF_ERROR if it has not reached the end of the stream.
  */
+
 int ZEXPORT inflate(strm, flush)
 z_streamp strm;
 int flush;
@@ -518,9 +573,11 @@ int flush;
 #endif
     static const unsigned short order[19] = /* permutation of code lengths */
         {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
+
     if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
         (strm->next_in == Z_NULL && strm->avail_in != 0))
         return Z_STREAM_ERROR;
+
     state = (struct inflate_state FAR *)strm->state;
     if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
     LOAD();
@@ -864,8 +921,10 @@ int flush;
                         state->lens[state->have++] = (unsigned short)len;
                 }
             }
+
             /* handle error breaks in while */
             if (state->mode == BAD) break;
+
             /* build code tables */
             state->next = state->codes;
             state->lencode = (code const FAR *)(state->next);
@@ -1064,6 +1123,7 @@ int flush;
         default:
             return Z_STREAM_ERROR;
         }
+
     /*
        Return from inflate(), updating the total counts and the check value.
        If there was no progress during the inflate() call, return a buffer
@@ -1091,6 +1151,7 @@ int flush;
         ret = Z_BUF_ERROR;
     return ret;
 }
+
 int ZEXPORT inflateEnd(strm)
 z_streamp strm;
 {
@@ -1104,6 +1165,7 @@ z_streamp strm;
     Tracev((stderr, "inflate: end\n"));
     return Z_OK;
 }
+
 int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
 z_streamp strm;
 const Bytef *dictionary;
@@ -1111,11 +1173,13 @@ uInt dictLength;
 {
     struct inflate_state FAR *state;
     unsigned long id;
+
     /* check state */
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
     if (state->wrap != 0 && state->mode != DICT)
         return Z_STREAM_ERROR;
+
     /* check for correct dictionary id */
     if (state->mode == DICT) {
         id = adler32(0L, Z_NULL, 0);
@@ -1123,6 +1187,7 @@ uInt dictLength;
         if (id != state->check)
             return Z_DATA_ERROR;
     }
+
     /* copy dictionary to window */
     if (updatewindow(strm, strm->avail_out)) {
         state->mode = MEM;
@@ -1142,20 +1207,24 @@ uInt dictLength;
     Tracev((stderr, "inflate:   dictionary set\n"));
     return Z_OK;
 }
+
 int ZEXPORT inflateGetHeader(strm, head)
 z_streamp strm;
 gz_headerp head;
 {
     struct inflate_state FAR *state;
+
     /* check state */
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
     if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
+
     /* save header structure */
     state->head = head;
     head->done = 0;
     return Z_OK;
 }
+
 /*
    Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff.  Return when found
    or when out of input.  When called, *have is the number of pattern bytes
@@ -1174,6 +1243,7 @@ unsigned len;
 {
     unsigned got;
     unsigned next;
+
     got = *have;
     next = 0;
     while (next < len && got < 4) {
@@ -1188,6 +1258,7 @@ unsigned len;
     *have = got;
     return next;
 }
+
 int ZEXPORT inflateSync(strm)
 z_streamp strm;
 {
@@ -1195,10 +1266,12 @@ z_streamp strm;
     unsigned long in, out;      /* temporary to save total_in and total_out */
     unsigned char buf[4];       /* to restore bit buffer to byte string */
     struct inflate_state FAR *state;
+
     /* check parameters */
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
     if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
+
     /* if first time, start search in bit buffer */
     if (state->mode != SYNC) {
         state->mode = SYNC;
@@ -1213,11 +1286,13 @@ z_streamp strm;
         state->have = 0;
         syncsearch(&(state->have), buf, len);
     }
+
     /* search available input */
     len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
     strm->avail_in -= len;
     strm->next_in += len;
     strm->total_in += len;
+
     /* return no joy or set up to restart inflate() on a new block */
     if (state->have != 4) return Z_DATA_ERROR;
     in = strm->total_in;  out = strm->total_out;
@@ -1226,6 +1301,7 @@ z_streamp strm;
     state->mode = TYPE;
     return Z_OK;
 }
+
 /*
    Returns true if inflate is currently at the end of a block generated by
    Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
@@ -1238,10 +1314,12 @@ int ZEXPORT inflateSyncPoint(strm)
 z_streamp strm;
 {
     struct inflate_state FAR *state;
+
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
     return state->mode == STORED && state->bits == 0;
 }
+
 int ZEXPORT inflateCopy(dest, source)
 z_streamp dest;
 z_streamp source;
@@ -1250,11 +1328,13 @@ z_streamp source;
     struct inflate_state FAR *copy;
     unsigned char FAR *window;
     unsigned wsize;
+
     /* check input */
     if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
         source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
         return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)source->state;
+
     /* allocate space */
     copy = (struct inflate_state FAR *)
            ZALLOC(source, 1, sizeof(struct inflate_state));
@@ -1268,6 +1348,7 @@ z_streamp source;
             return Z_MEM_ERROR;
         }
     }
+
     /* copy state */
     zmemcpy(dest, source, sizeof(z_stream));
     zmemcpy(copy, state, sizeof(struct inflate_state));
diff --git a/dep/src/zlib/inflate.h b/dep/src/zlib/inflate.h
index 8cc93dbcbf2..7c05e08fcba 100644
--- a/dep/src/zlib/inflate.h
+++ b/dep/src/zlib/inflate.h
@@ -2,10 +2,12 @@
  * Copyright (C) 1995-2004 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* WARNING: this file should *not* be used by applications. It is
    part of the implementation of the compression library and is
    subject to change. Applications should only use zlib.h.
  */
+
 /* define NO_GZIP when compiling if you want to disable gzip header and
    trailer decoding by inflate().  NO_GZIP would be used to avoid linking in
    the crc code when it is not needed.  For shared libraries, gzip decoding
@@ -13,6 +15,7 @@
 #ifndef NO_GZIP
 #  define GUNZIP
 #endif
+
 /* Possible inflate modes between inflate() calls */
 typedef enum {
     HEAD,       /* i: waiting for magic header */
@@ -46,9 +49,12 @@ typedef enum {
     MEM,        /* got an inflate() memory error -- remain here until reset */
     SYNC        /* looking for synchronization bytes to restart inflate() */
 } inflate_mode;
+
 /*
     State transitions between above modes -
+
     (most modes can go to the BAD or MEM mode -- not shown for clarity)
+
     Process header:
         HEAD -> (gzip) or (zlib)
         (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
@@ -66,6 +72,7 @@ typedef enum {
     Process trailer:
         CHECK -> LENGTH -> DONE
  */
+
 /* state maintained between inflate() calls.  Approximately 7K bytes. */
 struct inflate_state {
     inflate_mode mode;          /* current inflate mode */
diff --git a/dep/src/zlib/inftrees.c b/dep/src/zlib/inftrees.c
index 821dabc5caa..8a9c13ff03d 100644
--- a/dep/src/zlib/inftrees.c
+++ b/dep/src/zlib/inftrees.c
@@ -2,9 +2,12 @@
  * Copyright (C) 1995-2005 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 #include "zutil.h"
 #include "inftrees.h"
+
 #define MAXBITS 15
+
 const char inflate_copyright[] =
    " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
 /*
@@ -13,6 +16,7 @@ const char inflate_copyright[] =
   include such an acknowledgment, I would appreciate that you keep this
   copyright string in the executable of your product.
  */
+
 /*
    Build a set of tables to decode the provided canonical Huffman code.
    The code lengths are lens[0..codes-1].  The result starts at *table,
@@ -67,6 +71,7 @@ unsigned short FAR *work;
         16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
         23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
         28, 28, 29, 29, 64, 64};
+
     /*
        Process a set of code lengths to create a canonical Huffman code.  The
        code lengths are lens[0..codes-1].  Each length corresponds to the
@@ -79,26 +84,31 @@ unsigned short FAR *work;
        from their more natural integer increment ordering, and so when the
        decoding tables are built in the large loop below, the integer codes
        are incremented backwards.
+
        This routine assumes, but does not check, that all of the entries in
        lens[] are in the range 0..MAXBITS.  The caller must assure this.
        1..MAXBITS is interpreted as that code length.  zero means that that
        symbol does not occur in this code.
+
        The codes are sorted by computing a count of codes for each length,
        creating from that a table of starting indices for each length in the
        sorted table, and then entering the symbols in order in the sorted
        table.  The sorted table is work[], with that space being provided by
        the caller.
+
        The length counts are used for other purposes as well, i.e. finding
        the minimum and maximum length codes, determining if there are any
        codes at all, checking for a valid set of lengths, and looking ahead
        at length counts to determine sub-table sizes when building the
        decoding tables.
      */
+
     /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
     for (len = 0; len <= MAXBITS; len++)
         count[len] = 0;
     for (sym = 0; sym < codes; sym++)
         count[lens[sym]]++;
+
     /* bound code lengths, force root to be within code lengths */
     root = *bits;
     for (max = MAXBITS; max >= 1; max--)
@@ -116,6 +126,7 @@ unsigned short FAR *work;
     for (min = 1; min <= MAXBITS; min++)
         if (count[min] != 0) break;
     if (root < min) root = min;
+
     /* check for an over-subscribed or incomplete set of lengths */
     left = 1;
     for (len = 1; len <= MAXBITS; len++) {
@@ -125,13 +136,16 @@ unsigned short FAR *work;
     }
     if (left > 0 && (type == CODES || max != 1))
         return -1;                      /* incomplete set */
+
     /* generate offsets into symbol table for each length for sorting */
     offs[1] = 0;
     for (len = 1; len < MAXBITS; len++)
         offs[len + 1] = offs[len] + count[len];
+
     /* sort symbols by length, by symbol order within each length */
     for (sym = 0; sym < codes; sym++)
         if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
+
     /*
        Create and fill in decoding tables.  In this loop, the table being
        filled is at next and has curr index bits.  The code being used is huff
@@ -139,26 +153,31 @@ unsigned short FAR *work;
        bits off of the bottom.  For codes where len is less than drop + curr,
        those top drop + curr - len bits are incremented through all values to
        fill the table with replicated entries.
+
        root is the number of index bits for the root table.  When len exceeds
        root, sub-tables are created pointed to by the root entry with an index
        of the low root bits of huff.  This is saved in low to check for when a
        new sub-table should be started.  drop is zero when the root table is
        being filled, and drop is root when sub-tables are being filled.
+
        When a new sub-table is needed, it is necessary to look ahead in the
        code lengths to determine what size sub-table is needed.  The length
        counts are used for this, and so count[] is decremented as codes are
        entered in the tables.
+
        used keeps track of how many table entries have been allocated from the
        provided *table space.  It is checked when a LENS table is being made
        against the space in *table, ENOUGH, minus the maximum space needed by
        the worst case distance code, MAXD.  This should never happen, but the
        sufficiency of ENOUGH has not been proven exhaustively, hence the check.
        This assumes that when type == LENS, bits == 9.
+
        sym increments through all symbols, and the loop terminates when
        all codes of length max, i.e. all codes, have been processed.  This
        routine permits incomplete codes, so another loop after this one fills
        in the rest of the decoding tables with invalid code markers.
      */
+
     /* set up for code type */
     switch (type) {
     case CODES:
@@ -177,6 +196,7 @@ unsigned short FAR *work;
         extra = dext;
         end = -1;
     }
+
     /* initialize state for loop */
     huff = 0;                   /* starting code */
     sym = 0;                    /* starting code symbol */
@@ -187,9 +207,11 @@ unsigned short FAR *work;
     low = (unsigned)(-1);       /* trigger new sub-table when len > root */
     used = 1U << root;          /* use root table entries */
     mask = used - 1;            /* mask for comparing low */
+
     /* check available table space */
     if (type == LENS && used >= ENOUGH - MAXD)
         return 1;
+
     /* process all codes and make table entries */
     for (;;) {
         /* create table entry */
@@ -206,6 +228,7 @@ unsigned short FAR *work;
             this.op = (unsigned char)(32 + 64);         /* end of block */
             this.val = 0;
         }
+
         /* replicate for those indices with low len bits equal to huff */
         incr = 1U << (len - drop);
         fill = 1U << curr;
@@ -214,6 +237,7 @@ unsigned short FAR *work;
             fill -= incr;
             next[(huff >> drop) + fill] = this;
         } while (fill != 0);
+
         /* backwards increment the len-bit code huff */
         incr = 1U << (len - 1);
         while (huff & incr)
@@ -224,19 +248,23 @@ unsigned short FAR *work;
         }
         else
             huff = 0;
+
         /* go to next symbol, update count, len */
         sym++;
         if (--(count[len]) == 0) {
             if (len == max) break;
             len = lens[work[sym]];
         }
+
         /* create new sub-table if needed */
         if (len > root && (huff & mask) != low) {
             /* if first time, transition to sub-tables */
             if (drop == 0)
                 drop = root;
+
             /* increment past last table */
             next += min;            /* here min is 1 << curr */
+
             /* determine length of next table */
             curr = len - drop;
             left = (int)(1 << curr);
@@ -246,10 +274,12 @@ unsigned short FAR *work;
                 curr++;
                 left <<= 1;
             }
+
             /* check for enough space */
             used += 1U << curr;
             if (type == LENS && used >= ENOUGH - MAXD)
                 return 1;
+
             /* point entry in root table to sub-table */
             low = huff & mask;
             (*table)[low].op = (unsigned char)curr;
@@ -257,6 +287,7 @@ unsigned short FAR *work;
             (*table)[low].val = (unsigned short)(next - *table);
         }
     }
+
     /*
        Fill in rest of table for incomplete codes.  This loop is similar to the
        loop above in incrementing huff for table indices.  It is assumed that
@@ -275,8 +306,10 @@ unsigned short FAR *work;
             next = *table;
             this.bits = (unsigned char)len;
         }
+
         /* put invalid code marker in table */
         next[huff >> drop] = this;
+
         /* backwards increment the len-bit code huff */
         incr = 1U << (len - 1);
         while (huff & incr)
@@ -288,6 +321,7 @@ unsigned short FAR *work;
         else
             huff = 0;
     }
+
     /* set return parameters */
     *table += used;
     *bits = root;
diff --git a/dep/src/zlib/inftrees.h b/dep/src/zlib/inftrees.h
index 625b590241f..977ee2f78f5 100644
--- a/dep/src/zlib/inftrees.h
+++ b/dep/src/zlib/inftrees.h
@@ -2,10 +2,12 @@
  * Copyright (C) 1995-2005 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* WARNING: this file should *not* be used by applications. It is
    part of the implementation of the compression library and is
    subject to change. Applications should only use zlib.h.
  */
+
 /* Structure for decoding tables.  Each entry provides either the
    information needed to do the operation requested by the code that
    indexed that table entry, or it provides a pointer to another
@@ -24,6 +26,7 @@ typedef struct {
     unsigned char bits;         /* bits in this part of the code */
     unsigned short val;         /* offset in table or code value */
 } code;
+
 /* op values as set by inflate_table():
     00000000 - literal
     0000tttt - table link, tttt != 0 is the number of table index bits
@@ -31,6 +34,7 @@ typedef struct {
     01100000 - end of block
     01000000 - invalid code
  */
+
 /* Maximum size of dynamic tree.  The maximum found in a long but non-
    exhaustive search was 1444 code structures (852 for length/literals
    and 592 for distances, the latter actually the result of an
@@ -38,12 +42,14 @@ typedef struct {
    below is more than safe. */
 #define ENOUGH 2048
 #define MAXD 592
+
 /* Type of code to build for inftable() */
 typedef enum {
     CODES,
     LENS,
     DISTS
 } codetype;
+
 extern int inflate_table OF((codetype type, unsigned short FAR *lens,
                              unsigned codes, code FAR * FAR *table,
                              unsigned FAR *bits, unsigned short FAR *work));
diff --git a/dep/src/zlib/trees.c b/dep/src/zlib/trees.c
index 5e1908f51ff..395e4e16814 100644
--- a/dep/src/zlib/trees.c
+++ b/dep/src/zlib/trees.c
@@ -2,6 +2,7 @@
  * Copyright (C) 1995-2005 Jean-loup Gailly
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /*
  *  ALGORITHM
  *
@@ -27,70 +28,96 @@
  *          Algorithms, p290.
  *          Addison-Wesley, 1983. ISBN 0-201-06672-6.
  */
+
 /* @(#) $Id$ */
+
 /* #define GEN_TREES_H */
+
 #include "deflate.h"
+
 #ifdef DEBUG
 #  include 
 #endif
+
 /* ===========================================================================
  * Constants
  */
+
 #define MAX_BL_BITS 7
 /* Bit length codes must not exceed MAX_BL_BITS bits */
+
 #define END_BLOCK 256
 /* end of block literal code */
+
 #define REP_3_6      16
 /* repeat previous bit length 3-6 times (2 bits of repeat count) */
+
 #define REPZ_3_10    17
 /* repeat a zero length 3-10 times  (3 bits of repeat count) */
+
 #define REPZ_11_138  18
 /* repeat a zero length 11-138 times  (7 bits of repeat count) */
+
 local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
    = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
+
 local const int extra_dbits[D_CODES] /* extra bits for each distance code */
    = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
+
 local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
    = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
+
 local const uch bl_order[BL_CODES]
    = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
 /* The lengths of the bit length codes are sent in order of decreasing
  * probability, to avoid transmitting the lengths for unused bit length codes.
  */
+
 #define Buf_size (8 * 2*sizeof(char))
 /* Number of bits used within bi_buf. (bi_buf might be implemented on
  * more than 16 bits on some systems.)
  */
+
 /* ===========================================================================
  * Local data. These are initialized only once.
  */
+
 #define DIST_CODE_LEN  512 /* see definition of array dist_code below */
+
 #if defined(GEN_TREES_H) || !defined(STDC)
 /* non ANSI compilers may not accept trees.h */
+
 local ct_data static_ltree[L_CODES+2];
 /* The static literal tree. Since the bit lengths are imposed, there is no
  * need for the L_CODES extra codes used during heap construction. However
  * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
  * below).
  */
+
 local ct_data static_dtree[D_CODES];
 /* The static distance tree. (Actually a trivial tree since all codes use
  * 5 bits.)
  */
+
 uch _dist_code[DIST_CODE_LEN];
 /* Distance codes. The first 256 values correspond to the distances
  * 3 .. 258, the last 256 values correspond to the top 8 bits of
  * the 15 bit distances.
  */
+
 uch _length_code[MAX_MATCH-MIN_MATCH+1];
 /* length code for each normalized match length (0 == MIN_MATCH) */
+
 local int base_length[LENGTH_CODES];
 /* First normalized length for each code (0 = MIN_MATCH) */
+
 local int base_dist[D_CODES];
 /* First normalized distance for each code (0 = distance of 1) */
+
 #else
 #  include "trees.h"
 #endif /* GEN_TREES_H */
+
 struct static_tree_desc_s {
     const ct_data *static_tree;  /* static tree or NULL */
     const intf *extra_bits;      /* extra bits for each code or NULL */
@@ -98,15 +125,20 @@ struct static_tree_desc_s {
     int     elems;               /* max number of elements in the tree */
     int     max_length;          /* max bit length for the codes */
 };
+
 local static_tree_desc  static_l_desc =
 {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
+
 local static_tree_desc  static_d_desc =
 {static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};
+
 local static_tree_desc  static_bl_desc =
 {(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};
+
 /* ===========================================================================
  * Local (static) routines in this file.
  */
+
 local void tr_static_init OF((void));
 local void init_block     OF((deflate_state *s));
 local void pqdownheap     OF((deflate_state *s, ct_data *tree, int k));
@@ -126,17 +158,21 @@ local void bi_windup      OF((deflate_state *s));
 local void bi_flush       OF((deflate_state *s));
 local void copy_block     OF((deflate_state *s, charf *buf, unsigned len,
                               int header));
+
 #ifdef GEN_TREES_H
 local void gen_trees_header OF((void));
 #endif
+
 #ifndef DEBUG
 #  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
    /* Send a code of the given tree. c and tree must not have side effects */
+
 #else /* DEBUG */
 #  define send_code(s, c, tree) \
      { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
        send_bits(s, tree[c].Code, tree[c].Len); }
 #endif
+
 /* ===========================================================================
  * Output a short LSB first on the stream.
  * IN assertion: there is enough room in pendingBuf.
@@ -145,12 +181,14 @@ local void gen_trees_header OF((void));
     put_byte(s, (uch)((w) & 0xff)); \
     put_byte(s, (uch)((ush)(w) >> 8)); \
 }
+
 /* ===========================================================================
  * Send a value on a given number of bits.
  * IN assertion: length <= 16 and value fits in length bits.
  */
 #ifdef DEBUG
 local void send_bits      OF((deflate_state *s, int value, int length));
+
 local void send_bits(s, value, length)
     deflate_state *s;
     int value;  /* value to send */
@@ -159,6 +197,7 @@ local void send_bits(s, value, length)
     Tracevv((stderr," l %2d v %4x ", length, value));
     Assert(length > 0 && length <= 15, "invalid length");
     s->bits_sent += (ulg)length;
+
     /* If not enough room in bi_buf, use (valid) bits from bi_buf and
      * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
      * unused bits in value.
@@ -174,6 +213,7 @@ local void send_bits(s, value, length)
     }
 }
 #else /* !DEBUG */
+
 #define send_bits(s, value, length) \
 { int len = length;\
   if (s->bi_valid > (int)Buf_size - len) {\
@@ -189,7 +229,9 @@ local void send_bits(s, value, length)
 }
 #endif /* DEBUG */
 
+
 /* the arguments must not have side effects */
+
 /* ===========================================================================
  * Initialize the various 'constant' tables.
  */
@@ -204,13 +246,16 @@ local void tr_static_init()
     int dist;     /* distance index */
     ush bl_count[MAX_BITS+1];
     /* number of codes at each bit length for an optimal tree */
+
     if (static_init_done) return;
+
     /* For some embedded targets, global variables are not initialized: */
     static_l_desc.static_tree = static_ltree;
     static_l_desc.extra_bits = extra_lbits;
     static_d_desc.static_tree = static_dtree;
     static_d_desc.extra_bits = extra_dbits;
     static_bl_desc.extra_bits = extra_blbits;
+
     /* Initialize the mapping length (0..255) -> length code (0..28) */
     length = 0;
     for (code = 0; code < LENGTH_CODES-1; code++) {
@@ -225,6 +270,7 @@ local void tr_static_init()
      * overwrite length_code[255] to use the best encoding:
      */
     _length_code[length-1] = (uch)code;
+
     /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
     dist = 0;
     for (code = 0 ; code < 16; code++) {
@@ -242,6 +288,7 @@ local void tr_static_init()
         }
     }
     Assert (dist == 256, "tr_static_init: 256+dist != 512");
+
     /* Construct the codes of the static literal tree */
     for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
     n = 0;
@@ -254,17 +301,20 @@ local void tr_static_init()
      * all ones)
      */
     gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
+
     /* The static distance tree is trivial: */
     for (n = 0; n < D_CODES; n++) {
         static_dtree[n].Len = 5;
         static_dtree[n].Code = bi_reverse((unsigned)n, 5);
     }
     static_init_done = 1;
+
 #  ifdef GEN_TREES_H
     gen_trees_header();
 #  endif
 #endif /* defined(GEN_TREES_H) || !defined(STDC) */
 }
+
 /* ===========================================================================
  * Genererate the file trees.h describing the static trees.
  */
@@ -272,49 +322,60 @@ local void tr_static_init()
 #  ifndef DEBUG
 #    include 
 #  endif
+
 #  define SEPARATOR(i, last, width) \
       ((i) == (last)? "\n};\n\n" :    \
        ((i) % (width) == (width)-1 ? ",\n" : ", "))
+
 void gen_trees_header()
 {
     FILE *header = fopen("trees.h", "w");
     int i;
+
     Assert (header != NULL, "Can't open trees.h");
     fprintf(header,
             "/* header created automatically with -DGEN_TREES_H */\n\n");
+
     fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
     for (i = 0; i < L_CODES+2; i++) {
         fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
                 static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
     }
+
     fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
     for (i = 0; i < D_CODES; i++) {
         fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
                 static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
     }
+
     fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
     for (i = 0; i < DIST_CODE_LEN; i++) {
         fprintf(header, "%2u%s", _dist_code[i],
                 SEPARATOR(i, DIST_CODE_LEN-1, 20));
     }
+
     fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
     for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
         fprintf(header, "%2u%s", _length_code[i],
                 SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
     }
+
     fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
     for (i = 0; i < LENGTH_CODES; i++) {
         fprintf(header, "%1u%s", base_length[i],
                 SEPARATOR(i, LENGTH_CODES-1, 20));
     }
+
     fprintf(header, "local const int base_dist[D_CODES] = {\n");
     for (i = 0; i < D_CODES; i++) {
         fprintf(header, "%5u%s", base_dist[i],
                 SEPARATOR(i, D_CODES-1, 10));
     }
+
     fclose(header);
 }
 #endif /* GEN_TREES_H */
+
 /* ===========================================================================
  * Initialize the tree data structures for a new zlib stream.
  */
@@ -322,12 +383,16 @@ void _tr_init(s)
     deflate_state *s;
 {
     tr_static_init();
+
     s->l_desc.dyn_tree = s->dyn_ltree;
     s->l_desc.stat_desc = &static_l_desc;
+
     s->d_desc.dyn_tree = s->dyn_dtree;
     s->d_desc.stat_desc = &static_d_desc;
+
     s->bl_desc.dyn_tree = s->bl_tree;
     s->bl_desc.stat_desc = &static_bl_desc;
+
     s->bi_buf = 0;
     s->bi_valid = 0;
     s->last_eob_len = 8; /* enough lookahead for inflate */
@@ -335,9 +400,11 @@ void _tr_init(s)
     s->compressed_len = 0L;
     s->bits_sent = 0L;
 #endif
+
     /* Initialize the first block of the first file: */
     init_block(s);
 }
+
 /* ===========================================================================
  * Initialize a new block.
  */
@@ -345,17 +412,21 @@ local void init_block(s)
     deflate_state *s;
 {
     int n; /* iterates over tree elements */
+
     /* Initialize the trees. */
     for (n = 0; n < L_CODES;  n++) s->dyn_ltree[n].Freq = 0;
     for (n = 0; n < D_CODES;  n++) s->dyn_dtree[n].Freq = 0;
     for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
+
     s->dyn_ltree[END_BLOCK].Freq = 1;
     s->opt_len = s->static_len = 0L;
     s->last_lit = s->matches = 0;
 }
+
 #define SMALLEST 1
 /* Index within the heap array of least frequent node in the Huffman tree */
 
+
 /* ===========================================================================
  * Remove the smallest element from the heap and recreate the heap with
  * one less element. Updates heap and heap_len.
@@ -366,6 +437,7 @@ local void init_block(s)
     s->heap[SMALLEST] = s->heap[s->heap_len--]; \
     pqdownheap(s, tree, SMALLEST); \
 }
+
 /* ===========================================================================
  * Compares to subtrees, using the tree depth as tie breaker when
  * the subtrees have equal frequency. This minimizes the worst case length.
@@ -373,6 +445,7 @@ local void init_block(s)
 #define smaller(tree, n, m, depth) \
    (tree[n].Freq < tree[m].Freq || \
    (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
+
 /* ===========================================================================
  * Restore the heap property by moving down the tree starting at node k,
  * exchanging a node with the smallest of its two sons if necessary, stopping
@@ -394,13 +467,16 @@ local void pqdownheap(s, tree, k)
         }
         /* Exit if v is smaller than both sons */
         if (smaller(tree, v, s->heap[j], s->depth)) break;
+
         /* Exchange v with the smallest son */
         s->heap[k] = s->heap[j];  k = j;
+
         /* And continue down the tree, setting j to the left son of k */
         j <<= 1;
     }
     s->heap[k] = v;
 }
+
 /* ===========================================================================
  * Compute the optimal bit lengths for a tree and update the total bit length
  * for the current block.
@@ -427,18 +503,23 @@ local void gen_bitlen(s, desc)
     int xbits;          /* extra bits */
     ush f;              /* frequency */
     int overflow = 0;   /* number of elements with bit length too large */
+
     for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
+
     /* In a first pass, compute the optimal bit lengths (which may
      * overflow in the case of the bit length tree).
      */
     tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
+
     for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
         n = s->heap[h];
         bits = tree[tree[n].Dad].Len + 1;
         if (bits > max_length) bits = max_length, overflow++;
         tree[n].Len = (ush)bits;
         /* We overwrite tree[n].Dad which is no longer needed */
+
         if (n > max_code) continue; /* not a leaf node */
+
         s->bl_count[bits]++;
         xbits = 0;
         if (n >= base) xbits = extra[n-base];
@@ -447,8 +528,10 @@ local void gen_bitlen(s, desc)
         if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
     }
     if (overflow == 0) return;
+
     Trace((stderr,"\nbit length overflow\n"));
     /* This happens for example on obj2 and pic of the Calgary corpus */
+
     /* Find the first bit length which could increase: */
     do {
         bits = max_length-1;
@@ -461,6 +544,7 @@ local void gen_bitlen(s, desc)
          */
         overflow -= 2;
     } while (overflow > 0);
+
     /* Now recompute all bit lengths, scanning in increasing frequency.
      * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
      * lengths instead of fixing only the wrong ones. This idea is taken
@@ -481,6 +565,7 @@ local void gen_bitlen(s, desc)
         }
     }
 }
+
 /* ===========================================================================
  * Generate the codes for a given tree and bit counts (which need not be
  * optimal).
@@ -498,6 +583,7 @@ local void gen_codes (tree, max_code, bl_count)
     ush code = 0;              /* running code value */
     int bits;                  /* bit index */
     int n;                     /* code index */
+
     /* The distribution counts are first used to generate the code values
      * without bit reversal.
      */
@@ -510,15 +596,18 @@ local void gen_codes (tree, max_code, bl_count)
     Assert (code + bl_count[MAX_BITS]-1 == (1<heap_len = 0, s->heap_max = HEAP_SIZE;
+
     for (n = 0; n < elems; n++) {
         if (tree[n].Freq != 0) {
             s->heap[++(s->heap_len)] = max_code = n;
@@ -550,6 +641,7 @@ local void build_tree(s, desc)
             tree[n].Len = 0;
         }
     }
+
     /* The pkzip format requires that at least one distance code exists,
      * and that at least one bit should be sent even if there is only one
      * possible code. So to avoid special checks later on we force at least
@@ -563,10 +655,12 @@ local void build_tree(s, desc)
         /* node is 0 or 1 so it does not have extra bits */
     }
     desc->max_code = max_code;
+
     /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
      * establish sub-heaps of increasing lengths:
      */
     for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
+
     /* Construct the Huffman tree by repeatedly combining the least two
      * frequent nodes.
      */
@@ -574,8 +668,10 @@ local void build_tree(s, desc)
     do {
         pqremove(s, tree, n);  /* n = node of least frequency */
         m = s->heap[SMALLEST]; /* m = node of next least frequency */
+
         s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
         s->heap[--(s->heap_max)] = m;
+
         /* Create a new node father of n and m */
         tree[node].Freq = tree[n].Freq + tree[m].Freq;
         s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
@@ -590,15 +686,20 @@ local void build_tree(s, desc)
         /* and insert the new node in the heap */
         s->heap[SMALLEST] = node++;
         pqdownheap(s, tree, SMALLEST);
+
     } while (s->heap_len >= 2);
+
     s->heap[--(s->heap_max)] = s->heap[SMALLEST];
+
     /* At this point, the fields freq and dad are set. We can now
      * generate the bit lengths.
      */
     gen_bitlen(s, (tree_desc *)desc);
+
     /* The field len is now set, we can generate the bit codes */
     gen_codes ((ct_data *)tree, max_code, s->bl_count);
 }
+
 /* ===========================================================================
  * Scan a literal or distance tree to determine the frequencies of the codes
  * in the bit length tree.
@@ -615,8 +716,10 @@ local void scan_tree (s, tree, max_code)
     int count = 0;             /* repeat count of the current code */
     int max_count = 7;         /* max repeat count */
     int min_count = 4;         /* min repeat count */
+
     if (nextlen == 0) max_count = 138, min_count = 3;
     tree[max_code+1].Len = (ush)0xffff; /* guard */
+
     for (n = 0; n <= max_code; n++) {
         curlen = nextlen; nextlen = tree[n+1].Len;
         if (++count < max_count && curlen == nextlen) {
@@ -641,6 +744,7 @@ local void scan_tree (s, tree, max_code)
         }
     }
 }
+
 /* ===========================================================================
  * Send a literal or distance tree in compressed form, using the codes in
  * bl_tree.
@@ -657,22 +761,27 @@ local void send_tree (s, tree, max_code)
     int count = 0;             /* repeat count of the current code */
     int max_count = 7;         /* max repeat count */
     int min_count = 4;         /* min repeat count */
+
     /* tree[max_code+1].Len = -1; */  /* guard already set */
     if (nextlen == 0) max_count = 138, min_count = 3;
+
     for (n = 0; n <= max_code; n++) {
         curlen = nextlen; nextlen = tree[n+1].Len;
         if (++count < max_count && curlen == nextlen) {
             continue;
         } else if (count < min_count) {
             do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
+
         } else if (curlen != 0) {
             if (curlen != prevlen) {
                 send_code(s, curlen, s->bl_tree); count--;
             }
             Assert(count >= 3 && count <= 6, " 3_6?");
             send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
+
         } else if (count <= 10) {
             send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
+
         } else {
             send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
         }
@@ -686,6 +795,7 @@ local void send_tree (s, tree, max_code)
         }
     }
 }
+
 /* ===========================================================================
  * Construct the Huffman tree for the bit lengths and return the index in
  * bl_order of the last bit length code to send.
@@ -694,14 +804,17 @@ local int build_bl_tree(s)
     deflate_state *s;
 {
     int max_blindex;  /* index of last bit length code of non zero freq */
+
     /* Determine the bit length frequencies for literal and distance trees */
     scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
     scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
+
     /* Build the bit length tree: */
     build_tree(s, (tree_desc *)(&(s->bl_desc)));
     /* opt_len now includes the length of the tree representations, except
      * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
      */
+
     /* Determine the number of bit length codes to send. The pkzip format
      * requires that at least 4 bit length codes be sent. (appnote.txt says
      * 3 but the actual value used is 4.)
@@ -713,8 +826,10 @@ local int build_bl_tree(s)
     s->opt_len += 3*(max_blindex+1) + 5+5+4;
     Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
             s->opt_len, s->static_len));
+
     return max_blindex;
 }
+
 /* ===========================================================================
  * Send the header for a block using dynamic Huffman trees: the counts, the
  * lengths of the bit length codes, the literal tree and the distance tree.
@@ -725,6 +840,7 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
     int lcodes, dcodes, blcodes; /* number of codes for each tree */
 {
     int rank;                    /* index in bl_order */
+
     Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
     Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
             "too many codes");
@@ -737,11 +853,14 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
         send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
     }
     Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
+
     send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
     Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
+
     send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
     Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
 }
+
 /* ===========================================================================
  * Send a stored block
  */
@@ -758,6 +877,7 @@ void _tr_stored_block(s, buf, stored_len, eof)
 #endif
     copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
 }
+
 /* ===========================================================================
  * Send one empty static block to give enough lookahead for inflate.
  * This takes 10 bits, of which 7 may remain in the bit buffer.
@@ -793,6 +913,7 @@ void _tr_align(s)
     }
     s->last_eob_len = 7;
 }
+
 /* ===========================================================================
  * Determine the best encoding for the current block: dynamic trees, static
  * trees or store, and output the encoded block to the zip file.
@@ -805,36 +926,46 @@ void _tr_flush_block(s, buf, stored_len, eof)
 {
     ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
     int max_blindex = 0;  /* index of last bit length code of non zero freq */
+
     /* Build the Huffman trees unless a stored block is forced */
     if (s->level > 0) {
+
         /* Check if the file is binary or text */
         if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
             set_data_type(s);
+
         /* Construct the literal and distance trees */
         build_tree(s, (tree_desc *)(&(s->l_desc)));
         Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
                 s->static_len));
+
         build_tree(s, (tree_desc *)(&(s->d_desc)));
         Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
                 s->static_len));
         /* At this point, opt_len and static_len are the total bit lengths of
          * the compressed block data, excluding the tree representations.
          */
+
         /* Build the bit length tree for the above two trees, and get the index
          * in bl_order of the last bit length code to send.
          */
         max_blindex = build_bl_tree(s);
+
         /* Determine the best encoding. Compute the block lengths in bytes. */
         opt_lenb = (s->opt_len+3+7)>>3;
         static_lenb = (s->static_len+3+7)>>3;
+
         Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
                 opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
                 s->last_lit));
+
         if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
+
     } else {
         Assert(buf != (char*)0, "lost buf");
         opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
     }
+
 #ifdef FORCE_STORED
     if (buf != (char*)0) { /* force stored block */
 #else
@@ -848,6 +979,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
          * transform a block into a stored block.
          */
         _tr_stored_block(s, buf, stored_len, eof);
+
 #ifdef FORCE_STATIC
     } else if (static_lenb >= 0) { /* force static trees */
 #else
@@ -872,6 +1004,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
      * and uLong implemented on 32 bits.
      */
     init_block(s);
+
     if (eof) {
         bi_windup(s);
 #ifdef DEBUG
@@ -881,6 +1014,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
     Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
            s->compressed_len-7*eof));
 }
+
 /* ===========================================================================
  * Save the match info and tally the frequency counts. Return true if
  * the current block must be flushed.
@@ -902,9 +1036,11 @@ int _tr_tally (s, dist, lc)
         Assert((ush)dist < (ush)MAX_DIST(s) &&
                (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
                (ush)d_code(dist) < (ush)D_CODES,  "_tr_tally: bad match");
+
         s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
         s->dyn_dtree[d_code(dist)].Freq++;
     }
+
 #ifdef TRUNCATE_BLOCK
     /* Try to guess if it is profitable to stop the current block here */
     if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
@@ -929,6 +1065,7 @@ int _tr_tally (s, dist, lc)
      * 64K-1 bytes.
      */
 }
+
 /* ===========================================================================
  * Send the block data compressed using the given Huffman trees
  */
@@ -942,6 +1079,7 @@ local void compress_block(s, ltree, dtree)
     unsigned lx = 0;    /* running index in l_buf */
     unsigned code;      /* the code to send */
     int extra;          /* number of extra bits to send */
+
     if (s->last_lit != 0) do {
         dist = s->d_buf[lx];
         lc = s->l_buf[lx++];
@@ -960,6 +1098,7 @@ local void compress_block(s, ltree, dtree)
             dist--; /* dist is now the match distance - 1 */
             code = d_code(dist);
             Assert (code < D_CODES, "bad d_code");
+
             send_code(s, code, dtree);       /* send the distance code */
             extra = extra_dbits[code];
             if (extra != 0) {
@@ -967,13 +1106,17 @@ local void compress_block(s, ltree, dtree)
                 send_bits(s, dist, extra);   /* send the extra distance bits */
             }
         } /* literal or match pair ? */
+
         /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
         Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
                "pendingBuf overflow");
+
     } while (lx < s->last_lit);
+
     send_code(s, END_BLOCK, ltree);
     s->last_eob_len = ltree[END_BLOCK].Len;
 }
+
 /* ===========================================================================
  * Set the data type to BINARY or TEXT, using a crude approximation:
  * set it to Z_TEXT if all symbols are either printable characters (33 to 255)
@@ -984,6 +1127,7 @@ local void set_data_type(s)
     deflate_state *s;
 {
     int n;
+
     for (n = 0; n < 9; n++)
         if (s->dyn_ltree[n].Freq != 0)
             break;
@@ -993,6 +1137,7 @@ local void set_data_type(s)
                 break;
     s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
 }
+
 /* ===========================================================================
  * Reverse the first len bits of a code, using straightforward code (a faster
  * method would use a table)
@@ -1009,6 +1154,7 @@ local unsigned bi_reverse(code, len)
     } while (--len > 0);
     return res >> 1;
 }
+
 /* ===========================================================================
  * Flush the bit buffer, keeping at most 7 bits in it.
  */
@@ -1025,6 +1171,7 @@ local void bi_flush(s)
         s->bi_valid -= 8;
     }
 }
+
 /* ===========================================================================
  * Flush the bit buffer and align the output on a byte boundary
  */
@@ -1042,6 +1189,7 @@ local void bi_windup(s)
     s->bits_sent = (s->bits_sent+7) & ~7;
 #endif
 }
+
 /* ===========================================================================
  * Copy a stored block, storing first the length and its
  * one's complement if requested.
@@ -1054,6 +1202,7 @@ local void copy_block(s, buf, len, header)
 {
     bi_windup(s);        /* align on byte boundary */
     s->last_eob_len = 8; /* enough lookahead for inflate */
+
     if (header) {
         put_short(s, (ush)len);
         put_short(s, (ush)~len);
diff --git a/dep/src/zlib/trees.h b/dep/src/zlib/trees.h
index bcfecb67797..ba8cd78357b 100644
--- a/dep/src/zlib/trees.h
+++ b/dep/src/zlib/trees.h
@@ -1,4 +1,5 @@
 /* header created automatically with -DGEN_TREES_H */
+
 local const ct_data static_ltree[L_CODES+2] = {
 {{ 12},{  8}}, {{140},{  8}}, {{ 76},{  8}}, {{204},{  8}}, {{ 44},{  8}},
 {{172},{  8}}, {{108},{  8}}, {{236},{  8}}, {{ 28},{  8}}, {{156},{  8}},
@@ -59,6 +60,7 @@ local const ct_data static_ltree[L_CODES+2] = {
 {{  3},{  8}}, {{131},{  8}}, {{ 67},{  8}}, {{195},{  8}}, {{ 35},{  8}},
 {{163},{  8}}, {{ 99},{  8}}, {{227},{  8}}
 };
+
 local const ct_data static_dtree[D_CODES] = {
 {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
 {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
@@ -67,6 +69,7 @@ local const ct_data static_dtree[D_CODES] = {
 {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
 {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
 };
+
 const uch _dist_code[DIST_CODE_LEN] = {
  0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,
  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,
@@ -95,6 +98,7 @@ const uch _dist_code[DIST_CODE_LEN] = {
 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
 };
+
 const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
  0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,
 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
@@ -110,13 +114,16 @@ const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
 };
+
 local const int base_length[LENGTH_CODES] = {
 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
 64, 80, 96, 112, 128, 160, 192, 224, 0
 };
+
 local const int base_dist[D_CODES] = {
     0,     1,     2,     3,     4,     6,     8,    12,    16,    24,
    32,    48,    64,    96,   128,   192,   256,   384,   512,   768,
  1024,  1536,  2048,  3072,  4096,  6144,  8192, 12288, 16384, 24576
 };
 
+
diff --git a/dep/src/zlib/uncompr.c b/dep/src/zlib/uncompr.c
index 5858b9f2279..b59e3d0defb 100644
--- a/dep/src/zlib/uncompr.c
+++ b/dep/src/zlib/uncompr.c
@@ -2,9 +2,12 @@
  * Copyright (C) 1995-2003 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* @(#) $Id$ */
+
 #define ZLIB_INTERNAL
 #include "zlib.h"
+
 /* ===========================================================================
      Decompresses the source buffer into the destination buffer.  sourceLen is
    the byte length of the source buffer. Upon entry, destLen is the total
@@ -15,6 +18,7 @@
    Upon exit, destLen is the actual size of the compressed buffer.
      This function can be used to decompress a whole file at once if the
    input file is mmap'ed.
+
      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_BUF_ERROR if there was not enough room in the output
    buffer, or Z_DATA_ERROR if the input data was corrupted.
@@ -27,17 +31,22 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
 {
     z_stream stream;
     int err;
+
     stream.next_in = (Bytef*)source;
     stream.avail_in = (uInt)sourceLen;
     /* Check for source > 64K on 16-bit machine: */
     if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
+
     stream.next_out = dest;
     stream.avail_out = (uInt)*destLen;
     if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+
     stream.zalloc = (alloc_func)0;
     stream.zfree = (free_func)0;
+
     err = inflateInit(&stream);
     if (err != Z_OK) return err;
+
     err = inflate(&stream, Z_FINISH);
     if (err != Z_STREAM_END) {
         inflateEnd(&stream);
@@ -46,6 +55,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
         return err;
     }
     *destLen = stream.total_out;
+
     err = inflateEnd(&stream);
     return err;
 }
diff --git a/dep/src/zlib/zconf.h b/dep/src/zlib/zconf.h
index 6c3086b96d7..719855a60d4 100644
--- a/dep/src/zlib/zconf.h
+++ b/dep/src/zlib/zconf.h
@@ -2,9 +2,12 @@
  * Copyright (C) 1995-2005 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* @(#) $Id$ */
+
 #ifndef ZCONF_H
 #define ZCONF_H
+
 /*
  * If you *really* need a unique prefix for all types and library functions,
  * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
@@ -39,6 +42,7 @@
 #  define crc32                 z_crc32
 #  define get_crc_table         z_get_crc_table
 #  define zError                z_zError
+
 #  define alloc_func            z_alloc_func
 #  define free_func             z_free_func
 #  define in_func               z_in_func
@@ -54,6 +58,7 @@
 #  define voidpf                z_voidpf
 #  define voidp                 z_voidp
 #endif
+
 #if defined(__MSDOS__) && !defined(MSDOS)
 #  define MSDOS
 #endif
@@ -75,6 +80,7 @@
 #    endif
 #  endif
 #endif
+
 /*
  * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
  * than 64k bytes at a time (needed on systems with 16-bit int).
@@ -85,6 +91,7 @@
 #ifdef MSDOS
 #  define UNALIGNED_OK
 #endif
+
 #ifdef __STDC_VERSION__
 #  ifndef STDC
 #    define STDC
@@ -107,18 +114,22 @@
 #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
 #  define STDC
 #endif
+
 #if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
 #  define STDC
 #endif
+
 #ifndef STDC
 #  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
 #    define const       /* note: need a more gentle solution here */
 #  endif
 #endif
+
 /* Some Mac compilers merge all .h files incorrectly: */
 #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
 #  define NO_DUMMY_DECL
 #endif
+
 /* Maximum value for memLevel in deflateInit2 */
 #ifndef MAX_MEM_LEVEL
 #  ifdef MAXSEG_64K
@@ -127,6 +138,7 @@
 #    define MAX_MEM_LEVEL 9
 #  endif
 #endif
+
 /* Maximum value for windowBits in deflateInit2 and inflateInit2.
  * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
  * created by gzip. (Files created by minigzip can still be extracted by
@@ -135,6 +147,7 @@
 #ifndef MAX_WBITS
 #  define MAX_WBITS   15 /* 32K LZ77 window */
 #endif
+
 /* The memory requirements for deflate are (in bytes):
             (1 << (windowBits+2)) +  (1 << (memLevel+9))
  that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
@@ -142,11 +155,14 @@
  the default memory requirements from 256K to 128K, compile with
      make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
  Of course this will generally degrade compression (there's no free lunch).
+
    The memory requirements for inflate are (in bytes) 1 << windowBits
  that is, 32K for windowBits=15 (default value) plus a few kilobytes
  for small objects.
 */
+
                         /* Type declarations */
+
 #ifndef OF /* function prototypes */
 #  ifdef STDC
 #    define OF(args)  args
@@ -154,6 +170,7 @@
 #    define OF(args)  ()
 #  endif
 #endif
+
 /* The following definitions for FAR are needed only for MSDOS mixed
  * model programming (small or medium model with some far allocations).
  * This was tested only with MSC; for other MSDOS compilers you may have
@@ -180,6 +197,7 @@
 #    endif
 #  endif
 #endif
+
 #if defined(WINDOWS) || defined(WIN32)
    /* If building or using zlib as a DLL, define ZLIB_DLL.
     * This is not mandatory, but it offers a little performance increase.
@@ -212,6 +230,7 @@
 #    endif
 #  endif
 #endif
+
 #if defined (__BEOS__)
 #  ifdef ZLIB_DLL
 #    ifdef ZLIB_INTERNAL
@@ -223,6 +242,7 @@
 #    endif
 #  endif
 #endif
+
 #ifndef ZEXTERN
 #  define ZEXTERN extern
 #endif
@@ -232,14 +252,17 @@
 #ifndef ZEXPORTVA
 #  define ZEXPORTVA
 #endif
+
 #ifndef FAR
 #  define FAR
 #endif
+
 #if !defined(__MACTYPES__)
 typedef unsigned char  Byte;  /* 8 bits */
 #endif
 typedef unsigned int   uInt;  /* 16 bits or more */
 typedef unsigned long  uLong; /* 32 bits or more */
+
 #ifdef SMALL_MEDIUM
    /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
 #  define Bytef Byte FAR
@@ -250,6 +273,7 @@ typedef char  FAR charf;
 typedef int   FAR intf;
 typedef uInt  FAR uIntf;
 typedef uLong FAR uLongf;
+
 #ifdef STDC
    typedef void const *voidpc;
    typedef void FAR   *voidpf;
@@ -259,6 +283,7 @@ typedef uLong FAR uLongf;
    typedef Byte FAR   *voidpf;
    typedef Byte       *voidp;
 #endif
+
 #if 0           /* HAVE_UNISTD_H -- this line is updated by ./configure */
 #  include  /* for off_t */
 #  include     /* for SEEK_* and off_t */
@@ -275,15 +300,18 @@ typedef uLong FAR uLongf;
 #ifndef z_off_t
 #  define z_off_t long
 #endif
+
 #if defined(__OS400__)
 #  define NO_vsnprintf
 #endif
+
 #if defined(__MVS__)
 #  define NO_vsnprintf
 #  ifdef FAR
 #    undef FAR
 #  endif
 #endif
+
 /* MVS linker does not support external names larger than 8 bytes */
 #if defined(__MVS__)
 #   pragma map(deflateInit_,"DEIN")
@@ -300,5 +328,6 @@ typedef uLong FAR uLongf;
 #   pragma map(inflate_fast,"INFA")
 #   pragma map(inflate_copyright,"INCOPY")
 #endif
+
 #endif /* ZCONF_H */
 
diff --git a/dep/src/zlib/zlib.h b/dep/src/zlib/zlib.h
index 718a0899472..2ad74617098 100644
--- a/dep/src/zlib/zlib.h
+++ b/dep/src/zlib/zlib.h
@@ -1,12 +1,16 @@
 /* zlib.h -- interface of the 'zlib' general purpose compression library
   version 1.2.3, July 18th, 2005
+
   Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
+
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.
+
   Permission is granted to anyone to use this software for any purpose,
   including commercial applications, and to alter it and redistribute it
   freely, subject to the following restrictions:
+
   1. The origin of this software must not be misrepresented; you must not
      claim that you wrote the original software. If you use this software
      in a product, an acknowledgment in the product documentation would be
@@ -14,68 +18,90 @@
   2. Altered source versions must be plainly marked as such, and must not be
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
+
   Jean-loup Gailly        Mark Adler
   jloup@gzip.org          madler@alumni.caltech.edu
 
+
   The data format used by the zlib library is described by RFCs (Request for
   Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
 */
+
 #ifndef ZLIB_H
 #define ZLIB_H
+
 #include "zconf.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 #define ZLIB_VERSION "1.2.3"
 #define ZLIB_VERNUM 0x1230
+
 /*
      The 'zlib' compression library provides in-memory compression and
   decompression functions, including integrity checks of the uncompressed
   data.  This version of the library supports only one compression method
   (deflation) but other algorithms will be added later and will have the same
   stream interface.
+
      Compression can be done in a single step if the buffers are large
   enough (for example if an input file is mmap'ed), or can be done by
   repeated calls of the compression function.  In the latter case, the
   application must provide more input and/or consume the output
   (providing more output space) before each call.
+
      The compressed data format used by default by the in-memory functions is
   the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
   around a deflate stream, which is itself documented in RFC 1951.
+
      The library also supports reading and writing files in gzip (.gz) format
   with an interface similar to that of stdio using the functions that start
   with "gz".  The gzip format is different from the zlib format.  gzip is a
   gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
+
      This library can optionally read and write gzip streams in memory as well.
+
      The zlib format was designed to be compact and fast for use in memory
   and on communications channels.  The gzip format was designed for single-
   file compression on file systems, has a larger header than zlib to maintain
   directory information, and uses a different, slower check method than zlib.
+
      The library does not install any signal handler. The decoder checks
   the consistency of the compressed data, so the library should never
   crash even in case of corrupted input.
 */
+
 typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
 typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
+
 struct internal_state;
+
 typedef struct z_stream_s {
     Bytef    *next_in;  /* next input byte */
     uInt     avail_in;  /* number of bytes available at next_in */
     uLong    total_in;  /* total nb of input bytes read so far */
+
     Bytef    *next_out; /* next output byte should be put there */
     uInt     avail_out; /* remaining free space at next_out */
     uLong    total_out; /* total nb of bytes output so far */
+
     char     *msg;      /* last error message, NULL if no error */
     struct internal_state FAR *state; /* not visible by applications */
+
     alloc_func zalloc;  /* used to allocate the internal state */
     free_func  zfree;   /* used to free the internal state */
     voidpf     opaque;  /* private data object passed to zalloc and zfree */
+
     int     data_type;  /* best guess about the data type: binary or text */
     uLong   adler;      /* adler32 value of the uncompressed data */
     uLong   reserved;   /* reserved for future use */
 } z_stream;
+
 typedef z_stream FAR *z_streamp;
+
 /*
      gzip header information passed to and from zlib routines.  See RFC 1952
   for more details on the meanings of these fields.
@@ -96,20 +122,25 @@ typedef struct gz_header_s {
     int     done;       /* true when done reading gzip header (not used
                            when writing a gzip file) */
 } gz_header;
+
 typedef gz_header FAR *gz_headerp;
+
 /*
    The application must update next_in and avail_in when avail_in has
    dropped to zero. It must update next_out and avail_out when avail_out
    has dropped to zero. The application must initialize zalloc, zfree and
    opaque before calling the init function. All other fields are set by the
    compression library and must not be updated by the application.
+
    The opaque value provided by the application will be passed as the first
    parameter for calls of zalloc and zfree. This can be useful for custom
    memory management. The compression library attaches no meaning to the
    opaque value.
+
    zalloc must return Z_NULL if there is not enough memory for the object.
    If zlib is used in a multi-threaded application, zalloc and zfree must be
    thread safe.
+
    On 16-bit systems, the functions zalloc and zfree must be able to allocate
    exactly 65536 bytes, but will not be required to allocate more than this
    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
@@ -118,13 +149,16 @@ typedef gz_header FAR *gz_headerp;
    provided by this library ensures this (see zutil.c). To reduce memory
    requirements and avoid any allocation of 64K objects, at the expense of
    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
+
    The fields total_in and total_out can be used for statistics or
    progress reports. After compression, total_in holds the total size of
    the uncompressed data and may be saved for use in the decompressor
    (particularly if the decompressor wants to decompress everything in
    a single step).
 */
+
                         /* constants */
+
 #define Z_NO_FLUSH      0
 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
 #define Z_SYNC_FLUSH    2
@@ -132,6 +166,7 @@ typedef gz_header FAR *gz_headerp;
 #define Z_FINISH        4
 #define Z_BLOCK         5
 /* Allowed flush values; see deflate() and inflate() below for details */
+
 #define Z_OK            0
 #define Z_STREAM_END    1
 #define Z_NEED_DICT     2
@@ -144,45 +179,57 @@ typedef gz_header FAR *gz_headerp;
 /* Return codes for the compression/decompression functions. Negative
  * values are errors, positive values are used for special but normal events.
  */
+
 #define Z_NO_COMPRESSION         0
 #define Z_BEST_SPEED             1
 #define Z_BEST_COMPRESSION       9
 #define Z_DEFAULT_COMPRESSION  (-1)
 /* compression levels */
+
 #define Z_FILTERED            1
 #define Z_HUFFMAN_ONLY        2
 #define Z_RLE                 3
 #define Z_FIXED               4
 #define Z_DEFAULT_STRATEGY    0
 /* compression strategy; see deflateInit2() below for details */
+
 #define Z_BINARY   0
 #define Z_TEXT     1
 #define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
 #define Z_UNKNOWN  2
 /* Possible values of the data_type field (though see inflate()) */
+
 #define Z_DEFLATED   8
 /* The deflate compression method (the only one supported in this version) */
+
 #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
+
 #define zlib_version zlibVersion()
 /* for compatibility with versions < 1.0.2 */
+
                         /* basic functions */
+
 ZEXTERN const char * ZEXPORT zlibVersion OF((void));
 /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
    If the first character differs, the library code actually used is
    not compatible with the zlib.h header file used by the application.
    This check is automatically made by deflateInit and inflateInit.
  */
+
 /*
 ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+
      Initializes the internal stream state for compression. The fields
    zalloc, zfree and opaque must be initialized before by the caller.
    If zalloc and zfree are set to Z_NULL, deflateInit updates them to
    use default allocation functions.
+
      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
    1 gives best speed, 9 gives best compression, 0 gives no compression at
    all (the input data is simply copied a block at a time).
    Z_DEFAULT_COMPRESSION requests a default compromise between speed and
    compression (currently equivalent to level 6).
+
      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_STREAM_ERROR if level is not a valid compression level,
    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
@@ -191,23 +238,28 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
    perform any compression: this will be done by deflate().
 */
 
+
 ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
 /*
     deflate compresses as much data as possible, and stops when the input
   buffer becomes empty or the output buffer becomes full. It may introduce some
   output latency (reading input without producing any output) except when
   forced to flush.
+
     The detailed semantics are as follows. deflate performs one or both of the
   following actions:
+
   - Compress more input starting at next_in and update next_in and avail_in
     accordingly. If not all input can be processed (because there is not
     enough room in the output buffer), next_in and avail_in are updated and
     processing will resume at this point for the next call of deflate().
+
   - Provide more output starting at next_out and update next_out and avail_out
     accordingly. This action is forced if the parameter flush is non zero.
     Forcing flush frequently degrades the compression ratio, so this parameter
     should be set only when necessary (in interactive applications).
     Some output may be provided even if flush is not set.
+
   Before the call of deflate(), the application should ensure that at least
   one of the actions is possible, by providing more input and/or consuming
   more output, and updating avail_in or avail_out accordingly; avail_out
@@ -216,26 +268,31 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
   and with zero avail_out, it must be called again after making room in the
   output buffer because there might be more output pending.
+
     Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
   decide how much data to accumualte before producing output, in order to
   maximize compression.
+
     If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
   flushed to the output buffer and the output is aligned on a byte boundary, so
   that the decompressor can get all input data available so far. (In particular
   avail_in is zero after the call if enough output space has been provided
   before the call.)  Flushing may degrade compression for some compression
   algorithms and so it should be used only when necessary.
+
     If flush is set to Z_FULL_FLUSH, all output is flushed as with
   Z_SYNC_FLUSH, and the compression state is reset so that decompression can
   restart from this point if previous compressed data has been damaged or if
   random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
   compression.
+
     If deflate returns with avail_out == 0, this function must be called again
   with the same value of the flush parameter and more output space (updated
   avail_out), until the flush is complete (deflate returns with non-zero
   avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
   avail_out is greater than six to avoid repeated flush markers due to
   avail_out == 0 on return.
+
     If the parameter flush is set to Z_FINISH, pending input is processed,
   pending output is flushed and deflate returns with Z_STREAM_END if there
   was enough output space; if deflate returns with Z_OK, this function must be
@@ -243,16 +300,20 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
   more input data, until it returns with Z_STREAM_END or an error. After
   deflate has returned Z_STREAM_END, the only possible operations on the
   stream are deflateReset or deflateEnd.
+
     Z_FINISH can be used immediately after deflateInit if all the compression
   is to be done in a single step. In this case, avail_out must be at least
   the value returned by deflateBound (see below). If deflate does not return
   Z_STREAM_END, then it must be called again as described above.
+
     deflate() sets strm->adler to the adler32 checksum of all input read
   so far (that is, total_in bytes).
+
     deflate() may update strm->data_type if it can make a good guess about
   the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
   binary. This field is only for information purposes and does not affect
   the compression algorithm in any manner.
+
     deflate() returns Z_OK if some progress has been made (more input
   processed or more output produced), Z_STREAM_END if all input has been
   consumed and all output has been produced (only when flush is set to
@@ -263,11 +324,13 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
   space to continue compressing.
 */
 
+
 ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
 /*
      All dynamically allocated data structures for this stream are freed.
    This function discards any unprocessed input and does not flush any
    pending output.
+
      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
    prematurely (some input or output was discarded). In the error case,
@@ -275,8 +338,10 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
    deallocated).
 */
 
+
 /*
 ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
+
      Initializes the internal stream state for decompression. The fields
    next_in, avail_in, zalloc, zfree and opaque must be initialized before by
    the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
@@ -285,6 +350,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
    accordingly; otherwise the allocation will be deferred to the first call of
    inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
    use default allocation functions.
+
      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
    memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
    version assumed by the caller.  msg is set to null if there is no error
@@ -293,22 +359,27 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
    avail_in may be modified, but next_out and avail_out are unchanged.)
 */
 
+
 ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
 /*
     inflate decompresses as much data as possible, and stops when the input
   buffer becomes empty or the output buffer becomes full. It may introduce
   some output latency (reading input without producing any output) except when
   forced to flush.
+
   The detailed semantics are as follows. inflate performs one or both of the
   following actions:
+
   - Decompress more input starting at next_in and update next_in and avail_in
     accordingly. If not all input can be processed (because there is not
     enough room in the output buffer), next_in is updated and processing
     will resume at this point for the next call of inflate().
+
   - Provide more output starting at next_out and update next_out and avail_out
     accordingly.  inflate() provides as much output as possible, until there
     is no more input data or no more space in the output buffer (see below
     about the flush parameter).
+
   Before the call of inflate(), the application should ensure that at least
   one of the actions is possible, by providing more input and/or consuming
   more output, and updating the next_* and avail_* values accordingly.
@@ -317,6 +388,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
   must be called again after making room in the output buffer because there
   might be more output pending.
+
     The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
   Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
   output as possible to the output buffer. Z_BLOCK requests that inflate() stop
@@ -325,6 +397,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   the header and before the first block. When doing a raw inflate, inflate()
   will go ahead and process the first block, and will return when it gets to
   the end of that block, or when it runs out of data.
+
     The Z_BLOCK option assists in appending to or combining deflate streams.
   Also to assist in this, on return inflate() will set strm->data_type to the
   number of unused bits in the last byte taken from strm->next_in, plus 64
@@ -336,6 +409,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   number of unused bits may in general be greater than seven, except when
   bit 7 of data_type is set, in which case the number of unused bits will be
   less than eight.
+
     inflate() should normally be called until it returns Z_STREAM_END or an
   error. However if all decompression is to be performed in a single step
   (a single call of inflate), the parameter flush should be set to
@@ -346,11 +420,13 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
   is never required, but can be used to inform inflate that a faster approach
   may be used for the single inflate() call.
+
      In this implementation, inflate() always flushes as much output as
   possible to the output buffer, and always uses the faster approach on the
   first call. So the only effect of the flush parameter in this implementation
   is on the return value of inflate(), as noted below, or when it returns early
   because Z_BLOCK is used.
+
      If a preset dictionary is needed after this call (see inflateSetDictionary
   below), inflate sets strm->adler to the adler32 checksum of the dictionary
   chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
@@ -359,12 +435,14 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   below. At the end of the stream, inflate() checks that its computed adler32
   checksum is equal to that saved by the compressor and returns Z_STREAM_END
   only if the checksum is correct.
+
     inflate() will decompress and check either zlib-wrapped or gzip-wrapped
   deflate data.  The header type is detected automatically.  Any information
   contained in the gzip header is not retained, so applications that need that
   information should instead use raw inflate, see inflateInit2() below, or
   inflateBack() and perform their own processing of the gzip header and
   trailer.
+
     inflate() returns Z_OK if some progress has been made (more input processed
   or more output produced), Z_STREAM_END if the end of the compressed data has
   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
@@ -380,19 +458,24 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   of the data is desired.
 */
 
+
 ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
 /*
      All dynamically allocated data structures for this stream are freed.
    This function discards any unprocessed input and does not flush any
    pending output.
+
      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
    was inconsistent. In the error case, msg may be set but then points to a
    static string (which must not be deallocated).
 */
+
                         /* Advanced functions */
+
 /*
     The following functions are needed only in some special applications.
 */
+
 /*
 ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
                                      int  level,
@@ -400,30 +483,37 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
                                      int  windowBits,
                                      int  memLevel,
                                      int  strategy));
+
      This is another version of deflateInit with more compression options. The
    fields next_in, zalloc, zfree and opaque must be initialized before by
    the caller.
+
      The method parameter is the compression method. It must be Z_DEFLATED in
    this version of the library.
+
      The windowBits parameter is the base two logarithm of the window size
    (the size of the history buffer). It should be in the range 8..15 for this
    version of the library. Larger values of this parameter result in better
    compression at the expense of memory usage. The default value is 15 if
    deflateInit is used instead.
+
      windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
    determines the window size. deflate() will then generate raw deflate data
    with no zlib header or trailer, and will not compute an adler32 check value.
+
      windowBits can also be greater than 15 for optional gzip encoding. Add
    16 to windowBits to write a simple gzip header and trailer around the
    compressed data instead of a zlib wrapper. The gzip header will have no
    file name, no extra data, no comment, no modification time (set to zero),
    no header crc, and the operating system will be set to 255 (unknown).  If a
    gzip stream is being written, strm->adler is a crc32 instead of an adler32.
+
      The memLevel parameter specifies how much memory should be allocated
    for the internal compression state. memLevel=1 uses minimum memory but
    is slow and reduces compression ratio; memLevel=9 uses maximum memory
    for optimal speed. The default value is 8. See zconf.h for total memory
    usage as a function of windowBits and memLevel.
+
      The strategy parameter is used to tune the compression algorithm. Use the
    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
    filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
@@ -438,11 +528,13 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
    compressed output even if it is not set appropriately.  Z_FIXED prevents the
    use of dynamic Huffman codes, allowing for a simpler decoder for special
    applications.
+
       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
    method). msg is set to null if there is no error message.  deflateInit2 does
    not perform any compression: this will be done by deflate().
 */
+
 ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
                                              const Bytef *dictionary,
                                              uInt  dictLength));
@@ -452,12 +544,14 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
    immediately after deflateInit, deflateInit2 or deflateReset, before any
    call of deflate. The compressor and decompressor must use exactly the same
    dictionary (see inflateSetDictionary).
+
      The dictionary should consist of strings (byte sequences) that are likely
    to be encountered later in the data to be compressed, with the most commonly
    used strings preferably put towards the end of the dictionary. Using a
    dictionary is most useful when the data to be compressed is short and can be
    predicted with good accuracy; the data can then be compressed better than
    with the default empty dictionary.
+
      Depending on the size of the compression data structures selected by
    deflateInit or deflateInit2, a part of the dictionary may in effect be
    discarded, for example if the dictionary is larger than the window size in
@@ -465,42 +559,50 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
    put at the end of the dictionary, not at the front. In addition, the
    current implementation of deflate will use at most the window size minus
    262 bytes of the provided dictionary.
+
      Upon return of this function, strm->adler is set to the adler32 value
    of the dictionary; the decompressor may later use this value to determine
    which dictionary has been used by the compressor. (The adler32 value
    applies to the whole dictionary even if only a subset of the dictionary is
    actually used by the compressor.) If a raw deflate was requested, then the
    adler32 value is not computed and strm->adler is not set.
+
      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
    parameter is invalid (such as NULL dictionary) or the stream state is
    inconsistent (for example if deflate has already been called for this stream
    or if the compression method is bsort). deflateSetDictionary does not
    perform any compression: this will be done by deflate().
 */
+
 ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
                                     z_streamp source));
 /*
      Sets the destination stream as a complete copy of the source stream.
+
      This function can be useful when several compression strategies will be
    tried, for example when there are several ways of pre-processing the input
    data with a filter. The streams that will be discarded should then be freed
    by calling deflateEnd.  Note that deflateCopy duplicates the internal
    compression state which can be quite large, so this strategy is slow and
    can consume lots of memory.
+
      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
    (such as zalloc being NULL). msg is left unchanged in both source and
    destination.
 */
+
 ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
 /*
      This function is equivalent to deflateEnd followed by deflateInit,
    but does not free and reallocate all the internal compression state.
    The stream will keep the same compression level and any other attributes
    that may have been set by deflateInit2.
+
       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent (such as zalloc or state being NULL).
 */
+
 ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
                                       int level,
                                       int strategy));
@@ -512,13 +614,16 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
    strategy. If the compression level is changed, the input available so far
    is compressed with the old level (and may be flushed); the new level will
    take effect only at the next call of deflate().
+
      Before the call of deflateParams, the stream state must be set as for
    a call of deflate(), since the currently available input may have to
    be compressed and flushed. In particular, strm->avail_out must be non-zero.
+
      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
    if strm->avail_out was zero.
 */
+
 ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
                                     int good_length,
                                     int max_lazy,
@@ -531,9 +636,11 @@ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
    fanatic optimizer trying to squeeze out the last compressed bit for their
    specific input data.  Read the deflate.c source code for the meaning of the
    max_lazy, good_length, nice_length, and max_chain parameters.
+
      deflateTune() can be called after deflateInit() or deflateInit2(), and
    returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
  */
+
 ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
                                        uLong sourceLen));
 /*
@@ -542,6 +649,7 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
    or deflateInit2().  This would be used to allocate an output buffer
    for deflation in a single pass, and so would be called before deflate().
 */
+
 ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
                                      int bits,
                                      int value));
@@ -553,9 +661,11 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
   first deflate() call after a deflateInit2() or deflateReset().  bits must be
   less than or equal to 16, and that many of the least significant bits of
   value will be inserted in the output.
+
       deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent.
 */
+
 ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
                                          gz_headerp head));
 /*
@@ -571,18 +681,23 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
    the current versions of the command-line version of gzip (up through version
    1.3.x) do not support header crc's, and will report that it is a "multi-part
    gzip file" and give up.
+
       If deflateSetHeader is not used, the default gzip header has text false,
    the time set to zero, and os set to 255, with no extra, name, or comment
    fields.  The gzip header is returned to the default state by deflateReset().
+
       deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent.
 */
+
 /*
 ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
                                      int  windowBits));
+
      This is another version of inflateInit with an extra parameter. The
    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
    before by the caller.
+
      The windowBits parameter is the base two logarithm of the maximum window
    size (the size of the history buffer).  It should be in the range 8..15 for
    this version of the library. The default value is 15 if inflateInit is used
@@ -591,6 +706,7 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
    deflateInit2() was not used. If a compressed stream with a larger window
    size is given as input, inflate() will return with the error code
    Z_DATA_ERROR instead of trying to allocate a larger window.
+
      windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
    determines the window size. inflate() will then process raw deflate data,
    not looking for a zlib or gzip header, not generating a check value, and not
@@ -602,11 +718,13 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
    the uncompressed data as is done in the zlib, gzip, and zip formats.  For
    most applications, the zlib format should be used as is. Note that comments
    above on the use in deflateInit2() applies to the magnitude of windowBits.
+
      windowBits can also be greater than 15 for optional gzip decoding. Add
    32 to windowBits to enable zlib and gzip decoding with automatic header
    detection, or add 16 to decode only the gzip format (the zlib format will
    return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is
    a crc32 instead of an adler32.
+
      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
    is set to null if there is no error message.  inflateInit2 does not perform
@@ -614,6 +732,7 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
    be done by inflate(). (So next_in and avail_in may be modified, but next_out
    and avail_out are unchanged.)
 */
+
 ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
                                              const Bytef *dictionary,
                                              uInt  dictLength));
@@ -627,6 +746,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
    immediately after inflateInit2() or inflateReset() and before any call of
    inflate() to set the dictionary.  The application must insure that the
    dictionary that was used for compression is provided.
+
      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
    parameter is invalid (such as NULL dictionary) or the stream state is
    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
@@ -634,11 +754,13 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
    perform any decompression: this will be done by subsequent calls of
    inflate().
 */
+
 ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
 /*
     Skips invalid compressed data until a full flush point (see above the
   description of deflate with Z_FULL_FLUSH) can be found, or until all
   available input is skipped. No output is provided.
+
     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
   if no more input was provided, Z_DATA_ERROR if no flush point has been found,
   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
@@ -647,27 +769,33 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
   application may repeatedly call inflateSync, providing more input each time,
   until success or end of the input data.
 */
+
 ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
                                     z_streamp source));
 /*
      Sets the destination stream as a complete copy of the source stream.
+
      This function can be useful when randomly accessing a large stream.  The
    first pass through the stream can periodically record the inflate state,
    allowing restarting inflate at those points when randomly accessing the
    stream.
+
      inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
    (such as zalloc being NULL). msg is left unchanged in both source and
    destination.
 */
+
 ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
 /*
      This function is equivalent to inflateEnd followed by inflateInit,
    but does not free and reallocate all the internal decompression state.
    The stream will keep attributes that may have been set by inflateInit2.
+
       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent (such as zalloc or state being NULL).
 */
+
 ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
                                      int bits,
                                      int value));
@@ -679,9 +807,11 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
   should be used before the first inflate() call after inflateInit2() or
   inflateReset().  bits must be less than or equal to 16, and that many of the
   least significant bits of value will be inserted in the input.
+
       inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent.
 */
+
 ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
                                          gz_headerp head));
 /*
@@ -694,6 +824,7 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
    no gzip header information forthcoming.  Note that Z_BLOCK can be used to
    force inflate() to return immediately after header processing is complete
    and before any actual data is decompressed.
+
       The text, time, xflags, and os fields are filled in with the gzip header
    contents.  hcrc is set to true if there is a header CRC.  (The header CRC
    was valid if done is set to one.)  If extra is not Z_NULL, then extra_max
@@ -710,17 +841,21 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
    structure to duplicate the header.  However if those fields are set to
    allocated memory, then the application will need to save those pointers
    elsewhere so that they can be eventually freed.
+
       If inflateGetHeader is not used, then the header information is simply
    discarded.  The header is always checked for validity, including the header
    CRC if present.  inflateReset() will reset the process to discard the header
    information.  The application would need to call inflateGetHeader() again to
    retrieve the header from the next gzip stream.
+
       inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent.
 */
+
 /*
 ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
                                         unsigned char FAR *window));
+
      Initialize the internal stream state for decompression using inflateBack()
    calls.  The fields zalloc, zfree and opaque in strm must be initialized
    before the call.  If zalloc and zfree are Z_NULL, then the default library-
@@ -730,14 +865,18 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
    assured that deflate was used with small window sizes, windowBits must be 15
    and a 32K byte window must be supplied to be able to decompress general
    deflate streams.
+
      See inflateBack() for the usage of these routines.
+
      inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
    the paramaters are invalid, Z_MEM_ERROR if the internal state could not
    be allocated, or Z_VERSION_ERROR if the version of the library does not
    match the version of the header file.
 */
+
 typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
 typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
+
 ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
                                     in_func in, void FAR *in_desc,
                                     out_func out, void FAR *out_desc));
@@ -748,11 +887,13 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
    sliding window by simply making the window itself the output buffer.  This
    function trusts the application to not change the output buffer passed by
    the output function, at least until inflateBack() returns.
+
      inflateBackInit() must be called first to allocate the internal state
    and to initialize the state with the user-provided window buffer.
    inflateBack() may then be used multiple times to inflate a complete, raw
    deflate stream with each call.  inflateBackEnd() is then called to free
    the allocated state.
+
      A raw deflate stream is one with no zlib or gzip header or trailer.
    This routine would normally be used in a utility that reads zip or gzip
    files and writes out uncompressed files.  The utility would decode the
@@ -760,6 +901,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
    only the raw deflate stream to decompress.  This is different from the
    normal behavior of inflate(), which expects either a zlib or gzip header and
    trailer around the deflate stream.
+
      inflateBack() uses two subroutines supplied by the caller that are then
    called by inflateBack() for input and output.  inflateBack() calls those
    routines until it reads a complete deflate stream and writes out all of the
@@ -776,6 +918,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
    inflateBackInit(), which is also the buffer that out() uses to write from.
    The length written by out() will be at most the window size.  Any non-zero
    amount of input may be provided by in().
+
      For convenience, inflateBack() can be provided input on the first call by
    setting strm->next_in and strm->avail_in.  If that input is exhausted, then
    in() will be called.  Therefore strm->next_in must be initialized before
@@ -783,10 +926,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
    immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in
    must also be initialized, and then if strm->avail_in is not zero, input will
    initially be taken from strm->next_in[0 .. strm->avail_in - 1].
+
      The in_desc and out_desc parameters of inflateBack() is passed as the
    first parameter of in() and out() respectively when they are called.  These
    descriptors can be optionally used to pass any information that the caller-
    supplied in() and out() functions need to do their job.
+
      On return, inflateBack() will set strm->next_in and strm->avail_in to
    pass back any unused input that was provided by the last in() call.  The
    return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
@@ -800,47 +945,59 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
    strm->next_in is assured to be defined if out() returns non-zero.)  Note
    that inflateBack() cannot return Z_OK.
 */
+
 ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
 /*
      All memory allocated by inflateBackInit() is freed.
+
      inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
    state was inconsistent.
 */
+
 ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
 /* Return flags indicating compile-time options.
+
     Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
      1.0: size of uInt
      3.2: size of uLong
      5.4: size of voidpf (pointer)
      7.6: size of z_off_t
+
     Compiler, assembler, and debug options:
      8: DEBUG
      9: ASMV or ASMINF -- use ASM code
      10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
      11: 0 (reserved)
+
     One-time table building (smaller code, but not thread-safe if true):
      12: BUILDFIXED -- build static block decoding tables when needed
      13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
      14,15: 0 (reserved)
+
     Library content (indicates missing functionality):
      16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
                           deflate code when not needed)
      17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
                     and decode gzip streams (to avoid linking crc code)
      18-19: 0 (reserved)
+
     Operation variations (changes in library functionality):
      20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
      21: FASTEST -- deflate algorithm with only one, lowest compression level
      22,23: 0 (reserved)
+
     The sprintf variant used by gzprintf (zero is best):
      24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
      25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
      26: 0 = returns value, 1 = void -- 1 means inferred string length returned
+
     Remainder:
      27-31: 0 (reserved)
  */
 
+
                         /* utility functions */
+
 /*
      The following utility functions are implemented on top of the
    basic stream-oriented functions. To simplify the interface, some
@@ -848,6 +1005,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
    standard memory allocation functions). The source code of these
    utility functions can easily be modified if you need special options.
 */
+
 ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
                                  const Bytef *source, uLong sourceLen));
 /*
@@ -862,6 +1020,7 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
    enough memory, Z_BUF_ERROR if there was not enough room in the output
    buffer.
 */
+
 ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
                                   const Bytef *source, uLong sourceLen,
                                   int level));
@@ -872,16 +1031,19 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
    destination buffer, which must be at least the value returned by
    compressBound(sourceLen). Upon exit, destLen is the actual size of the
    compressed buffer.
+
      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
    Z_STREAM_ERROR if the level parameter is invalid.
 */
+
 ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
 /*
      compressBound() returns an upper bound on the compressed size after
    compress() or compress2() on sourceLen bytes.  It would be used before
    a compress() or compress2() call to allocate the destination buffer.
 */
+
 ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
                                    const Bytef *source, uLong sourceLen));
 /*
@@ -894,12 +1056,15 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
    Upon exit, destLen is the actual size of the compressed buffer.
      This function can be used to decompress a whole file at once if the
    input file is mmap'ed.
+
      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_BUF_ERROR if there was not enough room in the output
    buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
 */
 
+
 typedef voidp gzFile;
+
 ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode));
 /*
      Opens a gzip (.gz) file for reading or writing. The mode parameter
@@ -908,12 +1073,15 @@ ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode));
    Huffman only compression as in "wb1h", or 'R' for run-length encoding
    as in "wb1R". (See the description of deflateInit2 for more information
    about the strategy parameter.)
+
      gzopen can be used to read a file which is not in gzip format; in this
    case gzread will directly read from the file without decompression.
+
      gzopen returns NULL if the file could not be opened or if there was
    insufficient memory to allocate the (de)compression state; errno
    can be checked to distinguish the two cases (if errno is zero, the
    zlib error is Z_MEM_ERROR).  */
+
 ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode));
 /*
      gzdopen() associates a gzFile with the file descriptor fd.  File
@@ -926,6 +1094,7 @@ ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode));
      gzdopen returns NULL if there was insufficient memory to allocate
    the (de)compression state.
 */
+
 ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
 /*
      Dynamically update the compression level or strategy. See the description
@@ -933,6 +1102,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
      gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
    opened for writing.
 */
+
 ZEXTERN int ZEXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
 /*
      Reads the given number of uncompressed bytes from the compressed file.
@@ -940,6 +1110,7 @@ ZEXTERN int ZEXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
    of bytes into the buffer.
      gzread returns the number of uncompressed bytes actually read (0 for
    end of file, -1 for error). */
+
 ZEXTERN int ZEXPORT    gzwrite OF((gzFile file,
                                    voidpc buf, unsigned len));
 /*
@@ -947,6 +1118,7 @@ ZEXTERN int ZEXPORT    gzwrite OF((gzFile file,
    gzwrite returns the number of uncompressed bytes actually written
    (0 in case of error).
 */
+
 ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...));
 /*
      Converts, formats, and writes the args to the compressed file under
@@ -959,12 +1131,14 @@ ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...));
    zlib was compiled with the insecure functions sprintf() or vsprintf()
    because the secure snprintf() or vsnprintf() functions were not available.
 */
+
 ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
 /*
       Writes the given null-terminated string to the compressed file, excluding
    the terminating null character.
       gzputs returns the number of characters written, or -1 in case of error.
 */
+
 ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
 /*
       Reads bytes from the compressed file until len-1 characters are read, or
@@ -973,16 +1147,19 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
    character.
       gzgets returns buf, or Z_NULL in case of error.
 */
+
 ZEXTERN int ZEXPORT    gzputc OF((gzFile file, int c));
 /*
       Writes c, converted to an unsigned char, into the compressed file.
    gzputc returns the value that was written, or -1 in case of error.
 */
+
 ZEXTERN int ZEXPORT    gzgetc OF((gzFile file));
 /*
       Reads one byte from the compressed file. gzgetc returns this byte
    or -1 in case of end of file or error.
 */
+
 ZEXTERN int ZEXPORT    gzungetc OF((int c, gzFile file));
 /*
       Push one character back onto the stream to be read again later.
@@ -992,6 +1169,7 @@ ZEXTERN int ZEXPORT    gzungetc OF((int c, gzFile file));
    character will be discarded if the stream is repositioned with gzseek()
    or gzrewind().
 */
+
 ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush));
 /*
      Flushes all pending output into the compressed file. The parameter
@@ -1001,6 +1179,7 @@ ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush));
      gzflush should be called only when strictly necessary because it can
    degrade compression.
 */
+
 ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
                                       z_off_t offset, int whence));
 /*
@@ -1012,39 +1191,48 @@ ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
    extremely slow. If the file is opened for writing, only forward seeks are
    supported; gzseek then compresses a sequence of zeroes up to the new
    starting position.
+
       gzseek returns the resulting offset location as measured in bytes from
    the beginning of the uncompressed stream, or -1 in case of error, in
    particular if the file is opened for writing and the new starting position
    would be before the current position.
 */
+
 ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
 /*
      Rewinds the given file. This function is supported only for reading.
+
    gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
 */
+
 ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
 /*
      Returns the starting position for the next gzread or gzwrite on the
    given compressed file. This position represents a number of bytes in the
    uncompressed data stream.
+
    gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
 */
+
 ZEXTERN int ZEXPORT gzeof OF((gzFile file));
 /*
      Returns 1 when EOF has previously been detected reading the given
    input stream, otherwise zero.
 */
+
 ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
 /*
      Returns 1 if file is being read directly without decompression, otherwise
    zero.
 */
+
 ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
 /*
      Flushes all pending output if necessary, closes the compressed file
    and deallocates all the (de)compression state. The return value is the zlib
    error number (see function gzerror below).
 */
+
 ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
 /*
      Returns the error message for the last error which occurred on the
@@ -1053,18 +1241,22 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
    errnum is set to Z_ERRNO and the application may consult errno
    to get the exact error code.
 */
+
 ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
 /*
      Clears the error and end-of-file flags for file. This is analogous to the
    clearerr() function in stdio. This is useful for continuing to read a gzip
    file that is being written concurrently.
 */
+
                         /* checksum functions */
+
 /*
      These functions are not related to compression but are exported
    anyway because they might be useful in applications using the
    compression library.
 */
+
 ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
 /*
      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
@@ -1072,12 +1264,15 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
    the required initial value for the checksum.
    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
    much faster. Usage example:
+
      uLong adler = adler32(0L, Z_NULL, 0);
+
      while (read_buffer(buffer, length) != EOF) {
        adler = adler32(adler, buffer, length);
      }
      if (adler != original_adler) error();
 */
+
 ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
                                           z_off_t len2));
 /*
@@ -1086,6 +1281,7 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
    each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
    seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
 */
+
 ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
 /*
      Update a running CRC-32 with the bytes buf[0..len-1] and return the
@@ -1093,13 +1289,17 @@ ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
    value for the for the crc. Pre- and post-conditioning (one's complement) is
    performed within this function so it shouldn't be done by the application.
    Usage example:
+
      uLong crc = crc32(0L, Z_NULL, 0);
+
      while (read_buffer(buffer, length) != EOF) {
        crc = crc32(crc, buffer, length);
      }
      if (crc != original_crc) error();
 */
+
 ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
+
 /*
      Combine two CRC-32 check values into one.  For two sequences of bytes,
    seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
@@ -1108,7 +1308,9 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
    len2.
 */
 
+
                         /* various hacks, don't look :) */
+
 /* deflateInit and inflateInit are macros to allow checking the zlib version
  * and the compiler's view of z_stream:
  */
@@ -1139,14 +1341,18 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
         inflateBackInit_((strm), (windowBits), (window), \
         ZLIB_VERSION, sizeof(z_stream))
 
+
 #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
     struct internal_state {int dummy;}; /* hack for buggy compilers */
 #endif
+
 ZEXTERN const char   * ZEXPORT zError           OF((int));
 ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp z));
 ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
+
 #ifdef __cplusplus
 }
 #endif
+
 #endif /* ZLIB_H */
 
diff --git a/dep/src/zlib/zutil.c b/dep/src/zlib/zutil.c
index 09b456e54e4..d55f5948a37 100644
--- a/dep/src/zlib/zutil.c
+++ b/dep/src/zlib/zutil.c
@@ -2,11 +2,15 @@
  * Copyright (C) 1995-2005 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* @(#) $Id$ */
+
 #include "zutil.h"
+
 #ifndef NO_DUMMY_DECL
 struct internal_state      {int dummy;}; /* for buggy compilers */
 #endif
+
 const char * const z_errmsg[10] = {
 "need dictionary",     /* Z_NEED_DICT       2  */
 "stream end",          /* Z_STREAM_END      1  */
@@ -19,13 +23,16 @@ const char * const z_errmsg[10] = {
 "incompatible version",/* Z_VERSION_ERROR (-6) */
 ""};
 
+
 const char * ZEXPORT zlibVersion()
 {
     return ZLIB_VERSION;
 }
+
 uLong ZEXPORT zlibCompileFlags()
 {
     uLong flags;
+
     flags = 0;
     switch (sizeof(uInt)) {
     case 2:     break;
@@ -104,11 +111,14 @@ uLong ZEXPORT zlibCompileFlags()
 #endif
     return flags;
 }
+
 #ifdef DEBUG
+
 #  ifndef verbose
 #    define verbose 0
 #  endif
 int z_verbose = verbose;
+
 void z_error (m)
     char *m;
 {
@@ -116,6 +126,7 @@ void z_error (m)
     exit(1);
 }
 #endif
+
 /* exported to allow conversion of error code to string for compress() and
  * uncompress()
  */
@@ -124,6 +135,7 @@ const char * ZEXPORT zError(err)
 {
     return ERR_MSG(err);
 }
+
 #if defined(_WIN32_WCE)
     /* The Microsoft C Run-Time Library for Windows CE doesn't have
      * errno.  We define it as a global variable to simplify porting.
@@ -131,7 +143,9 @@ const char * ZEXPORT zError(err)
      */
     int errno = 0;
 #endif
+
 #ifndef HAVE_MEMCPY
+
 void zmemcpy(dest, source, len)
     Bytef* dest;
     const Bytef* source;
@@ -142,17 +156,20 @@ void zmemcpy(dest, source, len)
         *dest++ = *source++; /* ??? to be unrolled */
     } while (--len != 0);
 }
+
 int zmemcmp(s1, s2, len)
     const Bytef* s1;
     const Bytef* s2;
     uInt  len;
 {
     uInt j;
+
     for (j = 0; j < len; j++) {
         if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
     }
     return 0;
 }
+
 void zmemzero(dest, len)
     Bytef* dest;
     uInt  len;
@@ -164,22 +181,30 @@ void zmemzero(dest, len)
 }
 #endif
 
+
 #ifdef SYS16BIT
+
 #ifdef __TURBOC__
 /* Turbo C in 16-bit mode */
+
 #  define MY_ZCALLOC
+
 /* Turbo C malloc() does not allow dynamic allocation of 64K bytes
  * and farmalloc(64K) returns a pointer with an offset of 8, so we
  * must fix the pointer. Warning: the pointer must be put back to its
  * original form in order to free it, use zcfree().
  */
+
 #define MAX_PTR 10
 /* 10*64K = 640K */
+
 local int next_ptr = 0;
+
 typedef struct ptr_table_s {
     voidpf org_ptr;
     voidpf new_ptr;
 } ptr_table;
+
 local ptr_table table[MAX_PTR];
 /* This table is used to remember the original form of pointers
  * to large buffers (64K). Such pointers are normalized with a zero offset.
@@ -187,10 +212,12 @@ local ptr_table table[MAX_PTR];
  * protected from concurrent access. This hack doesn't work anyway on
  * a protected system like OS/2. Use Microsoft C instead.
  */
+
 voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
 {
     voidpf buf = opaque; /* just to make some compilers happy */
     ulg bsize = (ulg)items*size;
+
     /* If we allocate less than 65520 bytes, we assume that farmalloc
      * will return a usable pointer which doesn't have to be normalized.
      */
@@ -202,12 +229,14 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
     }
     if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
     table[next_ptr].org_ptr = buf;
+
     /* Normalize the pointer to seg:0 */
     *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
     *(ush*)&buf = 0;
     table[next_ptr++].new_ptr = buf;
     return buf;
 }
+
 void  zcfree (voidpf opaque, voidpf ptr)
 {
     int n;
@@ -218,6 +247,7 @@ void  zcfree (voidpf opaque, voidpf ptr)
     /* Find the original pointer */
     for (n = 0; n < next_ptr; n++) {
         if (ptr != table[n].new_ptr) continue;
+
         farfree(table[n].org_ptr);
         while (++n < next_ptr) {
             table[n-1] = table[n];
@@ -228,34 +258,45 @@ void  zcfree (voidpf opaque, voidpf ptr)
     ptr = opaque; /* just to make some compilers happy */
     Assert(0, "zcfree: ptr not found");
 }
+
 #endif /* __TURBOC__ */
 
+
 #ifdef M_I86
 /* Microsoft C in 16-bit mode */
+
 #  define MY_ZCALLOC
+
 #if (!defined(_MSC_VER) || (_MSC_VER <= 600))
 #  define _halloc  halloc
 #  define _hfree   hfree
 #endif
+
 voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
 {
     if (opaque) opaque = 0; /* to make compiler happy */
     return _halloc((long)items, size);
 }
+
 void  zcfree (voidpf opaque, voidpf ptr)
 {
     if (opaque) opaque = 0; /* to make compiler happy */
     _hfree(ptr);
 }
+
 #endif /* M_I86 */
+
 #endif /* SYS16BIT */
 
+
 #ifndef MY_ZCALLOC /* Any system without a special alloc function */
+
 #ifndef STDC
 extern voidp  malloc OF((uInt size));
 extern voidp  calloc OF((uInt items, uInt size));
 extern void   free   OF((voidpf ptr));
 #endif
+
 voidpf zcalloc (opaque, items, size)
     voidpf opaque;
     unsigned items;
@@ -265,6 +306,7 @@ voidpf zcalloc (opaque, items, size)
     return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
                               (voidpf)calloc(items, size);
 }
+
 void  zcfree (opaque, ptr)
     voidpf opaque;
     voidpf ptr;
@@ -272,4 +314,5 @@ void  zcfree (opaque, ptr)
     free(ptr);
     if (opaque) return; /* make compiler happy */
 }
+
 #endif /* MY_ZCALLOC */
diff --git a/dep/src/zlib/zutil.h b/dep/src/zlib/zutil.h
index f55a94803cd..b8a722d904d 100644
--- a/dep/src/zlib/zutil.h
+++ b/dep/src/zlib/zutil.h
@@ -2,15 +2,20 @@
  * Copyright (C) 1995-2005 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
+
 /* WARNING: this file should *not* be used by applications. It is
    part of the implementation of the compression library and is
    subject to change. Applications should only use zlib.h.
  */
+
 /* @(#) $Id$ */
+
 #ifndef ZUTIL_H
 #define ZUTIL_H
+
 #define ZLIB_INTERNAL
 #include "zlib.h"
+
 #ifdef STDC
 #  ifndef _WIN32_WCE
 #    include 
@@ -33,41 +38,54 @@
 #    include 
 #  endif
 #endif
+
 #ifndef local
 #  define local static
 #endif
 /* compile with -Dlocal if your debugger can't find static symbols */
+
 typedef unsigned char  uch;
 typedef uch FAR uchf;
 typedef unsigned short ush;
 typedef ush FAR ushf;
 typedef unsigned long  ulg;
+
 extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 /* (size given to avoid silly warnings with Visual C++) */
+
 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
+
 #define ERR_RETURN(strm,err) \
   return (strm->msg = (char*)ERR_MSG(err), (err))
 /* To be used only when the state is known to be valid */
+
         /* common constants */
+
 #ifndef DEF_WBITS
 #  define DEF_WBITS MAX_WBITS
 #endif
 /* default windowBits for decompression. MAX_WBITS is for compression only */
+
 #if MAX_MEM_LEVEL >= 8
 #  define DEF_MEM_LEVEL 8
 #else
 #  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
 #endif
 /* default memLevel */
+
 #define STORED_BLOCK 0
 #define STATIC_TREES 1
 #define DYN_TREES    2
 /* The three kinds of block type */
+
 #define MIN_MATCH  3
 #define MAX_MATCH  258
 /* The minimum and maximum match lengths */
+
 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
+
         /* target dependencies */
+
 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
 #  define OS_CODE  0x00
 #  if defined(__TURBOC__) || defined(__BORLANDC__)
@@ -82,23 +100,28 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #    include 
 #  endif
 #endif
+
 #ifdef AMIGA
 #  define OS_CODE  0x01
 #endif
+
 #if defined(VAXC) || defined(VMS)
 #  define OS_CODE  0x02
 #  define F_OPEN(name, mode) \
      fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
 #endif
+
 #if defined(ATARI) || defined(atarist)
 #  define OS_CODE  0x05
 #endif
+
 #ifdef OS2
 #  define OS_CODE  0x06
 #  ifdef M_I86
      #include 
 #  endif
 #endif
+
 #if defined(MACOS) || defined(TARGET_OS_MAC)
 #  define OS_CODE  0x07
 #  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
@@ -109,20 +132,25 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #    endif
 #  endif
 #endif
+
 #ifdef TOPS20
 #  define OS_CODE  0x0a
 #endif
+
 #ifdef WIN32
 #  ifndef __CYGWIN__  /* Cygwin is Unix, not Win32 */
 #    define OS_CODE  0x0b
 #  endif
 #endif
+
 #ifdef __50SERIES /* Prime/PRIMOS */
 #  define OS_CODE  0x0f
 #endif
+
 #if defined(_BEOS_) || defined(RISCOS)
 #  define fdopen(fd,mode) NULL /* No fdopen() */
 #endif
+
 #if (defined(_MSC_VER) && (_MSC_VER > 600))
 #  if defined(_WIN32_WCE)
 #    define fdopen(fd,mode) NULL /* No fdopen() */
@@ -134,14 +162,19 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #    define fdopen(fd,type)  _fdopen(fd,type)
 #  endif
 #endif
+
         /* common defaults */
+
 #ifndef OS_CODE
 #  define OS_CODE  0x03  /* assume Unix */
 #endif
+
 #ifndef F_OPEN
 #  define F_OPEN(name, mode) fopen((name), (mode))
 #endif
+
          /* functions */
+
 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
 #  ifndef HAVE_VSNPRINTF
 #    define HAVE_VSNPRINTF
@@ -174,6 +207,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #ifdef VMS
 #  define NO_vsnprintf
 #endif
+
 #if defined(pyr)
 #  define NO_MEMCPY
 #endif
@@ -202,6 +236,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    extern int  zmemcmp  OF((const Bytef* s1, const Bytef* s2, uInt len));
    extern void zmemzero OF((Bytef* dest, uInt len));
 #endif
+
 /* Diagnostic functions */
 #ifdef DEBUG
 #  include 
@@ -222,11 +257,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #  define Tracecv(c,x)
 #endif
 
+
 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
 void   zcfree  OF((voidpf opaque, voidpf ptr));
+
 #define ZALLOC(strm, items, size) \
            (*((strm)->zalloc))((strm)->opaque, (items), (size))
 #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
+
 #endif /* ZUTIL_H */
 
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp
index 7d38c82a278..0b48f5f7cef 100644
--- a/src/bindings/scripts/ScriptMgr.cpp
+++ b/src/bindings/scripts/ScriptMgr.cpp
@@ -1,6 +1,7 @@
 /* Copyright (C) 2006 - 2008 TrinityScript 
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #include "precompiled.h"
 #include "Config/Config.h"
 #include "Database/DatabaseEnv.h"
@@ -9,30 +10,39 @@
 #include "ProgressBar.h"
 #include "../system/ScriptLoader.h"
 #include "../system/system.h"
+
 #define _FULLVERSION "TrinityScript"
+
 #ifndef _TRINITY_SCRIPT_CONFIG
 # define _TRINITY_SCRIPT_CONFIG  "trinitycore.conf"
 #endif _TRINITY_SCRIPT_CONFIG
+
 int num_sc_scripts;
 Script *m_scripts[MAX_SCRIPTS];
+
 Config TScriptConfig;
+
 void FillSpellSummary();
 void LoadOverridenSQLData();
 void LoadOverridenDBCData();
+
 void LoadDatabase()
 {
     //Get db string from file
     std::string dbstring = TScriptConfig.GetStringDefault("WorldDatabaseInfo", "");
+
     if (dbstring.empty())
     {
         error_log("TSCR: Missing world database info from configuration file. Load database aborted.");
         return;
     }
+
     //Initialize connection to DB
     if (!dbstring.empty() && TScriptDB.Initialize(dbstring.c_str()))
     {
         outstring_log("TSCR: TrinityScript database initialized successfully.");
         outstring_log("");
+
         pSystemMgr.LoadVersion();
         pSystemMgr.LoadScriptTexts();
         pSystemMgr.LoadScriptTextsCustom();
@@ -43,22 +53,29 @@ void LoadDatabase()
         error_log("TSCR: Unable to connect to database at %s. Load database aborted.", dbstring.c_str());
         return;
     }
+
     TScriptDB.HaltDelayThread();
+
 }
+
 struct TSpellSummary {
     uint8 Targets;                                          // set of enum SelectTarget
     uint8 Effects;                                          // set of enum SelectEffect
 }extern *SpellSummary;
+
 TRINITY_DLL_EXPORT
 void ScriptsFree()
 {
     // Free Spell Summary
     delete []SpellSummary;
+
     // Free resources before library unload
-    for (uint16 i =0; i> Loaded %i C++ Scripts.", num_sc_scripts);
+
     outstring_log(">> Load Overriden SQL Data.");
     LoadOverridenSQLData();
     outstring_log(">> Load Overriden DBC Data.");
     LoadOverridenDBCData();
 }
+
 //*********************************
 //*** Functions used globally ***
+
 void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
 {
     if (!pSource)
@@ -102,18 +130,23 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
         error_log("TSCR: DoScriptText entry %i, invalid Source pointer.", iTextEntry);
         return;
     }
+
     if (iTextEntry >= 0)
     {
         error_log("TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
         return;
     }
+
     const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
+
     if (!pData)
     {
         error_log("TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
         return;
     }
+
     debug_log("TSCR: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote);
+
     if(pData->uiSoundId)
     {
         if(GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
@@ -123,6 +156,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
         else
             error_log("TSCR: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
     }
+
     if(pData->uiEmote)
     {
         if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER)
@@ -130,6 +164,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
         else
             error_log("TSCR: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", iTextEntry, pSource->GetTypeId());
     }
+
     switch(pData->uiType)
     {
         case CHAT_TYPE_SAY:
@@ -163,8 +198,10 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
             break;
     }
 }
+
 //*********************************
 //*** Functions used internally ***
+
 void Script::RegisterSelf()
 {
     int id = GetScriptId(Name.c_str());
@@ -179,8 +216,10 @@ void Script::RegisterSelf()
         delete this;
     }
 }
+
 //********************************
 //*** Functions to be Exported ***
+
 TRINITY_DLL_EXPORT
 void OnLogin(Player *pPlayer)
 {
@@ -188,6 +227,7 @@ void OnLogin(Player *pPlayer)
     if (!tmpscript || !tmpscript->pOnLogin) return;
     tmpscript->pOnLogin(pPlayer);
 }
+
 TRINITY_DLL_EXPORT
 void OnLogout(Player *pPlayer)
 {
@@ -195,6 +235,7 @@ void OnLogout(Player *pPlayer)
     if (!tmpscript || !tmpscript->pOnLogout) return;
     tmpscript->pOnLogout(pPlayer);
 }
+
 TRINITY_DLL_EXPORT
 void OnPVPKill(Player *killer, Player *killed)
 {
@@ -202,6 +243,7 @@ void OnPVPKill(Player *killer, Player *killed)
     if (!tmpscript || !tmpscript->pOnPVPKill) return;
     tmpscript->pOnPVPKill(killer, killed);
 }
+
 TRINITY_DLL_EXPORT
 bool OnSpellCast (Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, uint32 i, SpellEntry const *spell)
 {
@@ -209,6 +251,7 @@ bool OnSpellCast (Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, u
     if (!tmpscript || !tmpscript->pOnSpellCast) return true;
     return tmpscript->pOnSpellCast(pUnitTarget,pItemTarget,pGoTarget,i,spell);
 }
+
 TRINITY_DLL_EXPORT
 uint32 OnGetXP(Player *pPlayer, uint32 amount)
 {
@@ -216,6 +259,7 @@ uint32 OnGetXP(Player *pPlayer, uint32 amount)
     if (!tmpscript || !tmpscript->pOnGetXP) return amount;
     return tmpscript->pOnGetXP(pPlayer,amount);
 }
+
 TRINITY_DLL_EXPORT
 uint32 OnGetMoney(Player *pPlayer, int32 amount)
 {
@@ -223,6 +267,7 @@ uint32 OnGetMoney(Player *pPlayer, int32 amount)
     if (!tmpscript || !tmpscript->pOnGetMoney) return amount;
     return tmpscript->pOnGetMoney(pPlayer,amount);
 }
+
 TRINITY_DLL_EXPORT
 bool OnPlayerChat(Player *pPlayer, const char *text)
 {
@@ -230,6 +275,7 @@ bool OnPlayerChat(Player *pPlayer, const char *text)
     if (!tmpscript || !tmpscript->pOnPlayerChat) return true;
     return tmpscript->pOnPlayerChat(pPlayer,text);
 }
+
 TRINITY_DLL_EXPORT
 void OnServerStartup()
 {
@@ -237,6 +283,7 @@ void OnServerStartup()
     if (!tmpscript || !tmpscript->pOnServerStartup) return;
     tmpscript->pOnServerStartup();
 }
+
 TRINITY_DLL_EXPORT
 void OnServerShutdown()
 {
@@ -244,6 +291,7 @@ void OnServerShutdown()
     if (!tmpscript || !tmpscript->pOnServerShutdown) return;
     tmpscript->pOnServerShutdown();
 }
+
 TRINITY_DLL_EXPORT
 void OnAreaChange(Player *pPlayer, AreaTableEntry const *pArea)
 {
@@ -251,6 +299,7 @@ void OnAreaChange(Player *pPlayer, AreaTableEntry const *pArea)
     if (!tmpscript || !tmpscript->pOnAreaChange) return;
     tmpscript->pOnAreaChange(pPlayer, pArea);
 }
+
 TRINITY_DLL_EXPORT
 bool OnItemClick (Player *pPlayer, Item *pItem)
 {
@@ -258,6 +307,7 @@ bool OnItemClick (Player *pPlayer, Item *pItem)
     if (!tmpscript || !tmpscript->pOnItemClick) return true;
     return tmpscript->pOnItemClick(pPlayer,pItem);
 }
+
 TRINITY_DLL_EXPORT
 bool OnItemOpen (Player *pPlayer, Item *pItem)
 {
@@ -265,6 +315,7 @@ bool OnItemOpen (Player *pPlayer, Item *pItem)
     if (!tmpscript || !tmpscript->pOnItemOpen) return true;
     return tmpscript->pOnItemOpen(pPlayer,pItem);
 }
+
 TRINITY_DLL_EXPORT
 bool OnGoClick (Player *pPlayer, GameObject *pGameObject)
 {
@@ -272,6 +323,7 @@ bool OnGoClick (Player *pPlayer, GameObject *pGameObject)
     if (!tmpscript || !tmpscript->pOnGoClick) return true;
     return tmpscript->pOnGoClick(pPlayer,pGameObject);
 }
+
 TRINITY_DLL_EXPORT
 void OnCreatureKill (Player *pPlayer, Creature *pCreature)
 {
@@ -279,202 +331,259 @@ void OnCreatureKill (Player *pPlayer, Creature *pCreature)
     if (!tmpscript || !tmpscript->pOnCreatureKill) return;
     tmpscript->pOnCreatureKill(pPlayer,pCreature);
 }
+
 TRINITY_DLL_EXPORT
 char const* ScriptsVersion()
 {
     return "Default Trinity scripting library";
 }
+
 TRINITY_DLL_EXPORT
 bool GossipHello (Player * pPlayer, Creature* pCreature)
 {
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->pGossipHello) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGossipHello(pPlayer, pCreature);
 }
+
 TRINITY_DLL_EXPORT
 bool GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     debug_log("TSCR: Gossip selection, sender: %d, action: %d", uiSender, uiAction);
+
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->pGossipSelect) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGossipSelect(pPlayer, pCreature, uiSender, uiAction);
 }
+
 TRINITY_DLL_EXPORT
 bool GossipSelectWithCode(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode)
 {
     debug_log("TSCR: Gossip selection with code, sender: %d, action: %d", uiSender, uiAction);
+
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->pGossipSelectWithCode) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGossipSelectWithCode(pPlayer, pCreature, uiSender, uiAction, sCode);
 }
+
 TRINITY_DLL_EXPORT
 bool GOSelect(Player* pPlayer, GameObject* pGO, uint32 uiSender, uint32 uiAction)
 {
     if(!pGO)
     return false;
     debug_log("TSCR: Gossip selection, sender: %d, action: %d", uiSender, uiAction);
+
     Script *tmpscript = m_scripts[pGO->GetGOInfo()->ScriptId];
     if(!tmpscript || !tmpscript->pGOSelect) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGOSelect(pPlayer, pGO, uiSender, uiAction);
 }
+
 TRINITY_DLL_EXPORT
 bool GOSelectWithCode(Player* pPlayer, GameObject* pGO, uint32 uiSender, uint32 uiAction, const char* sCode)
 {
     if(!pGO)
     return false;
     debug_log("TSCR: Gossip selection, sender: %d, action: %d",uiSender, uiAction);
+
     Script *tmpscript = m_scripts[pGO->GetGOInfo()->ScriptId];
     if(!tmpscript || !tmpscript->pGOSelectWithCode) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGOSelectWithCode(pPlayer, pGO, uiSender ,uiAction, sCode);
 }
+
 TRINITY_DLL_EXPORT
 bool QuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->pQuestAccept) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pQuestAccept(pPlayer, pCreature, pQuest);
 }
+
 TRINITY_DLL_EXPORT
 bool QuestSelect(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->pQuestSelect) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pQuestSelect(pPlayer, pCreature, pQuest);
 }
+
 TRINITY_DLL_EXPORT
 bool QuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->pQuestComplete) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pQuestComplete(pPlayer, pCreature, pQuest);
 }
+
 TRINITY_DLL_EXPORT
 bool ChooseReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest, uint32 opt)
 {
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->pChooseReward) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pChooseReward(pPlayer, pCreature, pQuest, opt);
 }
+
 TRINITY_DLL_EXPORT
 uint32 NPCDialogStatus(Player* pPlayer, Creature* pCreature)
 {
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->pNPCDialogStatus) return 100;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pNPCDialogStatus(pPlayer, pCreature);
 }
+
 TRINITY_DLL_EXPORT
 uint32 GODialogStatus(Player* pPlayer, GameObject* pGO)
 {
     Script *tmpscript = m_scripts[pGO->GetGOInfo()->ScriptId];
     if (!tmpscript || !tmpscript->pGODialogStatus) return 100;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGODialogStatus(pPlayer, pGO);
 }
+
 TRINITY_DLL_EXPORT
 bool ItemHello(Player* pPlayer, Item* pItem, Quest const* pQuest)
 {
     Script *tmpscript = m_scripts[pItem->GetProto()->ScriptId];
     if (!tmpscript || !tmpscript->pItemHello) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pItemHello(pPlayer, pItem, pQuest);
 }
+
 TRINITY_DLL_EXPORT
 bool ItemQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest)
 {
     Script *tmpscript = m_scripts[pItem->GetProto()->ScriptId];
     if (!tmpscript || !tmpscript->pItemQuestAccept) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pItemQuestAccept(pPlayer, pItem, pQuest);
 }
+
 TRINITY_DLL_EXPORT
 bool GOHello(Player* pPlayer, GameObject* pGO)
 {
     Script *tmpscript = m_scripts[pGO->GetGOInfo()->ScriptId];
     if (!tmpscript || !tmpscript->pGOHello) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGOHello(pPlayer, pGO);
 }
+
 TRINITY_DLL_EXPORT
 bool GOQuestAccept(Player* pPlayer, GameObject* pGO, Quest const* pQuest)
 {
     Script *tmpscript = m_scripts[pGO->GetGOInfo()->ScriptId];
     if (!tmpscript || !tmpscript->pGOQuestAccept) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGOQuestAccept(pPlayer, pGO, pQuest);
 }
+
 TRINITY_DLL_EXPORT
 bool GOChooseReward(Player* pPlayer, GameObject* pGO, Quest const* pQuest, uint32 opt)
 {
     Script *tmpscript = m_scripts[pGO->GetGOInfo()->ScriptId];
     if (!tmpscript || !tmpscript->pGOChooseReward) return false;
+
     pPlayer->PlayerTalkClass->ClearMenus();
     return tmpscript->pGOChooseReward(pPlayer, pGO, pQuest, opt);
 }
+
 TRINITY_DLL_EXPORT
 bool AreaTrigger(Player* pPlayer, AreaTriggerEntry * atEntry)
 {
     Script *tmpscript = m_scripts[GetAreaTriggerScriptId(atEntry->id)];
     if (!tmpscript || !tmpscript->pAreaTrigger) return false;
+
     return tmpscript->pAreaTrigger(pPlayer, atEntry);
 }
+
 TRINITY_DLL_EXPORT
 CreatureAI* GetAI(Creature* pCreature)
 {
     Script *tmpscript = m_scripts[pCreature->GetScriptId()];
     if (!tmpscript || !tmpscript->GetAI) return NULL;
+
     return tmpscript->GetAI(pCreature);
 }
+
 TRINITY_DLL_EXPORT
 bool ItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
 {
     Script *tmpscript = m_scripts[pItem->GetProto()->ScriptId];
     if (!tmpscript || !tmpscript->pItemUse) return false;
+
     return tmpscript->pItemUse(pPlayer, pItem, targets);
 }
+
 TRINITY_DLL_EXPORT
 bool ItemExpire(Player* pPlayer, ItemPrototype const * pItemProto)
 {
     Script *tmpscript = m_scripts[pItemProto->ScriptId];
     if (!tmpscript || !tmpscript->pItemExpire) return true;
+
     return tmpscript->pItemExpire(pPlayer, pItemProto);
 }
+
 TRINITY_DLL_EXPORT
 bool EffectDummyCreature(Unit *caster, uint32 spellId, uint32 effIndex, Creature *crTarget)
 {
     Script *tmpscript = m_scripts[crTarget->GetScriptId()];
+
     if (!tmpscript || !tmpscript->pEffectDummyCreature) return false;
+
     return tmpscript->pEffectDummyCreature(caster, spellId, effIndex, crTarget);
 }
+
 TRINITY_DLL_EXPORT
 bool EffectDummyGameObj(Unit *caster, uint32 spellId, uint32 effIndex, GameObject *gameObjTarget)
 {
     Script *tmpscript = m_scripts[gameObjTarget->GetGOInfo()->ScriptId];
+
     if (!tmpscript || !tmpscript->pEffectDummyGameObj) return false;
+
     return tmpscript->pEffectDummyGameObj(caster, spellId, effIndex, gameObjTarget);
 }
+
 TRINITY_DLL_EXPORT
 bool EffectDummyItem(Unit *caster, uint32 spellId, uint32 effIndex, Item *itemTarget)
 {
     Script *tmpscript = m_scripts[itemTarget->GetProto()->ScriptId];
+
     if (!tmpscript || !tmpscript->pEffectDummyItem) return false;
+
     return tmpscript->pEffectDummyItem(caster, spellId, effIndex, itemTarget);
 }
+
 TRINITY_DLL_EXPORT
 InstanceData* CreateInstanceData(Map *map)
 {
     if (!map->IsDungeon()) return NULL;
+
     Script *tmpscript = m_scripts[((InstanceMap*)map)->GetScriptId()];
     if (!tmpscript || !tmpscript->GetInstanceData) return NULL;
+
     return tmpscript->GetInstanceData(map);
 }
 
diff --git a/src/bindings/scripts/ScriptMgr.h b/src/bindings/scripts/ScriptMgr.h
index 7e9ac9b89f2..9456a0da661 100644
--- a/src/bindings/scripts/ScriptMgr.h
+++ b/src/bindings/scripts/ScriptMgr.h
@@ -4,11 +4,14 @@
  *
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef SC_SCRIPTMGR_H
 #define SC_SCRIPTMGR_H
+
 #include "Common.h"
 #include "Platform/CompilerDefs.h"
 #include "DBCStructure.h"
+
 class Player;
 class Creature;
 class CreatureAI;
@@ -21,9 +24,11 @@ class Map;
 class Unit;
 class WorldObject;
 struct ItemPrototype;
+
 #define MAX_SCRIPTS         5000                            //72 bytes each (approx 351kb)
 #define VISIBLE_RANGE       (166.0f)                        //MAX visible range (size of grid)
 #define DEFAULT_TEXT        ""
+
 struct Script
 {
     Script() :
@@ -34,7 +39,9 @@ struct Script
         pEffectDummyCreature(NULL), pEffectDummyGameObj(NULL), pEffectDummyItem(NULL),
         GetAI(NULL), GetInstanceData(NULL)
     {}
+
     std::string Name;
+
     //Methods to be scripted
     void (*pOnLogin             )(Player*);
     void (*pOnLogout            )(Player*);
@@ -72,17 +79,22 @@ struct Script
     bool (*pEffectDummyCreature )(Unit*, uint32, uint32, Creature* );
     bool (*pEffectDummyGameObj  )(Unit*, uint32, uint32, GameObject* );
     bool (*pEffectDummyItem     )(Unit*, uint32, uint32, Item* );
+
     CreatureAI* (*GetAI)(Creature*);
     InstanceData* (*GetInstanceData)(Map*);
+
     void RegisterSelf();
 };
+
 //Generic scripting text function
 void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target = NULL);
+
 #if COMPILER == COMPILER_GNU
 #define FUNC_PTR(name,callconvention,returntype,parameters)    typedef returntype(*name)parameters __attribute__ ((callconvention));
 #else
 #define FUNC_PTR(name, callconvention, returntype, parameters)    typedef returntype(callconvention *name)parameters;
 #endif
+
 #ifdef WIN32
   #define TRINITY_DLL_EXPORT extern "C" __declspec(dllexport)
 #elif defined( __GNUC__ )
@@ -90,5 +102,6 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target = NULL);
 #else
 #define TRINITY_DLL_EXPORT extern "C" export
 #endif
+
 #endif
 
diff --git a/src/bindings/scripts/base/escort_ai.cpp b/src/bindings/scripts/base/escort_ai.cpp
index 5c256aceb65..4d6083ab470 100644
--- a/src/bindings/scripts/base/escort_ai.cpp
+++ b/src/bindings/scripts/base/escort_ai.cpp
@@ -1,19 +1,23 @@
 /* Copyright (C) 2006 - 2009 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 "escort_ai.h"
+
 enum ePoints
 {
     POINT_LAST_POINT    = 0xFFFFFF,
     POINT_HOME          = 0xFFFFFE
 };
+
 npc_escortAI::npc_escortAI(Creature* pCreature) : ScriptedAI(pCreature),
     m_uiPlayerGUID(0),
     MaxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE),
@@ -30,32 +34,40 @@ npc_escortAI::npc_escortAI(Creature* pCreature) : ScriptedAI(pCreature),
     m_bCanReturnToStart(false),
     ScriptWP(false)
 {}
+
 void npc_escortAI::AttackStart(Unit* pWho)
 {
     if (!pWho)
         return;
+
     if (m_creature->Attack(pWho, true))
     {
         if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
             m_creature->GetMotionMaster()->MovementExpired();
+
         if (IsCombatMovement())
             m_creature->GetMotionMaster()->MoveChase(pWho);
     }
 }
+
 //see followerAI
 bool npc_escortAI::AssistPlayerInCombat(Unit* pWho)
 {
     if (!pWho || !pWho->getVictim())
         return false;
+
     //experimental (unknown) flag not present
     if (!(m_creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13))
         return false;
+
     //not a player
     if (!pWho->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself())
         return false;
+
     //never attack friendly
     if (m_creature->IsFriendlyTo(pWho))
         return false;
+
     //too far away and no free sight?
     if (m_creature->IsWithinDistInMap(pWho, GetMaxPlayerDistance()) && m_creature->IsWithinLOSInMap(pWho))
     {
@@ -72,16 +84,20 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* pWho)
             return true;
         }
     }
+
     return false;
 }
+
 void npc_escortAI::MoveInLineOfSight(Unit* pWho)
 {
     if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && pWho->isInAccessiblePlaceFor(m_creature))
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING) && AssistPlayerInCombat(pWho))
             return;
+
         if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE)
             return;
+
         if (m_creature->IsHostileTo(pWho))
         {
             float fAttackRadius = m_creature->GetAttackDistance(pWho);
@@ -101,15 +117,17 @@ void npc_escortAI::MoveInLineOfSight(Unit* pWho)
         }
     }
 }
+
 void npc_escortAI::JustDied(Unit* pKiller)
 {
     if (!HasEscortState(STATE_ESCORT_ESCORTING) || !m_uiPlayerGUID || !m_pQuestForEscort)
         return;
+
     if (Player* pPlayer = GetPlayerForEscort())
     {
         if (Group* pGroup = pPlayer->GetGroup())
         {
-            for (GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
+            for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
             {
                 if (Player* pMember = pRef->getSource())
                 {
@@ -125,29 +143,37 @@ void npc_escortAI::JustDied(Unit* pKiller)
         }
     }
 }
+
 void npc_escortAI::JustRespawned()
 {
     m_uiEscortState = STATE_ESCORT_NONE;
+
     if (!IsCombatMovement())
         SetCombatMovement(true);
+
     //add a small delay before going to first waypoint, normal in near all cases
     m_uiWPWaitTimer = 2500;
+
     if (m_creature->getFaction() != m_creature->GetCreatureInfo()->faction_A)
         me->RestoreFaction();
+
     Reset();
 }
+
 void npc_escortAI::ReturnToLastPoint()
 {
     float x, y, z, o;
     m_creature->GetHomePosition(x, y, z, o);
     m_creature->GetMotionMaster()->MovePoint(POINT_LAST_POINT, x, y, z);
 }
+
 void npc_escortAI::EnterEvadeMode()
 {
     m_creature->RemoveAllAuras();
     m_creature->DeleteThreatList();
     m_creature->CombatStop(true);
     m_creature->SetLootRecipient(NULL);
+
     if (HasEscortState(STATE_ESCORT_ESCORTING))
     {
         AddEscortState(STATE_ESCORT_RETURNING);
@@ -156,17 +182,20 @@ void npc_escortAI::EnterEvadeMode()
     }
     else
         m_creature->GetMotionMaster()->MoveTargetedHome();
+
     Reset();
 }
+
 bool npc_escortAI::IsPlayerOrGroupInRange()
 {
     if (Player* pPlayer = GetPlayerForEscort())
     {
         if (Group* pGroup = pPlayer->GetGroup())
         {
-            for (GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
+            for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
             {
                 Player* pMember = pRef->getSource();
+
                 if (pMember && m_creature->IsWithinDistInMap(pMember, GetMaxPlayerDistance()))
                 {
                     return true;
@@ -182,6 +211,7 @@ bool npc_escortAI::IsPlayerOrGroupInRange()
     }
     return false;
 }
+
 void npc_escortAI::UpdateAI(const uint32 uiDiff)
 {
     //Waypoint Updating
@@ -195,15 +225,20 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff)
                 if (DespawnAtEnd)
                 {
                     debug_log("TSCR: EscortAI reached end of waypoints");
+
                     if (m_bCanReturnToStart)
                     {
                         float fRetX, fRetY, fRetZ;
                         m_creature->GetRespawnCoord(fRetX, fRetY, fRetZ);
+
                         m_creature->GetMotionMaster()->MovePoint(POINT_HOME, fRetX, fRetY, fRetZ);
+
                         m_uiWPWaitTimer = 0;
+
                         debug_log("TSCR: EscortAI are returning home to spawn location: %u, %f, %f, %f", POINT_HOME, fRetX, fRetY, fRetZ);
                         return;
                     }
+
                     if (m_bCanInstantRespawn)
                     {
                         m_creature->setDeathState(JUST_DIED);
@@ -211,25 +246,31 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff)
                     }
                     else
                         m_creature->ForcedDespawn();
+
                     return;
                 }
                 else
                 {
                     debug_log("TSCR: EscortAI reached end of waypoints with Despawn off");
+
                     return;
                 }
             }
+
             if (!HasEscortState(STATE_ESCORT_PAUSED))
             {
                 m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
                 debug_log("TSCR: EscortAI start waypoint %u (%f, %f, %f).", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
+
                 WaypointStart(CurrentWP->id);
+
                 m_uiWPWaitTimer = 0;
             }
         }
         else
             m_uiWPWaitTimer -= uiDiff;
     }
+
     //Check if player or any member of his group is within range
     if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPlayerGUID && !m_creature->getVictim() && !HasEscortState(STATE_ESCORT_RETURNING))
     {
@@ -238,6 +279,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff)
             if (DespawnAtFar && !IsPlayerOrGroupInRange())
             {
                 debug_log("TSCR: EscortAI failed because player/group was to far away or not found");
+
                 if (m_bCanInstantRespawn)
                 {
                     m_creature->setDeathState(JUST_DIED);
@@ -245,39 +287,49 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff)
                 }
                 else
                     m_creature->ForcedDespawn();
+
                 return;
             }
+
             m_uiPlayerCheckTimer = 1000;
         }
         else
             m_uiPlayerCheckTimer -= uiDiff;
     }
+
     UpdateEscortAI(uiDiff);
 }
+
 void npc_escortAI::UpdateEscortAI(const uint32 uiDiff)
 {
     if (CanMelee && UpdateVictim())
         DoMeleeAttackIfReady();
 }
+
 void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId)
 {
     if (uiMoveType != POINT_MOTION_TYPE || !HasEscortState(STATE_ESCORT_ESCORTING))
         return;
+
     //Combat start position reached, continue waypoint movement
     if (uiPointId == POINT_LAST_POINT)
     {
         debug_log("TSCR: EscortAI has returned to original position before combat");
+
         if (m_bIsRunning && m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
             m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
         else if (!m_bIsRunning && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
             m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+
         RemoveEscortState(STATE_ESCORT_RETURNING);
+
         if (!m_uiWPWaitTimer)
             m_uiWPWaitTimer = 1;
     }
     else if (uiPointId == POINT_HOME)
     {
         debug_log("TSCR: EscortAI has returned to original home location and will continue from beginning of waypoint list.");
+
         CurrentWP = WaypointList.begin();
         m_uiWPWaitTimer = 1;
     }
@@ -289,13 +341,18 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId)
             error_log("TSCR ERROR: EscortAI reached waypoint out of order %u, expected %u", uiPointId, CurrentWP->id);
             return;
         }
+
         debug_log("TSCR: EscortAI Waypoint %u reached", CurrentWP->id);
+
         //Call WP function
         WaypointReached(CurrentWP->id);
+
         m_uiWPWaitTimer = CurrentWP->WaitTimeMs + 1;
+
         ++CurrentWP;
     }
 }
+
 /*
 void npc_escortAI::OnPossess(bool apply)
 {
@@ -314,10 +371,13 @@ void npc_escortAI::OnPossess(bool apply)
     }
 }
 */
+
 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);
+
     // i think SD2 no longer uses this function
     ScriptWP = true;
     /*PointMovement wp;
@@ -329,18 +389,23 @@ void npc_escortAI::AddWaypoint(uint32 id, float x, float y, float z, uint32 Wait
     wp.m_uiWaitTime = WaitTimeMs;
     PointMovementMap[wp.m_uiCreatureEntry].push_back(wp);*/
 }
+
 void npc_escortAI::FillPointMovementListForCreature()
 {
     std::vector const &pPointsEntries = pSystemMgr.GetPointMoveList(m_creature->GetEntry());
+
     if (pPointsEntries.empty())
         return;
+
     std::vector::const_iterator itr;
+
     for (itr = pPointsEntries.begin(); itr != pPointsEntries.end(); ++itr)
     {
         Escort_Waypoint pPoint(itr->uiPointId, itr->fX, itr->fY, itr->fZ, itr->uiWaitTime);
         WaypointList.push_back(pPoint);
     }
 }
+
 void npc_escortAI::SetRun(bool bRun)
 {
     if (bRun)
@@ -359,6 +424,7 @@ void npc_escortAI::SetRun(bool bRun)
     }
     m_bIsRunning = bRun;
 }
+
 //TODO: get rid of this many variables passed in function.
 void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, const Quest* pQuest, bool bInstantRespawn, bool bCanLoopPath)
 {
@@ -367,52 +433,70 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID,
         error_log("TSCR ERROR: EscortAI attempt to Start while in combat.");
         return;
     }
+
     if (HasEscortState(STATE_ESCORT_ESCORTING))
     {
         error_log("TSCR: EscortAI attempt to Start while already escorting.");
         return;
     }
+
     if(!ScriptWP) // sd2 never adds wp in script, but tc does
     {
+
     if (!WaypointList.empty())
         WaypointList.clear();
+
     FillPointMovementListForCreature();
+
     }
+
     if (WaypointList.empty())
     {
         error_db_log("TSCR: EscortAI Start with 0 waypoints (possible missing entry in script_waypoint).");
         return;
     }
+
     //set variables
     m_bIsActiveAttacker = bIsActiveAttacker;
     m_bIsRunning = bRun;
+
     m_uiPlayerGUID = uiPlayerGUID;
     m_pQuestForEscort = pQuest;
+
     m_bCanInstantRespawn = bInstantRespawn;
     m_bCanReturnToStart = bCanLoopPath;
+
     if (m_bCanReturnToStart && m_bCanInstantRespawn)
         debug_log("TSCR: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn.");
+
     if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
     {
         m_creature->GetMotionMaster()->MovementExpired();
         m_creature->GetMotionMaster()->MoveIdle();
         debug_log("TSCR: EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle.");
     }
+
     //disable npcflags
     m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+
     debug_log("TSCR: EscortAI started with %u waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = %u", WaypointList.size(), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID);
+
     CurrentWP = WaypointList.begin();
+
     //Set initial speed
     if (m_bIsRunning)
         m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
     else
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+
     AddEscortState(STATE_ESCORT_ESCORTING);
 }
+
 void npc_escortAI::SetEscortPaused(bool bPaused)
 {
     if (!HasEscortState(STATE_ESCORT_ESCORTING))
         return;
+
     if (bPaused)
         AddEscortState(STATE_ESCORT_PAUSED);
     else
diff --git a/src/bindings/scripts/base/escort_ai.h b/src/bindings/scripts/base/escort_ai.h
index 89a0fc596e8..d0cb55b100a 100644
--- a/src/bindings/scripts/base/escort_ai.h
+++ b/src/bindings/scripts/base/escort_ai.h
@@ -1,10 +1,14 @@
 /* Copyright (C) 2006 - 2009 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
+
 #include "../system/system.h"
+
 #define DEFAULT_MAX_PLAYER_DISTANCE 50
+
 struct Escort_Waypoint
 {
     Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w)
@@ -15,12 +19,14 @@ struct Escort_Waypoint
         z = _z;
         WaitTimeMs = _w;
     }
+
     uint32 id;
     float x;
     float y;
     float z;
     uint32 WaitTimeMs;
 };
+
 enum eEscortState
 {
     STATE_ESCORT_NONE       = 0x000,                        //nothing in progress
@@ -28,53 +34,76 @@ enum eEscortState
     STATE_ESCORT_RETURNING  = 0x002,                        //escort is returning after being in combat
     STATE_ESCORT_PAUSED     = 0x004                         //will not proceed with waypoints before state is removed
 };
+
 struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
 {
     public:
         explicit npc_escortAI(Creature* pCreature);
         ~npc_escortAI() {}
+
         // CreatureAI functions
         void AttackStart(Unit* who);
+
         void MoveInLineOfSight(Unit* who);
+
         void JustDied(Unit*);
+
         void JustRespawned();
+
         void ReturnToLastPoint();
+
         void EnterEvadeMode();
+
         void UpdateAI(const uint32);                        //the "internal" update, calls UpdateEscortAI()
         virtual void UpdateEscortAI(const uint32);          //used when it's needed to add code in update (abilities, scripted events, etc)
+
         void MovementInform(uint32, uint32);
+
         // EscortAI functions
         void AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs = 0);
+
         virtual void WaypointReached(uint32 uiPointId) = 0;
         virtual void WaypointStart(uint32 uiPointId) {}
+
         void Start(bool bIsActiveAttacker = true, bool bRun = false, uint64 uiPlayerGUID = 0, const Quest* pQuest = NULL, bool bInstantRespawn = false, bool bCanLoopPath = false);
+
         void SetRun(bool bRun = true);
         void SetEscortPaused(bool uPaused);
+
         bool HasEscortState(uint32 uiEscortState) { return (m_uiEscortState & uiEscortState); }
+
         void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
         float GetMaxPlayerDistance() { return MaxPlayerDistance; }
+
         void SetCanMelee(bool usemelee) { CanMelee = usemelee; }
         void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; }
         void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
         bool GetAttack() { return m_bIsActiveAttacker; }//used in EnterEvadeMode override
         void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; }
         uint64 GetEventStarterGUID() { return m_uiPlayerGUID; }
+
     protected:
         Player* GetPlayerForEscort() { return (Player*)Unit::GetUnit(*m_creature, m_uiPlayerGUID); }
+
     private:
         bool AssistPlayerInCombat(Unit* pWho);
         bool IsPlayerOrGroupInRange();
         void FillPointMovementListForCreature();
+
         void AddEscortState(uint32 uiEscortState) { m_uiEscortState |= uiEscortState; }
         void RemoveEscortState(uint32 uiEscortState) { m_uiEscortState &= ~uiEscortState; }
+
         uint64 m_uiPlayerGUID;
         uint32 m_uiWPWaitTimer;
         uint32 m_uiPlayerCheckTimer;
         uint32 m_uiEscortState;
         float MaxPlayerDistance;
+
         const Quest* m_pQuestForEscort;                     //generally passed in Start() when regular escort script.
+
         std::list WaypointList;
         std::list::iterator CurrentWP;
+
         bool m_bIsActiveAttacker;                           //obsolete, determined by faction.
         bool m_bIsRunning;                                  //all creatures are walking by default (has flag MOVEMENTFLAG_WALK)
         bool m_bCanInstantRespawn;                          //if creature should respawn instantly after escort over (if not, database respawntime are used)
diff --git a/src/bindings/scripts/base/follower_ai.cpp b/src/bindings/scripts/base/follower_ai.cpp
index 67c03c396ce..8284af7aec0 100644
--- a/src/bindings/scripts/base/follower_ai.cpp
+++ b/src/bindings/scripts/base/follower_ai.cpp
@@ -1,40 +1,50 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 /* ScriptData
 SDName: FollowerAI
 SD%Complete: 50
 SDComment: This AI is under development
 SDCategory: Npc
 EndScriptData */
+
 #include "precompiled.h"
 #include "follower_ai.h"
+
 const float MAX_PLAYER_DISTANCE = 100.0f;
+
 enum ePoints
 {
     POINT_COMBAT_START  = 0xFFFFFF
 };
+
 FollowerAI::FollowerAI(Creature* pCreature) : ScriptedAI(pCreature),
     m_uiLeaderGUID(0),
     m_pQuestForFollow(NULL),
     m_uiUpdateFollowTimer(2500),
     m_uiFollowState(STATE_FOLLOW_NONE)
 {}
+
 void FollowerAI::AttackStart(Unit* pWho)
 {
     if (!pWho)
         return;
+
     if (m_creature->Attack(pWho, true))
     {
         m_creature->AddThreat(pWho, 0.0f);
         m_creature->SetInCombatWith(pWho);
         pWho->SetInCombatWith(m_creature);
+
         if (m_creature->hasUnitState(UNIT_STAT_FOLLOW))
             m_creature->clearUnitState(UNIT_STAT_FOLLOW);
+
         if (IsCombatMovement())
             m_creature->GetMotionMaster()->MoveChase(pWho);
     }
 }
+
 //This part provides assistance to a player that are attacked by pWho, even if out of normal aggro range
 //It will cause m_creature to attack pWho that are attacking _any_ player (which has been confirmed may happen also on offi)
 //The flag (type_flag) is unconfirmed, but used here for further research and is a good candidate.
@@ -42,15 +52,19 @@ bool FollowerAI::AssistPlayerInCombat(Unit* pWho)
 {
     if (!pWho || !pWho->getVictim())
         return false;
+
     //experimental (unknown) flag not present
     if (!(m_creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13))
         return false;
+
     //not a player
     if (!pWho->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself())
         return false;
+
     //never attack friendly
     if (m_creature->IsFriendlyTo(pWho))
         return false;
+
     //too far away and no free sight?
     if (m_creature->IsWithinDistInMap(pWho, MAX_PLAYER_DISTANCE) && m_creature->IsWithinLOSInMap(pWho))
     {
@@ -67,16 +81,20 @@ bool FollowerAI::AssistPlayerInCombat(Unit* pWho)
             return true;
         }
     }
+
     return false;
 }
+
 void FollowerAI::MoveInLineOfSight(Unit* pWho)
 {
     if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && pWho->isInAccessiblePlaceFor(m_creature))
     {
         if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombat(pWho))
             return;
+
         if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE)
             return;
+
         if (m_creature->IsHostileTo(pWho))
         {
             float fAttackRadius = m_creature->GetAttackDistance(pWho);
@@ -96,16 +114,18 @@ void FollowerAI::MoveInLineOfSight(Unit* pWho)
         }
     }
 }
+
 void FollowerAI::JustDied(Unit* pKiller)
 {
     if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || !m_uiLeaderGUID || !m_pQuestForFollow)
         return;
+
     //TODO: need a better check for quests with time limit.
     if (Player* pPlayer = GetLeaderForFollower())
     {
         if (Group* pGroup = pPlayer->GetGroup())
         {
-            for (GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
+            for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
             {
                 if (Player* pMember = pRef->getSource())
                 {
@@ -121,24 +141,31 @@ void FollowerAI::JustDied(Unit* pKiller)
         }
     }
 }
+
 void FollowerAI::JustRespawned()
 {
     m_uiFollowState = STATE_FOLLOW_NONE;
+
     if (!IsCombatMovement())
         SetCombatMovement(true);
+
     if (m_creature->getFaction() != m_creature->GetCreatureInfo()->faction_A)
         m_creature->setFaction(m_creature->GetCreatureInfo()->faction_A);
+
     Reset();
 }
+
 void FollowerAI::EnterEvadeMode()
 {
     m_creature->RemoveAllAuras();
     m_creature->DeleteThreatList();
     m_creature->CombatStop(true);
     m_creature->SetLootRecipient(NULL);
+
     if (HasFollowState(STATE_FOLLOW_INPROGRESS))
     {
         debug_log("TSCR: FollowerAI left combat, returning to CombatStartPosition.");
+
         if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
         {
             float fPosX, fPosY, fPosZ;
@@ -151,8 +178,10 @@ void FollowerAI::EnterEvadeMode()
         if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
             m_creature->GetMotionMaster()->MoveTargetedHome();
     }
+
     Reset();
 }
+
 void FollowerAI::UpdateAI(const uint32 uiDiff)
 {
     if (HasFollowState(STATE_FOLLOW_INPROGRESS) && !m_creature->getVictim())
@@ -165,21 +194,26 @@ void FollowerAI::UpdateAI(const uint32 uiDiff)
                 m_creature->ForcedDespawn();
                 return;
             }
+
             bool bIsMaxRangeExceeded = true;
+
             if (Player* pPlayer = GetLeaderForFollower())
             {
                 if (HasFollowState(STATE_FOLLOW_RETURNING))
                 {
                     debug_log("TSCR: FollowerAI is returning to leader.");
+
                     RemoveFollowState(STATE_FOLLOW_RETURNING);
                     m_creature->GetMotionMaster()->MoveFollow(pPlayer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
                     return;
                 }
+
                 if (Group* pGroup = pPlayer->GetGroup())
                 {
-                    for (GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
+                    for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
                     {
                         Player* pMember = pRef->getSource();
+
                         if (pMember && m_creature->IsWithinDistInMap(pMember, MAX_PLAYER_DISTANCE))
                         {
                             bIsMaxRangeExceeded = false;
@@ -193,29 +227,36 @@ void FollowerAI::UpdateAI(const uint32 uiDiff)
                         bIsMaxRangeExceeded = false;
                 }
             }
+
             if (bIsMaxRangeExceeded)
             {
                 debug_log("TSCR: FollowerAI failed because player/group was to far away or not found");
                 m_creature->ForcedDespawn();
                 return;
             }
+
             m_uiUpdateFollowTimer = 1000;
         }
         else
             m_uiUpdateFollowTimer -= uiDiff;
     }
+
     UpdateFollowerAI(uiDiff);
 }
+
 void FollowerAI::UpdateFollowerAI(const uint32 uiDiff)
 {
     if (!UpdateVictim())
         return;
+
     DoMeleeAttackIfReady();
 }
+
 void FollowerAI::MovementInform(uint32 uiMotionType, uint32 uiPointId)
 {
     if (uiMotionType != POINT_MOTION_TYPE || !HasFollowState(STATE_FOLLOW_INPROGRESS))
         return;
+
     if (uiPointId == POINT_COMBAT_START)
     {
         if (GetLeaderForFollower())
@@ -227,6 +268,7 @@ void FollowerAI::MovementInform(uint32 uiMotionType, uint32 uiPointId)
             m_creature->ForcedDespawn();
     }
 }
+
 void FollowerAI::StartFollow(Player* pLeader, uint32 uiFactionForFollower, const Quest* pQuest)
 {
     if (m_creature->getVictim())
@@ -234,27 +276,37 @@ void FollowerAI::StartFollow(Player* pLeader, uint32 uiFactionForFollower, const
         debug_log("TSCR: FollowerAI attempt to StartFollow while in combat.");
         return;
     }
+
     if (HasFollowState(STATE_FOLLOW_INPROGRESS))
     {
         error_log("TSCR: FollowerAI attempt to StartFollow while already following.");
         return;
     }
+
     //set variables
     m_uiLeaderGUID = pLeader->GetGUID();
+
     if (uiFactionForFollower)
         m_creature->setFaction(uiFactionForFollower);
+
     m_pQuestForFollow = pQuest;
+
     if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
     {
         m_creature->GetMotionMaster()->Clear();
         m_creature->GetMotionMaster()->MoveIdle();
         debug_log("TSCR: FollowerAI start with WAYPOINT_MOTION_TYPE, set to MoveIdle.");
     }
+
     m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+
     AddFollowState(STATE_FOLLOW_INPROGRESS);
+
     m_creature->GetMotionMaster()->MoveFollow(pLeader, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
+
     debug_log("TSCR: FollowerAI start follow %s (GUID %u)", pLeader->GetName(), m_uiLeaderGUID);
 }
+
 Player* FollowerAI::GetLeaderForFollower()
 {
     if (Player* pLeader = Unit::GetPlayer(m_uiLeaderGUID))
@@ -265,9 +317,10 @@ Player* FollowerAI::GetLeaderForFollower()
         {
             if (Group* pGroup = pLeader->GetGroup())
             {
-                for (GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
+                for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
                 {
                     Player* pMember = pRef->getSource();
+
                     if (pMember && pMember->isAlive() && m_creature->IsWithinDistInMap(pMember, MAX_PLAYER_DISTANCE))
                     {
                         debug_log("TSCR: FollowerAI GetLeader changed and returned new leader.");
@@ -279,18 +332,22 @@ Player* FollowerAI::GetLeaderForFollower()
             }
         }
     }
+
     debug_log("TSCR: FollowerAI GetLeader can not find suitable leader.");
     return NULL;
 }
+
 void FollowerAI::SetFollowComplete(bool bWithEndEvent)
 {
     if (m_creature->hasUnitState(UNIT_STAT_FOLLOW))
     {
         m_creature->clearUnitState(UNIT_STAT_FOLLOW);
+
         m_creature->StopMoving();
         m_creature->GetMotionMaster()->Clear();
         m_creature->GetMotionMaster()->MoveIdle();
     }
+
     if (bWithEndEvent)
         AddFollowState(STATE_FOLLOW_POSTEVENT);
     else
@@ -298,18 +355,23 @@ void FollowerAI::SetFollowComplete(bool bWithEndEvent)
         if (HasFollowState(STATE_FOLLOW_POSTEVENT))
             RemoveFollowState(STATE_FOLLOW_POSTEVENT);
     }
+
     AddFollowState(STATE_FOLLOW_COMPLETE);
 }
+
 void FollowerAI::SetFollowPaused(bool bPaused)
 {
     if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || HasFollowState(STATE_FOLLOW_COMPLETE))
         return;
+
     if (bPaused)
     {
         AddFollowState(STATE_FOLLOW_PAUSED);
+
         if (m_creature->hasUnitState(UNIT_STAT_FOLLOW))
         {
             m_creature->clearUnitState(UNIT_STAT_FOLLOW);
+
             m_creature->StopMoving();
             m_creature->GetMotionMaster()->Clear();
             m_creature->GetMotionMaster()->MoveIdle();
@@ -318,6 +380,7 @@ void FollowerAI::SetFollowPaused(bool bPaused)
     else
     {
         RemoveFollowState(STATE_FOLLOW_PAUSED);
+
         if (Player* pLeader = GetLeaderForFollower())
             m_creature->GetMotionMaster()->MoveFollow(pLeader, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
     }
diff --git a/src/bindings/scripts/base/follower_ai.h b/src/bindings/scripts/base/follower_ai.h
index 2a7ab778629..289efd4a6b0 100644
--- a/src/bindings/scripts/base/follower_ai.h
+++ b/src/bindings/scripts/base/follower_ai.h
@@ -1,9 +1,12 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef SC_FOLLOWERAI_H
 #define SC_FOLLOWERAI_H
+
 #include "../system/system.h"
+
 enum eFollowState
 {
     STATE_FOLLOW_NONE       = 0x000,
@@ -14,33 +17,51 @@ enum eFollowState
     STATE_FOLLOW_PREEVENT   = 0x010,                        //not implemented (allow pre event to run, before follow is initiated)
     STATE_FOLLOW_POSTEVENT  = 0x020                         //can be set at complete and allow post event to run
 };
+
 class TRINITY_DLL_DECL FollowerAI : public ScriptedAI
 {
     public:
         explicit FollowerAI(Creature* pCreature);
         ~FollowerAI() {}
+
         //virtual void WaypointReached(uint32 uiPointId) = 0;
+
         void MovementInform(uint32 uiMotionType, uint32 uiPointId);
+
         void AttackStart(Unit*);
+
         void MoveInLineOfSight(Unit*);
+
         void EnterEvadeMode();
+
         void JustDied(Unit*);
+
         void JustRespawned();
+
         void UpdateAI(const uint32);                        //the "internal" update, calls UpdateFollowerAI()
         virtual void UpdateFollowerAI(const uint32);        //used when it's needed to add code in update (abilities, scripted events, etc)
+
         void StartFollow(Player* pPlayer, uint32 uiFactionForFollower = 0, const Quest* pQuest = NULL);
+
         void SetFollowPaused(bool bPaused);                 //if special event require follow mode to hold/resume during the follow
         void SetFollowComplete(bool bWithEndEvent = false);
+
         bool HasFollowState(uint32 uiFollowState) { return (m_uiFollowState & uiFollowState); }
+
     protected:
         Player* GetLeaderForFollower();
+
     private:
         void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; }
         void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; }
+
         bool AssistPlayerInCombat(Unit* pWho);
+
         uint64 m_uiLeaderGUID;
         uint32 m_uiUpdateFollowTimer;
         uint32 m_uiFollowState;
+
         const Quest* m_pQuestForFollow;                     //normally we have a quest
 };
+
 #endif
diff --git a/src/bindings/scripts/base/guard_ai.cpp b/src/bindings/scripts/base/guard_ai.cpp
index badd763a78b..1001d3a1170 100644
--- a/src/bindings/scripts/base/guard_ai.cpp
+++ b/src/bindings/scripts/base/guard_ai.cpp
@@ -13,67 +13,84 @@
  * along 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
+
 #define SAY_GUARD_SIL_AGGRO1        -1070001
 #define SAY_GUARD_SIL_AGGRO2        -1070002
 #define SAY_GUARD_SIL_AGGRO3        -1070003
+
 guardAI::guardAI(Creature* pCreature) : ScriptedAI(pCreature),
     GlobalCooldown(0),
     BuffTimer(0)
 {}
+
 void guardAI::Reset()
 {
     GlobalCooldown = 0;
     BuffTimer = 0;                                          //Rebuff as soon as we can
 }
+
 void guardAI::EnterCombat(Unit *who)
 {
     if (m_creature->GetEntry() == 15184)
         DoScriptText(RAND(SAY_GUARD_SIL_AGGRO1,SAY_GUARD_SIL_AGGRO2,SAY_GUARD_SIL_AGGRO3), m_creature, who);
+
     if (SpellEntry const *spell = m_creature->reachWithSpellAttack(who))
         DoCastSpell(who, spell);
 }
+
 void guardAI::JustDied(Unit *Killer)
 {
     //Send Zone Under Attack message to the LocalDefense and WorldDefense Channels
     if (Player* pKiller = Killer->GetCharmerOrOwnerPlayerOrPlayerItself())
         m_creature->SendZoneUnderAttackMessage(pKiller);
 }
+
 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() && !m_creature->isInCombat())
         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 (!UpdateVictim())
         return;
+
     // Make sure our attack is ready and we arn't currently casting
     if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
     {
@@ -82,22 +99,27 @@ void guardAI::UpdateAI(const uint32 diff)
         {
             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();
         }
     }
@@ -108,12 +130,15 @@ void guardAI::UpdateAI(const uint32 diff)
         {
             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, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE);
+
             //Found a spell, check if we arn't on cooldown
             if (info && !GlobalCooldown)
             {
@@ -123,11 +148,14 @@ void guardAI::UpdateAI(const uint32 diff)
                     (*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)
             {
@@ -139,6 +167,7 @@ void guardAI::UpdateAI(const uint32 diff)
         }
     }
 }
+
 void guardAI::DoReplyToTextEmote(uint32 em)
 {
     switch(em)
@@ -151,11 +180,13 @@ void guardAI::DoReplyToTextEmote(uint32 em)
         case TEXTEMOTE_CHICKEN: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_POINT);  break;
     }
 }
+
 void guardAI_orgrimmar::ReceiveEmote(Player* pPlayer, uint32 text_emote)
 {
     if (pPlayer->GetTeam()==HORDE)
         DoReplyToTextEmote(text_emote);
 }
+
 void guardAI_stormwind::ReceiveEmote(Player* pPlayer, uint32 text_emote)
 {
     if (pPlayer->GetTeam() == ALLIANCE)
diff --git a/src/bindings/scripts/base/guard_ai.h b/src/bindings/scripts/base/guard_ai.h
index dd4e414d1ae..a7fff32e3ab 100644
--- a/src/bindings/scripts/base/guard_ai.h
+++ b/src/bindings/scripts/base/guard_ai.h
@@ -1,31 +1,44 @@
 /* Copyright (C) 2006 - 2009 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 TRINITY_DLL_DECL guardAI : public ScriptedAI
 {
     public:
         explicit guardAI(Creature* pCreature);
         ~guardAI() {}
+
     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 EnterCombat(Unit *who);
+
     void JustDied(Unit *Killer);
+
     void UpdateAI(const uint32 diff);
+
     //common used for guards in main cities
     void DoReplyToTextEmote(uint32 em);
 };
+
 struct TRINITY_DLL_DECL guardAI_orgrimmar : public guardAI
 {
     guardAI_orgrimmar(Creature *c) : guardAI(c) {}
+
     void ReceiveEmote(Player *player, uint32 text_emote);
 };
+
 struct TRINITY_DLL_DECL guardAI_stormwind : public guardAI
 {
     guardAI_stormwind(Creature *c) : guardAI(c) {}
+
     void ReceiveEmote(Player *player, uint32 text_emote);
 };
 #endif
diff --git a/src/bindings/scripts/base/simple_ai.cpp b/src/bindings/scripts/base/simple_ai.cpp
index c607885f4d3..60511d163b7 100644
--- a/src/bindings/scripts/base/simple_ai.cpp
+++ b/src/bindings/scripts/base/simple_ai.cpp
@@ -13,14 +13,17 @@
 * along 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
@@ -30,6 +33,7 @@ SimpleAI::SimpleAI(Creature *c) : ScriptedAI(c)
     Aggro_Sound[0] = 0;
     Aggro_Sound[1] = 0;
     Aggro_Sound[2] = 0;
+
     Death_TextId[0] = 0;
     Death_TextId[1] = 0;
     Death_TextId[2] = 0;
@@ -38,6 +42,7 @@ SimpleAI::SimpleAI(Creature *c) : ScriptedAI(c)
     Death_Sound[2] = 0;
     Death_Spell = 0;
     Death_Target_Type = 0;
+
     Kill_TextId[0] = 0;
     Kill_TextId[1] = 0;
     Kill_TextId[2] = 0;
@@ -46,12 +51,16 @@ SimpleAI::SimpleAI(Creature *c) : ScriptedAI(c)
     Kill_Sound[2] = 0;
     Kill_Spell = 0;
     Kill_Target_Type = 0;
+
     memset(Spell,0,sizeof(Spell));
+
     EnterEvadeMode();
 }
+
 void SimpleAI::Reset()
 {
 }
+
 void SimpleAI::EnterCombat(Unit *who)
 {
             //Reset cast timers
@@ -85,26 +94,35 @@ void SimpleAI::EnterCombat(Unit *who)
             if (Spell[9].First_Cast >= 0)
                 Spell_Timer[9] = Spell[9].First_Cast;
             else Spell_Timer[9] = 1000;
+
             uint8 random_text = urand(0,2);
+
             //Random text
             if (Aggro_TextId[random_text])
                 DoScriptText(Aggro_TextId[random_text], m_creature, who);
+
             //Random sound
             if (Aggro_Sound[random_text])
                 DoPlaySoundToSet(m_creature, Aggro_Sound[random_text]);
 }
+
 void SimpleAI::KilledUnit(Unit *victim)
 {
     uint8 random_text = urand(0,2);
+
     //Random yell
     if (Kill_TextId[random_text])
         DoScriptText(Kill_TextId[random_text], m_creature, 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:
@@ -126,25 +144,33 @@ void SimpleAI::KilledUnit(Unit *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;
+
     uint8 random_text = urand(0,2);
+
     //Random yell
     if (Death_TextId[random_text])
         DoScriptText(Death_TextId[random_text], m_creature, 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:
@@ -166,30 +192,36 @@ void SimpleAI::DamageTaken(Unit *killer, uint32 &damage)
         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 (!UpdateVictim())
         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:
@@ -208,29 +240,39 @@ void SimpleAI::UpdateAI(const uint32 diff)
                     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
                     uint8 random_text = urand(0,2);
+
                     //Random yell
                     if (Spell[i].TextId[random_text])
                         DoScriptText(Spell[i].TextId[random_text], m_creature, 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/base/simple_ai.h b/src/bindings/scripts/base/simple_ai.h
index 308f5a475ec..3a2e8a9341a 100644
--- a/src/bindings/scripts/base/simple_ai.h
+++ b/src/bindings/scripts/base/simple_ai.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
@@ -11,29 +13,41 @@ enum CastTarget
     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 TRINITY_DLL_DECL SimpleAI : public ScriptedAI
 {
     SimpleAI(Creature *c);// : ScriptedAI(c);
+
     void Reset();
+
     void EnterCombat(Unit *who);
+
     void KilledUnit(Unit *victim);
+
     void DamageTaken(Unit *killer, uint32 &damage);
+
     void UpdateAI(const uint32 diff);
+
 public:
+
     int32 Aggro_TextId[3];
     uint32 Aggro_Sound[3];
+
     int32 Death_TextId[3];
     uint32 Death_Sound[3];
     uint32 Death_Spell;
     uint32 Death_Target_Type;
+
     int32 Kill_TextId[3];
     uint32 Kill_Sound[3];
     uint32 Kill_Spell;
     uint32 Kill_Target_Type;
+
     struct SimpleAI_Spell
     {
         uint32 Spell_Id;                //Spell ID to cast
@@ -43,12 +57,15 @@ public:
         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?
         int32 TextId[3];
         uint32 Text_Sound[3];
     }Spell[10];
+
 protected:
     uint32 Spell_Timer[10];
 };
+
 #endif
 
diff --git a/src/bindings/scripts/include/precompiled.cpp b/src/bindings/scripts/include/precompiled.cpp
index 49f792c8fd8..75bfae9e1c4 100644
--- a/src/bindings/scripts/include/precompiled.cpp
+++ b/src/bindings/scripts/include/precompiled.cpp
@@ -1,5 +1,6 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
 * This program is free software licensed under GPL version 2
 * Please see the included DOCS/LICENSE.TXT for more information */
+
 #include "precompiled.h"
 
diff --git a/src/bindings/scripts/include/precompiled.h b/src/bindings/scripts/include/precompiled.h
index e5fc9a3eeb9..3f5bc7e7265 100644
--- a/src/bindings/scripts/include/precompiled.h
+++ b/src/bindings/scripts/include/precompiled.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
 * This program is free software licensed under GPL version 2
 * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef SC_PRECOMPILED_H
 #define SC_PRECOMPILED_H
+
 #include "../ScriptMgr.h"
 #include "Cell.h"
 #include "CellImpl.h"
@@ -18,6 +20,7 @@
 #include "Chat.h"
 #include "DBCStructure.h"
 #include "DBCStores.h"
+
 #ifdef WIN32
 #include 
 BOOL APIENTRY DllMain( HANDLE hModule,
@@ -28,5 +31,6 @@ LPVOID lpReserved
     return true;
 }
 #endif
+
 #endif
 
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp
index 7df3b66d8d7..21c8842fb44 100644
--- a/src/bindings/scripts/include/sc_creature.cpp
+++ b/src/bindings/scripts/include/sc_creature.cpp
@@ -4,20 +4,23 @@
  *
  * 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 "ObjectMgr.h"
 #include "TemporarySummon.h"
+
 // Spell summary for ScriptedAI::SelectSpell
 struct TSpellSummary
 {
     uint8 Targets;                                          // set of enum SelectTarget
     uint8 Effects;                                          // set of enum SelectEffect
 } *SpellSummary;
+
 void SummonList::DoZoneInCombat(uint32 entry)
 {
-    for (iterator i = begin(); i != end(); )
+    for(iterator i = begin(); i != end();)
     {
         Creature *summon = Unit::GetCreature(*m_creature, *i);
         ++i;
@@ -26,9 +29,10 @@ void SummonList::DoZoneInCombat(uint32 entry)
             summon->AI()->DoZoneInCombat();
     }
 }
+
 void SummonList::DoAction(uint32 entry, uint32 info)
 {
-    for (iterator i = begin(); i != end(); )
+    for(iterator i = begin(); i != end();)
     {
         Creature *summon = Unit::GetCreature(*m_creature, *i);
         ++i;
@@ -37,9 +41,10 @@ void SummonList::DoAction(uint32 entry, uint32 info)
             summon->AI()->DoAction(info);
     }
 }
+
 void SummonList::DespawnEntry(uint32 entry)
 {
-    for (iterator i = begin(); i != end(); )
+    for(iterator i = begin(); i != end();)
     {
         Creature *summon = Unit::GetCreature(*m_creature, *i);
         if(!summon)
@@ -54,6 +59,7 @@ void SummonList::DespawnEntry(uint32 entry)
             ++i;
     }
 }
+
 void SummonList::DespawnAll()
 {
     while(!empty())
@@ -74,6 +80,7 @@ void SummonList::DespawnAll()
         }
     }
 }
+
 ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature),
     m_creature(pCreature),
     IsFleeing(false),
@@ -82,18 +89,22 @@ ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature),
 {
     HeroicMode = m_creature->GetMap()->IsHeroic();
 }
+
 void ScriptedAI::AttackStartNoMove(Unit* pWho)
 {
     if (!pWho)
         return;
+
     if(m_creature->Attack(pWho, false))
         DoStartNoMovement(pWho);
 }
+
 void ScriptedAI::UpdateAI(const uint32 uiDiff)
 {
     //Check if we have a current target
     if (!UpdateVictim())
         return;
+
     if (m_creature->isAttackReady())
     {
         //If we are within range melee the target
@@ -104,180 +115,232 @@ void ScriptedAI::UpdateAI(const uint32 uiDiff)
         }
     }
 }
+
 void ScriptedAI::DoStartMovement(Unit* pVictim, float fDistance, float fAngle)
 {
     if (pVictim)
         m_creature->GetMotionMaster()->MoveChase(pVictim, fDistance, fAngle);
 }
+
 void ScriptedAI::DoStartNoMovement(Unit* pVictim)
 {
     if (!pVictim)
         return;
+
     m_creature->GetMotionMaster()->MoveIdle();
 }
+
 void ScriptedAI::DoStopAttack()
 {
     if (m_creature->getVictim())
         m_creature->AttackStop();
 }
+
 void ScriptedAI::DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered)
 {
     if (!pTarget || m_creature->IsNonMeleeSpellCasted(false))
         return;
+
     m_creature->StopMoving();
     m_creature->CastSpell(pTarget, pSpellInfo, bTriggered);
 }
+
 void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId)
 {
     if (!pSource)
         return;
+
     if (!GetSoundEntriesStore()->LookupEntry(uiSoundId))
     {
         error_log("TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", uiSoundId, pSource->GetTypeId(), pSource->GetGUIDLow());
         return;
     }
+
     pSource->PlayDirectSound(uiSoundId);
 }
+
 Creature* ScriptedAI::DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime)
 {
     return m_creature->SummonCreature(uiId, m_creature->GetPositionX()+fX, m_creature->GetPositionY()+fY, m_creature->GetPositionZ()+fZ, fAngle, (TempSummonType)uiType, uiDespawntime);
 }
+
 Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 uiPosition)
 {
     //ThreatList m_threatlist;
     std::list& threatlist = m_creature->getThreatManager().getThreatList();
     std::list::iterator itr = threatlist.begin();
     std::list::reverse_iterator ritr = threatlist.rbegin();
+
     if (uiPosition >= threatlist.size() || !threatlist.size())
         return NULL;
+
     switch (target)
     {
     case SELECT_TARGET_RANDOM:
         advance (itr , uiPosition +  (rand() % (threatlist.size() - uiPosition ) ));
         return Unit::GetUnit((*m_creature),(*itr)->getUnitGuid());
         break;
+
     case SELECT_TARGET_TOPAGGRO:
         advance (itr , uiPosition);
         return Unit::GetUnit((*m_creature),(*itr)->getUnitGuid());
         break;
+
     case SELECT_TARGET_BOTTOMAGGRO:
         advance (ritr , uiPosition);
         return Unit::GetUnit((*m_creature),(*ritr)->getUnitGuid());
         break;
     }
+
     return NULL;
 }
+
 SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 uiMechanic, SelectTargetType selectTargets, uint32 uiPowerCostMin, uint32 uiPowerCostMax, float fRangeMin, float fRangeMax, SelectEffect selectEffects)
 {
     //No target so we can't cast
     if (!pTarget)
         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* apSpell[CREATURE_MAX_SPELLS];
     memset(apSpell, 0, sizeof(SpellEntry*)*CREATURE_MAX_SPELLS);
+
     uint32 uiSpellCount = 0;
+
     SpellEntry const* pTempSpell;
     SpellRangeEntry const* pTempRange;
+
     //Check if each spell is viable(set it to null if not)
     for (uint32 i = 0; i < CREATURE_MAX_SPELLS; i++)
     {
         pTempSpell = GetSpellStore()->LookupEntry(m_creature->m_spells[i]);
+
         //This spell doesn't exist
         if (!pTempSpell)
             continue;
+
         // Targets and Effects checked first as most used restrictions
         //Check the spell targets if specified
         if (selectTargets && !(SpellSummary[m_creature->m_spells[i]].Targets & (1 << (selectTargets-1))))
             continue;
+
         //Check the type of spell if we are looking for a specific spell type
         if (selectEffects && !(SpellSummary[m_creature->m_spells[i]].Effects & (1 << (selectEffects-1))))
             continue;
+
         //Check for school if specified
         if (uiSchool >= 0 && pTempSpell->SchoolMask & uiSchool)
             continue;
+
         //Check for spell mechanic if specified
         if (uiMechanic >= 0 && pTempSpell->Mechanic != uiMechanic)
             continue;
+
         //Make sure that the spell uses the requested amount of power
         if (uiPowerCostMin && pTempSpell->manaCost < uiPowerCostMin)
             continue;
+
         if (uiPowerCostMax && pTempSpell->manaCost > uiPowerCostMax)
             continue;
+
         //Continue if we don't have the mana to actually cast this spell
         if (pTempSpell->manaCost > m_creature->GetPower((Powers)pTempSpell->powerType))
             continue;
+
         //Get the Range
         pTempRange = GetSpellRangeStore()->LookupEntry(pTempSpell->rangeIndex);
+
         //Spell has invalid range store so we can't use it
         if (!pTempRange)
             continue;
+
         //Check if the spell meets our range requirements
         if (fRangeMin && m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange) < fRangeMin)
             continue;
         if (fRangeMax && m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange) > fRangeMax)
             continue;
+
         //Check if our target is in range
          if (m_creature->IsWithinDistInMap(pTarget, m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange)) || !m_creature->IsWithinDistInMap(pTarget, m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange)))
             continue;
+
         //All good so lets add it to the spell list
         apSpell[uiSpellCount] = pTempSpell;
         ++uiSpellCount;
     }
+
     //We got our usable spells so now lets randomly pick one
     if (!uiSpellCount)
         return NULL;
+
     return apSpell[rand()%uiSpellCount];
 }
+
 bool ScriptedAI::CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered)
 {
     //No target so we can't cast
     if (!pTarget || !pSpell)
         return false;
+
     //Silenced so we can't cast
     if (!bTriggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
         return false;
+
     //Check for power
     if (!bTriggered && me->GetPower((Powers)pSpell->powerType) < pSpell->manaCost)
         return false;
+
     SpellRangeEntry const* pTempRange = GetSpellRangeStore()->LookupEntry(pSpell->rangeIndex);
+
     //Spell has invalid range store so we can't use it
     if (!pTempRange)
         return false;
+
     //Unit is out of range of this spell
     if (me->IsInRange(pTarget, m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange), m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange)))
         return false;
+
     return true;
 }
+
 void FillSpellSummary()
 {
     SpellSummary = new TSpellSummary[GetSpellStore()->GetNumRows()];
+
     SpellEntry const* pTempSpell;
-    for (uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i)
+
+    for(uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i)
     {
         SpellSummary[i].Effects = 0;
         SpellSummary[i].Targets = 0;
+
         pTempSpell = GetSpellStore()->LookupEntry(i);
         //This spell doesn't exist
         if (!pTempSpell)
             continue;
-        for (uint32 j = 0; j < 3; ++j)
+
+        for(uint32 j = 0; j < 3; ++j)
         {
             //Spell targets self
             if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER )
                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1);
+
             //Spell targets a single enemy
             if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_DST_TARGET_ENEMY )
                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1);
+
             //Spell targets AoE at enemy
             if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_SRC ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_DST ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_DEST_DYNOBJ_ENEMY )
                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1);
+
             //Spell targets an enemy
             if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_DST_TARGET_ENEMY ||
@@ -286,16 +349,19 @@ void FillSpellSummary()
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_DEST_DYNOBJ_ENEMY )
                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1);
+
             //Spell targets a single friend(or self)
             if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ALLY ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_PARTY )
                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1);
+
             //Spell targets aoe friends
             if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_CASTER ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_TARGET ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER)
                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1);
+
             //Spell targets any friend(or self)
             if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ALLY ||
@@ -304,24 +370,28 @@ void FillSpellSummary()
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_TARGET ||
                 pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER)
                 SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1);
+
             //Make sure that this spell includes a damage effect
             if (pTempSpell->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE ||
                 pTempSpell->Effect[j] == SPELL_EFFECT_INSTAKILL ||
                 pTempSpell->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
                 pTempSpell->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 (pTempSpell->Effect[j] == SPELL_EFFECT_HEAL ||
                 pTempSpell->Effect[j] == SPELL_EFFECT_HEAL_MAX_HEALTH ||
                 pTempSpell->Effect[j] == SPELL_EFFECT_HEAL_MECHANICAL ||
                 (pTempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA  && pTempSpell->EffectApplyAuraName[j]== 8 ))
                 SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1);
+
             //Make sure that this spell applies an aura
             if (pTempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA )
                 SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1);
         }
     }
 }
+
 void ScriptedAI::DoResetThreat()
 {
     if (!m_creature->CanHaveThreatList() || m_creature->getThreatManager().isThreatListEmpty())
@@ -329,33 +399,41 @@ void ScriptedAI::DoResetThreat()
         error_log("TSCR: 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& threatlist = m_creature->getThreatManager().getThreatList();
-    for (std::list::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
+
+    for(std::list::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
     {
         Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
+
         if(pUnit && DoGetThreat(pUnit))
             DoModifyThreatPercent(pUnit, -100);
     }
 }
+
 float ScriptedAI::DoGetThreat(Unit* pUnit)
 {
     if(!pUnit) return 0.0f;
     return m_creature->getThreatManager().getThreat(pUnit);
 }
+
 void ScriptedAI::DoModifyThreatPercent(Unit* pUnit, int32 pct)
 {
     if(!pUnit) return;
     m_creature->getThreatManager().modifyThreatPercent(pUnit, pct);
 }
+
 void ScriptedAI::DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime)
 {
     m_creature->Relocate(fX, fY, fZ);
     m_creature->SendMonsterMove(fX, fY, fZ, uiTime);
 }
+
 void ScriptedAI::DoTeleportTo(const float fPos[4])
 {
     me->NearTeleportTo(fPos[0], fPos[1], fPos[2], fPos[3]);
 }
+
 void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO)
 {
     if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER)
@@ -364,27 +442,33 @@ void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, flo
             error_log("TSCR: 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(), fX, fY, fZ, fO);
         return;
     }
+
     CAST_PLR(pUnit)->TeleportTo(pUnit->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT);
 }
+
 void ScriptedAI::DoTeleportAll(float fX, float fY, float fZ, float fO)
 {
     Map *map = m_creature->GetMap();
     if (!map->IsDungeon())
         return;
+
     Map::PlayerList const &PlayerList = map->GetPlayers();
-    for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
         if (Player* i_pl = i->getSource())
             if (i_pl->isAlive())
                 i_pl->TeleportTo(m_creature->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT);
 }
+
 Unit* ScriptedAI::DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff)
 {
     Unit* pUnit = NULL;
     Trinity::MostHPMissingInRange u_check(m_creature, fRange, uiMinHPDiff);
     Trinity::UnitLastSearcher searcher(m_creature, pUnit, u_check);
     m_creature->VisitNearbyObject(fRange, searcher);
+
     return pUnit;
 }
+
 std::list ScriptedAI::DoFindFriendlyCC(float fRange)
 {
     std::list pList;
@@ -393,6 +477,7 @@ std::list ScriptedAI::DoFindFriendlyCC(float fRange)
     m_creature->VisitNearbyObject(fRange, searcher);
     return pList;
 }
+
 std::list ScriptedAI::DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellid)
 {
     std::list pList;
@@ -401,39 +486,51 @@ std::list ScriptedAI::DoFindFriendlyMissingBuff(float fRange, uint32
     m_creature->VisitNearbyObject(fRange, searcher);
     return pList;
 }
+
 Player* ScriptedAI::GetPlayerAtMinimumRange(float fMinimumRange)
 {
     Player* pPlayer = NULL;
+
     CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
     Cell cell(pair);
     cell.data.Part.reserved = ALL_DISTRICT;
     cell.SetNoCreate();
+
     Trinity::PlayerAtMinimumRangeAway check(m_creature, fMinimumRange);
     Trinity::PlayerSearcher searcher(m_creature, pPlayer, check);
     TypeContainerVisitor, GridTypeMapContainer> visitor(searcher);
+
     CellLock cell_lock(cell, pair);
     cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap()));
+
     return pPlayer;
 }
+
 void ScriptedAI::SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand, int32 uiOffHand, int32 uiRanged)
 {
     if (bLoadDefault)
     {
         if (CreatureInfo const* pInfo = GetCreatureTemplateStore(m_creature->GetEntry()))
             m_creature->LoadEquipment(pInfo->equipmentId,true);
+
         return;
     }
+
     if (uiMainHand >= 0)
         m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(uiMainHand));
+
     if (uiOffHand >= 0)
         m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, uint32(uiOffHand));
+
     if (uiRanged >= 0)
         m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, uint32(uiRanged));
 }
+
 void ScriptedAI::SetCombatMovement(bool bCombatMove)
 {
     m_bCombatMovement = bCombatMove;
 }
+
 enum eNPCs
 {
     NPC_BROODLORD   = 12017,
@@ -441,6 +538,7 @@ enum eNPCs
     NPC_JAN_ALAI    = 23578,
     NPC_SARTHARION  = 28860
 };
+
 // Hacklike storage used for misc creatures that are expected to evade of outside of a certain area.
 // It is assumed the information is found elswehere and can be handled by mangos. So far no luck finding such information/way to extract it.
 bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
@@ -452,11 +550,14 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
         m_uiEvadeCheckCooldown -= uiDiff;
         return false;
     }
+
     if (m_creature->IsInEvadeMode() || !m_creature->getVictim())
         return false;
+
     float fX = m_creature->GetPositionX();
     float fY = m_creature->GetPositionY();
     float fZ = m_creature->GetPositionZ();
+
     switch(m_creature->GetEntry())
     {
         case NPC_BROODLORD:                                         // broodlord (not move down stairs)
@@ -479,32 +580,39 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
             error_log("TSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition.", m_creature->GetEntry());
             return false;
     }
+
     EnterEvadeMode();
     return true;
 }
+
 void Scripted_NoMovementAI::AttackStart(Unit* pWho)
 {
     if (!pWho)
         return;
+
     if (m_creature->Attack(pWho, true))
     {
         DoStartNoMovement(pWho);
     }
 }
+
 BossAI::BossAI(Creature *c, uint32 id) : ScriptedAI(c)
 , bossId(id), summons(me), instance(c->GetInstanceData())
 , boundary(instance ? instance->GetBossBoundary(id) : NULL)
 {
 }
+
 void BossAI::_Reset()
 {
     if(!me->isAlive())
         return;
+
     events.Reset();
     summons.DespawnAll();
     if(instance)
         instance->SetBossState(bossId, NOT_STARTED);
 }
+
 void BossAI::_JustDied()
 {
     events.Reset();
@@ -512,6 +620,7 @@ void BossAI::_JustDied()
     if(instance)
         instance->SetBossState(bossId, DONE);
 }
+
 void BossAI::_EnterCombat()
 {
     me->setActive(true);
@@ -519,20 +628,23 @@ void BossAI::_EnterCombat()
     if(instance)
         instance->SetBossState(bossId, IN_PROGRESS);
 }
+
 void BossAI::TeleportCheaters()
 {
     float x, y, z;
     me->GetPosition(x, y, z);
     std::list &m_threatlist = me->getThreatManager().getThreatList();
-    for (std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr)
+    for(std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr)
         if((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && !CheckBoundary((*itr)->getTarget()))
             (*itr)->getTarget()->NearTeleportTo(x, y, z, 0);
 }
+
 bool BossAI::CheckBoundary(Unit *who)
 {
     if(!boundary || !who)
         return true;
-    for (BossBoundaryMap::const_iterator itr = boundary->begin(); itr != boundary->end(); ++itr)
+
+    for(BossBoundaryMap::const_iterator itr = boundary->begin(); itr != boundary->end(); ++itr)
     {
         switch(itr->first)
         {
@@ -570,39 +682,48 @@ bool BossAI::CheckBoundary(Unit *who)
                 break;
         }
     }
+
     return true;
 }
+
 void BossAI::JustSummoned(Creature *summon)
 {
     summons.Summon(summon);
     if(me->isInCombat())
         DoZoneInCombat(summon);
 }
+
 void BossAI::SummonedCreatureDespawn(Creature *summon)
 {
     summons.Despawn(summon);
 }
+
 #define GOBJECT(x) (const_cast(GetGameObjectInfo(x)))
+
 void LoadOverridenSQLData()
 {
     GameObjectInfo *goInfo;
+
     // Sunwell Plateau : Kalecgos : Spectral Rift
     if(goInfo = GOBJECT(187055))
         if(goInfo->type == GAMEOBJECT_TYPE_GOOBER)
             goInfo->goober.lockId = 57; // need LOCKTYPE_QUICK_OPEN
+
     // Naxxramas : Sapphiron Birth
     if(goInfo = GOBJECT(181356))
         if(goInfo->type == GAMEOBJECT_TYPE_TRAP)
             goInfo->trap.radius = 50;
 }
+
 void LoadOverridenDBCData()
 {
     SpellEntry *spellInfo;
-    for (uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i)
+    for(uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i)
     {
         spellInfo = GET_SPELL(i);
         if(!spellInfo)
             continue;
+
         switch(i)
         {
             // Black Temple : Illidan : Parasitic Shadowfiend Passive
@@ -628,17 +749,23 @@ void LoadOverridenDBCData()
     }
 }
 
+
 Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 Entry, float MaxSearchRange)
 {
     Creature* pCreature = NULL;
+
     CellPair pair(Trinity::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
     Cell cell(pair);
     cell.data.Part.reserved = ALL_DISTRICT;
     cell.SetNoCreate();
+
     Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*pSource, Entry, true, MaxSearchRange);
     Trinity::CreatureLastSearcher searcher(pSource, pCreature, creature_check);
+
     TypeContainerVisitor, GridTypeMapContainer> creature_searcher(searcher);
+
     CellLock cell_lock(cell, pair);
     cell_lock->Visit(cell_lock, creature_searcher,*(pSource->GetMap()));
+
     return pCreature;
 }
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index a5b4953bb28..91073bf4032 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -4,21 +4,28 @@
  *
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef SC_CREATURE_H
 #define SC_CREATURE_H
+
 #include "Creature.h"
 #include "CreatureAI.h"
 #include "CreatureAIImpl.h"
 #include "InstanceData.h"
+
 #define SCRIPT_CAST_TYPE dynamic_cast
 //#define SCRIPT_CAST_TYPE static_cast
+
 #define CAST_PLR(a)     (SCRIPT_CAST_TYPE(a))
 #define CAST_CRE(a)     (SCRIPT_CAST_TYPE(a))
 #define CAST_SUM(a)     (SCRIPT_CAST_TYPE(a))
 #define CAST_PET(a)     (SCRIPT_CAST_TYPE(a))
 #define CAST_AI(a,b)    (SCRIPT_CAST_TYPE(b))
+
 #define GET_SPELL(a)    (const_cast(GetSpellStore()->LookupEntry(a)))
+
 class ScriptedInstance;
+
 class SummonList : public std::list
 {
     public:
@@ -32,125 +39,178 @@ class SummonList : public std::list
     private:
         Creature *m_creature;
 };
+
 struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
 {
     explicit ScriptedAI(Creature* pCreature);
     ~ScriptedAI() {}
+
     //*************
     //CreatureAI Functions
     //*************
+
     void AttackStartNoMove(Unit *target);
+
     // Called at any Damage from any attacker (before damage apply)
     void DamageTaken(Unit* pDone_by, uint32& uiDamage) {}
+
     //Called at World update tick
     void UpdateAI(const uint32);
+
     //Called at creature death
     void JustDied(Unit* who){}
+
     //Called at creature killing another unit
     void KilledUnit(Unit* who){}
+
     // Called when the creature summon successfully other creature
     void JustSummoned(Creature* ) {}
+
     // Called when a summoned creature is despawned
     void SummonedCreatureDespawn(Creature*) {}
+
     // Called when hit by a spell
     void SpellHit(Unit* caster, const SpellEntry *spell) {}
+
     // Called when spell hits a target
     void SpellHitTarget(Unit* target, const SpellEntry *spell) {}
+
     //Called at waypoint reached or PointMovement end
     void MovementInform(uint32 type, uint32 id){}
+
     // Called when AI is temporarily replaced or put back when possess is applied or removed
     void OnPossess(bool apply) {}
+
     //*************
     // Variables
     //*************
+
     //Pointer to creature we are manipulating
     Creature* m_creature;
+
     //For fleeing
     bool IsFleeing;
+
     bool HeroicMode;
+
     //*************
     //Pure virtual functions
     //*************
+
     //Called at creature reset either by death or evade
     void Reset() {}
+
     //Called at creature aggro either by MoveInLOS or Attack Start
     void EnterCombat(Unit* who) {}
+
     //*************
     //AI Helper Functions
     //*************
+
     //Start movement toward victim
     void DoStartMovement(Unit* pVictim, float fDistance = 0, float fAngle = 0);
+
     //Start no movement on victim
     void DoStartNoMovement(Unit* pVictim);
+
     //Stop attack of current victim
     void DoStopAttack();
+
     //Cast spell by spell info
     void DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered = false);
+
     //Plays a sound to all nearby players
     void DoPlaySoundToSet(WorldObject* pSource, uint32 sound);
+
     //Drops all threat to 0%. Does not remove players from the threat list
     void DoResetThreat();
+
     float DoGetThreat(Unit* u);
     void DoModifyThreatPercent(Unit* pUnit, int32 pct);
+
     void DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime = 0);
     void DoTeleportTo(const float pos[4]);
+
     void DoAction(const int32 param) {}
+
     //Teleports a player without dropping threat (only teleports to same map)
     void DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO);
     void DoTeleportAll(float fX, float fY, float fZ, float fO);
+
     //Returns friendly unit with the most amount of hp missing from max hp
     Unit* DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff = 1);
+
     //Returns a list of friendly CC'd units within range
     std::list DoFindFriendlyCC(float fRange);
+
     //Returns a list of all friendly units missing a specific buff within range
     std::list DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellId);
+
     //Return a player with at least minimumRange from m_creature
     Player* GetPlayerAtMinimumRange(float fMinimumRange);
+
     //Spawns a creature relative to m_creature
     Creature* DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime);
+
     //Selects a unit from the creature's current aggro list
     Unit* SelectUnit(SelectAggroTarget target, uint32 uiPosition);
+
     bool HealthBelowPct(uint32 pct) const { return me->GetHealth() * 100 < m_creature->GetMaxHealth() * pct; }
+
     //Returns spells that meet the specified criteria from the creatures spell list
     SpellEntry const* SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTargetType Targets,  uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effect);
+
     //Checks if you can cast the specified spell
     bool CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered = false);
+
     void SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand = EQUIP_NO_CHANGE, int32 uiOffHand = EQUIP_NO_CHANGE, int32 uiRanged = EQUIP_NO_CHANGE);
+
     //Generally used to control if MoveChase() is to be used or not in AttackStart(). Some creatures does not chase victims
     void SetCombatMovement(bool CombatMove);
     bool IsCombatMovement() { return m_bCombatMovement; }
+
     bool EnterEvadeIfOutOfCombatArea(const uint32 uiDiff);
+
     private:
         bool m_bCombatMovement;
         uint32 m_uiEvadeCheckCooldown;
 };
+
 struct TRINITY_DLL_DECL Scripted_NoMovementAI : public ScriptedAI
 {
     Scripted_NoMovementAI(Creature* creature) : ScriptedAI(creature) {}
 
+
     //Called at each attack of m_creature by any victim
     void AttackStart(Unit* who);
 };
+
 struct TRINITY_DLL_DECL BossAI : public ScriptedAI
 {
     BossAI(Creature *c, uint32 id);
+
     const uint32 bossId;
     EventMap events;
     SummonList summons;
     InstanceData * const instance;
     const BossBoundaryMap * const boundary;
+
     void JustSummoned(Creature *summon);
     void SummonedCreatureDespawn(Creature *summon);
+
     void UpdateAI(const uint32 diff) = 0;
+
     void Reset() { _Reset(); }
     void EnterCombat(Unit *who) { _EnterCombat(); }
     void JustDied(Unit *killer) { _JustDied(); }
     void JustReachedHome() { me->setActive(false); }
+
     protected:
         void _Reset();
         void _EnterCombat();
         void _JustDied();
         void _JustReachedHome() { me->setActive(false); }
+
         bool CheckInRoom()
         {
             if(CheckBoundary(me))
@@ -161,8 +221,11 @@ struct TRINITY_DLL_DECL BossAI : public ScriptedAI
         bool CheckBoundary(Unit *who);
         void TeleportCheaters();
 };
+
 // SD2's grid searchers
+
 //return closest creature alive in grid, with range from pSource
 Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 Entry, float MaxSearchRange);
+
 #endif
 
diff --git a/src/bindings/scripts/include/sc_gossip.h b/src/bindings/scripts/include/sc_gossip.h
index 1ade3edd3f5..5c8ded7d579 100644
--- a/src/bindings/scripts/include/sc_gossip.h
+++ b/src/bindings/scripts/include/sc_gossip.h
@@ -4,14 +4,18 @@
  *
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef SC_GOSSIP_H
 #define SC_GOSSIP_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_IRONFORGE_BANK      "The bank of Ironforge"
 #define GOSSIP_TEXT_STORMWIND_BANK      "The bank of Stormwind"
@@ -35,12 +39,14 @@
 #define GOSSIP_TEXT_CLASSTRAINER        "A class trainer"
 #define GOSSIP_TEXT_PROFTRAINER         "A profession trainer"
 #define GOSSIP_TEXT_LEXICON             "Lexicon of Power"
+
 #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_STRANDOFANCIENT     "Strand of the Ancients"
+
 #define GOSSIP_TEXT_DEATH_KNIGHT        "Death Knight"
 #define GOSSIP_TEXT_DRUID               "Druid"
 #define GOSSIP_TEXT_HUNTER              "Hunter"
@@ -51,6 +57,7 @@
 #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"
@@ -65,6 +72,7 @@
 #define GOSSIP_TEXT_MINING              "Mining"
 #define GOSSIP_TEXT_FISHING             "Fishing"
 #define GOSSIP_TEXT_SKINNING            "Skinning"
+
 enum eTradeskill
 {
 // Skill defines
@@ -83,6 +91,7 @@ enum eTradeskill
     TRADESKILL_SKINNING                 = 13,
     TRADESKILL_JEWLCRAFTING             = 14,
     TRADESKILL_INSCRIPTION              = 15,
+
     TRADESKILL_LEVEL_NONE               = 0,
     TRADESKILL_LEVEL_APPRENTICE         = 1,
     TRADESKILL_LEVEL_JOURNEYMAN         = 2,
@@ -90,6 +99,7 @@ enum eTradeskill
     TRADESKILL_LEVEL_ARTISAN            = 4,
     TRADESKILL_LEVEL_MASTER             = 5,
     TRADESKILL_LEVEL_GRAND_MASTER       = 6,
+
 // Gossip defines
     GOSSIP_ACTION_TRADE                 = 1,
     GOSSIP_ACTION_TRAIN                 = 2,
@@ -104,6 +114,7 @@ enum eTradeskill
     GOSSIP_ACTION_INN_INFO              = 11,
     GOSSIP_ACTION_UNLEARN               = 12,
     GOSSIP_ACTION_INFO_DEF              = 1000,
+
     GOSSIP_SENDER_MAIN                  = 1,
     GOSSIP_SENDER_INN_INFO              = 2,
     GOSSIP_SENDER_INFO                  = 3,
@@ -115,8 +126,11 @@ enum eTradeskill
     GOSSIP_SENDER_SEC_MAILBOX           = 9,
     GOSSIP_SENDER_SEC_STABLEMASTER      = 10
 };
+
 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
@@ -126,8 +140,10 @@ extern uint32 GetSkillLevel(Player *player,uint32 skill);
 // 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
@@ -136,19 +152,23 @@ extern uint32 GetSkillLevel(Player *player,uint32 skill);
 // 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)
@@ -156,12 +176,16 @@ extern uint32 GetSkillLevel(Player *player,uint32 skill);
 #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/include/sc_instance.h b/src/bindings/scripts/include/sc_instance.h
index 7849d97ad61..25593e05300 100644
--- a/src/bindings/scripts/include/sc_instance.h
+++ b/src/bindings/scripts/include/sc_instance.h
@@ -1,15 +1,20 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
 * This program is free software licensed under GPL version 2
 * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef SC_INSTANCE_H
 #define SC_INSTANCE_H
+
 #include "InstanceData.h"
 #include "Map.h"
+
 #define OUT_SAVE_INST_DATA             debug_log("TSCR: Saving Instance Data for Instance %s (Map %d, Instance Id %d)", instance->GetMapName(), instance->GetId(), instance->GetInstanceId())
 #define OUT_SAVE_INST_DATA_COMPLETE    debug_log("TSCR: Saving Instance Data for Instance %s (Map %d, Instance Id %d) completed.", instance->GetMapName(), instance->GetId(), instance->GetInstanceId())
 #define OUT_LOAD_INST_DATA(a)          debug_log("TSCR: Loading Instance Data for Instance %s (Map %d, Instance Id %d). Input is '%s'", instance->GetMapName(), instance->GetId(), instance->GetInstanceId(), a)
 #define OUT_LOAD_INST_DATA_COMPLETE    debug_log("TSCR: Instance Data Load for Instance %s (Map %d, Instance Id: %d) is complete.",instance->GetMapName(), instance->GetId(), instance->GetInstanceId())
 #define OUT_LOAD_INST_DATA_FAIL        error_log("TSCR: Unable to load Instance Data for Instance %s (Map %d, Instance Id: %d).",instance->GetMapName(), instance->GetId(), instance->GetInstanceId())
+
 #define ScriptedInstance InstanceData
+
 #endif
 
diff --git a/src/bindings/scripts/scripts/custom/npc_acherus_taxi.cpp b/src/bindings/scripts/scripts/custom/npc_acherus_taxi.cpp
index d69006277f3..b09f129788e 100644
--- a/src/bindings/scripts/scripts/custom/npc_acherus_taxi.cpp
+++ b/src/bindings/scripts/scripts/custom/npc_acherus_taxi.cpp
@@ -1,13 +1,17 @@
 #include "precompiled.h"
 #include "WorldPacket.h"
+
 #define GOSSIP_FLIGHT "I need a ride"
+
 bool GossipHello_npc_acherus_taxi(Player* pPlayer, Creature* pCreature)
 {
 pPlayer->SetTaxiCheater(true);
+
 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
         pPlayer->SEND_GOSSIP_MENU(9978, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_acherus_taxi(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -15,17 +19,18 @@ bool GossipSelect_npc_acherus_taxi(Player* pPlayer, Creature* pCreature, uint32
        if (pPlayer->GetPositionZ() >=316)
         {
         pPlayer->GetSession()->SendDoFlight(24446, 1053);
-        }
-        else
-        {
+        }else{
         pPlayer->GetSession()->SendDoFlight(24446, 1054);
         }
+
     }
     return true;
 }
+
 void AddSC_npc_acherus_taxi()
 {
     Script *newscript;
+
 newscript = new Script;
 newscript->Name = "npc_acherus_taxi";
 newscript->pGossipHello = &GossipHello_npc_acherus_taxi;
diff --git a/src/bindings/scripts/scripts/custom/npc_wyrmresttempel_taxi.cpp b/src/bindings/scripts/scripts/custom/npc_wyrmresttempel_taxi.cpp
index ea5ea5001f1..1f25d15205d 100644
--- a/src/bindings/scripts/scripts/custom/npc_wyrmresttempel_taxi.cpp
+++ b/src/bindings/scripts/scripts/custom/npc_wyrmresttempel_taxi.cpp
@@ -1,19 +1,24 @@
 #include "precompiled.h"
 #include "WorldPacket.h"
+
 #define GOSSIP_UP      "My Lord, I must go to the upper floor of the temple."
 #define GOSSIP_DOWN    "I would like to take a flight to the ground, Lord Afrasastrasz."
 #define GOSSIP_MIDDLE  "Can you spare a drake to travel to Lord Afrasastrasz, in the middle of the temple?"
 #define GOSSIP_TOP     "Please, Let me take one of these dragons to the top floor of the temple."
 #define GOSSIP_BOTTOM  "Yes, Please. I would like to return to the ground floor of the temple."
 #define GOSSIP_ONEDOWN "I would like to see Lord Afrasastrasz, in the middle of the temple."
+
 bool GossipHello_npc_wyrmresttempel_middle_taxi(Player* pPlayer, Creature* pCreature)
 {
 pPlayer->SetTaxiCheater(true);
+
 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UP, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DOWN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
         pPlayer->SEND_GOSSIP_MENU(12887, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_wyrmresttempel_middle_taxi(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -21,21 +26,28 @@ bool GossipSelect_npc_wyrmresttempel_middle_taxi(Player* pPlayer, Creature* pCre
         pPlayer->GetSession()->SendDoFlight(6376, 881);
     }
 
+
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 2)
     {
       pPlayer->GetSession()->SendDoFlight(6376, 882);
+
     }
 return true;
 }
+
 bool GossipHello_npc_wyrmresttempel_bottom_taxi(Player* pPlayer, Creature* pCreature)
 {
 pPlayer->SetTaxiCheater(true);
+
 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TOP, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_MIDDLE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
         pPlayer->SEND_GOSSIP_MENU(12713, pCreature->GetGUID());
+
     return true;
 }
 
+
+
 bool GossipSelect_npc_wyrmresttempel_bottom_taxi(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 4)
@@ -43,48 +55,62 @@ bool GossipSelect_npc_wyrmresttempel_bottom_taxi(Player* pPlayer, Creature* pCre
         pPlayer->GetSession()->SendDoFlight(6376, 878);
     }
 
+
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 3)
     {
       pPlayer->GetSession()->SendDoFlight(6376, 883);
+
     }
 return true;
 }
+
 bool GossipHello_npc_wyrmresttempel_top_taxi(Player* pPlayer, Creature* pCreature)
 {
 pPlayer->SetTaxiCheater(true);
+
 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BOTTOM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ONEDOWN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
         pPlayer->SEND_GOSSIP_MENU(12714, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_wyrmresttempel_top_taxi(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 5)
     {
         pPlayer->GetSession()->SendDoFlight(6376, 879);
     }
+
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 6)
+
     {
       pPlayer->GetSession()->SendDoFlight(6376, 880);
+
     }
 return true;
 }
+
 void AddSC_npc_wyrmresttempel_taxi()
 {
     Script *newscript;
+
 newscript = new Script;
 newscript->Name = "npc_wyrmresttempelmiddle_taxi";
 newscript->pGossipHello = &GossipHello_npc_wyrmresttempel_middle_taxi;
 newscript->pGossipSelect = &GossipSelect_npc_wyrmresttempel_middle_taxi;
 newscript->RegisterSelf();
+
 newscript = new Script;
 newscript->Name = "npc_wyrmresttempelbottom_taxi";
 newscript->pGossipHello = &GossipHello_npc_wyrmresttempel_bottom_taxi;
 newscript->pGossipSelect = &GossipSelect_npc_wyrmresttempel_bottom_taxi;
 newscript->RegisterSelf();
+
 newscript = new Script;
 newscript->Name = "npc_wyrmresttempeltop_taxi";
 newscript->pGossipHello = &GossipHello_npc_wyrmresttempel_top_taxi;
 newscript->pGossipSelect = &GossipSelect_npc_wyrmresttempel_top_taxi;
 newscript->RegisterSelf();
+
 }
diff --git a/src/bindings/scripts/scripts/custom/on_events.cpp b/src/bindings/scripts/scripts/custom/on_events.cpp
index 2580db7836f..e8d9a68e793 100644
--- a/src/bindings/scripts/scripts/custom/on_events.cpp
+++ b/src/bindings/scripts/scripts/custom/on_events.cpp
@@ -1,68 +1,89 @@
 #include "precompiled.h"
 #include 
+
 //This function is called when the player logs in (every login)
 void OnLogin(Player *pPlayer)
 {
+
 }
+
 //This function is called when the player logs out
 void OnLogout(Player *pPlayer)
 {
+
 }
+
 //This function is called when the player kills another player
 void OnPVPKill(Player *killer, Player *killed)
 {
+
 }
+
 //This function is called when a players AreaID changes
 void OnAreaChange(Player *pPlayer, AreaTableEntry const *pArea)
 {
+
 }
+
 //This is called when a player kills a creature (non pvp)
 void OnCreatureKill(Player *pPlayer, Creature *pCreature)
 {
+
 }
+
 //This function is called when a player has a money exchange
 int32 OnGetMoney(Player *pPlayer, int32 amount)
 {
     return amount;
 }
+
 //This function is called whenever a player gets XP
 uint32 OnGetXP(Player *pPlayer, uint32 amount)
 {
     return amount;
 }
+
 //This function is called when a player clicks a GO Object
 bool OnGoClick(Player *pPlayer, GameObject *pGameObject)
 {
     return true;
 }
+
 //This function is called when a player clicks and item
 bool OnItemClick(Player *pPlayer, Item *pItem)
 {
     return true;
 }
+
 //This function is called when a player opens an item (like a clam)
 bool OnItemOpen(Player *pPlayer, Item *pItem)
 {
     return true;
 }
+
 //This function is called when a player sends a chat message
 bool OnPlayerChat(Player *pPlayer, const char *text)
 {
     return true;
 }
+
 //this function is called when the server starts
 void OnServerStartup()
 {
+
 }
 //this function is called when the server shuts down
 void OnServerShutdown()
 {
+
 }
+
 //this function is called when a player casts a spell
 bool OnSpellCast(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, uint32 i, SpellEntry const *spell)
 {
     return true;
 }
+
  void AddSC_onevents()
 {
     Script *newscript;
@@ -82,5 +103,6 @@ bool OnSpellCast(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, ui
     newscript->pOnServerShutdown = &OnServerShutdown;
     newscript->pOnServerStartup = &OnServerStartup;
     newscript->pOnSpellCast = &OnSpellCast;
+
     newscript->RegisterSelf();
 }
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/alterac_mountains.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/alterac_mountains.cpp
index c3f93b426e1..8b4c360a886 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/alterac_mountains.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/alterac_mountains.cpp
@@ -13,15 +13,19 @@
  * along 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: 0
 SDComment: Placeholder
 SDCategory: Alterac Mountains
 EndScriptData */
+
 /* ContentData
 EndContentData */
+
 #include "precompiled.h"
+
 /*void AddSC_alterac_mountains()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/arathi_highlands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/arathi_highlands.cpp
index 7757d8da84d..60255570c59 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/arathi_highlands.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/arathi_highlands.cpp
@@ -13,20 +13,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Arathi Highlands
 SD%Complete: 100
 SDComment: Quest support: 665
 SDCategory: Arathi Highlands
 EndScriptData */
+
 /* ContentData
 npc_professor_phizzlethorpe
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_professor_phizzlethorpe
 ######*/
+
 enum eEnums
 {
     SAY_PROGRESS_1      = -1000235,
@@ -39,17 +44,22 @@ enum eEnums
     SAY_PROGRESS_7      = -1000242,
     EMOTE_PROGRESS_8    = -1000243,
     SAY_PROGRESS_9      = -1000244,
+
     QUEST_SUNKEN_TREASURE   = 665,
     MOB_VENGEFUL_SURGE      = 2776
 };
+
 struct TRINITY_DLL_DECL npc_professor_phizzlethorpeAI : public npc_escortAI
 {
     npc_professor_phizzlethorpeAI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 uiPointId)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(uiPointId)
         {
         case 4:DoScriptText(SAY_PROGRESS_2, m_creature, pPlayer);break;
@@ -75,19 +85,23 @@ struct TRINITY_DLL_DECL npc_professor_phizzlethorpeAI : public npc_escortAI
             break;
         }
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         pSummoned->AI()->AttackStart(m_creature);
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
     }
 };
+
 bool QuestAccept_npc_professor_phizzlethorpe(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_SUNKEN_TREASURE)
@@ -95,17 +109,21 @@ bool QuestAccept_npc_professor_phizzlethorpe(Player* pPlayer, Creature* pCreatur
         DoScriptText(SAY_PROGRESS_1, pCreature, pPlayer);
         if (npc_escortAI* pEscortAI = CAST_AI(npc_professor_phizzlethorpeAI, (pCreature->AI())))
             pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
+
         pCreature->setFaction(113);
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_professor_phizzlethorpeAI(Creature* pCreature)
 {
     return new npc_professor_phizzlethorpeAI(pCreature);
 }
+
 void AddSC_arathi_highlands()
 {
     Script * newscript;
+
     newscript = new Script;
     newscript->Name = "npc_professor_phizzlethorpe";
     newscript->GetAI = &GetAI_npc_professor_phizzlethorpeAI;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp
index 7d97bd80a22..a7bb66ac9cf 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp
@@ -1,5 +1,6 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
  * This program is free software; you can redistribute it and/or modify
+
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
@@ -13,12 +14,14 @@
  * along 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, 4322. Vendor Lokhtos Darkbargainer. Need to rewrite the Jail Break support
 SDCategory: Blackrock Depths
 EndScriptData */
+
 /* ContentData
 go_shadowforge_brazier
 at_ring_of_law
@@ -32,12 +35,15 @@ npc_marshal_reginald_windsor
 npc_tobias_seecher
 npc_rocknot
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "def_blackrock_depths.h"
+
 /*######
 +## go_shadowforge_brazier
 +######*/
+
 bool GOHello_go_shadowforge_brazier(Player* pPlayer, GameObject* pGo)
 {
     if (ScriptedInstance* pInstance = pGo->GetInstanceData())
@@ -49,16 +55,20 @@ bool GOHello_go_shadowforge_brazier(Player* pPlayer, GameObject* pGo)
     }
     return false;
 }
+
 /*######
 ## npc_grimstone
 ######*/
+
 enum eGrimstone
 {
     NPC_GRIMSTONE       = 10096,
     NPC_THELDREN        = 16059,
+
     //4 or 6 in total? 1+2+1 / 2+2+2 / 3+3. Depending on this, code should be changed.
     MAX_MOB_AMOUNT      = 4
 };
+
 uint32 RingMob[]=
 {
     8925,                                                   // Dredge Worm
@@ -68,6 +78,7 @@ uint32 RingMob[]=
     8933,                                                   // Cave Creeper
     8932,                                                   // Borer Beetle
 };
+
 uint32 RingBoss[]=
 {
     9027,                                                   // Gorosh
@@ -77,27 +88,33 @@ uint32 RingBoss[]=
     9031,                                                   // Anub'shiah
     9032,                                                   // Hedrum
 };
+
 bool AreaTrigger_at_ring_of_law(Player* pPlayer, AreaTriggerEntry *at)
 {
     if (ScriptedInstance* pInstance = pPlayer->GetInstanceData())
     {
         if (pInstance->GetData(TYPE_RING_OF_LAW) == IN_PROGRESS || pInstance->GetData(TYPE_RING_OF_LAW) == DONE)
             return false;
+
         pInstance->SetData(TYPE_RING_OF_LAW,IN_PROGRESS);
         pPlayer->SummonCreature(NPC_GRIMSTONE,625.559,-205.618,-52.735,2.609,TEMPSUMMON_DEAD_DESPAWN,0);
+
         return false;
     }
     return false;
 }
+
 /*######
 ## npc_grimstone
 ######*/
+
 #define SCRIPT_TEXT1    -1000000
 #define SCRIPT_TEXT2    -1000000
 #define SCRIPT_TEXT3    -1000000
 #define SCRIPT_TEXT4    -1000000
 #define SCRIPT_TEXT5    -1000000
 #define SCRIPT_TEXT6    -1000000
+
 //TODO: implement quest part of event (different end boss)
 struct TRINITY_DLL_DECL npc_grimstoneAI : public npc_escortAI
 {
@@ -106,43 +123,60 @@ struct TRINITY_DLL_DECL npc_grimstoneAI : public npc_escortAI
         pInstance = c->GetInstanceData();
         MobSpawnId = rand()%6;
     }
+
     ScriptedInstance* pInstance;
+
     uint8 EventPhase;
     uint32 Event_Timer;
+
     uint8 MobSpawnId;
     uint8 MobCount;
     uint32 MobDeath_Timer;
+
     uint64 RingMobGUID[4];
     uint64 RingBossGUID;
+
     bool CanWalk;
+
     void Reset()
     {
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
         EventPhase = 0;
         Event_Timer = 1000;
+
         MobCount = 0;
         MobDeath_Timer = 0;
-        for (uint8 i = 0; i < MAX_MOB_AMOUNT; ++i)
+
+        for(uint8 i = 0; i < MAX_MOB_AMOUNT; ++i)
             RingMobGUID[i] = 0;
+
         RingBossGUID = 0;
+
         CanWalk = false;
     }
+
     //TODO: move them to center
     void SummonRingMob()
     {
         if (Creature* tmp = m_creature->SummonCreature(RingMob[MobSpawnId],608.960,-235.322,-53.907,1.857,TEMPSUMMON_DEAD_DESPAWN,0))
             RingMobGUID[MobCount] = tmp->GetGUID();
+
         ++MobCount;
+
         if (MobCount == MAX_MOB_AMOUNT)
             MobDeath_Timer = 2500;
     }
+
     //TODO: move them to center
     void SummonRingBoss()
     {
         if (Creature* tmp = m_creature->SummonCreature(RingBoss[rand()%6],644.300,-175.989,-53.739,3.418,TEMPSUMMON_DEAD_DESPAWN,0))
             RingBossGUID = tmp->GetGUID();
+
         MobDeath_Timer = 2500;
     }
+
     void WaypointReached(uint32 i)
     {
         switch(i)
@@ -177,19 +211,23 @@ struct TRINITY_DLL_DECL npc_grimstoneAI : public npc_escortAI
             break;
         }
     }
+
     void HandleGameObject(uint32 id, bool open)
     {
         pInstance->HandleGameObject(pInstance->GetData64(id), open);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!pInstance)
             return;
+
         if (MobDeath_Timer)
         {
             if (MobDeath_Timer <= diff)
             {
                 MobDeath_Timer = 2500;
+
                 if (RingBossGUID)
                 {
                     Creature *boss = Unit::GetCreature(*m_creature,RingBossGUID);
@@ -202,13 +240,15 @@ struct TRINITY_DLL_DECL npc_grimstoneAI : public npc_escortAI
                     }
                     return;
                 }
-                for (uint8 i = 0; i < MAX_MOB_AMOUNT; ++i)
+
+                for(uint8 i = 0; i < MAX_MOB_AMOUNT; ++i)
                 {
                     Creature *mob = Unit::GetCreature(*m_creature,RingMobGUID[i]);
                     if (mob && !mob->isAlive() && mob->isDead())
                     {
                         RingMobGUID[i] = 0;
                         --MobCount;
+
                         //seems all are gone, so set timer to continue and discontinue this
                         if (!MobCount)
                         {
@@ -219,6 +259,7 @@ struct TRINITY_DLL_DECL npc_grimstoneAI : public npc_escortAI
                 }
             }else MobDeath_Timer -= diff;
         }
+
         if (Event_Timer)
         {
             if (Event_Timer <= diff)
@@ -286,43 +327,53 @@ struct TRINITY_DLL_DECL npc_grimstoneAI : public npc_escortAI
                 ++EventPhase;
             }else Event_Timer -= diff;
         }
+
         if (CanWalk)
             npc_escortAI::UpdateAI(diff);
        }
 };
+
 CreatureAI* GetAI_npc_grimstone(Creature* pCreature)
 {
     return new npc_grimstoneAI(pCreature);
 }
+
 /*######
 ## mob_phalanx
 ######*/
+
 #define SPELL_THUNDERCLAP       8732
 #define SPELL_FIREBALLVOLLEY    22425
 #define SPELL_MIGHTYBLOW        14099
+
 struct TRINITY_DLL_DECL mob_phalanxAI : public ScriptedAI
 {
     mob_phalanxAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ThunderClap_Timer;
     uint32 FireballVolley_Timer;
     uint32 MightyBlow_Timer;
+
     void Reset()
     {
         ThunderClap_Timer = 12000;
         FireballVolley_Timer =0;
         MightyBlow_Timer = 15000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -332,12 +383,14 @@ struct TRINITY_DLL_DECL mob_phalanxAI : public ScriptedAI
                 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();
     }
 };
@@ -345,13 +398,17 @@ CreatureAI* GetAI_mob_phalanx(Creature* pCreature)
 {
     return new mob_phalanxAI (pCreature);
 }
+
 /*######
 ## npc_kharan_mighthammer
 ######*/
+
 #define QUEST_4001  4001
 #define QUEST_4342  4342
+
 #define GOSSIP_ITEM_KHARAN_1    "I need to know where the princess are, Kharan!"
 #define GOSSIP_ITEM_KHARAN_2    "All is not lost, Kharan!"
+
 #define GOSSIP_ITEM_KHARAN_3    "Gor'shak is my friend, you can trust me."
 #define GOSSIP_ITEM_KHARAN_4    "Not enough, you need to tell me more."
 #define GOSSIP_ITEM_KHARAN_5    "So what happened?"
@@ -360,20 +417,26 @@ CreatureAI* GetAI_mob_phalanx(Creature* pCreature)
 #define GOSSIP_ITEM_KHARAN_8    "Continue with your story please."
 #define GOSSIP_ITEM_KHARAN_9    "Indeed."
 #define GOSSIP_ITEM_KHARAN_10   "The door is open, Kharan. You are a free man."
+
 bool GossipHello_npc_kharan_mighthammer(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_4001) == QUEST_STATUS_INCOMPLETE)
          pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KHARAN_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     if (pPlayer->GetQuestStatus(4342) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KHARAN_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
+
     if (pPlayer->GetTeam() == HORDE)
         pPlayer->SEND_GOSSIP_MENU(2473, pCreature->GetGUID());
     else
         pPlayer->SEND_GOSSIP_MENU(2474, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_kharan_mighthammer(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -386,6 +449,7 @@ bool GossipSelect_npc_kharan_mighthammer(Player* pPlayer, Creature* pCreature, u
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KHARAN_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
             pPlayer->SEND_GOSSIP_MENU(2476, pCreature->GetGUID());
             break;
+
         case GOSSIP_ACTION_INFO_DEF+3:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KHARAN_5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
             pPlayer->SEND_GOSSIP_MENU(2477, pCreature->GetGUID());
@@ -420,33 +484,42 @@ bool GossipSelect_npc_kharan_mighthammer(Player* pPlayer, Creature* pCreature, u
     }
     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
+
 #define GOSSIP_ITEM_SHOW_ACCESS     "Show me what I have access to, Lothos."
 #define GOSSIP_ITEM_GET_CONTRACT    "Get Thorium Brotherhood Contract"
+
 bool GossipHello_npc_lokhtos_darkbargainer(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor() && pPlayer->GetReputationRank(59) >= REP_FRIENDLY)
           pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_ITEM_SHOW_ACCESS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     if (pPlayer->GetQuestRewardStatus(QUEST_A_BINDING_CONTRACT) != 1 &&
         !pPlayer->HasItemCount(ITEM_THRORIUM_BROTHERHOOD_CONTRACT, 1, true) &&
         pPlayer->HasItemCount(ITEM_SULFURON_INGOT, 1))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_GET_CONTRACT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
     }
+
     if (pPlayer->GetReputationRank(59) < REP_FRIENDLY)
         pPlayer->SEND_GOSSIP_MENU(3673, pCreature->GetGUID());
     else
         pPlayer->SEND_GOSSIP_MENU(3677, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_lokhtos_darkbargainer(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -456,18 +529,23 @@ bool GossipSelect_npc_lokhtos_darkbargainer(Player* pPlayer, Creature* pCreature
     }
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 ## npc_dughal_stormwing
 ######*/
+
 #define QUEST_JAIL_BREAK        4322
 #define SAY_DUGHAL_FREE         "Thank you, $N! I'm free!!!"
 #define GOSSIP_DUGHAL           "You're free, Dughal! Get out of here!"
+
 /*
 struct TRINITY_DLL_DECL npc_dughal_stormwingAI : public npc_escortAI
 {
     npc_dughal_stormwingAI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
     switch(i)
@@ -482,8 +560,10 @@ struct TRINITY_DLL_DECL npc_dughal_stormwingAI : public npc_escortAI
             break;
         }
     }
+
     void EnterCombat(Unit* who) { }
     void Reset() {}
+
     void JustDied(Unit* killer)
     {
         if (IsBeingEscorted && killer == m_creature)
@@ -494,6 +574,7 @@ struct TRINITY_DLL_DECL npc_dughal_stormwingAI : public npc_escortAI
             pInstance->SetData(DATA_DUGHAL,ENCOUNTER_STATE_ENDED);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (pInstance->GetData(DATA_QUEST_JAIL_BREAK) == ENCOUNTER_STATE_NOT_STARTED) return;
@@ -515,9 +596,11 @@ struct TRINITY_DLL_DECL npc_dughal_stormwingAI : public npc_escortAI
 CreatureAI* GetAI_npc_dughal_stormwing(Creature* pCreature)
 {
     npc_dughal_stormwingAI* dughal_stormwingAI = new npc_dughal_stormwingAI(pCreature);
+
     dughal_stormwingAI->AddWaypoint(0, 280.42,-82.86, -77.12,0);
     dughal_stormwingAI->AddWaypoint(1, 287.64,-87.01, -76.79,0);
     dughal_stormwingAI->AddWaypoint(2, 354.63,-64.95, -67.53,0);
+
     return dughal_stormwingAI;
 }
 bool GossipHello_npc_dughal_stormwing(Player* pPlayer, Creature* pCreature)
@@ -529,6 +612,7 @@ bool GossipHello_npc_dughal_stormwing(Player* pPlayer, Creature* pCreature)
     }
     return true;
 }
+
 bool GossipSelect_npc_dughal_stormwing(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -544,6 +628,7 @@ bool GossipSelect_npc_dughal_stormwing(Player* pPlayer, Creature* pCreature, uin
 /*######
 ## npc_marshal_windsor
 ######*/
+
 #define SAY_WINDSOR_AGGRO1          "You locked up the wrong Marshal. Prepare to be destroyed!"
 #define SAY_WINDSOR_AGGRO2          "I bet you're sorry now, aren't you !?!!"
 #define SAY_WINDSOR_AGGRO3          "You better hold me back $N or they are going to feel some prison house beatings."
@@ -554,6 +639,7 @@ bool GossipSelect_npc_dughal_stormwing(Player* pPlayer, Creature* pCreature, uin
 #define SAY_WINDSOR_6               "This is it, $N. My stuff should be in that room. Cover me, I'm going in!"
 #define SAY_WINDSOR_9               "Ah, there it is!"
 #define MOB_ENTRY_REGINALD_WINDSOR  9682
+
 Player* pPlayerStart;
 /*
 struct TRINITY_DLL_DECL npc_marshal_windsorAI : public npc_escortAI
@@ -562,6 +648,7 @@ struct TRINITY_DLL_DECL npc_marshal_windsorAI : public npc_escortAI
     {
         pInstance = c->GetInstanceData();
     }
+
     void WaypointReached(uint32 i)
     {
     switch(i)
@@ -606,6 +693,7 @@ struct TRINITY_DLL_DECL npc_marshal_windsorAI : public npc_escortAI
             break;
         }
     }
+
     void EnterCombat(Unit* who)
         {
         switch(rand()%3)
@@ -615,11 +703,14 @@ struct TRINITY_DLL_DECL npc_marshal_windsorAI : public npc_escortAI
             case 2:m_creature->Say(SAY_WINDSOR_AGGRO3, LANG_UNIVERSAL, PlayerGUID);break;
             }
         }
+
     void Reset() {}
+
     void JustDied(Unit *slayer)
     {
         pInstance->SetData(DATA_QUEST_JAIL_BREAK,ENCOUNTER_STATE_FAILED);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (pInstance->GetData(DATA_QUEST_JAIL_BREAK) == ENCOUNTER_STATE_NOT_STARTED) return;
@@ -653,6 +744,7 @@ struct TRINITY_DLL_DECL npc_marshal_windsorAI : public npc_escortAI
 CreatureAI* GetAI_npc_marshal_windsor(Creature* pCreature)
 {
     npc_marshal_windsorAI* marshal_windsorAI = new npc_marshal_windsorAI(pCreature);
+
     marshal_windsorAI->AddWaypoint(0, 316.336,-225.528, -77.7258,7000);
     marshal_windsorAI->AddWaypoint(1, 316.336,-225.528, -77.7258,2000);
     marshal_windsorAI->AddWaypoint(2, 322.96,-207.13, -77.87,0);
@@ -673,8 +765,10 @@ CreatureAI* GetAI_npc_marshal_windsor(Creature* pCreature)
     marshal_windsorAI->AddWaypoint(17, 403.61,-51.71, -63.92,2000);
     marshal_windsorAI->AddWaypoint(18, 403.61,-51.71, -63.92,1000);
     marshal_windsorAI->AddWaypoint(19, 403.61,-51.71, -63.92,0);
+
     return marshal_windsorAI;
 }
+
 bool QuestAccept_npc_marshal_windsor(Player* pPlayer, Creature* pCreature, Quest const *quest)
 {
     if (quest->GetQuestId() == 4322)
@@ -685,6 +779,7 @@ bool QuestAccept_npc_marshal_windsor(Player* pPlayer, Creature* pCreature, Quest
                 pInstance->SetData(DATA_QUEST_JAIL_BREAK,ENCOUNTER_STATE_IN_PROGRESS);
                 pCreature->setFaction(11);
         }
+
         }
     return false;
 }
@@ -692,6 +787,7 @@ bool QuestAccept_npc_marshal_windsor(Player* pPlayer, Creature* pCreature, Quest
 /*######
 ## npc_marshal_reginald_windsor
 ######*/
+
 #define SAY_REGINALD_WINDSOR_0_1    "Can you feel the power, $N??? It's time to ROCK!"
 #define SAY_REGINALD_WINDSOR_0_2    "Now we just have to free Tobias and we can get out of here. This way!"
 #define SAY_REGINALD_WINDSOR_5_1    "Open it."
@@ -708,6 +804,7 @@ bool QuestAccept_npc_marshal_windsor(Player* pPlayer, Creature* pCreature, Quest
 #define SAY_REGINALD_WINDSOR_20_2   "Meet me at Maxwell's encampment. We'll go over the next stages of the plan there and figure out a way to decode my tablets without the decryption ring."
 #define MOB_ENTRY_SHILL_DINGER      9678
 #define MOB_ENTRY_CREST_KILLER      9680
+
 int wp = 0;
 /*
 struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI
@@ -715,6 +812,7 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI
     npc_marshal_reginald_windsorAI(Creature *c) : npc_escortAI(c)
     {
     }
+
     void WaypointReached(uint32 i)
     {
     wp=i;
@@ -772,10 +870,12 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI
             break;
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
             return;
+
         if (who->GetTypeId() == TYPEID_PLAYER)
         {
             if (CAST_PLR(who)->GetQuestStatus(4322) == QUEST_STATUS_INCOMPLETE)
@@ -789,6 +889,7 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI
             }
         }
     }
+
     void EnterCombat(Unit* who)
         {
         switch(rand()%3)
@@ -799,10 +900,12 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI
             }
         }
     void Reset() {}
+
     void JustDied(Unit *slayer)
     {
         pInstance->SetData(DATA_QUEST_JAIL_BREAK,ENCOUNTER_STATE_FAILED);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (pInstance->GetData(DATA_QUEST_JAIL_BREAK) == ENCOUNTER_STATE_NOT_STARTED) return;
@@ -853,6 +956,7 @@ struct TRINITY_DLL_DECL npc_marshal_reginald_windsorAI : public npc_escortAI
 CreatureAI* GetAI_npc_marshal_reginald_windsor(Creature* pCreature)
 {
     npc_marshal_reginald_windsorAI* marshal_reginald_windsorAI = new npc_marshal_reginald_windsorAI(pCreature);
+
     marshal_reginald_windsorAI->AddWaypoint(0, 403.61,-52.71, -63.92,4000);
     marshal_reginald_windsorAI->AddWaypoint(1, 403.61,-52.71, -63.92,4000);
     marshal_reginald_windsorAI->AddWaypoint(2, 406.33,-54.87, -63.95,0);
@@ -888,19 +992,23 @@ CreatureAI* GetAI_npc_marshal_reginald_windsor(Creature* pCreature)
     marshal_reginald_windsorAI->AddWaypoint(32, 452.45,29.85, -70.37,7000);
     marshal_reginald_windsorAI->AddWaypoint(33, 452.45,29.85, -70.37,10000);
     marshal_reginald_windsorAI->AddWaypoint(34, 451.27,31.85, -70.07,0);
+
     return marshal_reginald_windsorAI;
 }
 */
 /*######
 ## npc_tobias_seecher
 ######*/
+
 #define SAY_TOBIAS_FREE         "Thank you! I will run for safety immediately!"
 /*
 struct TRINITY_DLL_DECL npc_tobias_seecherAI : public npc_escortAI
 {
     npc_tobias_seecherAI(Creature *c) :npc_escortAI(c) {}
+
     void EnterCombat(Unit* who) { }
     void Reset() {}
+
     void JustDied(Unit* killer)
     {
         if (IsBeingEscorted && killer == m_creature)
@@ -911,6 +1019,7 @@ struct TRINITY_DLL_DECL npc_tobias_seecherAI : public npc_escortAI
             pInstance->SetData(DATA_TOBIAS,ENCOUNTER_STATE_ENDED);
         }
     }
+
     void WaypointReached(uint32 i)
     {
     switch(i)
@@ -926,6 +1035,7 @@ struct TRINITY_DLL_DECL npc_tobias_seecherAI : public npc_escortAI
             break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (pInstance->GetData(DATA_QUEST_JAIL_BREAK) == ENCOUNTER_STATE_NOT_STARTED) return;
@@ -944,16 +1054,20 @@ struct TRINITY_DLL_DECL npc_tobias_seecherAI : public npc_escortAI
         npc_escortAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_npc_tobias_seecher(Creature* pCreature)
 {
     npc_tobias_seecherAI* tobias_seecherAI = new npc_tobias_seecherAI(pCreature);
+
     tobias_seecherAI->AddWaypoint(0, 549.21, -281.07, -75.27);
     tobias_seecherAI->AddWaypoint(1, 554.39, -267.39, -73.68);
     tobias_seecherAI->AddWaypoint(2, 533.59, -249.38, -67.04);
     tobias_seecherAI->AddWaypoint(3, 519.44, -217.02, -59.34);
     tobias_seecherAI->AddWaypoint(4, 506.55, -153.49, -62.34);
+
     return tobias_seecherAI;
 }
+
 bool GossipHello_npc_tobias_seecher(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == ENCOUNTER_STATE_IN_PROGRESS)
@@ -963,6 +1077,7 @@ bool GossipHello_npc_tobias_seecher(Player* pPlayer, Creature* pCreature)
     }
     return true;
 }
+
 bool GossipSelect_npc_tobias_seecher(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -975,37 +1090,47 @@ bool GossipSelect_npc_tobias_seecher(Player* pPlayer, Creature* pCreature, uint3
     return true;
 }
 */
+
 /*######
 ## npc_rocknot
 ######*/
+
 #define SAY_GOT_BEER        -1230000
 #define SPELL_DRUNKEN_RAGE  14872
 #define QUEST_ALE           4295
+
 struct TRINITY_DLL_DECL npc_rocknotAI : public npc_escortAI
 {
     npc_rocknotAI(Creature *c) : npc_escortAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 BreakKeg_Timer;
     uint32 BreakDoor_Timer;
+
     void Reset()
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
             return;
+
         BreakKeg_Timer = 0;
         BreakDoor_Timer = 0;
     }
+
     void DoGo(uint32 id, uint32 state)
     {
         if (GameObject* pGo = pInstance->instance->GetGameObject(pInstance->GetData64(id)))
             pGo->SetGoState((GOState)state);
     }
+
     void WaypointReached(uint32 i)
     {
         if (!pInstance)
             return;
+
         switch(i)
         {
         case 1:
@@ -1026,10 +1151,12 @@ struct TRINITY_DLL_DECL npc_rocknotAI : public npc_escortAI
             break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!pInstance)
             return;
+
         if (BreakKeg_Timer)
         {
             if (BreakKeg_Timer <= diff)
@@ -1039,6 +1166,7 @@ struct TRINITY_DLL_DECL npc_rocknotAI : public npc_escortAI
                 BreakDoor_Timer = 1000;
             }else BreakKeg_Timer -= diff;
         }
+
         if (BreakDoor_Timer)
         {
             if (BreakDoor_Timer <= diff)
@@ -1046,33 +1174,44 @@ struct TRINITY_DLL_DECL npc_rocknotAI : public npc_escortAI
                 DoGo(DATA_GO_BAR_DOOR,2);
                 DoGo(DATA_GO_BAR_KEG_TRAP,0);               //doesn't work very well, leaving code here for future
                 //spell by trap has effect61, this indicate the bar go hostile
+
                 if (Unit *tmp = Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_PHALANX)))
                     tmp->setFaction(14);
+
                 //for later, this event(s) has alot more to it.
                 //optionally, DONE can trigger bar to go hostile.
                 pInstance->SetData(TYPE_BAR,DONE);
+
                 BreakDoor_Timer = 0;
             }else BreakDoor_Timer -= diff;
         }
+
         npc_escortAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_npc_rocknot(Creature* pCreature)
 {
     return new npc_rocknotAI(pCreature);
 }
+
 bool ChooseReward_npc_rocknot(Player* pPlayer, Creature* pCreature, const Quest *_Quest, uint32 item)
 {
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
+
     if (!pInstance)
         return true;
+
     if (pInstance->GetData(TYPE_BAR) == DONE || pInstance->GetData(TYPE_BAR) == SPECIAL)
         return true;
+
     if (_Quest->GetQuestId() == QUEST_ALE)
     {
         if (pInstance->GetData(TYPE_BAR) != IN_PROGRESS)
             pInstance->SetData(TYPE_BAR,IN_PROGRESS);
+
         pInstance->SetData(TYPE_BAR,SPECIAL);
+
         //keep track of amount in instance script, returns SPECIAL if amount ok and event in progress
         if (pInstance->GetData(TYPE_BAR) == SPECIAL)
         {
@@ -1082,35 +1221,44 @@ bool ChooseReward_npc_rocknot(Player* pPlayer, Creature* pCreature, const Quest
                 pEscortAI->Start(false, false);
         }
     }
+
     return true;
 }
+
 /*######
 ##
 ######*/
+
 void AddSC_blackrock_depths()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "go_shadowforge_brazier";
     newscript->pGOHello = &GOHello_go_shadowforge_brazier;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "at_ring_of_law";
     newscript->pAreaTrigger = &AreaTrigger_at_ring_of_law;
     newscript->RegisterSelf();
+
      newscript = new Script;
      newscript->Name = "npc_grimstone";
      newscript->GetAI = &GetAI_npc_grimstone;
      newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_phalanx";
     newscript->GetAI = &GetAI_mob_phalanx;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_kharan_mighthammer";
     newscript->pGossipHello =  &GossipHello_npc_kharan_mighthammer;
     newscript->pGossipSelect = &GossipSelect_npc_kharan_mighthammer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_lokhtos_darkbargainer";
     newscript->pGossipHello =  &GossipHello_npc_lokhtos_darkbargainer;
@@ -1123,22 +1271,26 @@ void AddSC_blackrock_depths()
     newscript->pGossipSelect = &GossipSelect_npc_dughal_stormwing;
     newscript->GetAI = &GetAI_npc_dughal_stormwing;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_tobias_seecher";
     newscript->pGossipHello =  &GossipHello_npc_tobias_seecher;
     newscript->pGossipSelect = &GossipSelect_npc_tobias_seecher;
     newscript->GetAI = &GetAI_npc_tobias_seecher;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_marshal_windsor";
     newscript->pQuestAccept = &QuestAccept_npc_marshal_windsor;
     newscript->GetAI = &GetAI_npc_marshal_windsor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_marshal_reginald_windsor";
     newscript->GetAI = &GetAI_npc_marshal_reginald_windsor;
     newscript->RegisterSelf();
 */
+
      newscript = new Script;
      newscript->Name = "npc_rocknot";
      newscript->GetAI = &GetAI_npc_rocknot;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_ambassador_flamelash.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_ambassador_flamelash.cpp
index 39f2be7e644..ba10c873b23 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_ambassador_flamelash.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_ambassador_flamelash.cpp
@@ -13,29 +13,37 @@
  * along with 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 TRINITY_DLL_DECL boss_ambassador_flamelashAI : public ScriptedAI
 {
     boss_ambassador_flamelashAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 FireBlast_Timer;
     uint32 Spirit_Timer;
     int Rand;
     int RandX;
     int RandY;
     Creature* Summoned;
+
     void Reset()
     {
         FireBlast_Timer = 2000;
         Spirit_Timer = 24000;
     }
+
     void EnterCombat(Unit *who) {}
+
     void SummonSpirits(Unit* victim)
     {
         Rand = rand()%10;
@@ -55,17 +63,20 @@ struct TRINITY_DLL_DECL boss_ambassador_flamelashAI : public ScriptedAI
         if (Summoned)
             (Summoned->AI())->AttackStart(victim);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -73,8 +84,10 @@ struct TRINITY_DLL_DECL boss_ambassador_flamelashAI : public ScriptedAI
             SummonSpirits(m_creature->getVictim());
             SummonSpirits(m_creature->getVictim());
             SummonSpirits(m_creature->getVictim());
+
             Spirit_Timer = 30000;
         }else Spirit_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -82,6 +95,7 @@ CreatureAI* GetAI_boss_ambassador_flamelash(Creature* pCreature)
 {
     return new boss_ambassador_flamelashAI (pCreature);
 }
+
 void AddSC_boss_ambassador_flamelash()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_anubshiah.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_anubshiah.cpp
index a6589ed0fd7..d5589967cac 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_anubshiah.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_anubshiah.cpp
@@ -13,26 +13,32 @@
  * along with 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 TRINITY_DLL_DECL boss_anubshiahAI : public ScriptedAI
 {
     boss_anubshiahAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowBolt_Timer;
     uint32 CurseOfTongues_Timer;
     uint32 CurseOfWeakness_Timer;
     uint32 DemonArmor_Timer;
     uint32 EnvelopingWeb_Timer;
+
     void Reset()
     {
         ShadowBolt_Timer = 7000;
@@ -41,20 +47,24 @@ struct TRINITY_DLL_DECL boss_anubshiahAI : public ScriptedAI
         DemonArmor_Timer = 3000;
         EnvelopingWeb_Timer = 16000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -63,18 +73,21 @@ struct TRINITY_DLL_DECL boss_anubshiahAI : public ScriptedAI
             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)
         {
@@ -83,6 +96,7 @@ struct TRINITY_DLL_DECL boss_anubshiahAI : public ScriptedAI
             if (target) DoCast(target,SPELL_ENVELOPINGWEB);
             EnvelopingWeb_Timer = 12000;
         }else EnvelopingWeb_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -90,6 +104,7 @@ CreatureAI* GetAI_boss_anubshiah(Creature* pCreature)
 {
     return new boss_anubshiahAI (pCreature);
 }
+
 void AddSC_boss_anubshiah()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_emperor_dagran_thaurissan.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_emperor_dagran_thaurissan.cpp
index 0b9c430917d..83a3839b44f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_emperor_dagran_thaurissan.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_emperor_dagran_thaurissan.cpp
@@ -13,47 +13,59 @@
  * along with 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 SAY_AGGRO                       -1230001
 #define SAY_SLAY                        -1230002
+
 #define SPELL_HANDOFTHAURISSAN          17492
 #define SPELL_AVATAROFFLAME             15636
+
 struct TRINITY_DLL_DECL boss_draganthaurissanAI : public ScriptedAI
 {
     boss_draganthaurissanAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 HandOfThaurissan_Timer;
     uint32 AvatarOfFlame_Timer;
     //uint32 Counter;
+
     void Reset()
     {
         HandOfThaurissan_Timer = 4000;
         AvatarOfFlame_Timer = 25000;
         //Counter= 0;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         m_creature->CallForHelp(VISIBLE_RANGE);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(SAY_SLAY, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (HandOfThaurissan_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 DoCast(target,SPELL_HANDOFTHAURISSAN);
+
             //3 Hands of Thaurissan will be casted
             //if (Counter < 3)
             //{
@@ -66,19 +78,23 @@ struct TRINITY_DLL_DECL boss_draganthaurissanAI : public ScriptedAI
                 //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* pCreature)
 {
     return new boss_draganthaurissanAI (pCreature);
 }
+
 void AddSC_boss_draganthaurissan()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_general_angerforge.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_general_angerforge.cpp
index 0ba98b48998..4c02c438347 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_general_angerforge.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_general_angerforge.cpp
@@ -13,19 +13,24 @@
  * along with 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 TRINITY_DLL_DECL boss_general_angerforgeAI : public ScriptedAI
 {
     boss_general_angerforgeAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 MightyBlow_Timer;
     uint32 HamString_Timer;
     uint32 Cleave_Timer;
@@ -39,6 +44,7 @@ struct TRINITY_DLL_DECL boss_general_angerforgeAI : public ScriptedAI
     int Rand2Y;
     Creature* SummonedAdds;
     Creature* SummonedMedics;
+
     void Reset()
     {
         MightyBlow_Timer = 8000;
@@ -47,9 +53,11 @@ struct TRINITY_DLL_DECL boss_general_angerforgeAI : public ScriptedAI
         Adds_Timer = 0;
         Medics = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void SummonAdds(Unit* victim)
     {
         Rand1 = rand()%15;
@@ -70,6 +78,7 @@ struct TRINITY_DLL_DECL boss_general_angerforgeAI : public ScriptedAI
         if (SummonedAdds)
             (SummonedAdds->AI())->AttackStart(victim);
     }
+
     void SummonMedics(Unit* victim)
     {
         Rand2 = rand()%10;
@@ -90,29 +99,34 @@ struct TRINITY_DLL_DECL boss_general_angerforgeAI : public ScriptedAI
         if (SummonedMedics)
             (SummonedMedics->AI())->AttackStart(victim);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -122,9 +136,11 @@ struct TRINITY_DLL_DECL boss_general_angerforgeAI : public ScriptedAI
                 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)
         {
@@ -132,6 +148,7 @@ struct TRINITY_DLL_DECL boss_general_angerforgeAI : public ScriptedAI
             SummonMedics(m_creature->getVictim());
             Medics = true;
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -139,6 +156,7 @@ CreatureAI* GetAI_boss_general_angerforge(Creature* pCreature)
 {
     return new boss_general_angerforgeAI (pCreature);
 }
+
 void AddSC_boss_general_angerforge()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_gorosh_the_dervish.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_gorosh_the_dervish.cpp
index 6aa1c60252d..5fcb18295f0 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_gorosh_the_dervish.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_gorosh_the_dervish.cpp
@@ -13,45 +13,56 @@
  * along with 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 TRINITY_DLL_DECL boss_gorosh_the_dervishAI : public ScriptedAI
 {
     boss_gorosh_the_dervishAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 WhirlWind_Timer;
     uint32 MortalStrike_Timer;
+
     void Reset()
     {
         WhirlWind_Timer = 12000;
         MortalStrike_Timer = 22000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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();
     }
 };
@@ -59,6 +70,7 @@ CreatureAI* GetAI_boss_gorosh_the_dervish(Creature* pCreature)
 {
     return new boss_gorosh_the_dervishAI (pCreature);
 }
+
 void AddSC_boss_gorosh_the_dervish()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_grizzle.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_grizzle.cpp
index 560e5874c0d..5950e92612f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_grizzle.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_grizzle.cpp
@@ -13,40 +13,51 @@
  * along with 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 EMOTE_GENERIC_FRENZY_KILL   -1000001
+
 #define SPELL_GROUNDTREMOR          6524
 #define SPELL_FRENZY                28371
+
 struct TRINITY_DLL_DECL boss_grizzleAI : public ScriptedAI
 {
     boss_grizzleAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 GroundTremor_Timer;
     uint32 Frenzy_Timer;
+
     void Reset()
     {
         GroundTremor_Timer = 12000;
         Frenzy_Timer =0;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -54,9 +65,11 @@ struct TRINITY_DLL_DECL boss_grizzleAI : public ScriptedAI
             {
                 DoCast(m_creature,SPELL_FRENZY);
                 DoScriptText(EMOTE_GENERIC_FRENZY_KILL, m_creature);
+
                 Frenzy_Timer = 15000;
             }else Frenzy_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -64,6 +77,7 @@ CreatureAI* GetAI_boss_grizzle(Creature* pCreature)
 {
     return new boss_grizzleAI (pCreature);
 }
+
 void AddSC_boss_grizzle()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_high_interrogator_gerstahn.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_high_interrogator_gerstahn.cpp
index a61e47ccfb2..94e8b8281e1 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_high_interrogator_gerstahn.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_high_interrogator_gerstahn.cpp
@@ -13,24 +13,30 @@
  * along with 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 TRINITY_DLL_DECL boss_high_interrogator_gerstahnAI : public ScriptedAI
 {
     boss_high_interrogator_gerstahnAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowWordPain_Timer;
     uint32 ManaBurn_Timer;
     uint32 PsychicScream_Timer;
     uint32 ShadowShield_Timer;
+
     void Reset()
     {
         ShadowWordPain_Timer = 4000;
@@ -38,14 +44,17 @@ struct TRINITY_DLL_DECL boss_high_interrogator_gerstahnAI : public ScriptedAI
         PsychicScream_Timer = 32000;
         ShadowShield_Timer = 8000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //ShadowWordPain_Timer
         if (ShadowWordPain_Timer < diff)
         {
@@ -54,6 +63,7 @@ struct TRINITY_DLL_DECL boss_high_interrogator_gerstahnAI : public ScriptedAI
             if (target)DoCast(target,SPELL_SHADOWWORDPAIN);
             ShadowWordPain_Timer = 7000;
         }else ShadowWordPain_Timer -= diff;
+
         //ManaBurn_Timer
         if (ManaBurn_Timer < diff)
         {
@@ -62,18 +72,21 @@ struct TRINITY_DLL_DECL boss_high_interrogator_gerstahnAI : public ScriptedAI
             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();
     }
 };
@@ -81,6 +94,7 @@ CreatureAI* GetAI_boss_high_interrogator_gerstahn(Creature* pCreature)
 {
     return new boss_high_interrogator_gerstahnAI (pCreature);
 }
+
 void AddSC_boss_high_interrogator_gerstahn()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_magmus.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_magmus.cpp
index dc8b9a269e9..773271d7e5e 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_magmus.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_magmus.cpp
@@ -13,39 +13,49 @@
  * along with 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 TRINITY_DLL_DECL boss_magmusAI : public ScriptedAI
 {
     boss_magmusAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 FieryBurst_Timer;
     uint32 WarStomp_Timer;
+
     void Reset()
     {
         FieryBurst_Timer = 5000;
         WarStomp_Timer =0;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -55,6 +65,7 @@ struct TRINITY_DLL_DECL boss_magmusAI : public ScriptedAI
                 WarStomp_Timer = 8000;
             }else WarStomp_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -62,6 +73,7 @@ CreatureAI* GetAI_boss_magmus(Creature* pCreature)
 {
     return new boss_magmusAI (pCreature);
 }
+
 void AddSC_boss_magmus()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_moira_bronzebeard.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_moira_bronzebeard.cpp
index 8687a1fbeeb..63395dd5016 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_moira_bronzebeard.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_moira_bronzebeard.cpp
@@ -13,22 +13,27 @@
  * along with 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 TRINITY_DLL_DECL boss_moira_bronzebeardAI : public ScriptedAI
 {
     boss_moira_bronzebeardAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Heal_Timer;
     uint32 MindBlast_Timer;
     uint32 ShadowWordPain_Timer;
@@ -36,6 +41,7 @@ struct TRINITY_DLL_DECL boss_moira_bronzebeardAI : public ScriptedAI
     Unit* PlayerHolder;
     Unit* Target;
     bool Heal;
+
     void Reset()
     {
         Target = NULL;
@@ -44,38 +50,45 @@ struct TRINITY_DLL_DECL boss_moira_bronzebeardAI : public ScriptedAI
         ShadowWordPain_Timer = 2000;
         Smite_Timer = 8000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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* pCreature)
 {
     return new boss_moira_bronzebeardAI (pCreature);
 }
+
 void AddSC_boss_moira_bronzebeard()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_tomb_of_seven.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_tomb_of_seven.cpp
index 57ffc0bb52c..80b2ea8ac08 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_tomb_of_seven.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/boss_tomb_of_seven.cpp
@@ -13,14 +13,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss_Tomb_Of_Seven
 SD%Complete: 90
 SDComment: Learning Smelt Dark Iron if tribute quest rewarded. Missing event.
 SDCategory: Blackrock Depths
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_blackrock_depths.h"
+
 enum eEnums
 {
     SPELL_SMELT_DARK_IRON       = 14891,
@@ -28,19 +31,24 @@ enum eEnums
     QUEST_SPECTRAL_CHALICE      = 4083,
     SKILLPOINT_MIN              = 230
 };
+
 #define GOSSIP_ITEM_TEACH_1 "Teach me the art of smelting dark iron"
 #define GOSSIP_ITEM_TEACH_2 "Continue..."
 #define GOSSIP_ITEM_TEACH_3 "[PH] Continue..."
 #define GOSSIP_ITEM_TRIBUTE "I want to pay tribute"
+
 bool GossipHello_boss_gloomrel(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestRewardStatus(QUEST_SPECTRAL_CHALICE) == 1 && pPlayer->GetSkillValue(SKILL_MINING) >= SKILLPOINT_MIN && !pPlayer->HasSpell(SPELL_SMELT_DARK_IRON))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TEACH_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
     if (pPlayer->GetQuestRewardStatus(QUEST_SPECTRAL_CHALICE) == 0 && pPlayer->GetSkillValue(SKILL_MINING) >= SKILLPOINT_MIN)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TRIBUTE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_boss_gloomrel(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -68,6 +76,7 @@ bool GossipSelect_boss_gloomrel(Player* pPlayer, Creature* pCreature, uint32 uiS
     }
     return true;
 }
+
 enum eSpells
 {
     SPELL_SHADOWBOLTVOLLEY               = 15245,
@@ -76,12 +85,14 @@ enum eSpells
     SPELL_DEMONARMOR                     = 13787,
     SPELL_SUMMON_VOIDWALKERS             = 15092
 };
+
 struct TRINITY_DLL_DECL boss_doomrelAI : public ScriptedAI
 {
     boss_doomrelAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     uint32 ShadowVolley_Timer;
     uint32 Immolate_Timer;
@@ -92,6 +103,7 @@ struct TRINITY_DLL_DECL boss_doomrelAI : public ScriptedAI
     int RandX;
     int RandY;
     Creature* Summoned;
+
     void Reset()
     {
         ShadowVolley_Timer = 10000;
@@ -99,18 +111,23 @@ struct TRINITY_DLL_DECL boss_doomrelAI : public ScriptedAI
         CurseOfWeakness_Timer = 5000;
         DemonArmor_Timer = 16000;
         Voidwalkers = false;
+
         m_creature->setFaction(FACTION_FRIEND);
+
         // was set before event start, so set again
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
+
         if (pInstance)
             if (pInstance->GetData(DATA_GHOSTKILL) >= 7)
                 m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
             else
                 m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void EnterEvadeMode()
     {
         m_creature->RemoveAllAuras();
@@ -123,61 +140,75 @@ struct TRINITY_DLL_DECL boss_doomrelAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData64(DATA_EVENSTARTER, 0);
     }
+
     void JustDied(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_GHOSTKILL, 1);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 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)
         {
             m_creature->CastSpell(m_creature->getVictim(), SPELL_SUMMON_VOIDWALKERS, true);
             Voidwalkers = true;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_doomrel(Creature* pCreature)
 {
     return new boss_doomrelAI (pCreature);
 }
+
 #define GOSSIP_ITEM_CHALLENGE   "Your bondage is at an end, Doom'rel. I challenge you!"
 #define GOSSIP_SELECT_DOOMREL   "[PH] Continue..."
+
 bool GossipHello_boss_doomrel(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHALLENGE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
     pPlayer->SEND_GOSSIP_MENU(2601, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_boss_doomrel(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -199,14 +230,17 @@ bool GossipSelect_boss_doomrel(Player* pPlayer, Creature* pCreature, uint32 uiSe
     }
     return true;
 }
+
 void AddSC_boss_tomb_of_seven()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_gloomrel";
     newscript->pGossipHello = &GossipHello_boss_gloomrel;
     newscript->pGossipSelect = &GossipSelect_boss_gloomrel;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_doomrel";
     newscript->GetAI = &GetAI_boss_doomrel;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/def_blackrock_depths.h b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/def_blackrock_depths.h
index 4f31378a495..6ced6bafe15 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/def_blackrock_depths.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/def_blackrock_depths.h
@@ -1,11 +1,14 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
 * This program is free software licensed under GPL version 2
 * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_BRD_H
 #define DEF_BRD_H
+
 #define FACTION_NEUTRAL             734
 #define FACTION_HOSTILE             754
 #define FACTION_FRIEND              35
+
 enum eTypes
 {
     TYPE_RING_OF_LAW        = 1,
@@ -14,16 +17,20 @@ enum eTypes
     TYPE_TOMB_OF_SEVEN      = 4,
     TYPE_LYCEUM             = 5,
     TYPE_IRON_HALL          = 6,
+
     DATA_EMPEROR            = 10,
     DATA_PHALANX            = 11,
+
     DATA_ARENA1             = 12,
     DATA_ARENA2             = 13,
     DATA_ARENA3             = 14,
     DATA_ARENA4             = 15,
+
     DATA_GO_BAR_KEG         = 16,
     DATA_GO_BAR_KEG_TRAP    = 17,
     DATA_GO_BAR_DOOR        = 18,
     DATA_GO_CHALICE         = 19,
+
     DATA_GHOSTKILL          = 20,
     DATA_EVENSTARTER        = 21
 };
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/instance_blackrock_depths.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/instance_blackrock_depths.cpp
index c17c27209e2..f14b7603fa7 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/instance_blackrock_depths.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_depths/instance_blackrock_depths.cpp
@@ -13,12 +13,14 @@
 * along 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_Blackrock_Depths
 SD%Complete: 100
 SDComment:
 SDCategory: Blackrock Depths
 EndScriptData */
+
 /*
 update `creature_template` set `npcflag`='1',`ScriptName`='npc_dughal_stormwing' where `entry`='9022';
 update `creature_template` set `ScriptName`='npc_marshal_windsor' where `entry`='9023';
@@ -26,12 +28,16 @@ update `creature_template` set `ScriptName`='npc_marshal_reginald_windsor' where
 update `creature_template` set `npcflag`='1',`ScriptName`='npc_tobias_seecher' where `entry`='9679';
 update `instance_template` set `script`='instance_blackrock_depths' where `map`='230';
 */
+
 #include "precompiled.h"
 #include "def_blackrock_depths.h"
+
 #define TIMER_TOMBOFTHESEVEN    15000
+
 enum eEnums
 {
     MAX_ENCOUNTER           = 6,
+
     NPC_EMPEROR             = 9019,
     NPC_PHALANX             = 9502,
     NPC_ANGERREL            = 9035,
@@ -41,6 +47,7 @@ enum eEnums
     NPC_SEETHREL            = 9038,
     NPC_GLOOMREL            = 9037,
     NPC_DOOMREL             = 9039,
+
     GO_ARENA1               = 161525,
     GO_ARENA2               = 161522,
     GO_ARENA3               = 161524,
@@ -58,16 +65,21 @@ enum eEnums
     GO_GOLEM_ROOM_N         = 170573,
     GO_GOLEM_ROOM_S         = 170574,
     GO_THONE_ROOM           = 170575,
+
     GO_SPECTRAL_CHALICE     = 164869,
     GO_CHEST_SEVEN          = 169243
 };
+
 struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
 {
     instance_blackrock_depths(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     std::string str_data;
+
     uint64 EmperorGUID;
     uint64 PhalanxGUID;
+
     uint64 GoArena1GUID;
     uint64 GoArena2GUID;
     uint64 GoArena3GUID;
@@ -86,17 +98,21 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
     uint64 GoGolemSGUID;
     uint64 GoThoneGUID;
     uint64 GoChestGUID;
+
     uint32 BarAleCount;
     uint32 GhostKillCount;
     uint64 TombBossGUIDs[7];
     uint64 TombEventStarterGUID;
     uint32 TombTimer;
     uint32 TombEventCounter;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         EmperorGUID = 0;
         PhalanxGUID = 0;
+
         GoArena1GUID = 0;
         GoArena2GUID = 0;
         GoArena3GUID = 0;
@@ -115,14 +131,17 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
         GoGolemSGUID = 0;
         GoThoneGUID = 0;
         GoChestGUID = 0;
+
         BarAleCount = 0;
         GhostKillCount = 0;
         TombEventStarterGUID = 0;
         TombTimer = TIMER_TOMBOFTHESEVEN;
         TombEventCounter = 0;
-        for (uint8 i = 0; i < 7; ++i)
+
+        for(uint8 i = 0; i < 7; ++i)
             TombBossGUIDs[i] = 0;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -138,6 +157,7 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
         case NPC_ANGERREL: TombBossGUIDs[6] = pCreature->GetGUID(); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -168,9 +188,11 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
         case GO_CHEST_SEVEN: GoChestGUID = pGo->GetGUID(); break;
         }
     }
+
     void SetData64(uint32 type, uint64 data)
     {
         debug_log("TSCR: Instance Blackrock Depths: SetData64 update (Type: %u Data %u)", type, data);
+
         switch(type)
         {
         case DATA_EVENSTARTER:
@@ -182,9 +204,11 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
             break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         debug_log("TSCR: Instance Blackrock Depths: SetData update (Type: %u Data %u)", type, data);
+
         switch(type)
         {
         case TYPE_RING_OF_LAW:
@@ -212,17 +236,22 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
             GhostKillCount += data;
             break;
         }
+
         if (data == DONE || GhostKillCount >= 7)
         {
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
             saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                 << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " " << GhostKillCount;
+
             str_data = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -247,6 +276,7 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 data)
     {
         switch(data)
@@ -274,10 +304,12 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
         }
         return 0;
     }
+
     std::string GetSaveData()
     {
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -285,19 +317,24 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         std::istringstream loadStream(in);
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3]
         >> m_auiEncounter[4] >> m_auiEncounter[5] >> GhostKillCount;
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)
                 m_auiEncounter[i] = NOT_STARTED;
         if (GhostKillCount > 0 && GhostKillCount < 7)
             GhostKillCount = 0;//reset tomb of seven event
         if (GhostKillCount > 7)
             GhostKillCount = 7;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
+
     void TombOfSevenEvent()
     {
         if (GhostKillCount < 7 && TombBossGUIDs[TombEventCounter])
@@ -311,11 +348,12 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
             }
         }
     }
+
     void TombOfSevenReset()
     {
         HandleGameObject(GoTombExitGUID,false);//event reseted, close exit door
         HandleGameObject(GoTombEnterGUID,true);//event reseted, open entrance door
-        for (uint8 i = 0; i < 7; ++i)
+        for(uint8 i = 0; i < 7; ++i)
         {
             if (Creature* boss = instance->GetCreature(TombBossGUIDs[i]))
             {
@@ -338,12 +376,14 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
         TombTimer = TIMER_TOMBOFTHESEVEN;
         SetData(TYPE_TOMB_OF_SEVEN, NOT_STARTED);
     }
+
     void TombOfSevenStart()
     {
         HandleGameObject(GoTombExitGUID,false);//event started, close exit door
         HandleGameObject(GoTombEnterGUID,false);//event started, close entrance door
         SetData(TYPE_TOMB_OF_SEVEN, IN_PROGRESS);
     }
+
     void TombOfSevenEnd()
     {
         DoRespawnGameObject(GoChestGUID,DAY);
@@ -367,10 +407,12 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
             TombOfSevenEnd();
     }
 };
+
 InstanceData* GetInstanceData_instance_blackrock_depths(Map* pMap)
 {
     return new instance_blackrock_depths(pMap);
 }
+
    void AddSC_instance_blackrock_depths()
    {
        Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_drakkisath.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_drakkisath.cpp
index 28a9d09aa0d..5aa5ea42520 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_drakkisath.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_drakkisath.cpp
@@ -13,24 +13,30 @@
  * along with 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 TRINITY_DLL_DECL boss_drakkisathAI : public ScriptedAI
 {
     boss_drakkisathAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 FireNova_Timer;
     uint32 Cleave_Timer;
     uint32 Confliguration_Timer;
     uint32 Thunderclap_Timer;
+
     void Reset()
     {
         FireNova_Timer = 6000;
@@ -38,38 +44,45 @@ struct TRINITY_DLL_DECL boss_drakkisathAI : public ScriptedAI
         Confliguration_Timer = 15000;
         Thunderclap_Timer = 17000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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();
     }
 };
@@ -77,6 +90,7 @@ CreatureAI* GetAI_boss_drakkisath(Creature* pCreature)
 {
     return new boss_drakkisathAI (pCreature);
 }
+
 void AddSC_boss_drakkisath()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_gyth.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_gyth.cpp
index d37d03d07b0..423a5cc1268 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_gyth.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_gyth.cpp
@@ -13,19 +13,24 @@
  * along with 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 TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
 {
     boss_gythAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Aggro_Timer;
     uint32 Dragons_Timer;
     uint32 Orc_Timer;
@@ -34,6 +39,7 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
     uint32 Flamebreath_Timer;
     uint32 Line1Count;
     uint32 Line2Count;
+
     bool Event;
     bool SummonedDragons;
     bool SummonedOrcs;
@@ -41,6 +47,7 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
     bool bAggro;
     bool RootSelf;
     Creature *SummonedCreature;
+
     void Reset()
     {
         Dragons_Timer = 3000;
@@ -55,6 +62,7 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
         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;
@@ -62,13 +70,16 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
             Line2Count = rand() % (5 - Line1Count) + 2;
         else
             Line2Count = 2;
+
         //Invisible for event start
         m_creature->SetDisplayId(11686);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void EnterCombat(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);
@@ -79,18 +90,22 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
                 Summoned->AddThreat(target, 1.0f);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //char buf[200];
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (!RootSelf)
         {
             //m_creature->m_canMove = true;
             DoCast(m_creature, 33356);
             RootSelf = true;
         }
+
         if (!bAggro && Line1Count == 0 && Line2Count == 0)
         {
             if (Aggro_Timer < diff)
@@ -102,6 +117,7 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
                 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)
         {
@@ -116,6 +132,7 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
                 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)
         {
@@ -130,6 +147,7 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
                 Orc_Timer = 60000;
             } else Orc_Timer -= diff;
         }
+
         // we take part in the fight
         if (bAggro)
         {
@@ -139,18 +157,21 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
                 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)
@@ -163,14 +184,17 @@ struct TRINITY_DLL_DECL boss_gythAI : public ScriptedAI
                 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* pCreature)
 {
     return new boss_gythAI (pCreature);
 }
+
 void AddSC_boss_gyth()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_halycon.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_halycon.cpp
index bcde2df4baf..6937aae0dc5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_halycon.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_halycon.cpp
@@ -13,57 +13,70 @@
  * along with 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 TRINITY_DLL_DECL boss_halyconAI : public ScriptedAI
 {
     boss_halyconAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 CrowdPummel_Timer;
     uint32 MightyBlow_Timer;
     bool Summoned;
+
     void Reset()
     {
         CrowdPummel_Timer = 8000;
         MightyBlow_Timer = 14000;
         Summoned = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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();
     }
 };
@@ -71,6 +84,7 @@ CreatureAI* GetAI_boss_halycon(Creature* pCreature)
 {
     return new boss_halyconAI (pCreature);
 }
+
 void AddSC_boss_halycon()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_highlord_omokk.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_highlord_omokk.cpp
index edd5d039d4d..5fccc3333a5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_highlord_omokk.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_highlord_omokk.cpp
@@ -13,13 +13,16 @@
  * along with 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
@@ -27,9 +30,11 @@ EndScriptData */
 #define SPELL_SUNDERARMOR       24317
 #define SPELL_KNOCKAWAY         20686
 #define SPELL_SLOW              22356
+
 struct TRINITY_DLL_DECL boss_highlordomokkAI : public ScriptedAI
 {
     boss_highlordomokkAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 WarStomp_Timer;
     uint32 Cleave_Timer;
     uint32 Strike_Timer;
@@ -37,6 +42,7 @@ struct TRINITY_DLL_DECL boss_highlordomokkAI : public ScriptedAI
     uint32 SunderArmor_Timer;
     uint32 KnockAway_Timer;
     uint32 Slow_Timer;
+
     void Reset()
     {
         WarStomp_Timer = 15000;
@@ -47,56 +53,66 @@ struct TRINITY_DLL_DECL boss_highlordomokkAI : public ScriptedAI
         KnockAway_Timer = 18000;
         Slow_Timer = 24000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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();
     }
 };
@@ -104,6 +120,7 @@ CreatureAI* GetAI_boss_highlordomokk(Creature* pCreature)
 {
     return new boss_highlordomokkAI (pCreature);
 }
+
 void AddSC_boss_highlordomokk()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_mother_smolderweb.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_mother_smolderweb.cpp
index cc858a33628..61a92ebfe40 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_mother_smolderweb.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_mother_smolderweb.cpp
@@ -13,49 +13,61 @@
  * along with 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 TRINITY_DLL_DECL boss_mothersmolderwebAI : public ScriptedAI
 {
     boss_mothersmolderwebAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Crystalize_Timer;
     uint32 MothersMilk_Timer;
+
     void Reset()
     {
         Crystalize_Timer = 20000;
         MothersMilk_Timer = 10000;
     }
+
     void EnterCombat(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 (!UpdateVictim())
             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();
     }
 };
@@ -63,6 +75,7 @@ CreatureAI* GetAI_boss_mothersmolderweb(Creature* pCreature)
 {
     return new boss_mothersmolderwebAI (pCreature);
 }
+
 void AddSC_boss_mothersmolderweb()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_overlord_wyrmthalak.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_overlord_wyrmthalak.cpp
index 285c455d437..3e5611da95a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_overlord_wyrmthalak.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_overlord_wyrmthalak.cpp
@@ -13,34 +13,42 @@
  * along with 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 TRINITY_DLL_DECL boss_overlordwyrmthalakAI : public ScriptedAI
 {
     boss_overlordwyrmthalakAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 BlastWave_Timer;
     uint32 Shout_Timer;
     uint32 Cleave_Timer;
     uint32 Knockaway_Timer;
     bool Summoned;
     Creature *SummonedCreature;
+
     void Reset()
     {
         BlastWave_Timer = 20000;
@@ -49,43 +57,51 @@ struct TRINITY_DLL_DECL boss_overlordwyrmthalakAI : public ScriptedAI
         Knockaway_Timer = 12000;
         Summoned = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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);
             if (SummonedCreature)
             (SummonedCreature->AI())->AttackStart(target);
@@ -94,6 +110,7 @@ struct TRINITY_DLL_DECL boss_overlordwyrmthalakAI : public ScriptedAI
             (SummonedCreature->AI())->AttackStart(target);
             Summoned = true;
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -101,6 +118,7 @@ CreatureAI* GetAI_boss_overlordwyrmthalak(Creature* pCreature)
 {
     return new boss_overlordwyrmthalakAI (pCreature);
 }
+
 void AddSC_boss_overlordwyrmthalak()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_pyroguard_emberseer.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_pyroguard_emberseer.cpp
index 36d0b38b304..9b9460181c2 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_pyroguard_emberseer.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_pyroguard_emberseer.cpp
@@ -13,48 +13,59 @@
  * along with 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 TRINITY_DLL_DECL boss_pyroguard_emberseerAI : public ScriptedAI
 {
     boss_pyroguard_emberseerAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 FireNova_Timer;
     uint32 FlameBuffet_Timer;
     uint32 PyroBlast_Timer;
+
     void Reset()
     {
         FireNova_Timer = 6000;
         FlameBuffet_Timer = 3000;
         PyroBlast_Timer = 14000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -63,6 +74,7 @@ struct TRINITY_DLL_DECL boss_pyroguard_emberseerAI : public ScriptedAI
             if (target) DoCast(target,SPELL_PYROBLAST);
             PyroBlast_Timer = 15000;
         }else PyroBlast_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -70,6 +82,7 @@ CreatureAI* GetAI_boss_pyroguard_emberseer(Creature* pCreature)
 {
     return new boss_pyroguard_emberseerAI (pCreature);
 }
+
 void AddSC_boss_pyroguard_emberseer()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_quartermaster_zigris.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_quartermaster_zigris.cpp
index 5c295d97f12..a8c560c71c7 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_quartermaster_zigris.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_quartermaster_zigris.cpp
@@ -13,49 +13,60 @@
  * along with 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 TRINITY_DLL_DECL boss_quatermasterzigrisAI : public ScriptedAI
 {
     boss_quatermasterzigrisAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Shoot_Timer;
     uint32 StunBomb_Timer;
     //uint32 HelingPotion_Timer;
+
     void Reset()
     {
         Shoot_Timer = 1000;
         StunBomb_Timer = 16000;
         //HelingPotion_Timer = 25000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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();
     }
 };
@@ -63,6 +74,7 @@ CreatureAI* GetAI_boss_quatermasterzigris(Creature* pCreature)
 {
     return new boss_quatermasterzigrisAI (pCreature);
 }
+
 void AddSC_boss_quatermasterzigris()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_rend_blackhand.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_rend_blackhand.cpp
index 28c1ffcf0d8..cd2aa32039e 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_rend_blackhand.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_rend_blackhand.cpp
@@ -13,54 +13,66 @@
  * along with 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 TRINITY_DLL_DECL boss_rend_blackhandAI : public ScriptedAI
 {
     boss_rend_blackhandAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 WhirlWind_Timer;
     uint32 Cleave_Timer;
     uint32 Thunderclap_Timer;
+
     void Reset()
     {
         WhirlWind_Timer = 20000;
         Cleave_Timer = 5000;
         Thunderclap_Timer = 9000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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();
     }
 };
@@ -68,6 +80,7 @@ CreatureAI* GetAI_boss_rend_blackhand(Creature* pCreature)
 {
     return new boss_rend_blackhandAI (pCreature);
 }
+
 void AddSC_boss_rend_blackhand()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_shadow_hunter_voshgajin.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_shadow_hunter_voshgajin.cpp
index 4525722f3e7..3e4be74b777 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_shadow_hunter_voshgajin.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_shadow_hunter_voshgajin.cpp
@@ -13,43 +13,54 @@
  * along with 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 TRINITY_DLL_DECL boss_shadowvoshAI : public ScriptedAI
 {
     boss_shadowvoshAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -58,12 +69,14 @@ struct TRINITY_DLL_DECL boss_shadowvoshAI : public ScriptedAI
             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();
     }
 };
@@ -71,6 +84,7 @@ CreatureAI* GetAI_boss_shadowvosh(Creature* pCreature)
 {
     return new boss_shadowvoshAI (pCreature);
 }
+
 void AddSC_boss_shadowvosh()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_the_beast.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_the_beast.cpp
index 971d4551806..0776c155562 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_the_beast.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_the_beast.cpp
@@ -13,42 +13,52 @@
  * along with 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 TRINITY_DLL_DECL boss_thebeastAI : public ScriptedAI
 {
     boss_thebeastAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Flamebreak_Timer;
     uint32 Immolate_Timer;
     uint32 TerrifyingRoar_Timer;
+
     void Reset()
     {
         Flamebreak_Timer = 12000;
         Immolate_Timer = 3000;
         TerrifyingRoar_Timer = 23000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -57,12 +67,14 @@ struct TRINITY_DLL_DECL boss_thebeastAI : public ScriptedAI
             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();
     }
 };
@@ -70,6 +82,7 @@ CreatureAI* GetAI_boss_thebeast(Creature* pCreature)
 {
     return new boss_thebeastAI (pCreature);
 }
+
 void AddSC_boss_thebeast()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_warmaster_voone.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_warmaster_voone.cpp
index 428c570d086..26fe20f8b05 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_warmaster_voone.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackrock_spire/boss_warmaster_voone.cpp
@@ -13,28 +13,34 @@
  * along with 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 TRINITY_DLL_DECL boss_warmastervooneAI : public ScriptedAI
 {
     boss_warmastervooneAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Snapkick_Timer;
     uint32 Cleave_Timer;
     uint32 Uppercut_Timer;
     uint32 MortalStrike_Timer;
     uint32 Pummel_Timer;
     uint32 ThrowAxe_Timer;
+
     void Reset()
     {
         Snapkick_Timer = 8000;
@@ -44,50 +50,59 @@ struct TRINITY_DLL_DECL boss_warmastervooneAI : public ScriptedAI
         Pummel_Timer = 32000;
         ThrowAxe_Timer = 1000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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();
     }
 };
@@ -95,6 +110,7 @@ CreatureAI* GetAI_boss_warmastervoone(Creature* pCreature)
 {
     return new boss_warmastervooneAI (pCreature);
 }
+
 void AddSC_boss_warmastervoone()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_broodlord_lashlayer.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_broodlord_lashlayer.cpp
index a6842af41c0..71b9850454f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_broodlord_lashlayer.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_broodlord_lashlayer.cpp
@@ -13,26 +13,33 @@
  * along with 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 SAY_AGGRO               -1469000
 #define SAY_LEASH               -1469001
+
 #define SPELL_CLEAVE            26350
 #define SPELL_BLASTWAVE         23331
 #define SPELL_MORTALSTRIKE      24573
 #define SPELL_KNOCKBACK         25778
+
 struct TRINITY_DLL_DECL boss_broodlordAI : public ScriptedAI
 {
     boss_broodlordAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Cleave_Timer;
     uint32 BlastWave_Timer;
     uint32 MortalStrike_Timer;
     uint32 KnockBack_Timer;
+
     void Reset()
     {
         Cleave_Timer = 8000;                                //These times are probably wrong
@@ -40,43 +47,52 @@ struct TRINITY_DLL_DECL boss_broodlordAI : public ScriptedAI
         MortalStrike_Timer = 20000;
         KnockBack_Timer = 30000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //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 (DoGetThreat(m_creature->getVictim()))
                 DoModifyThreatPercent(m_creature->getVictim(),-50);
+
             KnockBack_Timer = 15000 + rand()%15000;
         }else KnockBack_Timer -= diff;
+
         if (EnterEvadeIfOutOfCombatArea(diff))
             DoScriptText(SAY_LEASH, m_creature);
+
         DoMeleeAttackIfReady();
     }
 };
@@ -84,6 +100,7 @@ CreatureAI* GetAI_boss_broodlord(Creature* pCreature)
 {
     return new boss_broodlordAI (pCreature);
 }
+
 void AddSC_boss_broodlord()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_chromaggus.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_chromaggus.cpp
index 9d492ce8460..b36b4afe7b1 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_chromaggus.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_chromaggus.cpp
@@ -13,15 +13,19 @@
  * along with 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"
+
 #define EMOTE_FRENZY                -1469002
 #define EMOTE_SHIMMER               -1469003
+
 //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%
@@ -30,11 +34,13 @@ EndScriptData */
 #define SPELL_SHADOW_VURNALBILTY    22279
 #define SPELL_NATURE_VURNALBILTY    22280
 #define SPELL_ARCANE_VURNALBILTY    22281
+
 #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
@@ -42,9 +48,12 @@ EndScriptData */
 #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
+
 struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
 {
     boss_chromaggusAI(Creature *c) : ScriptedAI(c)
@@ -73,6 +82,7 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
                 Breath1_Spell = SPELL_INCINERATE;
                 Breath2_Spell = SPELL_FROSTBURN;
                 break;
+
                 //B1 - TL
             case 4:
                 Breath1_Spell = SPELL_TIMELAPSE;
@@ -90,6 +100,7 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
                 Breath1_Spell = SPELL_TIMELAPSE;
                 Breath2_Spell = SPELL_FROSTBURN;
                 break;
+
                 //B1 - Acid
             case 8:
                 Breath1_Spell = SPELL_CORROSIVEACID;
@@ -107,6 +118,7 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
                 Breath1_Spell = SPELL_CORROSIVEACID;
                 Breath2_Spell = SPELL_FROSTBURN;
                 break;
+
                 //B1 - Ignite
             case 12:
                 Breath1_Spell = SPELL_IGNITEFLESH;
@@ -124,6 +136,7 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
                 Breath1_Spell = SPELL_IGNITEFLESH;
                 Breath2_Spell = SPELL_FROSTBURN;
                 break;
+
                 //B1 - Frost
             case 16:
                 Breath1_Spell = SPELL_FROSTBURN;
@@ -142,40 +155,50 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
                 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 EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
@@ -186,27 +209,33 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
                 case 3: spell = SPELL_NATURE_VURNALBILTY; break;
                 case 4: spell = SPELL_ARCANE_VURNALBILTY; break;
             }
+
             DoCast(m_creature,spell);
             CurrentVurln_Spell = spell;
+
             DoScriptText(EMOTE_SHIMMER, m_creature);
             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;
@@ -215,16 +244,20 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
                 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(); )
+
+            for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end();)
             {
                 Unit* pUnit = NULL;
                 pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid());
                 ++i;
+
                 if (pUnit)
                 {
                     //Cast affliction
                     DoCast(pUnit, SpellAfflict, true);
+
                     //Chromatic mutation if target is effected by all afflictions
                     if (pUnit->HasAura(SPELL_BROODAF_BLUE)
                         && pUnit->HasAura(SPELL_BROODAF_BLACK)
@@ -234,17 +267,21 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
                     {
                         //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)
                             pUnit->CastSpell(pUnit, 5, false);
                     }
                 }
             }
+
             Affliction_Timer = 10000;
         }else Affliction_Timer -= diff;
+
         //Frenzy_Timer
         if (Frenzy_Timer < diff)
         {
@@ -252,12 +289,14 @@ struct TRINITY_DLL_DECL boss_chromaggusAI : public ScriptedAI
             DoScriptText(EMOTE_FRENZY, m_creature);
             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();
     }
 };
@@ -265,6 +304,7 @@ CreatureAI* GetAI_boss_chromaggus(Creature* pCreature)
 {
     return new boss_chromaggusAI (pCreature);
 }
+
 void AddSC_boss_chromaggus()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_ebonroc.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_ebonroc.cpp
index aee7d02f33e..a09da22e398 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_ebonroc.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_ebonroc.cpp
@@ -13,24 +13,30 @@
  * along with 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 TRINITY_DLL_DECL boss_ebonrocAI : public ScriptedAI
 {
     boss_ebonrocAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowFlame_Timer;
     uint32 WingBuffet_Timer;
     uint32 ShadowOfEbonroc_Timer;
     uint32 Heal_Timer;
+
     void Reset()
     {
         ShadowFlame_Timer = 15000;                          //These times are probably wrong
@@ -38,32 +44,38 @@ struct TRINITY_DLL_DECL boss_ebonrocAI : public ScriptedAI
         ShadowOfEbonroc_Timer = 45000;
         Heal_Timer = 1000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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))
         {
             if (Heal_Timer < diff)
@@ -72,6 +84,7 @@ struct TRINITY_DLL_DECL boss_ebonrocAI : public ScriptedAI
                 Heal_Timer = 1000 + rand()%2000;
             }else Heal_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -79,6 +92,7 @@ CreatureAI* GetAI_boss_ebonroc(Creature* pCreature)
 {
     return new boss_ebonrocAI (pCreature);
 }
+
 void AddSC_boss_ebonroc()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_firemaw.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_firemaw.cpp
index 8692563f4e7..73d546e0a2c 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_firemaw.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_firemaw.cpp
@@ -13,56 +13,69 @@
  * along with 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 TRINITY_DLL_DECL boss_firemawAI : public ScriptedAI
 {
     boss_firemawAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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 (DoGetThreat(m_creature->getVictim()))
                 DoModifyThreatPercent(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();
     }
 };
@@ -70,6 +83,7 @@ CreatureAI* GetAI_boss_firemaw(Creature* pCreature)
 {
     return new boss_firemawAI (pCreature);
 }
+
 void AddSC_boss_firemaw()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_flamegor.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_flamegor.cpp
index 6cf1f43b485..622ba445306 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_flamegor.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_flamegor.cpp
@@ -13,51 +13,64 @@
  * along with 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 EMOTE_FRENZY            -1469031
+
 #define SPELL_SHADOWFLAME        22539
 #define SPELL_WINGBUFFET         23339
 #define SPELL_FRENZY             23342                      //This spell periodically triggers fire nova
+
 struct TRINITY_DLL_DECL boss_flamegorAI : public ScriptedAI
 {
     boss_flamegorAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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 (DoGetThreat(m_creature->getVictim()))
                 DoModifyThreatPercent(m_creature->getVictim(),-75);
+
             WingBuffet_Timer = 25000;
         }else WingBuffet_Timer -= diff;
+
         //Frenzy_Timer
         if (Frenzy_Timer < diff)
         {
@@ -65,6 +78,7 @@ struct TRINITY_DLL_DECL boss_flamegorAI : public ScriptedAI
             DoCast(m_creature,SPELL_FRENZY);
             Frenzy_Timer = 8000 + (rand()%2000);
         }else Frenzy_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -72,6 +86,7 @@ CreatureAI* GetAI_boss_flamegor(Creature* pCreature)
 {
     return new boss_flamegorAI (pCreature);
 }
+
 void AddSC_boss_flamegor()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_nefarian.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_nefarian.cpp
index 0f0d4d7d613..b0d2d01494e 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_nefarian.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_nefarian.cpp
@@ -13,19 +13,23 @@
  * along with 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: 80
 SDComment: Some issues with class calls effecting more than one class
 SDCategory: Blackwing Lair
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SAY_AGGRO               -1469007
 #define SAY_XHEALTH             -1469008
 #define SAY_SHADOWFLAME         -1469009
 #define SAY_RAISE_SKELETONS     -1469010
 #define SAY_SLAY                -1469011
 #define SAY_DEATH               -1469012
+
 #define SAY_MAGE                -1469013
 #define SAY_WARRIOR             -1469014
 #define SAY_DRUID               -1469015
@@ -35,6 +39,7 @@ EndScriptData */
 #define SAY_WARLOCK             -1469019
 #define SAY_HUNTER              -1469020
 #define SAY_ROGUE               -1469021
+
 #define SPELL_SHADOWFLAME_INITIAL   22972
 #define SPELL_SHADOWFLAME           22539
 #define SPELL_BELLOWINGROAR         22686
@@ -42,6 +47,7 @@ EndScriptData */
 #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
@@ -51,9 +57,11 @@ EndScriptData */
 #define SPELL_WARLOCK               23427                   //infernals
 #define SPELL_HUNTER                23436                   //bow broke
 #define SPELL_ROGUE                 23414                   //Paralise
+
 struct TRINITY_DLL_DECL boss_nefarianAI : public ScriptedAI
 {
     boss_nefarianAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowFlame_Timer;
     uint32 BellowingRoar_Timer;
     uint32 VeilOfShadow_Timer;
@@ -61,7 +69,9 @@ struct TRINITY_DLL_DECL boss_nefarianAI : public ScriptedAI
     uint32 TailLash_Timer;
     uint32 ClassCall_Timer;
     bool Phase3;
+
     uint32 DespawnTimer;
+
     void Reset()
     {
         ShadowFlame_Timer = 12000;                          //These times are probably wrong
@@ -71,24 +81,31 @@ struct TRINITY_DLL_DECL boss_nefarianAI : public ScriptedAI
         TailLash_Timer = 10000;
         ClassCall_Timer = 35000;                            //35-40 seconds
         Phase3 = false;
+
         DespawnTimer = 5000;
     }
+
     void KilledUnit(Unit* Victim)
     {
         if (rand()%5)
             return;
+
         DoScriptText(SAY_SLAY, m_creature, Victim);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_XHEALTH,SAY_AGGRO,SAY_SHADOWFLAME), m_creature);
+
         DoCast(who,SPELL_SHADOWFLAME_INITIAL);
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(DespawnTimer < diff)
@@ -97,45 +114,54 @@ struct TRINITY_DLL_DECL boss_nefarianAI : public ScriptedAI
                 m_creature->ForcedDespawn();
             DespawnTimer = 5000;
         }else DespawnTimer -= diff;
+
         if (!UpdateVictim())
             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:
@@ -175,14 +201,17 @@ struct TRINITY_DLL_DECL boss_nefarianAI : public ScriptedAI
                     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;
             DoScriptText(SAY_RAISE_SKELETONS, m_creature);
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -190,6 +219,7 @@ CreatureAI* GetAI_boss_nefarian(Creature* pCreature)
 {
     return new boss_nefarianAI (pCreature);
 }
+
 void AddSC_boss_nefarian()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_razorgore.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_razorgore.cpp
index e88b479d43c..5496448b6ed 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_razorgore.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_razorgore.cpp
@@ -13,29 +13,37 @@
  * along with 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 (Grethok the Controller)
 SDCategory: Blackwing Lair
 EndScriptData */
+
 #include "precompiled.h"
+
 //Razorgore Phase 2 Script
+
 #define SAY_EGGS_BROKEN1        -1469022
 #define SAY_EGGS_BROKEN2        -1469023
 #define SAY_EGGS_BROKEN3        -1469024
 #define SAY_DEATH               -1469025
+
 #define SPELL_CLEAVE            22540
 #define SPELL_WARSTOMP          24375
 #define SPELL_FIREBALLVOLLEY    22425
 #define SPELL_CONFLAGRATION     23023
+
 struct TRINITY_DLL_DECL boss_razorgoreAI : public ScriptedAI
 {
     boss_razorgoreAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Cleave_Timer;
     uint32 WarStomp_Timer;
     uint32 FireballVolley_Timer;
     uint32 Conflagration_Timer;
+
     void Reset()
     {
         Cleave_Timer = 15000;                               //These times are probably wrong
@@ -43,45 +51,55 @@ struct TRINITY_DLL_DECL boss_razorgoreAI : public ScriptedAI
         FireballVolley_Timer = 7000;
         Conflagration_Timer = 12000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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 (DoGetThreat(m_creature->getVictim()))
             //DoModifyThreatPercent(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() && m_creature->getVictim()->HasAura(SPELL_CONFLAGRATION))
         {
@@ -90,13 +108,16 @@ struct TRINITY_DLL_DECL boss_razorgoreAI : public ScriptedAI
             if (target)
                 m_creature->TauntApply(target);
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_razorgore(Creature* pCreature)
 {
     return new boss_razorgoreAI (pCreature);
 }
+
 void AddSC_boss_razorgore()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp
index 9fb1f05d24e..ac9a0f6aaaa 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp
@@ -13,25 +13,31 @@
  * along with 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 SAY_LINE1           -1469026
 #define SAY_LINE2           -1469027
 #define SAY_LINE3           -1469028
 #define SAY_HALFLIFE        -1469029
 #define SAY_KILLTARGET      -1469030
+
 #define GOSSIP_ITEM         "Start Event "
+
 #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
+
 struct TRINITY_DLL_DECL boss_vaelAI : public ScriptedAI
 {
     boss_vaelAI(Creature *c) : ScriptedAI(c)
@@ -40,6 +46,7 @@ struct TRINITY_DLL_DECL boss_vaelAI : public ScriptedAI
         c->setFaction(35);
         c->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     uint64 PlayerGUID;
     uint32 SpeachTimer;
     uint32 SpeachNum;
@@ -51,6 +58,7 @@ struct TRINITY_DLL_DECL boss_vaelAI : public ScriptedAI
     uint32 TailSwipe_Timer;
     bool HasYelled;
     bool DoingSpeach;
+
     void Reset()
     {
         PlayerGUID = 0;
@@ -65,29 +73,37 @@ struct TRINITY_DLL_DECL boss_vaelAI : public ScriptedAI
         HasYelled = false;
         DoingSpeach = false;
     }
+
     void BeginSpeach(Unit* target)
     {
         //Stand up and begin speach
         PlayerGUID = target->GetGUID();
+
         //10 seconds
         DoScriptText(SAY_LINE1, m_creature);
+
         SpeachTimer = 10000;
         SpeachNum = 0;
         DoingSpeach = true;
+
         m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (rand()%5)
             return;
+
         DoScriptText(SAY_KILLTARGET, m_creature, victim);
     }
+
     void EnterCombat(Unit *who)
     {
         DoCast(m_creature,SPELL_ESSENCEOFTHERED);
         DoZoneInCombat();
         m_creature->SetHealth(int(m_creature->GetMaxHealth()*.3));
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Speach
@@ -122,31 +138,37 @@ struct TRINITY_DLL_DECL boss_vaelAI : public ScriptedAI
                 }
             }else SpeachTimer -= diff;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         // Yell if hp lower than 15%
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 15 && !HasYelled)
         {
             DoScriptText(SAY_HALFLIFE, m_creature);
             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
             {
@@ -158,22 +180,27 @@ struct TRINITY_DLL_DECL boss_vaelAI : public ScriptedAI
             }
             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)
         {
@@ -182,11 +209,14 @@ struct TRINITY_DLL_DECL boss_vaelAI : public ScriptedAI
             {
             DoCast(m_creature->getVictim(),SPELL_TAILSWIPE);
             }*/
+
             TailSwipe_Timer = 20000;
         }else TailSwipe_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 void SendDefaultMenu_boss_vael(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)               //Fight time
@@ -195,22 +225,28 @@ void SendDefaultMenu_boss_vael(Player* pPlayer, Creature* pCreature, uint32 uiAc
         CAST_AI(boss_vaelAI, pCreature->AI())->BeginSpeach(pPlayer);
     }
 }
+
 bool GossipSelect_boss_vael(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiSender == GOSSIP_SENDER_MAIN)
         SendDefaultMenu_boss_vael(pPlayer, pCreature, uiAction);
+
     return true;
 }
+
 bool GossipHello_boss_vael(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM        , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
     pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID());
+
     return true;
 }
+
 CreatureAI* GetAI_boss_vael(Creature* pCreature)
 {
     return new boss_vaelAI (pCreature);
 }
+
 void AddSC_boss_vael()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_victor_nefarius.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_victor_nefarius.cpp
index d0c8b510124..4b7fcecf683 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_victor_nefarius.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/boss_victor_nefarius.cpp
@@ -13,40 +13,51 @@
  * along with 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        -1469004
 #define SAY_GAMESBEGIN_2        -1469005
 #define SAY_VAEL_INTRO          -1469006                    //when he corrupts Vaelastrasz
+
 #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
@@ -55,6 +66,7 @@ EndScriptData */
 //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 TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
 {
     boss_victor_nefariusAI(Creature *c) : ScriptedAI(c)
@@ -145,6 +157,7 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
                 break;
         }
     }
+
     uint32 SpawnedAdds;
     uint32 AddSpawnTimer;
     uint32 ShadowBoltTimer;
@@ -155,6 +168,7 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
     uint32 DrakType2;
     uint64 NefarianGUID;
     uint32 NefCheckTime;
+
     void Reset()
     {
         SpawnedAdds = 0;
@@ -164,16 +178,20 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
         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)
     {
         DoScriptText(SAY_GAMESBEGIN_2, m_creature);
+
         //Trinity::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));
@@ -184,22 +202,27 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         AttackStart(target);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         //We simply use this function to find players until we can use pMap->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 (!UpdateVictim())
             return;
+
         //Only do this if we haven't spawned nef yet
         if (SpawnedAdds < 42)
         {
@@ -210,8 +233,10 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
                 target = SelectUnit(SELECT_TARGET_RANDOM,0);
                 if (target)
                     DoCast(target,SPELL_SHADOWBOLT);
+
                 ShadowBoltTimer = 3000 + (rand()%7000);
             }else ShadowBoltTimer -= diff;
+
             //FearTimer
             if (FearTimer < diff)
             {
@@ -219,8 +244,10 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
                 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)
             {
@@ -228,11 +255,14 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
                 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);
@@ -241,11 +271,14 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
                     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);
@@ -255,20 +288,26 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
                     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 Trinity log but no real issues)
                     DoTeleportTo(HIDE_X,HIDE_Y,HIDE_Z);
                     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);
@@ -282,6 +321,7 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
                     }
                     else error_log("TSCR: Blackwing Lair: Unable to spawn nefarian properly.");
                 }
+
                 AddSpawnTimer = 4000;
             }else AddSpawnTimer -= diff;
         }
@@ -290,6 +330,7 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
             if (NefCheckTime < diff)
             {
                 Unit* Nefarian = Unit::GetCreature((*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())
@@ -297,21 +338,25 @@ struct TRINITY_DLL_DECL boss_victor_nefariusAI : public ScriptedAI
                     NefarianGUID = 0;
                     m_creature->ForcedDespawn();
                 }
+
                 NefCheckTime = 2000;
             }else NefCheckTime -= diff;
         }
     }
 };
+
 CreatureAI* GetAI_boss_victor_nefarius(Creature* pCreature)
 {
     return new boss_victor_nefariusAI (pCreature);
 }
+
 bool GossipHello_boss_victor_nefarius(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1 , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     pPlayer->SEND_GOSSIP_MENU(7134, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_boss_victor_nefarius(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -332,9 +377,11 @@ bool GossipSelect_boss_victor_nefarius(Player* pPlayer, Creature* pCreature, uin
     }
     return true;
 }
+
 void AddSC_boss_victor_nefarius()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_victor_nefarius";
     newscript->GetAI = &GetAI_boss_victor_nefarius;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/instance_blackwing_lair.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/instance_blackwing_lair.cpp
index 781ae028c9f..97bf717589a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/instance_blackwing_lair.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blackwing_lair/instance_blackwing_lair.cpp
@@ -13,11 +13,13 @@
 * along 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_Blackwing_Lair
 SD%Complete: 0
 SDComment:
 SDCategory: Blackwing Lair
 EndScriptData */
+
 #include "precompiled.h"
 
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/blasted_lands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/blasted_lands.cpp
index 42fdbb98c60..97e10f59e59 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/blasted_lands.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/blasted_lands.cpp
@@ -13,31 +13,41 @@
  * along 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* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(3628) == QUEST_STATUS_INCOMPLETE && pPlayer->HasItemCount(10757, 1))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_USHER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_deathly_usher(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
@@ -45,32 +55,43 @@ bool GossipSelect_npc_deathly_usher(Player* pPlayer, Creature* pCreature, uint32
         pPlayer->CLOSE_GOSSIP_MENU();
         pCreature->CastSpell(pPlayer, SPELL_TELEPORT_SINGLE, true);
     }
+
     return true;
 }
+
 /*######
 ## npc_fallen_hero_of_horde
 ######*/
 #define GOSSIP_H_F1 "Why are you here?"
 #define GOSSIP_H_F2 "Continue story..."
+
 #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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(2784) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_H_F1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     if (pPlayer->GetQuestStatus(2801) == QUEST_STATUS_INCOMPLETE && pPlayer->GetTeam() == HORDE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_H_F2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+
     if (pPlayer->GetQuestStatus(2801) == QUEST_STATUS_INCOMPLETE && pPlayer->GetTeam() == ALLIANCE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_H_F1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_fallen_hero_of_horde(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -89,6 +110,7 @@ bool GossipSelect_npc_fallen_hero_of_horde(Player* pPlayer, Creature* pCreature,
                 pPlayer->SEND_GOSSIP_MENU(1411, pCreature->GetGUID());
             }
             break;
+
         case GOSSIP_ACTION_INFO_DEF+2:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_FALLEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21);
             pPlayer->SEND_GOSSIP_MENU(1451, pCreature->GetGUID());
@@ -120,14 +142,17 @@ bool GossipSelect_npc_fallen_hero_of_horde(Player* pPlayer, Creature* pCreature,
     }
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_fallen_hero_of_horde";
     newscript->pGossipHello =  &GossipHello_npc_fallen_hero_of_horde;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/boss_kruul.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/boss_kruul.cpp
index e85d7ed2ce2..267bbdefe95 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/boss_kruul.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/boss_kruul.cpp
@@ -13,13 +13,16 @@
  * along with 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
@@ -27,9 +30,11 @@ EndScriptData */
 #define SPELL_VOIDBOLT              21066
 #define SPELL_RAGE                  21340
 #define SPELL_CAPTURESOUL           21054
+
 struct TRINITY_DLL_DECL boss_kruulAI : public ScriptedAI
 {
     boss_kruulAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowVolley_Timer;
     uint32 Cleave_Timer;
     uint32 ThunderClap_Timer;
@@ -41,6 +46,7 @@ struct TRINITY_DLL_DECL boss_kruulAI : public ScriptedAI
     int RandX;
     int RandY;
     Creature* Summoned;
+
     void Reset()
     {
         ShadowVolley_Timer = 10000;
@@ -51,14 +57,18 @@ struct TRINITY_DLL_DECL boss_kruulAI : public ScriptedAI
         Rage_Timer = 60000;                                 //Cast rage after 1 minute
         Hound_Timer = 8000;
     }
+
     void EnterCombat(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;
@@ -79,11 +89,13 @@ struct TRINITY_DLL_DECL boss_kruulAI : public ScriptedAI
         if (Summoned)
             (Summoned->AI())->AttackStart(victim);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //ShadowVolley_Timer
         if (ShadowVolley_Timer < diff)
         {
@@ -91,8 +103,10 @@ struct TRINITY_DLL_DECL boss_kruulAI : public ScriptedAI
             {
                 DoCast(m_creature->getVictim(),SPELL_SHADOWVOLLEY);
             }
+
             ShadowVolley_Timer = 5000;
         }else ShadowVolley_Timer -= diff;
+
         //Cleave_Timer
         if (Cleave_Timer < diff)
         {
@@ -100,8 +114,10 @@ struct TRINITY_DLL_DECL boss_kruulAI : public ScriptedAI
             {
                 DoCast(m_creature->getVictim(),SPELL_CLEAVE);
             }
+
             Cleave_Timer = 10000;
         }else Cleave_Timer -= diff;
+
         //ThunderClap_Timer
         if (ThunderClap_Timer < diff)
         {
@@ -109,14 +125,17 @@ struct TRINITY_DLL_DECL boss_kruulAI : public ScriptedAI
             {
                 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)
         {
@@ -124,22 +143,27 @@ struct TRINITY_DLL_DECL boss_kruulAI : public ScriptedAI
             {
                 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();
     }
 };
@@ -147,6 +171,7 @@ CreatureAI* GetAI_boss_kruul(Creature* pCreature)
 {
     return new boss_kruulAI (pCreature);
 }
+
 void AddSC_boss_kruul()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/burning_steppes.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/burning_steppes.cpp
index 38a0a8052c6..d1b4c778a1f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/burning_steppes.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/burning_steppes.cpp
@@ -13,19 +13,24 @@
  * along 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
 ######*/
+
 #define GOSSIP_HELLO    "Official buisness, John. I need some information about Marsha Windsor. Tell me about the last time you saw him."
 #define GOSSIP_SELECT1  "So what did you do?"
 #define GOSSIP_SELECT2  "Start making sense, dwarf. I don't want to have anything to do with your cracker, your pappy, or any sort of 'discreditin'."
@@ -38,10 +43,13 @@ EndContentData */
 #define GOSSIP_SELECT9  "300? So the Dark Irons killed him and dragged him into the Depths?"
 #define GOSSIP_SELECT10 "Ahh... Ironfoe"
 #define GOSSIP_SELECT11 "Thanks, Ragged John. Your story was very uplifting and informative"
+
 struct TRINITY_DLL_DECL npc_ragged_johnAI : public ScriptedAI
 {
     npc_ragged_johnAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
+
     void MoveInLineOfSight(Unit *who)
     {
         if (who->HasAura(16468))
@@ -52,23 +60,30 @@ struct TRINITY_DLL_DECL npc_ragged_johnAI : public ScriptedAI
                 CAST_PLR(who)->AreaExploredOrEventHappens(4866);
             }
         }
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void EnterCombat(Unit *who) {}
 };
+
 CreatureAI* GetAI_npc_ragged_john(Creature* pCreature)
 {
     return new npc_ragged_johnAI (pCreature);
 }
+
 bool GossipHello_npc_ragged_john(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(4224) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(2713, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_ragged_john(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -124,9 +139,11 @@ bool GossipSelect_npc_ragged_john(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 void AddSC_burning_steppes()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_ragged_john";
     newscript->GetAI = &GetAI_npc_ragged_john;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/deadmines/deadmines.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/deadmines/deadmines.cpp
index c2a052917f6..d2544cc881f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/deadmines/deadmines.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/deadmines/deadmines.cpp
@@ -13,29 +13,36 @@
  * along 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"
 #include "def_deadmines.h"
 #include "Spell.h"
+
 #define SOUND_CANNONFIRE    1400
 #define SOUND_DESTROYDOOR    3079
 #define SAY_MR_SMITE_ALARM1 "You there, check out that noise!"
 #define SOUND_MR_SMITE_ALARM1  5775
 #define SAY_MR_SMITE_ALARM2 "We're under attack! A vast, ye swabs! Repel the invaders!"
 #define SOUND_MR_SMITE_ALARM2  5777
+
 #define GO_IRONCLAD_DOOR    16397
 #define GO_DEFIAS_CANNON    16398
 #define GO_DOOR_LEVER        101833
+
 #define CANNON_BLAST_TIMER 3000
 #define PIRATES_DELAY_TIMER 1000
+
 struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance
 {
     instance_deadmines(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     GameObject* IronCladDoor;
     GameObject* DefiasCannon;
     GameObject* DoorLever;
@@ -45,6 +52,7 @@ struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance
     uint32 State;
     uint32 CannonBlast_Timer;
     uint32 PiratesDelay_Timer;
+
     void Initialize()
     {
         IronCladDoor = NULL;
@@ -52,10 +60,12 @@ struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance
         DoorLever =    NULL;
         State = CANNON_NOT_USED;
     }
+
     virtual void Update(uint32 diff)
     {
         if (!IronCladDoor || !DefiasCannon || !DoorLever)
             return;
+
         switch(State)
         {
             case CANNON_GUNPOWDER_USED:
@@ -90,39 +100,47 @@ struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance
                 break;
         }
     }
+
     void SummonCreatures()
     {
         DefiasPirate1 = IronCladDoor->SummonCreature(657,IronCladDoor->GetPositionX() - 2,IronCladDoor->GetPositionY()-7,IronCladDoor->GetPositionZ(), 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
         DefiasPirate2 = IronCladDoor->SummonCreature(657,IronCladDoor->GetPositionX() + 3,IronCladDoor->GetPositionY()-6,IronCladDoor->GetPositionZ(), 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
         DefiasCompanion = IronCladDoor->SummonCreature(3450,IronCladDoor->GetPositionX() + 2,IronCladDoor->GetPositionY()-6,IronCladDoor->GetPositionZ(), 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
     }
+
     void MoveCreaturesInside()
     {
         if (!DefiasPirate1 || !DefiasPirate2 || !DefiasCompanion)
             return;
+
         MoveCreatureInside(DefiasPirate1);
         MoveCreatureInside(DefiasPirate2);
         MoveCreatureInside(DefiasCompanion);
     }
+
     void MoveCreatureInside(Creature* pCreature)
     {
         pCreature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
         pCreature->GetMotionMaster()->MovePoint(0, -102.7,-655.9, pCreature->GetPositionZ());
     }
+
     void ShootCannon()
     {
         DefiasCannon->SetGoState(GO_STATE_ACTIVE);
         DoPlaySound(DefiasCannon, SOUND_CANNONFIRE);
     }
+
     void BlastOutDoor()
     {
         IronCladDoor->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE);
         DoPlaySound(IronCladDoor, SOUND_DESTROYDOOR);
     }
+
     void LeverStucked()
     {
         DoorLever->SetUInt32Value(GAMEOBJECT_FLAGS, 4);
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -138,6 +156,7 @@ struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance
                 break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         if (type == EVENT_STATE)
@@ -146,12 +165,14 @@ struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance
                 State=data;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         if (type == EVENT_STATE)
             return State;
         return 0;
     }
+
     void DoPlaySound(GameObject* unit, uint32 sound)
     {
         WorldPacket data(4);
@@ -159,6 +180,7 @@ struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance
         data << uint32(sound);
         unit->SendMessageToSet(&data,false);
     }
+
     void DoPlaySoundCreature(Unit* unit, uint32 sound)
     {
         WorldPacket data(4);
@@ -167,12 +189,15 @@ struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance
         unit->SendMessageToSet(&data,false);
     }
 };
+
 /*#####
 # item_Defias_Gunpowder
 #####*/
+
 bool ItemUse_item_defias_gunpowder(Player* pPlayer, Item* _Item, SpellCastTargets const& targets)
 {
     ScriptedInstance *pInstance = pPlayer->GetInstanceData();
+
     if (!pInstance)
     {
         pPlayer->GetSession()->SendNotification("Instance script not initialized");
@@ -185,13 +210,16 @@ bool ItemUse_item_defias_gunpowder(Player* pPlayer, Item* _Item, SpellCastTarget
     {
         pInstance->SetData(EVENT_STATE, CANNON_GUNPOWDER_USED);
     }
+
     pPlayer->DestroyItemCount(_Item->GetEntry(), 1, true);
     return true;
 }
+
 InstanceData* GetInstanceData_instance_deadmines(Map* pMap)
 {
     return new instance_deadmines(pMap);
 }
+
 void AddSC_instance_deadmines()
 {
     Script *newscript;
@@ -199,6 +227,7 @@ void AddSC_instance_deadmines()
     newscript->Name = "instance_deadmines";
     newscript->GetInstanceData = &GetInstanceData_instance_deadmines;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_defias_gunpowder";
     newscript->pItemUse = &ItemUse_item_defias_gunpowder;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/deadmines/def_deadmines.h b/src/bindings/scripts/scripts/eastern_kingdoms/deadmines/def_deadmines.h
index faa55500209..9b535a9fd80 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/deadmines/def_deadmines.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/deadmines/def_deadmines.h
@@ -1,11 +1,14 @@
 #ifndef DEF_DEADMINES_H
 #define DEF_DEADMINES_H
+
 #include "precompiled.h"
+
 #define CANNON_NOT_USED 1
 #define CANNON_GUNPOWDER_USED 2
 #define CANNON_BLAST_INITIATED 3
 #define PIRATES_ATTACK 4
 #define EVENT_DONE 5
+
 #define EVENT_STATE 1
 #endif
 
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/dun_morogh.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/dun_morogh.cpp
index 488807a0109..f2d589d5302 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/dun_morogh.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/dun_morogh.cpp
@@ -13,26 +13,34 @@
  * along 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
 ######*/
+
 // signed for 6172
 #define SAY_HEAL -1000280
+
 struct TRINITY_DLL_DECL npc_narm_faulkAI : public ScriptedAI
 {
     uint32 lifeTimer;
     bool spellHit;
+
     npc_narm_faulkAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         lifeTimer = 120000;
@@ -40,13 +48,16 @@ struct TRINITY_DLL_DECL npc_narm_faulkAI : public ScriptedAI
         m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
         spellHit = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         return;
     }
+
     void UpdateAI(const uint32 diff)
     {
        if (m_creature->IsStandState())
@@ -60,6 +71,7 @@ struct TRINITY_DLL_DECL npc_narm_faulkAI : public ScriptedAI
                 lifeTimer -= diff;
         }
     }
+
     void SpellHit(Unit *Hitter, const SpellEntry *Spellkind)
     {
         if (Spellkind->Id == 8593 && !spellHit)
@@ -72,14 +84,17 @@ struct TRINITY_DLL_DECL npc_narm_faulkAI : public ScriptedAI
             spellHit = true;
         }
     }
+
 };
 CreatureAI* GetAI_npc_narm_faulk(Creature* pCreature)
 {
     return new npc_narm_faulkAI (pCreature);
 }
+
 void AddSC_dun_morogh()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_narm_faulk";
     newscript->GetAI = &GetAI_npc_narm_faulk;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/duskwood.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/duskwood.cpp
index e97094ecc23..394f652d8ff 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/duskwood.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/duskwood.cpp
@@ -13,16 +13,20 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Duskwood
 SD%Complete: 100
 SDComment: Quest Support:8735
 SDCategory: Duskwood
 EndScriptData */
+
 #include "precompiled.h"
+
 /*######
 # at_twilight_grove
 ######*/
+
 bool AreaTrigger_at_twilight_grove(Player* pPlayer, AreaTriggerEntry *at)
 {
     if (pPlayer->HasQuestForItem(21149))
@@ -41,18 +45,23 @@ bool AreaTrigger_at_twilight_grove(Player* pPlayer, AreaTriggerEntry *at)
     }
     return false;
 };
+
 /*######
 # boss_twilight_corrupter
 ######*/
+
 #define SPELL_SOUL_CORRUPTION 25805
 #define SPELL_CREATURE_OF_NIGHTMARE 25806
 #define SPELL_LEVEL_UP 24312
+
 struct TRINITY_DLL_DECL boss_twilight_corrupterAI : public ScriptedAI
 {
     boss_twilight_corrupterAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 SoulCorruption_Timer;
     uint32 CreatureOfNightmare_Timer;
     uint8 KillCount;
+
     void Reset()
     {
         SoulCorruption_Timer = 15000;
@@ -63,12 +72,14 @@ struct TRINITY_DLL_DECL boss_twilight_corrupterAI : public ScriptedAI
     {
         m_creature->MonsterYell("The Nightmare cannot be stopped!",0,m_creature->GetGUID());
     }
+
     void KilledUnit(Unit* victim)
     {
         if (victim->GetTypeId() == TYPEID_PLAYER)
         {
             ++KillCount;
             m_creature->MonsterTextEmote("Twilight Corrupter squeezes the last bit of life out of $N and swallows their soul.", victim->GetGUID(),true);
+
             if (KillCount == 3)
             {
                 DoCast(m_creature, SPELL_LEVEL_UP, true);
@@ -76,6 +87,7 @@ struct TRINITY_DLL_DECL boss_twilight_corrupterAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(!UpdateVictim())
@@ -97,13 +109,16 @@ CreatureAI* GetAI_boss_twilight_corrupter(Creature* pCreature)
 {
     return new boss_twilight_corrupterAI (pCreature);
 }
+
 void AddSC_duskwood()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_twilight_corrupter";
     newscript->GetAI = &GetAI_boss_twilight_corrupter;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "at_twilight_grove";
     newscript->pAreaTrigger = &AreaTrigger_at_twilight_grove;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/eastern_plaguelands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/eastern_plaguelands.cpp
index b7ae3722615..c801398b830 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/eastern_plaguelands.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/eastern_plaguelands.cpp
@@ -13,73 +13,94 @@
  * along 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 TRINITY_DLL_DECL mobs_ghoul_flayerAI : public ScriptedAI
 {
     mobs_ghoul_flayerAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() { }
+
     void EnterCombat(Unit* who) { }
+
     void JustDied(Unit* Killer)
     {
         if (Killer->GetTypeId() == TYPEID_PLAYER)
             m_creature->SummonCreature(11064, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 60000);
     }
 };
+
 CreatureAI* GetAI_mobs_ghoul_flayer(Creature* pCreature)
 {
     return new mobs_ghoul_flayerAI (pCreature);
 }
+
 /*######
 ## npc_augustus_the_touched
 ######*/
+
 bool GossipHello_npc_augustus_the_touched(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor() && pPlayer->GetQuestRewardStatus(6164))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_augustus_the_touched(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
     return true;
 }
+
 /*######
 ## npc_darrowshire_spirit
 ######*/
+
 #define SPELL_SPIRIT_SPAWNIN    17321
+
 struct TRINITY_DLL_DECL npc_darrowshire_spiritAI : public ScriptedAI
 {
     npc_darrowshire_spiritAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         DoCast(m_creature,SPELL_SPIRIT_SPAWNIN);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void EnterCombat(Unit *who) { }
+
 };
 CreatureAI* GetAI_npc_darrowshire_spirit(Creature* pCreature)
 {
     return new npc_darrowshire_spiritAI (pCreature);
 }
+
 bool GossipHello_npc_darrowshire_spirit(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->SEND_GOSSIP_MENU(3873, pCreature->GetGUID());
@@ -87,22 +108,29 @@ bool GossipHello_npc_darrowshire_spirit(Player* pPlayer, Creature* pCreature)
     pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     return true;
 }
+
 /*######
 ## npc_tirion_fordring
 ######*/
+
 #define GOSSIP_HELLO    "I am ready to hear your tale, Tirion."
 #define GOSSIP_SELECT1  "Thank you, Tirion.  What of your identity?"
 #define GOSSIP_SELECT2  "That is terrible."
 #define GOSSIP_SELECT3  "I will, Tirion."
+
 bool GossipHello_npc_tirion_fordring(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(5742) == QUEST_STATUS_INCOMPLETE && pPlayer->getStandState() == UNIT_STAND_STATE_SIT)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_tirion_fordring(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -126,23 +154,28 @@ bool GossipSelect_npc_tirion_fordring(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 void AddSC_eastern_plaguelands()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mobs_ghoul_flayer";
     newscript->GetAI = &GetAI_mobs_ghoul_flayer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_augustus_the_touched";
     newscript->pGossipHello = &GossipHello_npc_augustus_the_touched;
     newscript->pGossipSelect = &GossipSelect_npc_augustus_the_touched;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_darrowshire_spirit";
     newscript->GetAI = &GetAI_npc_darrowshire_spirit;
     newscript->pGossipHello = &GossipHello_npc_darrowshire_spirit;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_tirion_fordring";
     newscript->pGossipHello =  &GossipHello_npc_tirion_fordring;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/elwynn_forest.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/elwynn_forest.cpp
index ea69f408e94..40f0ceecd09 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/elwynn_forest.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/elwynn_forest.cpp
@@ -13,25 +13,33 @@
  * along 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 -1000280
+
 struct TRINITY_DLL_DECL npc_henze_faulkAI : public ScriptedAI
 {
     uint32 lifeTimer;
     bool spellHit;
+
     npc_henze_faulkAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         lifeTimer = 120000;
@@ -39,13 +47,16 @@ struct TRINITY_DLL_DECL npc_henze_faulkAI : public ScriptedAI
         m_creature->SetStandState(UNIT_STAND_STATE_DEAD);   // lay down
         spellHit = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         return;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (m_creature->IsStandState())
@@ -59,6 +70,7 @@ struct TRINITY_DLL_DECL npc_henze_faulkAI : public ScriptedAI
                 lifeTimer -= diff;
         }
     }
+
     void SpellHit(Unit *Hitter, const SpellEntry *Spellkind)
     {
         if (Spellkind->Id == 8593 && !spellHit)
@@ -71,14 +83,17 @@ struct TRINITY_DLL_DECL npc_henze_faulkAI : public ScriptedAI
             spellHit = true;
         }
     }
+
 };
 CreatureAI* GetAI_npc_henze_faulk(Creature* pCreature)
 {
     return new npc_henze_faulkAI (pCreature);
 }
+
 void AddSC_elwynn_forest()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_henze_faulk";
     newscript->GetAI = &GetAI_npc_henze_faulk;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/eversong_woods.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/eversong_woods.cpp
index 3474d46f1df..b3d598c7669 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/eversong_woods.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/eversong_woods.cpp
@@ -13,12 +13,14 @@
  * along 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: 8483, 8488, 8490, 9686
 SDCategory: Eversong Woods
 EndScriptData */
+
 /* ContentData
 npc_prospector_anvilward
 npc_apprentice_mirveda
@@ -26,26 +28,35 @@ npc_infused_crystal
 npc_kelerun_bloodmourn
 go_harbinger_second_trial
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_prospector_anvilward
 ######*/
+
 #define GOSSIP_HELLO    "I need a moment of your time, sir."
 #define GOSSIP_SELECT   "Why... yes, of course. I've something to show you right inside this building, Mr. Anvilward."
+
 #define SAY_PR_1 -1000281
 #define SAY_PR_2 -1000282
+
 #define QUEST_THE_DWARVEN_SPY 8483
+
 struct TRINITY_DLL_DECL npc_prospector_anvilwardAI : public npc_escortAI
 {
     // CreatureAI functions
     npc_prospector_anvilwardAI(Creature *c) : npc_escortAI(c) {}
+
     // Pure Virtual Functions
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch (i)
         {
             case 0: DoScriptText(SAY_PR_1, m_creature, pPlayer); break;
@@ -53,26 +64,32 @@ struct TRINITY_DLL_DECL npc_prospector_anvilwardAI : public npc_escortAI
             case 6: m_creature->setFaction(24); break;
         }
     }
+
     void Reset()
     {
         me->RestoreFaction();
     }
+
     void JustDied(Unit* killer)
     {
         me->RestoreFaction();
     }
 };
+
 CreatureAI* GetAI_npc_prospector_anvilward(Creature* pCreature)
 {
     return new npc_prospector_anvilwardAI(pCreature);
 }
+
 bool GossipHello_npc_prospector_anvilward(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_THE_DWARVEN_SPY) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(8239, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_prospector_anvilward(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -89,36 +106,50 @@ bool GossipSelect_npc_prospector_anvilward(Player* pPlayer, Creature* pCreature,
     }
     return true;
 }
+
 /*######
 ## Quest 9686 Second Trial
 ######*/
+
 #define QUEST_SECOND_TRIAL 9686
+
 #define MASTER_KELERUN_BLOODMOURN 17807
+
 #define CHAMPION_BLOODWRATH 17809
 #define CHAMPION_LIGHTREND  17810
 #define CHAMPION_SWIFTBLADE 17811
 #define CHAMPION_SUNSTRIKER 17812
+
 #define HARBINGER_OF_THE_SECOND_TRIAL 182052
+
 #define SPELL_FLASH_OF_LIGHT 19939
 #define TIMER_FLASH_OF_LIGHT 3225
+
 #define SPELL_SEAL_OF_JUSTICE 20164
 #define TIMER_SEAL_OF_JUSTICE 10000
+
 #define SPELL_JUDGEMENT_OF_LIGHT 20271
 #define TIMER_JUDGEMENT_OF_LIGHT 10000
+
 #define SPELL_SEAL_OF_COMMAND 20375
 #define TIMER_SEAL_OF_COMMAND 20000
+
 #define OFFSET_NEXT_ATTACK 750
+
 #define FACTION_HOSTILE    45
 #define FACTION_FRIENDLY   7
+
 // missing from db
 #define TEXT_SECOND_TRIAL_1 -1645006
 #define TEXT_SECOND_TRIAL_2 -1645007
 #define TEXT_SECOND_TRIAL_3 -1645008
 #define TEXT_SECOND_TRIAL_4 -1645009
+
 struct Locations
 {
     float x, y, z, o;
 };
+
 static Locations SpawnPosition[]=
 {
     {5.3, -11.8, 0.361, 4.2},
@@ -126,35 +157,46 @@ static Locations SpawnPosition[]=
     {-5.7, -34.85, 0.361, 1.09},
     {-11.9, -18, 0.361, 5.87}
 };
+
 static uint32 PaladinEntry[]= {CHAMPION_BLOODWRATH, CHAMPION_LIGHTREND, CHAMPION_SWIFTBLADE, CHAMPION_SUNSTRIKER};
+
 /*######
 ## npc_second_trial_paladin
 ######*/
+
 struct TRINITY_DLL_DECL npc_secondTrialAI : public ScriptedAI
 {
     npc_secondTrialAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 timer;
     uint8  questPhase;
     uint64 summonerGuid;
+
     bool spellFlashLight;
     bool spellJustice;
     bool spellJudLight;
     bool spellCommand;
+
     uint32 timerFlashLight;
     uint32 timerJustice;
     uint32 timerJudLight;
     uint32 timerCommand;
 
+
     void Reset() {
+
       timer = 2000;
       questPhase = 0;
       summonerGuid = 0;
+
       m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_KNEEL);
       m_creature->setFaction(FACTION_FRIENDLY);
+
       spellFlashLight = false;
       spellJustice    = false;
       spellJudLight   = false;
       spellCommand    = false;
+
       switch(m_creature->GetEntry()) {
         case CHAMPION_BLOODWRATH :
           spellFlashLight = true;
@@ -178,14 +220,18 @@ struct TRINITY_DLL_DECL npc_secondTrialAI : public ScriptedAI
         break;
       }
     }
+
     void EnterCombat(Unit *who) { }
+
     void UpdateAI(const uint32 diff)
     {
       if (questPhase == 1) {
+
         if (timer < diff) {
               m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_STAND);
               m_creature->setFaction(FACTION_HOSTILE);
               questPhase = 0;
+
               Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
               if (target && target->GetTypeId() == TYPEID_PLAYER) // only on players.
               {
@@ -195,8 +241,10 @@ struct TRINITY_DLL_DECL npc_secondTrialAI : public ScriptedAI
          }
          else timer -= diff;
       }
+
       if (!UpdateVictim())
           return;
+
       // healer
       if (spellFlashLight) {
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 70){
@@ -208,6 +256,7 @@ struct TRINITY_DLL_DECL npc_secondTrialAI : public ScriptedAI
             timerFlashLight -= diff;
         }
       }
+
       if (spellJustice) {
           if (timerJustice < diff)
             {
@@ -217,6 +266,7 @@ struct TRINITY_DLL_DECL npc_secondTrialAI : public ScriptedAI
           else
             timerJustice -= diff;
       }
+
       if (spellJudLight) {
           if (timerJudLight < diff) {
             DoCast(m_creature,  SPELL_JUDGEMENT_OF_LIGHT);
@@ -225,6 +275,7 @@ struct TRINITY_DLL_DECL npc_secondTrialAI : public ScriptedAI
           else
             timerJudLight -= diff;
       }
+
       if (spellCommand) {
           if (timerCommand < diff) {
             DoCast(m_creature,  TIMER_SEAL_OF_COMMAND);
@@ -233,29 +284,41 @@ struct TRINITY_DLL_DECL npc_secondTrialAI : public ScriptedAI
           else
             timerCommand -= diff;
       }
+
       DoMeleeAttackIfReady();
     }
+
     void Activate(uint64 summonerguid);
     void KilledUnit(Unit* Killed);
     void JustDied(Unit* Killer);
+
 };
+
 /*######
 ## npc_second_trial_controller
 ######*/
+
 struct TRINITY_DLL_DECL master_kelerun_bloodmournAI : public ScriptedAI
 {
     master_kelerun_bloodmournAI(Creature *c) : ScriptedAI(c) {}
+
     uint8  questPhase;
     uint8  paladinPhase;
     uint32 timer;
+
     uint64 paladinGuid[4];
+
     void Reset() {
+
       questPhase = 0;
       timer = 60000;
       paladinPhase = 0;
       uint64 paladinGuid[] = {0,0,0,0};
+
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
       // Quest accepted but object not activated, object despawned (if in sync 1 minute!)
@@ -265,11 +328,14 @@ struct TRINITY_DLL_DECL master_kelerun_bloodmournAI : public ScriptedAI
       }
       // fight the 4 paladin mobs phase
       else if (questPhase == 2) {
+
         if (timer < diff) {
+
           Creature* paladinSpawn;
           paladinSpawn = (Unit::GetCreature((*m_creature), paladinGuid[paladinPhase]));
             if (paladinSpawn) {
                CAST_AI(npc_secondTrialAI, paladinSpawn->AI())->Activate(m_creature->GetGUID());
+
                switch(paladinPhase) {
                  case 0:
                   DoScriptText(TEXT_SECOND_TRIAL_1,m_creature);
@@ -287,75 +353,99 @@ struct TRINITY_DLL_DECL master_kelerun_bloodmournAI : public ScriptedAI
             }
             else
               Reset();
+
             questPhase=4;
             timer = OFFSET_NEXT_ATTACK;
         }
          else timer -= diff;
       }
+
       if (!UpdateVictim())
           return;
+
       DoMeleeAttackIfReady();
     }
+
     void StartEvent()
     {
+
       if (questPhase == 1) { // no player check, quest can be finished as group, so no complex PlayerGUID/group search code
+
         for (int i = 0; i<4; ++i) {
           Creature* Summoned;
           Summoned = DoSpawnCreature(PaladinEntry[i], SpawnPosition[i].x, SpawnPosition[i].y, SpawnPosition[i].z, SpawnPosition[i].o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 180000);
+
           if (Summoned)
             paladinGuid[i] = Summoned->GetGUID();
         }
+
         timer = OFFSET_NEXT_ATTACK;
         questPhase = 2;
         }
     }
+
     void SecondTrialKill();
     void SummonedCreatureDespawn(Creature* c) {}
 };
 
+
 bool GossipHello_master_kelerun_bloodmourn(Player* pPlayer, Creature* pCreature)
 {
     // quest only available if not already started
     // Quest_template flag is set to : QUEST_FLAGS_EVENT
     // Escort quests or any other event-driven quests. If player in party, all players that can accept this quest will receive confirmation box to accept quest.
     // !not sure if this really works!
+
     if (CAST_AI(master_kelerun_bloodmournAI, pCreature->AI())->questPhase == 0) {
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
         pPlayer->SendPreparedQuest(pCreature->GetGUID());
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetEntry(), pCreature->GetGUID());
     return true;
 }
+
 bool QuestAccept_master_kelerun_bloodmourn(Player* pPlayer, Creature* pCreature, Quest const *quest)
 {
     // One Player exclusive quest, wait for user go activation
     if (quest->GetQuestId() == QUEST_SECOND_TRIAL)
         CAST_AI(master_kelerun_bloodmournAI, pCreature->AI())->questPhase = 1;
+
     return true;
 }
+
 void master_kelerun_bloodmournAI::SecondTrialKill() {
+
       if (questPhase > 0) {
+
         ++paladinPhase;
+
         if (paladinPhase < 4)
           questPhase=2;
         else
           Reset();  // Quest Complete, QuestComplete handler is in npc_secondTrialAI::JustDied
       }
   }
+
 void npc_secondTrialAI::JustDied(Unit* Killer) {
+
       if (Killer->GetTypeId() == TYPEID_PLAYER)
       {
           Creature* Summoner;
           Summoner = (Unit::GetCreature((*m_creature), summonerGuid));
+
           if (Summoner)
             CAST_AI(master_kelerun_bloodmournAI, Summoner->AI())->SecondTrialKill();
+
           // last kill quest complete for group
           if (m_creature->GetEntry() == CHAMPION_SUNSTRIKER) {
+
             if (Group *pGroup = CAST_PLR(Killer)->GetGroup())
             {
-               for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
+               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(m_creature) && !pGroupGuy->GetCorpse() && pGroupGuy->GetQuestStatus(QUEST_SECOND_TRIAL) == QUEST_STATUS_INCOMPLETE)
                    pGroupGuy->CompleteQuest(QUEST_SECOND_TRIAL);
@@ -368,47 +458,62 @@ void npc_secondTrialAI::JustDied(Unit* Killer) {
           }
       }
   }
+
 void npc_secondTrialAI::KilledUnit(Unit* Killed) {
+
   if (Killed->GetTypeId() == TYPEID_PLAYER) {
+
       if (CAST_PLR(Killed)->GetQuestStatus(QUEST_SECOND_TRIAL) == QUEST_STATUS_INCOMPLETE)
         CAST_PLR(Killed)->FailQuest(QUEST_SECOND_TRIAL);
   }
 }
+
 void npc_secondTrialAI::Activate(uint64 summonerguid) {
+
       questPhase=1;
       summonerGuid = summonerguid;
     }
+
 CreatureAI* GetAI_master_kelerun_bloodmourn(Creature* pCreature)
 {
     return new master_kelerun_bloodmournAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_secondTrial(Creature* pCreature)
 {
     return new npc_secondTrialAI (pCreature);
 }
+
 /*######
 ## go_second_trial
 ######*/
+
 bool GOHello_go_second_trial(Player* pPlayer, GameObject* pGO)
 {
     // find spawn :: master_kelerun_bloodmourn
     if (Creature* pCreature = pGO->FindNearestCreature(MASTER_KELERUN_BLOODMOURN, 30.0f))
        CAST_AI(master_kelerun_bloodmournAI, pCreature->AI())->StartEvent();
+
     return true;
 }
+
 /*######
 ## npc_apprentice_mirveda
 ######*/
+
 #define QUEST_UNEXPECTED_RESULT 8488
 #define MOB_GHARZUL     15958
 #define MOB_ANGERSHADE  15656
+
 struct TRINITY_DLL_DECL npc_apprentice_mirvedaAI : public ScriptedAI
 {
     npc_apprentice_mirvedaAI(Creature* c) : ScriptedAI(c), Summons(m_creature) {}
+
     uint32 KillCount;
     uint64 PlayerGUID;
     bool Summon;
     SummonList Summons;
+
     void Reset()
     {
         KillCount = 0;
@@ -416,17 +521,21 @@ struct TRINITY_DLL_DECL npc_apprentice_mirvedaAI : public ScriptedAI
         Summons.DespawnAll();
         Summon = false;
     }
+
     void EnterCombat(Unit* who){}
+
     void JustSummoned(Creature *summoned)
     {
         summoned->AI()->AttackStart(m_creature);
         Summons.Summon(summoned);
     }
+
     void SummonedCreatureDespawn(Creature* summoned)
     {
         Summons.Despawn(summoned);
         ++KillCount;
     }
+
     void JustDied(Unit* killer)
     {
         if (PlayerGUID)
@@ -436,6 +545,7 @@ struct TRINITY_DLL_DECL npc_apprentice_mirvedaAI : public ScriptedAI
                 CAST_PLR(pPlayer)->FailQuest(QUEST_UNEXPECTED_RESULT);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (KillCount >= 3)
@@ -447,6 +557,7 @@ struct TRINITY_DLL_DECL npc_apprentice_mirvedaAI : public ScriptedAI
                     CAST_PLR(pPlayer)->CompleteQuest(QUEST_UNEXPECTED_RESULT);
             }
         }
+
         if (Summon)
         {
             m_creature->SummonCreature(MOB_GHARZUL, 8745, -7134.32, 35.22, 0, TEMPSUMMON_CORPSE_DESPAWN, 4000);
@@ -456,6 +567,7 @@ struct TRINITY_DLL_DECL npc_apprentice_mirvedaAI : public ScriptedAI
         }
     }
 };
+
 bool QuestAccept_npc_apprentice_mirveda(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_UNEXPECTED_RESULT)
@@ -465,20 +577,25 @@ bool QuestAccept_npc_apprentice_mirveda(Player* pPlayer, Creature* pCreature, Qu
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_apprentice_mirvedaAI(Creature* pCreature)
 {
     return new npc_apprentice_mirvedaAI (pCreature);
 }
+
 /*######
 ## npc_infused_crystal
 ######*/
+
 #define MOB_ENRAGED_WRAITH  17086
 #define EMOTE   -1000283
 #define QUEST_POWERING_OUR_DEFENSES 8490
+
 struct Location
 {
     float x, y, z;
 };
+
 static Location SpawnLocations[]=
 {
     {8270.68, -7188.53, 139.619},
@@ -490,14 +607,17 @@ static Location SpawnLocations[]=
     {8278.51, -7242.13, 139.162},
     {8267.97, -7239.17, 139.517}
 };
+
 struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI
 {
     npc_infused_crystalAI(Creature* c) : Scripted_NoMovementAI(c) {}
+
     uint32 EndTimer;
     uint32 WaveTimer;
     bool Completed;
     bool Progress;
     uint64 PlayerGUID;
+
     void Reset()
     {
         EndTimer = 0;
@@ -506,6 +626,7 @@ struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI
         PlayerGUID = 0;
         WaveTimer = 0;
     }
+
     void MoveInLineOfSight(Unit* who)
     {
         if (!Progress && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 10.0f))
@@ -519,10 +640,12 @@ struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI
             }
         }
     }
+
     void JustSummoned(Creature *summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
+
     void JustDied(Unit* killer)
     {
         if (PlayerGUID && !Completed)
@@ -532,6 +655,7 @@ struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI
                 CAST_PLR(pPlayer)->FailQuest(QUEST_POWERING_OUR_DEFENSES);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (EndTimer < diff && Progress)
@@ -547,6 +671,7 @@ struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI
             m_creature->DealDamage(m_creature,m_creature->GetHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
             m_creature->RemoveCorpse();
         }else EndTimer -= diff;
+
         if (WaveTimer < diff && !Completed && Progress)
         {
             uint32 ran1 = rand()%8;
@@ -559,38 +684,46 @@ struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI
         }else WaveTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_npc_infused_crystalAI(Creature* pCreature)
 {
     return new npc_infused_crystalAI (pCreature);
 }
+
 void AddSC_eversong_woods()
 {
     Script *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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_second_trial_controller";
     newscript->GetAI = &GetAI_master_kelerun_bloodmourn;
     newscript->pGossipHello = &GossipHello_master_kelerun_bloodmourn;
     newscript->pQuestAccept = &QuestAccept_master_kelerun_bloodmourn;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_second_trial_paladin";
     newscript->GetAI = &GetAI_npc_secondTrial;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_second_trial";
     newscript->pGOHello =  &GOHello_go_second_trial;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_apprentice_mirveda";
     newscript->GetAI = &GetAI_npc_apprentice_mirvedaAI;
     newscript->pQuestAccept = &QuestAccept_npc_apprentice_mirveda;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_infused_crystal";
     newscript->GetAI = &GetAI_npc_infused_crystalAI;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/ghostlands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/ghostlands.cpp
index cc31deb29a3..8dd1a67a0fc 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/ghostlands.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/ghostlands.cpp
@@ -13,31 +13,40 @@
  * along 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, 9212. Obtain Budd's Guise of Zul'aman. Vendor Rathis Tomber
 SDCategory: Ghostlands
 EndScriptData */
+
 /* ContentData
 npc_blood_knight_dawnstar
 npc_budd_nedreck
 npc_rathis_tomber
 npc_ranger_lilatha
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_blood_knight_dawnstar
 ######*/
+
 #define GOSSIP_H_BKD "Take Blood Knight Insignia"
+
 bool GossipHello_npc_blood_knight_dawnstar(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(9692) == QUEST_STATUS_INCOMPLETE && !pPlayer->HasItemCount(24226,1,true))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_H_BKD, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_blood_knight_dawnstar(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -52,19 +61,25 @@ bool GossipSelect_npc_blood_knight_dawnstar(Player* pPlayer, Creature* pCreature
     }
     return true;
 }
+
 /*######
 ## npc_budd_nedreck
 ######*/
+
 #define GOSSIP_HBN "You gave the crew disguises?"
+
 bool GossipHello_npc_budd_nedreck(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(11166) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HBN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_budd_nedreck(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
@@ -74,30 +89,37 @@ bool GossipSelect_npc_budd_nedreck(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*######
 ## npc_rathis_tomber
 ######*/
+
 bool GossipHello_npc_rathis_tomber(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor() && pPlayer->GetQuestRewardStatus(9152))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
         pPlayer->SEND_GOSSIP_MENU(8432, pCreature->GetGUID());
     }else
     pPlayer->SEND_GOSSIP_MENU(8431, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_rathis_tomber(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
     return true;
 }
+
 /*#####
 ## go_gilded_brazier (Paladin First Trail quest (9678))
 #####*/
+
 bool GOHello_gilded_brazier(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->GetQuestStatus(9678) == QUEST_STATUS_INCOMPLETE)
@@ -108,9 +130,11 @@ bool GOHello_gilded_brazier(Player* pPlayer, GameObject* pGo)
     }
     return true;
 };
+
 /*######
 ## npc_ranger_lilatha
 ######*/
+
 enum eEnums
 {
     SAY_START           = -1000140,
@@ -120,20 +144,26 @@ enum eEnums
     SAY_END1            = -1000144,
     SAY_END2            = -1000145,
     SAY_CAPTAIN_ANSWER      = -1000146,
+
     QUEST_ESCAPE_FROM_THE_CATACOMBS     = 9212,
     GO_CAGE             = 181152,
     NPC_CAPTAIN_HELIOS  = 16220,
     FACTION_SMOON_E     = 1603,
 };
+
 struct TRINITY_DLL_DECL npc_ranger_lilathaAI : public npc_escortAI
 {
     npc_ranger_lilathaAI(Creature *c) : npc_escortAI(c) {}
+
     std::list CageList;
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
         case 0:
@@ -182,48 +212,58 @@ struct TRINITY_DLL_DECL npc_ranger_lilathaAI : public npc_escortAI
             break;
         }
     }
+
     void Reset()
     {
         if (GameObject* Cage = me->FindNearestGameObject(GO_CAGE, 20))
             Cage->SetGoState(GO_STATE_READY);
     }
 };
+
 bool QuestAccept_npc_ranger_lilatha(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_ESCAPE_FROM_THE_CATACOMBS)
     {
         pCreature->setFaction(113);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_ranger_lilathaAI, pCreature->AI()))
             pEscortAI->Start(true, false, pPlayer->GetGUID());
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_ranger_lilathaAI(Creature* pCreature)
 {
     return new npc_ranger_lilathaAI(pCreature);
 }
+
 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_budd_nedreck";
     newscript->pGossipHello = &GossipHello_npc_budd_nedreck;
     newscript->pGossipSelect = &GossipSelect_npc_budd_nedreck;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_rathis_tomber";
     newscript->pGossipHello = &GossipHello_npc_rathis_tomber;
     newscript->pGossipSelect = &GossipSelect_npc_rathis_tomber;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_gilded_brazier";
     newscript->pGOHello = &GOHello_gilded_brazier;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_ranger_lilatha";
     newscript->GetAI = &GetAI_npc_ranger_lilathaAI;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/hinterlands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/hinterlands.cpp
index 103d3340595..2a4bf67868b 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/hinterlands.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/hinterlands.cpp
@@ -13,21 +13,26 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Hinterlands
 SD%Complete: 100
 SDComment: Quest support: 863, 2742
 SDCategory: The Hinterlands
 EndScriptData */
+
 /* ContentData
 npc_00x09hl
 npc_rinji
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_00x09hl
 ######*/
+
 enum eOOX
 {
     SAY_OOX_START           = -1000287,
@@ -35,16 +40,22 @@ enum eOOX
     SAY_OOX_AGGRO2          = -1000289,
     SAY_OOX_AMBUSH          = -1000290,
     SAY_OOX_END             = -1000292,
+
     QUEST_RESQUE_OOX_09     = 836,
+
     NPC_MARAUDING_OWL       = 7808,
     NPC_VILE_AMBUSHER       = 7809,
+
     FACTION_ESCORTEE_A      = 774,
     FACTION_ESCORTEE_H      = 775
 };
+
 struct MANGOS_DLL_DECL npc_00x09hlAI : public npc_escortAI
 {
     npc_00x09hlAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     void Reset() { }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
@@ -62,12 +73,13 @@ struct MANGOS_DLL_DECL npc_00x09hlAI : public npc_escortAI
                 break;
         }
     }
+
     void WaypointStart(uint32 uiPointId)
     {
         switch(uiPointId)
         {
             case 27:
-                for (uint8 i = 0; i < 3; ++i)
+                for(uint8 i = 0; i < 3; ++i)
                 {
                     const Position src = {147.927444f, -3851.513428f, 130.893f, 0};
                     Position pos;
@@ -76,7 +88,7 @@ struct MANGOS_DLL_DECL npc_00x09hlAI : public npc_escortAI
                 }
                 break;
             case 44:
-                for (uint8 i = 0; i < 3; ++i)
+                for(uint8 i = 0; i < 3; ++i)
                 {
                     const Position src = {-141.151581f, -4291.213867f, 120.130f, 0};
                     Position dst;
@@ -86,42 +98,52 @@ struct MANGOS_DLL_DECL npc_00x09hlAI : public npc_escortAI
                 break;
         }
     }
+
     void Aggro(Unit* pWho)
     {
         if (pWho->GetEntry() == NPC_MARAUDING_OWL || pWho->GetEntry() == NPC_VILE_AMBUSHER)
             return;
+
         if (rand()%1)
             DoScriptText(SAY_OOX_AGGRO1, m_creature);
         else
             DoScriptText(SAY_OOX_AGGRO2, m_creature);
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         pSummoned->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
     }
 };
+
 bool QuestAccept_npc_00x09hl(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_RESQUE_OOX_09)
     {
         pCreature->SetStandState(UNIT_STAND_STATE_STAND);
+
         if (pPlayer->GetTeam() == ALLIANCE)
             pCreature->setFaction(FACTION_ESCORTEE_A);
         else if (pPlayer->GetTeam() == HORDE)
             pCreature->setFaction(FACTION_ESCORTEE_H);
+
         DoScriptText(SAY_OOX_START, pCreature, pPlayer);
+
         if (npc_00x09hlAI* pEscortAI = CAST_AI(npc_00x09hlAI, pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_00x09hl(Creature* pCreature)
 {
     return new npc_00x09hlAI(pCreature);
 }
+
 /*######
 ## npc_rinji
 ######*/
+
 enum eRinji
 {
     SAY_RIN_FREE            = -1000403, //from here
@@ -131,25 +153,30 @@ enum eRinji
     SAY_RIN_COMPLETE        = -1000407,
     SAY_RIN_PROGRESS_1      = -1000408,
     SAY_RIN_PROGRESS_2      = -1000409,
+
     QUEST_RINJI_TRAPPED     = 2742,
     NPC_RANGER              = 2694,
     NPC_OUTRUNNER           = 2691,
     GO_RINJI_CAGE           = 142036
 };
+
 struct Location
 {
     float m_fX, m_fY, m_fZ;
 };
+
 Location m_afAmbushSpawn[] =
 {
     {191.296204, -2839.329346, 107.388},
     {70.972466,  -2848.674805, 109.459}
 };
+
 Location m_afAmbushMoveTo[] =
 {
     {166.630386, -2824.780273, 108.153},
     {70.886589,  -2874.335449, 116.675}
 };
+
 struct TRINITY_DLL_DECL npc_rinjiAI : public npc_escortAI
 {
     npc_rinjiAI(Creature* pCreature) : npc_escortAI(pCreature)
@@ -157,21 +184,26 @@ struct TRINITY_DLL_DECL npc_rinjiAI : public npc_escortAI
         m_bIsByOutrunner = false;
         m_iSpawnId = 0;
     }
+
     bool m_bIsByOutrunner;
     uint32 m_uiPostEventCount;
     uint32 m_uiPostEventTimer;
     int m_iSpawnId;
+
     void Reset()
     {
         m_uiPostEventCount = 0;
         m_uiPostEventTimer = 3000;
     }
+
     void JustRespawned()
     {
         m_bIsByOutrunner = false;
         m_iSpawnId = 0;
+
         npc_escortAI::JustRespawned();
     }
+
     void EnterCombat(Unit* pWho)
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
@@ -181,36 +213,45 @@ struct TRINITY_DLL_DECL npc_rinjiAI : public npc_escortAI
                 DoScriptText(SAY_RIN_BY_OUTRUNNER, pWho);
                 m_bIsByOutrunner = true;
             }
+
             if (rand()%4)
                 return;
+
             //only if attacked and escorter is not in combat?
             DoScriptText(RAND(SAY_RIN_HELP_1,SAY_RIN_HELP_2), m_creature);
         }
     }
+
     void DoSpawnAmbush(bool bFirst)
     {
         if (!bFirst)
             m_iSpawnId = 1;
+
         m_creature->SummonCreature(NPC_RANGER,
             m_afAmbushSpawn[m_iSpawnId].m_fX, m_afAmbushSpawn[m_iSpawnId].m_fY, m_afAmbushSpawn[m_iSpawnId].m_fZ, 0.0f,
             TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
-        for (int i = 0; i < 2; ++i)
+
+        for(int i = 0; i < 2; ++i)
         {
             m_creature->SummonCreature(NPC_OUTRUNNER,
                 m_afAmbushSpawn[m_iSpawnId].m_fX, m_afAmbushSpawn[m_iSpawnId].m_fY, m_afAmbushSpawn[m_iSpawnId].m_fZ, 0.0f,
                 TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
         }
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         pSummoned->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
         pSummoned->GetMotionMaster()->MovePoint(0, m_afAmbushMoveTo[m_iSpawnId].m_fX, m_afAmbushMoveTo[m_iSpawnId].m_fY, m_afAmbushMoveTo[m_iSpawnId].m_fZ);
     }
+
     void WaypointReached(uint32 uiPointId)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(uiPointId)
         {
             case 1:
@@ -230,6 +271,7 @@ struct TRINITY_DLL_DECL npc_rinjiAI : public npc_escortAI
                 break;
         }
     }
+
     void UpdateEscortAI(const uint32 uiDiff)
     {
         //Check if we have a current target
@@ -240,6 +282,7 @@ struct TRINITY_DLL_DECL npc_rinjiAI : public npc_escortAI
                 if (m_uiPostEventTimer < uiDiff)
                 {
                     m_uiPostEventTimer = 3000;
+
                     if (Unit* pPlayer = GetPlayerForEscort())
                     {
                         switch(m_uiPostEventCount)
@@ -263,34 +306,42 @@ struct TRINITY_DLL_DECL npc_rinjiAI : public npc_escortAI
                 else
                     m_uiPostEventTimer -= uiDiff;
             }
+
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 bool QuestAccept_npc_rinji(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_RINJI_TRAPPED)
     {
         if (GameObject* pGo = pCreature->FindNearestGameObject(GO_RINJI_CAGE, INTERACTION_DISTANCE))
             pGo->UseDoorOrButton();
+
         if (npc_rinjiAI* pEscortAI = CAST_AI(npc_rinjiAI, pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_rinji(Creature* pCreature)
 {
     return new npc_rinjiAI(pCreature);
 }
+
 void AddSC_hinterlands()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "npc_00x09hl";
     newscript->GetAI = &GetAI_npc_00x09hl;
     newscript->pQuestAccept = &QuestAccept_npc_00x09hl;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_rinji";
     newscript->GetAI = &GetAI_npc_rinji;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/ironforge.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/ironforge.cpp
index 27f4286bd58..c087434f28c 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/ironforge.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/ironforge.cpp
@@ -13,28 +13,35 @@
  * along 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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(3702) == QUEST_STATUS_INCOMPLETE)
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ROYAL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
@@ -42,8 +49,10 @@ bool GossipHello_npc_royal_historian_archesonus(Player* pPlayer, Creature* pCrea
     }
     else
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_royal_historian_archesonus(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -71,9 +80,11 @@ bool GossipSelect_npc_royal_historian_archesonus(Player* pPlayer, Creature* pCre
     }
     return true;
 }
+
 void AddSC_ironforge()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_royal_historian_archesonus";
     newscript->pGossipHello =  &GossipHello_npc_royal_historian_archesonus;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/isle_of_queldanas.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/isle_of_queldanas.cpp
index 7c28190609a..9a9db09c514 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/isle_of_queldanas.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/isle_of_queldanas.cpp
@@ -13,37 +13,48 @@
  * along 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, 11541
 SDCategory: Isle Of Quel'Danas
 EndScriptData */
+
 /* ContentData
 npc_converted_sentry
 npc_greengill_slave
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## npc_converted_sentry
 ######*/
+
 #define SAY_CONVERTED_1         -1000284
 #define SAY_CONVERTED_2         -1000284
+
 #define SPELL_CONVERT_CREDIT    45009
+
 struct TRINITY_DLL_DECL npc_converted_sentryAI : public ScriptedAI
 {
     npc_converted_sentryAI(Creature *c) : ScriptedAI(c) {}
+
     bool Credit;
     uint32 Timer;
+
     void Reset()
     {
         Credit = false;
         Timer = 2500;
     }
+
     void MoveInLineOfSight(Unit *who)
         { return; }
     void EnterCombat(Unit* who)
         { }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Credit)
@@ -55,6 +66,7 @@ struct TRINITY_DLL_DECL npc_converted_sentryAI : public ScriptedAI
                     DoScriptText(SAY_CONVERTED_1, m_creature);
                 else
                     DoScriptText(SAY_CONVERTED_2, m_creature);
+
                 DoCast(m_creature, SPELL_CONVERT_CREDIT);
                 if (m_creature->isPet())
                     CAST_PET(m_creature)->SetDuration(7500);
@@ -67,26 +79,34 @@ CreatureAI* GetAI_npc_converted_sentry(Creature* pCreature)
 {
     return new npc_converted_sentryAI (pCreature);
 }
+
 /*######
 ## npc_greengill_slave
 ######*/
+
 #define ENRAGE  45111
 #define ORB     45109
 #define QUESTG  11541
 #define DM      25060
+
 struct TRINITY_DLL_DECL npc_greengill_slaveAI : public ScriptedAI
 {
     npc_greengill_slaveAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 PlayerGUID;
+
     void EnterCombat(Unit* who){}
+
     void Reset()
     {
     PlayerGUID = 0;
     }
+
     void SpellHit(Unit* caster, const SpellEntry* spell)
     {
         if (!caster)
             return;
+
         if (caster->GetTypeId() == TYPEID_PLAYER && spell->Id == ORB && !m_creature->HasAura(ENRAGE))
         {
             PlayerGUID = caster->GetGUID();
@@ -105,22 +125,27 @@ struct TRINITY_DLL_DECL npc_greengill_slaveAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_greengill_slaveAI(Creature* pCreature)
 {
     return new npc_greengill_slaveAI(pCreature);
 }
+
 void AddSC_isle_of_queldanas()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_converted_sentry";
     newscript->GetAI = &GetAI_npc_converted_sentry;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_greengill_slave";
     newscript->GetAI = &GetAI_npc_greengill_slaveAI;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_curator.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_curator.cpp
index 9416ab3b2c3..2a2d64e412e 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_curator.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_curator.cpp
@@ -13,13 +13,16 @@
  * along with 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:
 SDCategory: Karazhan
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SAY_AGGRO                       -1532057
 #define SAY_SUMMON1                     -1532058
 #define SAY_SUMMON2                     -1532059
@@ -28,21 +31,27 @@ EndScriptData */
 #define SAY_KILL1                       -1532062
 #define SAY_KILL2                       -1532063
 #define SAY_DEATH                       -1532064
+
 //Flare spell info
 #define SPELL_ASTRAL_FLARE_PASSIVE      30234               //Visual effect + Flare damage
+
 //Curator spell info
 #define SPELL_HATEFUL_BOLT              30383
 #define SPELL_EVOCATION                 30254
 #define SPELL_ENRAGE                    30403               //Arcane Infusion: Transforms Curator and adds damage.
 #define SPELL_BERSERK                   26662
+
 struct  TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI
 {
     boss_curatorAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 AddTimer;
     uint32 HatefulBoltTimer;
     uint32 BerserkTimer;
+
     bool Enraged;
     bool Evocating;
+
     void Reset()
     {
         AddTimer = 10000;
@@ -50,24 +59,30 @@ struct  TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI
         BerserkTimer = 720000;                              //12 minutes
         Enraged = false;
         Evocating = false;
+
         m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_ARCANE, true);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_KILL1,SAY_KILL2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //always decrease BerserkTimer
         if (BerserkTimer < diff)
         {
@@ -76,15 +91,20 @@ struct  TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI
             {
                 if (m_creature->HasAura(SPELL_EVOCATION))
                     m_creature->RemoveAurasDueToSpell(SPELL_EVOCATION);
+
                 Evocating = false;
             }
+
             //may not be correct SAY (generic hard enrage)
             DoScriptText(SAY_ENRAGE, m_creature);
+
             m_creature->InterruptNonMeleeSpells(true);
             DoCast(m_creature, SPELL_BERSERK);
+
             //don't know if he's supposed to do summon/evocate after hard enrage (probably not)
             Enraged = true;
         }else BerserkTimer -= diff;
+
         if (Evocating)
         {
             //not supposed to do anything while evocate
@@ -93,6 +113,7 @@ struct  TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI
             else
                 Evocating = false;
         }
+
         if (!Enraged)
         {
             if (AddTimer < diff)
@@ -101,16 +122,19 @@ struct  TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI
                 Creature* AstralFlare = DoSpawnCreature(17096, rand()%37, rand()%37, 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% of max health
                 if (int32 mana = m_creature->GetMaxPower(POWER_MANA))
                 {
                     mana /= 10;
                     m_creature->ModifyPower(POWER_MANA, -mana);
+
                     //if this get's us below 10%, then we evocate (the 10th should be summoned now)
                     if (m_creature->GetPower(POWER_MANA)*100 / m_creature->GetMaxPower(POWER_MANA) < 10)
                     {
@@ -129,8 +153,10 @@ struct  TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI
                         }
                     }
                 }
+
                 AddTimer = 10000;
             }else AddTimer -= diff;
+
             if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 15)
             {
                 Enraged = true;
@@ -138,22 +164,28 @@ struct  TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI
                 DoScriptText(SAY_ENRAGE, m_creature);
             }
         }
+
         if (HatefulBoltTimer < diff)
         {
             if (Enraged)
                 HatefulBoltTimer = 7000;
             else
                 HatefulBoltTimer = 15000;
+
             if (Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1))
                 DoCast(target, SPELL_HATEFUL_BOLT);
+
         }else HatefulBoltTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_curator(Creature* pCreature)
 {
     return new boss_curatorAI (pCreature);
 }
+
 void AddSC_boss_curator()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_maiden_of_virtue.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_maiden_of_virtue.cpp
index 6ecf759b11f..df30deb1ff3 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_maiden_of_virtue.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_maiden_of_virtue.cpp
@@ -13,13 +13,16 @@
  * along with 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 SAY_AGGRO               -1532018
 #define SAY_SLAY1               -1532019
 #define SAY_SLAY2               -1532020
@@ -27,20 +30,25 @@ EndScriptData */
 #define SAY_REPENTANCE1         -1532022
 #define SAY_REPENTANCE2         -1532023
 #define SAY_DEATH               -1532024
+
 #define SPELL_REPENTANCE        29511
 #define SPELL_HOLYFIRE          29522
 #define SPELL_HOLYWRATH         32445
 #define SPELL_HOLYGROUND        29512
 #define SPELL_BERSERK           26662
+
 struct TRINITY_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI
 {
     boss_maiden_of_virtueAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Repentance_Timer;
     uint32 Holyfire_Timer;
     uint32 Holywrath_Timer;
     uint32 Holyground_Timer;
     uint32 Enrage_Timer;
+
     bool Enraged;
+
     void Reset()
     {
         Repentance_Timer    = 25000+(rand()%15000);
@@ -48,60 +56,78 @@ struct TRINITY_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI
         Holywrath_Timer     = 15000+(rand()%10000);
         Holyground_Timer    = 3000;
         Enrage_Timer        = 600000;
+
         Enraged = false;
     }
+
     void KilledUnit(Unit* Victim)
     {
         if (urand(0,1) == 0)
             DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Enrage_Timer < diff && !Enraged)
         {
             DoCast(m_creature, SPELL_BERSERK,true);
             Enraged = true;
         } else Enrage_Timer -=diff;
+
         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);
             DoScriptText(RAND(SAY_REPENTANCE1,SAY_REPENTANCE2), m_creature);
+
             Repentance_Timer = 25000 + rand()%10000;        //A little randomness on that spell
         } else Repentance_Timer -= diff;
+
         if (Holyfire_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 DoCast(target,SPELL_HOLYFIRE);
+
                 Holyfire_Timer = 8000 + rand()%15000;           //Anywhere from 8 to 23 seconds, good luck having several of those in a row!
         } else Holyfire_Timer -= diff;
+
         if (Holywrath_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 DoCast(target,SPELL_HOLYWRATH);
+
             Holywrath_Timer = 20000+(rand()%5000);     //20-30 secs sounds nice
+
         } else Holywrath_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
 };
+
 CreatureAI* GetAI_boss_maiden_of_virtue(Creature* pCreature)
 {
     return new boss_maiden_of_virtueAI (pCreature);
 }
+
 void AddSC_boss_maiden_of_virtue()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_midnight.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_midnight.cpp
index d81d50b52f9..57a0a1c1c5b 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_midnight.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_midnight.cpp
@@ -13,13 +13,16 @@
  * along with 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           -1532000
 #define SAY_APPEAR1                 -1532001
 #define SAY_APPEAR2                 -1532002
@@ -31,27 +34,36 @@ EndScriptData */
 #define SAY_DEATH                   -1532008
 #define SAY_RANDOM1                 -1532009
 #define SAY_RANDOM2                 -1532010
+
 #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 TRINITY_DLL_DECL boss_midnightAI : public ScriptedAI
 {
     boss_midnightAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 Attumen;
     uint8 Phase;
     uint32 Mount_Timer;
+
     void Reset()
     {
         Phase = 1;
         Attumen = 0;
         Mount_Timer = 0;
+
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetVisibility(VISIBILITY_ON);
     }
+
     void EnterCombat(Unit* who) {}
+
     void KilledUnit(Unit *victim)
     {
         if (Phase == 2)
@@ -60,10 +72,12 @@ struct TRINITY_DLL_DECL boss_midnightAI : public ScriptedAI
             DoScriptText(SAY_MIDNIGHT_KILL, pUnit);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Phase == 1 && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 95)
         {
             Phase = 2;
@@ -103,9 +117,11 @@ struct TRINITY_DLL_DECL boss_midnightAI : public ScriptedAI
                 } else Mount_Timer -= diff;
             }
         }
+
         if (Phase != 3)
             DoMeleeAttackIfReady();
     }
+
     void Mount(Unit *pAttumen)
     {
         DoScriptText(SAY_MOUNT, pAttumen);
@@ -130,23 +146,28 @@ struct TRINITY_DLL_DECL boss_midnightAI : public ScriptedAI
         //pAttumen->SendMonsterMove(newX, newY, newZ, 0, true, 1000);
         Mount_Timer = 1000;
     }
+
     void SetMidnight(Creature *, uint64);                   //Below ..
 };
+
 CreatureAI* GetAI_boss_midnight(Creature* pCreature)
 {
     return new boss_midnightAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI
 {
     boss_attumenAI(Creature *c) : ScriptedAI(c)
     {
         Phase = 1;
+
         CleaveTimer = urand(10000,15000);
         CurseTimer = 30000;
         RandomYellTimer = urand(30000,60000);              //Occasionally yell
         ChargeTimer = 20000;
         ResetTimer = 0;
     }
+
     uint64 Midnight;
     uint8 Phase;
     uint32 CleaveTimer;
@@ -154,21 +175,26 @@ struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI
     uint32 RandomYellTimer;
     uint32 ChargeTimer;                                     //only when mounted
     uint32 ResetTimer;
+
     void Reset()
     {
         ResetTimer = 2000;
     }
+
     void EnterCombat(Unit* who) {}
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_KILL1,SAY_KILL2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
         if (Unit *pMidnight = Unit::GetUnit(*m_creature, Midnight))
             pMidnight->Kill(pMidnight);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (ResetTimer)
@@ -187,26 +213,32 @@ struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI
                 m_creature->Kill(m_creature);
             }
         } else ResetTimer -= diff;
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
             return;
+
         if (CleaveTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SHADOWCLEAVE);
             CleaveTimer = urand(10000,15000);
         } else CleaveTimer -= diff;
+
         if (CurseTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_INTANGIBLE_PRESENCE);
             CurseTimer = 30000;
         } else CurseTimer -= diff;
+
         if (RandomYellTimer < diff)
         {
             DoScriptText(RAND(SAY_RANDOM1,SAY_RANDOM2), m_creature);
             RandomYellTimer = urand(30000,60000);
         } else RandomYellTimer -= diff;
+
         if (m_creature->GetUInt32Value(UNIT_FIELD_DISPLAYID) == MOUNTED_DISPLAYID)
         {
             if (ChargeTimer < diff)
@@ -214,7 +246,7 @@ struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI
                 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)
+                for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                 {
                     target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                     if (target && !target->IsWithinDist(m_creature, ATTACK_DISTANCE, false))
@@ -223,6 +255,7 @@ struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI
                 }
                 if (target_list.size())
                     target = *(target_list.begin()+rand()%target_list.size());
+
                 DoCast(target, SPELL_BERSERKER_CHARGE);
                 ChargeTimer = 20000;
             } else ChargeTimer -= diff;
@@ -240,22 +273,27 @@ struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI
                 }
             }
         }
+
         DoMeleeAttackIfReady();
     }
+
     void SpellHit(Unit *source, const SpellEntry *spell)
     {
         if (spell->Mechanic == MECHANIC_DISARM)
             DoScriptText(SAY_DISARMED, m_creature);
     }
 };
+
 void boss_midnightAI::SetMidnight(Creature *pAttumen, uint64 value)
 {
     CAST_AI(boss_attumenAI, pAttumen->AI())->Midnight = value;
 }
+
 CreatureAI* GetAI_boss_attumen(Creature* pCreature)
 {
     return new boss_attumenAI (pCreature);
 }
+
 void AddSC_boss_attumen()
 {
     Script *newscript;
@@ -263,6 +301,7 @@ void AddSC_boss_attumen()
     newscript->Name = "boss_attumen";
     newscript->GetAI = &GetAI_boss_attumen;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_midnight";
     newscript->GetAI = &GetAI_boss_midnight;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_moroes.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_moroes.cpp
index 9a6970905fe..2714b95f3c4 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_moroes.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_moroes.cpp
@@ -13,14 +13,17 @@
  * along with 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: 95
 SDComment:
 SDCategory: Karazhan
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_karazhan.h"
+
 #define SAY_AGGRO           -1532011
 #define SAY_SPECIAL_1       -1532012
 #define SAY_SPECIAL_2       -1532013
@@ -28,12 +31,15 @@ EndScriptData */
 #define SAY_KILL_2          -1532015
 #define SAY_KILL_3          -1532016
 #define SAY_DEATH           -1532017
+
 #define SPELL_VANISH        29448
 #define SPELL_GARROTE       37066
 #define SPELL_BLIND         34694
 #define SPELL_GOUGE         29425
 #define SPELL_FRENZY        37023
+
 #define POS_Z               81.73
+
 float Locations[4][3]=
 {
     {-10991.0, -1884.33, 0.614315},
@@ -41,6 +47,7 @@ float Locations[4][3]=
     {-10978.1, -1887.07, 2.035550},
     {-10975.9, -1885.81, 2.253890},
 };
+
 const uint32 Adds[6]=
 {
     17007,
@@ -50,26 +57,32 @@ const uint32 Adds[6]=
     19875,
     19876,
 };
+
 struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
 {
     boss_moroesAI(Creature *c) : ScriptedAI(c)
     {
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             AddId[i] = 0;
         }
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint64 AddGUID[4];
+
     uint32 Vanish_Timer;
     uint32 Blind_Timer;
     uint32 Gouge_Timer;
     uint32 Wait_Timer;
     uint32 CheckAdds_Timer;
     uint32 AddId[4];
+
     bool InVanish;
     bool Enrage;
+
     void Reset()
     {
         Vanish_Timer = 30000;
@@ -77,45 +90,58 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
         Gouge_Timer = 23000;
         Wait_Timer = 0;
         CheckAdds_Timer = 5000;
+
         Enrage = false;
         InVanish = false;
         if (m_creature->GetHealth() > 0)
         {
             SpawnAdds();
         }
+
         if (pInstance)
             pInstance->SetData(TYPE_MOROES, NOT_STARTED);
     }
+
     void StartEvent()
     {
         if (pInstance)
             pInstance->SetData(TYPE_MOROES, IN_PROGRESS);
+
         DoZoneInCombat();
     }
+
     void EnterCombat(Unit* who)
     {
         StartEvent();
+
         DoScriptText(SAY_AGGRO, m_creature);
         AddsAttack();
         DoZoneInCombat();
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2,SAY_KILL_3), m_creature);
     }
+
     void JustDied(Unit* victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_MOROES, DONE);
+
         DeSpawnAdds();
+
         //remove aura from spell Garrote when Moroes dies
         Map* pMap = m_creature->GetMap();
         if (pMap->IsDungeon())
         {
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
+
             if (PlayerList.isEmpty())
                 return;
+
             for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
             {
                 if (i->getSource()->isAlive() && i->getSource()->HasAura(SPELL_GARROTE,0))
@@ -123,6 +149,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
             }
         }
     }
+
     void SpawnAdds()
     {
         DeSpawnAdds();
@@ -131,14 +158,18 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
             Creature *pCreature = NULL;
             std::vector AddList;
 
-            for (uint8 i = 0; i < 6; ++i)
+
+            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)
+            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, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
                 if (pCreature)
                 {
@@ -149,7 +180,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
             }
         }else
         {
-            for (uint8 i = 0; i < 4; ++i)
+            for(uint8 i = 0; i < 4; ++i)
             {
                 Creature *pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
                 if (pCreature)
@@ -159,18 +190,20 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
             }
         }
     }
+
     bool isAddlistEmpty()
     {
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (AddId[i] == 0)
                 return true;
         }
         return false;
     }
+
     void DeSpawnAdds()
     {
-        for (uint8 i = 0; i < 4 ; ++i)
+        for(uint8 i = 0; i < 4 ; ++i)
         {
             Creature* Temp = NULL;
             if (AddGUID[i])
@@ -181,9 +214,10 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
             }
         }
     }
+
     void AddsAttack()
     {
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             Creature* Temp = NULL;
             if (AddGUID[i])
@@ -198,20 +232,24 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (pInstance && !pInstance->GetData(TYPE_MOROES))
         {
             EnterEvadeMode();
             return;
         }
+
         if (!Enrage && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30)
         {
             DoCast(m_creature, SPELL_FRENZY);
             Enrage = true;
         }
+
         if (CheckAdds_Timer < diff)
         {
             for (uint8 i = 0; i < 4; ++i)
@@ -227,6 +265,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
             }
             CheckAdds_Timer = 5000;
         } else CheckAdds_Timer -= diff;
+
         if (!Enrage)
         {
             //Cast Vanish, then Garrote random victim
@@ -237,61 +276,75 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
                 Vanish_Timer = 30000;
                 Wait_Timer = 5000;
             } else Vanish_Timer -= diff;
+
             if (Gouge_Timer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_GOUGE);
                 Gouge_Timer = 40000;
             } else Gouge_Timer -= diff;
+
             if (Blind_Timer < diff)
             {
                 Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
                 if (target && target->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinMeleeRange(target))
                 {
                     DoCast(target, SPELL_BLIND);
+
                     Blind_Timer = 40000;
                 }
                 else
                     Blind_Timer = 1000;
             } else Blind_Timer -= diff;
         }
+
         if (InVanish)
         {
             if (Wait_Timer < diff)
             {
                 DoScriptText(RAND(SAY_SPECIAL_1,SAY_SPECIAL_2), m_creature);
+
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    target->CastSpell(target, SPELL_GARROTE,true);
+
                 InVanish = false;
             } else Wait_Timer -= diff;
         }
+
         if (!InVanish)
             DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_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)
+        for(uint8 i = 0; i < 4; ++i)
             GuestGUID[i] = 0;
+
         pInstance = c->GetInstanceData();
     }
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(TYPE_MOROES, NOT_STARTED);
     }
+
     void AcquireGUID()
     {
         if (!pInstance)
             return;
+
         GuestGUID[0] = pInstance->GetData64(DATA_MOROES);
         Creature* Moroes = (Unit::GetCreature((*m_creature), GuestGUID[0]));
         if (Moroes)
         {
-            for (uint8 i = 0; i < 3; ++i)
+            for(uint8 i = 0; i < 3; ++i)
             {
                 uint64 GUID = CAST_AI(boss_moroesAI, Moroes->AI())->AddGUID[i];
                 if (GUID && GUID != m_creature->GetGUID())
@@ -299,6 +352,7 @@ struct TRINITY_DLL_DECL boss_moroes_guestAI : public ScriptedAI
             }
         }
     }
+
     Unit* SelectTarget()
     {
         uint64 TempGUID = GuestGUID[rand()%5];
@@ -308,44 +362,57 @@ struct TRINITY_DLL_DECL boss_moroes_guestAI : public ScriptedAI
             if (pUnit && pUnit->isAlive())
                 return pUnit;
         }
+
         return m_creature;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (pInstance && !pInstance->GetData(TYPE_MOROES))
             EnterEvadeMode();
+
         DoMeleeAttackIfReady();
     }
 };
+
 #define SPELL_MANABURN       29405
 #define SPELL_MINDFLY        29570
 #define SPELL_SWPAIN         34441
 #define SPELL_SHADOWFORM     29406
+
 struct TRINITY_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 (!UpdateVictim())
             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);
@@ -353,6 +420,7 @@ struct TRINITY_DLL_DECL boss_baroness_dorothea_millstipeAI : public boss_moroes_
                 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);
@@ -364,39 +432,49 @@ struct TRINITY_DLL_DECL boss_baroness_dorothea_millstipeAI : public boss_moroes_
         }else ShadowWordPain_Timer -= diff;
     }
 };
+
 #define SPELL_HAMMEROFJUSTICE       13005
 #define SPELL_JUDGEMENTOFCOMMAND    29386
 #define SPELL_SEALOFCOMMAND         29385
+
 struct TRINITY_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 (!UpdateVictim())
             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);
@@ -404,144 +482,186 @@ struct TRINITY_DLL_DECL boss_baron_rafe_dreugerAI : public boss_moroes_guestAI
         }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 TRINITY_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 (!UpdateVictim())
             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 TRINITY_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 (!UpdateVictim())
             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 TRINITY_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 (!UpdateVictim())
             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);
@@ -549,46 +669,57 @@ struct TRINITY_DLL_DECL boss_lord_robin_darisAI : public boss_moroes_guestAI
         }else WhirlWind_Timer -= diff;
     }
 };
+
 #define SPELL_DISARM            8379
 #define SPELL_HEROICSTRIKE      29567
 #define SPELL_SHIELDBASH        11972
 #define SPELL_SHIELDWALL        29390
+
 struct TRINITY_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 (!UpdateVictim())
             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);
@@ -596,61 +727,76 @@ struct TRINITY_DLL_DECL boss_lord_crispin_ferenceAI : public boss_moroes_guestAI
         }else ShieldWall_Timer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_moroes(Creature* pCreature)
 {
     return new boss_moroesAI (pCreature);
 }
+
 CreatureAI* GetAI_baroness_dorothea_millstipe(Creature* pCreature)
 {
     return new boss_baroness_dorothea_millstipeAI (pCreature);
 }
+
 CreatureAI* GetAI_baron_rafe_dreuger(Creature* pCreature)
 {
     return new boss_baron_rafe_dreugerAI (pCreature);
 }
+
 CreatureAI* GetAI_lady_catriona_von_indi(Creature* pCreature)
 {
     return new boss_lady_catriona_von_indiAI (pCreature);
 }
+
 CreatureAI* GetAI_lady_keira_berrybuck(Creature* pCreature)
 {
     return new boss_lady_keira_berrybuckAI (pCreature);
 }
+
 CreatureAI* GetAI_lord_robin_daris(Creature* pCreature)
 {
     return new boss_lord_robin_darisAI (pCreature);
 }
+
 CreatureAI* GetAI_lord_crispin_ference(Creature* pCreature)
 {
     return new boss_lord_crispin_ferenceAI (pCreature);
 }
+
 void AddSC_boss_moroes()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_moroes";
     newscript->GetAI = &GetAI_boss_moroes;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_baroness_dorothea_millstipe";
     newscript->GetAI = &GetAI_baroness_dorothea_millstipe;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_baron_rafe_dreuger";
     newscript->GetAI = &GetAI_baron_rafe_dreuger;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_lady_catriona_von_indi";
     newscript->GetAI = &GetAI_lady_catriona_von_indi;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_lady_keira_berrybuck";
     newscript->GetAI = &GetAI_lady_keira_berrybuck;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_lord_robin_daris";
     newscript->GetAI = &GetAI_lord_robin_daris;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_lord_crispin_ference";
     newscript->GetAI = &GetAI_lord_crispin_ference;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_netherspite.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_netherspite.cpp
index c2d2de25309..b6e3d25c021 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_netherspite.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_netherspite.cpp
@@ -13,16 +13,20 @@
  * along with 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: 90
 SDComment: Not sure about timing and portals placing
 SDCategory: Karazhan
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_karazhan.h"
+
 #define EMOTE_PHASE_PORTAL          -1532089
 #define EMOTE_PHASE_BANISH          -1532090
+
 #define SPELL_NETHERBURN_AURA       30522
 #define SPELL_VOIDZONE              37063
 #define SPELL_NETHER_INFUSION       38688
@@ -31,42 +35,49 @@ EndScriptData */
 #define SPELL_BANISH_ROOT           42716
 #define SPELL_EMPOWERMENT           38549
 #define SPELL_NETHERSPITE_ROAR      38684
+
 const float PortalCoord[3][3] =
 {
     {-11195.353516, -1613.237183, 278.237258}, // Left side
     {-11137.846680, -1685.607422, 278.239258}, // Right side
     {-11094.493164, -1591.969238, 279.949188}  // Back side
 };
+
 enum Netherspite_Portal{
     RED_PORTAL = 0, // Perseverence
     GREEN_PORTAL = 1, // Serenity
     BLUE_PORTAL = 2 // Dominance
 };
+
 const uint32 PortalID[3] = {17369, 17367, 17368};
 const uint32 PortalVisual[3] = {30487,30490,30491};
 const uint32 PortalBeam[3] = {30465,30464,30463};
 const uint32 PlayerBuff[3] = {30421,30422,30423};
 const uint32 NetherBuff[3] = {30466,30467,30468};
 const uint32 PlayerDebuff[3] = {38637,38638,38639};
+
 struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
 {
     boss_netherspiteAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
-        for (int i=0; i<3; ++i)
+
+        for(int i=0; i<3; ++i)
         {
             PortalGUID[i] = 0;
             BeamTarget[i] = 0;
             BeamerGUID[i] = 0;
         }
         // need core fix
-        for (int i=0; i<3; ++i)
+        for(int i=0; i<3; ++i)
         {
             if(SpellEntry *spell = (SpellEntry*)GetSpellStore()->LookupEntry(PlayerBuff[i]))
                 spell->AttributesEx |= SPELL_ATTR_EX_NEGATIVE;
         }
     }
+
     ScriptedInstance* pInstance;
+
     bool PortalPhase;
     bool Berserk;
     uint32 PhaseTimer; // timer for phase switching
@@ -78,10 +89,12 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
     uint64 PortalGUID[3]; // guid's of portals
     uint64 BeamerGUID[3]; // guid's of auxiliary beaming portals
     uint64 BeamTarget[3]; // guid's of portals' current targets
+
     bool IsBetween(WorldObject* u1, WorldObject* target, WorldObject* u2) // the in-line checker
     {
         if(!u1 || !u2 || !target)
             return false;
+
         float xn, yn, xp, yp, xh, yh;
         xn = u1->GetPositionX();
         yn = u1->GetPositionY();
@@ -89,25 +102,30 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
         yp = u2->GetPositionY();
         xh = target->GetPositionX();
         yh = target->GetPositionY();
+
         // check if target is between (not checking distance from the beam yet)
         if(dist(xn,yn,xh,yh)>=dist(xn,yn,xp,yp) || dist(xp,yp,xh,yh)>=dist(xn,yn,xp,yp))
             return false;
         // check  distance from the beam
         return (abs((xn-xp)*yh+(yp-yn)*xh-xn*yp+xp*yn)/dist(xn,yn,xp,yp) < 1.5f);
     }
+
     float dist(float xa, float ya, float xb, float yb) // auxiliary method for distance
     {
         return sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
     }
+
     void Reset()
     {
         Berserk = false;
         NetherInfusionTimer = 540000;
         VoidZoneTimer = 15000;
         NetherbreathTimer = 3000;
+
         HandleDoors(true);
         DestroyPortals();
     }
+
     void SummonPortals()
     {
         uint8 r = rand()%4;
@@ -115,16 +133,18 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
         pos[RED_PORTAL] = (r%2 ? (r>1 ? 2: 1): 0);
         pos[GREEN_PORTAL] = (r%2 ? 0: (r>1 ? 2: 1));
         pos[BLUE_PORTAL] = (r>1 ? 1: 2); // Blue Portal not on the left side (0)
-        for (int i=0; i<3; ++i)
+
+        for(int i=0; i<3; ++i)
             if(Creature *portal = m_creature->SummonCreature(PortalID[i],PortalCoord[pos[i]][0],PortalCoord[pos[i]][1],PortalCoord[pos[i]][2],0,TEMPSUMMON_TIMED_DESPAWN,60000))
             {
                 PortalGUID[i] = portal->GetGUID();
                 portal->AddAura(PortalVisual[i], portal);
             }
     }
+
     void DestroyPortals()
     {
-        for (int i=0; i<3; ++i)
+        for(int i=0; i<3; ++i)
         {
             if(Creature *portal = Unit::GetCreature(*m_creature, PortalGUID[i]))
                 portal->DisappearAndDie();
@@ -134,20 +154,23 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
             BeamTarget[i] = 0;
         }
     }
+
     void UpdatePortals() // Here we handle the beams' behavior
     {
-        for (int j=0; j<3; ++j) // j = color
+        for(int j=0; j<3; ++j) // j = color
             if(Creature *portal = Unit::GetCreature(*m_creature, PortalGUID[j]))
             {
                 // the one who's been casted upon before
                 Unit *current = Unit::GetUnit(*portal, BeamTarget[j]);
                 // temporary store for the best suitable beam reciever
                 Unit *target = m_creature;
+
                 if(Map* map = m_creature->GetMap())
                 {
                     Map::PlayerList const& players = map->GetPlayers();
+
                     // get the best suitable target
-                    for (Map::PlayerList::const_iterator i = players.begin(); i!=players.end(); ++i)
+                    for(Map::PlayerList::const_iterator i = players.begin(); i!=players.end(); ++i)
                     {
                         Player* p = i->getSource();
                         if(p && p->isAlive() // alive
@@ -188,6 +211,7 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
                     m_creature->getThreatManager().addThreat(target, 100000.0f+DoGetThreat(m_creature->getVictim()));
             }
     }
+
     void SwitchToPortalPhase()
     {
         m_creature->RemoveAurasDueToSpell(SPELL_BANISH_ROOT);
@@ -199,6 +223,7 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
         EmpowermentTimer = 10000;
         DoScriptText(EMOTE_PHASE_PORTAL,m_creature);
     }
+
     void SwitchToBanishPhase()
     {
         m_creature->RemoveAurasDueToSpell(SPELL_EMPOWERMENT);
@@ -209,34 +234,41 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
         PhaseTimer = 30000;
         PortalPhase = false;
         DoScriptText(EMOTE_PHASE_BANISH,m_creature);
-        for (int i=0; i<3; ++i)
+
+        for(int i=0; i<3; ++i)
             m_creature->RemoveAurasDueToSpell(NetherBuff[i]);
     }
+
     void HandleDoors(bool open) // Massive Door switcher
     {
         if(GameObject *Door = GameObject::GetGameObject(*m_creature, pInstance ? pInstance->GetData64(DATA_GO_MASSIVE_DOOR) : 0))
             Door->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY);
     }
+
     void Aggro(Unit *who)
     {
         HandleDoors(false);
         SwitchToPortalPhase();
     }
+
     void JustDied(Unit* killer)
     {
         HandleDoors(true);
         DestroyPortals();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(!UpdateVictim())
             return;
+
         // Void Zone
         if(VoidZoneTimer < diff)
         {
             DoCast(SelectTarget(SELECT_TARGET_RANDOM,1,45,true),SPELL_VOIDZONE,true);
             VoidZoneTimer = 15000;
         }else VoidZoneTimer -= diff;
+
         // NetherInfusion Berserk
         if(!Berserk && NetherInfusionTimer < diff)
         {
@@ -244,6 +276,7 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
             DoCast(m_creature, SPELL_NETHERSPITE_ROAR);
             Berserk = true;
         }else NetherInfusionTimer -= diff;
+
         if(PortalPhase) // PORTAL PHASE
         {
             // Distribute beams and buffs
@@ -252,6 +285,7 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
                 UpdatePortals();
                 PortalTimer = 1000;
             }else PortalTimer -= diff;
+
             // Empowerment & Nether Burn
             if(EmpowermentTimer < diff)
             {
@@ -259,6 +293,7 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
                 m_creature->AddAura(SPELL_NETHERBURN_AURA, m_creature);
                 EmpowermentTimer = 90000;
             }else EmpowermentTimer -= diff;
+
             if(PhaseTimer < diff)
             {
                 if(!m_creature->IsNonMeleeSpellCasted(false))
@@ -277,6 +312,7 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
                     DoCast(target,SPELL_NETHERBREATH);
                 NetherbreathTimer = 5000+rand()%2000;
             }else NetherbreathTimer -= diff;
+
             if(PhaseTimer < diff)
             {
                 if(!m_creature->IsNonMeleeSpellCasted(false))
@@ -286,16 +322,20 @@ struct TRINITY_DLL_DECL boss_netherspiteAI : public ScriptedAI
                 }
             }else PhaseTimer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_netherspite(Creature *_Creature)
 {
     return new boss_netherspiteAI(_Creature);
 }
+
 void AddSC_boss_netherspite()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_netherspite";
     newscript->GetAI = GetAI_boss_netherspite;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_nightbane.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_nightbane.cpp
index b853414448d..0168ce10a35 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_nightbane.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_nightbane.cpp
@@ -13,14 +13,17 @@
  * along with 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: 80
 SDComment: SDComment: Timers may incorrect
 SDCategory: Karazhan
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_karazhan.h"
+
 //phase 1
 #define SPELL_BELLOWING_ROAR        39427
 #define SPELL_CHARRED_EARTH         30129
@@ -33,12 +36,14 @@ EndScriptData */
 #define SPELL_FIREBALL_BARRAGE      30282
 #define SPELL_SEARING_CINDERS       30127
 #define SPELL_SUMMON_SKELETON       30170
+
 #define EMOTE_SUMMON                "An ancient being awakens in the distance..."
 #define YELL_AGGRO                  "What fools! I shall bring a quick end to your suffering!"
 #define YELL_FLY_PHASE              "Miserable vermin. I shall exterminate you from the air!"
 #define YELL_LAND_PHASE_1           "Enough! I shall land and crush you myself!"
 #define YELL_LAND_PHASE_2           "Insects! Let me show you my strength up close!"
 #define EMOTE_BREATH                "takes a deep breath."
+
 float IntroWay[8][3] =
 {
     {-11053.37,-1794.48,149},
@@ -50,6 +55,7 @@ float IntroWay[8][3] =
     {-11140   , -1915  ,122},
     {-11163   , -1903  ,91.473}
 };
+
 struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
 {
     boss_nightbaneAI(Creature* c) : ScriptedAI(c)
@@ -57,10 +63,14 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         Intro = true;
     }
+
     ScriptedInstance* pInstance;
+
     uint32 Phase;
+
     bool RainBones;
     bool Skeletons;
+
     uint32 BellowingRoarTimer;
     uint32 CharredEarthTimer;
     uint32 DistractingAshTimer;
@@ -70,13 +80,17 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
     uint32 SmokingBlastTimer;
     uint32 FireballBarrageTimer;
     uint32 SearingCindersTimer;
+
     uint32 FlyCount;
     uint32 FlyTimer;
+
     bool Intro;
     bool Flying;
     bool Movement;
+
     uint32 WaitTimer;
     uint32 MovePhase;
+
     void Reset()
     {
         BellowingRoarTimer = 30000;
@@ -89,13 +103,16 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
         FireballBarrageTimer = 13000;
         SearingCindersTimer = 14000;
         WaitTimer = 1000;
+
         Phase =1;
         FlyCount = 0;
         MovePhase = 0;
+
         m_creature->SetSpeed(MOVE_RUN, 2.0f);
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
         m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
         m_creature->setActive(true);
+
         if (pInstance)
         {
             if (pInstance->GetData(TYPE_NIGHTBANE) == DONE || pInstance->GetData(TYPE_NIGHTBANE) == IN_PROGRESS)
@@ -103,15 +120,19 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
             else
                 pInstance->SetData(TYPE_NIGHTBANE, NOT_STARTED);
         }
+
         HandleTerraceDoors(true);
+
         Flying = false;
         Movement = false;
+
         if (!Intro)
         {
             m_creature->SetHomePosition(IntroWay[7][0],IntroWay[7][1],IntroWay[7][2],0);
             m_creature->GetMotionMaster()->MoveTargetedHome();
         }
     }
+
     void HandleTerraceDoors(bool open)
     {
         if(pInstance)
@@ -120,33 +141,41 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
             pInstance->HandleGameObject(pInstance->GetData64(DATA_MASTERS_TERRACE_DOOR_2), open);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(TYPE_NIGHTBANE, IN_PROGRESS);
+
         HandleTerraceDoors(false);
         m_creature->MonsterYell(YELL_AGGRO, LANG_UNIVERSAL, NULL);
     }
+
     void AttackStart(Unit* who)
     {
         if (!Intro && !Flying)
             ScriptedAI::AttackStart(who);
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
             pInstance->SetData(TYPE_NIGHTBANE, DONE);
+
         HandleTerraceDoors(true);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!Intro && !Flying)
             ScriptedAI::MoveInLineOfSight(who);
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
                 return;
+
         if (Intro)
         {
             if (id >= 8)
@@ -155,8 +184,10 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                 m_creature->SetHomePosition(IntroWay[7][0],IntroWay[7][1],IntroWay[7][2],0);
                 return;
             }
+
             WaitTimer = 1;
         }
+
         if (Flying)
         {
             if (id == 0)
@@ -166,12 +197,14 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                 Phase = 2;
                 return;
             }
+
             if (id == 3)
             {
                 MovePhase = 4;
                 WaitTimer = 1;
                 return;
             }
+
             if (id == 8)
             {
                 Flying = false;
@@ -179,28 +212,36 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                 Movement = true;
                 return;
             }
+
             WaitTimer = 1;
         }
     }
+
     void JustSummoned(Creature *summoned)
     {
         summoned->AI()->AttackStart(m_creature->getVictim());
     }
+
     void TakeOff()
     {
         m_creature->MonsterYell(YELL_FLY_PHASE, LANG_UNIVERSAL, NULL);
+
         m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
         m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
         (*m_creature).GetMotionMaster()->Clear(false);
         (*m_creature).GetMotionMaster()->MovePoint(0,IntroWay[2][0],IntroWay[2][1],IntroWay[2][2]);
+
         Flying = true;
+
         FlyTimer = 45000+rand()%15000; //timer wrong between 45 and 60 seconds
         ++FlyCount;
+
         RainofBonesTimer = 5000; //timer wrong (maybe)
         RainBones = false;
         Skeletons = false;
      }
+
     void UpdateAI(const uint32 diff)
     {
         if (WaitTimer)
@@ -220,6 +261,7 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                     ++MovePhase;
                 }
             }
+
             if (Flying)
             {
                 if (MovePhase >= 7)
@@ -234,12 +276,16 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                     ++MovePhase;
                 }
             }
+
             WaitTimer = 0;
         }else WaitTimer -= diff;
+
         if (!UpdateVictim())
             return;
+
         if (Flying)
             return;
+
         //  Phase 1 "GROUND FIGHT"
         if (Phase == 1)
         {
@@ -248,22 +294,26 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                 DoStartMovement(m_creature->getVictim());
                 Movement = false;
             }
+
             if (BellowingRoarTimer < diff)
             {
                 DoCast(m_creature->getVictim(),SPELL_BELLOWING_ROAR);
                 BellowingRoarTimer = 30000+rand()%10000 ; //Timer
             }else BellowingRoarTimer -= diff;
+
             if (SmolderingBreathTimer < diff)
             {
                 DoCast(m_creature->getVictim(),SPELL_SMOLDERING_BREATH);
                 SmolderingBreathTimer = 20000;//timer
             }else SmolderingBreathTimer -= diff;
+
             if (CharredEarthTimer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                     DoCast(target,SPELL_CHARRED_EARTH);
                 CharredEarthTimer = 20000; //timer
             }else CharredEarthTimer -= diff;
+
             if (TailSweepTimer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -271,22 +321,29 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                         DoCast(target,SPELL_TAIL_SWEEP);
                 TailSweepTimer = 15000;//timer
             }else TailSweepTimer -= diff;
+
             if (SearingCindersTimer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                     DoCast(target,SPELL_SEARING_CINDERS);
                 SearingCindersTimer = 10000; //timer
             }else SearingCindersTimer -= diff;
+
             uint32 Prozent;
             Prozent = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth();
+
             if (Prozent < 75 && FlyCount == 0) // first take off 75%
                 TakeOff();
+
             if (Prozent < 50 && FlyCount == 1) // secound take off 50%
                 TakeOff();
+
             if (Prozent < 25 && FlyCount == 2) // third take off 25%
                 TakeOff();
+
             DoMeleeAttackIfReady();
         }
+
         //Phase 2 "FLYING FIGHT"
         if (Phase == 2)
         {
@@ -300,12 +357,14 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                         Skeletons = true;
                     }
                 }
+
                 if (RainofBonesTimer < diff && !RainBones) // only once at the beginning of phase 2
                 {
                     DoCast(m_creature->getVictim(),SPELL_RAIN_OF_BONES);
                     RainBones = true;
                     SmokingBlastTimer = 20000;
                 }else RainofBonesTimer -= diff;
+
                 if (DistractingAshTimer < diff)
                 {
                     if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -313,6 +372,7 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                     DistractingAshTimer = 2000;//timer wrong
                 }else DistractingAshTimer -= diff;
             }
+
             if (RainBones)
             {
                 if (SmokingBlastTimer < diff)
@@ -321,29 +381,35 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
                     SmokingBlastTimer = 1500 ; //timer wrong
                  }else SmokingBlastTimer -= diff;
             }
+
             if (FireballBarrageTimer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_FARTHEST, 0))
                     DoCast(target,SPELL_FIREBALL_BARRAGE);
                 FireballBarrageTimer = 20000; //Timer
             }else FireballBarrageTimer -= diff;
+
             if (FlyTimer < diff) //landing
             {
                 if (rand()%2 == 0)
                     m_creature->MonsterYell(YELL_LAND_PHASE_1, LANG_UNIVERSAL, NULL);
                 else
                     m_creature->MonsterYell(YELL_LAND_PHASE_2, LANG_UNIVERSAL, NULL);
+
                 (*m_creature).GetMotionMaster()->Clear(false);
                 m_creature->GetMotionMaster()->MovePoint(3,IntroWay[3][0],IntroWay[3][1],IntroWay[3][2]);
+
                 Flying = true;
             }else FlyTimer -= diff;
         }
     }
 };
+
 CreatureAI* GetAI_boss_nightbane(Creature* pCreature)
 {
     return new boss_nightbaneAI (pCreature);
 }
+
 void AddSC_boss_nightbane()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp
index 89640d64ba0..4f78b626067 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp
@@ -13,14 +13,17 @@
  * along with 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"
 #include "def_karazhan.h"
+
 #define SAY_AGGRO           -1532091
 #define SAY_AXE_TOSS1       -1532092
 #define SAY_AXE_TOSS2       -1532093
@@ -33,12 +36,15 @@ EndScriptData */
 #define SAY_SUMMON1         -1532100
 #define SAY_SUMMON2         -1532101
 #define SAY_DEATH           -1532102
+
 // 18 Coordinates for Infernal spawns
 struct InfernalPoint
 {
     float x,y;
 };
+
 #define INFERNAL_Z  275.5
+
 static InfernalPoint InfernalPoints[] =
 {
     {-10922.8, -1985.2},
@@ -60,12 +66,16 @@ static InfernalPoint InfernalPoints[] =
     {-10932.8, -1979.6},
     {-10935.7, -1996.0}
 };
+
 #define TOTAL_INFERNAL_POINTS       18
+
 //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
@@ -77,21 +87,27 @@ static InfernalPoint InfernalPoints[] =
 #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 EQUIP_ID_AXE                33542                      //Axes info
+
 //---------Infernal code first
 struct TRINITY_DLL_DECL netherspite_infernalAI : public ScriptedAI
 {
     netherspite_infernalAI(Creature *c) : ScriptedAI(c) ,
         malchezaar(0), HellfireTimer(0), CleanupTimer(0), point(NULL) {}
+
     uint32 HellfireTimer;
     uint32 CleanupTimer;
     uint32 malchezaar;
     InfernalPoint *point;
+
     void Reset() {}
     void EnterCombat(Unit *who) {}
     void MoveInLineOfSight(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (HellfireTimer)
@@ -101,6 +117,7 @@ struct TRINITY_DLL_DECL netherspite_infernalAI : public ScriptedAI
             HellfireTimer = 0;
         }
         else HellfireTimer -= diff;
+
         if (CleanupTimer)
             if (CleanupTimer <= diff)
         {
@@ -108,12 +125,14 @@ struct TRINITY_DLL_DECL netherspite_infernalAI : public ScriptedAI
             CleanupTimer = 0;
         } else CleanupTimer -= diff;
     }
+
     void KilledUnit(Unit *who)
     {
         Unit *pMalchezaar = Unit::GetUnit(*m_creature, malchezaar);
         if (pMalchezaar)
             CAST_CRE(pMalchezaar)->AI()->KilledUnit(who);
     }
+
     void SpellHit(Unit *who, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_INFERNAL_RELAY)
@@ -124,19 +143,23 @@ struct TRINITY_DLL_DECL netherspite_infernalAI : public ScriptedAI
             CleanupTimer = 170000;
         }
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by->GetGUID() != malchezaar)
             damage = 0;
     }
+
     void Cleanup();                                         //below ...
 };
+
 struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
 {
     boss_malchezaarAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
     uint32 EnfeebleTimer;
     uint32 EnfeebleResetTimer;
@@ -148,22 +171,29 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
     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 (uint8 i =0; i < 5; ++i)
+
+        for(uint8 i =0; i < 5; ++i)
             enfeeble_targets[i] = 0;
-        for (uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
+
+        for(uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
             positions.push_back(&InfernalPoints[i]);
+
         EnfeebleTimer = 30000;
         EnfeebleResetTimer = 38000;
         ShadowNovaTimer = 35500;
@@ -175,35 +205,44 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
         AxesTargetSwitchTimer = 7500 + rand()%12500;
         SunderArmorTimer = 5000 + rand()%5000;
         phase = 1;
+
         if (pInstance)
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_NETHER_DOOR), true);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         AxesCleanup();
         ClearWeapons();
         InfernalCleanup();
         positions.clear();
-        for (uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
+
+        for(uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
             positions.push_back(&InfernalPoints[i]);
+
         if (pInstance)
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_NETHER_DOOR), true);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_NETHER_DOOR), false); // Open the door leading further in
     }
+
     void InfernalCleanup()
     {
         //Infernal Cleanup
-        for (std::vector::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr)
+        for(std::vector::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr)
         {
             Unit *pInfernal = Unit::GetUnit(*m_creature, *itr);
             if (pInfernal && pInfernal->isAlive())
@@ -214,9 +253,10 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
         }
         infernals.clear();
     }
+
     void AxesCleanup()
     {
-        for (uint8 i=0; i<2; ++i)
+        for(uint8 i=0; i<2; ++i)
         {
             Unit *axe = Unit::GetUnit(*m_creature, axes[i]);
             if (axe && axe->isAlive())
@@ -224,53 +264,64 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
             axes[i] = 0;
         }
     }
+
     void ClearWeapons()
     {
         SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_UNEQUIP, EQUIP_NO_CHANGE);
+
         //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
+        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 iter = targets.begin(); iter!= targets.end(); ++iter, ++i)
+        for(std::vector::iterator iter = targets.begin(); iter!= targets.end(); ++iter, ++i)
         {
             Unit *target = *iter;
             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 (uint8 i = 0; i < 5; ++i)
+        for(uint8 i = 0; i < 5; ++i)
         {
             Unit *target = Unit::GetUnit(*m_creature, enfeeble_targets[i]);
             if (target && target->isAlive())
@@ -279,6 +330,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
             enfeeble_health[i] = 0;
         }
     }
+
     void SummonInfernal(const uint32 diff)
     {
         InfernalPoint *point = NULL;
@@ -292,7 +344,9 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
             positions.erase(itr);
             pos.Relocate(point->x, point->y, INFERNAL_Z);
         }
+
         Creature *Infernal = m_creature->SummonCreature(NETHERSPITE_INFERNAL, pos, TEMPSUMMON_TIMED_DESPAWN, 180000);
+
         if (Infernal)
         {
             Infernal->SetDisplayId(INFERNAL_MODEL_INVISIBLE);
@@ -300,49 +354,64 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
             if (point)
                 CAST_AI(netherspite_infernalAI, Infernal->AI())->point=point;
             CAST_AI(netherspite_infernalAI, Infernal->AI())->malchezaar=m_creature->GetGUID();
+
             infernals.push_back(Infernal->GetGUID());
             DoCast(Infernal, SPELL_INFERNAL_RELAY);
         }
+
         DoScriptText(RAND(SAY_SUMMON1,SAY_SUMMON2), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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_STUNNED))     //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
                 DoScriptText(SAY_AXE_TOSS1, m_creature);
+
                 //passive thrash aura
                 m_creature->CastSpell(m_creature, SPELL_THRASH_AURA, true);
+
                 //models
                 SetEquipmentSlots(false, EQUIP_ID_AXE, EQUIP_ID_AXE, EQUIP_NO_CHANGE);
+
                 //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, (m_creature->GetAttackTime(BASE_ATTACK)*150)/100);
             }
         }
@@ -351,13 +420,18 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
             if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 30)
             {
                 InfernalTimer = 15000;
+
                 phase = 3;
+
                 ClearWeapons();
+
                 //remove thrash
                 m_creature->RemoveAurasDueToSpell(SPELL_THRASH_AURA);
+
                 DoScriptText(SAY_AXE_TOSS2, m_creature);
+
                 Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
-                for (uint32 i=0; i<2; ++i)
+                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)
@@ -374,19 +448,25 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
                         }
                     }
                 }
+
                 if (ShadowNovaTimer > 35000)
                     ShadowNovaTimer = EnfeebleTimer + 5000;
+
                 return;
             }
+
             if (SunderArmorTimer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_SUNDER_ARMOR);
                 SunderArmorTimer = 10000 + rand()%8000;
+
             }else SunderArmorTimer -= diff;
+
             if (Cleave_Timer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_CLEAVE);
                 Cleave_Timer = 6000 + rand()%6000;
+
             }else Cleave_Timer -= diff;
         }
         else
@@ -394,10 +474,11 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
             if (AxesTargetSwitchTimer < diff)
             {
                 AxesTargetSwitchTimer = 7500 + rand()%12500 ;
+
                 Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
                 if (target)
                 {
-                    for (uint8 i = 0; i < 2; ++i)
+                    for(uint8 i = 0; i < 2; ++i)
                     {
                         Unit *axe = Unit::GetUnit(*m_creature, axes[i]);
                         if (axe)
@@ -413,23 +494,27 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
                     }
                 }
             } 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 ? 14500 : 44500;    //15 secs in phase 3, 45 otherwise
         }else InfernalTimer -= diff;
+
         if (ShadowNovaTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SHADOWNOVA);
             ShadowNovaTimer = phase == 3 ? 31000 : -1;
         }else ShadowNovaTimer -= diff;
+
         if (phase != 2)
         {
             if (SWPainTimer < diff)
@@ -439,11 +524,14 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
                     target = m_creature->getVictim();       // the tank
                 else                                        //anyone but the tank
                     target = SelectUnit(SELECT_TARGET_RANDOM, 1);
+
                 if (target)
                     DoCast(target, SPELL_SW_PAIN);
+
                 SWPainTimer = 20000;
             }else SWPainTimer -= diff;
         }
+
         if (phase != 3)
         {
             if (EnfeebleTimer < diff)
@@ -454,11 +542,13 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
                 EnfeebleResetTimer = 9000;
             }else EnfeebleTimer -= diff;
         }
+
         if (phase==2)
             DoMeleeAttacksIfReady();
         else
             DoMeleeAttackIfReady();
     }
+
     void DoMeleeAttacksIfReady()
     {
         if (m_creature->IsWithinMeleeRange(m_creature->getVictim()) && !m_creature->IsNonMeleeSpellCasted(false))
@@ -477,31 +567,38 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
             }
         }
     }
+
     void Cleanup(Creature *infernal, InfernalPoint *point)
     {
-        for (std::vector::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr)
+        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())
         CAST_AI(boss_malchezaarAI, CAST_CRE(pMalchezaar)->AI())->Cleanup(m_creature, point);
 }
+
 CreatureAI* GetAI_netherspite_infernal(Creature* pCreature)
 {
     return new netherspite_infernalAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_malchezaar(Creature* pCreature)
 {
     return new boss_malchezaarAI (pCreature);
 }
+
 void AddSC_boss_malchezaar()
 {
     Script *newscript;
@@ -509,6 +606,7 @@ void AddSC_boss_malchezaar()
     newscript->Name = "boss_malchezaar";
     newscript->GetAI = &GetAI_boss_malchezaar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "netherspite_infernal";
     newscript->GetAI = &GetAI_netherspite_infernal;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_shade_of_aran.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_shade_of_aran.cpp
index c30c7c54500..5bdd4304d33 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_shade_of_aran.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_shade_of_aran.cpp
@@ -13,16 +13,19 @@
  * along with 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.
 SDCategory: Karazhan
 EndScriptData */
+
 #include "precompiled.h"
 #include "simple_ai.h"
 #include "def_karazhan.h"
 #include "GameObject.h"
+
 #define SAY_AGGRO1                  -1532073
 #define SAY_AGGRO2                  -1532074
 #define SAY_AGGRO3                  -1532075
@@ -39,6 +42,7 @@ EndScriptData */
 #define SAY_TIMEOVER                -1532086
 #define SAY_DEATH                   -1532087
 #define SAY_ATIESH                  -1532088                //Atiesh is equipped by a raid member
+
 //Spells
 #define SPELL_FROSTBOLT     29954
 #define SPELL_FIREBALL      29953
@@ -57,46 +61,58 @@ EndScriptData */
 #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 TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
 {
     boss_aranAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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;
@@ -104,17 +120,23 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
         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
@@ -122,47 +144,57 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_LIBRARY_DOOR), true);
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_KILL1,SAY_KILL2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(TYPE_ARAN, DONE);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_LIBRARY_DOOR), true);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(TYPE_ARAN, IN_PROGRESS);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_LIBRARY_DOOR), false);
         }
     }
+
     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)
+        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)
+        for(std::vector::iterator itr = targets.begin(); itr!= targets.end(); ++itr)
         {
             if (*itr)
             {
@@ -174,10 +206,12 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (CloseDoorTimer)
         {
             if (CloseDoorTimer <= diff)
@@ -189,6 +223,7 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                 }
             }else CloseDoorTimer -= diff;
         }
+
         //Cooldowns for casts
         if (ArcaneCooldown)
         {
@@ -196,23 +231,28 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                 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);
+
             DoScriptText(SAY_DRINK, m_creature);
+
             if (!DrinkInturrupted)
             {
                 m_creature->CastSpell(m_creature, SPELL_MASS_POLY, true);
@@ -222,6 +262,7 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                 DrinkInturruptTimer = 10000;
             }
         }
+
         //Drink Inturrupt
         if (Drinking && DrinkInturrupted)
         {
@@ -231,6 +272,7 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
             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)
@@ -243,9 +285,11 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
             DrinkInturrupted = true;
             Drinking = false;
         }
+
         //Don't execute any more code if we are drinking
         if (Drinking)
             return;
+
         //Normal casts
         if (NormalCastTimer < diff)
         {
@@ -255,8 +299,10 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                 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)
                 {
@@ -273,6 +319,7 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                     Spells[AvailableSpells] = SPELL_FROSTBOLT;
                     AvailableSpells++;
                 }
+
                 //If no available spells wait 1 second and try again
                 if (AvailableSpells)
                 {
@@ -282,10 +329,12 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
             }
             NormalCastTimer = 1000;
         }else NormalCastTimer -= diff;
+
         if (SecondarySpellTimer < diff)
         {
             switch (rand()%2)
             {
+
                 case 0:
                     DoCast(m_creature, SPELL_AOE_CS);
                     break;
@@ -296,9 +345,11 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
             }
             SecondarySpellTimer = 5000 + (rand()%15000);
         }else SecondarySpellTimer -= diff;
+
         if (SuperCastTimer < diff)
         {
             uint8 Available[2];
+
             switch (LastSuperSpell)
             {
                 case SUPER_AE:
@@ -314,36 +365,47 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                     Available[1] = SUPER_AE;
                     break;
             }
+
             LastSuperSpell = Available[rand()%2];
+
             switch (LastSuperSpell)
             {
                 case SUPER_AE:
+
                     if (rand()%2)
                         DoScriptText(SAY_EXPLOSION1, m_creature);
                     else
                         DoScriptText(SAY_EXPLOSION2, m_creature);
+
                     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)
                         DoScriptText(SAY_FLAMEWREATH1, m_creature);
                     else
                         DoScriptText(SAY_FLAMEWREATH2, m_creature);
+
                     FlameWreathTimer = 20000;
                     FlameWreathCheckTime = 500;
+
                     FlameWreathTarget[0] = 0;
                     FlameWreathTarget[1] = 0;
                     FlameWreathTarget[2] = 0;
+
                     FlameWreathEffect();
                     break;
+
                 case SUPER_BLIZZARD:
+
                     if (rand()%2)
                         DoScriptText(SAY_BLIZZARD1, m_creature);
                     else
                         DoScriptText(SAY_BLIZZARD2, m_creature);
+
                     if (Creature* pSpawn = m_creature->SummonCreature(CREATURE_ARAN_BLIZZARD, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 25000))
                     {
                         pSpawn->setFaction(m_creature->getFaction());
@@ -351,11 +413,14 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                     }
                     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)
             {
                 if (Creature* pUnit = m_creature->SummonCreature(CREATURE_WATER_ELEMENTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 90000))
@@ -364,8 +429,10 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                     pUnit->setFaction(m_creature->getFaction());
                 }
             }
+
             DoScriptText(SAY_ELEMENTALS, m_creature);
         }
+
         if (BerserkTimer < diff)
         {
             for (uint32 i = 0; i < 5; ++i)
@@ -376,21 +443,26 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                     pUnit->setFaction(m_creature->getFaction());
                 }
             }
+
             DoScriptText(SAY_TIMEOVER, m_creature);
+
             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->IsWithinDist2d(FWTargPosX[i], FWTargPosY[i], 3))
                     {
@@ -402,14 +474,17 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
                 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
@@ -417,10 +492,13 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
             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;
@@ -429,19 +507,25 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL water_elementalAI : public ScriptedAI
 {
     water_elementalAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 CastTimer;
+
     void Reset()
     {
         CastTimer = 2000 + (rand()%3000);
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (CastTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_WATERBOLT);
@@ -449,27 +533,34 @@ struct TRINITY_DLL_DECL water_elementalAI : public ScriptedAI
         }else CastTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_aran(Creature* pCreature)
 {
     return new boss_aranAI (pCreature);
 }
+
 CreatureAI* GetAI_water_elemental(Creature* pCreature)
 {
     return new water_elementalAI (pCreature);
 }
+
 // CONVERT TO ACID
 CreatureAI* GetAI_shadow_of_aran(Creature* pCreature)
 {
     outstring_log("TSCR: Convert simpleAI script for Creature Entry %u to ACID", pCreature->GetEntry());
     SimpleAI* ai = new SimpleAI (pCreature);
+
     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;
@@ -477,10 +568,12 @@ void AddSC_boss_shade_of_aran()
     newscript->Name = "boss_shade_of_aran";
     newscript->GetAI = &GetAI_boss_aran;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_shadow_of_aran";
     newscript->GetAI = &GetAI_shadow_of_aran;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_aran_elemental";
     newscript->GetAI = &GetAI_water_elemental;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_terestian_illhoof.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_terestian_illhoof.cpp
index 82684f57181..f60fab0bddb 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_terestian_illhoof.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_terestian_illhoof.cpp
@@ -13,14 +13,17 @@
  * along with 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: 95
 SDComment: Complete! Needs adjustments to use spell though.
 SDCategory: Karazhan
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_karazhan.h"
+
 #define SAY_SLAY1                   -1532065
 #define SAY_SLAY2                   -1532066
 #define SAY_DEATH                   -1532067
@@ -29,6 +32,7 @@ EndScriptData */
 #define SAY_SACRIFICE2              -1532070
 #define SAY_SUMMON1                 -1532071
 #define SAY_SUMMON2                 -1532072
+
 #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.
@@ -37,29 +41,38 @@ EndScriptData */
 #define SPELL_BERSERK               32965                   // Increases attack speed by 75%. Periodically casts Shadow Bolt Volley.
 #define SPELL_SUMMON_FIENDISIMP     30184                   // Summons a Fiendish Imp.
 #define SPELL_SUMMON_IMP            30066                   // Summons Kil'rek
+
 #define SPELL_FIENDISH_PORTAL       30171                   // Opens portal and summons Fiendish Portal, 2 sec cast
 #define SPELL_FIENDISH_PORTAL_1     30179                   // Opens portal and summons Fiendish Portal, instant cast
+
 #define SPELL_FIREBOLT              30050                   // 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 CREATURE_DEMONCHAINS    17248
 #define CREATURE_FIENDISHIMP    17267
 #define CREATURE_PORTAL         17265
 #define CREATURE_KILREK         17229
+
 struct TRINITY_DLL_DECL mob_kilrekAI : public ScriptedAI
 {
     mob_kilrekAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint64 TerestianGUID;
+
     uint32 AmplifyTimer;
+
     void Reset()
     {
         TerestianGUID = 0;
         AmplifyTimer = 2000;
     }
+
     void EnterCombat(Unit *who)
     {
         if (!pInstance)
@@ -68,6 +81,7 @@ struct TRINITY_DLL_DECL mob_kilrekAI : public ScriptedAI
             return;
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
@@ -81,31 +95,40 @@ struct TRINITY_DLL_DECL mob_kilrekAI : public ScriptedAI
             }
         }else ERROR_INST_DATA(m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (AmplifyTimer < diff)
         {
             m_creature->InterruptNonMeleeSpells(false);
             DoCast(m_creature->getVictim(),SPELL_AMPLIFY_FLAMES);
+
             AmplifyTimer = 10000 + rand()%10000;
         }else AmplifyTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_demon_chainAI : public ScriptedAI
 {
     mob_demon_chainAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 SacrificeGUID;
+
     void Reset()
     {
         SacrificeGUID = 0;
     }
+
     void EnterCombat(Unit* who) {}
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
+
     void JustDied(Unit *killer)
     {
         if (SacrificeGUID)
@@ -116,44 +139,55 @@ struct TRINITY_DLL_DECL mob_demon_chainAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_fiendish_portalAI : public PassiveAI
 {
     mob_fiendish_portalAI(Creature *c) : PassiveAI(c),summons(m_creature){}
+
     SummonList summons;
+
     void Reset()
     {
         summons.DespawnAll();
     }
+
     void JustSummoned(Creature* summon)
     {
         summons.Summon(summon);
         DoZoneInCombat(summon);
     }
+
     void DespawnAllImp()
     {
         summons.DespawnAll();
     }
 };
+
 struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI
 {
     boss_terestianAI(Creature *c) : ScriptedAI(c)
     {
-        for (uint8 i = 0; i < 2; ++i)
+        for(uint8 i = 0; i < 2; ++i)
             PortalGUID[i] = 0;
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint64 PortalGUID[2];
     uint8 PortalsCount;
+
     uint32 SacrificeTimer;
     uint32 ShadowboltTimer;
     uint32 SummonTimer;
     uint32 BerserkTimer;
+
     bool SummonedPortals;
     bool Berserk;
+
     void Reset()
     {
-        for (uint8 i = 0; i < 2; ++i)
+        for(uint8 i = 0; i < 2; ++i)
         {
             if (PortalGUID[i])
             {
@@ -162,19 +196,25 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI
                     CAST_AI(mob_fiendish_portalAI, pPortal->AI())->DespawnAllImp();
                     pPortal->ForcedDespawn();
                 }
+
                 PortalGUID[i] = 0;
             }
         }
+
         PortalsCount        =     0;
         SacrificeTimer      = 30000;
         ShadowboltTimer     =  5000;
         SummonTimer         = 10000;
         BerserkTimer        = 600000;
+
         SummonedPortals     = false;
         Berserk             = false;
+
         if (pInstance)
             pInstance->SetData(TYPE_TERESTIAN, NOT_STARTED);
+
         m_creature->RemoveAurasDueToSpell(SPELL_BROKEN_PACT);
+
         if(Minion* Kilrek = m_creature->GetFirstMinion())
         {
             if(!Kilrek->isAlive())
@@ -185,16 +225,19 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI
         }
         else DoCast(m_creature, SPELL_SUMMON_IMP, true);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (pSummoned->GetEntry() == CREATURE_PORTAL)
         {
             PortalGUID[PortalsCount] = pSummoned->GetGUID();
             PortalsCount++;
+
             if (pSummoned->GetUInt32Value(UNIT_CREATED_BY_SPELL) == SPELL_FIENDISH_PORTAL_1)
             {
                 DoScriptText(RAND(SAY_SUMMON1,SAY_SUMMON2), m_creature);
@@ -202,29 +245,36 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *killer)
     {
-        for (uint8 i = 0; i < 2; ++i)
+        for(uint8 i = 0; i < 2; ++i)
         {
             if (PortalGUID[i])
             {
                 if (Creature* pPortal = Unit::GetCreature((*m_creature), PortalGUID[i]))
                     pPortal->ForcedDespawn();
+
                 PortalGUID[i] = 0;
             }
         }
+
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_TERESTIAN, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (SacrificeTimer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
@@ -232,6 +282,7 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI
             {
                 DoCast(target, SPELL_SACRIFICE, true);
                 DoCast(target, SPELL_SUMMON_DEMONCHAINS, true);
+
                 Creature* Chains = m_creature->FindNearestCreature(CREATURE_DEMONCHAINS, 5000);
                 if (Chains)
                 {
@@ -242,17 +293,21 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI
                 }
             }
         }else SacrificeTimer -= diff;
+
         if (ShadowboltTimer < diff)
         {
             DoCast(SelectUnit(SELECT_TARGET_TOPAGGRO, 0), SPELL_SHADOW_BOLT);
             ShadowboltTimer = 10000;
         }else ShadowboltTimer -= diff;
+
         if (SummonTimer < diff)
         {
             if(!PortalGUID[0])
                 DoCast(m_creature->getVictim(), SPELL_FIENDISH_PORTAL, false);
+
             if(!PortalGUID[1])
                 DoCast(m_creature->getVictim(), SPELL_FIENDISH_PORTAL_1, false);
+
             if(PortalGUID[0] && PortalGUID[1])
             {
                 if (Creature* pPortal = Unit::GetCreature(*m_creature, PortalGUID[rand()%2]))
@@ -260,6 +315,7 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI
                 SummonTimer = 5000;
             }
         }else SummonTimer -= diff;
+
         if (!Berserk)
         {
             if (BerserkTimer < diff)
@@ -268,53 +324,69 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI
                 Berserk = true;
             }else BerserkTimer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 #define SPELL_FIREBOLT  30050   // Blasts a target for 181-209 Fire damage.
+
 struct TRINITY_DLL_DECL mob_fiendish_impAI : public ScriptedAI
 {
     mob_fiendish_impAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 FireboltTimer;
+
     void Reset()
     {
         FireboltTimer = 2000;
+
         m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true);
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (FireboltTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_FIREBOLT);
             FireboltTimer = 2200;
         }else FireboltTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_kilrek(Creature* pCreature)
 {
     return new mob_kilrekAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_fiendish_imp(Creature* pCreature)
 {
     return new mob_fiendish_impAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_fiendish_portal(Creature* pCreature)
 {
     return new mob_fiendish_portalAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_terestian_illhoof(Creature* pCreature)
 {
     return new boss_terestianAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_demon_chain(Creature* pCreature)
 {
     return new mob_demon_chainAI(pCreature);
 }
+
 void AddSC_boss_terestian_illhoof()
 {
     Script *newscript;
@@ -322,18 +394,22 @@ void AddSC_boss_terestian_illhoof()
     newscript->Name = "boss_terestian_illhoof";
     newscript->GetAI = &GetAI_boss_terestian_illhoof;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_fiendish_imp";
     newscript->GetAI = &GetAI_mob_fiendish_imp;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name= "mob_fiendish_portal";
     newscript->GetAI = &GetAI_mob_fiendish_portal;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_kilrek";
     newscript->GetAI = &GetAI_mob_kilrek;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_demon_chain";
     newscript->GetAI = &GetAI_mob_demon_chain;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/bosses_opera.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/bosses_opera.cpp
index c402bb2bfee..51827bd3fb3 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/bosses_opera.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/bosses_opera.cpp
@@ -13,65 +13,83 @@
  * along 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 *****/
 /*********************************/
+
 #define SAY_DOROTHEE_DEATH          -1532025
 #define SAY_DOROTHEE_SUMMON         -1532026
 #define SAY_DOROTHEE_TITO_DEATH     -1532027
 #define SAY_DOROTHEE_AGGRO          -1532028
+
 #define SAY_ROAR_AGGRO              -1532029
 #define SAY_ROAR_DEATH              -1532030
 #define SAY_ROAR_SLAY               -1532031
+
 #define SAY_STRAWMAN_AGGRO          -1532032
 #define SAY_STRAWMAN_DEATH          -1532033
 #define SAY_STRAWMAN_SLAY           -1532034
+
 #define SAY_TINHEAD_AGGRO           -1532035
 #define SAY_TINHEAD_DEATH           -1532036
 #define SAY_TINHEAD_SLAY            -1532037
 #define EMOTE_RUST                  -1532038
+
 #define SAY_CRONE_AGGRO             -1532039
 #define SAY_CRONE_AGGRO2            -1532040
 #define SAY_CRONE_DEATH             -1532041
 #define SAY_CRONE_SLAY              -1532042
+
 /**** 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
+
 void SummonCroneIfReady(ScriptedInstance* pInstance, Creature* pCreature)
 {
     pInstance->SetData(DATA_OPERA_OZ_DEATHCOUNT, SPECIAL);  // Increment DeathCount
+
     if (pInstance->GetData(DATA_OPERA_OZ_DEATHCOUNT) == 4)
     {
         if (Creature* pCrone = pCreature->SummonCreature(CREATURE_CRONE, -10891.96, -1755.95, pCreature->GetPositionZ(), 4.64, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, HOUR*2*IN_MILISECONDS))
@@ -81,55 +99,73 @@ void SummonCroneIfReady(ScriptedInstance* pInstance, Creature* pCreature)
         }
     }
 };
+
 struct TRINITY_DLL_DECL boss_dorotheeAI : public ScriptedAI
 {
     boss_dorotheeAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 AggroTimer;
+
     uint32 WaterBoltTimer;
     uint32 FearTimer;
     uint32 SummonTitoTimer;
+
     bool SummonedTito;
     bool TitoDied;
+
     void Reset()
     {
         AggroTimer = 500;
+
         WaterBoltTimer = 5000;
         FearTimer = 15000;
         SummonTitoTimer = 47500;
+
         SummonedTito = false;
         TitoDied = false;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_DOROTHEE_AGGRO, m_creature);
     }
+
     void JustReachedHome()
     {
         m_creature->ForcedDespawn();
     }
+
     void SummonTito();                                      // See below
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DOROTHEE_DEATH, m_creature);
+
         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)
@@ -140,38 +176,48 @@ struct TRINITY_DLL_DECL boss_dorotheeAI : public ScriptedAI
                 AggroTimer = 0;
             }else AggroTimer -= diff;
         }
+
         if (!UpdateVictim())
             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 TRINITY_DLL_DECL mob_titoAI : public ScriptedAI
 {
     mob_titoAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 DorotheeGUID;
     uint32 YipTimer;
+
     void Reset()
     {
         DorotheeGUID = 0;
         YipTimer = 10000;
     }
+
     void EnterCombat(Unit* who) {}
+
     void JustDied(Unit* killer)
     {
         if (DorotheeGUID)
@@ -184,18 +230,22 @@ struct TRINITY_DLL_DECL mob_titoAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (YipTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_YIPPING);
             YipTimer = 10000;
         }else YipTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 void boss_dorotheeAI::SummonTito()
 {
     if (Creature* pTito = m_creature->SummonCreature(CREATURE_TITO, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000))
@@ -207,42 +257,53 @@ void boss_dorotheeAI::SummonTito()
         TitoDied = false;
     }
 }
+
 struct TRINITY_DLL_DECL boss_strawmanAI : public ScriptedAI
 {
     boss_strawmanAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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 EnterCombat(Unit* who)
     {
         DoScriptText(SAY_STRAWMAN_AGGRO, m_creature);
     }
+
     void JustReachedHome()
     {
         m_creature->ForcedDespawn();
     }
+
     void SpellHit(Unit* caster, const SpellEntry *Spell)
     {
         if ((Spell->SchoolMask == SPELL_SCHOOL_MASK_FIRE) && (!(rand()%10)))
@@ -251,19 +312,24 @@ struct TRINITY_DLL_DECL boss_strawmanAI : public ScriptedAI
                 if (not direct damage(aoe,dot))
                     return;
             */
+
             DoCast(m_creature, SPELL_BURNING_STRAW, true);
         }
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_STRAWMAN_DEATH, m_creature);
+
         if (pInstance)
             SummonCroneIfReady(pInstance, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(SAY_STRAWMAN_SLAY, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (AggroTimer)
@@ -274,69 +340,89 @@ struct TRINITY_DLL_DECL boss_strawmanAI : public ScriptedAI
                 AggroTimer = 0;
             }else AggroTimer -= diff;
         }
+
         if (!UpdateVictim())
             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 TRINITY_DLL_DECL boss_tinheadAI : public ScriptedAI
 {
     boss_tinheadAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 AggroTimer;
     uint32 CleaveTimer;
     uint32 RustTimer;
+
     uint8 RustCount;
+
     void Reset()
     {
         AggroTimer = 15000;
         CleaveTimer = 5000;
         RustTimer   = 30000;
+
         RustCount   = 0;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_TINHEAD_AGGRO, m_creature);
     }
+
     void JustReachedHome()
     {
         m_creature->ForcedDespawn();
     }
+
     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)
     {
         DoScriptText(SAY_TINHEAD_DEATH, m_creature);
+
         if (pInstance)
             SummonCroneIfReady(pInstance, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(SAY_TINHEAD_SLAY, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (AggroTimer)
@@ -347,13 +433,16 @@ struct TRINITY_DLL_DECL boss_tinheadAI : public ScriptedAI
                 AggroTimer = 0;
             }else AggroTimer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         if (CleaveTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_CLEAVE);
             CleaveTimer = 5000;
         }else CleaveTimer -= diff;
+
         if (RustCount < 8)
         {
             if (RustTimer < diff)
@@ -364,20 +453,25 @@ struct TRINITY_DLL_DECL boss_tinheadAI : public ScriptedAI
                 RustTimer = 6000;
             }else RustTimer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_roarAI : public ScriptedAI
 {
     boss_roarAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 AggroTimer;
     uint32 MangleTimer;
     uint32 ShredTimer;
     uint32 ScreamTimer;
+
     void Reset()
     {
         AggroTimer = 20000;
@@ -385,36 +479,46 @@ struct TRINITY_DLL_DECL boss_roarAI : public ScriptedAI
         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 EnterCombat(Unit* who)
     {
         DoScriptText(SAY_ROAR_AGGRO, m_creature);
     }
+
     void JustReachedHome()
     {
         m_creature->ForcedDespawn();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_ROAR_DEATH, m_creature);
+
         if (pInstance)
             SummonCroneIfReady(pInstance, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(SAY_ROAR_SLAY, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (AggroTimer)
@@ -425,68 +529,85 @@ struct TRINITY_DLL_DECL boss_roarAI : public ScriptedAI
                 AggroTimer = 0;
             }else AggroTimer -= diff;
         }
+
         if (!UpdateVictim())
             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 TRINITY_DLL_DECL boss_croneAI : public ScriptedAI
 {
     boss_croneAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 CycloneTimer;
     uint32 ChainLightningTimer;
+
     void Reset()
     {
         CycloneTimer = 30000;
         ChainLightningTimer = 10000;
     }
+
     void JustReachedHome()
     {
         m_creature->ForcedDespawn();
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(RAND(SAY_CRONE_AGGRO,SAY_CRONE_AGGRO2), m_creature);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_CRONE_DEATH, m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(TYPE_OPERA, DONE);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_STAGEDOORLEFT), true);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
+
             if (GameObject* pSideEntrance = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
                 pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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);
@@ -494,30 +615,39 @@ struct TRINITY_DLL_DECL boss_croneAI : public ScriptedAI
                 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 TRINITY_DLL_DECL mob_cycloneAI : public ScriptedAI
 {
     mob_cycloneAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 MoveTimer;
+
     void Reset()
     {
         MoveTimer = 1000;
     }
+
     void EnterCombat(Unit* who) {}
+
     void MoveInLineOfSight(Unit* who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->HasAura(SPELL_KNOCKBACK))
             DoCast(m_creature, SPELL_KNOCKBACK, true);
+
         if (MoveTimer < diff)
         {
             Position pos;
@@ -527,112 +657,145 @@ struct TRINITY_DLL_DECL mob_cycloneAI : public ScriptedAI
         }else MoveTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_dorothee(Creature* pCreature)
 {
     return new boss_dorotheeAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_strawman(Creature* pCreature)
 {
     return new boss_strawmanAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_tinhead(Creature* pCreature)
 {
     return new boss_tinheadAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_roar(Creature* pCreature)
 {
     return new boss_roarAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_crone(Creature* pCreature)
 {
     return new boss_croneAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_tito(Creature* pCreature)
 {
     return new mob_titoAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_cyclone(Creature* pCreature)
 {
     return new mob_cycloneAI(pCreature);
 }
+
 /**************************************/
 /**** Opera Red Riding Hood Event ****/
 /************************************/
+
 /**** Yells for the Wolf ****/
 #define SAY_WOLF_AGGRO                  -1532043
 #define SAY_WOLF_SLAY                   -1532044
 #define SAY_WOLF_HOOD                   -1532045
 #define SOUND_WOLF_DEATH                9275                //Only sound on death, no text.
+
 /**** Spells For The Wolf ****/
 #define SPELL_LITTLE_RED_RIDING_HOOD    30768
 #define SPELL_TERRIFYING_HOWL           30752
 #define SPELL_WIDE_SWIPE                30761
+
 #define GOSSIP_GRANDMA          "What phat lewtz you have grandmother?"
+
 /**** The Wolf's Entry ****/
 #define CREATURE_BIG_BAD_WOLF           17521
+
 bool GossipHello_npc_grandmother(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_GRANDMA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
     pPlayer->SEND_GOSSIP_MENU(8990, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_grandmother(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
     {
         if (Creature* pBigBadWolf = pCreature->SummonCreature(CREATURE_BIG_BAD_WOLF, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, HOUR*2*IN_MILISECONDS))
             pBigBadWolf->AI()->AttackStart(pPlayer);
+
         pCreature->ForcedDespawn();
     }
+
     return true;
 }
+
 struct TRINITY_DLL_DECL boss_bigbadwolfAI : public ScriptedAI
 {
     boss_bigbadwolfAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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 EnterCombat(Unit* who)
     {
         DoScriptText(SAY_WOLF_AGGRO, m_creature);
     }
+
     void JustReachedHome()
     {
         m_creature->ForcedDespawn();
     }
+
     void JustDied(Unit* killer)
     {
         DoPlaySoundToSet(m_creature, SOUND_WOLF_DEATH);
+
         if (pInstance)
         {
             pInstance->SetData(TYPE_OPERA, DONE);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_STAGEDOORLEFT), true);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
+
             if (GameObject* pSideEntrance = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
                 pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
+
         if (ChaseTimer < diff)
         {
             if (!IsChasing)
@@ -641,6 +804,7 @@ struct TRINITY_DLL_DECL boss_bigbadwolfAI : public ScriptedAI
                 if (target && target->GetTypeId() == TYPEID_PLAYER)
                 {
                     DoScriptText(SAY_WOLF_HOOD, m_creature);
+
                     DoCast(target, SPELL_LITTLE_RED_RIDING_HOOD, true);
                     TempThreat = DoGetThreat(target);
                     if (TempThreat)
@@ -654,6 +818,7 @@ struct TRINITY_DLL_DECL boss_bigbadwolfAI : public ScriptedAI
             else
             {
                 IsChasing = false;
+
                 if (Unit* target = Unit::GetUnit((*m_creature), HoodGUID))
                 {
                     HoodGUID = 0;
@@ -662,30 +827,38 @@ struct TRINITY_DLL_DECL boss_bigbadwolfAI : public ScriptedAI
                     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()%10000;
         }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* pCreature)
 {
     return new boss_bigbadwolfAI(pCreature);
 }
+
 /**********************************************/
 /******** Opera Romeo and Juliet Event *******/
 /********************************************/
+
 /**** Speech *****/
 #define SAY_JULIANNE_AGGRO              -1532046
 #define SAY_JULIANNE_ENTER              -1532047
@@ -693,35 +866,42 @@ CreatureAI* GetAI_boss_bigbadwolf(Creature* pCreature)
 #define SAY_JULIANNE_DEATH02            -1532049
 #define SAY_JULIANNE_RESURRECT          -1532050
 #define SAY_JULIANNE_SLAY               -1532051
+
 #define SAY_ROMULO_AGGRO                -1532052
 #define SAY_ROMULO_DEATH                -1532053
 #define SAY_ROMULO_ENTER                -1532054
 #define SAY_ROMULO_RESURRECT            -1532055
 #define SAY_ROMULO_SLAY                 -1532056
+
 /***** 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
+
 /*** 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* pCreature)
 {
     pCreature->InterruptNonMeleeSpells(true);
@@ -732,6 +912,7 @@ void PretendToDie(Creature* pCreature)
     pCreature->GetMotionMaster()->MoveIdle();
     pCreature->SetStandState(UNIT_STAND_STATE_DEAD);
 };
+
 void Resurrect(Creature* target)
 {
     target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -746,6 +927,7 @@ void Resurrect(Creature* target)
         else
             target->GetMotionMaster()->Initialize();
 };
+
 struct TRINITY_DLL_DECL boss_julianneAI : public ScriptedAI
 {
     boss_julianneAI(Creature* c) : ScriptedAI(c)
@@ -755,11 +937,16 @@ struct TRINITY_DLL_DECL boss_julianneAI : public ScriptedAI
         AggroYellTimer = 10000;
         IsFakingDeath = false;
     }
+
     ScriptedInstance* pInstance;
+
     uint32 EntryYellTimer;
     uint32 AggroYellTimer;
+
     uint64 RomuloGUID;
+
     uint32 Phase;
+
     uint32 BlindingPassionTimer;
     uint32 DevotionTimer;
     uint32 EternalAffectionTimer;
@@ -768,13 +955,16 @@ struct TRINITY_DLL_DECL boss_julianneAI : public ScriptedAI
     uint32 ResurrectTimer;
     uint32 DrinkPoisonTimer;
     uint32 ResurrectSelfTimer;
+
     bool IsFakingDeath;
     bool SummonedRomulo;
     bool RomuloDead;
+
     void Reset()
     {
         RomuloGUID = 0;
         Phase = PHASE_JULIANNE;
+
         BlindingPassionTimer = 30000;
         DevotionTimer = 15000;
         EternalAffectionTimer = 25000;
@@ -782,31 +972,40 @@ struct TRINITY_DLL_DECL boss_julianneAI : public ScriptedAI
         SummonRomuloTimer = 10000;
         DrinkPoisonTimer = 0;
         ResurrectSelfTimer = 0;
+
         if (IsFakingDeath)
         {
             Resurrect(m_creature);
             IsFakingDeath = false;
         }
+
         SummonedRomulo = false;
         RomuloDead = false;
     }
+
     void EnterCombat(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 JustReachedHome()
     {
         m_creature->ForcedDespawn();
     }
+
     void SpellHit(Unit* caster, const SpellEntry *Spell)
     {
         if (Spell->Id == SPELL_DRINK_POISON)
@@ -815,10 +1014,13 @@ struct TRINITY_DLL_DECL boss_julianneAI : public ScriptedAI
             DrinkPoisonTimer = 2500;
         }
     }
+
     void DamageTaken(Unit* done_by, uint32 &damage);
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_JULIANNE_DEATH02, m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(TYPE_OPERA, DONE);
@@ -828,12 +1030,15 @@ struct TRINITY_DLL_DECL boss_julianneAI : public ScriptedAI
                 pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
         }
     }
+
     void KilledUnit(Unit* victim)
     {
        DoScriptText(SAY_JULIANNE_SLAY, m_creature);
     }
+
     void UpdateAI(const uint32 diff);
 };
+
 struct TRINITY_DLL_DECL boss_romuloAI : public ScriptedAI
 {
     boss_romuloAI(Creature* c) : ScriptedAI(c)
@@ -842,9 +1047,12 @@ struct TRINITY_DLL_DECL boss_romuloAI : public ScriptedAI
         EntryYellTimer = 8000;
         AggroYellTimer = 15000;
     }
+
     ScriptedInstance* pInstance;
+
     uint64 JulianneGUID;
     uint32 Phase;
+
     uint32 EntryYellTimer;
     uint32 AggroYellTimer;
     uint32 BackwardLungeTimer;
@@ -852,25 +1060,32 @@ struct TRINITY_DLL_DECL boss_romuloAI : public ScriptedAI
     uint32 DeadlySwatheTimer;
     uint32 PoisonThrustTimer;
     uint32 ResurrectTimer;
+
     bool IsFakingDeath;
     bool JulianneDead;
+
     void Reset()
     {
         JulianneGUID = 0;
         Phase = PHASE_ROMULO;
+
         BackwardLungeTimer = 15000;
         DaringTimer = 20000;
         DeadlySwatheTimer = 25000;
         PoisonThrustTimer = 10000;
         ResurrectTimer = 10000;
+
         IsFakingDeath = false;
         JulianneDead = false;
     }
+
     void JustReachedHome()
     {
         m_creature->ForcedDespawn();
     }
+
     void DamageTaken(Unit* done_by, uint32 &damage);
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_ROMULO_AGGRO, m_creature);
@@ -884,53 +1099,68 @@ struct TRINITY_DLL_DECL boss_romuloAI : public ScriptedAI
             }
         }
     }
+
     void MoveInLineOfSight(Unit* who)
     {
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_ROMULO_DEATH, m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(TYPE_OPERA, DONE);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_STAGEDOORLEFT), true);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
+
             if (GameObject* pSideEntrance = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
                 pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(SAY_ROMULO_SLAY, m_creature);
     }
+
     void UpdateAI(const uint32 diff);
 };
+
 void boss_julianneAI::DamageTaken(Unit* done_by, uint32 &damage)
 {
     if (damage < m_creature->GetHealth())
         return;
+
     //anything below only used if incoming damage will kill
+
     if (Phase == PHASE_JULIANNE)
     {
         damage = 0;
+
         //this means already drinking, so return
         if (IsFakingDeath)
             return;
+
         m_creature->InterruptNonMeleeSpells(true);
         DoCast(m_creature, SPELL_DRINK_POISON);
+
         IsFakingDeath = true;
         //IS THIS USEFULL? Creature* Julianne = (Unit::GetCreature((*m_creature), JulianneGUID));
         return;
     }
+
     if (Phase == PHASE_ROMULO)
     {
         error_log("TSCR: boss_julianneAI: cannot take damage in PHASE_ROMULO, why was i here?");
         damage = 0;
         return;
     }
+
     if (Phase == PHASE_BOTH)
     {
         //if this is true then we have to kill romulo too
@@ -945,8 +1175,10 @@ void boss_julianneAI::DamageTaken(Unit* done_by, uint32 &damage)
                 Romulo->DeleteThreatList();
                 Romulo->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
             }
+
             return;
         }
+
         //if not already returned, then romulo is alive and we can pretend die
         if (Creature* Romulo = (Unit::GetCreature((*m_creature), RomuloGUID)))
         {
@@ -960,25 +1192,31 @@ void boss_julianneAI::DamageTaken(Unit* done_by, uint32 &damage)
     }
     error_log("TSCR: boss_julianneAI: DamageTaken reach end of code, that should not happen.");
 }
+
 void boss_romuloAI::DamageTaken(Unit* done_by, uint32 &damage)
 {
     if (damage < m_creature->GetHealth())
         return;
+
     //anything below only used if incoming damage will kill
+
     if (Phase == PHASE_ROMULO)
     {
         DoScriptText(SAY_ROMULO_DEATH, m_creature);
         PretendToDie(m_creature);
         IsFakingDeath = true;
         Phase = PHASE_BOTH;
+
         if (Creature* Julianne = (Unit::GetCreature((*m_creature), JulianneGUID)))
         {
             CAST_AI(boss_julianneAI, Julianne->AI())->RomuloDead = true;
             CAST_AI(boss_julianneAI, Julianne->AI())->ResurrectSelfTimer = 10000;
         }
+
         damage = 0;
         return;
     }
+
     if (Phase == PHASE_BOTH)
     {
         if (JulianneDead)
@@ -994,6 +1232,7 @@ void boss_romuloAI::DamageTaken(Unit* done_by, uint32 &damage)
             }
             return;
         }
+
         if (Creature* Julianne = (Unit::GetCreature((*m_creature), JulianneGUID)))
         {
             PretendToDie(m_creature);
@@ -1004,8 +1243,10 @@ void boss_romuloAI::DamageTaken(Unit* done_by, uint32 &damage)
             return;
         }
     }
+
     error_log("TSCR: boss_romuloAI: DamageTaken reach end of code, that should not happen.");
 }
+
 void boss_julianneAI::UpdateAI(const uint32 diff)
 {
     if (EntryYellTimer)
@@ -1016,6 +1257,7 @@ void boss_julianneAI::UpdateAI(const uint32 diff)
             EntryYellTimer = 0;
         }else EntryYellTimer -= diff;
     }
+
     if (AggroYellTimer)
     {
         if (AggroYellTimer <= diff)
@@ -1026,6 +1268,7 @@ void boss_julianneAI::UpdateAI(const uint32 diff)
             AggroYellTimer = 0;
         }else AggroYellTimer -= diff;
     }
+
     if (DrinkPoisonTimer)
     {
         //will do this 2secs after spell hit. this is time to display visual as expected
@@ -1037,6 +1280,7 @@ void boss_julianneAI::UpdateAI(const uint32 diff)
             DrinkPoisonTimer = 0;
         }else DrinkPoisonTimer -= diff;
     }
+
     if (Phase == PHASE_ROMULO && !SummonedRomulo)
     {
         if (SummonRomuloTimer < diff)
@@ -1047,11 +1291,13 @@ void boss_julianneAI::UpdateAI(const uint32 diff)
                 CAST_AI(boss_romuloAI, pRomulo->AI())->JulianneGUID = m_creature->GetGUID();
                 CAST_AI(boss_romuloAI, pRomulo->AI())->Phase = PHASE_ROMULO;
                 DoZoneInCombat(pRomulo);
+
                 pRomulo->setFaction(16);
             }
             SummonedRomulo = true;
         }else SummonRomuloTimer -= diff;
     }
+
     if (ResurrectSelfTimer)
     {
         if (ResurrectSelfTimer <= diff)
@@ -1059,14 +1305,18 @@ void boss_julianneAI::UpdateAI(const uint32 diff)
             Resurrect(m_creature);
             Phase = PHASE_BOTH;
             IsFakingDeath = false;
+
             if (m_creature->getVictim())
                 AttackStart(m_creature->getVictim());
+
             ResurrectSelfTimer = 0;
             ResurrectTimer = 1000;
         }else ResurrectSelfTimer -= diff;
     }
+
     if (!UpdateVictim() || IsFakingDeath)
         return;
+
     if (RomuloDead)
     {
         if (ResurrectTimer < diff)
@@ -1082,21 +1332,25 @@ void boss_julianneAI::UpdateAI(const uint32 diff)
             }
         }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)
@@ -1105,14 +1359,18 @@ void boss_julianneAI::UpdateAI(const uint32 diff)
             if (Romulo && Romulo->isAlive() && !RomuloDead)
                 DoCast(Romulo, SPELL_ETERNAL_AFFECTION);
         }else DoCast(m_creature, SPELL_ETERNAL_AFFECTION);
+
         EternalAffectionTimer = 45000 + rand()%15000;
     }else EternalAffectionTimer -= diff;
+
     DoMeleeAttackIfReady();
 }
+
 void boss_romuloAI::UpdateAI(const uint32 diff)
 {
     if (!UpdateVictim() || IsFakingDeath)
         return;
+
     if (JulianneDead)
     {
         if (ResurrectTimer < diff)
@@ -1128,6 +1386,7 @@ void boss_romuloAI::UpdateAI(const uint32 diff)
             }
         }else ResurrectTimer -= diff;
     }
+
     if (BackwardLungeTimer < diff)
     {
         Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
@@ -1137,78 +1396,96 @@ void boss_romuloAI::UpdateAI(const uint32 diff)
             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* pCreature)
 {
     return new boss_julianneAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_romulo(Creature* pCreature)
 {
     return new boss_romuloAI(pCreature);
 }
+
 void AddSC_bosses_opera()
 {
     Script* newscript;
+
     // Oz
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_dorothee;
     newscript->Name = "boss_dorothee";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_strawman;
     newscript->Name = "boss_strawman";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_tinhead;
     newscript->Name = "boss_tinhead";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_roar;
     newscript->Name = "boss_roar";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_crone;
     newscript->Name = "boss_crone";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_tito;
     newscript->Name = "mob_tito";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_cyclone;
     newscript->Name = "mob_cyclone";
     newscript->RegisterSelf();
+
     // Hood
     newscript = new Script;
     newscript->pGossipHello = &GossipHello_npc_grandmother;
     newscript->pGossipSelect = &GossipSelect_npc_grandmother;
     newscript->Name = "npc_grandmother";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_bigbadwolf;
     newscript->Name = "boss_bigbadwolf";
     newscript->RegisterSelf();
+
     // Romeo And Juliet
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_julianne;
     newscript->Name = "boss_julianne";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_romulo;
     newscript->Name = "boss_romulo";
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/def_karazhan.h b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/def_karazhan.h
index b79aef32226..1c4c1f37eb0 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/def_karazhan.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/def_karazhan.h
@@ -2,8 +2,10 @@
  * 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
+
 enum eEnums
 {
     TYPE_ATTUMEN                    = 1,
@@ -18,8 +20,10 @@ enum eEnums
     TYPE_CHESS                      = 10,
     TYPE_MALCHEZZAR                 = 11,
     TYPE_NIGHTBANE                  = 12,
+
     DATA_OPERA_PERFORMANCE          = 13,
     DATA_OPERA_OZ_DEATHCOUNT        = 14,
+
     DATA_KILREK                     = 15,
     DATA_TERESTIAN                  = 16,
     DATA_MOROES                     = 17,
@@ -31,17 +35,20 @@ enum eEnums
     DATA_GO_NETHER_DOOR             = 23,
     DATA_GO_GAME_DOOR               = 24,
     DATA_GO_GAME_EXIT_DOOR          = 25,
+
     DATA_IMAGE_OF_MEDIVH            = 26,
     DATA_MASTERS_TERRACE_DOOR_1     = 27,
     DATA_MASTERS_TERRACE_DOOR_2     = 28,
     DATA_GO_SIDE_ENTRANCE_DOOR      = 29
 };
+
 enum OperaEvents
 {
     EVENT_OZ                        = 1,
     EVENT_HOOD                      = 2,
     EVENT_RAJ                       = 3
 };
+
 #define ERROR_INST_DATA(a)          error_log("TSCR: 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/eastern_kingdoms/karazhan/instance_karazhan.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/instance_karazhan.cpp
index 0d8a7cdb251..2ee3f3958cf 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/instance_karazhan.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/instance_karazhan.cpp
@@ -13,15 +13,19 @@
  * along 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 MAX_ENCOUNTER      12
+
 /*
 0  - Attumen + Midnight (optional)
 1  - Moroes
@@ -36,13 +40,17 @@ EndScriptData */
 10 - Prince Malchezzar
 11 - Nightbane
 */
+
 struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
 {
     instance_karazhan(Map* pMap) : ScriptedInstance(pMap) {Initialize();}
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     std::string strSaveData;
+
     uint32 m_uiOperaEvent;
     uint32 m_uiOzDeathCount;
+
     uint64 m_uiCurtainGUID;
     uint64 m_uiStageDoorLeftGUID;
     uint64 m_uiStageDoorRightGUID;
@@ -58,18 +66,23 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
     uint64 MastersTerraceDoor[2];
     uint64 ImageGUID;
     uint64 DustCoveredChest;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         // 1 - OZ, 2 - HOOD, 3 - RAJ, this never gets altered.
         m_uiOperaEvent      = urand(1,3);
         m_uiOzDeathCount    = 0;
+
         m_uiCurtainGUID         = 0;
         m_uiStageDoorLeftGUID   = 0;
         m_uiStageDoorRightGUID  = 0;
+
         m_uiKilrekGUID      = 0;
         m_uiTerestianGUID   = 0;
         m_uiMoroesGUID      = 0;
+
         m_uiLibraryDoor         = 0;
         m_uiMassiveDoor         = 0;
         m_uiSideEntranceDoor    = 0;
@@ -81,13 +94,16 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
         ImageGUID = 0;
         DustCoveredChest    = 0;
     }
+
     bool IsEncounterInProgress() const
     {
         for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)
                 return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch (pCreature->GetEntry())
@@ -97,6 +113,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
             case 15687:   m_uiMoroesGUID = pCreature->GetGUID();      break;
         }
     }
+
     void SetData(uint32 type, uint32 uiData)
     {
         switch (type)
@@ -132,18 +149,23 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
                     m_uiOzDeathCount = 0;
                 break;
         }
+
         if (uiData == DONE)
         {
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
             saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                 << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " " << m_auiEncounter[6] << " "
                 << m_auiEncounter[7] << " " << m_auiEncounter[8] << " " << m_auiEncounter[9] << " " << m_auiEncounter[10] << " " << m_auiEncounter[11];
+
             strSaveData = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
     }
+
      void SetData64(uint32 identifier, uint64 data)
      {
          switch(identifier)
@@ -151,6 +173,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
          case DATA_IMAGE_OF_MEDIVH: ImageGUID = data;
          }
      }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -182,21 +205,26 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
                 break;
             case 185119: DustCoveredChest = pGo->GetGUID(); break;
         }
+
         switch(m_uiOperaEvent)
         {
             //TODO: Set Object visibilities for Opera based on performance
             case EVENT_OZ:
                 break;
+
             case EVENT_HOOD:
                 break;
+
             case EVENT_RAJ:
                 break;
         }
     }
+
     std::string GetSaveData()
     {
         return strSaveData;
     }
+
     uint32 GetData(uint32 uiData)
     {
         switch (uiData)
@@ -217,8 +245,10 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
             case DATA_OPERA_OZ_DEATHCOUNT:  return m_uiOzDeathCount;
             case DATA_IMAGE_OF_MEDIVH:      return ImageGUID;
         }
+
         return 0;
     }
+
     uint64 GetData64(uint32 uiData)
     {
         switch (uiData)
@@ -238,8 +268,10 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
             case DATA_MASTERS_TERRACE_DOOR_1:   return MastersTerraceDoor[0];
             case DATA_MASTERS_TERRACE_DOOR_2:   return MastersTerraceDoor[1];
         }
+
         return 0;
     }
+
     void Load(const char* chrIn)
     {
         if (!chrIn)
@@ -247,21 +279,25 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(chrIn);
         std::istringstream loadStream(chrIn);
+
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3]
             >> m_auiEncounter[4] >> m_auiEncounter[5] >> m_auiEncounter[6] >> m_auiEncounter[7]
             >> m_auiEncounter[8] >> m_auiEncounter[9] >> m_auiEncounter[10] >> m_auiEncounter[11];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)                // Do not load an encounter as "In Progress" - reset it instead.
                 m_auiEncounter[i] = NOT_STARTED;
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_karazhan(Map* pMap)
 {
     return new instance_karazhan(pMap);
 }
+
 void AddSC_instance_karazhan()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/karazhan.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/karazhan.cpp
index a315ca3287c..f392c50ca13 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/karazhan.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/karazhan.cpp
@@ -13,39 +13,49 @@
  * along 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), Support for Quest 9645.
 SDCategory: Karazhan
 EndScriptData */
+
 /* ContentData
 npc_barnes
 npc_berthold
 npc_image_of_medivh
 EndContentData */
+
 #include "precompiled.h"
 #include "def_karazhan.h"
 #include "escort_ai.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."
+
 #define OZ_GM_GOSSIP1       "[GM] Change event to EVENT_OZ"
 #define OZ_GM_GOSSIP2       "[GM] Change event to EVENT_HOOD"
 #define OZ_GM_GOSSIP3       "[GM] Change event to EVENT_RAJ"
+
 struct Dialogue
 {
     int32 textid;
     uint32 timer;
 };
+
 static Dialogue OzDialogue[]=
 {
     {-1532103, 6000},
@@ -53,6 +63,7 @@ static Dialogue OzDialogue[]=
     {-1532105, 9000},
     {-1532106, 15000}
 };
+
 static Dialogue HoodDialogue[]=
 {
     {-1532107, 6000},
@@ -60,6 +71,7 @@ static Dialogue HoodDialogue[]=
     {-1532109, 14000},
     {-1532110, 15000}
 };
+
 static Dialogue RAJDialogue[]=
 {
     {-1532111, 5000},
@@ -67,6 +79,7 @@ static Dialogue RAJDialogue[]=
     {-1532113, 14000},
     {-1532114, 14000}
 };
+
 // Entries and spawn locations for creatures in Oz event
 float Spawns[6][2]=
 {
@@ -77,12 +90,16 @@ float Spawns[6][2]=
     {17603, -10892},                                        // Grandmother
     {17534, -10900},                                        // Julianne
 };
+
 #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 TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
 {
     npc_barnesAI(Creature* c) : npc_escortAI(c)
@@ -91,39 +108,54 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
         m_uiEventId = 0;
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint64 m_uiSpotlightGUID;
+
     uint32 TalkCount;
     uint32 TalkTimer;
     uint32 WipeTimer;
     uint32 m_uiEventId;
+
     bool PerformanceReady;
     bool RaidWiped;
+
     void Reset()
     {
         m_uiSpotlightGUID = 0;
+
         TalkCount = 0;
         TalkTimer = 2000;
         WipeTimer = 5000;
+
         PerformanceReady = false;
+
         if (pInstance)
             m_uiEventId = pInstance->GetData(DATA_OPERA_PERFORMANCE);
     }
+
     void StartEvent()
     {
         if (!pInstance)
             return;
+
         pInstance->SetData(TYPE_OPERA, IN_PROGRESS);
+
         //resets count for this event, in case earlier failed
         if (m_uiEventId == EVENT_OZ)
             pInstance->SetData(DATA_OPERA_OZ_DEATHCOUNT, IN_PROGRESS);
+
         Start(false, false);
     }
+
     void EnterCombat(Unit* who) {}
+
     void WaypointReached(uint32 i)
     {
         if (!pInstance)
             return;
+
         switch(i)
         {
             case 0:
@@ -133,6 +165,7 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
             case 4:
                 TalkCount = 0;
                 SetEscortPaused(true);
+
                 if (Creature* pSpotlight = m_creature->SummonCreature(CREATURE_SPOTLIGHT,
                     m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0.0f,
                     TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000))
@@ -152,9 +185,11 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
                 break;
         }
     }
+
     void Talk(uint32 count)
     {
         int32 text = 0;
+
         switch(m_uiEventId)
         {
             case EVENT_OZ:
@@ -163,12 +198,14 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
                 if (OzDialogue[count].timer)
                     TalkTimer = OzDialogue[count].timer;
                 break;
+
             case EVENT_HOOD:
                 if (HoodDialogue[count].textid)
                     text = HoodDialogue[count].textid;
                 if (HoodDialogue[count].timer)
                     TalkTimer = HoodDialogue[count].timer;
                 break;
+
             case EVENT_RAJ:
                  if (RAJDialogue[count].textid)
                      text = RAJDialogue[count].textid;
@@ -176,14 +213,17 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
                     TalkTimer = RAJDialogue[count].timer;
                 break;
         }
+
         if (text)
              DoScriptText(text, m_creature);
     }
+
     void PrepareEncounter()
     {
         debug_log("TSCR: Barnes Opera Event - Introduction complete - preparing encounter %d", m_uiEventId);
         uint8 index = 0;
         uint8 count = 0;
+
         switch(m_uiEventId)
         {
             case EVENT_OZ:
@@ -199,10 +239,12 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
                 count = index+1;
                 break;
         }
-        for (; index < count; ++index)
+
+        for(; index < count; ++index)
         {
             uint32 entry = ((uint32)Spawns[index][0]);
             float PosX = Spawns[index][1];
+
             if (Creature* pCreature = m_creature->SummonCreature(entry, PosX, SPAWN_Y, SPAWN_Z, SPAWN_O, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, HOUR*2*IN_MILISECONDS))
             {
                 // In case database has bad flags
@@ -210,11 +252,14 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
                 pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
             }
         }
+
         RaidWiped = false;
     }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
+
         if (HasEscortState(STATE_ESCORT_PAUSED))
         {
             if (TalkTimer < diff)
@@ -223,15 +268,18 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
                 {
                     if (Creature* pSpotlight = Unit::GetCreature(*m_creature, m_uiSpotlightGUID))
                         pSpotlight->ForcedDespawn();
+
                     SetEscortPaused(false);
                     return;
                 }
+
                 Talk(TalkCount);
                 ++TalkCount;
             }
             else
                 TalkTimer -= diff;
         }
+
         if (PerformanceReady)
         {
             if (!RaidWiped)
@@ -240,11 +288,13 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
                 {
                     Map* pMap = m_creature->GetMap();
                     if (!pMap->IsDungeon()) return;
+
                     Map::PlayerList const &PlayerList = pMap->GetPlayers();
                     if (PlayerList.isEmpty())
                         return;
+
                     RaidWiped = true;
-                    for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+                    for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
                     {
                         if (i->getSource()->isAlive() && !i->getSource()->isGameMaster())
                         {
@@ -252,22 +302,27 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
                             break;
                         }
                     }
+
                     if (RaidWiped)
                     {
                         RaidWiped = true;
                         EnterEvadeMode();
                         return;
                     }
+
                     WipeTimer = 15000;
                 }else WipeTimer -= diff;
             }
+
         }
     }
 };
+
 CreatureAI* GetAI_npc_barnesAI(Creature* pCreature)
 {
     return new npc_barnesAI(pCreature);
 }
+
 bool GossipHello_npc_barnes(Player* pPlayer, Creature* pCreature)
 {
     if (ScriptedInstance* pInstance = pCreature->GetInstanceData())
@@ -276,28 +331,34 @@ bool GossipHello_npc_barnes(Player* pPlayer, Creature* pCreature)
         if (pInstance->GetData(TYPE_MOROES) == DONE && pInstance->GetData(TYPE_OPERA) != DONE)
         {
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, OZ_GOSSIP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
             if (pPlayer->isGameMaster())
             {
                 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, OZ_GM_GOSSIP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
                 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, OZ_GM_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
                 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, OZ_GM_GOSSIP3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
             }
+
             if (npc_barnesAI* pBarnesAI = CAST_AI(npc_barnesAI,pCreature->AI()))
             {
                 if (!pBarnesAI->RaidWiped)
                     pPlayer->SEND_GOSSIP_MENU(8970, pCreature->GetGUID());
                 else
                     pPlayer->SEND_GOSSIP_MENU(8975, pCreature->GetGUID());
+
                 return true;
             }
         }
     }
+
     pPlayer->SEND_GOSSIP_MENU(8978, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_barnes(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     npc_barnesAI* pBarnesAI = CAST_AI(npc_barnesAI, pCreature->AI());
+
     switch(uiAction)
     {
         case GOSSIP_ACTION_INFO_DEF+1:
@@ -324,16 +385,21 @@ bool GossipSelect_npc_barnes(Player* pPlayer, Creature* pCreature, uint32 uiSend
             outstring_log("TSCR: player (GUID %i) manually set Opera event to EVENT_RAJ",pPlayer->GetGUID());
             break;
     }
+
     return true;
 }
+
 /*###
 # npc_berthold
 ####*/
+
 enum eBerthold
 {
     SPELL_TELEPORT           = 39567
 };
+
 #define GOSSIP_ITEM_TELEPORT    "Teleport me to the Guardian's Library"
+
 bool GossipHello_npc_berthold(Player* pPlayer, Creature* pCreature)
 {
     if (ScriptedInstance* pInstance = pCreature->GetInstanceData())
@@ -342,19 +408,24 @@ bool GossipHello_npc_berthold(Player* pPlayer, Creature* pCreature)
         if (pInstance->GetData(TYPE_ARAN) == DONE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELEPORT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_berthold(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
         pPlayer->CastSpell(pPlayer, SPELL_TELEPORT, true);
+
     pPlayer->CLOSE_GOSSIP_MENU();
     return true;
 }
+
 /*###
 # npc_image_of_medivh
 ####*/
+
 #define SAY_DIALOG_MEDIVH_1         "You've got my attention, dragon. You'll find I'm not as easily scared as the villagers below."
 #define SAY_DIALOG_ARCANAGOS_2      "Your dabbling in the arcane has gone too far, Medivh. You've attracted the attention of powers beyond your understanding. You must leave Karazhan at once!"
 #define SAY_DIALOG_MEDIVH_3         "You dare challenge me at my own dwelling? Your arrogance is astounding, even for a dragon!"
@@ -364,29 +435,38 @@ bool GossipSelect_npc_berthold(Player* pPlayer, Creature* pCreature, uint32 uiSe
 #define EMOTE_DIALOG_MEDIVH_7       "begins to cast a spell of great power, weaving his own essence into the magic."
 #define SAY_DIALOG_ARCANAGOS_8      "What have you done, wizard? This cannot be! I'm burning from... within!"
 #define SAY_DIALOG_MEDIVH_9         "He should not have angered me. I must go... recover my strength now..."
+
 #define MOB_ARCANAGOS               17652
 #define SPELL_FIRE_BALL             30967
 #define SPELL_UBER_FIREBALL         30971
 #define SPELL_CONFLAGRATION_BLAST   30977
 #define SPELL_MANA_SHIELD           31635
+
 static float MedivPos[4] = {-11161.49,-1902.24,91.48,1.94};
 static float ArcanagosPos[4] = {-11169.75,-1881.48,95.39,4.83};
+
 struct TRINITY_DLL_DECL npc_image_of_medivhAI : public ScriptedAI
 {
     npc_image_of_medivhAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint64 ArcanagosGUID;
+
     uint32 YellTimer;
     uint32 Step;
     uint32 FireMedivhTimer;
     uint32 FireArcanagosTimer;
+
     bool EventStarted;
+
     void Reset()
     {
         ArcanagosGUID = 0;
+
         if (pInstance && pInstance->GetData64(DATA_IMAGE_OF_MEDIVH) == 0)
         {
             pInstance->SetData64(DATA_IMAGE_OF_MEDIVH, m_creature->GetGUID());
@@ -399,6 +479,7 @@ struct TRINITY_DLL_DECL npc_image_of_medivhAI : public ScriptedAI
         }
     }
     void EnterCombat(Unit* who){}
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
@@ -410,6 +491,7 @@ struct TRINITY_DLL_DECL npc_image_of_medivhAI : public ScriptedAI
             m_creature->SetOrientation(MedivPos[3]);
         }
     }
+
     void StartEvent()
     {
         Step = 1;
@@ -425,6 +507,7 @@ struct TRINITY_DLL_DECL npc_image_of_medivhAI : public ScriptedAI
         YellTimer = 10000;
     }
 
+
     uint32 NextStep(uint32 Step)
     {
         Unit* arca = Unit::GetUnit((*m_creature),ArcanagosGUID);
@@ -483,6 +566,7 @@ struct TRINITY_DLL_DECL npc_image_of_medivhAI : public ScriptedAI
         case 14:
             m_creature->SetVisibility(VISIBILITY_OFF);
             m_creature->ClearInCombat();
+
             if (pMap->IsDungeon())
             {
                 InstanceMap::PlayerList const &PlayerList = pMap->GetPlayers();
@@ -501,9 +585,12 @@ struct TRINITY_DLL_DECL npc_image_of_medivhAI : public ScriptedAI
             return 5000;
         default : return 9999999;
         }
+
     }
+
     void UpdateAI(const uint32 diff)
     {
+
         if (YellTimer < diff)
         {
             if (EventStarted)
@@ -511,42 +598,51 @@ struct TRINITY_DLL_DECL npc_image_of_medivhAI : public ScriptedAI
                 YellTimer = NextStep(Step++);
             }
         }else YellTimer -= diff;
+
         if (Step >= 7 && Step <= 12)
         {
             Unit* arca = Unit::GetUnit((*m_creature),ArcanagosGUID);
+
             if (FireArcanagosTimer < diff)
             {
                 if (arca)
                     arca->CastSpell(m_creature, SPELL_FIRE_BALL, false);
                 FireArcanagosTimer = 6000;
             }else FireArcanagosTimer -= diff;
+
             if (FireMedivhTimer < diff)
             {
                 if (arca)
                     DoCast(arca, SPELL_FIRE_BALL);
                 FireMedivhTimer = 5000;
             }else FireMedivhTimer -= diff;
+
         }
     }
 };
+
 CreatureAI* GetAI_npc_image_of_medivh(Creature* pCreature)
 {
     return new npc_image_of_medivhAI(pCreature);
 }
+
 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_berthold";
     newscript->pGossipHello = &GossipHello_npc_berthold;
     newscript->pGossipSelect = &GossipSelect_npc_berthold;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_image_of_medivh";
     newscript->GetAI = &GetAI_npc_image_of_medivh;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/loch_modan.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/loch_modan.cpp
index c379a6ab590..80e1d3ffceb 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/loch_modan.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/loch_modan.cpp
@@ -13,35 +13,46 @@
  * along 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
 SDCategory: Loch Modan
 EndScriptData */
+
 /* ContentData
 npc_mountaineer_pebblebitty
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## npc_mountaineer_pebblebitty
 ######*/
+
 #define GOSSIP_MP "Open the gate please, i need to get to Searing Gorge"
+
 #define GOSSIP_MP1 "But i need to get there, now open the gate!"
 #define GOSSIP_MP2 "Ok, so what is this other way?"
 #define GOSSIP_MP3 "Doesn't matter, i'm invulnerable."
 #define GOSSIP_MP4 "Yes..."
 #define GOSSIP_MP5 "Ok, i'll try to remember that."
 #define GOSSIP_MP6 "A key? Ok!"
+
 bool GossipHello_npc_mountaineer_pebblebitty(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (!pPlayer->GetQuestRewardStatus(3181) == 1)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_MP, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_mountaineer_pebblebitty(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -76,9 +87,11 @@ bool GossipSelect_npc_mountaineer_pebblebitty(Player* pPlayer, Creature* pCreatu
     }
     return true;
 }
+
 void AddSC_loch_modan()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_mountaineer_pebblebitty";
     newscript->pGossipHello =  &GossipHello_npc_mountaineer_pebblebitty;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_felblood_kaelthas.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_felblood_kaelthas.cpp
index 721dd8f2fc5..3fc8e2dc4d1 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_felblood_kaelthas.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_felblood_kaelthas.cpp
@@ -13,15 +13,18 @@
  * along with 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.
 SDCategory: Magisters' Terrace
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_magisters_terrace.h"
 #include "WorldPacket.h"
+
 #define SAY_AGGRO                   -1585023                //This yell should be done when the room is cleared. For now, set it as a movelineofsight yell.
 #define SAY_PHOENIX                 -1585024
 #define SAY_FLAMESTRIKE             -1585025
@@ -29,19 +32,25 @@ EndScriptData */
 #define SAY_TIRED                   -1585027
 #define SAY_RECAST_GRAVITY          -1585028
 #define SAY_DEATH                   -1585029
+
 /*** 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            44197                 // A spell Phoenix uses to damage everything around
 #define SPELL_REBIRTH_DMG             44196                 // DMG if a Phoenix rebirth happen
+
 #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
@@ -50,10 +59,12 @@ EndScriptData */
 #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
+
 /** Locations **/
 float KaelLocations[3][2]=
 {
@@ -61,7 +72,9 @@ float KaelLocations[3][2]=
     {140.823883, 195.403046},
     {156.574188, 195.650482},
 };
+
 #define LOCATION_Z                  -16.727455
+
 struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
 {
     boss_felblood_kaelthasAI(Creature* c) : ScriptedAI(c)
@@ -69,13 +82,17 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         Heroic = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 FireballTimer;
     uint32 PhoenixTimer;
     uint32 FlameStrikeTimer;
     uint32 CombatPulseTimer;
+
     //Heroic only
     uint32 PyroblastTimer;
+
     uint32 GravityLapseTimer;
     uint32 GravityLapsePhase;
     // 0 = No Gravity Lapse
@@ -83,13 +100,16 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
     // 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;
     bool HasTaunted;
+
     uint8 Phase;
     // 0 = Not started
     // 1 = Fireball; Summon Phoenix; Flamestrike
     // 2 = Gravity Lapses
+
     void Reset()
     {
         // TODO: Timers
@@ -97,12 +117,17 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
         PhoenixTimer = 10000;
         FlameStrikeTimer = 25000;
         CombatPulseTimer = 0;
+
         PyroblastTimer = 60000;
+
         GravityLapseTimer = 0;
         GravityLapsePhase = 0;
+
         FirstGravityLapse = true;
         HasTaunted = false;
+
         Phase = 0;
+
         if (pInstance)
         {
             pInstance->SetData(DATA_KAELTHAS_EVENT, NOT_STARTED);
@@ -111,26 +136,33 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
            // Small door opened after event are expected to be closed by default
         }
     }
+
     void JustDied(Unit *killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (!pInstance)
             return;
+
         pInstance->HandleGameObject(pInstance->GetData64(DATA_KAEL_DOOR), true);
         // Open the encounter door
     }
+
     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 EnterCombat(Unit *who)
     {
         if (!pInstance)
             return;
+
         pInstance->HandleGameObject(pInstance->GetData64(DATA_KAEL_DOOR), false);
        //Close the encounter door, open it in JustDied/Reset
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!HasTaunted && m_creature->IsWithinDistInMap(who, 40.0))
@@ -138,15 +170,18 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
             DoScriptText(SAY_AGGRO, m_creature);
             HasTaunted = true;
         }
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     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)
+        for(i = m_threatlist.begin(); i != m_threatlist.end(); ++i)
         {
             Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid());
             if (pUnit && pUnit->isAlive())
@@ -156,6 +191,7 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
             }
         }
     }
+
     void TeleportPlayersToSelf()
     {
         float x = KaelLocations[0][0];
@@ -171,6 +207,7 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
         }
         DoCast(m_creature, SPELL_TELEPORT_CENTER, true);
     }
+
     void CastGravityLapseKnockUp()
     {
         std::list::iterator i = m_creature->getThreatManager().getThreatList().begin();
@@ -182,6 +219,7 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
                 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();
@@ -201,6 +239,7 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
             }
         }
     }
+
     void RemoveGravityLapse()
     {
         std::list::iterator i = m_creature->getThreatManager().getThreatList().begin();
@@ -211,6 +250,7 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
             {
                 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());
@@ -219,11 +259,13 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         switch(Phase)
         {
             case 0:
@@ -240,17 +282,22 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
                         PyroblastTimer = 60000;
                     }else PyroblastTimer -= diff;
                 }
+
                 if (FireballTimer < diff)
                 {
                     DoCast(m_creature->getVictim(), Heroic ? SPELL_FIREBALL_HEROIC : SPELL_FIREBALL_NORMAL);
                     FireballTimer = 2000 + rand()%4000;
                 }else FireballTimer -= diff;
+
                 if (PhoenixTimer < diff)
                 {
+
                     Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1);
+
                     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)
                     {
@@ -258,9 +305,12 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
                         SetThreatList(Phoenix);
                         Phoenix->AI()->AttackStart(target);
                     }
+
                     DoScriptText(SAY_PHOENIX, m_creature);
+
                     PhoenixTimer = 60000;
                 }else PhoenixTimer -= diff;
+
                 if (FlameStrikeTimer < diff)
                 {
                     if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -272,6 +322,7 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
                     }
                     FlameStrikeTimer = 15000 + rand()%10000;
                 }else FlameStrikeTimer -= diff;
+
                 // Below 50%
                 if (m_creature->GetMaxHealth() * 0.5 > m_creature->GetHealth())
                 {
@@ -283,9 +334,11 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
                     GravityLapsePhase = 0;
                     Phase = 1;
                 }
+
                 DoMeleeAttackIfReady();
             }
             break;
+
             case 1:
             {
                 if (GravityLapseTimer < diff)
@@ -297,6 +350,7 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
                             {
                                 DoScriptText(SAY_GRAVITY_LAPSE, m_creature);
                                 FirstGravityLapse = false;
+
                                 if (pInstance)
                                 {
                                     pInstance->HandleGameObject(pInstance->GetData64(DATA_KAEL_STATUE_LEFT), true);
@@ -306,29 +360,35 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
                             {
                                 DoScriptText(SAY_RECAST_GRAVITY, m_creature);
                             }
+
                             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)
+
+                            for(uint8 i = 0; i < 3; ++i)
                             {
                                 Unit* target = NULL;
                                 target = SelectUnit(SELECT_TARGET_RANDOM,0);
+
                                 Creature* Orb = DoSpawnCreature(CREATURE_ARCANE_SPHERE, 5, 5, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                                 if (Orb && target)
                                 {
@@ -336,9 +396,12 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
                                     Orb->AddThreat(target, 1.0f);
                                     Orb->AI()->AttackStart(target);
                                 }
+
                             }
+
                             DoCast(m_creature, SPELL_GRAVITY_LAPSE_CHANNEL);
                             break;
+
                         case 4:
                             m_creature->InterruptNonMeleeSpells(false);
                             DoScriptText(SAY_TIRED, m_creature);
@@ -354,21 +417,27 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_felkael_flamestrikeAI : public ScriptedAI
 {
     mob_felkael_flamestrikeAI(Creature *c) : ScriptedAI(c)
     {
         Heroic = c->GetMap()->IsHeroic();
     }
+
     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 EnterCombat(Unit *who) {}
     void MoveInLineOfSight(Unit *who) {}
     void UpdateAI(const uint32 diff)
@@ -380,17 +449,20 @@ struct TRINITY_DLL_DECL mob_felkael_flamestrikeAI : public ScriptedAI
         } else FlameStrikeTimer -= diff;
     }
 };
+
 struct TRINITY_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI
 {
     mob_felkael_phoenixAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     uint32 BurnTimer;
     uint32 Death_Timer;
     bool Rebirth;
     bool FakeDeath;
+
     void Reset()
     {
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE);
@@ -401,16 +473,20 @@ struct TRINITY_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI
         Rebirth = false;
         FakeDeath = false;
     }
+
     void EnterCombat(Unit* who) {}
+
     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 all phases of Kael'Thas
         if (pInstance && pInstance->GetData(DATA_KAELTHAS_EVENT) == 0)
@@ -418,6 +494,7 @@ struct TRINITY_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI
             //prevent death
             damage = 0;
             FakeDeath = true;
+
             m_creature->InterruptNonMeleeSpells(false);
             m_creature->SetHealth(0);
             m_creature->StopMoving();
@@ -431,14 +508,19 @@ struct TRINITY_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI
             m_creature->GetMotionMaster()->Clear();
             m_creature->GetMotionMaster()->MoveIdle();
             m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
+
        }
+
     }
+
     void JustDied(Unit* slayer)
     {
         m_creature->SummonCreature(CREATURE_PHOENIX_EGG, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000);
     }
+
     void UpdateAI(const uint32 diff)
     {
+
         //If we are fake death, we cast revbirth and after that we kill the phoenix to spawn the egg.
         if (FakeDeath)
         {
@@ -447,8 +529,10 @@ struct TRINITY_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI
                 DoCast(m_creature, SPELL_REBIRTH_DMG);
                 Rebirth = true;
             }
+
             if (Rebirth)
             {
+
                 if (Death_Timer < diff)
                 {
                     m_creature->SummonCreature(CREATURE_PHOENIX_EGG, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000);
@@ -458,9 +542,12 @@ struct TRINITY_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI
                 }else Death_Timer -= diff;
             }
 
+
         }
+
         if (!UpdateVictim())
             return;
+
         if (BurnTimer < diff)
         {
             //spell Burn should possible do this, but it doesn't, so do this for now.
@@ -468,19 +555,26 @@ struct TRINITY_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI
             m_creature->DealDamage(m_creature, dmg, 0, DOT, SPELL_SCHOOL_MASK_FIRE, NULL, false);
             BurnTimer += 2000;
         } BurnTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_felkael_phoenix_eggAI : public ScriptedAI
 {
     mob_felkael_phoenix_eggAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 HatchTimer;
+
     void Reset()
     {
         HatchTimer = 10000;
+
     }
+
     void EnterCombat(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (HatchTimer < diff)
@@ -488,31 +582,40 @@ struct TRINITY_DLL_DECL mob_felkael_phoenix_eggAI : public ScriptedAI
             m_creature->SummonCreature(CREATURE_PHOENIX, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
             m_creature->Kill(m_creature);
         } else HatchTimer -= diff;
+
     }
 };
+
 struct TRINITY_DLL_DECL mob_arcane_sphereAI : public ScriptedAI
 {
     mob_arcane_sphereAI(Creature *c) : ScriptedAI(c) {Reset();}
+
     uint32 DespawnTimer;
     uint32 ChangeTargetTimer;
+
     void Reset()
     {
         DespawnTimer = 30000;
         ChangeTargetTimer = urand(6000,12000);
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
         m_creature->setFaction(14);
         DoCast(m_creature, SPELL_ARCANE_SPHERE_PASSIVE, true);
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (DespawnTimer < diff)
             m_creature->Kill(m_creature);
         else DespawnTimer -= diff;
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (ChangeTargetTimer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
@@ -521,49 +624,61 @@ struct TRINITY_DLL_DECL mob_arcane_sphereAI : public ScriptedAI
                 m_creature->TauntApply(target);
                 AttackStart(target);
             }
+
             ChangeTargetTimer = urand(5000,15000);
         } 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_arcane_sphere";
     newscript->GetAI = &GetAI_mob_arcane_sphere;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_felkael_phoenix";
     newscript->GetAI = &GetAI_mob_felkael_phoenix;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_felkael_phoenix_egg";
     newscript->GetAI = &GetAI_mob_felkael_phoenix_egg;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_felkael_flamestrike";
     newscript->GetAI = &GetAI_mob_felkael_flamestrike;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_priestess_delrissa.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_priestess_delrissa.cpp
index ebf73da0f63..546f42cae19 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_priestess_delrissa.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_priestess_delrissa.cpp
@@ -13,18 +13,22 @@
  * along with 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: 65
 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"
+
 struct Speech
 {
     int32 id;
 };
+
 static Speech LackeyDeath[]=
 {
     {-1585013},
@@ -32,6 +36,7 @@ static Speech LackeyDeath[]=
     {-1585015},
     {-1585016},
 };
+
 static Speech PlayerDeath[]=
 {
     {-1585017},
@@ -40,10 +45,12 @@ static Speech PlayerDeath[]=
     {-1585020},
     {-1585021},
 };
+
 enum eEnums
 {
     SAY_AGGRO               = -1585012,
     SAY_DEATH               = -1585022,
+
     SPELL_DISPEL_MAGIC      = 27609,
     SPELL_FLASH_HEAL        = 17843,
     SPELL_SW_PAIN_NORMAL    = 14032,
@@ -51,10 +58,13 @@ enum eEnums
     SPELL_SHIELD            = 44291,
     SPELL_RENEW_NORMAL      = 44174,
     SPELL_RENEW_HEROIC      = 46192,
+
     MAX_ACTIVE_LACKEY       = 4
 };
+
 const float fOrientation = 4.98;
 const float fZLocation = -19.921;
+
 float LackeyLocations[4][2]=
 {
     {123.77, 17.6007},
@@ -62,6 +72,7 @@ float LackeyLocations[4][2]=
     {121.563, 15.6213},
     {129.988, 17.2355},
 };
+
 const uint32 m_auiAddEntries[] =
 {
     24557,                                                  //Kagani Nightstrike
@@ -73,6 +84,7 @@ const uint32 m_auiAddEntries[] =
     24553,                                                  //Apoko
     24556,                                                  //Zelfan
 };
+
 struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
 {
     boss_priestess_delrissaAI(Creature* c) : ScriptedAI(c)
@@ -82,38 +94,48 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
         memset(&m_auiLackeyGUID, 0, sizeof(m_auiLackeyGUID));
         LackeyEntryList.clear();
     }
+
     ScriptedInstance* pInstance;
     bool Heroic;
+
     std::vector LackeyEntryList;
     uint64 m_auiLackeyGUID[MAX_ACTIVE_LACKEY];
+
     uint8 PlayersKilled;
+
     uint32 HealTimer;
     uint32 RenewTimer;
     uint32 ShieldTimer;
     uint32 SWPainTimer;
     uint32 DispelTimer;
     uint32 ResetTimer;
+
     void Reset()
     {
         PlayersKilled = 0;
+
         HealTimer   = 15000;
         RenewTimer  = 10000;
         ShieldTimer = 2000;
         SWPainTimer = 5000;
         DispelTimer = 7500;
         ResetTimer = 5000;
+
         InitializeLackeys();
     }
+
     //this mean she at some point evaded
     void JustReachedHome()
     {
         if (pInstance)
              pInstance->SetData(DATA_DELRISSA_EVENT, FAIL);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
-        for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
+
+        for(uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
         {
             if (Unit* pAdd = Unit::GetUnit(*m_creature, m_auiLackeyGUID[i]))
             {
@@ -124,39 +146,48 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
                 }
             }
         }
+
         if (pInstance)
             pInstance->SetData(DATA_DELRISSA_EVENT, IN_PROGRESS);
     }
+
     void InitializeLackeys()
     {
         //can be called if Creature are dead, so avoid
         if (!m_creature->isAlive())
             return;
+
         uint8 j = 0;
+
         //it's empty, so first time
         if (LackeyEntryList.empty())
         {
             //pre-allocate size for speed
             LackeyEntryList.resize((sizeof(m_auiAddEntries) / sizeof(uint32)));
+
             //fill vector array with entries from Creature array
-            for (uint8 i = 0; i < LackeyEntryList.size(); ++i)
+            for(uint8 i = 0; i < LackeyEntryList.size(); ++i)
                 LackeyEntryList[i] = m_auiAddEntries[i];
+
             //remove random entries
             while(LackeyEntryList.size() > MAX_ACTIVE_LACKEY)
                 LackeyEntryList.erase(LackeyEntryList.begin() + rand()%LackeyEntryList.size());
+
             //summon all the remaining in vector
-            for (std::vector::iterator itr = LackeyEntryList.begin(); itr != LackeyEntryList.end(); ++itr)
+            for(std::vector::iterator itr = LackeyEntryList.begin(); itr != LackeyEntryList.end(); ++itr)
             {
                 if (Creature* pAdd = m_creature->SummonCreature((*itr), LackeyLocations[j][0], LackeyLocations[j][1], fZLocation, fOrientation, TEMPSUMMON_CORPSE_DESPAWN, 0))
                     m_auiLackeyGUID[j] = pAdd->GetGUID();
+
                 ++j;
             }
         }
         else
         {
-            for (std::vector::iterator itr = LackeyEntryList.begin(); itr != LackeyEntryList.end(); ++itr)
+            for(std::vector::iterator itr = LackeyEntryList.begin(); itr != LackeyEntryList.end(); ++itr)
             {
                 Unit* pAdd = Unit::GetUnit(*m_creature, m_auiLackeyGUID[j]);
+
                 //object already removed, not exist
                 if (!pAdd)
                 {
@@ -167,19 +198,25 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         if (victim->GetTypeId() != TYPEID_PLAYER)
             return;
+
         DoScriptText(PlayerDeath[PlayersKilled].id, m_creature);
+
         if (PlayersKilled < 4)
             ++PlayersKilled;
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (!pInstance)
             return;
+
         if (pInstance->GetData(DATA_DELRISSA_DEATH_COUNT) == MAX_ACTIVE_LACKEY)
             pInstance->SetData(DATA_DELRISSA_EVENT, DONE);
         else
@@ -188,10 +225,12 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
                 m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (ResetTimer < diff)
         {
             float x, y, z, o;
@@ -203,11 +242,12 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
             }
             ResetTimer = 5000;
         }else ResetTimer -= diff;
+
         if (HealTimer < diff)
         {
             uint32 health = m_creature->GetHealth();
             Unit* target = m_creature;
-            for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
+            for(uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
             {
                 if (Unit* pAdd = Unit::GetUnit(*m_creature, m_auiLackeyGUID[i]))
                 {
@@ -215,12 +255,15 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
                         target = pAdd;
                 }
             }
+
             DoCast(target, SPELL_FLASH_HEAL);
             HealTimer = 15000;
         }else HealTimer -= diff;
+
         if (RenewTimer < diff)
         {
             Unit* target = m_creature;
+
             if (rand()%2 == 1)
             {
                 if (Unit* pAdd = Unit::GetUnit(*m_creature, m_auiLackeyGUID[rand()%MAX_ACTIVE_LACKEY]))
@@ -232,9 +275,11 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
             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)
             {
                 if (Unit* pAdd = Unit::GetUnit(*m_creature, m_auiLackeyGUID[rand()%MAX_ACTIVE_LACKEY]))
@@ -243,18 +288,22 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
                         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
@@ -266,27 +315,35 @@ struct TRINITY_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI
                     }
                 }
             }
+
             if (target)
                 DoCast(target, SPELL_DISPEL_MAGIC);
+
             DispelTimer = 12000;
         }else DispelTimer -= diff;
+
         if (SWPainTimer < diff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, Heroic ? SPELL_SW_PAIN_HEROIC : SPELL_SW_PAIN_NORMAL);
+
             SWPainTimer = 10000;
         }else SWPainTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_priestess_delrissa(Creature* pCreature)
 {
     return new boss_priestess_delrissaAI(pCreature);
 }
+
 enum eHealingPotion
 {
     SPELL_HEALING_POTION    = 15503
 };
+
 //all 8 possible lackey use this common
 struct TRINITY_DLL_DECL boss_priestess_lackey_commonAI : public ScriptedAI
 {
@@ -296,18 +353,24 @@ struct TRINITY_DLL_DECL boss_priestess_lackey_commonAI : public ScriptedAI
         memset(&m_auiLackeyGUIDs, 0, sizeof(m_auiLackeyGUIDs));
         AcquireGUIDs();
     }
+
     ScriptedInstance* pInstance;
+
     uint64 m_auiLackeyGUIDs[MAX_ACTIVE_LACKEY];
     uint32 ResetThreatTimer;
+
     bool UsedPotion;
+
     void Reset()
     {
         UsedPotion = false;
+
         // These guys does not follow normal threat system rules
         // For later development, some alternative threat system should be made
         // We do not know what this system is based upon, but one theory is class (healers=high threat, dps=medium, etc)
         // We reset their threat frequently as an alternative until such a system exist
         ResetThreatTimer = 5000 + rand()%15000;
+
         // in case she is not alive and Reset was for some reason called, respawn her (most likely party wipe after killing her)
         if (Creature* pDelrissa = Unit::GetCreature(*m_creature, pInstance ? pInstance->GetData64(DATA_DELRISSA) : 0))
         {
@@ -315,13 +378,15 @@ struct TRINITY_DLL_DECL boss_priestess_lackey_commonAI : public ScriptedAI
                 pDelrissa->Respawn();
         }
     }
+
     void EnterCombat(Unit* pWho)
     {
         if (!pWho)
             return;
+
         if (pInstance)
         {
-            for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
+            for(uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
             {
                 if (Unit* pAdd = Unit::GetUnit(*m_creature, m_auiLackeyGUIDs[i]))
                 {
@@ -332,6 +397,7 @@ struct TRINITY_DLL_DECL boss_priestess_lackey_commonAI : public ScriptedAI
                     }
                 }
             }
+
             if (Creature* pDelrissa = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_DELRISSA)))
             {
                 if (pDelrissa->isAlive() && !pDelrissa->getVictim())
@@ -342,19 +408,26 @@ struct TRINITY_DLL_DECL boss_priestess_lackey_commonAI : public ScriptedAI
             }
         }
     }
+
     void JustDied(Unit* killer)
     {
         if (!pInstance)
             return;
+
         Creature* pDelrissa = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_DELRISSA));
         uint32 uiLackeyDeathCount = pInstance->GetData(DATA_DELRISSA_DEATH_COUNT);
+
         if (!pDelrissa)
             return;
+
         //should delrissa really yell if dead?
         DoScriptText(LackeyDeath[uiLackeyDeathCount].id, pDelrissa);
+
         pInstance->SetData(DATA_DELRISSA_DEATH_COUNT, SPECIAL);
+
         //increase local var, since we now may have four dead
         ++uiLackeyDeathCount;
+
         if (uiLackeyDeathCount == MAX_ACTIVE_LACKEY)
         {
             //time to make her lootable and complete event if she died before lackeys
@@ -362,27 +435,33 @@ struct TRINITY_DLL_DECL boss_priestess_lackey_commonAI : public ScriptedAI
             {
                 if (!pDelrissa->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE))
                     pDelrissa->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+
                 pInstance->SetData(DATA_DELRISSA_EVENT, DONE);
             }
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         if (!pInstance)
             return;
+
         if (Creature* Delrissa = (Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_DELRISSA))))
             Delrissa->AI()->KilledUnit(victim);
     }
+
     void AcquireGUIDs()
     {
         if (!pInstance)
             return;
+
         if (Creature* Delrissa = (Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_DELRISSA))))
         {
-            for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
+            for(uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
                 m_auiLackeyGUIDs[i] = CAST_AI(boss_priestess_delrissaAI, Delrissa->AI())->m_auiLackeyGUID[i];
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UsedPotion && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25))
@@ -390,6 +469,7 @@ struct TRINITY_DLL_DECL boss_priestess_lackey_commonAI : public ScriptedAI
             DoCast(m_creature, SPELL_HEALING_POTION);
             UsedPotion = true;
         }
+
         if (ResetThreatTimer < diff)
         {
             DoResetThreat();
@@ -397,6 +477,7 @@ struct TRINITY_DLL_DECL boss_priestess_lackey_commonAI : public ScriptedAI
         }else ResetThreatTimer -= diff;
     }
 };
+
 enum eRogueSpells
 {
     SPELL_KIDNEY_SHOT       = 27615,
@@ -406,16 +487,19 @@ enum eRogueSpells
     SPELL_BACKSTAB          = 15657,
     SPELL_EVISCERATE        = 27611
 };
+
 struct TRINITY_DLL_DECL boss_kagani_nightstrikeAI : public boss_priestess_lackey_commonAI
 {
     //Rogue
     boss_kagani_nightstrikeAI(Creature *c) : boss_priestess_lackey_commonAI(c) {}
+
     uint32 Gouge_Timer;
     uint32 Kick_Timer;
     uint32 Vanish_Timer;
     uint32 Eviscerate_Timer;
     uint32 Wait_Timer;
     bool InVanish;
+
     void Reset()
     {
         Gouge_Timer = 5500;
@@ -425,24 +509,33 @@ struct TRINITY_DLL_DECL boss_kagani_nightstrikeAI : public boss_priestess_lackey
         Wait_Timer = 5000;
         InVanish = false;
         m_creature->SetVisibility(VISIBILITY_ON);
+
         boss_priestess_lackey_commonAI::Reset();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         boss_priestess_lackey_commonAI::UpdateAI(diff);
+
         if (Vanish_Timer < diff)
         {
             DoCast(m_creature, SPELL_VANISH);
+
             Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0);
+
             DoResetThreat();
+
             if (pUnit)
                 m_creature->AddThreat(pUnit, 1000.0f);
+
             InVanish = true;
             Vanish_Timer = 30000;
             Wait_Timer = 10000;
         }else Vanish_Timer -= diff;
+
         if (InVanish)
         {
             if (Wait_Timer < diff)
@@ -453,29 +546,35 @@ struct TRINITY_DLL_DECL boss_kagani_nightstrikeAI : public boss_priestess_lackey
                 InVanish = false;
             }else Wait_Timer -= diff;
         }
+
         if (Gouge_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_GOUGE);
             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();
     }
 };
+
 CreatureAI* GetAI_boss_kagani_nightstrike(Creature* pCreature)
 {
     return new boss_kagani_nightstrikeAI(pCreature);
 }
+
 enum eWarlockSpells
 {
     SPELL_IMMOLATE              = 44267,
@@ -486,15 +585,18 @@ enum eWarlockSpells
     SPELL_IMP_FIREBALL          = 44164,
     SPELL_SUMMON_IMP            = 44163
 };
+
 struct TRINITY_DLL_DECL boss_ellris_duskhallowAI : public boss_priestess_lackey_commonAI
 {
     //Warlock
     boss_ellris_duskhallowAI(Creature *c) : boss_priestess_lackey_commonAI(c) {}
+
     uint32 Immolate_Timer;
     uint32 Shadow_Bolt_Timer;
     uint32 Seed_of_Corruption_Timer;
     uint32 Curse_of_Agony_Timer;
     uint32 Fear_Timer;
+
     void Reset()
     {
         Immolate_Timer = 6000;
@@ -502,91 +604,117 @@ struct TRINITY_DLL_DECL boss_ellris_duskhallowAI : public boss_priestess_lackey_
         Seed_of_Corruption_Timer = 2000;
         Curse_of_Agony_Timer = 1000;
         Fear_Timer = 10000;
+
         boss_priestess_lackey_commonAI::Reset();
     }
+
     void Aggro(Unit* pWho)
     {
         DoCast(m_creature,SPELL_SUMMON_IMP);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         boss_priestess_lackey_commonAI::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)
         {
             if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pUnit, SPELL_SEED_OF_CORRUPTION);
+
             Seed_of_Corruption_Timer = 10000;
         }else Seed_of_Corruption_Timer -= diff;
+
         if (Curse_of_Agony_Timer < diff)
         {
             if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pUnit, SPELL_CURSE_OF_AGONY);
+
             Curse_of_Agony_Timer = 13000;
         }else Curse_of_Agony_Timer -= diff;
+
         if (Fear_Timer < diff)
         {
             if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pUnit, SPELL_FEAR);
+
             Fear_Timer = 10000;
         }else Fear_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_ellris_duskhallow(Creature* pCreature)
 {
     return new boss_ellris_duskhallowAI(pCreature);
 }
+
 enum eKickDown
 {
     SPELL_KNOCKDOWN     = 11428,
     SPELL_SNAP_KICK     = 46182
 };
+
 struct TRINITY_DLL_DECL boss_eramas_brightblazeAI : public boss_priestess_lackey_commonAI
 {
     //Monk
     boss_eramas_brightblazeAI(Creature *c) : boss_priestess_lackey_commonAI(c) {}
+
     uint32 Knockdown_Timer;
     uint32 Snap_Kick_Timer;
+
     void Reset()
     {
         Knockdown_Timer = 6000;
         Snap_Kick_Timer = 4500;
+
         boss_priestess_lackey_commonAI::Reset();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         boss_priestess_lackey_commonAI::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();
     }
 };
+
 CreatureAI* GetAI_eramas_brightblaze(Creature* pCreature)
 {
     return new boss_eramas_brightblazeAI(pCreature);
 }
+
 enum eMageSpells
 {
     SPELL_POLYMORPH         = 13323,
@@ -597,11 +725,14 @@ enum eMageSpells
     SPELL_FROSTBOLT         = 15043,
     SPELL_BLINK             = 14514
 };
+
 struct TRINITY_DLL_DECL boss_yazzaiAI : public boss_priestess_lackey_commonAI
 {
     //Mage
     boss_yazzaiAI(Creature *c) : boss_priestess_lackey_commonAI(c) {}
+
     bool HasIceBlocked;
+
     uint32 Polymorph_Timer;
     uint32 Ice_Block_Timer;
     uint32 Wait_Timer;
@@ -610,9 +741,11 @@ struct TRINITY_DLL_DECL boss_yazzaiAI : public boss_priestess_lackey_commonAI
     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;
@@ -621,13 +754,17 @@ struct TRINITY_DLL_DECL boss_yazzaiAI : public boss_priestess_lackey_commonAI
         Cone_of_Cold_Timer = 10000;
         Frostbolt_Timer = 3000;
         Blink_Timer = 8000;
+
         boss_priestess_lackey_commonAI::Reset();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         boss_priestess_lackey_commonAI::UpdateAI(diff);
+
         if (Polymorph_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -636,37 +773,44 @@ struct TRINITY_DLL_DECL boss_yazzaiAI : public boss_priestess_lackey_commonAI
                 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)
         {
             if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pUnit, 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)
+            for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
             {
                 if (Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()))
                 {
@@ -678,18 +822,23 @@ struct TRINITY_DLL_DECL boss_yazzaiAI : public boss_priestess_lackey_commonAI
                     }
                 }
             }
+
             //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();
     }
 };
+
 CreatureAI* GetAI_yazzai(Creature* pCreature)
 {
     return new boss_yazzaiAI(pCreature);
 }
+
 enum eWarriorSpells
 {
     SPELL_INTERCEPT_STUN        = 27577,
@@ -700,16 +849,19 @@ enum eWarriorSpells
     SPELL_BATTLE_SHOUT          = 27578,
     SPELL_MORTAL_STRIKE         = 44268
 };
+
 struct TRINITY_DLL_DECL boss_warlord_salarisAI : public boss_priestess_lackey_commonAI
 {
     //Warrior
     boss_warlord_salarisAI(Creature *c) : boss_priestess_lackey_commonAI(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;
@@ -718,22 +870,27 @@ struct TRINITY_DLL_DECL boss_warlord_salarisAI : public boss_priestess_lackey_co
         Frightening_Shout_Timer = 18000;
         Hamstring_Timer = 4500;
         Mortal_Strike_Timer = 8000;
+
         boss_priestess_lackey_commonAI::Reset();
     }
+
     void EnterCombat(Unit* who)
     {
         DoCast(m_creature, SPELL_BATTLE_SHOUT);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         boss_priestess_lackey_commonAI::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)
+            for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
             {
                 if (Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()))
                 {
@@ -745,46 +902,56 @@ struct TRINITY_DLL_DECL boss_warlord_salarisAI : public boss_priestess_lackey_co
                     }
                 }
             }
+
             //if nobody is in melee range than try to use Intercept
             if (!InMeleeRange)
             {
                 if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                     DoCast(pUnit, 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();
     }
 };
+
 CreatureAI* GetAI_warlord_salaris(Creature* pCreature)
 {
     return new boss_warlord_salarisAI(pCreature);
 }
+
 enum eHunterSpells
 {
     SPELL_AIMED_SHOT            = 44271,
@@ -793,19 +960,24 @@ enum eHunterSpells
     SPELL_MULTI_SHOT            = 31942,
     SPELL_WING_CLIP             = 44286,
     SPELL_FREEZING_TRAP         = 44136,
+
     NPC_SLIVER                  = 24552
 };
+
 struct TRINITY_DLL_DECL boss_garaxxasAI : public boss_priestess_lackey_commonAI
 {
     //Hunter
     boss_garaxxasAI(Creature *c) : boss_priestess_lackey_commonAI(c) { m_uiPetGUID = 0; }
+
     uint64 m_uiPetGUID;
+
     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()
     {
         Aimed_Shot_Timer = 6000;
@@ -814,20 +986,26 @@ struct TRINITY_DLL_DECL boss_garaxxasAI : public boss_priestess_lackey_commonAI
         Multi_Shot_Timer = 10000;
         Wing_Clip_Timer = 4000;
         Freezing_Trap_Timer = 15000;
+
         Unit* pPet = Unit::GetUnit(*m_creature,m_uiPetGUID);
         if (!pPet)
             m_creature->SummonCreature(NPC_SLIVER, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0);
+
         boss_priestess_lackey_commonAI::Reset();
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         m_uiPetGUID = pSummoned->GetGUID();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         boss_priestess_lackey_commonAI::UpdateAI(diff);
+
         if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
         {
             if (Wing_Clip_Timer < diff)
@@ -835,10 +1013,12 @@ struct TRINITY_DLL_DECL boss_garaxxasAI : public boss_priestess_lackey_commonAI
                 DoCast(m_creature->getVictim(), SPELL_WING_CLIP);
                 Wing_Clip_Timer = 4000;
             }else Wing_Clip_Timer -= diff;
+
             if (Freezing_Trap_Timer < diff)
             {
                 //attempt find go summoned from spell (casted by m_creature)
                 GameObject* pGo = m_creature->GetGameObject(SPELL_FREEZING_TRAP);
+
                 //if we have a pGo, we need to wait (only one trap at a time)
                 if (pGo)
                     Freezing_Trap_Timer = 2500;
@@ -849,6 +1029,7 @@ struct TRINITY_DLL_DECL boss_garaxxasAI : public boss_priestess_lackey_commonAI
                     Freezing_Trap_Timer = 15000;
                 }
             }else Freezing_Trap_Timer -= diff;
+
             DoMeleeAttackIfReady();
         }
         else
@@ -858,16 +1039,19 @@ struct TRINITY_DLL_DECL boss_garaxxasAI : public boss_priestess_lackey_commonAI
                 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);
@@ -876,10 +1060,12 @@ struct TRINITY_DLL_DECL boss_garaxxasAI : public boss_priestess_lackey_commonAI
         }
     }
 };
+
 CreatureAI* GetAI_garaxxas(Creature* pCreature)
 {
     return new boss_garaxxasAI(pCreature);
 }
+
 enum Spells
 {
     SPELL_WINDFURY_TOTEM        = 27621,
@@ -890,16 +1076,19 @@ enum Spells
     SPELL_FIRE_NOVA_TOTEM       = 44257,
     SPELL_EARTHBIND_TOTEM       = 15786
 };
+
 struct TRINITY_DLL_DECL boss_apokoAI : public boss_priestess_lackey_commonAI
 {
     //Shaman
     boss_apokoAI(Creature *c) : boss_priestess_lackey_commonAI(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;
@@ -908,35 +1097,44 @@ struct TRINITY_DLL_DECL boss_apokoAI : public boss_priestess_lackey_commonAI
         Purge_Timer = 8000;
         Healing_Wave_Timer = 5000;
         Frost_Shock_Timer = 7000;
+
         boss_priestess_lackey_commonAI::Reset();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         boss_priestess_lackey_commonAI::UpdateAI(diff);
+
         if (Totem_Timer < diff)
         {
             DoCast(m_creature, RAND(SPELL_WINDFURY_TOTEM,SPELL_FIRE_NOVA_TOTEM,SPELL_EARTHBIND_TOTEM));
             ++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)
         {
             if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pUnit, 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();
@@ -951,13 +1149,16 @@ struct TRINITY_DLL_DECL boss_apokoAI : public boss_priestess_lackey_commonAI
             //    }
             // }
         } else Healing_Wave_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_apoko(Creature* pCreature)
 {
     return new boss_apokoAI(pCreature);
 }
+
 enum eEngineerSpells
 {
     SPELL_GOBLIN_DRAGON_GUN     = 44272,
@@ -967,15 +1168,18 @@ enum eEngineerSpells
     SPELL_FEL_IRON_BOMB         = 46024,
     SPELL_SHEEP_EXPLOSION       = 44279
 };
+
 struct TRINITY_DLL_DECL boss_zelfanAI : public boss_priestess_lackey_commonAI
 {
     //Engineer
     boss_zelfanAI(Creature *c) : boss_priestess_lackey_commonAI(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;
@@ -983,31 +1187,38 @@ struct TRINITY_DLL_DECL boss_zelfanAI : public boss_priestess_lackey_commonAI
         Recombobulate_Timer = 4000;
         High_Explosive_Sheep_Timer = 10000;
         Fel_Iron_Bomb_Timer = 15000;
+
         boss_priestess_lackey_commonAI::Reset();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         boss_priestess_lackey_commonAI::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 < MAX_ACTIVE_LACKEY; ++i)
+            for(uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
             {
                 if (Unit* pAdd = Unit::GetUnit(*m_creature, m_auiLackeyGUIDs[i]))
                 {
@@ -1020,18 +1231,22 @@ struct TRINITY_DLL_DECL boss_zelfanAI : public boss_priestess_lackey_commonAI
             }
             Recombobulate_Timer = 2000;
         }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();
     }
 };
+
 CreatureAI* GetAI_zelfan(Creature* pCreature)
 {
     return new boss_zelfanAI(pCreature);
 }
+
 //struct TRINITY_DLL_DECL mob_high_explosive_sheepAI : public ScriptedAI
 //{
 //    mob_high_explosive_sheepAI(Creature *c) : ScriptedAI(c) {}
@@ -1056,49 +1271,61 @@ CreatureAI* GetAI_zelfan(Creature* pCreature)
 //            Explosion_Timer -= diff;
 //    }
 //};
+
 //CreatureAI* GetAI_mob_high_explosive_sheep(Creature* pCreature)
 //{
 //    return new mob_high_explosive_sheepAI (pCreature);
 //};
+
 void AddSC_boss_priestess_delrissa()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_priestess_delrissa";
     newscript->GetAI = &GetAI_boss_priestess_delrissa;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_kagani_nightstrike";
     newscript->GetAI = &GetAI_boss_kagani_nightstrike;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_ellris_duskhallow";
     newscript->GetAI = &GetAI_ellris_duskhallow;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_eramas_brightblaze";
     newscript->GetAI = &GetAI_eramas_brightblaze;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_yazzai";
     newscript->GetAI = &GetAI_yazzai;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_warlord_salaris";
     newscript->GetAI = &GetAI_warlord_salaris;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_garaxxas";
     newscript->GetAI = &GetAI_garaxxas;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_apoko";
     newscript->GetAI = &GetAI_apoko;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_zelfan";
     newscript->GetAI = &GetAI_zelfan;
     newscript->RegisterSelf();
+
     /*newscript = new Script;
     newscript->Name = "mob_high_explosive_sheep";
     newscript->GetAI = &GetAI_mob_high_explosive_sheep;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_selin_fireheart.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_selin_fireheart.cpp
index 22e1ad968d0..080e2ad6f68 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_selin_fireheart.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_selin_fireheart.cpp
@@ -13,14 +13,17 @@
  * along with 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: 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                       -1585000
 #define SAY_ENERGY                      -1585001
 #define SAY_EMPOWERED                   -1585002
@@ -28,29 +31,36 @@ EndScriptData */
 #define SAY_KILL_2                      -1585004
 #define SAY_DEATH                       -1585005
 #define EMOTE_CRYSTAL                   -1585006
+
 //Crystal effect 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 TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
 {
     boss_selin_fireheartAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = 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)
+            for(uint8 i = 0; i < size; ++i)
             {
                 uint64 guid = pInstance->GetData64(DATA_FEL_CRYSTAL);
                 debug_log("TSCR: Selin: Adding Fel Crystal %u to list", guid);
@@ -59,23 +69,29 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
         }
         Heroic = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool Heroic;
+
     std::list Crystals;
+
     uint32 DrainLifeTimer;
     uint32 DrainManaTimer;
     uint32 FelExplosionTimer;
     uint32 DrainCrystalTimer;
     uint32 EmpowerTimer;
+
     bool IsDraining;
     bool DrainingCrystal;
+
     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)
+            //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);
@@ -83,36 +99,42 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
                 {
                     if (!pUnit->isAlive())
                         CAST_CRE(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);
                 }
             }
+
             pInstance->HandleGameObject(pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), true);
             // Open the big encounter door. Close it in Aggro and open it only in JustDied(and here)
                                                             // Small door opened after event are expected to be closed by default
             // 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)
+        //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]);
@@ -131,20 +153,25 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
         {
             DoScriptText(SAY_ENERGY, m_creature);
             DoScriptText(EMOTE_CRYSTAL, m_creature);
+
             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)
+
+        //for(uint8 i = 0; i < CRYSTALS_NUMBER; ++i)
+        for(std::list::iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr)
         {
             //Creature* pCrystal = (Unit::GetCreature(*m_creature, FelCrystals[i]));
             Creature* pCrystal = Unit::GetCreature(*m_creature, *itr);
@@ -152,17 +179,21 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
                 pCrystal->Kill(pCrystal);
         }
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->HandleGameObject(pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), false);
             //Close the encounter door, open it in JustDied/Reset
      }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type == POINT_MOTION_TYPE && id == 1)
@@ -184,20 +215,25 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
             }
         }
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (!pInstance)
             return;
+
         pInstance->SetData(DATA_SELIN_EVENT, DONE);         // Encounter complete!
         pInstance->HandleGameObject(pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), true);                  // Open the encounter door
         pInstance->HandleGameObject(pInstance->GetData64(DATA_SELIN_DOOR), true);                 // Open the door leading further in
         ShatterRemainingCrystals();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (!DrainingCrystal)
         {
             uint32 maxPowerMana = m_creature->GetMaxPower(POWER_MANA);
@@ -208,6 +244,7 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
                     DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DRAIN_LIFE);
                     DrainLifeTimer = 10000;
                 } else DrainLifeTimer -= diff;
+
                 // Heroic only
                 if (Heroic)
                 {
@@ -218,6 +255,7 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
                     } else DrainManaTimer -= diff;
                 }
             }
+
             if (FelExplosionTimer < diff)
             {
                 if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -226,6 +264,7 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
                     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))
@@ -237,6 +276,7 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
                     else        DrainCrystalTimer = 20000 + rand()%5000;
                 } else DrainCrystalTimer -= diff;
             }
+
         }else
         {
             if (IsDraining)
@@ -245,32 +285,41 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI
                 {
                     IsDraining = false;
                     DrainingCrystal = false;
+
                     DoScriptText(SAY_EMPOWERED, m_creature);
+
                     Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID);
                     if (CrystalChosen && CrystalChosen->isAlive())
                         // Use Deal Damage to kill it, not setDeathState.
                         CrystalChosen->Kill(CrystalChosen);
+
                     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* pCreature)
 {
     return new boss_selin_fireheartAI (pCreature);
 };
+
 struct TRINITY_DLL_DECL mob_fel_crystalAI : public ScriptedAI
 {
     mob_fel_crystalAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit* who) {}
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
     void UpdateAI(const uint32 diff) {}
+
     void JustDied(Unit* killer)
     {
         if (ScriptedInstance* pInstance = m_creature->GetInstanceData())
@@ -294,17 +343,21 @@ struct TRINITY_DLL_DECL mob_fel_crystalAI : public ScriptedAI
         } else error_log(ERROR_INST_DATA);
     }
 };
+
 CreatureAI* GetAI_mob_fel_crystal(Creature* pCreature)
 {
     return new mob_fel_crystalAI (pCreature);
 };
+
 void AddSC_boss_selin_fireheart()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_selin_fireheart";
     newscript->GetAI = &GetAI_boss_selin_fireheart;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_fel_crystal";
     newscript->GetAI = &GetAI_mob_fel_crystal;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_vexallus.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_vexallus.cpp
index a90f435aa9c..82b5980ca44 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_vexallus.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_vexallus.cpp
@@ -13,14 +13,17 @@
  * along with 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"
+
 enum eEnums
 {
     SAY_AGGRO                       = -1585007,
@@ -28,25 +31,32 @@ enum eEnums
     SAY_OVERLOAD                    = -1585009,
     SAY_KILL                        = -1585010,
     EMOTE_DISCHARGE_ENERGY          = -1585011,
+
     //is this text for real?
     //#define SAY_DEATH             "What...happen...ed."
+
     //Pure energy spell info
     SPELL_ENERGY_BOLT               = 46156,
     SPELL_ENERGY_FEEDBACK           = 44335,
+
     //Vexallus spell info
     SPELL_CHAIN_LIGHTNING           = 44318,
     SPELL_H_CHAIN_LIGHTNING         = 46380,                //heroic spell
     SPELL_OVERLOAD                  = 44353,
     SPELL_ARCANE_SHOCK              = 44319,
     SPELL_H_ARCANE_SHOCK            = 46381,                //heroic spell
+
     SPELL_SUMMON_PURE_ENERGY        = 44322,                //mod scale -10
     H_SPELL_SUMMON_PURE_ENERGY1     = 46154,                //mod scale -5
     H_SPELL_SUMMON_PURE_ENERGY2     = 46159,                //mod scale -5
+
     //Creatures
     NPC_PURE_ENERGY                 = 24745,
+
     INTERVAL_MODIFIER               = 15,
     INTERVAL_SWITCH                 = 6
 };
+
 struct  TRINITY_DLL_DECL boss_vexallusAI : public ScriptedAI
 {
     boss_vexallusAI(Creature *c) : ScriptedAI(c)
@@ -54,13 +64,16 @@ struct  TRINITY_DLL_DECL boss_vexallusAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         Heroic = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool Heroic;
+
     uint32 ChainLightningTimer;
     uint32 ArcaneShockTimer;
     uint32 OverloadTimer;
     uint32 IntervalHealthAmount;
     bool Enraged;
+
     void Reset()
     {
         ChainLightningTimer = 8000;
@@ -68,35 +81,44 @@ struct  TRINITY_DLL_DECL boss_vexallusAI : public ScriptedAI
         OverloadTimer = 1200;
         IntervalHealthAmount = 1;
         Enraged = false;
+
         if (pInstance)
             pInstance->SetData(DATA_VEXALLUS_EVENT, NOT_STARTED);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
             pInstance->SetData(DATA_VEXALLUS_EVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_VEXALLUS_EVENT, IN_PROGRESS);
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (Unit *temp = SelectUnit(SELECT_TARGET_RANDOM, 0))
             summoned->GetMotionMaster()->MoveFollow(temp,0,0);
+
         //spells are SUMMON_TYPE_GUARDIAN, so using setOwner should be ok
         summoned->CastSpell(summoned,SPELL_ENERGY_BOLT,false,0,0,m_creature->GetGUID());
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (!Enraged)
         {
             //used for check, when Vexallus cast adds 85%, 70%, 55%, 40%, 25%
@@ -110,8 +132,10 @@ struct  TRINITY_DLL_DECL boss_vexallusAI : public ScriptedAI
                 }
                 else
                     ++IntervalHealthAmount;
+
                 DoScriptText(SAY_ENERGY, m_creature);
                 DoScriptText(EMOTE_DISCHARGE_ENERGY, m_creature);
+
                 if (Heroic)
                 {
                     m_creature->CastSpell(m_creature,H_SPELL_SUMMON_PURE_ENERGY1,false);
@@ -119,22 +143,28 @@ struct  TRINITY_DLL_DECL boss_vexallusAI : public ScriptedAI
                 }
                 else
                     m_creature->CastSpell(m_creature,SPELL_SUMMON_PURE_ENERGY,false);
+
                 //below are workaround summons, remove when summoning spells w/implicitTarget 73 implemented in Mangos
                 m_creature->SummonCreature(NPC_PURE_ENERGY, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0);
+
                 if (Heroic)
                     m_creature->SummonCreature(NPC_PURE_ENERGY, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0);
             }
+
             if (ChainLightningTimer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                     DoCast(target, Heroic ? SPELL_H_CHAIN_LIGHTNING : SPELL_CHAIN_LIGHTNING);
+
                 ChainLightningTimer = 8000;
             }else ChainLightningTimer -= diff;
+
             if (ArcaneShockTimer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 if (target)
                     DoCast(target, Heroic ? SPELL_H_ARCANE_SHOCK : SPELL_ARCANE_SHOCK);
+
                 ArcaneShockTimer = 8000;
             }else ArcaneShockTimer -= diff;
         }
@@ -143,20 +173,26 @@ struct  TRINITY_DLL_DECL boss_vexallusAI : public ScriptedAI
             if (OverloadTimer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_OVERLOAD);
+
                 OverloadTimer = 2000;
             }else OverloadTimer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_vexallus(Creature* pCreature)
 {
     return new boss_vexallusAI (pCreature);
 };
+
 struct  TRINITY_DLL_DECL mob_pure_energyAI : public ScriptedAI
 {
     mob_pure_energyAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() { }
+
     void JustDied(Unit* slayer)
     {
         if (Unit *temp = m_creature->GetOwner())
@@ -165,21 +201,26 @@ struct  TRINITY_DLL_DECL mob_pure_energyAI : public ScriptedAI
                 slayer->CastSpell(slayer, SPELL_ENERGY_FEEDBACK, true, 0, 0, temp->GetGUID());
         }
     }
+
     void EnterCombat(Unit *who) { }
     void MoveInLineOfSight(Unit *who) { }
     void AttackStart(Unit *who) { }
 };
+
 CreatureAI* GetAI_mob_pure_energy(Creature* pCreature)
 {
     return new mob_pure_energyAI (pCreature);
 };
+
 void AddSC_boss_vexallus()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_vexallus";
     newscript->GetAI = &GetAI_boss_vexallus;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_pure_energy";
     newscript->GetAI = &GetAI_mob_pure_energy;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/def_magisters_terrace.h b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/def_magisters_terrace.h
index ac7aee1f887..d6419ea409c 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/def_magisters_terrace.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/def_magisters_terrace.h
@@ -1,24 +1,31 @@
 /* Copyright (C) 2006 - 2009 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_DOOR              13
 #define DATA_KAEL_STATUE_LEFT       14
 #define DATA_KAEL_STATUE_RIGHT      15
+
 #define DATA_DELRISSA_DEATH_COUNT   16
+
 #define ERROR_INST_DATA      "TSCR 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/eastern_kingdoms/magisters_terrace/instance_magisters_terrace.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/instance_magisters_terrace.cpp
index 7874123a4f4..4b7a68b9a61 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/instance_magisters_terrace.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/instance_magisters_terrace.cpp
@@ -13,28 +13,36 @@
  * along 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: 60
 SDComment:  Designed only for Selin Fireheart
 SDCategory: Magister's Terrace
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_magisters_terrace.h"
+
 #define MAX_ENCOUNTER      4
+
 /*
 0  - Selin Fireheart
 1  - Vexallus
 2  - Priestess Delrissa
 3  - Kael'thas Sunstrider
 */
+
 struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
 {
     instance_magisters_terrace(Map* pMap) : ScriptedInstance(pMap) {Initialize();}
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     uint32 DelrissaDeathCount;
+
     std::list FelCrystals;
     std::list::iterator CrystalItr;
+
     uint64 SelinGUID;
     uint64 DelrissaGUID;
     uint64 VexallusDoorGUID;
@@ -43,12 +51,17 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
     uint64 DelrissaDoorGUID;
     uint64 KaelDoorGUID;
     uint64 KaelStatue[2];
+
     bool InitializedItr;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         FelCrystals.clear();
+
         DelrissaDeathCount = 0;
+
         SelinGUID = 0;
         DelrissaGUID = 0;
         VexallusDoorGUID = 0;
@@ -58,15 +71,18 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
         KaelDoorGUID = 0;
         KaelStatue[0] = 0;
         KaelStatue[1] = 0;
+
         InitializedItr = false;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)
                 return true;
         return false;
     }
+
     uint32 GetData(uint32 identifier)
     {
         switch(identifier)
@@ -80,6 +96,7 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 identifier, uint32 data)
     {
         switch(identifier)
@@ -98,6 +115,7 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
                 m_auiEncounter[2] = data;
                 break;
             case DATA_KAELTHAS_EVENT:    m_auiEncounter[3] = data;  break;
+
             case DATA_DELRISSA_DEATH_COUNT:
                 if (data == SPECIAL)
                     ++DelrissaDeathCount;
@@ -106,6 +124,7 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
                 break;
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -115,6 +134,7 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
             case 24722: FelCrystals.push_back(pCreature->GetGUID()); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -130,6 +150,7 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
             case 188166:  KaelStatue[1] = pGo->GetGUID();          break;
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -143,6 +164,7 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
             case DATA_KAEL_DOOR:            return KaelDoorGUID;
             case DATA_KAEL_STATUE_LEFT:     return KaelStatue[0];
             case DATA_KAEL_STATUE_RIGHT:    return KaelStatue[1];
+
             case DATA_FEL_CRYSTAL:
             {
                 if (FelCrystals.empty())
@@ -150,11 +172,13 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
                     error_log("TSCR: Magisters Terrace: No Fel Crystals loaded in Inst Data");
                     return 0;
                 }
+
                 if (!InitializedItr)
                 {
                     CrystalItr = FelCrystals.begin();
                     InitializedItr = true;
                 }
+
                 uint64 guid = *CrystalItr;
                 ++CrystalItr;
                 return guid;
@@ -163,13 +187,16 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance
         return 0;
     }
 };
+
 InstanceData* GetInstanceData_instance_magisters_terrace(Map* pMap)
 {
     return new instance_magisters_terrace(pMap);
 }
+
 void AddSC_instance_magisters_terrace()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "instance_magisters_terrace";
     newscript->GetInstanceData = &GetInstanceData_instance_magisters_terrace;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/magisters_terrace.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/magisters_terrace.cpp
index 542569c8392..b23d5e72186 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/magisters_terrace.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/magisters_terrace.cpp
@@ -13,19 +13,24 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Magisters_Terrace
 SD%Complete: 100
 SDComment: Quest support: 11490(post-event)
 SDCategory: Magisters Terrace
 EndScriptData */
+
 /* ContentData
 npc_kalecgos
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## npc_kalecgos
 ######*/
+
 enum eEnums
 {
     SPELL_TRANSFORM_TO_KAEL     = 44670,
@@ -33,43 +38,57 @@ enum eEnums
     NPC_KAEL                    = 24848,                    //human form entry
     POINT_ID_LAND               = 1
 };
+
 const float afKaelLandPoint[] = {225.045, -276.236, -5.434};
+
 #define GOSSIP_ITEM_KAEL_1      "Who are you?"
 #define GOSSIP_ITEM_KAEL_2      "What can we do to assist you?"
 #define GOSSIP_ITEM_KAEL_3      "What brings you to the Sunwell?"
 #define GOSSIP_ITEM_KAEL_4      "You're not alone here?"
 #define GOSSIP_ITEM_KAEL_5      "What would Kil'jaeden want with a mortal woman?"
+
 // This is friendly keal that appear after used Orb.
 // If we assume DB handle summon, summon appear somewhere outside the platform where Orb is
 struct TRINITY_DLL_DECL npc_kalecgosAI : public ScriptedAI
 {
     npc_kalecgosAI(Creature* pCreature) : ScriptedAI(pCreature) { }
+
     uint32 m_uiTransformTimer;
+
     void Reset()
     {
         m_uiTransformTimer = 0;
+
         // we must assume he appear as dragon somewhere outside the platform of orb, and then move directly to here
         if (m_creature->GetEntry() != NPC_KAEL)
             m_creature->GetMotionMaster()->MovePoint(POINT_ID_LAND, afKaelLandPoint[0], afKaelLandPoint[1], afKaelLandPoint[2]);
     }
+
     void MovementInform(uint32 uiType, uint32 uiPointId)
     {
         if (uiType != POINT_MOTION_TYPE)
             return;
+
         if (uiPointId == POINT_ID_LAND)
             m_uiTransformTimer = MINUTE*IN_MILISECONDS;
     }
+
     // some targeting issues with the spell, so use this workaround as temporary solution
     void DoWorkaroundForQuestCredit()
     {
         Map* pMap = m_creature->GetMap();
+
         if (!pMap || pMap->IsHeroic())
             return;
+
         Map::PlayerList const &lList = pMap->GetPlayers();
+
         if (lList.isEmpty())
             return;
+
         SpellEntry const* pSpell = GetSpellStore()->LookupEntry(SPELL_ORB_KILL_CREDIT);
-        for (Map::PlayerList::const_iterator i = lList.begin(); i != lList.end(); ++i)
+
+        for(Map::PlayerList::const_iterator i = lList.begin(); i != lList.end(); ++i)
         {
             if (Player* pPlayer = i->getSource())
             {
@@ -78,6 +97,7 @@ struct TRINITY_DLL_DECL npc_kalecgosAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (m_uiTransformTimer)
@@ -86,26 +106,33 @@ struct TRINITY_DLL_DECL npc_kalecgosAI : public ScriptedAI
             {
                 m_creature->CastSpell(m_creature,SPELL_ORB_KILL_CREDIT,false);
                 DoWorkaroundForQuestCredit();
+
                 // Transform and update entry, now ready for quest/read gossip
                 m_creature->CastSpell(m_creature,SPELL_TRANSFORM_TO_KAEL,false);
                 m_creature->UpdateEntry(NPC_KAEL);
+
                 m_uiTransformTimer = 0;
             }else m_uiTransformTimer -= uiDiff;
         }
     }
 };
+
 CreatureAI* GetAI_npc_kalecgos(Creature* pCreature)
 {
     return new npc_kalecgosAI(pCreature);
 }
+
 bool GossipHello_npc_kalecgos(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KAEL_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
     pPlayer->SEND_GOSSIP_MENU(12498, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_kalecgos(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -130,11 +157,14 @@ bool GossipSelect_npc_kalecgos(Player* pPlayer, Creature* pCreature, uint32 uiSe
             pPlayer->SEND_GOSSIP_MENU(12608, pCreature->GetGUID());
             break;
     }
+
     return true;
 }
+
 void AddSC_magisters_terrace()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_kalecgos";
     newscript->GetAI = &GetAI_npc_kalecgos;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_baron_geddon.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_baron_geddon.cpp
index c32f85e2797..1a6ead66319 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_baron_geddon.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_baron_geddon.cpp
@@ -13,37 +13,47 @@
  * along with 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 EMOTE_SERVICE               -1409000
+
 #define SPELL_INFERNO               19695
 #define SPELL_IGNITEMANA            19659
 #define SPELL_LIVINGBOMB            20475
 #define SPELL_ARMAGEDDOM            20479
+
 struct TRINITY_DLL_DECL boss_baron_geddonAI : public ScriptedAI
 {
     boss_baron_geddonAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //If we are <2% hp cast Armageddom
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 2)
         {
@@ -52,26 +62,32 @@ struct TRINITY_DLL_DECL boss_baron_geddonAI : public ScriptedAI
             DoScriptText(EMOTE_SERVICE, m_creature);
             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)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 DoCast(target,SPELL_IGNITEMANA);
+
             IgniteMana_Timer = 30000;
         }else IgniteMana_Timer -= diff;
+
         //LivingBomb_Timer
         if (LivingBomb_Timer < diff)
         {
            if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                DoCast(target,SPELL_LIVINGBOMB);
+
             LivingBomb_Timer = 35000;
         }else LivingBomb_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -79,6 +95,7 @@ CreatureAI* GetAI_boss_baron_geddon(Creature* pCreature)
 {
     return new boss_baron_geddonAI (pCreature);
 }
+
 void AddSC_boss_baron_geddon()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_garr.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_garr.cpp
index 89336c33166..bfdc20a251a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_garr.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_garr.cpp
@@ -13,78 +13,98 @@
  * along with 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 TRINITY_DLL_DECL boss_garrAI : public ScriptedAI
 {
     boss_garrAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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 TRINITY_DLL_DECL mob_fireswornAI : public ScriptedAI
 {
     mob_fireswornAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Immolate_Timer;
+
     void Reset()
     {
         Immolate_Timer = 4000;                              //These times are probably wrong
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //Immolate_Timer
         if (Immolate_Timer < diff)
         {
              if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 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)
         {
@@ -92,6 +112,7 @@ struct TRINITY_DLL_DECL mob_fireswornAI : public ScriptedAI
             m_creature->setDeathState(JUST_DIED);
             m_creature->RemoveCorpse();
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -99,17 +120,21 @@ CreatureAI* GetAI_boss_garr(Creature* pCreature)
 {
     return new boss_garrAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_firesworn(Creature* pCreature)
 {
     return new mob_fireswornAI (pCreature);
 }
+
 void AddSC_boss_garr()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_garr";
     newscript->GetAI = &GetAI_boss_garr;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_firesworn";
     newscript->GetAI = &GetAI_mob_firesworn;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_gehennas.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_gehennas.cpp
index 43df768573f..d33e9a92ba3 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_gehennas.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_gehennas.cpp
@@ -13,33 +13,42 @@
  * along with 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 TRINITY_DLL_DECL boss_gehennasAI : public ScriptedAI
 {
     boss_gehennasAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowBolt_Timer;
     uint32 RainOfFire_Timer;
     uint32 GehennasCurse_Timer;
+
     void Reset()
     {
         ShadowBolt_Timer = 6000;
         RainOfFire_Timer = 10000;
         GehennasCurse_Timer = 12000;
     }
+
     void EnterCombat(Unit *who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //ShadowBolt_Timer
         if (ShadowBolt_Timer < diff)
         {
@@ -47,19 +56,23 @@ struct TRINITY_DLL_DECL boss_gehennasAI : public ScriptedAI
                 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();
     }
 };
@@ -67,6 +80,7 @@ CreatureAI* GetAI_boss_gehennas(Creature* pCreature)
 {
     return new boss_gehennasAI (pCreature);
 }
+
 void AddSC_boss_gehennas()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_golemagg.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_golemagg.cpp
index 1f9375bb82b..3fedad28827 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_golemagg.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_golemagg.cpp
@@ -13,14 +13,17 @@
  * along with 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: Timers need to be confirmed, Golemagg's Trust need to be checked
 SDCategory: Molten Core
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_molten_core.h"
+
 enum eEnums
 {
     SPELL_MAGMASPLASH       = 13879,
@@ -28,53 +31,65 @@ enum eEnums
     SPELL_EARTHQUAKE        = 19798,
     SPELL_ENRAGE            = 19953,
     SPELL_GOLEMAGG_TRUST    = 20553,
+
     // Core Rager
     EMOTE_LOWHP             = -1409002,
     SPELL_MANGLE            = 19820
 };
+
 struct TRINITY_DLL_DECL boss_golemaggAI : public ScriptedAI
 {
     boss_golemaggAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     uint32 m_uiPyroblastTimer;
     uint32 m_uiEarthquakeTimer;
     uint32 m_uiBuffTimer;
     bool m_bEnraged;
+
     void Reset()
     {
         m_uiPyroblastTimer = 7*IN_MILISECONDS;              // These timers are probably wrong
         m_uiEarthquakeTimer = 3*IN_MILISECONDS;
         m_uiBuffTimer = 2.5*IN_MILISECONDS;
         m_bEnraged = false;
+
         m_creature->CastSpell(m_creature, SPELL_MAGMASPLASH, true);
     }
+
     void JustDied(Unit* pKiller)
     {
         if (m_pInstance)
             m_pInstance->SetData(DATA_GOLEMAGG_DEATH, 0);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         //Pyroblast
         if (m_uiPyroblastTimer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, SPELL_PYROBLAST);
+
             m_uiPyroblastTimer = 7*IN_MILISECONDS;
         }
         else
             m_uiPyroblastTimer -= uiDiff;
+
         // Enrage
         if (!m_bEnraged && m_creature->GetHealth()*100 < m_creature->GetMaxHealth()*10)
         {
             DoCast(m_creature, SPELL_ENRAGE);
             m_bEnraged = true;
         }
+
         // Earthquake
         if (m_bEnraged)
         {
@@ -86,6 +101,7 @@ struct TRINITY_DLL_DECL boss_golemaggAI : public ScriptedAI
             else
                 m_uiEarthquakeTimer -= uiDiff;
         }
+
         /*
         // Golemagg's Trust
         if (m_uiBuffTimer < uiDiff)
@@ -96,21 +112,27 @@ struct TRINITY_DLL_DECL boss_golemaggAI : public ScriptedAI
         else
             m_uiBuffTimer -= uiDiff;
         */
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_core_ragerAI : public ScriptedAI
 {
     mob_core_ragerAI(Creature *c) : ScriptedAI(c)
     {
         m_pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     uint32 m_uiMangleTimer;
+
     void Reset()
     {
         m_uiMangleTimer = 7*IN_MILISECONDS;                 // These times are probably wrong
     }
+
     void DamageTaken(Unit* pDoneBy, uint32& uiDamage)
     {
         if (m_creature->GetHealth()*100 < m_creature->GetMaxHealth()*50)
@@ -130,10 +152,12 @@ struct TRINITY_DLL_DECL mob_core_ragerAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         // Mangle
         if (m_uiMangleTimer < uiDiff)
         {
@@ -142,24 +166,30 @@ struct TRINITY_DLL_DECL mob_core_ragerAI : public ScriptedAI
         }
         else
             m_uiMangleTimer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_golemagg(Creature* pCreature)
 {
     return new boss_golemaggAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_core_rager(Creature* pCreature)
 {
     return new mob_core_ragerAI (pCreature);
 }
+
 void AddSC_boss_golemagg()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "boss_golemagg";
     newscript->GetAI = &GetAI_boss_golemagg;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_core_rager";
     newscript->GetAI = &GetAI_mob_core_rager;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_lucifron.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_lucifron.cpp
index a6ffcb657c0..509faaa6fd4 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_lucifron.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_lucifron.cpp
@@ -13,53 +13,65 @@
  * along with 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 TRINITY_DLL_DECL boss_lucifronAI : public ScriptedAI
 {
     boss_lucifronAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -67,6 +79,7 @@ CreatureAI* GetAI_boss_lucifron(Creature* pCreature)
 {
     return new boss_lucifronAI (pCreature);
 }
+
 void AddSC_boss_lucifron()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_magmadar.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_magmadar.cpp
index c43e9eaada7..ce6348f005e 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_magmadar.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_magmadar.cpp
@@ -13,39 +13,50 @@
  * along with 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 EMOTE_FRENZY                -1409001
+
 #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 TRINITY_DLL_DECL boss_magmadarAI : public ScriptedAI
 {
     boss_magmadarAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //Frenzy_Timer
         if (Frenzy_Timer < diff)
         {
@@ -53,19 +64,23 @@ struct TRINITY_DLL_DECL boss_magmadarAI : public ScriptedAI
             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();
     }
 };
@@ -73,6 +88,7 @@ CreatureAI* GetAI_boss_magmadar(Creature* pCreature)
 {
     return new boss_magmadarAI (pCreature);
 }
+
 void AddSC_boss_magmadar()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_majordomo_executus.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_majordomo_executus.cpp
index 6d9c06af2b3..905edf27ea8 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_majordomo_executus.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_majordomo_executus.cpp
@@ -13,86 +13,108 @@
  * along with 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 SAY_AGGRO           -1409003
 #define SAY_SPAWN           -1409004
 #define SAY_SLAY            -1409005
 #define SAY_SPECIAL         -1409006
 #define SAY_DEFEAT          -1409007
+
 #define SAY_SUMMON_MAJ      -1409008
 #define SAY_ARRIVAL1_RAG    -1409009
 #define SAY_ARRIVAL2_MAJ    -1409010
 #define SAY_ARRIVAL3_RAG    -1409011
 #define SAY_ARRIVAL5_RAG    -1409012
+
 #define SPAWN_RAG_X         838.51
 #define SPAWN_RAG_Y         -829.84
 #define SPAWN_RAG_Z         -232.00
 #define SPAWN_RAG_O         1.70
+
 #define SPELL_MAGIC_REFLECTION      20619
 #define SPELL_DAMAGE_REFLECTION     21075
+
 #define SPELL_BLASTWAVE             20229
 #define SPELL_AEGIS                 20620                   //This is self casted whenever we are below 50%
 #define SPELL_TELEPORT              20618
 #define SPELL_SUMMON_RAGNAROS       19774
+
 #define ENTRY_FLAMEWALKER_HEALER    11663
 #define ENTRY_FLAMEWALKER_ELITE     11664
+
 struct TRINITY_DLL_DECL boss_majordomoAI : public ScriptedAI
 {
     boss_majordomoAI(Creature *c) : ScriptedAI(c) {}
+
     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;
+
         DoScriptText(SAY_SLAY, m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -100,6 +122,7 @@ CreatureAI* GetAI_boss_majordomo(Creature* pCreature)
 {
     return new boss_majordomoAI (pCreature);
 }
+
 void AddSC_boss_majordomo()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_ragnaros.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_ragnaros.cpp
index 3e97982f047..9376250e3e8 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_ragnaros.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_ragnaros.cpp
@@ -13,67 +13,83 @@
  * along with 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 SAY_REINFORCEMENTS1         -1409013
 #define SAY_REINFORCEMENTS2         -1409014
 #define SAY_HAND                    -1409015
 #define SAY_WRATH                   -1409016
 #define SAY_KILL                    -1409017
 #define SAY_MAGMABURST              -1409018
+
 #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 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 TRINITY_DLL_DECL boss_ragnarosAI : public ScriptedAI
 {
     boss_ragnarosAI(Creature *c) : ScriptedAI(c)
     {
         SetCombatMovement(false);
     }
+
     uint32 WrathOfRagnaros_Timer;
     uint32 HandOfRagnaros_Timer;
     uint32 LavaBurst_Timer;
@@ -87,6 +103,7 @@ struct TRINITY_DLL_DECL boss_ragnarosAI : public ScriptedAI
     bool HasSubmergedOnce;
     bool WasBanished;
     bool HasAura;
+
     void Reset()
     {
         WrathOfRagnaros_Timer = 30000;
@@ -100,18 +117,23 @@ struct TRINITY_DLL_DECL boss_ragnarosAI : public ScriptedAI
         HasYelledMagmaBurst = false;
         HasSubmergedOnce = false;
         WasBanished = false;
+
         m_creature->CastSpell(m_creature,SPELL_MELTWEAPON,true);
         HasAura = true;
     }
+
     void KilledUnit(Unit* victim)
     {
         if (rand()%5)
             return;
+
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (WasBanished && Attack_Timer < diff)
@@ -127,64 +149,78 @@ struct TRINITY_DLL_DECL boss_ragnarosAI : public ScriptedAI
             //Do nothing while banished
             return;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //WrathOfRagnaros_Timer
         if (WrathOfRagnaros_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_WRATHOFRAGNAROS);
+
             if (rand()%2 == 0)
             {
                 DoScriptText(SAY_WRATH, m_creature);
             }
+
             WrathOfRagnaros_Timer = 30000;
         }else WrathOfRagnaros_Timer -= diff;
+
         //HandOfRagnaros_Timer
         if (HandOfRagnaros_Timer < diff)
         {
             DoCast(m_creature,SPELL_HANDOFRAGNAROS);
+
             if (rand()%2==0)
             {
                 DoScriptText(SAY_HAND, m_creature);
             }
+
             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);
+
             if (!HasSubmergedOnce)
             {
                 DoScriptText(SAY_REINFORCEMENTS1, m_creature);
+
                 // summon 10 elementals
-                for (uint8 i = 0; i < 9; ++i)
+                for(uint8 i = 0; i < 9; ++i)
                 {
                     if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
                     {
@@ -192,15 +228,18 @@ struct TRINITY_DLL_DECL boss_ragnarosAI : public ScriptedAI
                             pSummoned->AI()->AttackStart(pTarget);
                     }
                 }
+
                 HasSubmergedOnce = true;
                 WasBanished = true;
                 DoCast(m_creature,SPELL_RAGSUBMERGE);
                 Attack_Timer = 90000;
+
             }
             else
             {
                 DoScriptText(SAY_REINFORCEMENTS2, m_creature);
-                for (uint8 i = 0; i < 9; ++i)
+
+                for(uint8 i = 0; i < 9; ++i)
                 {
                     if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
                     {
@@ -208,12 +247,15 @@ struct TRINITY_DLL_DECL boss_ragnarosAI : public ScriptedAI
                         pSummoned->AI()->AttackStart(pTarget);
                     }
                 }
+
                 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->IsWithinMeleeRange(m_creature->getVictim()))
         {
@@ -230,12 +272,14 @@ struct TRINITY_DLL_DECL boss_ragnarosAI : public ScriptedAI
             if (MagmaBurst_Timer < diff)
             {
                 DoCast(m_creature->getVictim(),SPELL_MAGMABURST);
+
                 if (!HasYelledMagmaBurst)
                 {
                     //Say our dialog
                     DoScriptText(SAY_MAGMABURST, m_creature);
                     HasYelledMagmaBurst = true;
                 }
+
                 MagmaBurst_Timer = 2500;
             }else MagmaBurst_Timer -= diff;
         }
@@ -245,6 +289,7 @@ CreatureAI* GetAI_boss_ragnaros(Creature* pCreature)
 {
     return new boss_ragnarosAI (pCreature);
 }
+
 void AddSC_boss_ragnaros()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_shazzrah.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_shazzrah.cpp
index efb042d6711..772a7452214 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_shazzrah.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_shazzrah.cpp
@@ -13,25 +13,31 @@
  * along with 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 TRINITY_DLL_DECL boss_shazzrahAI : public ScriptedAI
 {
     boss_shazzrahAI(Creature *c) : ScriptedAI(c) {}
+
     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
@@ -40,39 +46,47 @@ struct TRINITY_DLL_DECL boss_shazzrahAI : public ScriptedAI
         Countspell_Timer = 15000;
         Blink_Timer = 30000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
@@ -80,14 +94,17 @@ struct TRINITY_DLL_DECL boss_shazzrahAI : public ScriptedAI
             // Blink is not working cause of LoS System we need to do this hardcoded.
             Unit* target = NULL;
             target = SelectUnit(SELECT_TARGET_RANDOM,0);
+
             if (target)
             {
             DoTeleportTo(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
             DoCast(target,SPELL_ARCANEEXPLOSION);
             DoResetThreat();
             }
+
             Blink_Timer = 45000;
         }else Blink_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -95,6 +112,7 @@ CreatureAI* GetAI_boss_shazzrah(Creature* pCreature)
 {
     return new boss_shazzrahAI (pCreature);
 }
+
 void AddSC_boss_shazzrah()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_sulfuron_harbinger.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_sulfuron_harbinger.cpp
index a0aaa76c0be..a01fb32c46c 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_sulfuron_harbinger.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/boss_sulfuron_harbinger.cpp
@@ -13,31 +13,38 @@
  * along with 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 TRINITY_DLL_DECL boss_sulfuronAI : public ScriptedAI
 {
     boss_sulfuronAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Darkstrike_Timer;
     uint32 DemoralizingShout_Timer;
     uint32 Inspire_Timer;
     uint32 Knockdown_Timer;
     uint32 Flamespear_Timer;
+
     void Reset()
     {
         Darkstrike_Timer=10000;                             //These times are probably wrong
@@ -46,19 +53,23 @@ struct TRINITY_DLL_DECL boss_sulfuronAI : public ScriptedAI
         Knockdown_Timer = 6000;
         Flamespear_Timer = 2000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
@@ -70,96 +81,122 @@ struct TRINITY_DLL_DECL boss_sulfuronAI : public ScriptedAI
                 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 TRINITY_DLL_DECL mob_flamewaker_priestAI : public ScriptedAI
 {
     mob_flamewaker_priestAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Heal_Timer;
     uint32 ShadowWordPain_Timer;
     uint32 Immolate_Timer;
+
     void Reset()
     {
         Heal_Timer = 15000+rand()%15000;
         ShadowWordPain_Timer = 2000;
         Immolate_Timer = 8000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new boss_sulfuronAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_flamewaker_priest(Creature* pCreature)
 {
     return new mob_flamewaker_priestAI (pCreature);
 }
+
 void AddSC_boss_sulfuron()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_sulfuron";
     newscript->GetAI = &GetAI_boss_sulfuron;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_flamewaker_priest";
     newscript->GetAI = &GetAI_mob_flamewaker_priest;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/def_molten_core.h b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/def_molten_core.h
index 40bbcb1226e..5874d8b9408 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/def_molten_core.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/def_molten_core.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/instance_molten_core.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/instance_molten_core.cpp
index e5c0a0351e2..6e7df410a98 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/instance_molten_core.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/instance_molten_core.cpp
@@ -13,15 +13,19 @@
  * along 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 MAX_ENCOUNTER      9
+
 #define ID_LUCIFRON     12118
 #define ID_MAGMADAR     11982
 #define ID_GEHENNAS     12259
@@ -33,17 +37,23 @@ EndScriptData */
 #define ID_DOMO         12018
 #define ID_RAGNAROS     11502
 #define ID_FLAMEWAKERPRIEST     11662
+
 struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance
 {
     instance_molten_core(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 Lucifron, Magmadar, Gehennas, Garr, Geddon, Shazzrah, Sulfuron, Golemagg, Domo, Ragnaros, FlamewakerPriest;
     uint64 RuneKoro, RuneZeth, RuneMazj, RuneTheri, RuneBlaz, RuneKress, RuneMohn, m_uiFirelordCacheGUID;;
+
     //If all Bosses are dead.
     bool IsBossDied[9];
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         Lucifron = 0;
         Magmadar = 0;
         Gehennas = 0;
@@ -55,6 +65,7 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance
         Domo = 0;
         Ragnaros = 0;
         FlamewakerPriest = 0;
+
         RuneKoro = 0;
         RuneZeth = 0;
         RuneMazj = 0;
@@ -62,7 +73,9 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance
         RuneBlaz = 0;
         RuneKress = 0;
         RuneMohn = 0;
+
         m_uiFirelordCacheGUID = 0;
+
         IsBossDied[0] = false;
         IsBossDied[1] = false;
         IsBossDied[2] = false;
@@ -70,14 +83,17 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance
         IsBossDied[4] = false;
         IsBossDied[5] = false;
         IsBossDied[6] = false;
+
         IsBossDied[7] = false;
         IsBossDied[8] = false;
     }
+
     bool IsEncounterInProgress() const
     {
         return false;
     };
 
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -109,6 +125,7 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance
         }
     }
 
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch (pCreature->GetEntry())
@@ -116,38 +133,49 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance
             case ID_LUCIFRON:
                 Lucifron = pCreature->GetGUID();
                 break;
+
             case ID_MAGMADAR:
                 Magmadar = pCreature->GetGUID();
                 break;
+
             case ID_GEHENNAS:
                 Gehennas = pCreature->GetGUID();
                 break;
+
             case ID_GARR:
                 Garr = pCreature->GetGUID();
                 break;
+
             case ID_GEDDON:
                 Geddon = pCreature->GetGUID();
                 break;
+
             case ID_SHAZZRAH:
                 Shazzrah = pCreature->GetGUID();
                 break;
+
             case ID_SULFURON:
                 Sulfuron = pCreature->GetGUID();
                 break;
+
             case ID_GOLEMAGG:
                 Golemagg = pCreature->GetGUID();
                 break;
+
             case ID_DOMO:
                 Domo = pCreature->GetGUID();
                 break;
+
             case ID_RAGNAROS:
                 Ragnaros = pCreature->GetGUID();
                 break;
+
             case ID_FLAMEWAKERPRIEST:
                 FlamewakerPriest = pCreature->GetGUID();
                 break;
         }
     }
+
     uint64 GetData64 (uint32 identifier)
     {
         switch(identifier)
@@ -156,11 +184,14 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance
                 return Sulfuron;
             case DATA_GOLEMAGG:
                 return Golemagg;
+
             case DATA_FLAMEWAKERPRIEST:
                 return FlamewakerPriest;
         }
+
         return 0;
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -169,51 +200,63 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance
                 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* pMap)
 {
     return new instance_molten_core (pMap);
 }
+
 void AddSC_instance_molten_core()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/molten_core.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/molten_core.cpp
index a6be8e4f346..833f67f5fc7 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/molten_core.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/molten_core.cpp
@@ -13,19 +13,24 @@
  * along 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 "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
@@ -33,32 +38,41 @@ EndContentData */
 #define SPELL_WITHERING_HEAT        19367
 #define SPELL_ANCIENT_DESPAIR       19369
 #define SPELL_ANCIENT_HYSTERIA      19372
+
 CreatureAI* GetAI_mob_ancient_core_hound(Creature* pCreature)
 {
     SimpleAI *ai = new SimpleAI(pCreature);
+
     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 = RAND(SPELL_GROUND_STOMP,SPELL_ANCIENT_DREAD,SPELL_CAUTERIZING_FLAMES,
                              SPELL_WITHERING_HEAT,SPELL_ANCIENT_DESPAIR,SPELL_ANCIENT_HYSTERIA);
+
     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;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp
index 4fd9d5ef933..449ed462a44 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp
@@ -15,39 +15,48 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "Vehicle.h"
 #include "ObjectMgr.h"
 #include "escort_ai.h"
+
 /*######
 ##Quest 12848
 ######*/
+
 #define GCD_CAST    1
+
 enum eDeathKnightSpells
 {
     SPELL_SOUL_PRISON_CHAIN_SELF    = 54612,
     SPELL_SOUL_PRISON_CHAIN         = 54613,
     SPELL_DK_INITIATE_VISUAL        = 51519,
+
     SPELL_ICY_TOUCH                 = 52372,
     SPELL_PLAGUE_STRIKE             = 52373,
     SPELL_BLOOD_STRIKE              = 52374,
     SPELL_DEATH_COIL                = 52375
 };
+
 #define EVENT_ICY_TOUCH                 1
 #define EVENT_PLAGUE_STRIKE             2
 #define EVENT_BLOOD_STRIKE              3
 #define EVENT_DEATH_COIL                4
+
 //used by 29519,29520,29565,29566,29567 but signed for 29519
 int32 say_event_start[8] =
 {
     -1609000,-1609001,-1609002,-1609003,
     -1609004,-1609005,-1609006,-1609007
 };
+
 int32 say_event_attack[9] =
 {
     -1609008,-1609009,-1609010,-1609011,-1609012,
     -1609013,-1609014,-1609015,-1609016
 };
+
 uint32 acherus_soul_prison[12] =
 {
     191577,
@@ -63,6 +72,7 @@ uint32 acherus_soul_prison[12] =
     191589,
     191590
 };
+
 uint32 acherus_unworthy_initiate[5] =
 {
     29519,
@@ -71,6 +81,7 @@ uint32 acherus_unworthy_initiate[5] =
     29566,
     29567
 };
+
 enum UnworthyInitiatePhase
 {
     PHASE_CHAINED,
@@ -79,6 +90,7 @@ enum UnworthyInitiatePhase
     PHASE_TO_ATTACK,
     PHASE_ATTACKING,
 };
+
 struct TRINITY_DLL_DECL npc_unworthy_initiateAI : public ScriptedAI
 {
     npc_unworthy_initiateAI(Creature *c) : ScriptedAI(c)
@@ -89,12 +101,15 @@ struct TRINITY_DLL_DECL npc_unworthy_initiateAI : public ScriptedAI
                 if (info->equipmentId)
                     const_cast(me->GetCreatureInfo())->equipmentId = info->equipmentId;
     }
+
     uint64 playerGUID;
     UnworthyInitiatePhase phase;
     uint32 wait_timer;
     float anchorX, anchorY;
     uint64 anchorGUID;
+
     EventMap events;
+
     void Reset()
     {
         anchorGUID = 0;
@@ -105,6 +120,7 @@ struct TRINITY_DLL_DECL npc_unworthy_initiateAI : public ScriptedAI
         me->SetUInt32Value(UNIT_FIELD_BYTES_1, 8);
         me->LoadEquipment(0, true);
     }
+
     void EnterCombat(Unit *who)
     {
         events.ScheduleEvent(EVENT_ICY_TOUCH, 1000, GCD_CAST);
@@ -112,48 +128,63 @@ struct TRINITY_DLL_DECL npc_unworthy_initiateAI : public ScriptedAI
         events.ScheduleEvent(EVENT_BLOOD_STRIKE, 2000, GCD_CAST);
         events.ScheduleEvent(EVENT_DEATH_COIL, 5000, GCD_CAST);
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
             return;
+
         if (id == 1)
         {
             wait_timer = 5000;
             me->CastSpell(me, SPELL_DK_INITIATE_VISUAL, true);
+
             if(Player* starter = Unit::GetPlayer(playerGUID))
                 DoScriptText(say_event_attack[rand()%9], me, starter);
+
             phase = PHASE_TO_ATTACK;
         }
     }
+
     void EventStart(Creature* anchor, Player* target)
     {
         wait_timer = 5000;
         phase = PHASE_TO_EQUIP;
+
         me->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
         me->RemoveAurasDueToSpell(SPELL_SOUL_PRISON_CHAIN_SELF);
         me->RemoveAurasDueToSpell(SPELL_SOUL_PRISON_CHAIN);
+
         float z;
         anchor->GetContactPoint(me, anchorX, anchorY, z, 1.0f);
+
         playerGUID = target->GetGUID();
         DoScriptText(say_event_start[rand()%8], me, target);
     }
+
     void UpdateAI(const uint32 diff);
 };
+
 CreatureAI* GetAI_npc_unworthy_initiate(Creature* pCreature)
 {
     return new npc_unworthy_initiateAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_unworthy_initiate_anchorAI : public PassiveAI
 {
     npc_unworthy_initiate_anchorAI(Creature *c) : PassiveAI(c), prisonerGUID(0) {}
+
     uint64 prisonerGUID;
+
     void SetGUID(const uint64 &guid, int32 id)
     {
         if (!prisonerGUID)
             prisonerGUID = guid;
     }
+
     uint64 GetGUID(int32 id) { return prisonerGUID; }
 };
+
 void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
 {
     switch(phase)
@@ -169,9 +200,11 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
             }
             else
                 error_log("npc_unworthy_initiateAI: unable to find anchor!");
+
             float dist = 99.0f;
             GameObject *prison = NULL;
-            for (uint8 i = 0; i < 12; ++i)
+
+            for(uint8 i = 0; i < 12; ++i)
             {
                 if (GameObject* temp_prison = me->FindNearestGameObject(acherus_soul_prison[i],30))
                 {
@@ -182,6 +215,7 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
                     }
                 }
             }
+
             if (prison)
                 prison->ResetDoorOrButton();
             else
@@ -212,6 +246,7 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
                 me->setFaction(14);
                 me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
                 phase = PHASE_ATTACKING;
+
                 if (Player* target = Unit::GetPlayer(playerGUID))
                     me->AI()->AttackStart(target);
                 wait_timer = 0;
@@ -221,7 +256,9 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
     case PHASE_ATTACKING:
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -248,25 +285,32 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
                 break;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 }
+
 CreatureAI* GetAI_npc_unworthy_initiate_anchor(Creature* pCreature)
 {
     return new npc_unworthy_initiate_anchorAI(pCreature);
 }
+
 bool GOHello_go_acherus_soul_prison(Player* pPlayer, GameObject* pGo)
 {
     if (Creature *anchor = pGo->FindNearestCreature(29521, 15))
         if (uint64 prisonerGUID = anchor->AI()->GetGUID())
             if (Creature* prisoner = Creature::GetCreature(*pPlayer, prisonerGUID))
                 CAST_AI(npc_unworthy_initiateAI, prisoner->AI())->EventStart(anchor, pPlayer);
+
     return false;
 }
+
 /*######
 ## npc_death_knight_initiate
 ######*/
+
 #define GOSSIP_ACCEPT_DUEL      "I challenge you, death knight!"
+
 enum eDuelEnums
 {
     SAY_DUEL_A                  = -1609080,
@@ -278,37 +322,46 @@ enum eDuelEnums
     SAY_DUEL_G                  = -1609086,
     SAY_DUEL_H                  = -1609087,
     SAY_DUEL_I                  = -1609088,
+
     SPELL_DUEL                  = 52996,
     //SPELL_DUEL_TRIGGERED        = 52990,
     SPELL_DUEL_VICTORY          = 52994,
     SPELL_DUEL_FLAG             = 52991,
+
     QUEST_DEATH_CHALLENGE       = 12733,
     FACTION_HOSTILE             = 2068
 };
+
 int32 m_auiRandomSay[] =
 {
     SAY_DUEL_A, SAY_DUEL_B, SAY_DUEL_C, SAY_DUEL_D, SAY_DUEL_E, SAY_DUEL_F, SAY_DUEL_G, SAY_DUEL_H, SAY_DUEL_I
 };
+
 struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public CombatAI
 {
     npc_death_knight_initiateAI(Creature* pCreature) : CombatAI(pCreature)
     {
         m_bIsDuelInProgress = false;
     }
+
     bool lose;
     uint64 m_uiDuelerGUID;
     uint32 m_uiDuelTimer;
     bool m_bIsDuelInProgress;
+
     void Reset()
     {
         lose = false;
         me->RestoreFaction();
         CombatAI::Reset();
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_15);
+
         m_uiDuelerGUID = 0;
         m_uiDuelTimer = 5000;
         m_bIsDuelInProgress = false;
     }
+
     void SpellHit(Unit* pCaster, const SpellEntry* pSpell)
     {
         if (!m_bIsDuelInProgress && pSpell->Id == SPELL_DUEL)
@@ -317,6 +370,7 @@ struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public CombatAI
             m_bIsDuelInProgress = true;
         }
     }
+
    void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
     {
         if (m_bIsDuelInProgress && pDoneBy->IsControlledByPlayer())
@@ -326,6 +380,7 @@ struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public CombatAI
             else if (uiDamage >= m_creature->GetHealth())
             {
                 uiDamage = 0;
+
                 if (!lose)
                 {
                     pDoneBy->RemoveGameObject(SPELL_DUEL_FLAG, true);
@@ -338,6 +393,7 @@ struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public CombatAI
             }
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
@@ -347,6 +403,7 @@ struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public CombatAI
                 if (m_uiDuelTimer < uiDiff)
                 {
                     m_creature->setFaction(FACTION_HOSTILE);
+
                     if (Unit* pUnit = Unit::GetUnit(*m_creature, m_uiDuelerGUID))
                         AttackStart(pUnit);
                 }
@@ -355,6 +412,7 @@ struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public CombatAI
             }
             return;
         }
+
         if (m_bIsDuelInProgress)
         {
             if (lose)
@@ -372,59 +430,76 @@ struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public CombatAI
                 return;
             }
         }
+
         // TODO: spells
+
         CombatAI::UpdateAI(uiDiff);
     }
 };
+
 CreatureAI* GetAI_npc_death_knight_initiate(Creature* pCreature)
 {
     return new npc_death_knight_initiateAI(pCreature);
 }
+
 bool GossipHello_npc_death_knight_initiate(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_DEATH_CHALLENGE) == QUEST_STATUS_INCOMPLETE && pCreature->GetHealth() == pCreature->GetMaxHealth())
     {
         if (pPlayer->GetHealth() * 10 < pPlayer->GetMaxHealth())
             return true;
+
         if (pPlayer->isInCombat() || pCreature->isInCombat())
             return true;
+
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ACCEPT_DUEL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(),pCreature->GetGUID());
     }
     return true;
 }
+
 bool GossipSelect_npc_death_knight_initiate(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
     {
         pPlayer->CLOSE_GOSSIP_MENU();
+
         if (pPlayer->isInCombat() || pCreature->isInCombat())
             return true;
+
         if (npc_death_knight_initiateAI* pInitiateAI = CAST_AI(npc_death_knight_initiateAI, pCreature->AI()))
         {
             if (pInitiateAI->m_bIsDuelInProgress)
                 return true;
         }
+
         pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_15);
+
         int32 uiSayId = rand()% (sizeof(m_auiRandomSay)/sizeof(int32));
         DoScriptText(m_auiRandomSay[uiSayId], pCreature, pPlayer);
+
         pPlayer->CastSpell(pCreature, SPELL_DUEL, false);
         pPlayer->CastSpell(pPlayer, SPELL_DUEL_FLAG, true);
     }
     return true;
 }
+
 /*######
 ## npc_dark_rider_of_acherus
 ######*/
+
 #define DESPAWN_HORSE 52267
 #define SAY_DARK_RIDER      "The realm of shadows awaits..."
+
 struct TRINITY_DLL_DECL npc_dark_rider_of_acherusAI : public ScriptedAI
 {
     npc_dark_rider_of_acherusAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 PhaseTimer;
     uint32 Phase;
     bool Intro;
     Unit *Target;
+
     void Reset()
     {
         PhaseTimer = 4000;
@@ -432,10 +507,12 @@ struct TRINITY_DLL_DECL npc_dark_rider_of_acherusAI : public ScriptedAI
         Intro = false;
         Target = NULL;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Intro)
             return;
+
         if (PhaseTimer < diff)
         {
             switch(Phase)
@@ -462,11 +539,14 @@ struct TRINITY_DLL_DECL npc_dark_rider_of_acherusAI : public ScriptedAI
                     break;
             }
         }else PhaseTimer -= diff;
+
     }
+
     void InitDespawnHorse(Unit *who)
     {
         if (!who)
             return;
+
         Target = who;
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
         m_creature->SetSpeed(MOVE_RUN, 0.4f);
@@ -474,14 +554,18 @@ struct TRINITY_DLL_DECL npc_dark_rider_of_acherusAI : public ScriptedAI
         m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Target->GetGUID());
         Intro = true;
     }
+
 };
+
 CreatureAI* GetAI_npc_dark_rider_of_acherus(Creature* pCreature)
 {
     return new npc_dark_rider_of_acherusAI(pCreature);
 }
+
 /*######
 ## npc_salanar_the_horseman
 ######*/
+
 enum eSalanar
 {
     REALM_OF_SHADOWS            = 52693,
@@ -490,9 +574,11 @@ enum eSalanar
     CALL_DARK_RIDER             = 52266,
     SPELL_EFFECT_OVERTAKE       = 52349
 };
+
 struct TRINITY_DLL_DECL npc_salanar_the_horsemanAI : public ScriptedAI
 {
     npc_salanar_the_horsemanAI(Creature *c) : ScriptedAI(c) {}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == DELIVER_STOLEN_HORSE)
@@ -511,9 +597,11 @@ struct TRINITY_DLL_DECL npc_salanar_the_horsemanAI : public ScriptedAI
             }
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         ScriptedAI::MoveInLineOfSight(who);
+
         if (who->GetTypeId() == TYPEID_UNIT && who->IsVehicle() && me->IsWithinDistInMap(who, 5.0f))
         {
             if (Unit *charmer = who->GetCharmer())
@@ -528,6 +616,7 @@ struct TRINITY_DLL_DECL npc_salanar_the_horsemanAI : public ScriptedAI
                         CAST_CRE(who)->ForcedDespawn();
                         //CAST_CRE(who)->Respawn(true);
                     }
+
                     if (CAST_PLR(charmer)->HasAura(REALM_OF_SHADOWS))
                         charmer->RemoveAurasDueToSpell(REALM_OF_SHADOWS);
                 }
@@ -535,20 +624,25 @@ struct TRINITY_DLL_DECL npc_salanar_the_horsemanAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_salanar_the_horseman(Creature* pCreature)
 {
     return new npc_salanar_the_horsemanAI(pCreature);
 }
+
 /*######
 ## npc_ros_dark_rider
 ######*/
+
 struct TRINITY_DLL_DECL npc_ros_dark_riderAI : public ScriptedAI
 {
     npc_ros_dark_riderAI(Creature *c) : ScriptedAI(c) {}
+
     void EnterCombat(Unit *who)
     {
         me->ExitVehicle();
     }
+
     void Reset()
     {
         Creature* deathcharger = me->FindNearestCreature(28782, 30);
@@ -559,6 +653,7 @@ struct TRINITY_DLL_DECL npc_ros_dark_riderAI : public ScriptedAI
         if (!me->GetVehicle() && deathcharger->IsVehicle() && deathcharger->GetVehicleKit()->HasEmptySeat(0))
             me->EnterVehicle(deathcharger);
     }
+
     void JustDied(Unit *killer)
     {
         Creature* deathcharger = me->FindNearestCreature(28782, 30);
@@ -571,10 +666,12 @@ struct TRINITY_DLL_DECL npc_ros_dark_riderAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_ros_dark_rider(Creature* pCreature)
 {
     return new npc_ros_dark_riderAI(pCreature);
 }
+
 // correct way: 52312 52314 52555 ...
 enum SG
 {
@@ -584,9 +681,11 @@ enum SG
 struct TRINITY_DLL_DECL npc_dkc1_gothikAI : public ScriptedAI
 {
     npc_dkc1_gothikAI(Creature *c) : ScriptedAI(c) {}
+
     void MoveInLineOfSight(Unit *who)
     {
         ScriptedAI::MoveInLineOfSight(who);
+
         if (who->GetEntry() == GHOULS && me->IsWithinDistInMap(who, 10.0f))
         {
             if (Unit *owner = who->GetOwner())
@@ -602,6 +701,7 @@ struct TRINITY_DLL_DECL npc_dkc1_gothikAI : public ScriptedAI
                     //      stand next to Gothik and be commanded into the pit
                     //      and dig into the ground.
                     CAST_CRE(who)->ForcedDespawn();
+
                     if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_COMPLETE)
                         owner->RemoveAllMinionsByEntry(GHOULS);
                 }
@@ -609,10 +709,12 @@ struct TRINITY_DLL_DECL npc_dkc1_gothikAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_dkc1_gothik(Creature* pCreature)
 {
     return new npc_dkc1_gothikAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_scarlet_ghoulAI : public ScriptedAI
 {
     npc_scarlet_ghoulAI(Creature *c) : ScriptedAI(c)
@@ -623,13 +725,15 @@ struct TRINITY_DLL_DECL npc_scarlet_ghoulAI : public ScriptedAI
         //m_creature->MonsterSay("Mommy?",LANG_UNIVERSAL,0);
         m_creature->SetReactState(REACT_DEFENSIVE);
     }
+
     void FindMinions(Unit *owner)
     {
         std::list MinionList;
         owner->GetAllMinionsByEntry(MinionList,GHOULS);
+
         if (!MinionList.empty())
         {
-            for (std::list::iterator itr = MinionList.begin(); itr != MinionList.end(); ++itr)
+            for(std::list::iterator itr = MinionList.begin(); itr != MinionList.end(); ++itr)
             {
                 if (CAST_CRE(*itr)->GetOwner()->GetGUID() == m_creature->GetOwner()->GetGUID())
                 {
@@ -641,6 +745,7 @@ struct TRINITY_DLL_DECL npc_scarlet_ghoulAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->isInCombat())
@@ -660,8 +765,10 @@ struct TRINITY_DLL_DECL npc_scarlet_ghoulAI : public ScriptedAI
                 }
             }
         }
+
         if (!UpdateVictim())
             return;
+
         //ScriptedAI::UpdateAI(diff);
         //Check if we have a current target
         if (m_creature->getVictim()->GetEntry() == GHOSTS)
@@ -678,15 +785,19 @@ struct TRINITY_DLL_DECL npc_scarlet_ghoulAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_scarlet_ghoul(Creature* pCreature)
 {
     return new npc_scarlet_ghoulAI(pCreature);
 }
+
 /*####
 ## npc_scarlet_miner_cart
 ####*/
+
 #define SPELL_CART_CHECK     54173
 #define SPELL_CART_DRAG      52465
+
 struct TRINITY_DLL_DECL npc_scarlet_miner_cartAI : public PassiveAI
 {
     npc_scarlet_miner_cartAI(Creature *c) : PassiveAI(c), minerGUID(0)
@@ -694,11 +805,14 @@ struct TRINITY_DLL_DECL npc_scarlet_miner_cartAI : public PassiveAI
         me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
         me->SetDisplayId(me->GetCreatureInfo()->Modelid1); // H0 is horse
     }
+
     uint64 minerGUID;
+
     void SetGUID(const uint64 &guid, int32 id)
     {
         minerGUID = guid;
     }
+
     void DoAction(const int32 param)
     {
         if(Creature *miner = Unit::GetCreature(*me, minerGUID))
@@ -710,6 +824,7 @@ struct TRINITY_DLL_DECL npc_scarlet_miner_cartAI : public PassiveAI
             me->GetMotionMaster()->MoveFollow(miner, 1.0f, 0);
         }
     }
+
     void PassengerBoarded(Unit *who, int8 seatId, bool apply)
     {
         if(!apply)
@@ -717,30 +832,37 @@ struct TRINITY_DLL_DECL npc_scarlet_miner_cartAI : public PassiveAI
                 miner->DisappearAndDie();
     }
 };
+
 CreatureAI* GetAI_npc_scarlet_miner_cart(Creature *_Creature)
 {
     return new npc_scarlet_miner_cartAI(_Creature);
 }
+
 /*####
 ## npc_scarlet_miner
 ####*/
+
 #define SAY_SCARLET_MINER1  "Where'd this come from? I better get this down to the ships before the foreman sees it!"
 #define SAY_SCARLET_MINER2  "Now I can have a rest!"
+
 struct TRINITY_DLL_DECL npc_scarlet_minerAI : public npc_escortAI
 {
     npc_scarlet_minerAI(Creature *c) : npc_escortAI(c)
     {
         me->SetReactState(REACT_PASSIVE);
     }
+
     uint32 IntroTimer;
     uint32 IntroPhase;
     uint64 carGUID;
+
     void Reset()
     {
         carGUID = 0;
         IntroTimer = 0;
         IntroPhase = 0;
     }
+
     void InitWaypoint()
     {
         AddWaypoint(1, 2389.03,     -5902.74,     109.014, 5000);
@@ -755,6 +877,7 @@ struct TRINITY_DLL_DECL npc_scarlet_minerAI : public npc_escortAI
         AddWaypoint(10, 2217.265625, -6028.959473, 7.675705 );
         AddWaypoint(11, 2202.595947, -6061.325684, 5.882018 );
         AddWaypoint(12, 2188.974609, -6080.866699, 3.370027 );
+
         if(rand()%2)
         {
             AddWaypoint(13, 2176.483887, -6110.407227, 1.855181 );
@@ -772,6 +895,7 @@ struct TRINITY_DLL_DECL npc_scarlet_minerAI : public npc_escortAI
             AddWaypoint(17, 2271.739014, -6195.401855, 13.3542, 10000);
         }
     }
+
     void InitCartQuest(Player *who)
     {
         carGUID = who->GetVehicleBase()->GetGUID();
@@ -779,6 +903,7 @@ struct TRINITY_DLL_DECL npc_scarlet_minerAI : public npc_escortAI
         Start(false, false, who->GetGUID());
         SetDespawnAtFar(false);
     }
+
     void WaypointReached(uint32 i)
     {
         switch (i)
@@ -811,6 +936,7 @@ struct TRINITY_DLL_DECL npc_scarlet_minerAI : public npc_escortAI
                 break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IntroPhase)
@@ -835,14 +961,18 @@ struct TRINITY_DLL_DECL npc_scarlet_minerAI : public npc_escortAI
         npc_escortAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_npc_scarlet_miner(Creature *_Creature)
 {
     return new npc_scarlet_minerAI(_Creature);
 }
+
 /*######
 ## go_inconspicuous_mine_car
 ######*/
+
 #define SPELL_CART_SUMM   52463
+
 bool GOHello_go_inconspicuous_mine_car(Player* pPlayer, GameObject* pGO)
 {
     if (pPlayer->GetQuestStatus(12701) == QUEST_STATUS_INCOMPLETE)
@@ -863,23 +993,29 @@ bool GOHello_go_inconspicuous_mine_car(Player* pPlayer, GameObject* pGO)
     }
     return true;
 }
+
 // npc 28912 quest 17217 boss 29001 mob 29007 go 191092
+
 void AddSC_the_scarlet_enclave_c1()
 {
     Script *newscript;
+
     // 12848 The Endless Hunger
     newscript = new Script;
     newscript->Name = "npc_unworthy_initiate";
     newscript->GetAI = &GetAI_npc_unworthy_initiate;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_unworthy_initiate_anchor";
     newscript->GetAI = &GetAI_npc_unworthy_initiate_anchor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_acherus_soul_prison";
     newscript->pGOHello = &GOHello_go_acherus_soul_prison;
     newscript->RegisterSelf();
+
     // Death's Challenge
     newscript = new Script;
     newscript->Name = "npc_death_knight_initiate";
@@ -887,43 +1023,52 @@ void AddSC_the_scarlet_enclave_c1()
     newscript->pGossipHello = &GossipHello_npc_death_knight_initiate;
     newscript->pGossipSelect = &GossipSelect_npc_death_knight_initiate;
     newscript->RegisterSelf();
+
     // 12680 Grand Theft Palomino
     newscript = new Script;
     newscript->Name = "npc_salanar_the_horseman";
     newscript->GetAI = &GetAI_npc_salanar_the_horseman;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_dark_rider_of_acherus";
     newscript->GetAI = &GetAI_npc_dark_rider_of_acherus;
     newscript->RegisterSelf();
+
     // 12687 Into the Realm of Shadows
     newscript = new Script;
     newscript->Name = "npc_ros_dark_rider";
     newscript->GetAI = &GetAI_npc_ros_dark_rider;
     newscript->RegisterSelf();
+
     // 12698 The Gift That Keeps On Giving
     newscript = new Script;
     newscript->Name = "npc_dkc1_gothik";
     newscript->GetAI = &GetAI_npc_dkc1_gothik;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_scarlet_ghoul";
     newscript->GetAI = &GetAI_npc_scarlet_ghoul;
     newscript->RegisterSelf();
+
     // Massacre At Light's Point
     newscript = new Script;
     newscript->Name = "npc_scarlet_miner";
     newscript->GetAI = &GetAI_npc_scarlet_miner;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_scarlet_miner_cart";
     newscript->GetAI = &GetAI_npc_scarlet_miner_cart;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_inconspicuous_mine_car";
     newscript->pGOHello = &GOHello_go_inconspicuous_mine_car;
     newscript->RegisterSelf();
 }
+
 /*
 DELETE FROM `script_texts` WHERE `entry` IN(-1609301, -1609302);
 INSERT INTO `script_texts` (`entry`,`content_default`,`type`,`language`,`emote`,`comment`) VALUES
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp
index b9f8ed31bf8..a592b0cc9b0 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp
@@ -15,8 +15,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 //How to win friends and influence enemies
 // texts signed for creature 28939 but used for 28939,28940,28610
 enum win_friends
@@ -42,12 +44,15 @@ enum win_friends
     SAY_PERSUADED6                    = -1609519,
     SPELL_PERSUASIVE_STRIKE           = 52781
 };
+
 struct TRINITY_DLL_DECL npc_crusade_persuadedAI : public ScriptedAI
 {
     npc_crusade_persuadedAI(Creature *pCreature) : ScriptedAI(pCreature) {}
+
     uint32 uiSpeech_timer;
     uint32 uiSpeech_counter;
     uint64 uiPlayerGUID;
+
     void Reset()
     {
         uiSpeech_timer = 0;
@@ -56,6 +61,7 @@ struct TRINITY_DLL_DECL npc_crusade_persuadedAI : public ScriptedAI
         me->SetReactState(REACT_AGGRESSIVE);
         me->RestoreFaction();
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_PERSUASIVE_STRIKE && caster->GetTypeId() == TYPEID_PLAYER && me->isAlive() && !uiSpeech_counter)
@@ -70,14 +76,17 @@ struct TRINITY_DLL_DECL npc_crusade_persuadedAI : public ScriptedAI
                 me->GetMotionMaster()->MoveIdle();
                 me->SetReactState(REACT_PASSIVE);
                 DoCastAOE(58111, true);
+
                 DoScriptText(RAND(SAY_PERSUADE1,SAY_PERSUADE2,SAY_PERSUADE3,
                                   SAY_PERSUADE4,SAY_PERSUADE5,SAY_PERSUADE6,
                                   SAY_PERSUADE7), caster);
+
                 DoScriptText(RAND(SAY_CRUSADER1,SAY_CRUSADER2,SAY_CRUSADER3,
                                   SAY_CRUSADER4,SAY_CRUSADER5,SAY_CRUSADER6), me);
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (uiSpeech_counter)
@@ -90,6 +99,7 @@ struct TRINITY_DLL_DECL npc_crusade_persuadedAI : public ScriptedAI
                     EnterEvadeMode();
                     return;
                 }
+
                 switch(uiSpeech_counter)
                 {
                     case 1: DoScriptText(SAY_PERSUADED1, me); uiSpeech_timer = 8000; break;
@@ -105,23 +115,30 @@ struct TRINITY_DLL_DECL npc_crusade_persuadedAI : public ScriptedAI
                         pPlayer->GroupEventHappens(12720, me);
                         return;
                 }
+
                 ++uiSpeech_counter;
                 DoCastAOE(58111, true);
             }else uiSpeech_timer -= diff;
+
             return;
         }
+
         if(!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_crusade_persuaded(Creature* pCreature)
 {
     return new npc_crusade_persuadedAI (pCreature);
 }
+
 /*######
 ## npc_koltira_deathweaver
 ######*/
+
 enum eKoltira
 {
     SAY_BREAKOUT1                   = -1609561,
@@ -134,25 +151,32 @@ enum eKoltira
     SAY_BREAKOUT8                   = -1609568,
     SAY_BREAKOUT9                   = -1609569,
     SAY_BREAKOUT10                  = -1609570,
+
     SPELL_KOLTIRA_TRANSFORM         = 52899,
     SPELL_ANTI_MAGIC_ZONE           = 52894,
+
     QUEST_BREAKOUT                  = 12727,
+
     NPC_CRIMSON_ACOLYTE             = 29007,
     NPC_HIGH_INQUISITOR_VALROTH     = 29001,
     NPC_KOLTIRA_ALT                 = 28447,
+
     //not sure about this id
     //NPC_DEATH_KNIGHT_MOUNT          = 29201,
     MODEL_DEATH_KNIGHT_MOUNT        = 25278
 };
+
 struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI
 {
     npc_koltira_deathweaverAI(Creature *pCreature) : npc_escortAI(pCreature)
     {
         me->SetReactState(REACT_DEFENSIVE);
     }
+
     uint32 m_uiWave;
     uint32 m_uiWave_Timer;
     uint64 m_uiValrothGUID;
+
     void Reset()
     {
         if (!HasEscortState(STATE_ESCORT_ESCORTING))
@@ -165,6 +189,7 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI
             me->RemoveAura(SPELL_ANTI_MAGIC_ZONE);
         }
     }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
@@ -199,25 +224,31 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI
                 break;
         }
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (Player* pPlayer = GetPlayerForEscort())
         {
             pSummoned->AI()->AttackStart(pPlayer);
         }
+
         if (pSummoned->GetEntry() == NPC_HIGH_INQUISITOR_VALROTH)
             m_uiValrothGUID = pSummoned->GetGUID();
+
         pSummoned->AddThreat(me, 0.0f);
         pSummoned->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
     }
+
     void SummonAcolyte(uint32 uiAmount)
     {
-        for (uint32 i = 0; i < uiAmount; ++i)
+        for(uint32 i = 0; i < uiAmount; ++i)
             me->SummonCreature(NPC_CRIMSON_ACOLYTE, 1642.329, -6045.818, 127.583, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         npc_escortAI::UpdateAI(uiDiff);
+
         if (HasEscortState(STATE_ESCORT_PAUSED))
         {
             if (m_uiWave_Timer < uiDiff)
@@ -247,6 +278,7 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI
                     case 4:
                     {
                         Creature* pTemp = Unit::GetCreature(*me, m_uiValrothGUID);
+
                         if (!pTemp || !pTemp->isAlive())
                         {
                             DoScriptText(SAY_BREAKOUT8, me);
@@ -270,6 +302,7 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI
                         SetEscortPaused(false);
                         break;
                 }
+
                 ++m_uiWave;
             }
             else
@@ -277,20 +310,24 @@ struct TRINITY_DLL_DECL npc_koltira_deathweaverAI : public npc_escortAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_koltira_deathweaver(Creature* pCreature)
 {
     return new npc_koltira_deathweaverAI(pCreature);
 }
+
 bool QuestAccept_npc_koltira_deathweaver(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_BREAKOUT)
     {
         pCreature->SetStandState(UNIT_STAND_STATE_STAND);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_koltira_deathweaverAI,pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID());
     }
     return true;
 }
+
 //Scarlet courier
 enum ScarletCourierEnum
 {
@@ -300,30 +337,37 @@ enum ScarletCourierEnum
     GO_INCONSPICUOUS_TREE              = 191144,
     NPC_SCARLET_COURIER                = 29076
 };
+
 struct TRINITY_DLL_DECL mob_scarlet_courierAI : public ScriptedAI
 {
     mob_scarlet_courierAI(Creature *pCreature) : ScriptedAI(pCreature) {}
+
     uint32 uiStage;
     uint32 uiStage_timer;
+
     void Reset()
     {
         me->Mount(14338); // not sure about this id
         uiStage = 1;
         uiStage_timer = 3000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_TREE2, me);
         me->Unmount();
         uiStage = 0;
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if(type != POINT_MOTION_TYPE)
             return;
+
         if(id == 1)
             uiStage = 2;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(uiStage && !me->isInCombat())
@@ -352,16 +396,21 @@ struct TRINITY_DLL_DECL mob_scarlet_courierAI : public ScriptedAI
                 uiStage = 0;
             }else uiStage_timer -= diff;
         }
+
         if(!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_scarlet_courier(Creature* pCreature)
 {
     return new mob_scarlet_courierAI (pCreature);
 }
+
 //Koltira & Valroth- Breakout
+
 enum valroth
 {
     SAY_VALROTH1                      = -1609581,
@@ -375,23 +424,28 @@ enum valroth
     SPELL_VALROTH_SMITE               = 52926,
     SPELL_SUMMON_VALROTH_REMAINS      = 52929
 };
+
 struct TRINITY_DLL_DECL mob_high_inquisitor_valrothAI : public ScriptedAI
 {
     mob_high_inquisitor_valrothAI(Creature *pCreature) : ScriptedAI(pCreature) {}
+
     uint32 uiRenew_timer;
     uint32 uiInquisitor_Penance_timer;
     uint32 uiValroth_Smite_timer;
+
     void Reset()
     {
         uiRenew_timer = 1000;
         uiInquisitor_Penance_timer = 2000;
         uiValroth_Smite_timer = 1000;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_VALROTH2, me);
         DoCast(who, SPELL_VALROTH_SMITE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (uiRenew_timer < diff)
@@ -400,36 +454,43 @@ struct TRINITY_DLL_DECL mob_high_inquisitor_valrothAI : public ScriptedAI
             DoCast(me, SPELL_RENEW);
             uiRenew_timer = 1000 + rand()%5000;
         }else uiRenew_timer -= diff;
+
         if (uiInquisitor_Penance_timer < diff)
         {
             Shout();
             DoCast(me->getVictim(), SPELL_INQUISITOR_PENANCE);
             uiInquisitor_Penance_timer = 2000 + rand()%5000;
         }else uiInquisitor_Penance_timer -= diff;
+
         if (uiValroth_Smite_timer < diff)
         {
             Shout();
             DoCast(me->getVictim(), SPELL_VALROTH_SMITE);
             uiValroth_Smite_timer = 1000 + rand()%5000;
         }else uiValroth_Smite_timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void Shout()
     {
         if(rand()%100 < 15)
             DoScriptText(RAND(SAY_VALROTH3,SAY_VALROTH4,SAY_VALROTH5), me);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_VALROTH6, me);
         killer->CastSpell(me, SPELL_SUMMON_VALROTH_REMAINS, true);
     }
 };
+
 CreatureAI* GetAI_mob_high_inquisitor_valroth(Creature* pCreature)
 {
     return new mob_high_inquisitor_valrothAI (pCreature);
 }
 
+
 /*######
 ## npc_a_special_surprise
 ######*/
@@ -490,21 +551,27 @@ enum SpecialSurprise
     SAY_EXEC_TIME_10            = -1609076,
     SAY_EXEC_WAITING            = -1609077,
     EMOTE_DIES                  = -1609078,
+
     NPC_PLAGUEFIST              = 29053
 };
+
 struct TRINITY_DLL_DECL npc_a_special_surpriseAI : public ScriptedAI
 {
     npc_a_special_surpriseAI(Creature *pCreature) : ScriptedAI(pCreature) {}
+
     uint32 ExecuteSpeech_Timer;
     uint32 ExecuteSpeech_Counter;
     uint64 PlayerGUID;
+
     void Reset()
     {
         ExecuteSpeech_Timer = 0;
         ExecuteSpeech_Counter = 0;
         PlayerGUID = 0;
+
         me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
     }
+
     bool MeetQuestCondition(Unit* pPlayer)
     {
         switch(me->GetEntry())
@@ -550,15 +617,19 @@ struct TRINITY_DLL_DECL npc_a_special_surpriseAI : public ScriptedAI
                     return true;
                 break;
         }
+
         return false;
     }
+
     void MoveInLineOfSight(Unit* pWho)
     {
         if (PlayerGUID || pWho->GetTypeId() != TYPEID_PLAYER || !pWho->IsWithinDist(me, INTERACTION_DISTANCE))
             return;
+
         if (MeetQuestCondition(pWho))
             PlayerGUID = pWho->GetGUID();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (PlayerGUID && !me->getVictim() && me->isAlive())
@@ -566,12 +637,15 @@ struct TRINITY_DLL_DECL npc_a_special_surpriseAI : public ScriptedAI
             if (ExecuteSpeech_Timer < diff)
             {
                 Player* pPlayer = Unit::GetPlayer(PlayerGUID);
+
                 if (!pPlayer)
                 {
                     Reset();
                     return;
                 }
+
                 //TODO: simplify text's selection
+
                 switch(pPlayer->getRace())
                 {
                     case RACE_HUMAN:
@@ -855,10 +929,12 @@ struct TRINITY_DLL_DECL npc_a_special_surpriseAI : public ScriptedAI
                         }
                         break;
                 }
+
                 if (ExecuteSpeech_Counter >= 9)
                     ExecuteSpeech_Timer = 15000;
                 else
                     ExecuteSpeech_Timer = 7000;
+
                 ++ExecuteSpeech_Counter;
             }
             else
@@ -866,39 +942,47 @@ struct TRINITY_DLL_DECL npc_a_special_surpriseAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_a_special_surprise(Creature* pCreature)
 {
     return new npc_a_special_surpriseAI(pCreature);
 }
+
 void AddSC_the_scarlet_enclave_c2()
 {
     Script *newscript;
+
     // How to win friends and influence enemies
     newscript = new Script;
     newscript->Name = "npc_crusade_persuaded";
     newscript->GetAI = &GetAI_npc_crusade_persuaded;
     newscript->RegisterSelf();
+
     // Ambush At The Overlook
     newscript = new Script;
     newscript->Name = "mob_scarlet_courier";
     newscript->GetAI = &GetAI_mob_scarlet_courier;
     newscript->RegisterSelf();
+
     // 12727 Bloody Breakout
     newscript = new Script;
     newscript->Name = "npc_koltira_deathweaver";
     newscript->GetAI = &GetAI_npc_koltira_deathweaver;
     newscript->pQuestAccept = &QuestAccept_npc_koltira_deathweaver;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_high_inquisitor_valroth";
     newscript->GetAI = &GetAI_mob_high_inquisitor_valroth;
     newscript->RegisterSelf();
+
     // A Special Suprise
     newscript = new Script;
     newscript->Name = "npc_a_special_surprise";
     newscript->GetAI = &GetAI_npc_a_special_surprise;
     newscript->RegisterSelf();
 }
+
 /*
 -- Bloody Breakout
 UPDATE `creature_template` SET `ScriptName`='npc_koltira_deathweaver' WHERE `entry`='28912';
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp
index 2d42374f84c..0f64371f528 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp
@@ -15,8 +15,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 #define LESS_MOB // if you do not have a good server and do not want it to be laggy as hell
 //Light of Dawn
 enum mograine
@@ -42,9 +44,11 @@ enum mograine
 #endif
     ENCOUNTER_TOTAL_DAWN              = 300,  // Total number
     ENCOUNTER_TOTAL_SCOURGE           = 10000,
+
     WORLD_STATE_REMAINS               = 3592,
     WORLD_STATE_COUNTDOWN             = 3603,
     WORLD_STATE_EVENT_BEGIN           = 3605,
+
     SAY_LIGHT_OF_DAWN01               = -1609201, // pre text
     SAY_LIGHT_OF_DAWN02               = -1609202,
     SAY_LIGHT_OF_DAWN03               = -1609203,
@@ -113,6 +117,7 @@ enum mograine
     SAY_LIGHT_OF_DAWN66               = -1609266, // Highlord Tirion Fordring
     SAY_LIGHT_OF_DAWN67               = -1609267, // Highlord Tirion Fordring
     SAY_LIGHT_OF_DAWN68               = -1609268, // Highlord Darion Mograine
+
     EMOTE_LIGHT_OF_DAWN01             = -1609269,  // Emotes
     EMOTE_LIGHT_OF_DAWN02             = -1609270,
     EMOTE_LIGHT_OF_DAWN03             = -1609271,
@@ -131,8 +136,10 @@ enum mograine
     EMOTE_LIGHT_OF_DAWN16             = -1609284,
     EMOTE_LIGHT_OF_DAWN17             = -1609285,
     EMOTE_LIGHT_OF_DAWN18             = -1609286,
+
     GO_LIGHT_OF_DAWN                  = 191330,
     SPELL_THE_LIGHT_OF_DAWN_Q         = 53606, // quest credit
+
     // ---- Dark Knight npc --------------------
     // Highlord Darion Mograine
     NPC_HIGHLORD_DARION_MOGRAINE      = 29173,
@@ -146,6 +153,7 @@ enum mograine
     SPELL_ALEXANDROS_MOGRAINE_SPAWN   = 53667,
     SPELL_MOGRAINE_CHARGE             = 53679,
     SPELL_ASHBRINGER                  = 53701,
+
     // Koltira Deathweaver & Orbaz Bloodbane are using the same abilities
     NPC_KOLTIRA_DEATHWEAVER           = 29199,
     NPC_ORBAZ_BLOODBANE               = 29204, // this guy fleed
@@ -155,6 +163,7 @@ enum mograine
     SPELL_ICY_TOUCH2                  = 52372,
     SPELL_PLAGUE_STRIKE1              = 50668,
     // all do SPELL_HERO_AGGRO_AURA    53627
+
     // Lich King
     NPC_THE_LICH_KING                 = 29183, // show up at end
     SPELL_APOCALYPSE                  = 53210,
@@ -163,20 +172,26 @@ enum mograine
     SPELL_SOUL_FEAST_TIRION           = 53685, // on Tirion
     SPELL_ICEBOUND_VISAGE             = 53274, // not sure what is it for
     SPELL_REBUKE                      = 53680,
+
     // others
     NPC_RAMPAGING_ABOMINATION         = 29186,
     SPELL_CLEAVE1                     = 53633,
     SPELL_SCOURGE_HOOK                = 50335,
     SPELL_SCOURGE_AGGRO_AURA          = 53624,
+
     NPC_FLESH_BEHEMOTH                = 29190, // giant guy
     SPELL_STOMP                       = 53634,
     SPELL_THUNDERCLAP                 = 36706,
     SPELL_HERO_AGGRO_AURA             = 53627,
+
     NPC_ACHERUS_GHOUL                 = 29219, // just ghoul....
     SPELL_GHOULPLOSION                = 53632,
+
     NPC_WARRIOR_OF_THE_FROZEN_WASTES  = 29206, // use SPELL_CLEAVE 53631
+
     NPC_HIGHLORD_ALEXANDROS_MOGRAINE  = 29227, // ghost
     NPC_DARION_MOGRAINE               = 29228, // ghost
+
     // ---- Dawn npc --------------------
     // Highlord Tirion Fordring
     NPC_HIGHLORD_TIRION_FORDRING      = 29175,
@@ -185,46 +200,56 @@ enum mograine
     SPELL_REBIRTH_OF_THE_ASHBRINGER   = 53702,
     SPELL_TIRION_CHARGE               = 53705,
     SPELL_TIRION_CHARGE_VISUAL        = 53706,
+
     // others
     NPC_KORFAX_CHAMPION_OF_THE_LIGHT  = 29176,
     SPELL_CLEAVE                      = 53631,
     SPELL_HEROIC_LEAP                 = 53625,
+
     NPC_LORD_MAXWELL_TYROSUS          = 29178,
     NPC_LEONID_BARTHALOMEW_THE_REVERED = 29179,
     NPC_DUKE_NICHOLAS_ZVERENHOFF      = 29180,
+
     NPC_COMMANDER_ELIGOR_DAWNBRINGER  = 29177,
     SPELL_HOLY_LIGHT2                 = 37979,
+
     NPC_RAYNE                         = 29181,
     SPELL_REJUVENATION                = 20664,
     SPELL_STARFALL                    = 20678,
     SPELL_TRANQUILITY                 = 25817,
     SPELL_WRATH                       = 21807,
+
     NPC_DEFENDER_OF_THE_LIGHT         = 29174, // also does SPELL_HEROIC_LEAP 53625
     SPELL_HOLY_LIGHT1                 = 29427,
     SPELL_HOLY_STRIKE                 = 53643,
     SPELL_HOLY_WRATH                  = 53638,
     SPELL_UPPERCUT                    = 53629,
+
     NPC_RIMBLAT_EARTHSHATTER          = 29182,
     SPELL_CHAIN_HEAL                  = 33642,
     SPELL_THUNDER                     = 53630
 };
+
 struct Locations
 {
     float x, y, z, o;
     uint32 id;
 };
+
 void UpdateWorldState(Map *map, uint32 id, uint32 state)
 {
     Map::PlayerList const& players = map->GetPlayers();
+
     if (!players.isEmpty())
     {
-        for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+        for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
         {
             if (Player* pPlayer = itr->getSource())
                 pPlayer->SendUpdateWorldState(id,state);
         }
     }
 }
+
 static Locations LightofDawnLoc[]=
 {
     {2281.335, -5300.409, 85.170, 0},     // 0 Tirion Fordring loc
@@ -258,12 +283,14 @@ static Locations LightofDawnLoc[]=
     {2272.709, -5255.552, 78.226, 0},     // 28 Lich king kicked
     {2273.972, -5257.676, 78.862, 0}      // 29 Lich king moves forward
 };
+
 struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
 {
     npc_highlord_darion_mograineAI(Creature *pCreature) : npc_escortAI(pCreature)
     {
         Reset();
     }
+
     bool bIsBattle;
     uint32 uiStep;
     uint32 uiPhase_timer;
@@ -271,6 +298,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
     uint32 uiTotal_dawn;
     uint32 uiTotal_scourge;
     uint32 uiSummon_counter;
+
     // Darion Mograine
     uint32 uiAnti_magic_zone;
     uint32 uiDeath_strike;
@@ -280,6 +308,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
     uint32 uiFight_speech;
     uint32 uiSpawncheck;
     uint32 uiTargetcheck;
+
     // Dawn
     uint64 uiTirionGUID;
     uint64 uiAlexandrosGUID;
@@ -290,6 +319,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
     uint64 uiRayneGUID;
     uint64 uiDefenderGUID[ENCOUNTER_DEFENDER_NUMBER];
     uint64 uiEarthshatterGUID[ENCOUNTER_EARTHSHATTER_NUMBER];
+
     // Death
     uint64 uiKoltiraGUID;
     uint64 uiOrbazGUID;
@@ -299,6 +329,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
     uint64 uiBehemothGUID[ENCOUNTER_BEHEMOTH_NUMBER];
     uint64 uiGhoulGUID[ENCOUNTER_GHOUL_NUMBER];
     uint64 uiWarriorGUID[ENCOUNTER_WARRIOR_NUMBER];
+
     void Reset()
     {
         if (!HasEscortState(STATE_ESCORT_ESCORTING))
@@ -310,19 +341,24 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
             uiTotal_dawn = ENCOUNTER_TOTAL_DAWN;
             uiTotal_scourge = ENCOUNTER_TOTAL_SCOURGE;
             uiSummon_counter = 0;
+
             uiAnti_magic_zone = 1000 + rand()%5000;
             uiDeath_strike = 5000 + rand()%5000;
             uiDeath_embrace = 5000 + rand()%5000;
             uiIcy_touch = 5000 + rand()%5000;
             uiUnholy_blight = 5000 + rand()%5000;
+
             uiFight_speech = 15000;
             uiSpawncheck = 1000;
             uiTargetcheck = 10000;
+
             me->SetStandState(UNIT_STAND_STATE_STAND);
             me->Mount(25279);
+
             UpdateWorldState(me->GetMap(), WORLD_STATE_REMAINS, 0);
             //UpdateWorldState(me->GetMap(), WORLD_STATE_COUNTDOWN, 0);
             UpdateWorldState(me->GetMap(), WORLD_STATE_EVENT_BEGIN, 0);
+
             if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                 pTemp->setDeathState(JUST_DIED);
             if (Creature* pTemp = Unit::GetCreature(*me, uiKorfaxGUID))
@@ -333,23 +369,26 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 pTemp->setDeathState(JUST_DIED);
             if (Creature* pTemp = Unit::GetCreature(*me, uiRayneGUID))
                 pTemp->setDeathState(JUST_DIED);
+
             uiTirionGUID = NULL;
             uiKorfaxGUID = NULL;
             uiMaxwellGUID = NULL;
             uiEligorGUID = NULL;
             uiRayneGUID = NULL;
-            for (uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i)
+
+            for(uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i)
             {
                 if (Creature* pTemp = Unit::GetCreature(*me, uiDefenderGUID[i]))
                     pTemp->setDeathState(JUST_DIED);
                 uiDefenderGUID[i] = 0;
             }
-            for (uint8 i = 0; i < ENCOUNTER_EARTHSHATTER_NUMBER; ++i)
+            for(uint8 i = 0; i < ENCOUNTER_EARTHSHATTER_NUMBER; ++i)
             {
                 if (Creature* pTemp = Unit::GetCreature(*me, uiEarthshatterGUID[i]))
                     pTemp->setDeathState(JUST_DIED);
                 uiEarthshatterGUID[i] = 0;
             }
+
             if (Creature* pTemp = Unit::GetCreature(*me, uiKoltiraGUID))
                 pTemp->setDeathState(JUST_DIED);
             if (Creature* pTemp = Unit::GetCreature(*me, uiOrbazGUID))
@@ -358,29 +397,30 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 pTemp->setDeathState(JUST_DIED);
             if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                 pTemp->setDeathState(JUST_DIED);
+
             uiKoltiraGUID = NULL;
             uiOrbazGUID = NULL;
             uiThassarianGUID = NULL;
             uiLichKingGUID = NULL;
-            for (uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
+            for(uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
             {
                 if (Creature* pTemp = Unit::GetCreature(*me, uiAbominationGUID[i]))
                     pTemp->setDeathState(JUST_DIED);
                 uiAbominationGUID[i] = 0;
             }
-            for (uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
+            for(uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
             {
                 if (Creature* pTemp = Unit::GetCreature(*me, uiBehemothGUID[i]))
                     pTemp->setDeathState(JUST_DIED);
                 uiBehemothGUID[i] = 0;
             }
-            for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
+            for(uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
             {
                 if (Creature* pTemp = Unit::GetCreature(*me, uiGhoulGUID[i]))
                     pTemp->setDeathState(JUST_DIED);
                 uiGhoulGUID[i] = 0;
             }
-            for (uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
+            for(uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
             {
                 if (Creature* pTemp = Unit::GetCreature(*me, uiWarriorGUID[i]))
                     pTemp->setDeathState(JUST_DIED);
@@ -388,12 +428,15 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
             }
         }
     }
+
     void AttackStart(Unit* who)
     {
         if (!who)
             return;
+
         if (who == me)
             return;
+
         if (me->Attack(who, true))
         {
             me->AddThreat(who, 0.0f);
@@ -402,18 +445,22 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
             DoStartMovement(who);
         }
     }
+
     void MoveInLineOfSight(Unit* who)
     {
         if (!who)
             return;
+
         if (who->isTargetableForAttack() && me->IsHostileTo(who))
             if (me->IsWithinDistInMap(who, 20) && me->IsWithinLOSInMap(who))
                 AttackStart(who);
     }
+
     void SetHoldState(bool bOnHold)
     {
         SetEscortPaused(bOnHold);
     }
+
     void WaypointReached(uint32 i)
     {
         switch(i)
@@ -424,28 +471,33 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 break;
             case 1:
                 SetHoldState(true);
+
                 SpawnNPC();
                 if (Creature* pTemp = Unit::GetCreature(*me, uiKorfaxGUID))
                     DoScriptText(SAY_LIGHT_OF_DAWN07, pTemp);
                 if (Creature* pTemp = Unit::GetCreature(*me, uiMaxwellGUID))
                     DoScriptText(SAY_LIGHT_OF_DAWN08, pTemp);
-                for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
+
+                for(uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
                     NPCChangeTarget(uiGhoulGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
                     NPCChangeTarget(uiWarriorGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
                     NPCChangeTarget(uiAbominationGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
                     NPCChangeTarget(uiBehemothGUID[i]);
                 NPCChangeTarget(uiKoltiraGUID);
                 NPCChangeTarget(uiOrbazGUID);
                 NPCChangeTarget(uiThassarianGUID);
+
                 me->Unmount();
                 me->CastSpell(me, SPELL_THE_MIGHT_OF_MOGRAINE, true); // need to fix, on player only
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiKoltiraGUID))
                     pTemp->Unmount();
                 if (Creature* pTemp = Unit::GetCreature(*me, uiThassarianGUID))
                     pTemp->Unmount();
+
                 bIsBattle = true;
                 break;
             case 2:
@@ -455,6 +507,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
             case 3:
             {
                 Unit* pTirion = Unit::GetCreature(*me, uiTirionGUID);
+
                 DoScriptText(EMOTE_LIGHT_OF_DAWN05, me);
                 if (me->HasAura(SPELL_THE_LIGHT_OF_DAWN, 0))
                     me->RemoveAurasDueToSpell(SPELL_THE_LIGHT_OF_DAWN);
@@ -493,6 +546,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
             case 4:
                 DoScriptText(SAY_LIGHT_OF_DAWN27, me);
                 me->SetStandState(UNIT_STAND_STATE_KNEEL);
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiKoltiraGUID))
                     pTemp->SetStandState(UNIT_STAND_STATE_KNEEL);
                 if (Creature* pTemp = Unit::GetCreature(*me, uiThassarianGUID))
@@ -521,9 +575,11 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
+
         if (!bIsBattle)
         {
             if (uiPhase_timer < diff)
@@ -534,6 +590,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                     case 0:  // countdown
                         //UpdateWorldState(me->GetMap(), WORLD_STATE_COUNTDOWN, 1);
                         break;
+
                     case 1:  // just delay
                         //UpdateWorldState(me->GetMap(), WORLD_STATE_REMAINS, 1);
                         UpdateWorldState(me->GetMap(), WORLD_STATE_COUNTDOWN, 0);
@@ -541,6 +598,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                         JumpToNextStep(3000);
                         break;
+
                     case 2:
                         DoScriptText(SAY_LIGHT_OF_DAWN04, me);
                         if (Creature* pKoltira = GetClosestCreatureWithEntry(me, NPC_KOLTIRA_DEATHWEAVER, 50.0f))
@@ -551,10 +609,12 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                             uiThassarianGUID = pThassarian->GetGUID();
                         JumpToNextStep(10000);
                         break;
+
                     case 3: // rise
                         DoScriptText(SAY_LIGHT_OF_DAWN05, me);
                         JumpToNextStep(3000);
                         break;
+
                     case 4: // summon ghoul
                         // Dunno whats the summon spell, so workaround
                         DoCast(me, 33271); // shack effect
@@ -573,6 +633,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                             uiStep++;
                         }
                         break;
+
                     case 5: // summon abomination
                         DoCast(me, 33271); // shack effect
                         uiPhase_timer = 500;
@@ -590,6 +651,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                             uiStep++;
                         }
                         break;
+
                     case 6: // summon warrior
                         DoCast(me, 33271); // shack effect
                         uiPhase_timer = 500;
@@ -607,6 +669,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                             uiStep++;
                         }
                         break;
+
                     case 7: // summon warrior
                         DoCast(me, 33271); // shack effect
                         uiPhase_timer = 500;
@@ -624,10 +687,12 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                             uiStep++;
                         }
                         break;
+
                     case 8: // summon announce
                         DoScriptText(SAY_LIGHT_OF_DAWN06, me);
                         JumpToNextStep(5000);
                         break;
+
                     case 9: // charge begins
                         SetHoldState(false);
                         if (Creature* pTemp = Unit::GetCreature(*me, uiKoltiraGUID))
@@ -645,41 +710,46 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                             pTemp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
                             pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z);
                         }
-                        for (uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
+                        for(uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
                             if (Creature* pTemp = Unit::GetCreature(*me, uiAbominationGUID[i]))
                                 pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z);
-                        for (uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
+                        for(uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
                             if (Creature* pTemp = Unit::GetCreature(*me, uiBehemothGUID[i]))
                                 pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z);
-                        for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
+                        for(uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
                             if (Creature* pTemp = Unit::GetCreature(*me, uiGhoulGUID[i]))
                                 pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z);
-                        for (uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
+                        for(uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
                             if (Creature* pTemp = Unit::GetCreature(*me, uiWarriorGUID[i]))
                                 pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z);
                         JumpToNextStep(5000);
                         break;
+
                     // ******* After battle *****************************************************************
                     case 11: // Tirion starts to speak
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN28, pTemp);
                         JumpToNextStep(21000);
                         break;
+
                     case 12:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN29, pTemp);
                         JumpToNextStep(13000);
                         break;
+
                     case 13:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN30, pTemp);
                         JumpToNextStep(13000);
                         break;
+
                     case 14:
                         me->SetStandState(UNIT_STAND_STATE_STAND);
                         DoScriptText(SAY_LIGHT_OF_DAWN31, me);
                         JumpToNextStep(7000);
                         break;
+
                     case 15: // summon gate
                         if (Unit* pTemp = me->SummonCreature(NPC_HIGHLORD_ALEXANDROS_MOGRAINE, LightofDawnLoc[22].x, LightofDawnLoc[22].y, LightofDawnLoc[22].z, LightofDawnLoc[22].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000))
                         {
@@ -690,6 +760,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(4000);
                         break;
+
                     case 16: // Alexandros out
                         if (Creature* pTemp = Unit::GetCreature(*me, uiAlexandrosGUID))
                         {
@@ -700,11 +771,13 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         SetHoldState(false); // makes darion turns back
                         JumpToNextStep(5000);
                         break;
+
                     case 17:
                         me->SetStandState(UNIT_STAND_STATE_KNEEL);
                         DoScriptText(SAY_LIGHT_OF_DAWN34, me);
                         JumpToNextStep(5000);
                         break;
+
                     case 18: // Darion's spirit out
                         if (Unit* pTemp = me->SummonCreature(NPC_DARION_MOGRAINE, LightofDawnLoc[24].x, LightofDawnLoc[24].y, LightofDawnLoc[24].z, LightofDawnLoc[24].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000))
                         {
@@ -714,6 +787,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(4000);
                         break;
+
                     case 19: // runs to father
                         if (Creature* pTemp = Unit::GetCreature(*me, uiDarionGUID))
                         {
@@ -722,53 +796,65 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(4000);
                         break;
+
                     case 20:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiDarionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN36, pTemp);
                         JumpToNextStep(4000);
                         break;
+
                     case 21:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiDarionGUID))
                             DoScriptText(EMOTE_LIGHT_OF_DAWN08, pTemp);
                         JumpToNextStep(4000);
                         break;
+
                     case 22:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiAlexandrosGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN37, pTemp);
                         JumpToNextStep(8000);
                         break;
+
                     case 23:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiDarionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN38, pTemp);
                         JumpToNextStep(8000);
                         break;
+
                     case 24:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiAlexandrosGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN39, pTemp);
+
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID)) // Tirion moves forward here
                             pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[1].x, LightofDawnLoc[1].y, LightofDawnLoc[1].z);
+
                         JumpToNextStep(15000);
                         break;
+
                     case 25:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiDarionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN40, pTemp);
                         JumpToNextStep(11000);
                         break;
+
                     case 26:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiAlexandrosGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN41, pTemp);
                         JumpToNextStep(5000);
                         break;
+
                     case 27:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiDarionGUID))
                             pTemp->setDeathState(JUST_DIED);
                         JumpToNextStep(24000);
                         break;
+
                     case 28:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiAlexandrosGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN42, pTemp);
                         JumpToNextStep(6000);
                         break;
+
                     case 29: // lich king spawns
                         if (Unit* pTemp = me->SummonCreature(NPC_THE_LICH_KING, LightofDawnLoc[26].x, LightofDawnLoc[26].y, LightofDawnLoc[26].z, LightofDawnLoc[26].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000))
                         {
@@ -779,6 +865,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(2000);
                         break;
+
                     case 30:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiAlexandrosGUID)) // just hide him
                         {
@@ -792,17 +879,20 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(3000);
                         break;
+
                     case 31:
                         me->SetStandState(UNIT_STAND_STATE_STAND);
                         DoScriptText(EMOTE_LIGHT_OF_DAWN10, me);
                         DoScriptText(SAY_LIGHT_OF_DAWN44, me);
                         JumpToNextStep(3000);
                         break;
+
                     case 32:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[27].x, LightofDawnLoc[27].y, LightofDawnLoc[27].z);
                         JumpToNextStep(6000);
                         break;
+
                     case 33: // Darion supports to jump to lich king here
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             DoCast(me, SPELL_MOGRAINE_CHARGE); // jumping charge
@@ -812,6 +902,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         SetHoldState(false);
                         JumpToNextStep(0);
                         break;
+
                     case 35: // Lich king counterattacks
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                         {
@@ -823,25 +914,30 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         SetHoldState(false); // Darion got kicked by lich king
                         JumpToNextStep(0);
                         break;
+
                     case 37: // Lich king counterattacks
                         me->SetStandState(UNIT_STAND_STATE_KNEEL);
                         JumpToNextStep(3000);
                         break;
+
                     case 38:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN47, pTemp);
                         JumpToNextStep(8000);
                         break;
+
                     case 39:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN48, pTemp);
                         JumpToNextStep(15000);
                         break;
+
                     case 40:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN49, pTemp);
                         JumpToNextStep(17000);
                         break;
+
                     case 41: // Lich king - Apocalypse
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                         {
@@ -857,6 +953,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(2000);
                         break;
+
                     case 42: // Maxwell yells for attack
                         {
                             float fLichPositionX, fLichPositionY, fLichPositionZ;
@@ -866,6 +963,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                                 fLichPositionY = pTemp->GetPositionY();
                                 fLichPositionZ = pTemp->GetPositionZ();
                             }
+
                             if (fLichPositionX && fLichPositionY)
                             {
                                 Unit* pTemp;
@@ -876,6 +974,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                                 pTemp->setFaction(me->getFaction());
                                 pTemp->GetMotionMaster()->MovePoint(0, fLichPositionX, fLichPositionY, fLichPositionZ);
                                 uiDefenderGUID[0] = pTemp->GetGUID();
+
                                 pTemp = me->SummonCreature(NPC_RIMBLAT_EARTHSHATTER, LightofDawnLoc[0].x+rand()%10, LightofDawnLoc[0].y+rand()%10, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10000);
                                 pTemp->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_ATTACK_UNARMED);
                                 pTemp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
@@ -910,9 +1009,11 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(4500);
                         break;
+
                     case 43: // They all got kicked
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             DoScriptText(EMOTE_LIGHT_OF_DAWN13, pTemp);
+
                         if (Creature* pTemp = Unit::GetCreature(*me, uiMaxwellGUID))
                         {
                             pTemp->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
@@ -948,6 +1049,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(3000);
                         break;
+
                     case 44: // make them stand up
                         if (Creature* pTemp = Unit::GetCreature(*me, uiMaxwellGUID))
                             pTemp->SetStandState(UNIT_STAND_STATE_STAND);
@@ -957,10 +1059,12 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                             pTemp->SetStandState(UNIT_STAND_STATE_STAND);
                         JumpToNextStep(1000);
                         break;
+
                     case 45:
                         DoScriptText(SAY_LIGHT_OF_DAWN52, me);
                         JumpToNextStep(5000);
                         break;
+
                     case 46: // Darion stand up, "not today"
                         me->SetSpeed(MOVE_RUN, 1.0f);
                         me->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
@@ -969,6 +1073,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         SetHoldState(false); // Darion throws sword
                         JumpToNextStep(7000);
                         break;
+
                     case 47: // Ashbringer rebirth
                         me->SetStandState(UNIT_STAND_STATE_KNEEL);
                         DoScriptText(EMOTE_LIGHT_OF_DAWN15, me);
@@ -980,6 +1085,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(1000);
                         break;
+
                     case 48: // Show the cleansing effect (dawn of light)
                         //if (GameObject* pGo = me->GetMap()->GetGameObject(uiDawnofLightGUID))
                         //    pGo->SetPhaseMask(128, true);
@@ -995,21 +1101,25 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                             pTemp->InterruptNonMeleeSpells(false);
                         JumpToNextStep(2500);
                         break;
+
                     case 49:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN54, pTemp);
                         JumpToNextStep(4000);
                         break;
+
                     case 50:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN55, pTemp);
                         JumpToNextStep(5000);
                         break;
+
                     case 51:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN56, pTemp);
                         JumpToNextStep(1000);
                         break;
+
                     case 52: // Tiron charges
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                         {
@@ -1024,11 +1134,13 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(1500);
                         break;
+
                     case 53:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN57, pTemp);
                         JumpToNextStep(1000);
                         break;
+
                     case 54:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                         {
@@ -1038,26 +1150,31 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(4000);
                         break;
+
                     case 55:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             pTemp->SetStandState(UNIT_STAND_STATE_KNEEL);
                         JumpToNextStep(2000);
                         break;
+
                     case 56:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             pTemp->SetStandState(UNIT_STAND_STATE_STAND);
                         JumpToNextStep(1500);
                         break;
+
                     case 57:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN58, pTemp);
                         JumpToNextStep(10000);
                         break;
+
                     case 58:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN59, pTemp);
                         JumpToNextStep(10000);
                         break;
+
                     case 59:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID))
                             pTemp->CastSpell(pTemp, SPELL_TELEPORT_VISUAL, false);
@@ -1069,6 +1186,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(2500);
                         break;
+
                     case 60:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiLichKingGUID)) // Lich king disappears here
                         {
@@ -1077,11 +1195,13 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(10000);
                         break;
+
                     case 61:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN60, pTemp);
                         JumpToNextStep(3000);
                         break;
+
                     case 62:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                         {
@@ -1090,6 +1210,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(5500);
                         break;
+
                     case 63:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                         {
@@ -1098,44 +1219,53 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         }
                         JumpToNextStep(15000);
                         break;
+
                     case 64:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN62, pTemp);
                         JumpToNextStep(7000);
                         break;
+
                     case 65:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN63, pTemp);
                         JumpToNextStep(10000);
                         break;
+
                     case 66:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN64, pTemp);
                         JumpToNextStep(11000);
                         break;
+
                     case 67:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN65, pTemp);
                         JumpToNextStep(10000);
                         break;
+
                     case 68:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN66, pTemp);
                         JumpToNextStep(8000);
                         break;
+
                     case 69:
                         if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                             DoScriptText(SAY_LIGHT_OF_DAWN67, pTemp);
                         JumpToNextStep(10000);
                         break;
+
                     case 70:
                         me->SetStandState(UNIT_STAND_STATE_STAND);
                         DoScriptText(SAY_LIGHT_OF_DAWN68, me);
                         JumpToNextStep(10000);
                         break;
+
                     case 71:
                         //if (GameObject* pGo = me->GetMap()->GetGameObject(uiDawnofLightGUID)) // Turn off dawn of light
                         //    pGo->SetPhaseMask(0, true);
+
                         {
                             Map *map = me->GetMap(); // search players with in 50 yards for quest credit
                             Map::PlayerList const &PlayerList = map->GetPlayers();
@@ -1150,13 +1280,16 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         me->SummonCreature(NPC_HIGHLORD_DARION_MOGRAINE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 180000);
                         JumpToNextStep(1000);
                         break;
+
                     case 72:
                         SetHoldState(false); // Escort ends
                         JumpToNextStep(0);
                         break;
                 }
+
             }else uiPhase_timer -= diff;
         }
+
         // ******* During battle *****************************************************************
         else
         {
@@ -1165,26 +1298,31 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 DoCast(me, SPELL_ANTI_MAGIC_ZONE1);
                 uiAnti_magic_zone = 25000 + rand()%5000;
             } else uiAnti_magic_zone -= diff;
+
             if (uiDeath_strike < diff)
             {
                 DoCast(me->getVictim(), SPELL_DEATH_STRIKE);
                 uiDeath_strike = 5000 + rand()%5000;
             } else uiDeath_strike -= diff;
+
             if (uiDeath_embrace < diff)
             {
                 DoCast(me->getVictim(), SPELL_DEATH_EMBRACE);
                 uiDeath_embrace = 5000 + rand()%5000;
             } else uiDeath_embrace -= diff;
+
             if (uiIcy_touch < diff)
             {
                 DoCast(me->getVictim(), SPELL_ICY_TOUCH1);
                 uiIcy_touch = 5000 + rand()%5000;
             } else uiIcy_touch -= diff;
+
             if (uiUnholy_blight < diff)
             {
                 DoCast(me->getVictim(), SPELL_UNHOLY_BLIGHT);
                 uiUnholy_blight = 5000 + rand()%5000;
             } else uiUnholy_blight -= diff;
+
             if (uiFight_speech < diff)
             {
                 DoScriptText(RAND(SAY_LIGHT_OF_DAWN09,SAY_LIGHT_OF_DAWN10,SAY_LIGHT_OF_DAWN11,
@@ -1195,28 +1333,32 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                                   SAY_LIGHT_OF_DAWN24), me);
                 uiFight_speech = 15000 + rand()%5000;
             } else uiFight_speech -= diff;
+
             // Check spawns
             if (uiSpawncheck < diff)
             {
                 SpawnNPC();
                 uiSpawncheck = 1000;
             } else uiSpawncheck -= diff;
+
             // Check targets
             if (uiTargetcheck < diff)
             {
-                for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
                     NPCChangeTarget(uiGhoulGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
                     NPCChangeTarget(uiWarriorGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
                     NPCChangeTarget(uiAbominationGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
                     NPCChangeTarget(uiBehemothGUID[i]);
                 NPCChangeTarget(uiKoltiraGUID);
                 NPCChangeTarget(uiOrbazGUID);
                 NPCChangeTarget(uiThassarianGUID);
+
                 uiTargetcheck = 10000;
             } else uiTargetcheck -= diff;
+
             // Battle end
             if (uiFight_duration < diff + 5000)
             {
@@ -1233,6 +1375,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
             {
                 bIsBattle = false;
                 uiFight_duration = 300000;
+
                 if (me->HasAura(SPELL_THE_MIGHT_OF_MOGRAINE, 0))
                     me->RemoveAurasDueToSpell(SPELL_THE_MIGHT_OF_MOGRAINE);
                 me->RemoveAllAuras();
@@ -1240,18 +1383,20 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 me->CombatStop(true);
                 me->InterruptNonMeleeSpells(false);
                 me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
-                for (uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i)
+
+                for(uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i)
                     DespawnNPC(uiDefenderGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_EARTHSHATTER_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_EARTHSHATTER_NUMBER; ++i)
                     DespawnNPC(uiEarthshatterGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
                     DespawnNPC(uiAbominationGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
                     DespawnNPC(uiBehemothGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
                     DespawnNPC(uiGhoulGUID[i]);
-                for (uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
+                for(uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
                     DespawnNPC(uiWarriorGUID[i]);
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiKorfaxGUID))
                 {
                     pTemp->RemoveAllAuras();
@@ -1262,6 +1407,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                     pTemp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
                     pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[9].x, LightofDawnLoc[9].y, LightofDawnLoc[9].z);
                 }
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiMaxwellGUID))
                 {
                     pTemp->RemoveAllAuras();
@@ -1272,6 +1418,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                     pTemp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
                     pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[12].x, LightofDawnLoc[12].y, LightofDawnLoc[12].z);
                 }
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiEligorGUID))
                 {
                     pTemp->RemoveAllAuras();
@@ -1283,6 +1430,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                     pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[15].x, LightofDawnLoc[15].y, LightofDawnLoc[15].z);
                 }
                 DespawnNPC(uiRayneGUID);
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiKoltiraGUID))
                 {
                     pTemp->RemoveAllAuras();
@@ -1294,8 +1442,10 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                     pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[18].x, LightofDawnLoc[18].y, LightofDawnLoc[18].z);
                     pTemp->CastSpell(pTemp, SPELL_THE_LIGHT_OF_DAWN, false);
                 }
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiOrbazGUID))
                     DoScriptText(EMOTE_LIGHT_OF_DAWN04, pTemp);
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiThassarianGUID))
                 {
                     pTemp->RemoveAllAuras();
@@ -1307,18 +1457,24 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                     pTemp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[20].x, LightofDawnLoc[20].y, LightofDawnLoc[20].z);
                     pTemp->CastSpell(pTemp, SPELL_THE_LIGHT_OF_DAWN, false);
                 }
+
                 if (Creature* pTemp = Unit::GetCreature(*me, uiTirionGUID))
                     DoScriptText(SAY_LIGHT_OF_DAWN26, pTemp);
+
                 SetHoldState(false);
+
             } else uiFight_duration -= diff;
+
             DoMeleeAttackIfReady();
         }
     }
+
     void JumpToNextStep(uint32 uiTimer)
     {
         uiPhase_timer = uiTimer;
         uiStep++;
     }
+
     void NPCChangeTarget(uint64 ui_GUID)
     {
         if (Creature* pTemp = Unit::GetCreature(*me, ui_GUID))
@@ -1334,11 +1490,13 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                         // pTemp->GetMotionMaster()->MoveChase(pTarger, 20.0f);
                     }
     }
+
     void SpawnNPC()
     {
         Unit* pTemp = NULL;
+
         // Death
-        for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
+        for(uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i)
         {
             if (!(pTemp = Unit::GetCreature(*me, uiGhoulGUID[i])))
             {
@@ -1347,7 +1505,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 uiGhoulGUID[i] = pTemp->GetGUID();
             }
         }
-        for (uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
+        for(uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i)
         {
             if (!(pTemp = Unit::GetCreature(*me, uiAbominationGUID[i])))
             {
@@ -1356,7 +1514,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 uiAbominationGUID[i] = pTemp->GetGUID();
             }
         }
-        for (uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
+        for(uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i)
         {
             if (!(pTemp = Unit::GetCreature(*me, uiWarriorGUID[i])))
             {
@@ -1365,7 +1523,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 uiWarriorGUID[i] = pTemp->GetGUID();
             }
         }
-        for (uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
+        for(uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i)
         {
             if (!(pTemp = Unit::GetCreature(*me, uiBehemothGUID[i])))
             {
@@ -1374,8 +1532,9 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 uiBehemothGUID[i] = pTemp->GetGUID();
             }
         }
+
         // Dawn
-        for (uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i)
+        for(uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i)
         {
             if (!(pTemp = Unit::GetCreature(*me, uiDefenderGUID[i])))
             {
@@ -1385,7 +1544,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
                 uiDefenderGUID[i] = pTemp->GetGUID();
             }
         }
-        for (uint8 i = 0; i < ENCOUNTER_EARTHSHATTER_NUMBER; ++i)
+        for(uint8 i = 0; i < ENCOUNTER_EARTHSHATTER_NUMBER; ++i)
         {
             if (!(pTemp = Unit::GetCreature(*me, uiEarthshatterGUID[i])))
             {
@@ -1424,6 +1583,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
             uiRayneGUID = pTemp->GetGUID();
         }
     }
+
     void DespawnNPC(uint64 pGUID)
     {
         if (Creature* pTemp = Unit::GetCreature(*me, pGUID))
@@ -1434,15 +1594,20 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI
             }
     }
 };
+
 bool GossipHello_npc_highlord_darion_mograine(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu( pCreature->GetGUID() );
+
     if (pPlayer->GetQuestStatus(12801) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM( 0, "I am ready.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_highlord_darion_mograine(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -1455,6 +1620,7 @@ bool GossipSelect_npc_highlord_darion_mograine(Player* pPlayer, Creature* pCreat
     }
     return true;
 }
+
 /*######
 ## npc the lich king in dawn of light
 ######*/
@@ -1466,23 +1632,28 @@ struct TRINITY_DLL_DECL npc_the_lich_king_tirion_dawnAI : public ScriptedAI
     void UpdateAI(const uint32 diff) { return; }
     void JustDied(Unit* killer) {}
 };
+
 CreatureAI* GetAI_npc_highlord_darion_mograine(Creature* pCreature)
 {
     return new npc_highlord_darion_mograineAI(pCreature);
 }
+
 CreatureAI* GetAI_npc_the_lich_king_tirion_dawn(Creature* pCreature)
 {
     return new npc_the_lich_king_tirion_dawnAI (pCreature);
 }
+
 void AddSC_the_scarlet_enclave_c5()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_highlord_darion_mograine";
     newscript->GetAI = &GetAI_npc_highlord_darion_mograine;
     newscript->pGossipHello =  &GossipHello_npc_highlord_darion_mograine;
     newscript->pGossipSelect = &GossipSelect_npc_highlord_darion_mograine;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_the_lich_king_tirion_dawn";
     newscript->GetAI = &GetAI_npc_the_lich_king_tirion_dawn;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp
index 2a728d5d2da..049c4b72cde 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/the_scarlet_enclave.cpp
@@ -15,18 +15,23 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
+
 /*####
 ## npc_valkyr_battle_maiden
 ####*/
 #define SPELL_REVIVE 51918
 #define VALK_WHISPER "It is not yet your time, champion. Rise! Rise and fight once more!"
+
 struct TRINITY_DLL_DECL npc_valkyr_battle_maidenAI : public PassiveAI
 {
     npc_valkyr_battle_maidenAI(Creature *c) : PassiveAI(c) {}
+
     uint32 FlyBackTimer;
     float x, y, z;
     uint32 phase;
+
     void Reset()
     {
         m_creature->SetVisibility(VISIBILITY_OFF);
@@ -34,11 +39,13 @@ struct TRINITY_DLL_DECL npc_valkyr_battle_maidenAI : public PassiveAI
         m_creature->SetFlying(true);
         FlyBackTimer = 500;
         phase = 0;
+
         m_creature->GetPosition(x, y, z);
         z += 4; x -= 3.5; y -= 5;
         m_creature->GetMotionMaster()->Clear(false);
         m_creature->GetMap()->CreatureRelocation(m_creature, x, y, z, 0.0f);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(FlyBackTimer < diff)
@@ -48,8 +55,10 @@ struct TRINITY_DLL_DECL npc_valkyr_battle_maidenAI : public PassiveAI
                 if(Unit *summoner = CAST_SUM(me)->GetSummoner())
                     if(summoner->GetTypeId() == TYPEID_PLAYER)
                         plr = CAST_PLR(summoner);
+
             if(!plr)
                 phase = 3;
+
             switch(phase)
             {
                 case 0:
@@ -85,17 +94,21 @@ struct TRINITY_DLL_DECL npc_valkyr_battle_maidenAI : public PassiveAI
         }else FlyBackTimer-=diff;
     }
 };
+
 CreatureAI* GetAI_npc_valkyr_battle_maiden(Creature* pCreature)
 {
     return new npc_valkyr_battle_maidenAI (pCreature);
 }
+
 void AddSC_the_scarlet_enclave()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_valkyr_battle_maiden";
     newscript->GetAI = &GetAI_npc_valkyr_battle_maiden;
     newscript->RegisterSelf();
+
     // Chapter 3: Scarlet Armies Approach... - An End To All Things...
     // Chapter 4: An End To All Things... - An End To All Things...
 }
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_arcanist_doan.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_arcanist_doan.cpp
index be5d73b4009..51a8d6efc8d 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_arcanist_doan.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_arcanist_doan.cpp
@@ -13,31 +13,38 @@
  * along with 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"
+
 enum eEnums
 {
     SAY_AGGRO                   = -1189019,
     SAY_SPECIALAE               = -1189020,
+
     SPELL_POLYMORPH             = 13323,
     SPELL_AOESILENCE            = 8988,
     SPELL_ARCANEEXPLOSION       = 9433,
     SPELL_FIREAOE               = 9435,
     SPELL_ARCANEBUBBLE          = 9438,
 };
+
 struct TRINITY_DLL_DECL boss_arcanist_doanAI : public ScriptedAI
 {
     boss_arcanist_doanAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Polymorph_Timer;
     uint32 AoESilence_Timer;
     uint32 ArcaneExplosion_Timer;
     bool bCanDetonate;
     bool bShielded;
+
     void Reset()
     {
         Polymorph_Timer = 20000;
@@ -46,50 +53,62 @@ struct TRINITY_DLL_DECL boss_arcanist_doanAI : public ScriptedAI
         bCanDetonate = false;
         bShielded = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (bShielded && bCanDetonate)
         {
             DoCast(m_creature,SPELL_FIREAOE);
             bCanDetonate = false;
         }
+
         if (m_creature->HasAura(SPELL_ARCANEBUBBLE))
             return;
+
         //If we are <50% hp cast Arcane Bubble
         if (!bShielded && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50)
         {
             //wait if we already casting
             if (m_creature->IsNonMeleeSpellCasted(false))
                 return;
+
             DoScriptText(SAY_SPECIALAE, m_creature);
             DoCast(m_creature,SPELL_ARCANEBUBBLE);
+
             bCanDetonate = true;
             bShielded = true;
         }
+
         if (Polymorph_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1))
                 DoCast(target,SPELL_POLYMORPH);
+
             Polymorph_Timer = 20000;
         }else Polymorph_Timer -= diff;
+
         //AoESilence_Timer
         if (AoESilence_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_AOESILENCE);
             AoESilence_Timer = 15000 + rand()%5000;
         }else AoESilence_Timer -= diff;
+
         //ArcaneExplosion_Timer
         if (ArcaneExplosion_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_ARCANEEXPLOSION);
             ArcaneExplosion_Timer = 8000;
         }else ArcaneExplosion_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -97,6 +116,7 @@ CreatureAI* GetAI_boss_arcanist_doan(Creature* pCreature)
 {
     return new boss_arcanist_doanAI (pCreature);
 }
+
 void AddSC_boss_arcanist_doan()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp
index 4b2a045cb7a..1409b2ff693 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp
@@ -13,35 +13,44 @@
  * along with 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 TRINITY_DLL_DECL boss_azshir_the_sleeplessAI : public ScriptedAI
 {
     boss_azshir_the_sleeplessAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 SoulSiphon_Timer;
     uint32 CallOftheGrave_Timer;
     uint32 Terrify_Timer;
+
     void Reset()
     {
         SoulSiphon_Timer = 1;
         CallOftheGrave_Timer = 30000;
         Terrify_Timer = 20000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //If we are <50% hp cast Soul Siphon rank 1
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false))
         {
@@ -50,28 +59,34 @@ struct TRINITY_DLL_DECL boss_azshir_the_sleeplessAI : public ScriptedAI
             {
                 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* pCreature)
 {
     return new boss_azshir_the_sleeplessAI (pCreature);
 }
+
 void AddSC_boss_azshir_the_sleepless()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_bloodmage_thalnos.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_bloodmage_thalnos.cpp
index a3b67ee7e71..b7cba1ae97a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_bloodmage_thalnos.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_bloodmage_thalnos.cpp
@@ -13,31 +13,38 @@
  * along with 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"
+
 enum eEnums
 {
     SAY_AGGRO               = -1189016,
     SAY_HEALTH              = -1189017,
     SAY_KILL                = -1189018,
+
     SPELL_FLAMESHOCK        = 8053,
     SPELL_SHADOWBOLT        = 1106,
     SPELL_FLAMESPIKE        = 8814,
     SPELL_FIRENOVA          = 16079,
 };
+
 struct TRINITY_DLL_DECL boss_bloodmage_thalnosAI : public ScriptedAI
 {
     boss_bloodmage_thalnosAI(Creature *c) : ScriptedAI(c) {}
+
     bool HpYell;
     uint32 FlameShock_Timer;
     uint32 ShadowBolt_Timer;
     uint32 FlameSpike_Timer;
     uint32 FireNova_Timer;
+
     void Reset()
     {
         HpYell = false;
@@ -46,55 +53,66 @@ struct TRINITY_DLL_DECL boss_bloodmage_thalnosAI : public ScriptedAI
         FlameSpike_Timer = 8000;
         FireNova_Timer = 40000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void KilledUnit(Unit* Victim)
     {
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //If we are <35% hp
         if (!HpYell && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 35))
         {
             DoScriptText(SAY_HEALTH, m_creature);
             HpYell = true;
         }
+
         //FlameShock_Timer
         if (FlameShock_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_FLAMESHOCK);
             FlameShock_Timer = 10000 + rand()%5000;
         }else FlameShock_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 = 40000;
         }else FireNova_Timer -= diff;
+
         //ShadowBolt_Timer
         if (ShadowBolt_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT);
             ShadowBolt_Timer = 2000;
         }else ShadowBolt_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_bloodmage_thalnos(Creature* pCreature)
 {
     return new boss_bloodmage_thalnosAI (pCreature);
 }
+
 void AddSC_boss_bloodmage_thalnos()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp
index bece0e692bd..bce58b42632 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp
@@ -13,15 +13,18 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Boss_Headless_Horseman
 SD%Complete:
 SDComment:
 SDCategory: Scarlet Monastery
 EndScriptData */
+
 #include "precompiled.h"
 #include "SpellMgr.h"
 #include "def_scarlet_monastery.h"
+
 //this texts are already used by 3975 and 3976
 #define SAY_ENTRANCE                -1189001
 #define SAY_REJOINED                -1189002
@@ -30,7 +33,9 @@ EndScriptData */
 #define SAY_SPROUTING_PUMPKINS      -1189005
 #define SAY_PLAYER_DEATH            -1189006
 #define SAY_DEATH                   -1189007
+
 uint32 RandomLaugh[] = {11965, 11975, 11976};
+
     // Entryes
 #define HH_MOUNTED                  23682
 #define HH_UNHORSED                 23800
@@ -39,23 +44,28 @@ uint32 RandomLaugh[] = {11965, 11975, 11976};
 #define PUMPKIN_FIEND               23545
 #define HELPER                      23686
 #define WISP_INVIS                  24034
+
     //Spells
 #define SPELL_CLEAVE                42587
 #define SPELL_CONFLAGRATION         42380       //Phase 2, can't find real spell(Dim Fire?)
 //#define SPELL_CONFL_SPEED         22587       //8% increase speed, value 22587 from SPELL_CONFLAGRATION mains that spell?
 #define SPELL_SUMMON_PUMPKIN        42394
+
 #define SPELL_WHIRLWIND             43116
 #define SPELL_IMMUNE                42556
 #define SPELL_BODY_REGEN            42403
 #define SPELL_CONFUSE               43105
+
 #define SPELL_FLYING_HEAD           42399       //visual flying head
 #define SPELL_HEAD                  42413       //visual buff, "head"
 #define SPELL_HEAD_IS_DEAD          42428       //at killing head, Phase 3
+
 #define SPELL_PUMPKIN_AURA          42280
 #define SPELL_PUMPKIN_AURA_GREEN    42294
 #define SPELL_SQUASH_SOUL           42514
 #define SPELL_SPROUTING             42281
 #define SPELL_SPROUT_BODY           42285
+
     //Effects
 #define SPELL_RHYME_BIG             42909
 //#define SPELL_RHYME_SMALL         42910
@@ -69,10 +79,12 @@ uint32 RandomLaugh[] = {11965, 11975, 11976};
 //#define SPELL_WISP_INVIS          42823
 #define SPELL_SMOKE                 42355
 #define SPELL_DEATH                 42566       //not correct spell
+
 struct Locations
 {
     float x, y, z;
 };
+
 static Locations FlightPoint[]=
 {
     {1754.00,1346.00,17.50},
@@ -97,15 +109,18 @@ static Locations FlightPoint[]=
     {1757.80,1378.20,29.00},
     {1758.00,1367.00,19.51}
 };
+
 static Locations Spawn[]=
 {
     {1776.27,1348.74,19.20},        //spawn point for pumpkin shrine mob
     {1765.28,1347.46,17.55}     //spawn point for smoke
 };
+
 struct Summon
 {
     const std::string text;
 };
+
 static Summon Text[]=
 {
     {"Horseman rise..."},
@@ -113,7 +128,9 @@ static Summon Text[]=
     {"You felt death once..."},
     {"Now, know demise!"}
 };
+
 #define EMOTE_LAUGHS    "laughs"
+
 struct TRINITY_DLL_DECL mob_wisp_invisAI : public ScriptedAI
 {
     mob_wisp_invisAI(Creature *c) : ScriptedAI(c)
@@ -127,6 +144,7 @@ struct TRINITY_DLL_DECL mob_wisp_invisAI : public ScriptedAI
         if (port)
             port->rangeIndex = 6;
     }
+
     uint32 Creaturetype;
     uint32 delay;
     uint32 spell;
@@ -157,18 +175,22 @@ struct TRINITY_DLL_DECL mob_wisp_invisAI : public ScriptedAI
         if (spell)
             DoCast(m_creature,spell);
     }
+
     void SpellHit(Unit* caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_WISP_FLIGHT_PORT && Creaturetype == 4)
             m_creature->SetDisplayId(2027);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || Creaturetype != 1 || !who->isTargetableForAttack())
             return;
+
         if (m_creature->IsWithinDist(who, 0.1, false) && !who->HasAura(SPELL_SQUASH_SOUL))
             DoCast(who,SPELL_SQUASH_SOUL);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (delay)
@@ -183,15 +205,20 @@ struct TRINITY_DLL_DECL mob_wisp_invisAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_headAI : public ScriptedAI
 {
     mob_headAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 bodyGUID;
+
     uint32 Phase;
     uint32 laugh;
     uint32 wait;
+
     bool withbody;
     bool die;
+
     void Reset()
     {
         Phase = 0;
@@ -201,6 +228,7 @@ struct TRINITY_DLL_DECL mob_headAI : public ScriptedAI
         wait = 1000;
         laugh = urand(15000,30000);
     }
+
     void EnterCombat(Unit *who) {}
     void SaySound(int32 textEntry, Unit *target = 0)
     {
@@ -211,10 +239,12 @@ struct TRINITY_DLL_DECL mob_headAI : public ScriptedAI
             speaker->CastSpell(speaker,SPELL_HEAD_SPEAKS,false);
         laugh += 3000;
     }
+
     void DamageTaken(Unit* done_by,uint32 &damage)
     {
         if (withbody)
             return;
+
         switch(Phase)
         {
             case 1:
@@ -240,10 +270,12 @@ struct TRINITY_DLL_DECL mob_headAI : public ScriptedAI
                 break;
         }
     }
+
     void SpellHit(Unit *caster, const SpellEntry* spell)
     {
         if (!withbody)
             return;
+
         if (spell->Id == SPELL_FLYING_HEAD)
         {
             if (Phase < 3) ++Phase;
@@ -272,6 +304,7 @@ struct TRINITY_DLL_DECL mob_headAI : public ScriptedAI
                 m_creature->GetMotionMaster()->Clear(false);
                 m_creature->GetMotionMaster()->MoveFleeing(m_creature->getVictim());
             } else wait -= diff;
+
             if (laugh < diff)
             {
                 laugh = urand(15000,30000);
@@ -298,6 +331,7 @@ struct TRINITY_DLL_DECL mob_headAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
 {
     boss_headless_horsemanAI(Creature *c) : ScriptedAI(c)
@@ -313,6 +347,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
 /*
         if (SpellEntry *confl = GET_SPELL(SPELL_CONFLAGRATION))
             confl->EffectTriggerSpell[1] = 22587;
+
         if (SpellEntry *speed = GET_SPELL(22587))
         {
             speed->Effect[1] = SPELL_EFFECT_APPLY_AURA;
@@ -321,13 +356,17 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
 */
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint64 headGUID;
     uint64 PlayerGUID;
+
     uint32 Phase;
     uint32 id;
     uint32 count;
     uint32 say_timer;
+
     uint32 conflagrate;
     uint32 summonadds;
     uint32 cleave;
@@ -335,11 +374,13 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
     uint32 whirlwind;
     uint32 laugh;
     uint32 burn;
+
     bool withhead;
     bool returned;
     bool IsFlying;
     bool wp_reached;
     bool burned;
+
     void Reset()
     {
         Phase = 1;
@@ -351,6 +392,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
         burn = 6000;
         count = 0;
         say_timer = 3000;
+
         withhead = true;
         returned = true;
         burned = false;
@@ -360,11 +402,14 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
         {
             if (Creature* Head = Unit::GetCreature((*m_creature), headGUID))
                 Head->DisappearAndDie();
+
             headGUID = 0;
         }
+
         if (pInstance)
             pInstance->SetData(DATA_HORSEMAN_EVENT, NOT_STARTED);
     }
+
     void FlyMode()
     {
         m_creature->SetVisibility(VISIBILITY_OFF);
@@ -377,11 +422,14 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
         id = 0;
         Phase = 0;
     }
+
     void MovementInform(uint32 type, uint32 i)
     {
         if (type != POINT_MOTION_TYPE || !IsFlying || i != id)
             return;
+
         wp_reached = true;
+
         switch (id)
         {
             case 0:
@@ -415,6 +463,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
         }
         ++id;
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -438,24 +487,30 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
                 CAST_AI(mob_headAI, Head->AI())->SaySound(SAY_PLAYER_DEATH);
         }
     }
+
     void SaySound(int32 textEntry, Unit *target = 0)
     {
         DoScriptText(textEntry, m_creature, target);
         laugh += 4000;
     }
+
     Player* SelectRandomPlayer(float range = 0.0f, bool checkLoS = true)
     {
         Map* pMap = m_creature->GetMap();
         if (!pMap->IsDungeon()) return NULL;
+
         Map::PlayerList const &PlayerList = pMap->GetPlayers();
         Map::PlayerList::const_iterator i;
         if (PlayerList.isEmpty()) return NULL;
+
         std::list temp;
         std::list::iterator j;
-        for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+
+        for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
             if ((m_creature->IsWithinLOSInMap(i->getSource()) || !checkLoS) && m_creature->getVictim() != i->getSource() &&
                 m_creature->IsWithinDistInMap(i->getSource(), range) && i->getSource()->isAlive())
                 temp.push_back(i->getSource());
+
         if (temp.size())
         {
             j = temp.begin();
@@ -464,11 +519,13 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
         }
         return NULL;
     }
+
     void SpellHitTarget(Unit* unit, const SpellEntry* spell)
     {
         if (spell->Id == SPELL_CONFLAGRATION && unit->HasAura(SPELL_CONFLAGRATION))
             SaySound(SAY_CONFLAGRATION,unit);
     }
+
     void JustDied(Unit* killer)
     {
         m_creature->StopMoving();
@@ -481,10 +538,12 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(DATA_HORSEMAN_EVENT, DONE);
     }
+
     void SpellHit(Unit *caster, const SpellEntry* spell)
     {
         if (withhead)
             return;
+
         if (spell->Id == SPELL_FLYING_HEAD)
         {
             if (Phase < 3)
@@ -501,7 +560,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
             caster->GetMotionMaster()->MoveFollow(m_creature,6,urand(0,5));
             //DoResetThreat();//not sure if need
             std::list::iterator itr;
-            for (itr = caster->getThreatManager().getThreatList().begin(); itr != caster->getThreatManager().getThreatList().end(); ++itr)
+            for(itr = caster->getThreatManager().getThreatList().begin(); itr != caster->getThreatManager().getThreatList().end(); ++itr)
             {
                 Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
                 if (pUnit && pUnit->isAlive() && pUnit != caster)
@@ -509,6 +568,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
             }
         }
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth() && withhead)
@@ -518,6 +578,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
             damage = m_creature->GetHealth() - m_creature->GetMaxHealth()/100;
             m_creature->RemoveAllAuras();
             m_creature->SetName("Headless Horseman, Unhorsed");
+
             if (!headGUID)
                 headGUID = DoSpawnCreature(HEAD,rand()%6,rand()%6,0,0,TEMPSUMMON_DEAD_DESPAWN,0)->GetGUID();
             Unit* Head = Unit::GetUnit((*m_creature), headGUID);
@@ -536,6 +597,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (withhead)
@@ -610,12 +672,14 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
                     } else summonadds -= diff;
                     break;
             }
+
             if (laugh < diff)
             {
                 laugh = urand(11000,22000);
                 m_creature->MonsterTextEmote(EMOTE_LAUGHS,NULL);
                 DoPlaySoundToSet(m_creature, RandomLaugh[rand()%3]);
             } else laugh -= diff;
+
             if (UpdateVictim())
             {
                 DoMeleeAttackIfReady();
@@ -647,6 +711,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
                 }
             }
             else regen -= diff;
+
             if (whirlwind < diff)
             {
                 whirlwind = urand(4000,8000);
@@ -661,6 +726,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
         }
     }
 };
+
 void mob_headAI::Disappear()
 {
     if (withbody)
@@ -682,11 +748,14 @@ void mob_headAI::Disappear()
         }
     }
 }
+
 struct TRINITY_DLL_DECL mob_pulsing_pumpkinAI : public ScriptedAI
 {
     mob_pulsing_pumpkinAI(Creature *c) : ScriptedAI(c) {}
+
     bool sprouted;
     uint64 debuffGUID;
+
     void Reset()
     {
         float x, y, z;
@@ -706,7 +775,9 @@ struct TRINITY_DLL_DECL mob_pulsing_pumpkinAI : public ScriptedAI
         DoCast(m_creature,SPELL_SPROUTING);
         m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_STUNNED);
     }
+
     void EnterCombat(Unit *who){}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_SPROUTING)
@@ -719,6 +790,7 @@ struct TRINITY_DLL_DECL mob_pulsing_pumpkinAI : public ScriptedAI
             DoStartMovement(m_creature->getVictim());
         }
     }
+
     void Despawn()
     {
         if (!debuffGUID) return;
@@ -727,21 +799,26 @@ struct TRINITY_DLL_DECL mob_pulsing_pumpkinAI : public ScriptedAI
             debuff->SetVisibility(VISIBILITY_OFF);
             debuffGUID = 0;
     }
+
     void JustDied(Unit *killer) { if (!sprouted) Despawn(); }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || !who->isTargetableForAttack() || !m_creature->IsHostileTo(who) || m_creature->getVictim())
             return;
+
         m_creature->AddThreat(who,0.0f);
         if (sprouted)
             DoStartMovement(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (sprouted && UpdateVictim())
             DoMeleeAttackIfReady();
     }
 };
+
 bool GOHello_go_loosely_turned_soil(Player* pPlayer, GameObject* soil)
 {
 /*  if (soil->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER && plr->getLevel() > 64)
@@ -760,41 +837,51 @@ bool GOHello_go_loosely_turned_soil(Player* pPlayer, GameObject* soil)
     //}
     return true;
 }
+
 CreatureAI* GetAI_mob_head(Creature* pCreature)
 {
     return new mob_headAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_headless_horseman(Creature* pCreature)
 {
     return new boss_headless_horsemanAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_pulsing_pumpkin(Creature* pCreature)
 {
     return new mob_pulsing_pumpkinAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_wisp_invis(Creature* pCreature)
 {
     return new mob_wisp_invisAI (pCreature);
 }
+
 void AddSC_boss_headless_horseman()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_headless_horseman";
     newscript->GetAI = &GetAI_boss_headless_horseman;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_head";
     newscript->GetAI = &GetAI_mob_head;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_pulsing_pumpkin";
     newscript->GetAI = &GetAI_mob_pulsing_pumpkin;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_wisp_invis";
     newscript->GetAI = &GetAI_mob_wisp_invis;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_loosely_turned_soil";
     newscript->pGOHello = &GOHello_go_loosely_turned_soil;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_herod.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_herod.cpp
index 5e4a3d31d70..fc02cad4a2f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_herod.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_herod.cpp
@@ -13,56 +13,70 @@
  * along with 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: 95
 SDComment: Should in addition spawn Myrmidons in the hallway outside
 SDCategory: Scarlet Monastery
 EndScriptData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 #define SAY_AGGRO                   -1189000
 #define SAY_WHIRLWIND               -1189001
 #define SAY_ENRAGE                  -1189002
 #define SAY_KILL                    -1189003
 #define EMOTE_ENRAGE                -1189004
+
 #define SPELL_RUSHINGCHARGE         8260
 #define SPELL_CLEAVE                15496
 #define SPELL_WHIRLWIND             8989
 #define SPELL_FRENZY                8269
+
 #define ENTRY_SCARLET_TRAINEE       6575
 #define ENTRY_SCARLET_MYRMIDON      4295
+
 struct TRINITY_DLL_DECL boss_herodAI : public ScriptedAI
 {
     boss_herodAI(Creature *c) : ScriptedAI(c) {}
+
     bool Enrage;
+
     uint32 Cleave_Timer;
     uint32 Whirlwind_Timer;
 
+
     void Reset()
     {
         Enrage = false;
         Cleave_Timer = 12000;
         Whirlwind_Timer = 60000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoCast(m_creature,SPELL_RUSHINGCHARGE);
     }
+
      void KilledUnit(Unit *victim)
      {
          DoScriptText(SAY_KILL, m_creature);
      }
+
      void JustDied(Unit* killer)
      {
-         for (uint8 i = 0; i < 20; ++i)
+         for(uint8 i = 0; i < 20; ++i)
              m_creature->SummonCreature(ENTRY_SCARLET_TRAINEE, 1939.18, -431.58, 17.09, 6.22, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
      }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //If we are <30% hp goes Enraged
         if (!Enrage && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCasted(false))
         {
@@ -71,12 +85,14 @@ struct TRINITY_DLL_DECL boss_herodAI : public ScriptedAI
             DoCast(m_creature,SPELL_FRENZY);
             Enrage = true;
         }
+
         //Cleave_Timer
         if (Cleave_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_CLEAVE);
             Cleave_Timer = 12000;
         }else Cleave_Timer -= diff;
+
         // Whirlwind_Timer
         if (Whirlwind_Timer < diff)
         {
@@ -84,23 +100,29 @@ struct TRINITY_DLL_DECL boss_herodAI : public ScriptedAI
             DoCast(m_creature->getVictim(),SPELL_WHIRLWIND);
             Whirlwind_Timer = 30000;
         }else Whirlwind_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_herod(Creature* pCreature)
 {
     return new boss_herodAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_scarlet_traineeAI : public npc_escortAI
 {
     mob_scarlet_traineeAI(Creature *c) : npc_escortAI(c)
     {
         Start_Timer = urand(1000,6000);
     }
+
     uint32 Start_Timer;
+
     void Reset() { }
     void WaypointReached(uint32 uiPoint) { }
     void EnterCombat(Unit* who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (Start_Timer)
@@ -111,13 +133,16 @@ struct TRINITY_DLL_DECL mob_scarlet_traineeAI : public npc_escortAI
                 Start_Timer = 0;
             }else Start_Timer -= diff;
         }
+
         npc_escortAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_mob_scarlet_trainee(Creature* pCreature)
 {
     return new mob_scarlet_traineeAI(pCreature);
 }
+
 void AddSC_boss_herod()
 {
     Script *newscript;
@@ -125,6 +150,7 @@ void AddSC_boss_herod()
     newscript->Name = "boss_herod";
     newscript->GetAI = &GetAI_boss_herod;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_scarlet_trainee";
     newscript->GetAI = &GetAI_mob_scarlet_trainee;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp
index 6522510fc13..13e9ef4af53 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp
@@ -13,13 +13,16 @@
  * along with 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_Fairbanks
 SD%Complete: 100
 SDComment: TODO: if this guy not involved in some special event, remove (and let ACID script)
 SDCategory: Scarlet Monastery
 EndScriptData */
+
 #include "precompiled.h"
+
 enum eSpells
 {
     SPELL_CURSEOFBLOOD              = 8282,
@@ -29,9 +32,11 @@ enum eSpells
     SPELL_POWERWORDSHIELD           = 11647,
     SPELL_SLEEP                     = 8399
 };
+
 struct TRINITY_DLL_DECL boss_high_inquisitor_fairbanksAI : public ScriptedAI
 {
     boss_high_inquisitor_fairbanksAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 CurseOfBlood_Timer;
     uint32 DispelMagic_Timer;
     uint32 Fear_Timer;
@@ -39,6 +44,7 @@ struct TRINITY_DLL_DECL boss_high_inquisitor_fairbanksAI : public ScriptedAI
     uint32 Sleep_Timer;
     uint32 Dispel_Timer;
     bool PowerWordShield;
+
     void Reset()
     {
         CurseOfBlood_Timer = 10000;
@@ -49,59 +55,73 @@ struct TRINITY_DLL_DECL boss_high_inquisitor_fairbanksAI : public ScriptedAI
         Dispel_Timer = 20000;
         PowerWordShield = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //If we are <25% hp cast Heal
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 25 && !m_creature->IsNonMeleeSpellCasted(false) && Heal_Timer < diff)
         {
             DoCast(m_creature,SPELL_HEAL);
             Heal_Timer = 30000;
         }else Heal_Timer -= diff;
+
         //Fear_Timer
         if (Fear_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1))
                 DoCast(target,SPELL_FEAR);
+
             Fear_Timer = 40000;
         }else Fear_Timer -= diff;
+
         //Sleep_Timer
         if (Sleep_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO,0))
                 DoCast(target,SPELL_SLEEP);
+
             Sleep_Timer = 30000;
         }else Sleep_Timer -= diff;
+
         //PowerWordShield_Timer
         if (!PowerWordShield && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 25)
         {
             DoCast(m_creature,SPELL_POWERWORDSHIELD);
             PowerWordShield = true;
         }
+
         //Dispel_Timer
         if (Dispel_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 DoCast(target, SPELL_DISPELMAGIC);
+
             DispelMagic_Timer = 30000;
         }else DispelMagic_Timer -= diff;
+
         //CurseOfBlood_Timer
         if (CurseOfBlood_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_CURSEOFBLOOD);
             CurseOfBlood_Timer = 25000;
         }else CurseOfBlood_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_high_inquisitor_fairbanks(Creature* pCreature)
 {
     return new boss_high_inquisitor_fairbanksAI (pCreature);
 }
+
 void AddSC_boss_high_inquisitor_fairbanks()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_houndmaster_loksey.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_houndmaster_loksey.cpp
index c431cde008b..2e79f2449d0 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_houndmaster_loksey.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_houndmaster_loksey.cpp
@@ -13,47 +13,59 @@
  * along with 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"
+
 enum eEnums
 {
     SAY_AGGRO                       = -1189021,
     SPELL_SUMMONSCARLETHOUND        = 17164,
     SPELL_BLOODLUST                 = 6742
 };
+
 struct TRINITY_DLL_DECL boss_houndmaster_lokseyAI : public ScriptedAI
 {
     boss_houndmaster_lokseyAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 BloodLust_Timer;
+
     void Reset()
     {
         BloodLust_Timer = 20000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (BloodLust_Timer < diff)
         {
             DoCast(m_creature,SPELL_BLOODLUST);
             BloodLust_Timer = 20000;
         }else BloodLust_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_houndmaster_loksey(Creature* pCreature)
 {
     return new boss_houndmaster_lokseyAI (pCreature);
 }
+
 void AddSC_boss_houndmaster_loksey()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_interrogator_vishas.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_interrogator_vishas.cpp
index b50c1a6a023..c0b02a2c370 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_interrogator_vishas.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_interrogator_vishas.cpp
@@ -13,14 +13,17 @@
  * along with 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"
 #include "def_scarlet_monastery.h"
+
 enum eEnums
 {
     SAY_AGGRO               = -1189011,
@@ -28,66 +31,82 @@ enum eEnums
     SAY_HEALTH2             = -1189013,
     SAY_KILL                = -1189014,
     SAY_TRIGGER_VORREL      = -1189015,
+
     SPELL_SHADOWWORDPAIN    = 2767,
 };
+
 struct TRINITY_DLL_DECL boss_interrogator_vishasAI : public ScriptedAI
 {
     boss_interrogator_vishasAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     bool Yell30;
     bool Yell60;
     uint32 ShadowWordPain_Timer;
+
     void Reset()
     {
         ShadowWordPain_Timer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void KilledUnit(Unit* Victim)
     {
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         if (!pInstance)
             return;
+
         //Any other actions to do with vorrel? setStandState?
         if (Unit *vorrel = Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_VORREL)))
             DoScriptText(SAY_TRIGGER_VORREL, vorrel);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //If we are low on hp Do sayings
         if (!Yell60 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 60))
         {
             DoScriptText(SAY_HEALTH1, m_creature);
             Yell60 = true;
         }
+
         if (!Yell30 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 30))
         {
             DoScriptText(SAY_HEALTH2, m_creature);
             Yell30 = true;
         }
+
         //ShadowWordPain_Timer
         if (ShadowWordPain_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_SHADOWWORDPAIN);
             ShadowWordPain_Timer = 5000 + rand()%10000;;
         }else ShadowWordPain_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_interrogator_vishas(Creature* pCreature)
 {
     return new boss_interrogator_vishasAI (pCreature);
 }
+
 void AddSC_boss_interrogator_vishas()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_mograine_and_whitemane.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_mograine_and_whitemane.cpp
index 742b2709e2b..9859f3b8bd7 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_mograine_and_whitemane.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_mograine_and_whitemane.cpp
@@ -13,29 +13,35 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss_Mograine_And_Whitemane
 SD%Complete: 90
 SDComment:
 SDCategory: Scarlet Monastery
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_scarlet_monastery.h"
+
 enum eEnums
 {
     //Mograine says
     SAY_MO_AGGRO                 = -1189005,
     SAY_MO_KILL                  = -1189006,
     SAY_MO_RESSURECTED           = -1189007,
+
     //Whitemane says
     SAY_WH_INTRO                 = -1189008,
     SAY_WH_KILL                  = -1189009,
     SAY_WH_RESSURECT             = -1189010,
+
     //Mograine Spells
     SPELL_CRUSADERSTRIKE         = 14518,
     SPELL_HAMMEROFJUSTICE        = 5589,
     SPELL_LAYONHANDS             = 9257,
     SPELL_RETRIBUTIONAURA        = 8990,
+
     //Whitemanes Spells
     SPELL_DEEPSLEEP              = 9256,
     SPELL_SCARLETRESURRECTION    = 9232,
@@ -44,33 +50,42 @@ enum eEnums
     SPELL_HEAL                   = 12039,
     SPELL_POWERWORDSHIELD        = 22187
 };
+
 struct TRINITY_DLL_DECL boss_scarlet_commander_mograineAI : public ScriptedAI
 {
     boss_scarlet_commander_mograineAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     uint32 m_uiCrusaderStrike_Timer;
     uint32 m_uiHammerOfJustice_Timer;
+
     bool m_bHasDied;
     bool m_bHeal;
     bool m_bFakeDeath;
+
     void Reset()
     {
         m_uiCrusaderStrike_Timer = 10000;
         m_uiHammerOfJustice_Timer = 10000;
+
         //Incase wipe during phase that mograine fake death
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
+
         if (m_pInstance)
             if (m_creature->isAlive())
                 m_pInstance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT,NOT_STARTED);
+
         m_bHasDied = false;
         m_bHeal = false;
         m_bFakeDeath = false;
     }
+
     void JustReachedHome()
     {
         if (m_pInstance)
@@ -79,42 +94,57 @@ struct TRINITY_DLL_DECL boss_scarlet_commander_mograineAI : public ScriptedAI
                 m_pInstance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, FAIL);
         }
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_MO_AGGRO, m_creature);
         DoCast(m_creature,SPELL_RETRIBUTIONAURA);
+
         m_creature->CallForHelp(VISIBLE_RANGE);
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(SAY_MO_KILL, m_creature);
     }
+
     void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
     {
         if (uiDamage < m_creature->GetHealth() || m_bHasDied || m_bFakeDeath)
             return;
+
         if (!m_pInstance)
             return;
+
         //On first death, fake death and open door, as well as initiate whitemane if exist
         if (Unit* Whitemane = Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_WHITEMANE)))
         {
             m_pInstance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, IN_PROGRESS);
+
             Whitemane->GetMotionMaster()->MovePoint(1,1163.113370,1398.856812,32.527786);
+
             m_creature->GetMotionMaster()->MovementExpired();
             m_creature->GetMotionMaster()->MoveIdle();
+
             m_creature->SetHealth(0);
+
             if (m_creature->IsNonMeleeSpellCasted(false))
                 m_creature->InterruptNonMeleeSpells(false);
+
             m_creature->ClearComboPointHolders();
             m_creature->RemoveAllAuras();
             m_creature->ClearAllReactives();
+
             m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
             m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
+
             m_bHasDied = true;
             m_bFakeDeath = true;
+
             uiDamage = 0;
         }
     }
+
     void SpellHit(Unit* pWho, const SpellEntry* pSpell)
     {
         //When hit with ressurection say text
@@ -122,15 +152,18 @@ struct TRINITY_DLL_DECL boss_scarlet_commander_mograineAI : public ScriptedAI
         {
             DoScriptText(SAY_MO_RESSURECTED, m_creature);
             m_bFakeDeath = false;
+
             if (m_pInstance)
                 m_pInstance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, SPECIAL);
         }
     }
 
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         if (m_bHasDied && !m_bHeal && m_pInstance && m_pInstance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) == SPECIAL)
         {
             //On ressurection, stop fake death and heal whitemane and resume fight
@@ -139,74 +172,94 @@ struct TRINITY_DLL_DECL boss_scarlet_commander_mograineAI : public ScriptedAI
                 m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                 m_creature->SetStandState(UNIT_STAND_STATE_STAND);
                 DoCast(Whitemane, SPELL_LAYONHANDS);
+
                 m_uiCrusaderStrike_Timer = 10000;
                 m_uiHammerOfJustice_Timer = 10000;
+
                 if (m_creature->getVictim())
                     m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
+
                 m_bHeal = true;
             }
         }
+
         //This if-check to make sure mograine does not attack while fake death
         if (m_bFakeDeath)
             return;
+
         //m_uiCrusaderStrike_Timer
         if (m_uiCrusaderStrike_Timer < uiDiff)
         {
             DoCast(m_creature->getVictim(),SPELL_CRUSADERSTRIKE);
             m_uiCrusaderStrike_Timer = 10000;
         }else m_uiCrusaderStrike_Timer -= uiDiff;
+
         //m_uiHammerOfJustice_Timer
         if (m_uiHammerOfJustice_Timer < uiDiff)
         {
             DoCast(m_creature->getVictim(),SPELL_HAMMEROFJUSTICE);
             m_uiHammerOfJustice_Timer = 60000;
         }else m_uiHammerOfJustice_Timer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_high_inquisitor_whitemaneAI : public ScriptedAI
 {
     boss_high_inquisitor_whitemaneAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     uint32 m_uiHeal_Timer;
     uint32 m_uiPowerWordShield_Timer;
     uint32 m_uiHolySmite_Timer;
     uint32 m_uiWait_Timer;
+
     bool m_bCanResurrectCheck;
     bool m_bCanResurrect;
+
     void Reset()
     {
         m_uiWait_Timer = 7000;
         m_uiHeal_Timer = 10000;
         m_uiPowerWordShield_Timer = 15000;
         m_uiHolySmite_Timer = 6000;
+
         m_bCanResurrectCheck = false;
         m_bCanResurrect = false;
+
         if (m_pInstance)
             if (m_creature->isAlive())
                 m_pInstance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, NOT_STARTED);
     }
+
     void AttackStart(Unit* pWho)
     {
         if (m_pInstance && m_pInstance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) == NOT_STARTED)
             return;
+
         ScriptedAI::AttackStart(pWho);
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_WH_INTRO, m_creature);
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(SAY_WH_KILL, m_creature);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         if (m_bCanResurrect)
         {
             //When casting resuruction make sure to delay so on rez when reinstate battle deepsleep runs out
@@ -221,25 +274,31 @@ struct TRINITY_DLL_DECL boss_high_inquisitor_whitemaneAI : public ScriptedAI
             }
             else m_uiWait_Timer -= uiDiff;
         }
+
         //Cast Deep sleep when health is less than 50%
         if (!m_bCanResurrectCheck && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50)
         {
             if (m_creature->IsNonMeleeSpellCasted(false))
                 m_creature->InterruptNonMeleeSpells(false);
+
             DoCast(m_creature->getVictim(), SPELL_DEEPSLEEP);
             m_bCanResurrectCheck = true;
             m_bCanResurrect = true;
             return;
         }
+
         //while in "resurrect-mode", don't do anything
         if (m_bCanResurrect)
             return;
+
         //If we are <75% hp cast healing spells at self or Mograine
         if (m_uiHeal_Timer < uiDiff)
         {
             Creature* pTarget = NULL;
+
             if (m_creature->GetHealth() <= m_creature->GetMaxHealth()*0.75f)
                 pTarget = m_creature;
+
             if (m_pInstance)
             {
                 if (Creature* pMograine = Unit::GetCreature((*m_creature), m_pInstance->GetData64(DATA_MOGRAINE)))
@@ -249,40 +308,50 @@ struct TRINITY_DLL_DECL boss_high_inquisitor_whitemaneAI : public ScriptedAI
                         pTarget = pMograine;
                 }
             }
+
             if (pTarget)
                 DoCast(pTarget, SPELL_HEAL);
+
             m_uiHeal_Timer = 13000;
         }else m_uiHeal_Timer -= uiDiff;
+
         //m_uiPowerWordShield_Timer
         if (m_uiPowerWordShield_Timer < uiDiff)
         {
             DoCast(m_creature,SPELL_POWERWORDSHIELD);
             m_uiPowerWordShield_Timer = 15000;
         }else m_uiPowerWordShield_Timer -= uiDiff;
+
         //m_uiHolySmite_Timer
         if (m_uiHolySmite_Timer < uiDiff)
         {
             DoCast(m_creature->getVictim(),SPELL_HOLYSMITE);
             m_uiHolySmite_Timer = 6000;
         }else m_uiHolySmite_Timer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_scarlet_commander_mograine(Creature* pCreature)
 {
     return new boss_scarlet_commander_mograineAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_high_inquisitor_whitemane(Creature* pCreature)
 {
     return new boss_high_inquisitor_whitemaneAI (pCreature);
 }
+
 void AddSC_boss_mograine_and_whitemane()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_scarlet_commander_mograine";
     newscript->GetAI = &GetAI_boss_scarlet_commander_mograine;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_high_inquisitor_whitemane";
     newscript->GetAI = &GetAI_boss_high_inquisitor_whitemane;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_scorn.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_scorn.cpp
index 9d5d99a9a83..0b0b5114f92 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_scorn.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/boss_scorn.cpp
@@ -13,24 +13,30 @@
  * along with 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 TRINITY_DLL_DECL boss_scornAI : public ScriptedAI
 {
     boss_scornAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 LichSlap_Timer;
     uint32 FrostboltVolley_Timer;
     uint32 MindFlay_Timer;
     uint32 FrostNova_Timer;
+
     void Reset()
     {
         LichSlap_Timer = 45000;
@@ -38,37 +44,44 @@ struct TRINITY_DLL_DECL boss_scornAI : public ScriptedAI
         MindFlay_Timer = 30000;
         FrostNova_Timer = 30000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -76,6 +89,7 @@ CreatureAI* GetAI_boss_scorn(Creature* pCreature)
 {
     return new boss_scornAI (pCreature);
 }
+
 void AddSC_boss_scorn()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/def_scarlet_monastery.h b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/def_scarlet_monastery.h
index e92d0cd9cad..2b6399ae3e4 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/def_scarlet_monastery.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/def_scarlet_monastery.h
@@ -1,14 +1,18 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 .sourceforge.net/>
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_SCARLET_M
 #define DEF_SCARLET_M
+
 #define TYPE_MOGRAINE_AND_WHITE_EVENT   1
 #define DATA_MOGRAINE                   2
 #define DATA_WHITEMANE                  3
 #define DATA_DOOR_WHITEMANE             4
+
 #define DATA_HORSEMAN_EVENT             5
 #define GAMEOBJECT_PUMPKIN_SHRINE       6
+
 #define DATA_VORREL                     7
 #endif
 
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/instance_scarlet_monastery.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/instance_scarlet_monastery.cpp
index 6b0e0098f80..492493e2390 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/instance_scarlet_monastery.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_monastery/instance_scarlet_monastery.cpp
@@ -13,44 +13,56 @@
 * along 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_Scarlet_Monastery
 SD%Complete: 50
 SDComment:
 SDCategory: Scarlet Monastery
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_scarlet_monastery.h"
 #include "sc_creature.h"
+
 #define ENTRY_PUMPKIN_SHRINE    186267
 #define ENTRY_HORSEMAN          23682
 #define ENTRY_HEAD              23775
 #define ENTRY_PUMPKIN           23694
+
 #define MAX_ENCOUNTER 1
+
 struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance
 {
     instance_scarlet_monastery(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 PumpkinShrineGUID;
     uint64 HorsemanGUID;
     uint64 HeadGUID;
     std::set HorsemanAdds;
+
     uint64 MograineGUID;
     uint64 WhitemaneGUID;
     uint64 VorrelGUID;
     uint64 DoorHighInquisitorGUID;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         PumpkinShrineGUID  = 0;
         HorsemanGUID = 0;
         HeadGUID = 0;
         HorsemanAdds.clear();
+
         MograineGUID = 0;
         WhitemaneGUID = 0;
         VorrelGUID = 0;
         DoorHighInquisitorGUID = 0;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -59,6 +71,7 @@ struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance
         case 104600: DoorHighInquisitorGUID = pGo->GetGUID(); break;
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -71,6 +84,7 @@ struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance
             case 3981: VorrelGUID = pCreature->GetGUID(); break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -80,6 +94,7 @@ struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance
                 DoUseDoorOrButton(DoorHighInquisitorGUID);
             if (data == FAIL)
                 DoUseDoorOrButton(DoorHighInquisitorGUID);
+
             m_auiEncounter[0] = data;
             break;
         case GAMEOBJECT_PUMPKIN_SHRINE:
@@ -88,7 +103,7 @@ struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance
         case DATA_HORSEMAN_EVENT:
             if (data == DONE)
             {
-                for (std::set::iterator itr = HorsemanAdds.begin(); itr != HorsemanAdds.end(); ++itr)
+                for(std::set::iterator itr = HorsemanAdds.begin(); itr != HorsemanAdds.end(); ++itr)
                 {
                     Creature* add = instance->GetCreature(*itr);
                     if (add && add->isAlive())
@@ -100,6 +115,7 @@ struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance
             break;
         }
     }
+
     uint64 GetData64(uint32 type)
     {
         switch(type)
@@ -114,17 +130,21 @@ struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance
         }
         return 0;
     }
+
     uint32 GetData(uint32 type)
     {
         if (type == TYPE_MOGRAINE_AND_WHITE_EVENT)
             return m_auiEncounter[0];
+
         return 0;
     }
 };
+
 InstanceData* GetInstanceData_instance_scarlet_monastery(Map* pMap)
 {
     return new instance_scarlet_monastery(pMap);
 }
+
 void AddSC_instance_scarlet_monastery()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_darkmaster_gandling.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_darkmaster_gandling.cpp
index 7ad9a5a67bf..b064a1d9e10 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_darkmaster_gandling.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_darkmaster_gandling.cpp
@@ -13,45 +13,57 @@
  * along with 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: 75
 SDComment: Doors missing in instance script.
 SDCategory: Scholomance
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_scholomance.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 TRINITY_DLL_DECL boss_darkmaster_gandlingAI : public ScriptedAI
 {
     boss_darkmaster_gandlingAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 ArcaneMissiles_Timer;
     uint32 ShadowShield_Timer;
     uint32 Curse_Timer;
     uint32 Teleport_Timer;
+
     Creature *Summoned;
+
     void Reset()
     {
         ArcaneMissiles_Timer = 4500;
@@ -59,36 +71,43 @@ struct TRINITY_DLL_DECL boss_darkmaster_gandlingAI : public ScriptedAI
         Curse_Timer = 2000;
         Teleport_Timer = 16000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void JustDied(Unit *killer)
     {
         if (pInstance)
             pInstance->SetData(TYPE_GANDLING, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
@@ -101,6 +120,7 @@ struct TRINITY_DLL_DECL boss_darkmaster_gandlingAI : public ScriptedAI
                 {
                     if (DoGetThreat(target))
                         DoModifyThreatPercent(target, -100);
+
                     switch(rand()%6)
                     {
                         case 0:
@@ -186,6 +206,7 @@ struct TRINITY_DLL_DECL boss_darkmaster_gandlingAI : public ScriptedAI
                 Teleport_Timer = 20000 + rand()%15000;
             }else Teleport_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -193,6 +214,7 @@ CreatureAI* GetAI_boss_darkmaster_gandling(Creature* pCreature)
 {
     return new boss_darkmaster_gandlingAI (pCreature);
 }
+
 void AddSC_boss_darkmaster_gandling()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_death_knight_darkreaver.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_death_knight_darkreaver.cpp
index bab59bf0638..9144542ae7e 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_death_knight_darkreaver.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_death_knight_darkreaver.cpp
@@ -13,19 +13,24 @@
  * along with 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 TRINITY_DLL_DECL boss_death_knight_darkreaverAI : public ScriptedAI
 {
     boss_death_knight_darkreaverAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (m_creature->GetHealth() <= damage)
@@ -33,6 +38,7 @@ struct TRINITY_DLL_DECL boss_death_knight_darkreaverAI : public ScriptedAI
             m_creature->CastSpell(m_creature,23261,true);   //Summon Darkreaver's Fallen Charger
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
@@ -41,9 +47,11 @@ CreatureAI* GetAI_boss_death_knight_darkreaver(Creature* pCreature)
 {
     return new boss_death_knight_darkreaverAI (pCreature);
 }
+
 void AddSC_boss_death_knight_darkreaver()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_death_knight_darkreaver";
     newscript->GetAI = &GetAI_boss_death_knight_darkreaver;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_doctor_theolen_krastinov.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_doctor_theolen_krastinov.cpp
index 0ec2492eb39..51ace6a6e21 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_doctor_theolen_krastinov.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_doctor_theolen_krastinov.cpp
@@ -13,47 +13,58 @@
  * along with 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"
+
 enum eEnums
 {
     EMOTE_GENERIC_FRENZY_KILL   = -1000001,
+
     SPELL_REND                  = 16509,
     SPELL_BACKHAND              = 18103,
     SPELL_FRENZY                = 8269
 };
+
 struct TRINITY_DLL_DECL boss_theolenkrastinovAI : public ScriptedAI
 {
     boss_theolenkrastinovAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 m_uiRend_Timer;
     uint32 m_uiBackhand_Timer;
     uint32 m_uiFrenzy_Timer;
+
     void Reset()
     {
         m_uiRend_Timer = 8000;
         m_uiBackhand_Timer = 9000;
         m_uiFrenzy_Timer = 1000;
     }
+
     void JustDied(Unit* pKiller)
     {
         ScriptedInstance* pInstance = m_creature->GetInstanceData();
         if (pInstance)
         {
             pInstance->SetData(DATA_DOCTORTHEOLENKRASTINOV_DEATH, 0);
+
             if (pInstance->GetData(TYPE_GANDLING) == IN_PROGRESS)
                 m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0);
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         //Rend_Timer
         if (m_uiRend_Timer < uiDiff)
         {
@@ -62,6 +73,7 @@ struct TRINITY_DLL_DECL boss_theolenkrastinovAI : public ScriptedAI
         }
         else
             m_uiRend_Timer -= uiDiff;
+
         //Backhand_Timer
         if (m_uiBackhand_Timer < uiDiff)
         {
@@ -70,6 +82,7 @@ struct TRINITY_DLL_DECL boss_theolenkrastinovAI : public ScriptedAI
         }
         else
             m_uiBackhand_Timer -= uiDiff;
+
         //Frenzy_Timer
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 26)
         {
@@ -77,18 +90,22 @@ struct TRINITY_DLL_DECL boss_theolenkrastinovAI : public ScriptedAI
             {
                 DoCast(m_creature,SPELL_FRENZY);
                 DoScriptText(EMOTE_GENERIC_FRENZY_KILL, m_creature);
+
                 m_uiFrenzy_Timer = 120000;
             }
             else
                 m_uiFrenzy_Timer -= uiDiff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_theolenkrastinov(Creature* pCreature)
 {
     return new boss_theolenkrastinovAI (pCreature);
 }
+
 void AddSC_boss_theolenkrastinov()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_illucia_barov.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_illucia_barov.cpp
index d37a8668a89..c6bb471f6f0 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_illucia_barov.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_illucia_barov.cpp
@@ -13,25 +13,31 @@
  * along with 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 TRINITY_DLL_DECL boss_illuciabarovAI : public ScriptedAI
 {
     boss_illuciabarovAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 CurseOfAgony_Timer;
     uint32 ShadowShock_Timer;
     uint32 Silence_Timer;
     uint32 Fear_Timer;
+
     void Reset()
     {
         CurseOfAgony_Timer = 18000;
@@ -39,49 +45,59 @@ struct TRINITY_DLL_DECL boss_illuciabarovAI : public ScriptedAI
         Silence_Timer = 5000;
         Fear_Timer = 30000;
     }
+
     void JustDied(Unit *killer)
     {
         ScriptedInstance *pInstance = m_creature->GetInstanceData();
         if (pInstance)
         {
             pInstance->SetData(DATA_LADYILLUCIABAROV_DEATH, 0);
+
             if (pInstance->GetData(TYPE_GANDLING) == IN_PROGRESS)
                 m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0);
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -89,6 +105,7 @@ CreatureAI* GetAI_boss_illuciabarov(Creature* pCreature)
 {
     return new boss_illuciabarovAI (pCreature);
 }
+
 void AddSC_boss_illuciabarov()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_instructor_malicia.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_instructor_malicia.cpp
index 2b8f7ac2a41..866a2f4dfbc 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_instructor_malicia.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_instructor_malicia.cpp
@@ -13,22 +13,27 @@
  * along with 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 TRINITY_DLL_DECL boss_instructormaliciaAI : public ScriptedAI
 {
     boss_instructormaliciaAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 CallOfGraves_Timer;
     uint32 Corruption_Timer;
     uint32 FlashHeal_Timer;
@@ -36,6 +41,7 @@ struct TRINITY_DLL_DECL boss_instructormaliciaAI : public ScriptedAI
     uint32 HealingTouch_Timer;
     uint32 FlashCounter;
     uint32 TouchCounter;
+
     void Reset()
     {
         CallOfGraves_Timer = 4000;
@@ -46,47 +52,57 @@ struct TRINITY_DLL_DECL boss_instructormaliciaAI : public ScriptedAI
         FlashCounter = 0;
         TouchCounter = 0;
     }
+
     void JustDied(Unit *killer)
     {
         ScriptedInstance *pInstance = m_creature->GetInstanceData();
         if (pInstance)
         {
             pInstance->SetData(DATA_INSTRUCTORMALICIA_DEATH, 0);
+
             if (pInstance->GetData(TYPE_GANDLING) == IN_PROGRESS)
                 m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0);
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
             {
@@ -99,10 +115,12 @@ struct TRINITY_DLL_DECL boss_instructormaliciaAI : public ScriptedAI
                 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)
             {
@@ -115,6 +133,7 @@ struct TRINITY_DLL_DECL boss_instructormaliciaAI : public ScriptedAI
                 HealingTouch_Timer = 30000;
             }
         }else HealingTouch_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -122,6 +141,7 @@ CreatureAI* GetAI_boss_instructormalicia(Creature* pCreature)
 {
     return new boss_instructormaliciaAI (pCreature);
 }
+
 void AddSC_boss_instructormalicia()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_jandice_barov.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_jandice_barov.cpp
index 328cf01be4f..7d304445fdc 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_jandice_barov.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_jandice_barov.cpp
@@ -13,20 +13,26 @@
 * along with 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 TRINITY_DLL_DECL boss_jandicebarovAI : public ScriptedAI
 {
     boss_jandicebarovAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 CurseOfBlood_Timer;
     uint32 Illusion_Timer;
     //uint32 Illusioncounter;
@@ -36,6 +42,7 @@ struct TRINITY_DLL_DECL boss_jandicebarovAI : public ScriptedAI
     int RandX;
     int RandY;
     Creature* Summoned;
+
     void Reset()
     {
         CurseOfBlood_Timer = 15000;
@@ -43,9 +50,11 @@ struct TRINITY_DLL_DECL boss_jandicebarovAI : public ScriptedAI
         Invisible_Timer = 3000;                             //Too much too low?
         Invisible = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void SummonIllusions(Unit* victim)
     {
         Rand = rand()%10;
@@ -66,6 +75,7 @@ struct TRINITY_DLL_DECL boss_jandicebarovAI : public ScriptedAI
         if (Summoned)
             (Summoned->AI())->AttackStart(victim);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Invisible && Invisible_Timer < diff)
@@ -81,29 +91,35 @@ struct TRINITY_DLL_DECL boss_jandicebarovAI : public ScriptedAI
             //Do nothing while invisible
             return;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //CurseOfBlood_Timer
         if (CurseOfBlood_Timer < diff)
         {
             //Cast
             DoCast(m_creature->getVictim(),SPELL_CURSEOFBLOOD);
+
             //45 seconds
             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);
             m_creature->SetDisplayId(11686);  // Invisible Model
             DoModifyThreatPercent(m_creature->getVictim(),-99);
+
             //Summon 10 Illusions attacking random gamers
             Unit* target = NULL;
-            for (uint8 i = 0; i < 10; ++i)
+            for(uint8 i = 0; i < 10; ++i)
             {
                 target = SelectUnit(SELECT_TARGET_RANDOM,0);
                 if (target)
@@ -111,10 +127,12 @@ struct TRINITY_DLL_DECL boss_jandicebarovAI : public ScriptedAI
             }
             Invisible = true;
             Invisible_Timer = 3000;
+
             //25 seconds until we should cast this agian
             Illusion_Timer = 25000;
         }else Illusion_Timer -= diff;
 
+
         //            //Illusion_Timer
         //            if (Illusion_Timer < diff)
         //            {
@@ -134,48 +152,61 @@ struct TRINITY_DLL_DECL boss_jandicebarovAI : public ScriptedAI
         //                  }
         //
         //            }else Illusion_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 // Illusion of Jandice Barov Script
+
 struct TRINITY_DLL_DECL mob_illusionofjandicebarovAI : public ScriptedAI
 {
     mob_illusionofjandicebarovAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Cleave_Timer;
+
     void Reset()
     {
         Cleave_Timer = 2000 + rand()%6000;
         m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Cleave_Timer
         if (Cleave_Timer < diff)
         {
             //Cast
             DoCast(m_creature->getVictim(),SPELL_CLEAVE);
+
             //5-8 seconds
             Cleave_Timer = 5000 + rand()%3000;
         }else Cleave_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
 
+
 CreatureAI* GetAI_boss_jandicebarov(Creature* pCreature)
 {
     return new boss_jandicebarovAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_illusionofjandicebarov(Creature* pCreature)
 {
     return new mob_illusionofjandicebarovAI (pCreature);
 }
 
+
 void AddSC_boss_jandicebarov()
 {
     Script *newscript;
@@ -183,6 +214,7 @@ void AddSC_boss_jandicebarov()
     newscript->Name = "boss_jandice_barov";
     newscript->GetAI = &GetAI_boss_jandicebarov;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_illusionofjandicebarov";
     newscript->GetAI = &GetAI_mob_illusionofjandicebarov;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_kormok.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_kormok.cpp
index d5793b24e98..753f1969f7f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_kormok.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_kormok.cpp
@@ -13,18 +13,23 @@
  * along with 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 TRINITY_DLL_DECL boss_kormokAI : public ScriptedAI
 {
     boss_kormokAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowVolley_Timer;
     uint32 BoneShield_Timer;
     uint32 Minion_Timer;
@@ -38,6 +43,7 @@ struct TRINITY_DLL_DECL boss_kormokAI : public ScriptedAI
     int Rand2Y;
     Creature* SummonedMinions;
     Creature* SummonedMages;
+
     void Reset()
     {
         ShadowVolley_Timer = 10000;
@@ -46,9 +52,11 @@ struct TRINITY_DLL_DECL boss_kormokAI : public ScriptedAI
         Mage_Timer = 0;
         Mages = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void SummonMinion(Unit* victim)
     {
         Rand1 = rand()%8;
@@ -69,6 +77,7 @@ struct TRINITY_DLL_DECL boss_kormokAI : public ScriptedAI
         if (SummonedMinions)
             (SummonedMinions->AI())->AttackStart(victim);
     }
+
     void SummonMages(Unit* victim)
     {
         Rand2 = rand()%10;
@@ -89,22 +98,26 @@ struct TRINITY_DLL_DECL boss_kormokAI : public ScriptedAI
         if (SummonedMages)
             (SummonedMages->AI())->AttackStart(victim);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
@@ -113,8 +126,10 @@ struct TRINITY_DLL_DECL boss_kormokAI : public ScriptedAI
             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)
         {
@@ -123,6 +138,7 @@ struct TRINITY_DLL_DECL boss_kormokAI : public ScriptedAI
             SummonMages(m_creature->getVictim());
             Mages = true;
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -130,6 +146,7 @@ CreatureAI* GetAI_boss_kormok(Creature* pCreature)
 {
     return new boss_kormokAI (pCreature);
 }
+
 void AddSC_boss_kormok()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_lord_alexei_barov.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_lord_alexei_barov.cpp
index 5b777130b32..41f771471db 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_lord_alexei_barov.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_lord_alexei_barov.cpp
@@ -13,58 +13,73 @@
  * along with 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 TRINITY_DLL_DECL boss_lordalexeibarovAI : public ScriptedAI
 {
     boss_lordalexeibarovAI(Creature *c) : ScriptedAI(c) {}
+
     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();
         if (pInstance)
         {
             pInstance->SetData(DATA_LORDALEXEIBAROV_DEATH, 0);
+
             if (pInstance->GetData(TYPE_GANDLING) == IN_PROGRESS)
                 m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0);
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -72,6 +87,7 @@ CreatureAI* GetAI_boss_lordalexeibarov(Creature* pCreature)
 {
     return new boss_lordalexeibarovAI (pCreature);
 }
+
 void AddSC_boss_lordalexeibarov()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_lorekeeper_polkelt.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_lorekeeper_polkelt.cpp
index a2b9e017eb1..695d907fca5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_lorekeeper_polkelt.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_lorekeeper_polkelt.cpp
@@ -13,25 +13,31 @@
  * along with 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 TRINITY_DLL_DECL boss_lorekeeperpolkeltAI : public ScriptedAI
 {
     boss_lorekeeperpolkeltAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 VolatileInfection_Timer;
     uint32 Darkplague_Timer;
     uint32 CorrosiveAcid_Timer;
     uint32 NoxiousCatalyst_Timer;
+
     void Reset()
     {
         VolatileInfection_Timer = 38000;
@@ -39,47 +45,56 @@ struct TRINITY_DLL_DECL boss_lorekeeperpolkeltAI : public ScriptedAI
         CorrosiveAcid_Timer = 45000;
         NoxiousCatalyst_Timer = 35000;
     }
+
     void JustDied(Unit *killer)
     {
         ScriptedInstance *pInstance = m_creature->GetInstanceData();
         if (pInstance)
         {
             pInstance->SetData(DATA_LOREKEEPERPOLKELT_DEATH, 0);
+
             if (pInstance->GetData(TYPE_GANDLING) == IN_PROGRESS)
                 m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0);
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -87,6 +102,7 @@ CreatureAI* GetAI_boss_lorekeeperpolkelt(Creature* pCreature)
 {
     return new boss_lorekeeperpolkeltAI (pCreature);
 }
+
 void AddSC_boss_lorekeeperpolkelt()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_ras_frostwhisper.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_ras_frostwhisper.cpp
index 2a2e34e137a..0659ab2da4d 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_ras_frostwhisper.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_ras_frostwhisper.cpp
@@ -13,28 +13,34 @@
  * along with 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 TRINITY_DLL_DECL boss_rasfrostAI : public ScriptedAI
 {
     boss_rasfrostAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 IceArmor_Timer;
     uint32 Frostbolt_Timer;
     uint32 Freeze_Timer;
     uint32 Fear_Timer;
     uint32 ChillNova_Timer;
     uint32 FrostVolley_Timer;
+
     void Reset()
     {
         IceArmor_Timer = 2000;
@@ -43,53 +49,64 @@ struct TRINITY_DLL_DECL boss_rasfrostAI : public ScriptedAI
         Freeze_Timer = 18000;
         FrostVolley_Timer = 24000;
         Fear_Timer = 45000;
+
         m_creature->CastSpell(m_creature,SPELL_ICEARMOR,true);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -97,6 +114,7 @@ CreatureAI* GetAI_boss_rasfrost(Creature* pCreature)
 {
     return new boss_rasfrostAI (pCreature);
 }
+
 void AddSC_boss_rasfrost()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_the_ravenian.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_the_ravenian.cpp
index 01479e575cb..aae06c8d27a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_the_ravenian.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_the_ravenian.cpp
@@ -13,26 +13,32 @@
  * along with 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
+
 struct TRINITY_DLL_DECL boss_theravenianAI : public ScriptedAI
 {
     boss_theravenianAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Trample_Timer;
     uint32 Cleave_Timer;
     uint32 SunderingCleave_Timer;
     uint32 KnockAway_Timer;
     bool HasYelled;
+
     void Reset()
     {
         Trample_Timer = 24000;
@@ -41,54 +47,65 @@ struct TRINITY_DLL_DECL boss_theravenianAI : public ScriptedAI
         KnockAway_Timer = 32000;
         HasYelled = false;
     }
+
     void JustDied(Unit *killer)
     {
         ScriptedInstance *pInstance = m_creature->GetInstanceData();
         if (pInstance)
         {
             pInstance->SetData(DATA_THERAVENIAN_DEATH, 0);
+
             if (pInstance->GetData(TYPE_GANDLING) == IN_PROGRESS)
                 m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0);
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new boss_theravenianAI (pCreature);
 }
+
 void AddSC_boss_theravenian()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_vectus.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_vectus.cpp
index e20ecf20b2f..f3eef33d24a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_vectus.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/boss_vectus.cpp
@@ -13,37 +13,46 @@
  * along with 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"
+
 enum eEnums
 {
     EMOTE_GENERIC_FRENZY_KILL   = -1000001,
+
     SPELL_FLAMESTRIKE            = 18399,
     SPELL_BLAST_WAVE             = 16046,
     SPELL_FIRESHIELD             = 19626,
     SPELL_FRENZY                 = 8269 //28371,
 };
+
 struct TRINITY_DLL_DECL boss_vectusAI : public ScriptedAI
 {
     boss_vectusAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 m_uiFireShield_Timer;
     uint32 m_uiBlastWave_Timer;
     uint32 m_uiFrenzy_Timer;
+
     void Reset()
     {
         m_uiFireShield_Timer = 2000;
         m_uiBlastWave_Timer = 14000;
         m_uiFrenzy_Timer = 0;
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         //FireShield_Timer
         if (m_uiFireShield_Timer < uiDiff)
         {
@@ -52,6 +61,7 @@ struct TRINITY_DLL_DECL boss_vectusAI : public ScriptedAI
         }
         else
             m_uiFireShield_Timer -= uiDiff;
+
         //BlastWave_Timer
         if (m_uiBlastWave_Timer < uiDiff)
         {
@@ -60,6 +70,7 @@ struct TRINITY_DLL_DECL boss_vectusAI : public ScriptedAI
         }
         else
             m_uiBlastWave_Timer -= uiDiff;
+
         //Frenzy_Timer
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 25)
         {
@@ -67,18 +78,22 @@ struct TRINITY_DLL_DECL boss_vectusAI : public ScriptedAI
             {
                 DoCast(m_creature, SPELL_FRENZY);
                 DoScriptText(EMOTE_GENERIC_FRENZY_KILL, m_creature);
+
                 m_uiFrenzy_Timer = 24000;
             }
             else
                 m_uiFrenzy_Timer -= uiDiff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_vectus(Creature* pCreature)
 {
     return new boss_vectusAI (pCreature);
 }
+
 void AddSC_boss_vectus()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/def_scholomance.h b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/def_scholomance.h
index beaae92bee8..83ce26c9687 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/def_scholomance.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/def_scholomance.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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 TYPE_GANDLING                       1
 #define DATA_DOCTORTHEOLENKRASTINOV_DEATH   2
 #define DATA_INSTRUCTORMALICIA_DEATH        3
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/instance_scholomance.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/instance_scholomance.cpp
index 4a56bf215f1..282d6e9705a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/instance_scholomance.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/scholomance/instance_scholomance.cpp
@@ -13,14 +13,17 @@
  * along 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"
+
 #define GO_GATE_KIRTONOS    175570
 #define GO_GATE_GANDLING    177374
 #define GO_GATE_MALICIA     177375
@@ -29,13 +32,17 @@ EndScriptData */
 #define GO_GATE_RAVENIAN    177372
 #define GO_GATE_BAROV       177373
 #define GO_GATE_ILLUCIA     177371
+
 #define MAX_ENCOUNTER          2
+
 struct TRINITY_DLL_DECL instance_scholomance : public ScriptedInstance
 {
     instance_scholomance(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     //Lord Alexei Barov, Doctor Theolen Krastinov, The Ravenian, Lorekeeper Polkelt, Instructor Malicia and the Lady Illucia Barov.
     bool IsBossDied[6];
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     uint64 GateKirtonosGUID;
     uint64 GateGandlingGUID;
     uint64 GateMiliciaGUID;
@@ -44,9 +51,11 @@ struct TRINITY_DLL_DECL instance_scholomance : public ScriptedInstance
     uint64 GateRavenianGUID;
     uint64 GateBarovGUID;
     uint64 GateIlluciaGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         GateKirtonosGUID = 0;
         GateGandlingGUID = 0;
         GateMiliciaGUID = 0;
@@ -55,9 +64,11 @@ struct TRINITY_DLL_DECL instance_scholomance : public ScriptedInstance
         GateRavenianGUID = 0;
         GateBarovGUID = 0;
         GateIlluciaGUID = 0;
-        for (uint8 i = 0; i < 6; ++i)
+
+        for(uint8 i = 0; i < 6; ++i)
             IsBossDied[i] = false;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -72,6 +83,7 @@ struct TRINITY_DLL_DECL instance_scholomance : public ScriptedInstance
             case GO_GATE_ILLUCIA:   GateIlluciaGUID = pGo->GetGUID(); break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -102,6 +114,7 @@ struct TRINITY_DLL_DECL instance_scholomance : public ScriptedInstance
                 break;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         if (type == TYPE_GANDLING)
@@ -112,13 +125,16 @@ struct TRINITY_DLL_DECL instance_scholomance : public ScriptedInstance
                 return IN_PROGRESS;
             }
         }
+
         return 0;
     }
 };
+
 InstanceData* GetInstanceData_instance_scholomance(Map* pMap)
 {
     return new instance_scholomance(pMap);
 }
+
 void AddSC_instance_scholomance()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/searing_gorge.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/searing_gorge.cpp
index a2797da6dbe..c6e18761ded 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/searing_gorge.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/searing_gorge.cpp
@@ -13,33 +13,43 @@
  * along 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
 ######*/
+
 #define GOSSIP_HELLO_KW    "Tell me what drives this vengance?"
 #define GOSSIP_SELECT_KW1  "Continue please"
 #define GOSSIP_SELECT_KW2  "Let me confer with my colleagues"
+
 bool GossipHello_npc_kalaran_windblade(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(3441) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_KW, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_kalaran_windblade(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -59,19 +69,26 @@ bool GossipSelect_npc_kalaran_windblade(Player* pPlayer, Creature* pCreature, ui
     }
     return true;
 }
+
 /*######
 ## npc_lothos_riftwaker
 ######*/
+
 #define GOSSIP_HELLO_LR "Teleport me to the Molten Core"
+
 bool GossipHello_npc_lothos_riftwaker(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestRewardStatus(7487) || pPlayer->GetQuestRewardStatus(7848))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_LR, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_lothos_riftwaker(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -79,23 +96,31 @@ bool GossipSelect_npc_lothos_riftwaker(Player* pPlayer, Creature* pCreature, uin
         pPlayer->CLOSE_GOSSIP_MENU();
         pPlayer->TeleportTo(409, 1096, -467, -104.6, 3.64);
     }
+
     return true;
 }
+
 /*######
 ## npc_zamael_lunthistle
 ######*/
+
 #define GOSSIP_HELLO_ZL     "Tell me your story"
 #define GOSSIP_SELECT_ZL1   "Please continue..."
 #define GOSSIP_SELECT_ZL2   "Goodbye"
+
 bool GossipHello_npc_zamael_lunthistle(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(3377) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_ZL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(1920, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_zamael_lunthistle(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -115,22 +140,27 @@ bool GossipSelect_npc_zamael_lunthistle(Player* pPlayer, Creature* pCreature, ui
     }
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_lothos_riftwaker";
     newscript->pGossipHello          = &GossipHello_npc_lothos_riftwaker;
     newscript->pGossipSelect         = &GossipSelect_npc_lothos_riftwaker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_zamael_lunthistle";
     newscript->pGossipHello =  &GossipHello_npc_zamael_lunthistle;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/def_shadowfang_keep.h b/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/def_shadowfang_keep.h
index d3a2dce833e..8383a5c3950 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/def_shadowfang_keep.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/def_shadowfang_keep.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/instance_shadowfang_keep.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/instance_shadowfang_keep.cpp
index b5381c1e685..29a8d04a1cb 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/instance_shadowfang_keep.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/instance_shadowfang_keep.cpp
@@ -13,44 +13,58 @@
  * along 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: 90
 SDComment:
 SDCategory: Shadowfang Keep
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_shadowfang_keep.h"
+
 #define MAX_ENCOUNTER              4
+
 enum eEnums
 {
     SAY_BOSS_DIE_AD         = -1033007,
     SAY_BOSS_DIE_AS         = -1033008,
+
     NPC_ASH                 = 3850,
     NPC_ADA                 = 3849,
+
     GO_COURTYARD_DOOR       = 18895,                        //door to open when talking to NPC's
     GO_SORCERER_DOOR        = 18972,                        //door to open when Fenrus the Devourer
     GO_ARUGAL_DOOR          = 18971                         //door to open when Wolf Master Nandos
 };
+
 struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
 {
     instance_shadowfang_keep(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     std::string str_data;
+
     uint64 uiAshGUID;
     uint64 uiAdaGUID;
+
     uint64 DoorCourtyardGUID;
     uint64 DoorSorcererGUID;
     uint64 DoorArugalGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         uiAshGUID = 0;
         uiAdaGUID = 0;
+
         DoorCourtyardGUID = 0;
         DoorSorcererGUID = 0;
         DoorArugalGUID = 0;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -59,6 +73,7 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
             case NPC_ADA: uiAdaGUID = pCreature->GetGUID(); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -80,16 +95,19 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
                 break;
         }
     }
+
     void DoSpeech()
     {
         Creature* pAda = instance->GetCreature(uiAdaGUID);
         Creature* pAsh = instance->GetCreature(uiAshGUID);
+
         if (pAda && pAda->isAlive() && pAsh && pAsh->isAlive())
         {
             DoScriptText(SAY_BOSS_DIE_AD,pAda);
             DoScriptText(SAY_BOSS_DIE_AS,pAsh);
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -115,16 +133,21 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
                 m_auiEncounter[3] = data;
                 break;
         }
+
         if (data == DONE)
         {
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
             saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " << m_auiEncounter[3];
+
             str_data = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -140,10 +163,12 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
         }
         return 0;
     }
+
     std::string GetSaveData()
     {
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -151,21 +176,27 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         std::istringstream loadStream(in);
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
         {
             if (m_auiEncounter[i] == IN_PROGRESS)
                 m_auiEncounter[i] = NOT_STARTED;
         }
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_shadowfang_keep(Map* pMap)
 {
     return new instance_shadowfang_keep(pMap);
 }
+
 void AddSC_instance_shadowfang_keep()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/shadowfang_keep.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/shadowfang_keep.cpp
index 6c3f0197466..dddf80ee4bb 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/shadowfang_keep.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/shadowfang_keep/shadowfang_keep.cpp
@@ -13,21 +13,26 @@
  * along 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 "escort_ai.h"
 #include "def_shadowfang_keep.h"
+
 /*######
 ## npc_shadowfang_prisoner
 ######*/
+
 enum eEnums
 {
     SAY_FREE_AS             = -1033000,
@@ -37,10 +42,13 @@ enum eEnums
     SAY_OPEN_DOOR_AD        = -1033004,
     SAY_POST1_DOOR_AD       = -1033005,
     SAY_POST2_DOOR_AD       = -1033006,
+
     SPELL_UNLOCK            = 6421,
     NPC_ASH                 = 3850
 };
+
 #define GOSSIP_ITEM_DOOR        "Thanks, I'll follow you to the door."
+
 struct TRINITY_DLL_DECL npc_shadowfang_prisonerAI : public npc_escortAI
 {
     npc_shadowfang_prisonerAI(Creature *c) : npc_escortAI(c)
@@ -48,8 +56,10 @@ struct TRINITY_DLL_DECL npc_shadowfang_prisonerAI : public npc_escortAI
         pInstance = c->GetInstanceData();
         uiNpcEntry = c->GetEntry();
     }
+
     ScriptedInstance *pInstance;
     uint32 uiNpcEntry;
+
     void WaypointReached(uint32 uiPoint)
     {
         switch(uiPoint)
@@ -75,6 +85,7 @@ struct TRINITY_DLL_DECL npc_shadowfang_prisonerAI : public npc_escortAI
                     DoScriptText(SAY_POST_DOOR_AS, m_creature);
                 else
                     DoScriptText(SAY_POST1_DOOR_AD, m_creature);
+
                 if (pInstance)
                     pInstance->SetData(TYPE_FREE_NPC, DONE);
                 break;
@@ -84,34 +95,44 @@ struct TRINITY_DLL_DECL npc_shadowfang_prisonerAI : public npc_escortAI
                 break;
         }
     }
+
     void Reset() {}
     void EnterCombat(Unit* who) {}
 };
+
 CreatureAI* GetAI_npc_shadowfang_prisoner(Creature* pCreature)
 {
     return new npc_shadowfang_prisonerAI(pCreature);
 }
+
 bool GossipHello_npc_shadowfang_prisoner(Player* pPlayer, Creature* pCreature)
 {
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
+
     if (pInstance && pInstance->GetData(TYPE_FREE_NPC) != DONE && pInstance->GetData(TYPE_RETHILGORE) == DONE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_DOOR, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_shadowfang_prisoner(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
     {
         pPlayer->CLOSE_GOSSIP_MENU();
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_shadowfang_prisonerAI, pCreature->AI()))
             pEscortAI->Start(false, false);
     }
     return true;
 }
+
 void AddSC_shadowfang_keep()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_shadowfang_prisoner";
     newscript->pGossipHello =  &GossipHello_npc_shadowfang_prisoner;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/silvermoon_city.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/silvermoon_city.cpp
index e69f8dfc71e..eb06008ed75 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/silvermoon_city.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/silvermoon_city.cpp
@@ -13,28 +13,37 @@
  * along 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 -1000334
+
 #define QUEST_REDEEMING_THE_DEAD        9685
 #define SPELL_SHIMMERING_VESSEL         31225
 #define SPELL_REVIVE_SELF               32343
+
 struct TRINITY_DLL_DECL npc_blood_knight_stillbladeAI : public ScriptedAI
 {
     npc_blood_knight_stillbladeAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 lifeTimer;
     bool spellHit;
+
     void Reset()
     {
         lifeTimer = 120000;
@@ -42,13 +51,16 @@ struct TRINITY_DLL_DECL npc_blood_knight_stillbladeAI : public ScriptedAI
         m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7);   // lay down
         spellHit = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         return;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (m_creature->IsStandState())
@@ -59,6 +71,7 @@ struct TRINITY_DLL_DECL npc_blood_knight_stillbladeAI : public ScriptedAI
                 lifeTimer -= diff;
         }
     }
+
     void SpellHit(Unit *Hitter, const SpellEntry *Spellkind)
     {
         if ((Spellkind->Id == SPELL_SHIMMERING_VESSEL) && !spellHit &&
@@ -74,10 +87,12 @@ struct TRINITY_DLL_DECL npc_blood_knight_stillbladeAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_blood_knight_stillblade(Creature* pCreature)
 {
     return new npc_blood_knight_stillbladeAI (pCreature);
 }
+
 void AddSC_silvermoon_city()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/silverpine_forest.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/silverpine_forest.cpp
index 453656b94c4..7a70d646fae 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/silverpine_forest.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/silverpine_forest.cpp
@@ -13,49 +13,63 @@
  * along 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, 435
 SDCategory: Silverpine Forest
 EndScriptData */
+
 /* ContentData
 npc_astor_hadren
 npc_deathstalker_erland
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_astor_hadren
 ######*/
+
 #define GOSSIP_HAH "You're Astor Hadren, right?"
 #define GOSSIP_SAH "You've got something I need, Astor. And I'll be taking it now."
+
 struct TRINITY_DLL_DECL npc_astor_hadrenAI : public ScriptedAI
 {
     npc_astor_hadrenAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         m_creature->setFaction(68);
     }
+
     void EnterCombat(Unit* who)
     {
     }
+
     void JustDied(Unit *who)
     {
         m_creature->setFaction(68);
     }
 };
+
 CreatureAI* GetAI_npc_astor_hadren(Creature* pCreature)
 {
     return new npc_astor_hadrenAI(pCreature);
 }
+
 bool GossipHello_npc_astor_hadren(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(1886) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HAH, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
     pPlayer->SEND_GOSSIP_MENU(623, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_astor_hadren(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -73,9 +87,11 @@ bool GossipSelect_npc_astor_hadren(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*######
 ## npc_deathstalker_erland
 ######*/
+
 enum eErland
 {
     SAY_QUESTACCEPT     = -1000335,
@@ -83,25 +99,32 @@ enum eErland
     SAY_AGGRO_1         = -1000337,
     SAY_AGGRO_2         = -1000338,
     SAY_LAST            = -1000339,
+
     SAY_THANKS          = -1000340,
     SAY_RANE            = -1000341,
     SAY_ANSWER          = -1000342,
     SAY_MOVE_QUINN      = -1000343,
+
     SAY_GREETINGS       = -1000344,
     SAY_QUINN           = -1000345,
     SAY_ON_BYE          = -1000346,
+
     QUEST_ESCORTING     = 435,
     NPC_RANE            = 1950,
     NPC_QUINN           = 1951
 };
+
 struct TRINITY_DLL_DECL npc_deathstalker_erlandAI : public npc_escortAI
 {
     npc_deathstalker_erlandAI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
         case 1: DoScriptText(SAY_START, m_creature, pPlayer);break;
@@ -123,40 +146,51 @@ struct TRINITY_DLL_DECL npc_deathstalker_erlandAI : public npc_escortAI
                     DoScriptText(SAY_QUINN, Quinn);
                 break;}
         case 26: DoScriptText(SAY_ON_BYE, m_creature, NULL);break;
+
         }
     }
+
     void Reset() {}
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2), m_creature, who);
     }
 };
+
 bool QuestAccept_npc_deathstalker_erland(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_ESCORTING)
     {
         DoScriptText(SAY_QUESTACCEPT, pCreature, pPlayer);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_deathstalker_erlandAI, pCreature->AI()))
             pEscortAI->Start(true, false, pPlayer->GetGUID());
     }
+
     return true;
 }
+
 CreatureAI* GetAI_npc_deathstalker_erlandAI(Creature* pCreature)
 {
     return new npc_deathstalker_erlandAI(pCreature);
 }
+
 /*######
 ## 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_deathstalker_erland";
     newscript->GetAI = &GetAI_npc_deathstalker_erlandAI;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stormwind_city.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stormwind_city.cpp
index e0f190b5a7b..5e495d6e1e6 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stormwind_city.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stormwind_city.cpp
@@ -13,32 +13,42 @@
  * along 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
 SDCategory: Stormwind City
 EndScriptData */
+
 /* ContentData
 npc_archmage_malin
 npc_bartleby
 npc_dashel_stonefist
 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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(11223) == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(11223))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_MALIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_archmage_malin(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
@@ -46,48 +56,60 @@ bool GossipSelect_npc_archmage_malin(Player* pPlayer, Creature* pCreature, uint3
         pPlayer->CLOSE_GOSSIP_MENU();
         pCreature->CastSpell(pPlayer, 42711, true);
     }
+
     return true;
 }
+
 /*######
 ## npc_bartleby
 ######*/
+
 enum eBartleby
 {
     FACTION_ENEMY       = 168,
     QUEST_BEAT          = 1640
 };
+
 struct TRINITY_DLL_DECL npc_bartlebyAI : public ScriptedAI
 {
     npc_bartlebyAI(Creature *c) : ScriptedAI(c)
     {
         m_uiNormalFaction = c->getFaction();
     }
+
     uint32 m_uiNormalFaction;
+
     void Reset()
     {
         if (m_creature->getFaction() != m_uiNormalFaction)
             m_creature->setFaction(m_uiNormalFaction);
     }
+
     void AttackedBy(Unit* pAttacker)
     {
         if (m_creature->getVictim())
             return;
+
         if (m_creature->IsFriendlyTo(pAttacker))
             return;
+
         AttackStart(pAttacker);
     }
+
     void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
     {
         if (uiDamage > m_creature->GetHealth() || ((m_creature->GetHealth() - uiDamage)*100 / m_creature->GetMaxHealth() < 15))
         {
             //Take 0 damage
             uiDamage = 0;
+
             if (pDoneBy->GetTypeId() == TYPEID_PLAYER)
                 CAST_PLR(pDoneBy)->AreaExploredOrEventHappens(QUEST_BEAT);
             EnterEvadeMode();
         }
     }
 };
+
 bool QuestAccept_npc_bartleby(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_BEAT)
@@ -97,49 +119,62 @@ bool QuestAccept_npc_bartleby(Player* pPlayer, Creature* pCreature, Quest const*
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_bartleby(Creature* pCreature)
 {
     return new npc_bartlebyAI(pCreature);
 }
+
 /*######
 ## npc_dashel_stonefist
 ######*/
+
 enum eDashel
 {
     QUEST_MISSING_DIPLO_PT8     = 1447,
     FACTION_HOSTILE             = 168
 };
+
 struct TRINITY_DLL_DECL npc_dashel_stonefistAI : public ScriptedAI
 {
     npc_dashel_stonefistAI(Creature *c) : ScriptedAI(c)
     {
         m_uiNormalFaction = c->getFaction();
     }
+
     uint32 m_uiNormalFaction;
+
     void Reset()
     {
         if (m_creature->getFaction() != m_uiNormalFaction)
             m_creature->setFaction(m_uiNormalFaction);
     }
+
     void AttackedBy(Unit* pAttacker)
     {
         if (m_creature->getVictim())
             return;
+
         if (m_creature->IsFriendlyTo(pAttacker))
             return;
+
         AttackStart(pAttacker);
     }
+
     void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
     {
         if (uiDamage > m_creature->GetHealth() || ((m_creature->GetHealth() - uiDamage)*100 / m_creature->GetMaxHealth() < 15))
         {
             uiDamage = 0;
+
             if (pDoneBy->GetTypeId() == TYPEID_PLAYER)
                 CAST_PLR(pDoneBy)->AreaExploredOrEventHappens(QUEST_MISSING_DIPLO_PT8);
+
             EnterEvadeMode();
         }
     }
 };
+
 bool QuestAccept_npc_dashel_stonefist(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_MISSING_DIPLO_PT8)
@@ -149,26 +184,34 @@ bool QuestAccept_npc_dashel_stonefist(Player* pPlayer, Creature* pCreature, Ques
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_dashel_stonefist(Creature* pCreature)
 {
     return new npc_dashel_stonefistAI(pCreature);
 }
+
 /*######
 ## 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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(4185) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KAT_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(2693, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_lady_katrana_prestor(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -192,24 +235,29 @@ bool GossipSelect_npc_lady_katrana_prestor(Player* pPlayer, Creature* pCreature,
     }
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_bartleby";
     newscript->GetAI = &GetAI_npc_bartleby;
     newscript->pQuestAccept = &QuestAccept_npc_bartleby;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_dashel_stonefist";
     newscript->GetAI = &GetAI_npc_dashel_stonefist;
     newscript->pQuestAccept = &QuestAccept_npc_dashel_stonefist;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_lady_katrana_prestor";
     newscript->pGossipHello = &GossipHello_npc_lady_katrana_prestor;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stranglethorn_vale.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stranglethorn_vale.cpp
index c8a43c7d5e9..6f2c787f950 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stranglethorn_vale.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stranglethorn_vale.cpp
@@ -13,32 +13,40 @@
  * along 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 TRINITY_DLL_DECL mob_yennikuAI : public ScriptedAI
 {
     mob_yennikuAI(Creature *c) : ScriptedAI(c)
     {
         bReset = false;
     }
+
     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)
@@ -50,13 +58,16 @@ struct TRINITY_DLL_DECL mob_yennikuAI : public ScriptedAI
                 m_creature->CombatStop();                   //stop combat
                 m_creature->DeleteThreatList();             //unsure of this
                 m_creature->setFaction(83);                 //horde generic
+
                 bReset = true;
                 Reset_Timer = 60000;
             }
         }
         return;
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (bReset)
@@ -69,6 +80,7 @@ struct TRINITY_DLL_DECL mob_yennikuAI : public ScriptedAI
                 return;
             }
             else Reset_Timer -= diff;
+
             if (m_creature->isInCombat() && m_creature->getVictim())
             {
                 if (m_creature->getVictim()->GetTypeId() == TYPEID_PLAYER)
@@ -82,9 +94,11 @@ struct TRINITY_DLL_DECL mob_yennikuAI : public ScriptedAI
                 }
             }
          }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -92,12 +106,15 @@ CreatureAI* GetAI_mob_yenniku(Creature* pCreature)
 {
     return new mob_yennikuAI (pCreature);
 }
+
 /*######
 ##
 ######*/
+
 void AddSC_stranglethorn_vale()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_yenniku";
     newscript->GetAI = &GetAI_mob_yenniku;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_baron_rivendare.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_baron_rivendare.cpp
index aaf4f754f35..e5f33d7a086 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_baron_rivendare.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_baron_rivendare.cpp
@@ -13,68 +13,84 @@
 * along with 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: 70
 SDComment: aura applied/defined in database
 SDCategory: Stratholme
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_stratholme.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    17393
 #define SPELL_CLEAVE        15284
 #define SPELL_MORTALSTRIKE  15708
+
 #define SPELL_UNHOLY_AURA   17467
 #define SPELL_RAISEDEAD     17473                           //triggers death pact (17471)
+
 #define SPELL_RAISE_DEAD1   17475
 #define SPELL_RAISE_DEAD2   17476
 #define SPELL_RAISE_DEAD3   17477
 #define SPELL_RAISE_DEAD4   17478
 #define SPELL_RAISE_DEAD5   17479
 #define SPELL_RAISE_DEAD6   17480
+
 struct TRINITY_DLL_DECL boss_baron_rivendareAI : public ScriptedAI
 {
     boss_baron_rivendareAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 ShadowBolt_Timer;
     uint32 Cleave_Timer;
     uint32 MortalStrike_Timer;
     //    uint32 RaiseDead_Timer;
     uint32 SummonSkeletons_Timer;
     Creature *Summoned;
+
     void Reset()
     {
         ShadowBolt_Timer = 5000;
@@ -85,33 +101,40 @@ struct TRINITY_DLL_DECL boss_baron_rivendareAI : public ScriptedAI
         if (pInstance && pInstance->GetData(TYPE_RAMSTEIN) == DONE)
             pInstance->SetData(TYPE_BARON,NOT_STARTED);
     }
+
     void AttackStart(Unit* who)
     {
-        if (pInstance) //can't use entercombat(), boss' dmg aura sets near players in combat, before entering the room's door
+        if (pInstance)//can't use entercombat(), boss' dmg aura sets near players in combat, before entering the room's door
             pInstance->SetData(TYPE_BARON,IN_PROGRESS);
         ScriptedAI::AttackStart(who);
     }
+
     void JustSummoned(Creature* summoned)
     {
         if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
              summoned->AI()->AttackStart(target);
     }
+
      void JustDied(Unit* Killer)
      {
          if (pInstance)
              pInstance->SetData(TYPE_BARON,DONE);
      }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //ShadowBolt
         if (ShadowBolt_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT);
+
             ShadowBolt_Timer = 10000;
         }else ShadowBolt_Timer -= diff;
+
         //Cleave
         if (Cleave_Timer < diff)
         {
@@ -119,18 +142,21 @@ struct TRINITY_DLL_DECL boss_baron_rivendareAI : public ScriptedAI
             //13 seconds until we should cast this again
             Cleave_Timer = 7000 + (rand()%10000);
         }else Cleave_Timer -= diff;
+
         //MortalStrike
         if (MortalStrike_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE);
             MortalStrike_Timer = 10000 + (rand()%15000);
         }else MortalStrike_Timer -= diff;
+
         //RaiseDead
         //            if (RaiseDead_Timer < diff)
         //          {
         //      DoCast(m_creature,SPELL_RAISEDEAD);
         //                RaiseDead_Timer = 45000;
         //            }else RaiseDead_Timer -= diff;
+
         //SummonSkeletons
         if (SummonSkeletons_Timer < diff)
         {
@@ -140,16 +166,20 @@ struct TRINITY_DLL_DECL boss_baron_rivendareAI : public ScriptedAI
             m_creature->SummonCreature(11197,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,29000);
             m_creature->SummonCreature(11197,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,29000);
             m_creature->SummonCreature(11197,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,29000);
+
             //34 seconds until we should cast this again
             SummonSkeletons_Timer = 40000;
         }else SummonSkeletons_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_baron_rivendare(Creature* pCreature)
 {
     return new boss_baron_rivendareAI (pCreature);
 }
+
 void AddSC_boss_baron_rivendare()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_baroness_anastari.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_baroness_anastari.cpp
index 897a2aef8e5..ba5c2ec0521 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_baroness_anastari.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_baroness_anastari.cpp
@@ -13,29 +13,36 @@
 * along with 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"
 #include "def_stratholme.h"
+
 #define SPELL_BANSHEEWAIL   16565
 #define SPELL_BANSHEECURSE    16867
 #define SPELL_SILENCE    18327
 //#define SPELL_POSSESS   17244
+
 struct TRINITY_DLL_DECL boss_baroness_anastariAI : public ScriptedAI
 {
     boss_baroness_anastariAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 BansheeWail_Timer;
     uint32 BansheeCurse_Timer;
     uint32 Silence_Timer;
     //uint32 Possess_Timer;
+
     void Reset()
     {
         BansheeWail_Timer = 1000;
@@ -43,18 +50,22 @@ struct TRINITY_DLL_DECL boss_baroness_anastariAI : public ScriptedAI
         Silence_Timer = 13000;
         //Possess_Timer = 35000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
      void JustDied(Unit* Killer)
      {
          if (pInstance)
              pInstance->SetData(TYPE_BARONESS,IN_PROGRESS);
      }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //BansheeWail
         if (BansheeWail_Timer < diff)
         {
@@ -63,6 +74,7 @@ struct TRINITY_DLL_DECL boss_baroness_anastariAI : public ScriptedAI
             //4 seconds until we should cast this again
             BansheeWail_Timer = 4000;
         }else BansheeWail_Timer -= diff;
+
         //BansheeCurse
         if (BansheeCurse_Timer < diff)
         {
@@ -71,6 +83,7 @@ struct TRINITY_DLL_DECL boss_baroness_anastariAI : public ScriptedAI
             //18 seconds until we should cast this again
             BansheeCurse_Timer = 18000;
         }else BansheeCurse_Timer -= diff;
+
         //Silence
         if (Silence_Timer < diff)
         {
@@ -79,6 +92,7 @@ struct TRINITY_DLL_DECL boss_baroness_anastariAI : public ScriptedAI
             //13 seconds until we should cast this again
             Silence_Timer = 13000;
         }else Silence_Timer -= diff;
+
         //Possess
         /*            if (Possess_Timer < diff)
         {
@@ -93,6 +107,7 @@ struct TRINITY_DLL_DECL boss_baroness_anastariAI : public ScriptedAI
         Possess_Timer = 50000;
         }else Possess_Timer -= diff;
         */
+
         DoMeleeAttackIfReady();
     }
 };
@@ -100,6 +115,7 @@ CreatureAI* GetAI_boss_baroness_anastari(Creature* pCreature)
 {
     return new boss_baroness_anastariAI (pCreature);
 }
+
 void AddSC_boss_baroness_anastari()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_cannon_master_willey.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_cannon_master_willey.cpp
index 5586693df80..69ff09067f5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_cannon_master_willey.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_cannon_master_willey.cpp
@@ -13,13 +13,16 @@
 * along with 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
@@ -65,17 +68,21 @@ EndScriptData */
 #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    16496
 //#define SPELL_SUMMONCRIMSONRIFLEMAN    17279
+
 struct TRINITY_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI
 {
     boss_cannon_master_willeyAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 KnockAway_Timer;
     uint32 Pummel_Timer;
     uint32 Shoot_Timer;
     uint32 SummonRifleman_Timer;
+
     void Reset()
     {
         Shoot_Timer = 1000;
@@ -83,6 +90,7 @@ struct TRINITY_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI
         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);
@@ -93,15 +101,18 @@ struct TRINITY_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI
         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 EnterCombat(Unit *who)
     {
     }
 
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Pummel
         if (Pummel_Timer < diff)
         {
@@ -113,6 +124,7 @@ struct TRINITY_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI
             //12 seconds until we should cast this again
             Pummel_Timer = 12000;
         }else Pummel_Timer -= diff;
+
         //KnockAway
         if (KnockAway_Timer < diff)
         {
@@ -124,6 +136,7 @@ struct TRINITY_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI
             //14 seconds until we should cast this again
             KnockAway_Timer = 14000;
         }else KnockAway_Timer -= diff;
+
         //Shoot
         if (Shoot_Timer < diff)
         {
@@ -132,6 +145,7 @@ struct TRINITY_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI
             //1 seconds until we should cast this again
             Shoot_Timer = 1000;
         }else Shoot_Timer -= diff;
+
         //SummonRifleman
         if (SummonRifleman_Timer < diff)
         {
@@ -187,6 +201,7 @@ struct TRINITY_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI
             //30 seconds until we should cast this again
             SummonRifleman_Timer = 30000;
         }else SummonRifleman_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -194,6 +209,7 @@ CreatureAI* GetAI_boss_cannon_master_willey(Creature* pCreature)
 {
     return new boss_cannon_master_willeyAI (pCreature);
 }
+
 void AddSC_boss_cannon_master_willey()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_dathrohan_balnazzar.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_dathrohan_balnazzar.cpp
index 86978181dd7..91477d3fef5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_dathrohan_balnazzar.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_dathrohan_balnazzar.cpp
@@ -13,49 +13,60 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
+
 /* ScriptData
 SDName: Boss_Dathrohan_Balnazzar
 SD%Complete: 95
 SDComment: Possibly need to fix/improve summons after death
 SDCategory: Stratholme
 EndScriptData */
+
 #include "precompiled.h"
+
 enum eEnums
 {
     //Dathrohan spells
     SPELL_CRUSADERSHAMMER           = 17286,                //AOE stun
     SPELL_CRUSADERSTRIKE            = 17281,
     SPELL_HOLYSTRIKE                = 17284,                //weapon dmg +3
+
     //Transform
     SPELL_BALNAZZARTRANSFORM        = 17288,                //restore full HP/mana, trigger spell Balnazzar Transform Stun
+
     //Balnazzar spells
     SPELL_SHADOWSHOCK               = 17399,
     SPELL_MINDBLAST                 = 17287,
     SPELL_PSYCHICSCREAM             = 13704,
     SPELL_SLEEP                     = 12098,
     SPELL_MINDCONTROL               = 15690,
+
     NPC_DATHROHAN                   = 10812,
     NPC_BALNAZZAR                   = 10813,
     NPC_ZOMBIE                      = 10698                 //probably incorrect
 };
+
 struct SummonDef
 {
     float m_fX, m_fY, m_fZ, m_fOrient;
 };
+
 SummonDef m_aSummonPoint[]=
 {
     {3444.156, -3090.626, 135.002, 2.240},                  //G1 front, left
     {3449.123, -3087.009, 135.002, 2.240},                  //G1 front, right
     {3446.246, -3093.466, 135.002, 2.240},                  //G1 back left
     {3451.160, -3089.904, 135.002, 2.240},                  //G1 back, right
+
     {3457.995, -3080.916, 135.002, 3.784},                  //G2 front, left
     {3454.302, -3076.330, 135.002, 3.784},                  //G2 front, right
     {3460.975, -3078.901, 135.002, 3.784},                  //G2 back left
     {3457.338, -3073.979, 135.002, 3.784}                   //G2 back, right
 };
+
 struct TRINITY_DLL_DECL boss_dathrohan_balnazzarAI : public ScriptedAI
 {
     boss_dathrohan_balnazzarAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 m_uiCrusadersHammer_Timer;
     uint32 m_uiCrusaderStrike_Timer;
     uint32 m_uiMindBlast_Timer;
@@ -65,6 +76,7 @@ struct TRINITY_DLL_DECL boss_dathrohan_balnazzarAI : public ScriptedAI
     uint32 m_uiDeepSleep_Timer;
     uint32 m_uiMindControl_Timer;
     bool m_bTransformed;
+
     void Reset()
     {
         m_uiCrusadersHammer_Timer = 8000;
@@ -76,24 +88,30 @@ struct TRINITY_DLL_DECL boss_dathrohan_balnazzarAI : public ScriptedAI
         m_uiDeepSleep_Timer = 20000;
         m_uiMindControl_Timer = 10000;
         m_bTransformed = false;
+
         if (m_creature->GetEntry() == NPC_BALNAZZAR)
             m_creature->UpdateEntry(NPC_DATHROHAN);
     }
+
     void JustDied(Unit* Victim)
     {
         static uint32 uiCount = sizeof(m_aSummonPoint)/sizeof(SummonDef);
+
         for (uint8 i=0; iSummonCreature(NPC_ZOMBIE,
             m_aSummonPoint[i].m_fX, m_aSummonPoint[i].m_fY, m_aSummonPoint[i].m_fZ, m_aSummonPoint[i].m_fOrient,
             TEMPSUMMON_TIMED_DESPAWN, HOUR*IN_MILISECONDS);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         //START NOT TRANSFORMED
         if (!m_bTransformed)
         {
@@ -103,29 +121,34 @@ struct TRINITY_DLL_DECL boss_dathrohan_balnazzarAI : public ScriptedAI
                 DoCast(m_creature->getVictim(),SPELL_MINDBLAST);
                 m_uiMindBlast_Timer = 15000 + rand()%5000;
             }else m_uiMindBlast_Timer -= uiDiff;
+
             //CrusadersHammer
             if (m_uiCrusadersHammer_Timer < uiDiff)
             {
                 DoCast(m_creature->getVictim(),SPELL_CRUSADERSHAMMER);
                 m_uiCrusadersHammer_Timer = 12000;
             }else m_uiCrusadersHammer_Timer -= uiDiff;
+
             //CrusaderStrike
             if (m_uiCrusaderStrike_Timer < uiDiff)
             {
                 DoCast(m_creature->getVictim(),SPELL_CRUSADERSTRIKE);
                 m_uiCrusaderStrike_Timer = 15000;
             }else m_uiCrusaderStrike_Timer -= uiDiff;
+
             //HolyStrike
             if (m_uiHolyStrike_Timer < uiDiff)
             {
                 DoCast(m_creature->getVictim(),SPELL_HOLYSTRIKE);
                 m_uiHolyStrike_Timer = 15000;
             }else m_uiHolyStrike_Timer -= uiDiff;
+
             //BalnazzarTransform
             if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40)
             {
                 if (m_creature->IsNonMeleeSpellCasted(false))
                     m_creature->InterruptNonMeleeSpells(false);
+
                 //restore hp, mana and stun
                 DoCast(m_creature,SPELL_BALNAZZARTRANSFORM);
                 m_creature->UpdateEntry(NPC_BALNAZZAR);
@@ -140,26 +163,32 @@ struct TRINITY_DLL_DECL boss_dathrohan_balnazzarAI : public ScriptedAI
                 DoCast(m_creature->getVictim(),SPELL_MINDBLAST);
                 m_uiMindBlast_Timer = 15000 + rand()%5000;
             }else m_uiMindBlast_Timer -= uiDiff;
+
             //ShadowShock
             if (m_uiShadowShock_Timer < uiDiff)
             {
                 DoCast(m_creature->getVictim(),SPELL_SHADOWSHOCK);
                 m_uiShadowShock_Timer = 11000;
             }else m_uiShadowShock_Timer -= uiDiff;
+
             //PsychicScream
             if (m_uiPsychicScream_Timer < uiDiff)
             {
                 if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
                     DoCast(pTarget,SPELL_PSYCHICSCREAM);
+
                 m_uiPsychicScream_Timer = 20000;
             }else m_uiPsychicScream_Timer -= uiDiff;
+
             //DeepSleep
             if (m_uiDeepSleep_Timer < uiDiff)
             {
                 if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
                     DoCast(pTarget,SPELL_SLEEP);
+
                 m_uiDeepSleep_Timer = 15000;
             }else m_uiDeepSleep_Timer -= uiDiff;
+
             //MindControl
             if (m_uiMindControl_Timer < uiDiff)
             {
@@ -167,13 +196,16 @@ struct TRINITY_DLL_DECL boss_dathrohan_balnazzarAI : public ScriptedAI
                 m_uiMindControl_Timer = 15000;
             }else m_uiMindControl_Timer -= uiDiff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_dathrohan_balnazzar(Creature* pCreature)
 {
     return new boss_dathrohan_balnazzarAI (pCreature);
 }
+
 void AddSC_boss_dathrohan_balnazzar()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_magistrate_barthilas.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_magistrate_barthilas.cpp
index 439e104b8ef..c1fe3220b9e 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_magistrate_barthilas.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_magistrate_barthilas.cpp
@@ -13,28 +13,35 @@
 * along with 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: 70
 SDComment:
 SDCategory: Stratholme
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_stratholme.h"
+
 #define SPELL_DRAININGBLOW    16793
 #define SPELL_CROWDPUMMEL    10887
 #define SPELL_MIGHTYBLOW    14099
 #define SPELL_FURIOUS_ANGER     16791
+
 #define MODEL_NORMAL            10433
 #define MODEL_HUMAN             3637
+
 struct TRINITY_DLL_DECL boss_magistrate_barthilasAI : public ScriptedAI
 {
     boss_magistrate_barthilasAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 DrainingBlow_Timer;
     uint32 CrowdPummel_Timer;
     uint32 MightyBlow_Timer;
     uint32 FuriousAnger_Timer;
     uint32 AngerCount;
+
     void Reset()
     {
         DrainingBlow_Timer = 20000;
@@ -42,54 +49,66 @@ struct TRINITY_DLL_DECL boss_magistrate_barthilasAI : public ScriptedAI
         MightyBlow_Timer = 10000;
         FuriousAnger_Timer = 5000;
         AngerCount = 0;
+
         if (m_creature->isAlive())
             m_creature->SetDisplayId(MODEL_NORMAL);
         else
             m_creature->SetDisplayId(MODEL_HUMAN);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         //nothing to see here yet
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void JustDied(Unit* Killer)
     {
         m_creature->SetDisplayId(MODEL_HUMAN);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (FuriousAnger_Timer < diff)
         {
             FuriousAnger_Timer = 4000;
             if (AngerCount > 25)
                 return;
+
             ++AngerCount;
             m_creature->CastSpell(m_creature,SPELL_FURIOUS_ANGER,false);
         }else FuriousAnger_Timer -= diff;
+
         //DrainingBlow
         if (DrainingBlow_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_DRAININGBLOW);
             DrainingBlow_Timer = 15000;
         }else DrainingBlow_Timer -= diff;
+
         //CrowdPummel
         if (CrowdPummel_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_CROWDPUMMEL);
             CrowdPummel_Timer = 15000;
         }else CrowdPummel_Timer -= diff;
+
         //MightyBlow
         if (MightyBlow_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW);
             MightyBlow_Timer = 20000;
         }else MightyBlow_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -97,6 +116,7 @@ CreatureAI* GetAI_boss_magistrate_barthilas(Creature* pCreature)
 {
     return new boss_magistrate_barthilasAI (pCreature);
 }
+
 void AddSC_boss_magistrate_barthilas()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_maleki_the_pallid.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_maleki_the_pallid.cpp
index 1af71d380da..e5e31e20704 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_maleki_the_pallid.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_maleki_the_pallid.cpp
@@ -13,47 +13,58 @@
 * along with 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"
 #include "def_stratholme.h"
+
 #define SPELL_FROSTBOLT    17503
 #define SPELL_DRAINLIFE    20743
 #define SPELL_DRAIN_MANA    17243
 #define SPELL_ICETOMB    16869
+
 struct TRINITY_DLL_DECL boss_maleki_the_pallidAI : public ScriptedAI
 {
     boss_maleki_the_pallidAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 Frostbolt_Timer;
     uint32 IceTomb_Timer;
     uint32 DrainLife_Timer;
+
     void Reset()
     {
         Frostbolt_Timer = 1000;
         IceTomb_Timer = 16000;
         DrainLife_Timer = 31000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
             pInstance->SetData(TYPE_PALLID,IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Frostbolt
         if (Frostbolt_Timer < diff)
         {
@@ -61,6 +72,7 @@ struct TRINITY_DLL_DECL boss_maleki_the_pallidAI : public ScriptedAI
                 DoCast(m_creature->getVictim(),SPELL_FROSTBOLT);
             Frostbolt_Timer = 3500;
         }else Frostbolt_Timer -= diff;
+
         //IceTomb
         if (IceTomb_Timer < diff)
         {
@@ -68,6 +80,7 @@ struct TRINITY_DLL_DECL boss_maleki_the_pallidAI : public ScriptedAI
                 DoCast(m_creature->getVictim(),SPELL_ICETOMB);
             IceTomb_Timer = 28000;
         }else IceTomb_Timer -= diff;
+
         //DrainLife
         if (DrainLife_Timer < diff)
         {
@@ -75,6 +88,7 @@ struct TRINITY_DLL_DECL boss_maleki_the_pallidAI : public ScriptedAI
                 DoCast(m_creature->getVictim(),SPELL_DRAINLIFE);
             DrainLife_Timer = 31000;
         }else DrainLife_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -82,6 +96,7 @@ CreatureAI* GetAI_boss_maleki_the_pallid(Creature* pCreature)
 {
     return new boss_maleki_the_pallidAI (pCreature);
 }
+
 void AddSC_boss_maleki_the_pallid()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_nerubenkan.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_nerubenkan.cpp
index 465b7c4a272..f051208c287 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_nerubenkan.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_nerubenkan.cpp
@@ -13,25 +13,31 @@
 * along with 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: 70
 SDComment:
 SDCategory: Stratholme
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_stratholme.h"
+
 #define SPELL_ENCASINGWEBS          4962
 #define SPELL_PIERCEARMOR           6016
 #define SPELL_CRYPT_SCARABS         31602
 #define SPELL_RAISEUNDEADSCARAB     17235
+
 struct TRINITY_DLL_DECL boss_nerubenkanAI : public ScriptedAI
 {
     boss_nerubenkanAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 EncasingWebs_Timer;
     uint32 PierceArmor_Timer;
    uint32 CryptScarabs_Timer;
@@ -40,6 +46,7 @@ struct TRINITY_DLL_DECL boss_nerubenkanAI : public ScriptedAI
     int RandX;
     int RandY;
     Creature* Summoned;
+
     void Reset()
     {
        CryptScarabs_Timer = 3000;
@@ -47,14 +54,17 @@ struct TRINITY_DLL_DECL boss_nerubenkanAI : public ScriptedAI
         PierceArmor_Timer = 19000;
         RaiseUndeadScarab_Timer = 3000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
             pInstance->SetData(TYPE_NERUB,IN_PROGRESS);
     }
+
     void RaiseUndeadScarab(Unit* victim)
     {
         Rand = rand()%10;
@@ -75,16 +85,19 @@ struct TRINITY_DLL_DECL boss_nerubenkanAI : public ScriptedAI
         if (Summoned)
             (Summoned->AI())->AttackStart(victim);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //EncasingWebs
         if (EncasingWebs_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_ENCASINGWEBS);
             EncasingWebs_Timer = 30000;
         }else EncasingWebs_Timer -= diff;
+
         //PierceArmor
         if (PierceArmor_Timer < diff)
         {
@@ -92,18 +105,21 @@ struct TRINITY_DLL_DECL boss_nerubenkanAI : public ScriptedAI
                 DoCast(m_creature->getVictim(),SPELL_PIERCEARMOR);
             PierceArmor_Timer = 35000;
         }else PierceArmor_Timer -= diff;
+
         //CryptScarabs_Timer
         if (CryptScarabs_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_CRYPT_SCARABS);
             CryptScarabs_Timer = 20000;
         }else CryptScarabs_Timer -= diff;
+
         //RaiseUndeadScarab
         if (RaiseUndeadScarab_Timer < diff)
         {
             RaiseUndeadScarab(m_creature->getVictim());
             RaiseUndeadScarab_Timer = 16000;
         }else RaiseUndeadScarab_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -111,6 +127,7 @@ CreatureAI* GetAI_boss_nerubenkan(Creature* pCreature)
 {
     return new boss_nerubenkanAI (pCreature);
 }
+
 void AddSC_boss_nerubenkan()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_order_of_silver_hand.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_order_of_silver_hand.cpp
index 63e0da6143b..4cbbe273a65 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_order_of_silver_hand.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_order_of_silver_hand.cpp
@@ -13,41 +13,51 @@
 * along with 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 TRINITY_DLL_DECL boss_silver_hand_bossesAI : public ScriptedAI
 {
     boss_silver_hand_bossesAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 HolyLight_Timer;
     uint32 DivineShield_Timer;
+
     void Reset()
     {
         HolyLight_Timer = 20000;
         DivineShield_Timer = 20000;
+
         if (pInstance)
         {
             switch(m_creature->GetEntry())
@@ -70,9 +80,11 @@ struct TRINITY_DLL_DECL boss_silver_hand_bossesAI : public ScriptedAI
             }
         }
     }
+
     void EnterCombat(Unit* who)
     {
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
@@ -99,11 +111,13 @@ struct TRINITY_DLL_DECL boss_silver_hand_bossesAI : public ScriptedAI
                 CAST_PLR(Killer)->KilledMonsterCredit(SH_QUEST_CREDIT,m_creature->GetGUID());
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (HolyLight_Timer < diff)
         {
             if (m_creature->GetHealth()*5 < m_creature->GetMaxHealth())
@@ -112,6 +126,7 @@ struct TRINITY_DLL_DECL boss_silver_hand_bossesAI : public ScriptedAI
                 HolyLight_Timer = 20000;
             }
         }else HolyLight_Timer -= diff;
+
         if (DivineShield_Timer < diff)
         {
             if (m_creature->GetHealth()*20 < m_creature->GetMaxHealth())
@@ -120,16 +135,20 @@ struct TRINITY_DLL_DECL boss_silver_hand_bossesAI : public ScriptedAI
                 DivineShield_Timer = 40000;
             }
         }else DivineShield_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
 };
 CreatureAI* GetAI_boss_silver_hand_bossesAI(Creature* pCreature)
 {
     return new boss_silver_hand_bossesAI (pCreature);
 }
+
 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;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_postmaster_malown.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_postmaster_malown.cpp
index e2c6fcb3312..ef43c7774bc 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_postmaster_malown.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_postmaster_malown.cpp
@@ -13,30 +13,38 @@
 * along with 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 TRINITY_DLL_DECL boss_postmaster_malownAI : public ScriptedAI
 {
     boss_postmaster_malownAI(Creature *c) : ScriptedAI(c) {}
+
     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
@@ -46,14 +54,17 @@ struct TRINITY_DLL_DECL boss_postmaster_malownAI : public ScriptedAI
         CallOfTheGrave_Timer = 25000;
         HasYelled = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //WailingDead
         if (WailingDead_Timer < diff)
         {
@@ -65,6 +76,7 @@ struct TRINITY_DLL_DECL boss_postmaster_malownAI : public ScriptedAI
             //19 seconds until we should cast this again
             WailingDead_Timer = 19000;
         }else WailingDead_Timer -= diff;
+
         //Backhand
         if (Backhand_Timer < diff)
         {
@@ -76,6 +88,7 @@ struct TRINITY_DLL_DECL boss_postmaster_malownAI : public ScriptedAI
             //8 seconds until we should cast this again
             Backhand_Timer = 8000;
         }else Backhand_Timer -= diff;
+
         //CurseOfWeakness
         if (CurseOfWeakness_Timer < diff)
         {
@@ -87,6 +100,7 @@ struct TRINITY_DLL_DECL boss_postmaster_malownAI : public ScriptedAI
             //20 seconds until we should cast this again
             CurseOfWeakness_Timer = 20000;
         }else CurseOfWeakness_Timer -= diff;
+
         //CurseOfTongues
         if (CurseOfTongues_Timer < diff)
         {
@@ -98,6 +112,7 @@ struct TRINITY_DLL_DECL boss_postmaster_malownAI : public ScriptedAI
             //22 seconds until we should cast this again
             CurseOfTongues_Timer = 22000;
         }else CurseOfTongues_Timer -= diff;
+
         //CallOfTheGrave
         if (CallOfTheGrave_Timer < diff)
         {
@@ -109,6 +124,7 @@ struct TRINITY_DLL_DECL boss_postmaster_malownAI : public ScriptedAI
             //25 seconds until we should cast this again
             CallOfTheGrave_Timer = 25000;
         }else CallOfTheGrave_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -116,6 +132,7 @@ CreatureAI* GetAI_boss_postmaster_malown(Creature* pCreature)
 {
     return new boss_postmaster_malownAI (pCreature);
 }
+
 void AddSC_boss_postmaster_malown()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_ramstein_the_gorger.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_ramstein_the_gorger.cpp
index a65022ac629..bac18320293 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_ramstein_the_gorger.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_ramstein_the_gorger.cpp
@@ -13,61 +13,76 @@
 * along with 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: 70
 SDComment:
 SDCategory: Stratholme
 EndScriptData */
+
 #include "precompiled.h"
  #include "def_stratholme.h"
+
 #define SPELL_TRAMPLE       5568
 #define SPELL_KNOCKOUT    17307
+
  #define C_MINDLESS_UNDEAD   11030
+
 struct TRINITY_DLL_DECL boss_ramstein_the_gorgerAI : public ScriptedAI
 {
     boss_ramstein_the_gorgerAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 Trample_Timer;
     uint32 Knockout_Timer;
+
     void Reset()
     {
         Trample_Timer = 3000;
         Knockout_Timer = 12000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void JustDied(Unit* Killer)
     {
-        for (uint8 i = 0; i < 30; ++i)
+        for(uint8 i = 0; i < 30; ++i)
         {
             if (Creature* mob = m_creature->SummonCreature(C_MINDLESS_UNDEAD,3969.35+irand(-10,10),-3391.87+irand(-10,10),119.11,5.91,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000))
                 mob->AI()->AttackStart(m_creature->SelectNearestTarget(500));
         }
+
         if (pInstance)
             pInstance->SetData(TYPE_RAMSTEIN,DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Trample
         if (Trample_Timer < diff)
         {
             DoCast(m_creature,SPELL_TRAMPLE);
             Trample_Timer = 7000;
         }else Trample_Timer -= diff;
+
         //Knockout
         if (Knockout_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_KNOCKOUT);
             Knockout_Timer = 10000;
         }else Knockout_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -75,6 +90,7 @@ CreatureAI* GetAI_boss_ramstein_the_gorger(Creature* pCreature)
 {
     return new boss_ramstein_the_gorgerAI (pCreature);
 }
+
 void AddSC_boss_ramstein_the_gorger()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_timmy_the_cruel.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_timmy_the_cruel.cpp
index 140b8725841..e6e96c3a776 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_timmy_the_cruel.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/boss_timmy_the_cruel.cpp
@@ -13,25 +13,33 @@
 * along with 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 TRINITY_DLL_DECL boss_timmy_the_cruelAI : public ScriptedAI
 {
     boss_timmy_the_cruelAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 RavenousClaw_Timer;
     bool HasYelled;
+
     void Reset()
     {
         RavenousClaw_Timer = 10000;
         HasYelled = false;
     }
+
     void EnterCombat(Unit *who)
     {
         if (!HasYelled)
@@ -40,11 +48,13 @@ struct TRINITY_DLL_DECL boss_timmy_the_cruelAI : public ScriptedAI
             HasYelled = true;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //RavenousClaw
         if (RavenousClaw_Timer < diff)
         {
@@ -53,6 +63,7 @@ struct TRINITY_DLL_DECL boss_timmy_the_cruelAI : public ScriptedAI
             //15 seconds until we should cast this again
             RavenousClaw_Timer = 15000;
         }else RavenousClaw_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -60,6 +71,7 @@ CreatureAI* GetAI_boss_timmy_the_cruel(Creature* pCreature)
 {
     return new boss_timmy_the_cruelAI (pCreature);
 }
+
 void AddSC_boss_timmy_the_cruel()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/def_stratholme.h b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/def_stratholme.h
index 2f05f55f556..b9246091a7c 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/def_stratholme.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/def_stratholme.h
@@ -1,22 +1,27 @@
 /* Copyright (C) 2006 - 2009 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_BARON_RUN          1
 #define TYPE_BARONESS           2
 #define TYPE_NERUB              3
 #define TYPE_PALLID             4
 #define TYPE_RAMSTEIN           5
 #define TYPE_BARON              6
+
 #define DATA_BARON              10
 #define DATA_YSIDA_TRIGGER      11
+
 #define TYPE_SH_QUEST           20
 #define TYPE_SH_CATHELA         21
 #define TYPE_SH_GREGOR          22
 #define TYPE_SH_NEMAS           23
 #define TYPE_SH_VICAR           24
 #define TYPE_SH_AELMAR          25
+
 #define QUEST_DEAD_MAN_PLEA     8945
 #define SPELL_BARON_ULTIMATUM   27861
 #endif
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/instance_stratholme.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/instance_stratholme.cpp
index 6a56d2ca865..d475e116039 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/instance_stratholme.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/instance_stratholme.cpp
@@ -13,14 +13,17 @@
 * along 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: 50
 SDComment: In progress. Undead side 75% implemented. Save/load not implemented.
 SDCategory: Stratholme
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_stratholme.h"
+
 #define GO_SERVICE_ENTRANCE     175368
 #define GO_GAUNTLET_GATE1       175357
 #define GO_ZIGGURAT1            175380                      //baroness
@@ -31,22 +34,30 @@ EndScriptData */
 #define GO_PORT_GAUNTLET        175374                      //port from gauntlet to slaugther
 #define GO_PORT_SLAUGTHER       175373                      //port at slaugther
 #define GO_PORT_ELDERS          175377                      //port at elders square
+
 #define C_CRYSTAL               10415                       //three ziggurat crystals
 #define C_BARON                 10440
 #define C_YSIDA_TRIGGER         16100
+
 #define C_RAMSTEIN              10439
 #define C_ABOM_BILE             10416
 #define C_ABOM_VENOM            10417
 #define C_BLACK_GUARD           10394
 #define C_YSIDA                 16031
+
 #define MAX_ENCOUNTER              6
+
 struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
 {
     instance_stratholme(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 Encounter[MAX_ENCOUNTER];
+
     bool IsSilverHandDead[5];
+
     uint32 BaronRun_Timer;
     uint32 SlaugtherSquare_Timer;
+
     uint64 serviceEntranceGUID;
     uint64 gauntletGate1GUID;
     uint64 ziggurat1GUID;
@@ -57,18 +68,23 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
     uint64 portGauntletGUID;
     uint64 portSlaugtherGUID;
     uint64 portElderGUID;
+
     uint64 baronGUID;
     uint64 ysidaTriggerGUID;
     std::set crystalsGUID;
     std::set abomnationGUID;
+
     void Initialize()
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             Encounter[i] = NOT_STARTED;
-        for (uint8 i = 0; i < 5; ++i)
+
+        for(uint8 i = 0; i < 5; ++i)
             IsSilverHandDead[i] = false;
+
         BaronRun_Timer = 0;
         SlaugtherSquare_Timer = 0;
+
         serviceEntranceGUID = 0;
         gauntletGate1GUID = 0;
         ziggurat1GUID = 0;
@@ -79,11 +95,13 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
         portGauntletGUID = 0;
         portSlaugtherGUID = 0;
         portElderGUID = 0;
+
         baronGUID = 0;
         ysidaTriggerGUID = 0;
         crystalsGUID.clear();
         abomnationGUID.clear();
     }
+
     bool StartSlaugtherSquare()
     {
         //change to DONE when crystals implemented
@@ -93,14 +111,17 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
             UpdateGoState(portSlaugtherGUID,0,false);
             return true;
         }
+
         debug_log("TSCR: Instance Stratholme: Cannot open slaugther square yet.");
         return false;
     }
+
     //if withRestoreTime true, then newState will be ignored and GO should be restored to original state after 10 seconds
     void UpdateGoState(uint64 goGuid, uint32 newState, bool withRestoreTime)
     {
         if (!goGuid)
             return;
+
         if (GameObject* pGo = instance->GetGameObject(goGuid))
         {
             if (withRestoreTime)
@@ -109,6 +130,7 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
                 pGo->SetGoState((GOState)newState);
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -120,6 +142,7 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
         case C_ABOM_VENOM:      abomnationGUID.insert(pCreature->GetGUID()); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -148,6 +171,7 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
         case GO_PORT_ELDERS:        portElderGUID = pGo->GetGUID(); break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -200,8 +224,9 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
             {
                 if (Encounter[4] != IN_PROGRESS)
                     UpdateGoState(portGauntletGUID,GO_STATE_READY,false);
+
                 uint32 count = abomnationGUID.size();
-                for (std::set::iterator i = abomnationGUID.begin(); i != abomnationGUID.end(); ++i)
+                for(std::set::iterator i = abomnationGUID.begin(); i != abomnationGUID.end(); ++i)
                 {
                     if (Creature* pAbom = instance->GetCreature(*i))
                     {
@@ -209,6 +234,7 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
                             --count;
                     }
                 }
+
                 if (!count)
                 {
                     //a bit itchy, it should close the door after 10 secs, but it doesn't. skipping it for now.
@@ -235,19 +261,22 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
                 if (GetData(TYPE_BARON_RUN) == IN_PROGRESS)
                 {
                     Map::PlayerList const& players = instance->GetPlayers();
+
                     if (!players.isEmpty())
                     {
-                        for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                        for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         {
                             if (Player* pPlayer = itr->getSource())
                             {
                                 if (pPlayer->HasAura(SPELL_BARON_ULTIMATUM))
                                     pPlayer->RemoveAurasDueToSpell(SPELL_BARON_ULTIMATUM);
+
                                 if (pPlayer->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE)
                                     pPlayer->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
                             }
                         }
                     }
+
                     SetData(TYPE_BARON_RUN,DONE);
                 }
             }
@@ -276,15 +305,19 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
         }
         if (data == DONE)SaveToDB();
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::ostringstream saveStream;
         saveStream << Encounter[0] << " " << Encounter[1] << " " << Encounter[2] << " "
             << Encounter[3] << " " << Encounter[4] << " " << Encounter[5];
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return saveStream.str();
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -292,15 +325,20 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         std::istringstream loadStream(in);
         loadStream >> Encounter[0] >> Encounter[1] >> Encounter[2] >> Encounter[3]
         >> Encounter[4] >> Encounter[5];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (Encounter[i] == IN_PROGRESS)
                 Encounter[i] = NOT_STARTED;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
+
     uint32 GetData(uint32 type)
     {
           switch(type)
@@ -324,6 +362,7 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
           }
           return 0;
     }
+
     uint64 GetData64(uint32 data)
     {
         switch(data)
@@ -335,6 +374,7 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
         }
         return 0;
     }
+
     void Update(uint32 diff)
     {
         if (BaronRun_Timer)
@@ -347,14 +387,16 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
                 debug_log("TSCR: Instance Stratholme: Baron run event reached end. Event has state %u.",GetData(TYPE_BARON_RUN));
             }else BaronRun_Timer -= diff;
         }
+
         if (SlaugtherSquare_Timer)
         {
             if (SlaugtherSquare_Timer <= diff)
             {
                 if (Creature* pBaron = instance->GetCreature(baronGUID))
                 {
-                    for (uint8 i = 0; i < 4; ++i)
+                    for(uint8 i = 0; i < 4; ++i)
                         pBaron->SummonCreature(C_BLACK_GUARD,4032.84,-3390.24,119.73,4.71,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000);
+
                     UpdateGoState(ziggurat4GUID,GO_STATE_ACTIVE,false);
                     UpdateGoState(ziggurat5GUID,GO_STATE_ACTIVE,false);
                     debug_log("TSCR: Instance Stratholme: Black guard sentries spawned. Opening gates to baron.");
@@ -364,10 +406,12 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
         }
     }
 };
+
 InstanceData* GetInstanceData_instance_stratholme(Map* pMap)
 {
     return new instance_stratholme(pMap);
 }
+
 void AddSC_instance_stratholme()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/stratholme.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/stratholme.cpp
index c091ab5562e..1d0473e1d9b 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/stratholme.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/stratholme/stratholme.cpp
@@ -13,37 +13,46 @@
  * along 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: Misc mobs for instance. pGo-script to apply aura and start event for quest 8945
 SDCategory: Stratholme
 EndScriptData */
+
 /* ContentData
 go_gauntlet_gate
 mob_freed_soul
 mob_restless_soul
 mobs_spectral_ghostly_citizen
 EndContentData */
+
 #include "precompiled.h"
 #include "def_stratholme.h"
+
 /*######
 ## go_gauntlet_gate (this is the _first_ of the gauntlet gates, two exist)
 ######*/
+
 bool GOHello_go_gauntlet_gate(Player* pPlayer, GameObject* pGo)
 {
     ScriptedInstance* pInstance = pGo->GetInstanceData();
+
     if (!pInstance)
         return false;
+
     if (pInstance->GetData(TYPE_BARON_RUN) != NOT_STARTED)
         return false;
+
     if (Group *pGroup = pPlayer->GetGroup())
     {
-        for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
+        for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
         {
             Player* pGroupie = itr->getSource();
             if (!pGroupie)
                 continue;
+
             if (pGroupie->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE &&
                 !pGroupie->HasAura(SPELL_BARON_ULTIMATUM) &&
                 pGroupie->GetMap() == pGo->GetMap())
@@ -53,51 +62,65 @@ bool GOHello_go_gauntlet_gate(Player* pPlayer, GameObject* pGo)
                 !pPlayer->HasAura(SPELL_BARON_ULTIMATUM) &&
                 pPlayer->GetMap() == pGo->GetMap())
                 pPlayer->CastSpell(pPlayer,SPELL_BARON_ULTIMATUM,true);
+
     pInstance->SetData(TYPE_BARON_RUN,IN_PROGRESS);
     return false;
 }
+
 /*######
 ## mob_freed_soul
 ######*/
+
 //Possibly more of these quotes around.
 #define SAY_ZAPPED0 -1329000
 #define SAY_ZAPPED1 -1329001
 #define SAY_ZAPPED2 -1329002
 #define SAY_ZAPPED3 -1329003
+
 struct TRINITY_DLL_DECL mob_freed_soulAI : public ScriptedAI
 {
     mob_freed_soulAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         DoScriptText(RAND(SAY_ZAPPED0,SAY_ZAPPED1,SAY_ZAPPED2,SAY_ZAPPED3), m_creature);
     }
+
     void EnterCombat(Unit* who) { }
 };
+
 CreatureAI* GetAI_mob_freed_soul(Creature* pCreature)
 {
     return new mob_freed_soulAI (pCreature);
 }
+
 /*######
 ## mob_restless_soul
 ######*/
+
 #define SPELL_EGAN_BLASTER  17368
 #define SPELL_SOUL_FREED    17370
 #define QUEST_RESTLESS_SOUL 5282
 #define ENTRY_RESTLESS      11122
 #define ENTRY_FREED         11136
+
 struct TRINITY_DLL_DECL mob_restless_soulAI : public ScriptedAI
 {
     mob_restless_soulAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 Tagger;
     uint32 Die_Timer;
     bool Tagged;
+
     void Reset()
     {
         Tagger = 0;
         Die_Timer = 5000;
         Tagged = false;
     }
+
     void EnterCombat(Unit* who) {}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (caster->GetTypeId() == TYPEID_PLAYER)
@@ -109,15 +132,18 @@ struct TRINITY_DLL_DECL mob_restless_soulAI : public ScriptedAI
             }
         }
     }
+
     void JustSummoned(Creature *summoned)
     {
         summoned->CastSpell(summoned,SPELL_SOUL_FREED,false);
     }
+
     void JustDied(Unit* Killer)
     {
         if (Tagged)
             m_creature->SummonCreature(ENTRY_FREED, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 300000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Tagged)
@@ -130,39 +156,48 @@ struct TRINITY_DLL_DECL mob_restless_soulAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_mob_restless_soul(Creature* pCreature)
 {
     return new mob_restless_soulAI (pCreature);
 }
+
 /*######
 ## mobs_spectral_ghostly_citizen
 ######*/
+
 enum eGhostlyCitizenSpells
 {
     SPELL_HAUNTING_PHANTOM  = 16336,
     SPELL_SLAP              = 6754
 };
+
 struct TRINITY_DLL_DECL mobs_spectral_ghostly_citizenAI : public ScriptedAI
 {
     mobs_spectral_ghostly_citizenAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Die_Timer;
     bool Tagged;
+
     void Reset()
     {
         Die_Timer = 5000;
         Tagged = false;
     }
+
     void EnterCombat(Unit* who) {}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (!Tagged && spell->Id == SPELL_EGAN_BLASTER)
             Tagged = true;
     }
+
     void JustDied(Unit* Killer)
     {
         if (Tagged)
         {
-            for (uint32 i = 1; i <= 4; ++i)
+            for(uint32 i = 1; i <= 4; ++i)
             {
                  //100%, 50%, 33%, 25% chance to spawn
                  if (urand(1,i) == 1)
@@ -170,6 +205,7 @@ struct TRINITY_DLL_DECL mobs_spectral_ghostly_citizenAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Tagged)
@@ -178,10 +214,13 @@ struct TRINITY_DLL_DECL mobs_spectral_ghostly_citizenAI : public ScriptedAI
                 m_creature->Kill(m_creature);
             else Die_Timer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void ReceiveEmote(Player* pPlayer, uint32 emote)
     {
         switch(emote)
@@ -207,25 +246,31 @@ struct TRINITY_DLL_DECL mobs_spectral_ghostly_citizenAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_mobs_spectral_ghostly_citizen(Creature* pCreature)
 {
     return new mobs_spectral_ghostly_citizenAI (pCreature);
 }
+
 void AddSC_stratholme()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "go_gauntlet_gate";
     newscript->pGOHello = &GOHello_go_gauntlet_gate;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_freed_soul";
     newscript->GetAI = &GetAI_mob_freed_soul;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_restless_soul";
     newscript->GetAI = &GetAI_mob_restless_soul;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mobs_spectral_ghostly_citizen";
     newscript->GetAI = &GetAI_mobs_spectral_ghostly_citizen;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/def_sunken_temple.h b/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/def_sunken_temple.h
index bc191af0697..82245095c31 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/def_sunken_temple.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/def_sunken_temple.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 kb_z
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_SUNKEN_TEMPLE_H
 #define DEF_SUNKEN_TEMPLE_H
+
 #define TROLLBOSS1_DEATH 1
 #define TROLLBOSS2_DEATH 2
 #define TROLLBOSS3_DEATH 3
@@ -14,6 +16,7 @@
 #define HAZZAS_DEATH 9
 #define ERANIKUS_DEATH 10
 #define ATALALARION_DEATH 11 //optional
+
 #define EVENT_STATE 1
 #endif
 
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/instance_sunken_temple.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/instance_sunken_temple.cpp
index 4e7981c7969..42ec8d5d784 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/instance_sunken_temple.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/instance_sunken_temple.cpp
@@ -13,14 +13,17 @@
  * along 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_Sunken_Temple
 SD%Complete: 100
 SDComment:Place Holder
 SDCategory: Sunken Temple
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_sunken_temple.h"
+
 #define GO_ATALAI_STATUE1 148830
 #define GO_ATALAI_STATUE2 148831
 #define GO_ATALAI_STATUE3 148832
@@ -28,15 +31,19 @@ EndScriptData */
 #define GO_ATALAI_STATUE5 148834
 #define GO_ATALAI_STATUE6 148835
 #define GO_ATALAI_IDOL 148836
+
 #define GO_ATALAI_LIGHT1 148883
 #define GO_ATALAI_LIGHT2 148937
+
 #define NPC_MALFURION_STORMRAGE 15362
+
 struct TRINITY_DLL_DECL instance_sunken_temple : public ScriptedInstance
 {
     instance_sunken_temple(Map* pMap) : ScriptedInstance(pMap)
     {
         Initialize();
     };
+
     GameObject* AtalaiStatue1;
     GameObject* AtalaiStatue2;
     GameObject* AtalaiStatue3;
@@ -44,6 +51,7 @@ struct TRINITY_DLL_DECL instance_sunken_temple : public ScriptedInstance
     GameObject* AtalaiStatue5;
     GameObject* AtalaiStatue6;
     GameObject* AtalaiIdol;
+
     uint64 GOAtalaiStatue1;
     uint64 GOAtalaiStatue2;
     uint64 GOAtalaiStatue3;
@@ -52,12 +60,14 @@ struct TRINITY_DLL_DECL instance_sunken_temple : public ScriptedInstance
     uint64 GOAtalaiStatue6;
     uint64 GOAtalaiIdol;
     uint32 State;
+
     bool s1;
     bool s2;
     bool s3;
     bool s4;
     bool s5;
     bool s6;
+
     void Initialize()
     {
         GOAtalaiStatue1 = 0;
@@ -82,6 +92,7 @@ struct TRINITY_DLL_DECL instance_sunken_temple : public ScriptedInstance
         s5 = false;
         s6 = false;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
      {
          switch(pGo->GetEntry())
@@ -117,6 +128,7 @@ struct TRINITY_DLL_DECL instance_sunken_temple : public ScriptedInstance
          }
      };
 
+
      virtual void Update(uint32 diff) // correct order goes form 1-6
      {
          switch(State)
@@ -171,6 +183,7 @@ struct TRINITY_DLL_DECL instance_sunken_temple : public ScriptedInstance
             break;
          }
      };
+
      void UseStatue(GameObject* pGo)
      {
          pGo->SummonGameObject(GO_ATALAI_LIGHT1,pGo->GetPositionX(),pGo->GetPositionY(),pGo->GetPositionZ(),0,0,0,0,0,0);
@@ -186,11 +199,13 @@ struct TRINITY_DLL_DECL instance_sunken_temple : public ScriptedInstance
          AtalaiStatue6->SummonGameObject(GO_ATALAI_LIGHT2,AtalaiStatue6->GetPositionX(),AtalaiStatue6->GetPositionY(),AtalaiStatue6->GetPositionZ(),0,0,0,0,0,100000);
          pGo->SummonGameObject(148838,-488.997,96.61,-189.019,-1.52,0,0,0,0,100000);
      }
+
      void SetData(uint32 type, uint32 data)
      {
         if (type == EVENT_STATE)
             State = data;
      }
+
      uint32 GetData(uint32 type)
      {
         if (type == EVENT_STATE)
@@ -198,10 +213,12 @@ struct TRINITY_DLL_DECL instance_sunken_temple : public ScriptedInstance
         return 0;
      }
 };
+
 InstanceData* GetInstanceData_instance_sunken_temple(Map* pMap)
 {
     return new instance_sunken_temple(pMap);
 }
+
 void AddSC_instance_sunken_temple()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/sunken_temple.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/sunken_temple.cpp
index 47af3f53cb0..d4da9a68e53 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/sunken_temple.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunken_temple/sunken_temple.cpp
@@ -13,20 +13,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Sunken_Temple
 SD%Complete: 100
 SDComment: Area Trigger + Puzzle event support
 SDCategory: Sunken Temple
 EndScriptData */
+
 /* ContentData
 at_malfurion_Stormrage_trigger
 EndContentData */
+
 #include "precompiled.h"
 #include "def_sunken_temple.h"
+
 /*#####
 # at_malfurion_Stormrage_trigger
 #####*/
+
 bool AreaTrigger_at_malfurion_stormrage(Player* pPlayer, AreaTriggerEntry *at)
 {
     if (ScriptedInstance* pInstance = pPlayer->GetInstanceData())
@@ -40,6 +45,7 @@ return false;
 /*#####
 # go_atalai_statue
 #####*/
+
 bool GOHello_go_atalai_statue(Player* pPlayer, GameObject* pGo)
 {
     ScriptedInstance* pInstance = pPlayer->GetInstanceData();
@@ -48,13 +54,16 @@ bool GOHello_go_atalai_statue(Player* pPlayer, GameObject* pGo)
     pInstance->SetData(EVENT_STATE,pGo->GetEntry());
     return false;
 }
+
 void AddSC_sunken_temple()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "at_malfurion_stormrage";
     newscript->pAreaTrigger = &AreaTrigger_at_malfurion_stormrage;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_atalai_statue";
     newscript->pGOHello = &GOHello_go_atalai_statue;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_brutallus.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_brutallus.cpp
index d63ca9061a7..cfa03ab6086 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_brutallus.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_brutallus.cpp
@@ -13,13 +13,16 @@
  * along with 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: Find a way to start the intro, best code for the intro
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_sunwell_plateau.h"
+
 enum Quotes
 {
  YELL_INTRO                 =   -1580017,
@@ -27,11 +30,13 @@ enum Quotes
  YELL_INTRO_CHARGE          =   -1580019,
  YELL_INTRO_KILL_MADRIGOSA  =   -1580020,
  YELL_INTRO_TAUNT           =   -1580021,
+
  YELL_MADR_ICE_BARRIER      =   -1580031,
  YELL_MADR_INTRO            =   -1580032,
  YELL_MADR_ICE_BLOCK        =   -1580033,
  YELL_MADR_TRAP             =   -1580034,
  YELL_MADR_DEATH            =   -1580035,
+
  YELL_AGGRO                 =   -1580022,
  YELL_KILL1                 =   -1580023,
  YELL_KILL2                 =   -1580024,
@@ -42,6 +47,7 @@ enum Quotes
  YELL_BERSERK               =   -1580029,
  YELL_DEATH                 =   -1580030
 };
+
 enum Spells
 {
     SPELL_METEOR_SLASH                 =   45150,
@@ -49,47 +55,59 @@ enum Spells
     SPELL_STOMP                        =   45185,
     SPELL_BERSERK                      =   26662,
     SPELL_DUAL_WIELD                   =   42459,
+
     SPELL_INTRO_FROST_BLAST            =   45203,
     SPELL_INTRO_FROSTBOLT              =   44843,
     SPELL_INTRO_ENCAPSULATE            =   45665,
     SPELL_INTRO_ENCAPSULATE_CHANELLING =   45661
 };
+
 #define FELMYST 25038
+
 struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI
 {
     boss_brutallusAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     Unit* Madrigosa;
+
     uint32 SlashTimer;
     uint32 BurnTimer;
     uint32 StompTimer;
     uint32 BerserkTimer;
+
     uint32 IntroPhase;
     uint32 IntroPhaseTimer;
     uint32 IntroFrostBoltTimer;
+
     bool Intro;
     bool IsIntro;
     bool Enraged;
+
     void Reset()
     {
         SlashTimer = 11000;
         StompTimer = 30000;
         BurnTimer = 60000;
         BerserkTimer = 360000;
+
         IntroPhase = 0;
         IntroPhaseTimer = 0;
         IntroFrostBoltTimer = 0;
+
         IsIntro = false;
         Enraged = false;
         Intro = true; //for debug
+
         m_creature->CastSpell(m_creature, SPELL_DUAL_WIELD, true);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         Madrigosa = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_MADRIGOSA));
         //Creature* boss = Unit::GetCreature((*m_creature),AzgalorGUID);
         if (!Madrigosa) error_log("Madrigosa was not found");
+
         if (Intro && Madrigosa){
             if (!Madrigosa->isAlive())
                 EndIntro();
@@ -97,22 +115,28 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI
         }
         else
             EndIntro();
+
         if (pInstance)
             pInstance->SetData(DATA_BRUTALLUS_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(YELL_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_BRUTALLUS_EVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(YELL_KILL1,YELL_KILL2,YELL_KILL3), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(YELL_DEATH, m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(DATA_BRUTALLUS_EVENT, DONE);
@@ -121,6 +145,7 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI
             m_creature->SummonCreature(FELMYST, x,y, z+30, m_creature->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN, 0);
         }
     }
+
     void StartIntro()
     {
         if (!Intro)
@@ -133,6 +158,7 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI
         }
         error_log("Start Intro");
     }
+
     void EndIntro()
     {
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -140,10 +166,12 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI
         IsIntro = false;
         error_log("End Intro");
     }
+
     void DoIntro()
     {
         if (!Madrigosa)
             return;
+
         switch (IntroPhase)
         {
             case 0:
@@ -214,13 +242,16 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI
                 break;
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (pInstance && Intro)
             pInstance->SetData(DATA_BRUTALLUS_EVENT, SPECIAL);
+
         if (Intro && !IsIntro)
             StartIntro();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IsIntro)
@@ -228,6 +259,7 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI
             if (IntroPhaseTimer < diff)
                 DoIntro();
             else IntroPhaseTimer -= diff;
+
             if (IntroPhase == 3 + 1)
             {
                 if (IntroFrostBoltTimer < diff)
@@ -240,41 +272,50 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI
                 } else IntroFrostBoltTimer -= diff;
             }
         }
+
         if (!UpdateVictim() || IsIntro)
             return;
+
         if (SlashTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_METEOR_SLASH);
             SlashTimer = 11000;
         } else SlashTimer -= diff;
+
         if (StompTimer < diff)
         {
             DoScriptText(RAND(YELL_LOVE1,YELL_LOVE2,YELL_LOVE3), m_creature);
             DoCast(m_creature->getVictim(), SPELL_STOMP);
             StompTimer = 30000;
         } else StompTimer -= diff;
+
         if (BurnTimer < diff)
         {
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 target->CastSpell(target, SPELL_BURN, true);
             BurnTimer = 60000;
         } else BurnTimer -= diff;
+
         if (BerserkTimer < diff && !Enraged)
         {
             DoScriptText(YELL_BERSERK, m_creature);
             DoCast(m_creature, SPELL_BERSERK);
             Enraged = true;
         } else BerserkTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_brutallus(Creature* pCreature)
 {
     return new boss_brutallusAI (pCreature);
 }
+
 void AddSC_boss_brutallus()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_brutallus";
     newscript->GetAI = &GetAI_boss_brutallus;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_eredar_twins.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_eredar_twins.cpp
index 332ef12a60d..1d46bba348b 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_eredar_twins.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_eredar_twins.cpp
@@ -13,13 +13,16 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
+
 /* ScriptData
 SDName: Boss_Eredar_Twins
 SD%Complete: 100
 SDComment:
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_sunwell_plateau.h"
+
 enum Quotes
 {
     //Alytesh
@@ -29,6 +32,7 @@ enum Quotes
     YELL_ALY_KILL_2             =   -1580047,
     YELL_ALY_DEAD               =   -1580048,
     YELL_BERSERK                =   -1580049,
+
     //Sacrolash
     YELL_SHADOW_NOVA            =   -1580050,
     YELL_SISTER_ALYTHESS_DEAD   =   -1580051,
@@ -36,6 +40,7 @@ enum Quotes
     YELL_SAC_KILL_2             =   -1580053,
     SAY_SAC_DEAD                =   -1580054,
     YELL_ENRAGE                 =   -1580055,
+
     //Intro
     YELL_INTRO_SAC_1            =   -1580056,
     YELL_INTRO_ALY_2            =   -1580057,
@@ -45,10 +50,12 @@ enum Quotes
     YELL_INTRO_ALY_6            =   -1580061,
     YELL_INTRO_SAC_7            =   -1580062,
     YELL_INTRO_ALY_8            =   -1580063,
+
     //Emote
     EMOTE_SHADOW_NOVA           =   -1580064,
     EMOTE_CONFLAGRATION         =   -1580065
 };
+
 enum Spells
 {
     //Lady Sacrolash spells
@@ -57,13 +64,16 @@ enum Spells
     SPELL_DARK_STRIKE       =   45271,
     SPELL_SHADOW_NOVA       =   45329, //30-35 secs
     SPELL_CONFOUNDING_BLOW  =   45256, //25 secs
+
     //Shadow Image spells
     SPELL_SHADOW_FURY       =   45270,
     SPELL_IMAGE_VISUAL      =   45263,
+
     //Misc spells
     SPELL_ENRAGE            =   46587,
     SPELL_EMPOWER           =   45366,
     SPELL_DARK_FLAME        =   45345,
+
     //Grand Warlock Alythess spells
     SPELL_PYROGENICS        =   45230, //15secs
     SPELL_FLAME_TOUCHED     =   45348,
@@ -73,30 +83,37 @@ enum Spells
     SPELL_BLAZE_SUMMON      =   45236, //187366 GO
     SPELL_BLAZE_BURN        =   45246
 };
+
 enum Creatures
 {
     GRAND_WARLOCK_ALYTHESS  =   25166,
     MOB_SHADOW_IMAGE        =   25214,
     LADY_SACROLASH          =   25165
 };
+
 struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
 {
     boss_sacrolashAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     bool SisterDeath;
     bool Enraged;
+
     uint32 ShadowbladesTimer;
     uint32 ShadownovaTimer;
     uint32 ConfoundingblowTimer;
     uint32 ShadowimageTimer;
     uint32 ConflagrationTimer;
     uint32 EnrageTimer;
+
     void Reset()
     {
         Enraged = false;
+
         if (pInstance)
         {
             Unit* Temp =  Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_ALYTHESS));
@@ -112,6 +129,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
                     }
                 }
         }
+
         if (!m_creature->isInCombat())
         {
             ShadowbladesTimer = 10000;
@@ -120,40 +138,49 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
             ShadowimageTimer = 20000;
             ConflagrationTimer = 30000;
             EnrageTimer = 360000;
+
             SisterDeath = false;
         }
+
         if (pInstance)
             pInstance->SetData(DATA_EREDAR_TWINS_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
+
         if (pInstance)
         {
             Unit* Temp =  Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_ALYTHESS));
             if (Temp && Temp->isAlive() && !(Temp->getVictim()))
                 CAST_CRE(Temp)->AI()->AttackStart(who);
         }
+
         if (pInstance)
             pInstance->SetData(DATA_EREDAR_TWINS_EVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (rand()%4 == 0)
             DoScriptText(RAND(YELL_SAC_KILL_1,YELL_SAC_KILL_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         // only if ALY death
         if (SisterDeath)
         {
             DoScriptText(SAY_SAC_DEAD, m_creature);
+
             if (pInstance)
                 pInstance->SetData(DATA_EREDAR_TWINS_EVENT, DONE);
         }
         else
             m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
     }
+
     void SpellHitTarget(Unit* target,const SpellEntry* spell)
     {
         switch(spell->Id)
@@ -169,6 +196,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
             break;
         }
     }
+
     void HandleTouchedSpells(Unit* target, uint32 TouchedType)
     {
         switch(TouchedType)
@@ -195,6 +223,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
             break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!SisterDeath)
@@ -212,8 +241,10 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
                 }
             }
         }
+
         if (!UpdateVictim())
             return;
+
         if (SisterDeath)
         {
             if (ConflagrationTimer < diff)
@@ -239,6 +270,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
                     target = SelectUnit(SELECT_TARGET_RANDOM, 0);
                     if (target)
                         DoCast(target, SPELL_SHADOW_NOVA);
+
                     if (!SisterDeath)
                     {
                         if (target)
@@ -249,6 +281,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
                 }
             }else ShadownovaTimer -=diff;
         }
+
         if (ConfoundingblowTimer < diff)
         {
             if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -260,11 +293,12 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
                 ConfoundingblowTimer = 20000 + (rand()%5000);
             }
         }else ConfoundingblowTimer -=diff;
+
         if (ShadowimageTimer < diff)
         {
             Unit* target = NULL;
             Creature* temp = NULL;
-            for (uint8 i = 0; i<3; ++i)
+            for(uint8 i = 0;i<3; ++i)
             {
                 target = SelectUnit(SELECT_TARGET_RANDOM, 0);
                 temp = DoSpawnCreature(MOB_SHADOW_IMAGE,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN,10000);
@@ -273,6 +307,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
             }
             ShadowimageTimer = 20000;
         }else ShadowimageTimer -=diff;
+
         if (ShadowbladesTimer < diff)
         {
             if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -281,6 +316,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
                 ShadowbladesTimer = 10000;
             }
         }else ShadowbladesTimer -=diff;
+
         if (EnrageTimer < diff && !Enraged)
         {
             m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
@@ -288,6 +324,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
             DoCast(m_creature,SPELL_ENRAGE);
             Enraged = true;
         }else EnrageTimer -= diff;
+
         if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
         {
             //If we are within range melee the target
@@ -300,10 +337,12 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_sacrolash(Creature* pCreature)
 {
     return new boss_sacrolashAI (pCreature);
 };
+
 struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
 {
     boss_alythessAI(Creature *c) : Scripted_NoMovementAI(c)
@@ -311,20 +350,26 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
         pInstance = c->GetInstanceData();
         IntroStepCounter = 10;
     }
+
     ScriptedInstance *pInstance;
+
     bool SisterDeath;
     bool Enraged;
+
     uint32 IntroStepCounter;
     uint32 IntroYellTimer;
+
     uint32 ConflagrationTimer;
     uint32 BlazeTimer;
     uint32 PyrogenicsTimer;
     uint32 ShadownovaTimer;
     uint32 FlamesearTimer;
     uint32 EnrageTimer;
+
     void Reset()
     {
         Enraged = false;
+
         if (pInstance)
         {
             Unit* Temp =  Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_SACROLASH));
@@ -340,6 +385,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
                     }
                 }
         }
+
         if (!m_creature->isInCombat())
         {
             ConflagrationTimer = 45000;
@@ -349,23 +395,29 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
             EnrageTimer = 360000;
             FlamesearTimer = 15000;
             IntroYellTimer = 10000;
+
             SisterDeath = false;
         }
+
         if (pInstance)
             pInstance->SetData(DATA_EREDAR_TWINS_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
+
         if (pInstance)
         {
             Unit* Temp =  Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_SACROLASH));
             if (Temp && Temp->isAlive() && !(Temp->getVictim()))
                 CAST_CRE(Temp)->AI()->AttackStart(who);
         }
+
         if (pInstance)
             pInstance->SetData(DATA_EREDAR_TWINS_EVENT, IN_PROGRESS);
     }
+
     void AttackStart(Unit *who)
     {
         if (!m_creature->isInCombat())
@@ -373,12 +425,15 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
             Scripted_NoMovementAI::AttackStart(who);
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || m_creature->getVictim())
             return;
+
         if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(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))
             {
@@ -393,6 +448,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
             IntroStepCounter = 0;
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (rand()%4 == 0)
@@ -400,21 +456,25 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
             DoScriptText(RAND(YELL_ALY_KILL_1,YELL_ALY_KILL_2), m_creature);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (SisterDeath)
         {
             DoScriptText(YELL_ALY_DEAD, m_creature);
+
             if (pInstance)
                 pInstance->SetData(DATA_EREDAR_TWINS_EVENT, DONE);
         }
         else
             m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
     }
+
     void SpellHitTarget(Unit* target,const SpellEntry* spell)
     {
         switch(spell->Id)
         {
+
         case SPELL_BLAZE:
             target->CastSpell(target, SPELL_BLAZE_SUMMON, true);
         case SPELL_CONFLAGRATION:
@@ -426,6 +486,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
             break;
         }
     }
+
     void HandleTouchedSpells(Unit* target, uint32 TouchedType)
     {
         switch(TouchedType)
@@ -455,6 +516,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
             break;
         }
     }
+
     uint32 IntroStep(uint32 step)
     {
         Creature* Sacrolash = Unit::GetCreature(*m_creature, pInstance ? pInstance->GetData64(DATA_SACROLASH) : 0);
@@ -484,6 +546,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
         }
         return 10000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IntroStepCounter < 9)
@@ -493,6 +556,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
                 IntroYellTimer = IntroStep(++IntroStepCounter);
             }else IntroYellTimer -= diff;
         }
+
         if (!SisterDeath)
         {
             if (pInstance)
@@ -508,8 +572,10 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
                 }
             }
         }
+
         if (!UpdateVictim())
             return;
+
         if (SisterDeath)
         {
             if (ShadownovaTimer < diff)
@@ -536,16 +602,19 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
                     if (target)
                         DoCast(target, SPELL_CONFLAGRATION);
                     ConflagrationTimer = 30000+(rand()%5000);
+
                     if (!SisterDeath)
                     {
                         if (target)
                             DoScriptText(EMOTE_CONFLAGRATION, m_creature, target);
                         DoScriptText(YELL_CANFLAGRATION, m_creature);
                     }
+
                     BlazeTimer = 4000;
                 }
             }else ConflagrationTimer -= diff;
         }
+
         if (FlamesearTimer < diff)
         {
             if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -554,6 +623,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
                 FlamesearTimer = 15000;
             }
         }else FlamesearTimer -=diff;
+
         if (PyrogenicsTimer < diff)
         {
             if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -562,6 +632,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
                 PyrogenicsTimer = 15000;
             }
         }else PyrogenicsTimer -= diff;
+
         if (BlazeTimer < diff)
         {
             if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -570,6 +641,7 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
                 BlazeTimer = 3800;
             }
         }else BlazeTimer -= diff;
+
         if (EnrageTimer < diff && !Enraged)
         {
             m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
@@ -579,27 +651,34 @@ struct TRINITY_DLL_DECL boss_alythessAI : public Scripted_NoMovementAI
         }else EnrageTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_alythess(Creature* pCreature)
 {
     return new boss_alythessAI (pCreature);
 };
+
 struct TRINITY_DLL_DECL mob_shadow_imageAI : public ScriptedAI
 {
     mob_shadow_imageAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowfuryTimer;
     uint32 KillTimer;
     uint32 DarkstrikeTimer;
+
     void Reset()
     {
         ShadowfuryTimer = 5000 + (rand()%15000);
         DarkstrikeTimer = 3000;
         KillTimer = 15000;
     }
+
     void EnterCombat(Unit *who){}
+
     void SpellHitTarget(Unit* target,const SpellEntry* spell)
     {
         switch(spell->Id)
         {
+
         case SPELL_SHADOW_FURY:
         case SPELL_DARK_STRIKE:
             if (!target->HasAura(SPELL_DARK_FLAME))
@@ -613,22 +692,27 @@ struct TRINITY_DLL_DECL mob_shadow_imageAI : public ScriptedAI
             break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->HasAura(SPELL_IMAGE_VISUAL))
             DoCast(m_creature, SPELL_IMAGE_VISUAL);
+
         if (KillTimer < diff)
         {
             m_creature->Kill(m_creature);
             KillTimer = 9999999;
         } else KillTimer -= diff;
+
         if (!UpdateVictim())
             return;
+
         if (ShadowfuryTimer < diff)
         {
             DoCast(m_creature, SPELL_SHADOW_FURY);
             ShadowfuryTimer = 10000;
         } else ShadowfuryTimer -=diff;
+
         if (DarkstrikeTimer < diff)
         {
             if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -641,21 +725,26 @@ struct TRINITY_DLL_DECL mob_shadow_imageAI : public ScriptedAI
         } else DarkstrikeTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_shadow_image(Creature* pCreature)
 {
     return new mob_shadow_imageAI (pCreature);
 };
+
 void AddSC_boss_eredar_twins()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_sacrolash";
     newscript->GetAI = &GetAI_boss_sacrolash;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_alythess";
     newscript->GetAI = &GetAI_boss_alythess;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_shadow_image";
     newscript->GetAI = &GetAI_mob_shadow_image;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_felmyst.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_felmyst.cpp
index 3d4338493ed..b81cbca3516 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_felmyst.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_felmyst.cpp
@@ -13,13 +13,16 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
+
 /* ScriptData
 SDName: Boss_Felmyst
 SD%Complete: 0
 SDComment:
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_sunwell_plateau.h"
+
 enum Quotes
 {
     YELL_BIRTH      =       -1580036,
@@ -31,11 +34,13 @@ enum Quotes
     YELL_DEATH      =       -1580042,
     YELL_KALECGOS   =       -1580043 //after felmyst's death spawned and say this
 };
+
 enum Spells
 {
     //Aura
     AURA_SUNWELL_RADIANCE       =   45769,
     AURA_NOXIOUS_FUMES          =   47002,
+
     //Land phase
     SPELL_CLEAVE                =   19983,
     SPELL_CORROSION             =   45866,
@@ -43,6 +48,7 @@ enum Spells
     SPELL_ENCAPSULATE_CHANNEL   =   45661,
     // SPELL_ENCAPSULATE_EFFECT    =   45665,
     // SPELL_ENCAPSULATE_AOE       =   45662,
+
     //Flight phase
     SPELL_VAPOR_SELECT          =   45391,   // fel to player, force cast 45392, 50000y selete target
     SPELL_VAPOR_SUMMON          =   45392,   // player summon vapor, radius around caster, 5y,
@@ -61,15 +67,18 @@ enum Spells
     SPELL_FOG_INFORM            =   45714,   // player let fel cast 45717, script effect
     SPELL_FOG_CHARM             =   45717,   // fel to player
     SPELL_FOG_CHARM2            =   45726,   // link to 45717
+
     SPELL_TRANSFORM_TRIGGER     =   44885,   // madrigosa to self, trigger 46350
     SPELL_TRANSFORM_VISUAL      =   46350,   //46411stun?
     SPELL_TRANSFORM_FELMYST     =   45068,   // become fel
     SPELL_FELMYST_SUMMON        =   45069,
+
     //Other
     SPELL_BERSERK               =   45078,
     SPELL_CLOUD_VISUAL          =   45212,
     SPELL_CLOUD_SUMMON          =   45884
 };
+
 enum Creatures
 {
     MOB_FELMYST        =   25038,
@@ -84,36 +93,43 @@ enum Creatures
     MOB_VAPOR          =   25265,
     MOB_VAPOR_TRAIL    =   25267
 };
+
 enum PhaseFelmyst
 {
     PHASE_NULL  = 0,
     PHASE_GROUND = 1,
     PHASE_FLIGHT = 2,
 };
+
 enum EventFelmyst
 {
     EVENT_NULL          =   0,
     EVENT_BERSERK       =   1,
+
     EVENT_CLEAVE        =   2,
     EVENT_CORROSION     =   3,
     EVENT_GAS_NOVA      =   4,
     EVENT_ENCAPSULATE   =   5,
     EVENT_FLIGHT        =   6,
+
     EVENT_FLIGHT_SEQUENCE   =   2,
     EVENT_SUMMON_DEAD       =   3,
     EVENT_SUMMON_FOG        =   4
 };
+
 static EventFelmyst MaxTimer[]=
 {
     EVENT_NULL,
     EVENT_FLIGHT,
     EVENT_SUMMON_FOG,
 };
+
 struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
 {
     boss_felmystAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
+
         // wait for core patch be accepted
         /*SpellEntry *TempSpell = GET_SPELL(SPELL_ENCAPSULATE_EFFECT);
         if (TempSpell->SpellIconID == 2294)
@@ -125,27 +141,35 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
         if ((TempSpell->Attributes & SPELL_ATTR_PASSIVE) == 0)
             TempSpell->Attributes |= SPELL_ATTR_PASSIVE;*/
     }
+
     ScriptedInstance *pInstance;
     PhaseFelmyst Phase;
     EventFelmyst Event;
     uint32 Timer[EVENT_FLIGHT + 1];
+
     uint32 FlightCount;
     uint32 BreathCount;
+
     float BreathX, BreathY;
+
     void Reset()
     {
         Phase = PHASE_NULL;
         Event = EVENT_NULL;
         Timer[EVENT_BERSERK] = 600000;
         FlightCount = 0;
+
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
         m_creature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10);
         m_creature->SetFloatValue(UNIT_FIELD_COMBATREACH, 10);
+
         DespawnSummons(MOB_VAPOR_TRAIL);
         m_creature->setActive(false);
+
         if (pInstance)
             pInstance->SetData(DATA_FELMYST_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->setActive(true);
@@ -153,33 +177,41 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
         m_creature->CastSpell(m_creature, AURA_SUNWELL_RADIANCE, true);
         m_creature->CastSpell(m_creature, AURA_NOXIOUS_FUMES, true);
         EnterPhase(PHASE_GROUND);
+
         if (pInstance)
             pInstance->SetData(DATA_FELMYST_EVENT, IN_PROGRESS);
     }
+
     void AttackStart(Unit *who)
     {
         if (Phase != PHASE_FLIGHT)
             ScriptedAI::AttackStart(who);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (Phase != PHASE_FLIGHT)
             ScriptedAI::MoveInLineOfSight(who);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(YELL_KILL1,YELL_KILL2), m_creature);
     }
+
     void JustRespawned()
     {
         DoScriptText(YELL_BIRTH, m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(YELL_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_FELMYST_EVENT, DONE);
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         // workaround for linked aura
@@ -202,6 +234,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
             m_creature->DealDamage(caster, caster->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         }
     }
+
     void JustSummoned(Creature *summon)
     {
         if (summon->GetEntry() == MOB_DEAD)
@@ -211,15 +244,18 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
             summon->CastSpell(summon, SPELL_DEAD_PASSIVE, true);
         }
     }
+
     void MovementInform(uint32, uint32)
     {
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
     }
+
     void DamageTaken(Unit*, uint32 &damage)
     {
         if (Phase != PHASE_GROUND && damage >= m_creature->GetHealth())
             damage = 0;
     }
+
     void EnterPhase(PhaseFelmyst NextPhase)
     {
         switch(NextPhase)
@@ -243,6 +279,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
         }
         Phase = NextPhase;
     }
+
     void HandleFlightSequence()
     {
         switch(FlightCount)
@@ -384,6 +421,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
         }
         FlightCount++;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -392,8 +430,9 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
                 EnterEvadeMode();
             return;
         }
+
         Event = EVENT_NULL;
-        for (uint32 i = 1; i <= MaxTimer[Phase]; ++i)
+        for(uint32 i = 1; i <= MaxTimer[Phase]; ++i)
         {
             if (Timer[i])
                 if (Timer[i] <= diff)
@@ -402,8 +441,10 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
                         Event = (EventFelmyst)i;
                 }else Timer[i] -= diff;
         }
+
         if (m_creature->IsNonMeleeSpellCasted(false))
             return;
+
         if (Phase == PHASE_GROUND)
         {
             switch(Event)
@@ -439,6 +480,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
                 break;
             }
         }
+
         if (Phase == PHASE_FLIGHT)
         {
             switch(Event)
@@ -469,23 +511,29 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
             }
         }
     }
+
     void DespawnSummons(uint32 entry)
     {
         std::list templist;
         float x, y, z;
         m_creature->GetPosition(x, y, z);
+
         {
             CellPair pair(Trinity::ComputeCellPair(x, y));
             Cell cell(pair);
             cell.data.Part.reserved = ALL_DISTRICT;
             cell.SetNoCreate();
+
             Trinity::AllCreaturesOfEntryInRange check(m_creature, entry, 100);
             Trinity::CreatureListSearcher searcher(m_creature, templist, check);
+
             TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher);
+
             CellLock cell_lock(cell, pair);
             cell_lock->Visit(cell_lock, cSearcher, *(m_creature->GetMap()));
         }
-        for (std::list::iterator i = templist.begin(); i != templist.end(); ++i)
+
+        for(std::list::iterator i = templist.begin(); i != templist.end(); ++i)
         {
             if (entry == MOB_VAPOR_TRAIL && Phase == PHASE_FLIGHT)
             {
@@ -499,6 +547,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_felmyst_vaporAI : public ScriptedAI
 {
     mob_felmyst_vaporAI(Creature *c) : ScriptedAI(c)
@@ -518,6 +567,7 @@ struct TRINITY_DLL_DECL mob_felmyst_vaporAI : public ScriptedAI
             AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0));
     }
 };
+
 struct TRINITY_DLL_DECL mob_felmyst_trailAI : public ScriptedAI
 {
     mob_felmyst_trailAI(Creature *c) : ScriptedAI(c)
@@ -533,18 +583,22 @@ struct TRINITY_DLL_DECL mob_felmyst_trailAI : public ScriptedAI
     void MoveInLineOfSight(Unit* who) {}
     void UpdateAI(const uint32 diff) {}
 };
+
 CreatureAI* GetAI_boss_felmyst(Creature* pCreature)
 {
     return new boss_felmystAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_felmyst_vapor(Creature* pCreature)
 {
     return new mob_felmyst_vaporAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_felmyst_trail(Creature* pCreature)
 {
     return new mob_felmyst_trailAI(pCreature);
 }
+
 void AddSC_boss_felmyst()
 {
     Script *newscript;
@@ -552,10 +606,12 @@ void AddSC_boss_felmyst()
     newscript->Name = "boss_felmyst";
     newscript->GetAI = &GetAI_boss_felmyst;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_felmyst_vapor";
     newscript->GetAI = &GetAI_mob_felmyst_vapor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_felmyst_trail";
     newscript->GetAI = &GetAI_mob_felmyst_trail;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_kalecgos.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_kalecgos.cpp
index 2fcfdb43a5d..22328334919 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_kalecgos.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_kalecgos.cpp
@@ -13,14 +13,17 @@
 * along with 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: 95
 SDComment:
 SDCategory: Sunwell_Plateau
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_sunwell_plateau.h"
+
 enum Quotes
 {
     //Kalecgos dragon form
@@ -30,11 +33,13 @@ enum Quotes
     SAY_EVIL_SLAY1          = -1580003,
     SAY_EVIL_SLAY2          = -1580004,
     SAY_EVIL_ENRAGE         = -1580005,
+
     //Kalecgos humanoid form
     SAY_GOOD_AGGRO          = -1580006,
     SAY_GOOD_NEAR_DEATH     = -1580007,
     SAY_GOOD_NEAR_DEATH2    = -1580008,
     SAY_GOOD_PLRWIN         = -1580009,
+
     //Shattrowar
     SAY_SATH_AGGRO          = -1580010,
     SAY_SATH_DEATH          = -1580011,
@@ -44,6 +49,7 @@ enum Quotes
     SAY_SATH_SLAY2          = -1580015,
     SAY_SATH_ENRAGE         = -1580016
 };
+
 enum SpellIds
 {
     AURA_SUNWELL_RADIANCE       =   45769,
@@ -51,20 +57,25 @@ enum SpellIds
     AURA_SPECTRAL_REALM         =   46021,
     AURA_SPECTRAL_INVISIBILITY  =   44801,
     AURA_DEMONIC_VISUAL         =   44800,
+
     SPELL_SPECTRAL_BLAST        =   44869,
     SPELL_TELEPORT_SPECTRAL     =   46019,
     SPELL_ARCANE_BUFFET         =   45018,
     SPELL_FROST_BREATH          =   44799,
     SPELL_TAIL_LASH             =   45122,
+
     SPELL_BANISH                =   44836,
     SPELL_TRANSFORM_KALEC       =   44670,
     SPELL_ENRAGE                =   44807,
+
     SPELL_CORRUPTION_STRIKE     =   45029,
     SPELL_AGONY_CURSE           =   45032,
     SPELL_SHADOW_BOLT           =   45031,
+
     SPELL_HEROIC_STRIKE         =   45026,
     SPELL_REVITALIZE            =   45027
 };
+
 enum Creatures
 {
     MOB_KALECGOS    =  24850,
@@ -77,18 +88,26 @@ enum SWPActions
     DO_BANISH    =  2
 };
 
+
 #define GO_FAILED   "You are unable to use this currently."
+
 #define EMOTE_UNABLE_TO_FIND    "is unable to find Kalecgos"
+
 #define FLY_X   1679
 #define FLY_Y   900
 #define FLY_Z   82
+
 #define CENTER_X    1705
 #define CENTER_Y    930
 #define RADIUS      30
+
 #define DRAGON_REALM_Z  53.079
 #define DEMON_REALM_Z   -74.558
+
 #define MAX_PLAYERS_IN_SPECTRAL_REALM 0 //over this, teleport object won't work, 0 disables check
+
 uint32 WildMagic[]= { 44978, 45001, 45002, 45004, 45006, 45010 };
+
 struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
 {
     boss_kalecgosAI(Creature *c) : ScriptedAI(c)
@@ -102,7 +121,9 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
         if (TempSpell)
             TempSpell->EffectImplicitTargetB[0] = TARGET_UNIT_TARGET_ENEMY;
     }
+
     ScriptedInstance *pInstance;
+
     uint32 ArcaneBuffetTimer;
     uint32 FrostBreathTimer;
     uint32 WildMagicTimer;
@@ -112,12 +133,15 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
     uint32 TalkTimer;
     uint32 TalkSequence;
     uint32 ResetTimer;
+
     bool isFriendly;
     bool isEnraged;
     bool isBanished;
     bool JustReseted;
+
     uint64 SathGUID;
     uint64 DoorGUID;
+
     void Reset()
     {
         if (pInstance)
@@ -125,10 +149,12 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
             SathGUID = pInstance->GetData64(DATA_SATHROVARR);
             pInstance->SetData(DATA_KALECGOS_EVENT, NOT_STARTED);
         }
+
         if(Creature *Sath = Unit::GetCreature(*me, SathGUID))
             Sath->AI()->EnterEvadeMode();
+
         me->setFaction(14);
-        if(!JustReseted) //first reset at create
+        if(!JustReseted)//first reset at create
         {
             me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
             me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
@@ -143,12 +169,14 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
         SpectralBlastTimer = 20000+(rand()%5000);
         CheckTimer = 1000;
         ResetTimer = 30000;
+
         TalkTimer = 0;
         TalkSequence = 0;
         isFriendly = false;
         isEnraged = false;
         isBanished = false;
     }
+
     void EnterEvadeMode()
     {
         JustReseted = true;
@@ -156,6 +184,7 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
         ScriptedAI::EnterEvadeMode();
     }
+
     void DoAction(const int32 param)
     {
         switch (param)
@@ -170,6 +199,7 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
                 break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (TalkTimer)
@@ -209,6 +239,7 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
             }
             if (!UpdateVictim())
                 return;
+
             if (CheckTimer < diff)
             {
                 if(me->GetDistance(CENTER_X, CENTER_Y, DRAGON_REALM_Z) >= 75)
@@ -243,31 +274,36 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
                 }
                 CheckTimer = 1000;
             }else CheckTimer -= diff;
+
             if (ArcaneBuffetTimer < diff)
             {
                 DoCastAOE(SPELL_ARCANE_BUFFET);
                 ArcaneBuffetTimer = 8000;
             }else ArcaneBuffetTimer -= diff;
+
             if (FrostBreathTimer < diff)
             {
                 DoCastAOE(SPELL_FROST_BREATH);
                 FrostBreathTimer = 15000;
             }else FrostBreathTimer -= diff;
+
             if (TailLashTimer < diff)
             {
                 DoCastAOE(SPELL_TAIL_LASH);
                 TailLashTimer = 15000;
             }else TailLashTimer -= diff;
+
             if (WildMagicTimer < diff)
             {
                 DoCastAOE(WildMagic[rand()%6]);
                 WildMagicTimer = 20000;
             }else WildMagicTimer -= diff;
+
             if (SpectralBlastTimer < diff)
             {
                 std::list &m_threatlist = me->getThreatManager().getThreatList();
                 std::list targetList;
-                for (std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr)
+                for(std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr)
                     if((*itr)->getTarget() && (*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget()->GetGUID() != me->getVictim()->GetGUID() && !(*itr)->getTarget()->HasAura(AURA_SPECTRAL_EXHAUSTION) && (*itr)->getTarget()->GetPositionZ() > me->GetPositionZ()-5)
                         targetList.push_back((*itr)->getTarget());
                 if(targetList.empty())
@@ -283,12 +319,14 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
                     SpectralBlastTimer = 20000+rand()%5000;
                 }else SpectralBlastTimer = 1000;
             }else SpectralBlastTimer -= diff;
+
             DoMeleeAttackIfReady();
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
-        if(JustReseted) //boss is invisible, don't attack
+        if(JustReseted)//boss is invisible, don't attack
             return;
         if (!m_creature->getVictim() && who->isTargetableForAttack() && (m_creature->IsHostileTo(who)))
         {
@@ -299,23 +337,28 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
             }
         }
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage >= me->GetHealth() && done_by != me)
             damage = 0;
     }
+
     void EnterCombat(Unit* who)
     {
         me->SetStandState(UNIT_STAND_STATE_STAND);
         DoScriptText(SAY_EVIL_AGGRO, me);
         DoZoneInCombat();
+
         if (pInstance)
             pInstance->SetData(DATA_KALECGOS_EVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_EVIL_SLAY1,SAY_EVIL_SLAY2), me);
     }
+
     void MovementInform(uint32 type,uint32 id)
     {
         me->SetVisibility(VISIBILITY_OFF);
@@ -327,6 +370,7 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
             TalkTimer = 1000;
         }
     }
+
     void GoodEnding()
     {
         switch(TalkSequence)
@@ -348,6 +392,7 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
             break;
         }
     }
+
     void BadEnding()
     {
         switch(TalkSequence)
@@ -369,6 +414,7 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
 {
     boss_sathrovarrAI(Creature *c) : ScriptedAI(c)
@@ -377,16 +423,21 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
         KalecGUID = 0;
         KalecgosGUID = 0;
     }
+
     ScriptedInstance *pInstance;
+
     uint32 CorruptionStrikeTimer;
     uint32 AgonyCurseTimer;
     uint32 ShadowBoltTimer;
     uint32 CheckTimer;
     uint32 ResetThreat;
+
     uint64 KalecGUID;
     uint64 KalecgosGUID;
+
     bool isEnraged;
     bool isBanished;
+
     void Reset()
     {
         me->SetHealth(me->GetMaxHealth());//dunno why it does not resets health at evade..
@@ -402,6 +453,7 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
                 Kalec->setDeathState(JUST_DIED);
             KalecGUID = 0;
         }
+
         ShadowBoltTimer = 7000 + rand()%3 * 1000;
         AgonyCurseTimer = 20000;
         CorruptionStrikeTimer = 13000;
@@ -409,9 +461,11 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
         ResetThreat = 1000;
         isEnraged = false;
         isBanished = false;
+
         me->CastSpell(me, AURA_DEMONIC_VISUAL, true);
         TeleportAllPlayersBack();
     }
+
     void EnterCombat(Unit* who)
     {
         if(Creature *Kalec = me->SummonCreature(MOB_KALEC, me->GetPositionX() + 10, me->GetPositionY() + 5, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0))
@@ -423,11 +477,13 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
         }
         DoScriptText(SAY_SATH_AGGRO, me);
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage >= me->GetHealth() && done_by != me)
             damage = 0;
     }
+
     void KilledUnit(Unit *target)
     {
         if (target->GetGUID() == KalecGUID)
@@ -443,6 +499,7 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
         }
         DoScriptText(RAND(SAY_SATH_SLAY1,SAY_SATH_SLAY2), me);
     }
+
     void JustDied(Unit *killer)
     {
         DoScriptText(SAY_SATH_DEATH, me);
@@ -453,15 +510,17 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
             CAST_AI(boss_kalecgosAI, Kalecgos->AI())->TalkTimer = 1;
             CAST_AI(boss_kalecgosAI, Kalecgos->AI())->isFriendly = true;
         }
+
         if (pInstance)
             pInstance->SetData(DATA_KALECGOS_EVENT, DONE);
     }
+
     void TeleportAllPlayersBack()
     {
         Map* pMap = me->GetMap();
         if (!pMap->IsDungeon()) return;
         Map::PlayerList const &PlayerList = pMap->GetPlayers();
-        for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+        for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
         {
             if(i->getSource()->GetPositionZ() <= DRAGON_REALM_Z-5)
             {
@@ -470,6 +529,7 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
             }
         }
     }
+
     void DoAction(const int32 param)
     {
         switch (param)
@@ -484,12 +544,14 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
                 break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(!me->HasAura(AURA_SPECTRAL_INVISIBILITY))
             me->CastSpell(me, AURA_SPECTRAL_INVISIBILITY, true);
         if (!UpdateVictim())
             return;
+
         if (CheckTimer < diff)
         {
             Creature *Kalec = Unit::GetCreature(*me, KalecGUID);
@@ -535,9 +597,10 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
             }
             CheckTimer = 1000;
         }else CheckTimer -= diff;
+
         if (ResetThreat < diff)
         {
-            for (std::list::iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr)
+            for(std::list::iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr)
             {
                 if(Unit* pUnit = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()))
                 {
@@ -549,12 +612,14 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
             }
             ResetThreat = 1000;
         }else ResetThreat -= diff;
+
         if (ShadowBoltTimer < diff)
         {
             if(!(rand()%5))DoScriptText(SAY_SATH_SPELL1, me);
             DoCast(me, SPELL_SHADOW_BOLT);
             ShadowBoltTimer = 7000+(rand()%3000);
         }else ShadowBoltTimer -= diff;
+
         if (AgonyCurseTimer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
@@ -562,38 +627,49 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
             DoCast(target, SPELL_AGONY_CURSE);
             AgonyCurseTimer = 20000;
         }else AgonyCurseTimer -= diff;
+
         if (CorruptionStrikeTimer < diff)
         {
             if(!(rand()%5))DoScriptText(SAY_SATH_SPELL2, me);
             DoCast(me->getVictim(), SPELL_CORRUPTION_STRIKE);
             CorruptionStrikeTimer = 13000;
         }else CorruptionStrikeTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_kalecAI : public ScriptedAI
 {
     ScriptedInstance *pInstance;
+
     uint32 RevitalizeTimer;
     uint32 HeroicStrikeTimer;
     uint32 YellTimer;
     uint32 YellSequence;
+
     uint64 SathGUID;
+
     bool isEnraged; // if demon is enraged
+
     boss_kalecAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     void Reset()
     {
         if (pInstance)
             SathGUID = pInstance->GetData64(DATA_SATHROVARR);
+
         RevitalizeTimer = 5000;
         HeroicStrikeTimer = 3000;
         YellTimer = 5000;
         YellSequence = 0;
+
         isEnraged = false;
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by->GetGUID() != SathGUID)
@@ -601,12 +677,14 @@ struct TRINITY_DLL_DECL boss_kalecAI : public ScriptedAI
         else if (isEnraged)
             damage *= 3;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(!me->HasAura(AURA_SPECTRAL_INVISIBILITY))
             me->CastSpell(me, AURA_SPECTRAL_INVISIBILITY, true);
         if (!UpdateVictim())
             return;
+
         if (YellTimer < diff)
         {
             switch(YellSequence)
@@ -634,26 +712,30 @@ struct TRINITY_DLL_DECL boss_kalecAI : public ScriptedAI
             }
             YellTimer = 5000;
         }
+
         if (RevitalizeTimer < diff)
         {
             DoCast(me, SPELL_REVITALIZE);
             RevitalizeTimer = 5000;
         }else RevitalizeTimer -= diff;
+
         if (HeroicStrikeTimer < diff)
         {
             DoCast(me->getVictim(), SPELL_HEROIC_STRIKE);
             HeroicStrikeTimer = 2000;
         }else HeroicStrikeTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 bool GOkalecgos_teleporter(Player* pPlayer, GameObject* pGo)
 {
     uint32 SpectralPlayers = 0;
     Map* pMap = pGo->GetMap();
     if (!pMap->IsDungeon()) return true;
     Map::PlayerList const &PlayerList = pMap->GetPlayers();
-    for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
     {
         if(i->getSource() && i->getSource()->GetPositionZ() < DEMON_REALM_Z + 5)
             SpectralPlayers++;
@@ -664,18 +746,22 @@ bool GOkalecgos_teleporter(Player* pPlayer, GameObject* pGo)
         pPlayer->CastSpell(pPlayer, SPELL_TELEPORT_SPECTRAL, true);
     return true;
 }
+
 CreatureAI* GetAI_boss_kalecgos(Creature* pCreature)
 {
     return new boss_kalecgosAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_Sathrovarr(Creature* pCreature)
 {
     return new boss_sathrovarrAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_kalec(Creature* pCreature)
 {
     return new boss_kalecAI (pCreature);
 }
+
 void AddSC_boss_kalecgos()
 {
     Script *newscript;
@@ -683,14 +769,17 @@ void AddSC_boss_kalecgos()
     newscript->Name = "boss_kalecgos";
     newscript->GetAI = &GetAI_boss_kalecgos;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_sathrovarr";
     newscript->GetAI = &GetAI_boss_Sathrovarr;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_kalec";
     newscript->GetAI = &GetAI_boss_kalec;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "kalecgos_teleporter";
     newscript->pGOHello = &GOkalecgos_teleporter;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_kiljaeden.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_kiljaeden.cpp
index 84627aca7c7..3bb91d52110 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_kiljaeden.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_kiljaeden.cpp
@@ -13,17 +13,21 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Boss_Kiljaeden
 SD%Complete: 70
 SDComment: Phase4, Phase5, Shadow Spike, Armageddon
 SDCategory: Sunwell_Plateau
 EndScriptData */
+
 //TODO rewrite Amagedon
 //TODO Remove blue visual from Orbs on reset and if it is used
+
 #include "precompiled.h"
 #include "def_sunwell_plateau.h"
 #include 
+
 /*** Speech and sounds***/
 enum Speeches
 {
@@ -33,6 +37,7 @@ enum Speeches
     SAY_KJ_OFFCOMBAT3   = -1580068,
     SAY_KJ_OFFCOMBAT4   = -1580069,
     SAY_KJ_OFFCOMBAT5   = -1580070,
+
     // Encounter speech and sounds
     SAY_KJ_EMERGE       = -1580071,
     SAY_KJ_SLAY1        = -1580072,
@@ -47,6 +52,7 @@ enum Speeches
     SAY_KJ_PHASE5       = -1580081,
     SAY_KJ_DEATH        = -1580093,
     EMOTE_KJ_DARKNESS   = -1580094,
+
     /*** Kalecgos - Anveena speech at the beginning of Phase 5; Anveena's sacrifice ***/
     SAY_KALECGOS_AWAKEN     = -1580082,
     SAY_ANVEENA_IMPRISONED  = -1580083,
@@ -58,6 +64,7 @@ enum Speeches
     SAY_ANVEENA_GOODBYE     = -1580089,
     SAY_KALECGOS_GOODBYE    = -1580090,
     SAY_KALECGOS_ENCOURAGE  = -1580091,
+
     /*** Kalecgos says throughout the fight ***/
     SAY_KALECGOS_JOIN       = -1580092,
     SAY_KALEC_ORB_READY1    = -1580095,
@@ -65,6 +72,7 @@ enum Speeches
     SAY_KALEC_ORB_READY3    = -1580097,
     SAY_KALEC_ORB_READY4    = -1580098
 };
+
 /*** Spells used during the encounter ***/
 enum SpellIds
 {
@@ -73,8 +81,10 @@ enum SpellIds
     SPELL_SHADOW_INFUSION                               = 45772, // They gain this at 20% - Immunity to Stun/Silence and makes them look angry!
     SPELL_FELFIRE_PORTAL                                = 46875, // Creates a portal that spawns Felfire Fiends (LIVE FOR THE SWARM!1 FOR THE OVERMIND!)
     SPELL_SHADOW_CHANNELING                             = 46757, // Channeling animation out of combat
+
     /* Volatile Felfire Fiend's spells */
     SPELL_FELFIRE_FISSION                               = 45779, // Felfire Fiends explode when they die or get close to target.
+
     /* Kil'Jaeden's spells and cosmetics */
     SPELL_TRANS                                         = 23188, // Surprisingly, this seems to be the right spell.. (Where is it used?)
     SPELL_REBIRTH                                       = 44200, // Emerge from the Sunwell
@@ -82,15 +92,18 @@ enum SpellIds
     SPELL_SOUL_FLAY_SLOW                                = 47106,
     SPELL_LEGION_LIGHTNING                              = 45664, // Chain Lightning, 4 targets, ~3k Shadow damage, 1.5k mana burn
     SPELL_FIRE_BLOOM                                    = 45641, // Places a debuff on 5 raid members, which causes them to deal 2k Fire damage to nearby allies and selves. MIGHT NOT WORK
+
     SPELL_SINISTER_REFLECTION                           = 45785, // Summon shadow copies of 5 raid members that fight against KJ's enemies
     SPELL_COPY_WEAPON                                   = 41055, // }
     SPELL_COPY_WEAPON2                                  = 41054, // }
     SPELL_COPY_OFFHAND                                  = 45206, // }- Spells used in Sinister Reflection creation
     SPELL_COPY_OFFHAND_WEAPON                           = 45205, // }
+
     SPELL_SHADOW_SPIKE                                  = 46680, // Bombard random raid members with Shadow Spikes (Very similar to Void Reaver orbs)
     SPELL_FLAME_DART                                    = 45737, // Bombards the raid with flames every 3(?) seconds
     SPELL_DARKNESS_OF_A_THOUSAND_SOULS                  = 46605, // Begins a 8-second channeling, after which he will deal 50'000 damage to the raid
     SPELL_DARKNESS_OF_A_THOUSAND_SOULS_DAMAGE           = 45657,
+
     /* Armageddon spells wrong visual */
     SPELL_ARMAGEDDON_TRIGGER                            = 45909, // Meteor spell trigger missile should cast Creature on himself
     SPELL_ARMAGEDDON_VISUAL                             = 45911, // Does the hellfire visual to indicate where the meteor missle lands
@@ -98,34 +111,47 @@ enum SpellIds
     SPELL_ARMAGEDDON_VISUAL3                            = 24207, // This shouldn't correct but same as seen on the movie
     SPELL_ARMAGEDDON_SUMMON_TRIGGER                     = 45921, // Summons the triggers that cast the spells on himself need random target select
     SPELL_ARMAGEDDON_DAMAGE                             = 45915, // This does the area damage
+
     /* Shield Orb Spells*/
     SPELL_SHADOW_BOLT                                   = 45680, //45679 would be correct but triggers to often //TODO fix console error
 
+
     /* Anveena's spells and cosmetics (Or, generally, everything that has "Anveena" in name) */
     SPELL_ANVEENA_PRISON                                = 46367, // She hovers locked within a bubble
     SPELL_ANVEENA_ENERGY_DRAIN                          = 46410, // Sunwell energy glow animation (Control mob uses this)
     SPELL_SACRIFICE_OF_ANVEENA                          = 46474, // This is cast on Kil'Jaeden when Anveena sacrifices herself into the Sunwell
+
     /* Sinister Reflection Spells */
     SPELL_SR_CURSE_OF_AGONY                             = 46190,
     SPELL_SR_SHADOW_BOLT                                = 47076,
+
     SPELL_SR_EARTH_SHOCK                                = 47071,
+
     SPELL_SR_FIREBALL                                   = 47074,
+
     SPELL_SR_HEMORRHAGE                                 = 45897,
+
     SPELL_SR_HOLY_SHOCK                                 = 38921,
     SPELL_SR_HAMMER_OF_JUSTICE                          = 37369,
+
     SPELL_SR_HOLY_SMITE                                 = 47077,
     SPELL_SR_RENEW                                      = 47079,
+
     SPELL_SR_SHOOT                                      = 16496,
     SPELL_SR_MULTI_SHOT                                 = 48098,
     SPELL_SR_WING_CLIP                                  = 40652,
+
     SPELL_SR_WHIRLWIND                                  = 17207,
+
     SPELL_SR_MOONFIRE                                   = 47072,
     //SPELL_SR_PLAGU STRIKE                             = 58843, Dk Spell!
+
     /*** Other Spells (used by players, etc) ***/
     SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT                  = 45839, // Possess the blue dragon from the orb to help the raid.
     SPELL_ENTROPIUS_BODY                                = 46819, // Visual for Entropius at the Epilogue
     SPELL_RING_OF_BLUE_FLAMES                           = 45825  //Cast this spell when the go is activated
 };
+
 enum CreatureIds
 {
     CREATURE_ANVEENA                        = 26046, // Embodiment of the Sunwell
@@ -143,13 +169,17 @@ enum CreatureIds
     CREATURE_SPIKE_TARGET2                  = 30614,
     CREATURE_SINISTER_REFLECTION            = 25708  //Sinister Relection spawnd on Phase swichtes
 };
+
 /*** GameObjects ***/
 #define GAMEOBJECT_ORB_OF_THE_BLUE_DRAGONFLIGHT 188415
+
 /*** Error messages ***/
 #define ERROR_KJ_NOT_SUMMONED "TSCR ERROR: Unable to summon Kil'Jaeden for some reason"
+
 /*** Others ***/
 #define FLOOR_Z 28.050388
 #define SHIELD_ORB_Z 45.000
+
 enum Phase
 {
     PHASE_DECEIVERS     = 1, // Fight 3 adds
@@ -158,22 +188,27 @@ enum Phase
     PHASE_ARMAGEDDON    = 4, // At 55%, he gains even more abilities
     PHASE_SACRIFICE     = 5, // At 25%, Anveena sacrifices herself into the Sunwell; at this point he becomes enraged and has *significally* shorter cooldowns.
 };
+
 //Timers
 enum KilJaedenTimers {
     TIMER_KALEC_JOIN       = 0,
+
     //Phase 2 Timer
     TIMER_SOUL_FLAY           = 1,
     TIMER_LEGION_LIGHTNING = 2,
     TIMER_FIRE_BLOOM       = 3,
     TIMER_SUMMON_SHILEDORB = 4,
+
     //Phase 3 Timer
     TIMER_SHADOW_SPIKE     = 5,
     TIMER_FLAME_DART       = 6,
     TIMER_DARKNESS         = 7,
     TIMER_ORBS_EMPOWER     = 8,
+
     //Phase 4 Timer
     TIMER_ARMAGEDDON       = 9
 };
+
 // Locations of the Hand of Deceiver adds
 float DeceiverLocations[3][3]=
 {
@@ -181,6 +216,7 @@ float DeceiverLocations[3][3]=
     {1684.099, 618.848, 0.589},
     {1694.170, 612.272, 1.416},
 };
+
 // Locations, where Shield Orbs will spawn
 float ShieldOrbLocations[4][2]=
 {
@@ -189,12 +225,14 @@ float ShieldOrbLocations[4][2]=
     {12, 3.14/0.7}, // Second one spawns southeast
     {12, 3.14*3.8}  // Third one spawns (?)
 };
+
 float OrbLocations[4][5] = {
     (1694.48, 674.29,  28.0502, 4.86985),
     (1745.68, 621.823, 28.0505, 2.93777),
     (1704.14, 583.591, 28.1696, 1.59003),
     (1653.12, 635.41,  28.0932, 0.0977725),
 };
+
 struct Speech
 {
     int32 textid;
@@ -215,6 +253,7 @@ static Speech Sacrifice[]=
     {SAY_KJ_PHASE5,             CREATURE_KILJAEDEN, 8000},
     {SAY_KALECGOS_ENCOURAGE,    CREATURE_KALECGOS,  5000}
 };
+
 class AllOrbsInGrid
 {
 public:
@@ -226,6 +265,7 @@ public:
         return false;
     }
 };
+
 bool GOHello_go_orb_of_the_blue_flight(Player* pPlayer, GameObject* pGo)
 {
     if (pGo->GetUInt32Value(GAMEOBJECT_FACTION) == 35)
@@ -242,7 +282,7 @@ bool GOHello_go_orb_of_the_blue_flight(Player* pPlayer, GameObject* pGo)
         pGo->GetPosition(x,y,z);
         // this won't work. need rewritten
         /*
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (DynamicObject* Dyn = Kalec->GetDynObject(SPELL_RING_OF_BLUE_FLAMES))
             {
@@ -259,6 +299,7 @@ bool GOHello_go_orb_of_the_blue_flight(Player* pPlayer, GameObject* pGo)
     }
     return true;
 }
+
 //AI for Kalecgos
 struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
 {
@@ -266,13 +307,16 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     GameObject* Orb[4];
     ScriptedInstance* pInstance;
     uint8 OrbsEmpowered;
     uint8 EmpowerCount;
+
     bool Searched;
+
     void InitializeAI(){
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
             Orb[i] = NULL;
         FindOrbs();
         OrbsEmpowered = 0;
@@ -282,9 +326,12 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
         m_creature->setActive(true);
         Searched = false;
         FindOrbs();
+
         ScriptedAI::InitializeAI();
     }
+
     void Reset(){}
+
     void FindOrbs()
     {
         CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
@@ -300,16 +347,18 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
         if (orbList.empty())
             return;
         uint8 i = 0;
-        for (std::list::iterator itr = orbList.begin(); itr != orbList.end(); ++itr, ++i){
+        for(std::list::iterator itr = orbList.begin(); itr != orbList.end(); ++itr, ++i){
             Orb[i] = pInstance ? pInstance->instance->GetGameObject(pInstance->GetData64((*itr)->GetGUID())) : NULL;
         }
     }
+
     void ResetOrbs()
     {
         m_creature->RemoveDynObject(SPELL_RING_OF_BLUE_FLAMES);
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
             if (Orb[i]) Orb[i]->SetUInt32Value(GAMEOBJECT_FACTION, 0);
     }
+
     void EmpowerOrb(bool all)
     {
         if (!Orb[OrbsEmpowered])
@@ -318,7 +367,7 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
         if (all)
         {
             m_creature->RemoveDynObject(SPELL_RING_OF_BLUE_FLAMES);
-            for (uint8 i = 0; i < 4; ++i)
+            for(uint8 i = 0; i < 4; ++i)
             {
                 if (!Orb[i]) return;
                 Orb[i]->CastSpell(m_creature, SPELL_RING_OF_BLUE_FLAMES);
@@ -333,7 +382,7 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
             /*
             float x,y,z, dx,dy,dz;
             Orb[random]->GetPosition(x,y,z);
-            for (uint8 i = 0; i < 4; ++i){
+            for(uint8 i = 0; i < 4; ++i){
                 DynamicObject* Dyn = m_creature->GetDynObject(SPELL_RING_OF_BLUE_FLAMES);
                 if (Dyn){
                     Dyn->GetPosition(dx,dy,dz);
@@ -353,6 +402,7 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
         ++OrbsEmpowered;
         }
         ++EmpowerCount;
+
         switch(EmpowerCount)
         {
             case 1: DoScriptText(SAY_KALEC_ORB_READY1, m_creature); break;
@@ -361,6 +411,7 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
             case 4: DoScriptText(SAY_KALEC_ORB_READY4, m_creature); break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Searched)
@@ -368,14 +419,17 @@ struct TRINITY_DLL_DECL boss_kalecgos_kjAI : public ScriptedAI
             FindOrbs();
             Searched = true;
         }
+
         if (OrbsEmpowered == 4)
             OrbsEmpowered = 0;
     }
 };
+
 CreatureAI* GetAI_boss_kalecgos_kj(Creature* pCreature)
 {
     return new boss_kalecgos_kjAI (pCreature);
 }
+
 //AI for Kil'jaeden
 struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
 {
@@ -383,57 +437,72 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     SummonList Summons;
     Creature*  Kalec;
     Unit*      randomPlayer;
+
     uint8 Phase;
     uint8 ActiveTimers;
+
     uint32 Timer[10];
     uint32 WaitTimer;
+
     /* Boolean */
     bool IsKalecJoined;
     bool IsInDarkness;
     bool TimerIsDeactiveted[10];
     bool IsWaiting;
     bool OrbActivated;
+
     void Reset()
     {
         // TODO: Fix timers
         Timer[TIMER_KALEC_JOIN]       = 26000;
+
         //Phase 2 Timer
         Timer[TIMER_SOUL_FLAY]        = 20000;
         Timer[TIMER_LEGION_LIGHTNING] = 40000;
         Timer[TIMER_FIRE_BLOOM]       = 30000;
         Timer[TIMER_SUMMON_SHILEDORB] = 45000;
+
         //Phase 3 Timer
         Timer[TIMER_SHADOW_SPIKE]     = 4000;
         Timer[TIMER_FLAME_DART]       = 3000;
         Timer[TIMER_DARKNESS]         = 45000;
         Timer[TIMER_ORBS_EMPOWER]     = 35000;
+
         //Phase 4 Timer
         Timer[TIMER_ARMAGEDDON]       = 2000;
+
         ActiveTimers = 5;
         WaitTimer    = 0;
+
         Phase = PHASE_DECEIVERS;
+
         IsKalecJoined = false;
         IsInDarkness  = false;
         IsWaiting     = false;
         OrbActivated  = false;
+
         if(pInstance)
             Kalec = CAST_CRE(Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_KJ)));
         ChangeTimers(false, 0);
     }
+
     void ChangeTimers(bool status, uint32 WTimer)
     {
-        for (uint8 i = 0; i < 10; ++i)
+        for(uint8 i = 0; i < 10; ++i)
             TimerIsDeactiveted[i] = status;
         TimerIsDeactiveted[TIMER_KALEC_JOIN] = IsKalecJoined;
+
         if (WTimer > 0)
         {
             IsWaiting = true;
             WaitTimer = WTimer;
         }
+
         if (OrbActivated)
             TimerIsDeactiveted[TIMER_ORBS_EMPOWER] = true;
         if (Timer[TIMER_SHADOW_SPIKE] == 0)
@@ -441,53 +510,59 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
         if (Phase == PHASE_SACRIFICE)
             TimerIsDeactiveted[TIMER_SUMMON_SHILEDORB] = true;
     }
+
     void JustSummoned(Creature* summoned)
     {
         if (summoned->GetEntry() == CREATURE_ARMAGEDDON_TARGET)
         {
             summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
             summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
-        }
-        else
-        {
+        }else{
             summoned->SetLevel(m_creature->getLevel());
         }
         summoned->setFaction(m_creature->getFaction());
         Summons.Summon(summoned);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_KJ_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_KILJAEDEN_EVENT, DONE);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_KJ_SLAY1,SAY_KJ_SLAY2), m_creature);
     }
+
     void EnterEvadeMode()
     {
         Scripted_NoMovementAI::EnterEvadeMode();
         Summons.DespawnAll();
+
         // Reset the controller
         if (pInstance)
             if(Creature* Control = CAST_CRE(Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KILJAEDEN_CONTROLLER))))
                 CAST_AI(Scripted_NoMovementAI, Control->AI())->Reset();
     }
+
     void EnterCombat(Unit* who)
     {
         DoZoneInCombat();
         DoScriptText(SAY_KJ_EMERGE, m_creature);
     }
+
     void CastSinisterReflection()
     {
         DoScriptText(RAND(SAY_KJ_REFLECTION1,SAY_KJ_REFLECTION2), m_creature);
         DoCast(m_creature, SPELL_SINISTER_REFLECTION, true);
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             float x,y,z;
             Unit* target;
-            for (uint8 z = 0; z < 6; ++z)
+            for(uint8 z = 0; z < 6; ++z)
             {
                 target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                 if (!target->HasAura(SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT,0))break;
@@ -498,10 +573,12 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
                 SinisterReflection->AI()->AttackStart(target);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim() || Phase < PHASE_NORMAL)
             return;
+
         if (IsWaiting)
         {
             if (WaitTimer < diff)
@@ -510,7 +587,8 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
                 ChangeTimers(false, 0);
             } else WaitTimer -= diff;
         }
-        for (uint8 t = 0; t < ActiveTimers; ++t)
+
+        for(uint8 t = 0; t < ActiveTimers; ++t)
         {
             if (Timer[t] < diff && !TimerIsDeactiveted[t])
             {
@@ -536,7 +614,7 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
                         if (!m_creature->IsNonMeleeSpellCasted(false))
                         {
                             m_creature->RemoveAurasDueToSpell(SPELL_SOUL_FLAY);
-                            for (uint8 z = 0; z < 6; ++z)
+                            for(uint8 z = 0; z < 6; ++z)
                             {
                                 randomPlayer = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                                 if (!randomPlayer->HasAura(SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT,0)) break;
@@ -559,7 +637,7 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
                         }
                         break;
                     case TIMER_SUMMON_SHILEDORB:
-                        for (uint8 i = 1; i < Phase; ++i)
+                        for(uint8 i = 1; i < Phase; ++i)
                         {
                             float sx, sy;
                             sx = ShieldOrbLocations[0][0] + sin(ShieldOrbLocations[i][0]);
@@ -626,7 +704,7 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
                         break;
                     case TIMER_ARMAGEDDON: //Phase 4
                         Unit* target;
-                        for (uint8 z = 0; z < 6; ++z)
+                        for(uint8 z = 0; z < 6; ++z)
                         {
                             target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                             if (!target->HasAura(SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT,0)) break;
@@ -644,12 +722,13 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
             }
         }
             //Time runs over!
-            for (uint8 i = 0; i < ActiveTimers; ++i)
+            for(uint8 i = 0; i < ActiveTimers; ++i)
                 if (!TimerIsDeactiveted[i])
                 {
                     Timer[i] -= diff;
                     if (((int32)Timer[i]) < 0) Timer[i] = 0;
                 }
+
         //Phase 3
         if (Phase <= PHASE_NORMAL)
         {
@@ -663,6 +742,7 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
             }
             else return;
         }
+
         //Phase 4
         if (Phase <= PHASE_DARKNESS)
         {
@@ -675,6 +755,7 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
             }
             else return;
         }
+
         //Phase 5 specific spells all we can
         if (Phase <= PHASE_ARMAGEDDON)
         {
@@ -689,12 +770,15 @@ struct TRINITY_DLL_DECL boss_kiljaedenAI : public Scripted_NoMovementAI
             }
             else return;
         }
+
 }
 };
+
 CreatureAI* GetAI_boss_kiljaeden(Creature* pCreature)
 {
     return new boss_kiljaedenAI (pCreature);
 }
+
 //AI for Kil'jaeden Event Controller
 struct TRINITY_DLL_DECL mob_kiljaeden_controllerAI : public Scripted_NoMovementAI
 {
@@ -702,14 +786,18 @@ struct TRINITY_DLL_DECL mob_kiljaeden_controllerAI : public Scripted_NoMovementA
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     Creature* KalecKJ;
     SummonList Summons;
+
     bool SummonedDeceivers;
     bool KiljaedenDeath;
+
     uint32 RandomSayTimer;
     uint32 Phase;
     uint8 DeceiverDeathCount;
+
     void InitializeAI()
     {
         if(pInstance)
@@ -717,8 +805,10 @@ struct TRINITY_DLL_DECL mob_kiljaeden_controllerAI : public Scripted_NoMovementA
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->addUnitState(UNIT_STAT_STUNNED);
+
         ScriptedAI::InitializeAI();
     }
+
     void Reset()
     {
         Phase = PHASE_DECEIVERS;
@@ -730,6 +820,7 @@ struct TRINITY_DLL_DECL mob_kiljaeden_controllerAI : public Scripted_NoMovementA
         RandomSayTimer = 30000;
         Summons.DespawnAll();
     }
+
     void JustSummoned(Creature* summoned)
     {
         switch(summoned->GetEntry())
@@ -750,6 +841,7 @@ struct TRINITY_DLL_DECL mob_kiljaeden_controllerAI : public Scripted_NoMovementA
         }
         Summons.Summon(summoned);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (RandomSayTimer < diff && pInstance && pInstance->GetData(DATA_MURU_EVENT) != DONE && pInstance->GetData(DATA_KILJAEDEN_EVENT) == NOT_STARTED)
@@ -757,14 +849,17 @@ struct TRINITY_DLL_DECL mob_kiljaeden_controllerAI : public Scripted_NoMovementA
             DoScriptText(RAND(SAY_KJ_OFFCOMBAT1,SAY_KJ_OFFCOMBAT2,SAY_KJ_OFFCOMBAT3,SAY_KJ_OFFCOMBAT4,SAY_KJ_OFFCOMBAT5), m_creature);
             RandomSayTimer = 30000;
         } else RandomSayTimer -= diff;
+
         if (!SummonedDeceivers)
         {
             for (uint8 i = 0; i < 3; ++i)
                 m_creature->SummonCreature(CREATURE_HAND_OF_THE_DECEIVER, DeceiverLocations[i][0], DeceiverLocations[i][1], FLOOR_Z, DeceiverLocations[i][2], TEMPSUMMON_DEAD_DESPAWN, 0);
+
             DoSpawnCreature(CREATURE_ANVEENA,  0, 0, 40, 0, TEMPSUMMON_DEAD_DESPAWN, 0);
             DoCast(m_creature, SPELL_ANVEENA_ENERGY_DRAIN);
             SummonedDeceivers = true;
         }
+
         if (DeceiverDeathCount > 2 && Phase == PHASE_DECEIVERS)
         {
             m_creature->RemoveAurasDueToSpell(SPELL_ANVEENA_ENERGY_DRAIN);
@@ -773,10 +868,12 @@ struct TRINITY_DLL_DECL mob_kiljaeden_controllerAI : public Scripted_NoMovementA
         }
     }
 };
+
 CreatureAI* GetAI_mob_kiljaeden_controller(Creature* pCreature)
 {
     return new mob_kiljaeden_controllerAI (pCreature);
 }
+
 //AI for Hand of the Deceiver
 struct TRINITY_DLL_DECL mob_hand_of_the_deceiverAI : public ScriptedAI
 {
@@ -785,8 +882,10 @@ struct TRINITY_DLL_DECL mob_hand_of_the_deceiverAI : public ScriptedAI
         pInstance = c->GetInstanceData();
     }
     ScriptedInstance* pInstance;
+
     uint32 ShadowBoltVolleyTimer;
     uint32 FelfirePortalTimer;
+
     void Reset()
     {
         // TODO: Timers!
@@ -795,11 +894,13 @@ struct TRINITY_DLL_DECL mob_hand_of_the_deceiverAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(DATA_KILJAEDEN_EVENT, NOT_STARTED);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->setFaction(m_creature->getFaction());
         summoned->SetLevel(m_creature->getLevel());
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
@@ -810,34 +911,41 @@ struct TRINITY_DLL_DECL mob_hand_of_the_deceiverAI : public ScriptedAI
         }
         m_creature->InterruptNonMeleeSpells(true);
     }
+
     void JustDied(Unit* killer)
     {
         if (!pInstance)
             return;
+
         if (Creature* Control = CAST_CRE(Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KILJAEDEN_CONTROLLER))))
             ++(CAST_AI(mob_kiljaeden_controllerAI, Control->AI())->DeceiverDeathCount);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!me->isInCombat())
             DoCast(m_creature, SPELL_SHADOW_CHANNELING);
+
         if (!UpdateVictim())
             return;
+
         // Gain Shadow Infusion at 20% health
         if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) && !m_creature->HasAura(SPELL_SHADOW_INFUSION, 0))
             DoCast(m_creature, SPELL_SHADOW_INFUSION, true);
+
         // Shadow Bolt Volley - Shoots Shadow Bolts at all enemies within 30 yards, for ~2k Shadow damage.
         if (ShadowBoltVolleyTimer < diff){
             DoCast(m_creature->getVictim(), SPELL_SHADOW_BOLT_VOLLEY);
             ShadowBoltVolleyTimer = 12000;
         }else ShadowBoltVolleyTimer -= diff;
+
         // Felfire Portal - Creatres a portal, that spawns Volatile Felfire Fiends, which do suicide bombing.
         if (FelfirePortalTimer < diff){
             Creature* Portal = DoSpawnCreature(CREATURE_FELFIRE_PORTAL, 0, 0,0, 0, TEMPSUMMON_TIMED_DESPAWN, 20000);
             if (Portal)
             {
                 std::list::iterator itr;
-                for (itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++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)
@@ -846,36 +954,46 @@ struct TRINITY_DLL_DECL mob_hand_of_the_deceiverAI : public ScriptedAI
             }
             FelfirePortalTimer = 20000;
         }else FelfirePortalTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_hand_of_the_deceiver(Creature* pCreature)
 {
     return new mob_hand_of_the_deceiverAI (pCreature);
 }
+
 //AI for Felfire Portal
 struct TRINITY_DLL_DECL mob_felfire_portalAI : public Scripted_NoMovementAI
 {
     mob_felfire_portalAI(Creature* c) : Scripted_NoMovementAI(c) {}
+
     uint32 SpawnFiendTimer;
+
     void InitializeAI()
     {
         SpawnFiendTimer = 5000;
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
         ScriptedAI::InitializeAI();
     }
+
     // TODO: Timers
     void Reset() {}
+
     void JustSummoned(Creature* summoned)
     {
         summoned->setFaction(m_creature->getFaction());
         summoned->SetLevel(m_creature->getLevel());
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (SpawnFiendTimer < diff)
         {
             Creature* Fiend = DoSpawnCreature(CREATURE_VOLATILE_FELFIRE_FIEND, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 20000);
@@ -885,35 +1003,44 @@ struct TRINITY_DLL_DECL mob_felfire_portalAI : public Scripted_NoMovementAI
         }else SpawnFiendTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_felfire_portal(Creature* pCreature)
 {
     return new mob_felfire_portalAI (pCreature);
 }
+
 //AI for Felfire Fiend
 struct TRINITY_DLL_DECL mob_volatile_felfire_fiendAI : public ScriptedAI
 {
     mob_volatile_felfire_fiendAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 ExplodeTimer;
+
     bool LockedTarget;
+
     void Reset()
     {
         ExplodeTimer = 2000;
         LockedTarget = false;
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage > m_creature->GetHealth())
             DoCast(m_creature, SPELL_FELFIRE_FISSION, true);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (!LockedTarget)
         {
             m_creature->AddThreat(m_creature->getVictim(), 10000000.0f);
             LockedTarget = true;
         }
+
         if (ExplodeTimer)
         {
             if (ExplodeTimer < diff)
@@ -927,21 +1054,26 @@ struct TRINITY_DLL_DECL mob_volatile_felfire_fiendAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_mob_volatile_felfire_fiend(Creature* pCreature)
 {
     return new mob_volatile_felfire_fiendAI (pCreature);
 }
+
 //AI for Armageddon target
 struct TRINITY_DLL_DECL mob_armageddonAI : public Scripted_NoMovementAI
 {
     mob_armageddonAI(Creature* c) : Scripted_NoMovementAI(c) {}
+
     uint8 Spell;
     uint32 Timer;
+
     void Reset()
     {
         Spell = 0;
         Timer = 0;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Timer < diff)
@@ -970,10 +1102,12 @@ struct TRINITY_DLL_DECL mob_armageddonAI : public Scripted_NoMovementAI
         } else Timer -=diff;
     }
 };
+
 CreatureAI* GetAI_mob_armageddon(Creature* pCreature)
 {
     return new mob_armageddonAI (pCreature);
 }
+
 //AI for Shield Orbs
 struct TRINITY_DLL_DECL mob_shield_orbAI : public ScriptedAI
 {
@@ -981,12 +1115,14 @@ struct TRINITY_DLL_DECL mob_shield_orbAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     bool PointReached;
     bool Clockwise;
     uint32 Timer;
     uint32 CheckTimer;
     ScriptedInstance* pInstance;
     float x, y, r, c, mx, my;
+
     void InitializeAI()
     {
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
@@ -998,9 +1134,12 @@ struct TRINITY_DLL_DECL mob_shield_orbAI : public ScriptedAI
         mx = ShieldOrbLocations[0][0];
         my = ShieldOrbLocations[0][1];
         Clockwise = urand(0,1);
+
         ScriptedAI::InitializeAI();
     }
+
     void Reset(){}
+
     void UpdateAI(const uint32 diff)
     {
         if (PointReached)
@@ -1028,7 +1167,9 @@ struct TRINITY_DLL_DECL mob_shield_orbAI : public ScriptedAI
                 DoTeleportTo(x,y,SHIELD_ORB_Z);
                 PointReached = true;
             } else CheckTimer -= diff;
+
         }
+
         if (Timer < diff)
         {
             if (Unit* random = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0))
@@ -1036,23 +1177,29 @@ struct TRINITY_DLL_DECL mob_shield_orbAI : public ScriptedAI
             Timer = urand(500,1000);
         } else Timer -= diff;
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
             return;
+
         PointReached = true;
     }
 };
+
 CreatureAI* GetAI_mob_shield_orb(Creature* pCreature)
 {
     return new mob_shield_orbAI (pCreature);
 }
+
 //AI for Sinister Reflection
 struct TRINITY_DLL_DECL mob_sinster_reflectionAI : public ScriptedAI
 {
     mob_sinster_reflectionAI(Creature* c) : ScriptedAI(c) {}
+
     uint8 Class;
     uint32 Timer[3];
+
     void Reset()
     {
         Timer[0] = 0;
@@ -1060,8 +1207,10 @@ struct TRINITY_DLL_DECL mob_sinster_reflectionAI : public ScriptedAI
         Timer[2] = 0;
         Class = 0;
     }
+
     void UpdateAI(const uint32 diff)
     {
+
         if (Class == 0)
         {
             Class = m_creature->getVictim()->getClass();
@@ -1090,6 +1239,7 @@ struct TRINITY_DLL_DECL mob_sinster_reflectionAI : public ScriptedAI
                     break;
             }
         }
+
         switch(Class){
             case CLASS_DRUID:
                 if (Timer[1] < diff)
@@ -1193,53 +1343,66 @@ struct TRINITY_DLL_DECL mob_sinster_reflectionAI : public ScriptedAI
                 break;
             }
             debug_log("Sinister-Timer");
-            for (uint8 i = 0; i < 3; ++i)
+            for(uint8 i = 0; i < 3; ++i)
                 Timer[i] -= diff;
         }
+
 };
+
 CreatureAI* GetAI_mob_sinster_reflection(Creature* pCreature)
 {
     return new mob_sinster_reflectionAI (pCreature);
 }
+
 void AddSC_boss_kiljaeden()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->pGOHello = &GOHello_go_orb_of_the_blue_flight;
     newscript->Name = "go_orb_of_the_blue_flight";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_kalecgos_kj;
     newscript->Name = "boss_kalecgos_kj";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_boss_kiljaeden;
     newscript->Name = "boss_kiljaeden";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_kiljaeden_controller;
     newscript->Name = "mob_kiljaeden_controller";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_hand_of_the_deceiver;
     newscript->Name = "mob_hand_of_the_deceiver";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_felfire_portal;
     newscript->Name = "mob_felfire_portal";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_volatile_felfire_fiend;
     newscript->Name = "mob_volatile_felfire_fiend";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_armageddon;
     newscript->Name = "mob_armageddon";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_shield_orb;
     newscript->Name = "mob_shield_orb";
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->GetAI = &GetAI_mob_sinster_reflection;
     newscript->Name = "mob_sinster_reflection";
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_muru.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_muru.cpp
index 26f3329e6de..ba95eb51e0f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_muru.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_muru.cpp
@@ -13,17 +13,21 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
+
 /* ScriptData
 SDName: Boss_Muru
 SD%Complete: 80
 SDComment: all sounds, black hole effect triggers to often (46228)
 */
+
 #include "precompiled.h"
 #include "def_sunwell_plateau.h"
+
 // Muru & Entropius's spells
 enum Spells
 {
     SPELL_ENRAGE                = 26662,
+
     // Muru's spells
     SPELL_NEGATIVE_ENERGY        = 46009, //(this trigger 46008)
     SPELL_DARKNESS                = 45999,
@@ -34,30 +38,38 @@ enum Spells
     SPELL_SUMNON_FURY_MAGE        = 46038,
     SPELL_SUMMON_VOID_SENTINEL    = 45988,
     SPELL_SUMMON_ENTROPIUS        = 46217,
+
     // Entropius's spells
     SPELL_DARKNESS_E            = 46269,
     SPELL_BLACKHOLE             = 46282,
     SPELL_NEGATIVE_ENERGY_E     = 46284,
     SPELL_ENTROPIUS_SPAWN        = 46223,
+
     // Shadowsword Berserker's spells
     SPELL_FLURRY                = 46160,
     SPELL_DUAL_WIELD            = 29651,
+
     // Shadowsword Fury Mage's spells
     SPELL_FEL_FIREBALL          = 46101,
     SPELL_SPELL_FURY            = 46102,
+
     // Void Sentinel's spells
     SPELL_SHADOW_PULSE          = 46087,
     SPELL_VOID_BLAST            = 46161,
+
     // Void Spawn's spells
     SPELL_SHADOW_BOLT_VOLLEY    = 46082,
+
     //Dark Fiend Spells
     SPELL_DARKFIEND_AOE            = 45944,
     SPELL_DARKFIEND_VISUAL        = 45936,
     SPELL_DARKFIEND_SKIN        = 45934,
+
     //Black Hole Spells
     SPELL_BLACKHOLE_SPAWN        = 46242,
     SPELL_BLACKHOLE_GROW        = 46228
 };
+
 enum Creatures
 {
     CREATURE_DARKNESS            = 25879,
@@ -70,12 +82,14 @@ enum Creatures
     BOSS_MURU                    = 25741,
     BOSS_ENTROPIUS                = 25840
 };
+
 enum BossTimers{
     TIMER_DARKNESS                = 0,
     TIMER_HUMANOIDES            = 1,
     TIMER_PHASE                    = 2,
     TIMER_SENTINEL                = 3
 };
+
 float DarkFiends[8][4] =
 {
     {1819.9,    609.80,    69.74,    1.94},
@@ -87,6 +101,7 @@ float DarkFiends[8][4] =
     {1823.9 ,   639.69,    69.74,    4.12},
     {1811.85,   640.46,    69.73,    4.97}
 };
+
 float Humanoides[6][5] =
 {
     {CREATURE_FURY_MAGE, 1780.16,    666.83,    71.19,    5.21},
@@ -96,6 +111,7 @@ float Humanoides[6][5] =
     {CREATURE_BERSERKER, 1845.17,    602.63,    71.28,    2.43},
     {CREATURE_BERSERKER, 1842.91,    599.93,    71.23,    2.44}
 };
+
 uint32 EnrageTimer = 600000;
 struct TRINITY_DLL_DECL boss_entropiusAI : public ScriptedAI
 {
@@ -103,24 +119,32 @@ struct TRINITY_DLL_DECL boss_entropiusAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     SummonList Summons;
+
     uint32 BlackHoleSummonTimer;
+
     void Reset()
     {
         BlackHoleSummonTimer = 15000;
         DoCastAOE(SPELL_NEGATIVE_ENERGY_E, false);
+
         Summons.DespawnAll();
+
         if (pInstance)
             pInstance->SetData(DATA_MURU_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoCastAOE(SPELL_NEGATIVE_ENERGY_E, true);
         DoCast(m_creature, SPELL_ENTROPIUS_SPAWN, false);
+
         if (pInstance)
             pInstance->SetData(DATA_MURU_EVENT, IN_PROGRESS);
     }
+
     void JustSummoned(Creature* summoned)
     {
         switch(summoned->GetEntry())
@@ -138,71 +162,93 @@ struct TRINITY_DLL_DECL boss_entropiusAI : public ScriptedAI
         summoned->AI()->AttackStart(SelectTarget(SELECT_TARGET_RANDOM,0, 50, true));
         Summons.Summon(summoned);
     }
+
     void JustDied(Unit* killer)
     {
         Summons.DespawnAll();
+
         if (pInstance)
             pInstance->SetData(DATA_MURU_EVENT, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (EnrageTimer < diff && !m_creature->HasAura(SPELL_ENRAGE, 0))
         {
             DoCast(m_creature,SPELL_ENRAGE, false);
         }else EnrageTimer -= diff;
+
         if (BlackHoleSummonTimer < diff)
         {
             Unit* random = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
             if (!random)
                 return;
+
             DoCast(random, SPELL_DARKNESS_E, false);
+
             random = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
             if (!random)
                 return;
+
             random->CastSpell(random, SPELL_BLACKHOLE, false);
             BlackHoleSummonTimer = 15000;
         }else BlackHoleSummonTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_entropius(Creature* pCreature)
 {
     return new boss_entropiusAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL boss_muruAI : public Scripted_NoMovementAI
 {
     boss_muruAI(Creature *c) : Scripted_NoMovementAI(c), Summons(m_creature)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     SummonList Summons;
+
     uint8 Phase;
     uint32 Timer[4];
+
     bool DarkFiend;
+
     void Reset()
     {
         DarkFiend = false;
         Phase = 1;
+
         EnrageTimer = 600000;
         Timer[TIMER_DARKNESS] = 45000;
         Timer[TIMER_HUMANOIDES] = 10000;
         Timer[TIMER_PHASE] = 2000;
         Timer[TIMER_SENTINEL] = 31500;
+
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetVisibility(VISIBILITY_ON);
+
         Summons.DespawnAll();
+
         if (pInstance)
             pInstance->SetData(DATA_MURU_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoCastAOE(SPELL_NEGATIVE_ENERGY,false);
+
         if (pInstance)
             pInstance->SetData(DATA_MURU_EVENT, IN_PROGRESS);
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage > m_creature->GetHealth() && Phase == 1)
@@ -216,6 +262,7 @@ struct TRINITY_DLL_DECL boss_muruAI : public Scripted_NoMovementAI
         if (Phase > 1 && Phase < 4)
             damage = 0;
     }
+
     void JustSummoned(Creature* summoned)
     {
         switch(summoned->GetEntry())
@@ -230,10 +277,12 @@ struct TRINITY_DLL_DECL boss_muruAI : public Scripted_NoMovementAI
         summoned->AI()->AttackStart(SelectTarget(SELECT_TARGET_RANDOM,0, 50, true));
         Summons.Summon(summoned);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Phase == 3)
         {
             if (Timer[TIMER_PHASE] HasAura(SPELL_ENRAGE, 0))
         {
             DoCast(m_creature, SPELL_ENRAGE, false);
         }else EnrageTimer -= diff;
+
         for (uint8 i = 0; i < 4; ++i)
         {
             if (Timer[i] < diff)
@@ -274,13 +325,13 @@ struct TRINITY_DLL_DECL boss_muruAI : public Scripted_NoMovementAI
                         else
                         {
                             DarkFiend = false;
-                            for (uint8 i = 0; i < 8; ++i)
+                            for(uint8 i = 0; i < 8; ++i)
                                 m_creature->SummonCreature(CREATURE_DARK_FIENDS,DarkFiends[i][0],DarkFiends[i][1],DarkFiends[i][2], DarkFiends[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
                             Timer[TIMER_DARKNESS] = 42000;
                         }
                         break;
                     case TIMER_HUMANOIDES:
-                        for (uint8 i = 0; i < 6; ++i)
+                        for(uint8 i = 0; i < 6; ++i)
                             m_creature->SummonCreature(Humanoides[i][0],Humanoides[i][1],Humanoides[i][2],Humanoides[i][3], Humanoides[i][4], TEMPSUMMON_CORPSE_DESPAWN, 0);
                         Timer[TIMER_HUMANOIDES] = 60000;
                         break;
@@ -298,45 +349,59 @@ struct TRINITY_DLL_DECL boss_muruAI : public Scripted_NoMovementAI
                 break;
             }
         }
+
         //Timer
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (i != TIMER_PHASE)Timer[i] -= diff;
             else if (Phase == 2) Timer[i] -= diff;
         }
     }
 };
+
 CreatureAI* GetAI_boss_muru(Creature* pCreature)
 {
     return new boss_muruAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_muru_portalAI : public Scripted_NoMovementAI
 {
     npc_muru_portalAI(Creature *c) : Scripted_NoMovementAI(c), Summons(m_creature)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     SummonList Summons;
     Creature* Muru;
+
     bool SummonSentinel;
     bool InAction;
+
     uint32 SummonTimer;
+
     void Reset()
     {
         SummonTimer = 5000;
+
         InAction = false;
         SummonSentinel = false;
+
         m_creature->addUnitState(UNIT_STAT_STUNNED);
+
         Summons.DespawnAll();
     }
+
     void JustSummoned(Creature* summoned)
     {
         if (pInstance)
             if (Player* Target = Unit::GetPlayer(pInstance->GetData64(DATA_PLAYER_GUID)))
                 summoned->AI()->AttackStart(Target);
+
         Summons.Summon(summoned);
     }
+
     void SpellHit(Unit* caster, const SpellEntry* Spell)
     {
         float x,y,z,o;
@@ -354,6 +419,7 @@ struct TRINITY_DLL_DECL npc_muru_portalAI : public Scripted_NoMovementAI
                 break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!SummonSentinel)
@@ -370,31 +436,39 @@ struct TRINITY_DLL_DECL npc_muru_portalAI : public Scripted_NoMovementAI
         }else SummonTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_npc_muru_portal(Creature* pCreature)
 {
     return new npc_muru_portalAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_dark_fiendAI : public ScriptedAI
 {
     npc_dark_fiendAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 WaitTimer;
     bool InAction;
+
     void Reset()
     {
         WaitTimer = 2000;
         InAction = false;
+
         m_creature->addUnitState(UNIT_STAT_STUNNED);
     }
+
     void SpellHit(Unit* caster, const SpellEntry* Spell)
     {
-        for (uint8 i = 0; i < 3; ++i)
+        for(uint8 i = 0; i < 3; ++i)
             if (Spell->Effect[i] == 38)
                 m_creature->DisappearAndDie();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (WaitTimer < diff)
         {
             if (!InAction)
@@ -407,6 +481,7 @@ struct TRINITY_DLL_DECL npc_dark_fiendAI : public ScriptedAI
             }
             else
             {
+
                 if (m_creature->IsWithinDist(m_creature->getVictim(), 5))
                 {
                     DoCastAOE(SPELL_DARKFIEND_AOE, false);
@@ -417,68 +492,85 @@ struct TRINITY_DLL_DECL npc_dark_fiendAI : public ScriptedAI
         } else WaitTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_npc_dark_fiend(Creature* pCreature)
 {
     return new npc_dark_fiendAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_void_sentinelAI : public ScriptedAI
 {
     npc_void_sentinelAI(Creature *c) : ScriptedAI(c){}
+
     uint32 PulseTimer;
     uint32 VoidBlastTimer;
+
     void Reset()
     {
         PulseTimer = 3000;
         VoidBlastTimer = 45000; //is this a correct timer?
+
         float x,y,z,o;
         m_creature->GetHomePosition(x,y,z,o);
         DoTeleportTo(x,y,71);
     }
+
     void JustDied(Unit* killer)
     {
         for (uint8 i = 0; i < 8; ++i)
             m_creature->SummonCreature(CREATURE_VOID_SPAWN, m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(), rand()%6, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 180000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (PulseTimer < diff)
         {
             DoCastAOE(SPELL_SHADOW_PULSE, true);
             PulseTimer = 3000;
         } else PulseTimer -= diff;
+
         if (VoidBlastTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_VOID_BLAST, false);
             VoidBlastTimer = 45000;
         } else VoidBlastTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_void_sentinel(Creature* pCreature)
 {
     return new npc_void_sentinelAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_blackholeAI : public ScriptedAI
 {
     npc_blackholeAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 DespawnTimer;
     uint32 SpellTimer;
     uint8 Phase;
     uint8 NeedForAHack;
+
     void Reset()
     {
         DespawnTimer = 15000;
         SpellTimer = 5000;
         Phase = 0;
+
         m_creature->addUnitState(UNIT_STAT_STUNNED);
         DoCastAOE(SPELL_BLACKHOLE_SPAWN, true);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (SpellTimer < diff)
@@ -515,15 +607,18 @@ struct TRINITY_DLL_DECL npc_blackholeAI : public ScriptedAI
                         return;
             }
         } else SpellTimer -= diff;
+
         if (DespawnTimer < diff)
             m_creature->DisappearAndDie();
         else DespawnTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_npc_blackhole(Creature* pCreature)
 {
     return new npc_blackholeAI (pCreature);
 }
+
 void AddSC_boss_muru()
 {
     Script *newscript;
@@ -531,22 +626,27 @@ void AddSC_boss_muru()
     newscript->Name = "boss_muru";
     newscript->GetAI = &GetAI_boss_muru;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_entropius";
     newscript->GetAI = &GetAI_boss_entropius;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_muru_portal";
     newscript->GetAI = &GetAI_npc_muru_portal;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_dark_fiend";
     newscript->GetAI = &GetAI_npc_dark_fiend;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_void_sentinel";
     newscript->GetAI = &GetAI_npc_void_sentinel;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_blackhole";
     newscript->GetAI = &GetAI_npc_blackhole;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/def_sunwell_plateau.h b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/def_sunwell_plateau.h
index bfcb042fc7e..f955e8c7e17 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/def_sunwell_plateau.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/def_sunwell_plateau.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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         1
 #define DATA_BRUTALLUS_EVENT        2
@@ -10,6 +12,7 @@
 #define DATA_EREDAR_TWINS_EVENT     4
 #define DATA_MURU_EVENT             5
 #define DATA_KILJAEDEN_EVENT        6
+
 /*** Creatures ***/
 #define DATA_KALECGOS_DRAGON        7
 #define DATA_KALECGOS_HUMAN         8
@@ -24,8 +27,10 @@
 #define DATA_KILJAEDEN_CONTROLLER   17
 #define DATA_ANVEENA                18
 #define DATA_KALECGOS_KJ            19
+
 /*** GameObjects ***/
 #define DATA_GO_FORCEFIELD          20
+
 /*** Misc ***/
 #define DATA_PLAYER_GUID            21
 #endif
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/instance_sunwell_plateau.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/instance_sunwell_plateau.cpp
index ce51643f6de..4195ebd91a5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/instance_sunwell_plateau.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/instance_sunwell_plateau.cpp
@@ -1,15 +1,19 @@
 /* Copyright (C) 2006 - 2009 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: 25
 SDComment: VERIFY SCRIPT
 SDCategory: Sunwell_Plateau
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_sunwell_plateau.h"
+
 #define MAX_ENCOUNTER 6
+
 /* Sunwell Plateau:
 0 - Kalecgos and Sathrovarr
 1 - Brutallus
@@ -18,10 +22,13 @@ EndScriptData */
 4 - M'uru
 5 - Kil'Jaeden
 */
+
 struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
 {
     instance_sunwell_plateau(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     /** Creatures **/
     uint64 Kalecgos_Dragon;
     uint64 Kalecgos_Human;
@@ -37,17 +44,21 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
     uint64 Anveena;
     uint64 KalecgosKJ;
     uint32 SpectralPlayers;
+
     /** GameObjects **/
     uint64 ForceField;                                      // Kalecgos Encounter
     uint64 KalecgosWall[2];
     uint64 FireBarrier;                                     // Felmysts Encounter
     uint64 MurusGate[2];                                    // Murus Encounter
+
     /*** Misc ***/
     uint32 SpectralRealmTimer;
     std::vector SpectralRealmList;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         /*** Creatures ***/
         Kalecgos_Dragon         = 0;
         Kalecgos_Human          = 0;
@@ -63,6 +74,7 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
         Anveena                 = 0;
         KalecgosKJ              = 0;
         SpectralPlayers         = 0;
+
         /*** GameObjects ***/
         ForceField  = 0;
         FireBarrier = 0;
@@ -70,31 +82,38 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
         MurusGate[1] = 0;
         KalecgosWall[0] = 0;
         KalecgosWall[1] = 0;
+
         /*** Misc ***/
         SpectralRealmTimer = 5000;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)
                 return true;
+
         return false;
     }
+
     Player* GetPlayerInMap()
     {
         Map::PlayerList const& players = instance->GetPlayers();
+
         if (!players.isEmpty())
         {
-            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+            for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
             {
                 Player* plr = itr->getSource();
                 if (plr && !plr->HasAura(45839,0))
                         return plr;
             }
         }
+
         debug_log("TSCR: Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!");
         return NULL;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -114,6 +133,7 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
             case 25319: KalecgosKJ          = pCreature->GetGUID(); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -134,6 +154,7 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
                 break;
         }
     }
+
     uint32 GetData(uint32 id)
     {
         switch(id)
@@ -147,6 +168,7 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 id)
     {
         switch(id)
@@ -171,6 +193,7 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 id, uint32 data)
     {
         switch(id)
@@ -216,9 +239,11 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
                 m_auiEncounter[4] = data; break;
             case DATA_KILJAEDEN_EVENT:     m_auiEncounter[5] = data; break;
         }
+
         if (data == DONE)
             SaveToDB();
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
@@ -234,6 +259,7 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
         }
         return NULL;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -241,23 +267,27 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
         std::istringstream stream(in);
         stream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3]
             >> m_auiEncounter[4] >> m_auiEncounter[5];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)                // Do not load an encounter as "In Progress" - reset it instead.
                 m_auiEncounter[i] = NOT_STARTED;
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_sunwell_plateau(Map* pMap)
 {
     return new instance_sunwell_plateau(pMap);
 }
+
 void AddSC_instance_sunwell_plateau()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "instance_sunwell_plateau";
     newscript->GetInstanceData = &GetInstanceData_instance_sunwell_plateau;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/sunwell_plateau.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/sunwell_plateau.cpp
index 88f0a8d9db9..e68717857cb 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/sunwell_plateau.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/sunwell_plateau.cpp
@@ -13,20 +13,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Sunwell_Plateau
 SD%Complete: 0
 SDComment: Placeholder, Epilogue after Kil'jaeden, Captain Selana Gossips
 EndScriptData */
+
 /* ContentData
 npc_prophet_velen
 npc_captain_selana
 EndContentData */
+
 #include "precompiled.h"
 #include "def_sunwell_plateau.h"
+
 /*######
 ## npc_prophet_velen
 ######*/
+
 enum ProphetSpeeches
 {
     PROPHET_SAY1 = -1580099,
@@ -38,6 +43,7 @@ enum ProphetSpeeches
     PROPHET_SAY7 = -1580105,
     PROPHET_SAY8 = -1580106
 };
+
 enum LiadrinnSpeeches
 {
     LIADRIN_SAY1 = -1580107,
@@ -45,13 +51,16 @@ enum LiadrinnSpeeches
     LIADRIN_SAY3 = -1580109
 };
 
+
 /*######
 ## npc_captain_selana
 ######*/
+
 #define CS_GOSSIP1 "Give me a situation report, Captain."
 #define CS_GOSSIP2 "What went wrong?"
 #define CS_GOSSIP3 "Why did they stop?"
 #define CS_GOSSIP4 "Your insight is appreciated."
+
 void AddSC_sunwell_plateau()
 {
 }
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/tirisfal_glades.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/tirisfal_glades.cpp
index 29c10e34da4..ba2a9cd762a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/tirisfal_glades.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/tirisfal_glades.cpp
@@ -13,21 +13,26 @@
  * along 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, 1819
 SDCategory: Tirisfal Glades
 EndScriptData */
+
 /* ContentData
 npc_calvin_montague
 go_mausoleum_door
 go_mausoleum_trigger
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## npc_calvin_montague
 ######*/
+
 enum eCalvin
 {
     SAY_COMPLETE        = -1000431,
@@ -35,41 +40,54 @@ enum eCalvin
     QUEST_590           = 590,
     FACTION_HOSTILE     = 168
 };
+
 struct TRINITY_DLL_DECL npc_calvin_montagueAI : public ScriptedAI
 {
     npc_calvin_montagueAI(Creature* pCreature) : ScriptedAI(pCreature) { }
+
     uint32 m_uiPhase;
     uint32 m_uiPhaseTimer;
     uint64 m_uiPlayerGUID;
+
     void Reset()
     {
         m_uiPhase = 0;
         m_uiPhaseTimer = 5000;
         m_uiPlayerGUID = 0;
+
         me->RestoreFaction();
+
         if (!m_creature->HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_OOC_NOT_ATTACKABLE))
             m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_OOC_NOT_ATTACKABLE);
     }
+
     void EnterCombat(Unit* who) { }
+
     void AttackedBy(Unit* pAttacker)
     {
         if (m_creature->getVictim() || m_creature->IsFriendlyTo(pAttacker))
             return;
+
         AttackStart(pAttacker);
     }
+
     void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
     {
         if (uiDamage > m_creature->GetHealth() || ((m_creature->GetHealth() - uiDamage)*100 / m_creature->GetMaxHealth() < 15))
         {
             uiDamage = 0;
+
             me->RestoreFaction();
             m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_OOC_NOT_ATTACKABLE);
             m_creature->CombatStop(true);
+
             m_uiPhase = 1;
+
             if (pDoneBy->GetTypeId() == TYPEID_PLAYER)
                 m_uiPlayerGUID = pDoneBy->GetGUID();
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (m_uiPhase)
@@ -81,6 +99,7 @@ struct TRINITY_DLL_DECL npc_calvin_montagueAI : public ScriptedAI
                 m_uiPhaseTimer -= uiDiff;
                 return;
             }
+
             switch(m_uiPhase)
             {
                 case 1:
@@ -90,6 +109,7 @@ struct TRINITY_DLL_DECL npc_calvin_montagueAI : public ScriptedAI
                 case 2:
                     if (Unit* pUnit = Unit::GetUnit(*m_creature, m_uiPlayerGUID))
                         CAST_PLR(pUnit)->AreaExploredOrEventHappens(QUEST_590);
+
                     m_creature->CastSpell(m_creature,SPELL_DRINK,true);
                     ++m_uiPhase;
                     break;
@@ -97,10 +117,13 @@ struct TRINITY_DLL_DECL npc_calvin_montagueAI : public ScriptedAI
                     EnterEvadeMode();
                     break;
             }
+
             return;
         }
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -108,6 +131,7 @@ CreatureAI* GetAI_npc_calvin_montague(Creature* pCreature)
 {
     return new npc_calvin_montagueAI (pCreature);
 }
+
 bool QuestAccept_npc_calvin_montague(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_590)
@@ -118,10 +142,12 @@ bool QuestAccept_npc_calvin_montague(Player* pPlayer, Creature* pCreature, Quest
     }
     return true;
 }
+
 /*######
 ## go_mausoleum_door
 ## go_mausoleum_trigger
 ######*/
+
 enum eMausoleum
 {
     QUEST_ULAG      = 1819,
@@ -129,42 +155,52 @@ enum eMausoleum
     GO_TRIGGER      = 104593,
     GO_DOOR         = 176594
 };
+
 bool GOHello_go_mausoleum_door(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->GetQuestStatus(QUEST_ULAG) != QUEST_STATUS_INCOMPLETE)
         return false;
+
     if (GameObject* pTrigger = pPlayer->FindNearestGameObject(GO_TRIGGER, 30.0f))
     {
         pTrigger->SetGoState(GO_STATE_READY);
         pPlayer->SummonCreature(NPC_ULAG, 2390.26, 336.47, 40.01, 2.26, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 300000);
         return false;
     }
+
     return false;
 }
+
 bool GOHello_go_mausoleum_trigger(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->GetQuestStatus(QUEST_ULAG) != QUEST_STATUS_INCOMPLETE)
         return false;
+
     if (GameObject* pDoor = pPlayer->FindNearestGameObject(GO_DOOR, 30.0f))
     {
         pGo->SetGoState(GO_STATE_ACTIVE);
         pDoor->RemoveFlag(GAMEOBJECT_FLAGS,GO_FLAG_INTERACT_COND);
         return true;
     }
+
     return false;
 }
+
 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_mausoleum_door";
     newscript->pGOHello = &GOHello_go_mausoleum_door;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_mausoleum_trigger";
     newscript->pGOHello = &GOHello_go_mausoleum_trigger;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/boss_archaedas.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/boss_archaedas.cpp
index c22340031bf..203fc8268d5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/boss_archaedas.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/boss_archaedas.cpp
@@ -13,6 +13,7 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: boss_archaedas
 SD%Complete: 100
@@ -22,16 +23,22 @@ At 66%, he will awaken the 6 Guardians.
 At 33%, he will awaken the Vault Walkers
 On his death the vault door opens.
 EndScriptData */
+
 #include "precompiled.h"
 
+
 #define SAY_AGGRO           "Who dares awaken Archaedas? Who dares the wrath of the makers!"
 #define SOUND_AGGRO         5855
+
 #define SAY_SUMMON          "Awake ye servants, defend the discs!"
 #define SOUND_SUMMON        5856
+
 #define SAY_SUMMON2         "To my side, brothers. For the makers!"
 #define SOUND_SUMMON2       5857
+
 #define SAY_KILL            "Reckless mortal."
 #define SOUND_KILL            5858
+
 #define SPELL_GROUND_TREMOR           6524
 #define SPELL_ARCHAEDAS_AWAKEN        10347
 #define SPELL_BOSS_OBJECT_VISUAL      11206
@@ -39,36 +46,45 @@ EndScriptData */
 #define SPELL_SUB_BOSS_AGGRO          11568
 #define SPELL_AWAKEN_VAULT_WALKER     10258
 #define SPELL_AWAKEN_EARTHEN_GUARDIAN 10252
+
 struct TRINITY_DLL_DECL boss_archaedasAI : public ScriptedAI
 {
     boss_archaedasAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     uint32 Tremor_Timer;
     int32  Awaken_Timer;
     uint32 WallMinionTimer;
     bool wakingUp;
+
     bool guardiansAwake;
     bool vaultWalkersAwake;
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         Tremor_Timer = 60000;
         Awaken_Timer = 0;
         WallMinionTimer = 10000;
+
         wakingUp = false;
         guardiansAwake = false;
         vaultWalkersAwake = false;
+
         if (pInstance)
             pInstance->SetData (NULL, 5);    // respawn any dead minions
         m_creature->setFaction(35);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
+
     }
+
     void ActivateMinion (uint64 guid, bool flag)
     {
         Unit *minion = Unit::GetUnit(*m_creature, guid);
+
         if (minion && minion->isAlive())
         {
             DoCast (minion, SPELL_AWAKEN_VAULT_WALKER, flag);
@@ -76,12 +92,14 @@ struct TRINITY_DLL_DECL boss_archaedasAI : public ScriptedAI
         }
     }
 
+
     void EnterCombat(Unit *who)
     {
         m_creature->setFaction (14);
         m_creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->RemoveFlag (UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE);
     }
+
     void SpellHit (Unit* caster, const SpellEntry *spell)
     {
         // Being woken up from the altar, start the awaken sequence
@@ -92,11 +110,13 @@ struct TRINITY_DLL_DECL boss_archaedasAI : public ScriptedAI
             wakingUp = true;
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         m_creature->MonsterYell(SAY_KILL,LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_KILL);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!pInstance)
@@ -110,15 +130,19 @@ struct TRINITY_DLL_DECL boss_archaedasAI : public ScriptedAI
             AttackStart(Unit::GetUnit(*m_creature, pInstance->GetData64(0)));
             return;     // dont want to continue until we finish the AttackStart method
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
 
+
         // wake a wall minion
         if (WallMinionTimer < diff) {
             pInstance->SetData (NULL, 2);
+
             WallMinionTimer = 10000;
         } else WallMinionTimer -= diff;
+
         //If we are <66 summon the guardians
         if (!guardiansAwake && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 66) {
             ActivateMinion(pInstance->GetData64(5),true);   // EarthenGuardian1
@@ -131,6 +155,7 @@ struct TRINITY_DLL_DECL boss_archaedasAI : public ScriptedAI
             DoPlaySoundToSet(m_creature, SOUND_SUMMON);
             guardiansAwake = true;
         }
+
         //If we are <33 summon the vault walkers
         if (!vaultWalkersAwake && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 33) {
             ActivateMinion(pInstance->GetData64(1),true);    // VaultWalker1
@@ -142,15 +167,19 @@ struct TRINITY_DLL_DECL boss_archaedasAI : public ScriptedAI
             vaultWalkersAwake = true;
         }
 
+
         if (Tremor_Timer < diff)
         {
             //Cast
             DoCast(m_creature->getVictim(),SPELL_GROUND_TREMOR);
+
             //45 seconds until we should cast this agian
             Tremor_Timer  = 45000;
         }else Tremor_Timer  -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied (Unit *killer) {
         if (pInstance)
         {
@@ -158,11 +187,14 @@ struct TRINITY_DLL_DECL boss_archaedasAI : public ScriptedAI
             pInstance->SetData(NULL,4);        // deactivate his minions
         }
     }
+
 };
+
 CreatureAI* GetAI_boss_archaedas(Creature* pCreature)
 {
     return new boss_archaedasAI (pCreature);
 }
+
 /* ScriptData
 SDName: mob_archaedas_minions
 SD%Complete: 100
@@ -170,29 +202,37 @@ SDComment: These mobs are initially frozen until Archaedas awakens them
 one at a time.
 EndScriptData */
 
+
 #define SPELL_ARCHAEDAS_AWAKEN        10347
+
 struct TRINITY_DLL_DECL mob_archaedas_minionsAI : public ScriptedAI
 {
     mob_archaedas_minionsAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = m_creature->GetInstanceData();
     }
+
     uint32 Arcing_Timer;
     int32 Awaken_Timer;
     bool wakingUp;
+
     bool amIAwake;
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         Arcing_Timer = 3000;
         Awaken_Timer = 0;
+
         wakingUp = false;
         amIAwake = false;
+
         m_creature->setFaction(35);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
         m_creature->RemoveAllAuras();
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->setFaction (14);
@@ -201,6 +241,7 @@ struct TRINITY_DLL_DECL mob_archaedas_minionsAI : public ScriptedAI
         m_creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
         amIAwake = true;
     }
+
     void SpellHit (Unit* caster, const SpellEntry *spell) {
         // time to wake up, start animation
         if (spell == GetSpellStore()->LookupEntry(SPELL_ARCHAEDAS_AWAKEN)){
@@ -208,11 +249,13 @@ struct TRINITY_DLL_DECL mob_archaedas_minionsAI : public ScriptedAI
             wakingUp = true;
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (amIAwake)
             ScriptedAI::MoveInLineOfSight(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         // we're still in the awaken animation
@@ -225,17 +268,21 @@ struct TRINITY_DLL_DECL mob_archaedas_minionsAI : public ScriptedAI
             // AttackStart(Unit::GetUnit(*m_creature, pInstance->GetData64(0))); // whoWokeArchaedasGUID
             return;     // dont want to continue until we finish the AttackStart method
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
 
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_archaedas_minions(Creature* pCreature)
 {
     return new mob_archaedas_minionsAI (pCreature);
 }
+
 /* ScriptData
 SDName: go_altar_archaedas
 SD%Complete: 100
@@ -243,16 +290,22 @@ SDComment: Needs 1 person to activate the Archaedas script
 SDCategory: Uldaman
 EndScriptData */
 
+
 #define OBJECT_ALTAR_OF_ARCHAEDAS   133234
+
 #define NUMBER_NEEDED_TO_ACTIVATE 1 // as of patch 3.0.8 the altars can be opened by a single player (previously 3)
+
 #define SPELL_BOSS_OBJECT_VISUAL    11206
+
 //uint64 altarOfArchaedasCount[5];
 //int32 altarOfArchaedasCounter=0;
 
+
 bool GOHello_go_altar_of_archaedas(Player* pPlayer, GameObject* pGo)
 {
     //bool alreadyUsed;
     //pGo->AddUse ();
+
     /*
     alreadyUsed = false;
     for (uint32 loop=0; loop<5; loop++) {
@@ -261,11 +314,14 @@ bool GOHello_go_altar_of_archaedas(Player* pPlayer, GameObject* pGo)
     if (!alreadyUsed)
         altarOfArchaedasCount[altarOfArchaedasCounter++] = pPlayer->GetGUID();
         */
+
     pPlayer->CastSpell (pPlayer, SPELL_BOSS_OBJECT_VISUAL, false);
+
     /*
     if (altarOfArchaedasCounter < NUMBER_NEEDED_TO_ACTIVATE) {
         return false;        // not enough people yet
     }
+
     // Check to make sure at least three people are still casting
     uint32 count=0;
     Unit *pTarget;
@@ -275,32 +331,42 @@ bool GOHello_go_altar_of_archaedas(Player* pPlayer, GameObject* pGo)
         if (pTarget->IsNonMeleeSpellCasted(true)) count++;
         if (count >= NUMBER_NEEDED_TO_ACTIVATE) break;
     }
+
     if (count < NUMBER_NEEDED_TO_ACTIVATE) {
         return false;            // not enough people
     }
     */
+
     ScriptedInstance* pInstance = pPlayer->GetInstanceData();
     if (!pInstance)
         return false;
+
     pInstance->SetData(NULL,0);
     pInstance->SetData64(0,pPlayer->GetGUID());     // activate archaedas
+
     return false;
 }
+
 /* ScriptData
 SDName: mob_stonekeepers
 SD%Complete: 100
 SDComment: After activating the altar of the keepers, the stone keepers will
 wake up one by one.
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SPELL_SELF_DESTRUCT           9874
+
 struct TRINITY_DLL_DECL mob_stonekeepersAI : public ScriptedAI
 {
     mob_stonekeepersAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = (m_creature->GetInstanceData());
     }
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         m_creature->setFaction(35);
@@ -308,30 +374,38 @@ struct TRINITY_DLL_DECL mob_stonekeepersAI : public ScriptedAI
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
         m_creature->RemoveAllAuras();
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->setFaction (14);
         m_creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
     }
+
     void UpdateAI(const uint32 diff)
     {
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit *attacker)
     {
         DoCast (m_creature, SPELL_SELF_DESTRUCT,true);
         if (pInstance)
             pInstance->SetData(NULL, 1);    // activate next stonekeeper
     }
+
 };
+
 CreatureAI* GetAI_mob_stonekeepers(Creature* pCreature)
 {
     return new mob_stonekeepersAI (pCreature);
 }
+
 /* ScriptData
 SDName: go_altar_of_the_keepers
 SD%Complete: 100
@@ -339,17 +413,24 @@ SDComment: Need 1 person to activate to open the altar.  One by one the StoneKee
 SDCategory: Uldaman
 EndScriptData */
 
+
 #define SPELL_BOSS_OBJECT_VISUAL    11206
+
 #define NUMBER_NEEDED_TO_ACTIVATE 1 // as of patch 3.0.8 the altars can be opened by a single player (previously 3)
+
 //static uint64 altarOfTheKeeperCount[5];
 //static uint32 altarOfTheKeeperCounter=0;
+
 bool GOHello_go_altar_of_the_keepers(Player* pPlayer, GameObject* pGo)
 {
     ScriptedInstance* pInstance = pPlayer->GetInstanceData();
     if (!pInstance)
         return true;
+
     //bool alreadyUsed;
+
     //pGo->AddUse ();
+
     //alreadyUsed = false;
     //for (uint32 loop=0; loop<5; ++loop)
     //{
@@ -359,6 +440,7 @@ bool GOHello_go_altar_of_the_keepers(Player* pPlayer, GameObject* pGo)
     //if (!alreadyUsed && altarOfTheKeeperCounter < 5)
     //    altarOfTheKeeperCount[altarOfTheKeeperCounter++] = pPlayer->GetGUID();
     pPlayer->CastSpell (pPlayer, SPELL_BOSS_OBJECT_VISUAL, false);
+
     //if (altarOfTheKeeperCounter < NUMBER_NEEDED_TO_ACTIVATE)
     //{
         //error_log ("not enough people yet, altarOfTheKeeperCounter = %d", altarOfTheKeeperCounter);
@@ -376,6 +458,7 @@ bool GOHello_go_altar_of_the_keepers(Player* pPlayer, GameObject* pGo)
         if (pTarget->IsNonMeleeSpellCasted(true)) count++;
         if (count >= NUMBER_NEEDED_TO_ACTIVATE) break;
     }
+
     if (count < NUMBER_NEEDED_TO_ACTIVATE)
     {
         // error_log ("still not enough people");
@@ -386,6 +469,7 @@ bool GOHello_go_altar_of_the_keepers(Player* pPlayer, GameObject* pGo)
     pInstance->SetData(NULL,1);        // activate the Stone Keepers
     return true;
 }
+
 void AddSC_boss_archaedas()
 {
     Script *newscript;
@@ -393,18 +477,22 @@ void AddSC_boss_archaedas()
     newscript->Name = "boss_archaedas";
     newscript->GetAI = &GetAI_boss_archaedas;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_altar_of_archaedas";
     newscript->pGOHello = &GOHello_go_altar_of_archaedas;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_archaedas_minions";
     newscript->GetAI = &GetAI_mob_archaedas_minions;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_altar_of_the_keepers";
     newscript->pGOHello = &GOHello_go_altar_of_the_keepers;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_stonekeepers";
     newscript->GetAI = &GetAI_mob_stonekeepers;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/boss_ironaya.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/boss_ironaya.cpp
index 11ece7039c4..06c0289812b 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/boss_ironaya.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/boss_ironaya.cpp
@@ -13,69 +13,88 @@
  * along with 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 SAY_AGGRO                   -1070000
+
 #define SPELL_ARCINGSMASH           8374
 #define SPELL_KNOCKAWAY             10101
 #define SPELL_WSTOMP                11876
+
 struct TRINITY_DLL_DECL boss_ironayaAI : public ScriptedAI
 {
     boss_ironayaAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Arcing_Timer;
     bool hasCastedWstomp;
     bool hasCastedKnockaway;
+
     void Reset()
     {
         Arcing_Timer = 3000;
         hasCastedKnockaway = false;
         hasCastedWstomp = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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* pCreature)
 {
     return new boss_ironayaAI (pCreature);
 }
+
 void AddSC_boss_ironaya()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/instance_uldaman.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/instance_uldaman.cpp
index 178ea0985b3..21b639e2449 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/instance_uldaman.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/instance_uldaman.cpp
@@ -14,21 +14,28 @@
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+
 #include "precompiled.h"
 
+
 #define SPELL_ARCHAEDAS_AWAKEN        10347
 #define SPELL_AWAKEN_VAULT_WALKER     10258
+
 #define ARCHAEDAS_TEMPLE_DOOR           141869
 #define ALTAR_OF_ARCHAEDAS              133234
+
 #define ALTAR_OF_THE_KEEPER_TEMPLE_DOOR 124367
 #define ALTAR_OF_THE_KEEPER_TEMPLE      130511
+
 #define ANCIENT_VAULT_DOOR              124369
+
 struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
 {
     instance_uldaman(Map* pMap) : ScriptedInstance(pMap)
     {
         Initialize();
     };
+
     void Initialize()
     {
         archaedasGUID = 0;
@@ -37,16 +44,19 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
         ancientVaultDoor = 0;
         whoWokeArchaedasGUID = 0;
     }
+
     uint64 archaedasGUID;
     uint64 altarOfTheKeeperTempleDoor;
     uint64 archaedasTempleDoor;
     uint64 ancientVaultDoor;
     uint64 whoWokeArchaedasGUID;
+
     std::vector stoneKeeper;
     std::vector altarOfTheKeeperCount;
     std::vector vaultWalker;
     std::vector earthenGuardian;
     std::vector archaedasWallMinions;    // minions lined up around the wall
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch (pGo->GetEntry())
@@ -54,9 +64,11 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
             case ALTAR_OF_THE_KEEPER_TEMPLE_DOOR:         // lock the door
                 altarOfTheKeeperTempleDoor = pGo->GetGUID();
             break;
+
             case ARCHAEDAS_TEMPLE_DOOR:
                 archaedasTempleDoor = pGo->GetGUID();
             break;
+
             case ANCIENT_VAULT_DOOR:
                 pGo->SetGoState(GO_STATE_READY);
                 pGo->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
@@ -64,6 +76,7 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
             break;
         }
     }
+
     void SetFrozenState(Creature* pCreature)
     {
         pCreature->setFaction(35);
@@ -72,17 +85,20 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
         pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
     }
+
     void OpenDoor(uint64 guid)
     {
         GameObject* pGo = instance->GetGameObject(guid);
         if (!pGo)
             return;
+
         pGo->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
         pGo->SetGoState(GO_STATE_ACTIVE);
     }
+
     void ActivateStoneKeepers()
     {
-        for (std::vector::iterator i = stoneKeeper.begin(); i != stoneKeeper.end(); ++i)
+        for(std::vector::iterator i = stoneKeeper.begin(); i != stoneKeeper.end(); ++i)
         {
             Creature *target = instance->GetCreature(*i);
             if (!target || !target->isAlive() || target->getFaction()==14)
@@ -95,12 +111,14 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
         // if we get this far than all four are dead so open the door
         SetData (NULL, 0);
     }
+
     void ActivateWallMinions()
     {
         Creature *archaedas = instance->GetCreature(archaedasGUID);
         if (!archaedas)
             return;
-        for (std::vector::iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
+
+        for(std::vector::iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
         {
             Creature *target = instance->GetCreature(*i);
             if (!target || !target->isAlive() || target->getFaction()==14)
@@ -110,11 +128,12 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
             return;        // only want the first one we find
         }
     }
+
     // used when Archaedas dies.  All active minions must be despawned.
     void DeActivateMinions()
     {
         // first despawn any aggroed wall minions
-        for (std::vector::iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
+        for(std::vector::iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
         {
             Creature *target = instance->GetCreature(*i);
             if (!target || target->isDead() || target->getFaction()!=14)
@@ -122,8 +141,9 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
             target->setDeathState(JUST_DIED);
             target->RemoveCorpse();
         }
+
         // Vault Walkers
-        for (std::vector::iterator i = vaultWalker.begin(); i != vaultWalker.end(); ++i)
+        for(std::vector::iterator i = vaultWalker.begin(); i != vaultWalker.end(); ++i)
         {
             Creature *target = instance->GetCreature(*i);
             if (!target || target->isDead() || target->getFaction()!=14)
@@ -131,8 +151,9 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
             target->setDeathState(JUST_DIED);
             target->RemoveCorpse();
         }
+
         // Earthen Guardians
-        for (std::vector::iterator i = earthenGuardian.begin(); i != earthenGuardian.end(); ++i)
+        for(std::vector::iterator i = earthenGuardian.begin(); i != earthenGuardian.end(); ++i)
         {
             Creature *target = instance->GetCreature(*i);
             if (!target || target->isDead() || target->getFaction()!=14)
@@ -141,21 +162,24 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
             target->RemoveCorpse();
         }
     }
+
     void ActivateArchaedas(uint64 target)
     {
         Creature *archaedas = instance->GetCreature(archaedasGUID);
         if (!archaedas)
             return;
+
         if (Unit *victim = Unit::GetUnit(*archaedas, target))
         {
             archaedas->CastSpell(archaedas, SPELL_ARCHAEDAS_AWAKEN,false);
             whoWokeArchaedasGUID = target;
         }
     }
+
     void RespawnMinions()
     {
         // first respawn any aggroed wall minions
-        for (std::vector::iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
+        for(std::vector::iterator i = archaedasWallMinions.begin(); i != archaedasWallMinions.end(); ++i)
         {
             Creature *target = instance->GetCreature(*i);
             if (target && target->isDead())
@@ -165,8 +189,9 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
                 SetFrozenState(target);
             }
         }
+
         // Vault Walkers
-        for (std::vector::iterator i = vaultWalker.begin(); i != vaultWalker.end(); ++i)
+        for(std::vector::iterator i = vaultWalker.begin(); i != vaultWalker.end(); ++i)
         {
             Creature *target = instance->GetCreature(*i);
             if (target && target->isDead())
@@ -176,8 +201,9 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
                 SetFrozenState(target);
             }
         }
+
         // Earthen Guardians
-        for (std::vector::iterator i = earthenGuardian.begin(); i != earthenGuardian.end(); ++i)
+        for(std::vector::iterator i = earthenGuardian.begin(); i != earthenGuardian.end(); ++i)
         {
             Creature *target = instance->GetCreature(*i);
             if (target && target->isDead())
@@ -188,6 +214,7 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
             }
         }
     }
+
     void SetData (uint32 type, uint32 data)
     {
         //error_log ("SetData: data = %d", data);
@@ -200,6 +227,7 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
         if (data==5) RespawnMinions();
     }
 
+
     void SetData64 (uint32 type, uint64 data)
     {
         // Archaedas
@@ -209,6 +237,7 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
         }
     }
 
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch (pCreature->GetEntry()) {
@@ -216,23 +245,30 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
                 SetFrozenState (pCreature);
                 stoneKeeper.push_back(pCreature->GetGUID());
                 break;
+
             case 7309:    // Earthen Custodian
                 archaedasWallMinions.push_back(pCreature->GetGUID());
                 break;
+
             case 7077:    // Earthen Hallshaper
                 archaedasWallMinions.push_back(pCreature->GetGUID());
                 break;
+
             case 7076:    // Earthen Guardian
                 earthenGuardian.push_back(pCreature->GetGUID());
                 break;
+
             case 10120:    // Vault Walker
                 vaultWalker.push_back(pCreature->GetGUID());
                 break;
+
             case 2748:    // Archaedas
                 archaedasGUID = pCreature->GetGUID();
                 break;
+
         } // end switch
     } // end OnCreatureCreate
+
     uint64 GetData64 (uint32 identifier)
     {
         if (identifier == 0) return whoWokeArchaedasGUID;
@@ -240,20 +276,25 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance
         if (identifier == 2) return vaultWalker[1];    // VaultWalker2
         if (identifier == 3) return vaultWalker[2];    // VaultWalker3
         if (identifier == 4) return vaultWalker[3];    // VaultWalker4
+
         if (identifier == 5) return earthenGuardian[0];
         if (identifier == 6) return earthenGuardian[1];
         if (identifier == 7) return earthenGuardian[2];
         if (identifier == 8) return earthenGuardian[3];
         if (identifier == 9) return earthenGuardian[4];
         if (identifier == 10) return earthenGuardian[5];
+
         return 0;
     } // end GetData64
 };
 
+
+
 InstanceData* GetInstanceData_instance_uldaman(Map* pMap)
 {
     return new instance_uldaman(pMap);
 }
+
 void AddSC_instance_uldaman()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/uldaman.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/uldaman.cpp
index 3872d9bfa13..4ba8ed0c65b 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/uldaman.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/uldaman/uldaman.cpp
@@ -13,61 +13,81 @@
  * along 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 TRINITY_DLL_DECL mob_jadespine_basiliskAI : public ScriptedAI
 {
     mob_jadespine_basiliskAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Cslumber_Timer;
+
     void Reset()
     {
         Cslumber_Timer = 2000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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* pCreature)
 {
     return new mob_jadespine_basiliskAI (pCreature);
 }
+
 /*######
 ## npc_lore_keeper_of_norgannon
 ######*/
+
 #define GOSSIP_HELLO_KEEPER     "Who are the Earthen?"
 #define GOSSIP_SELECT_KEEPER1   "What is a \"subterranean being matrix\"?"
 #define GOSSIP_SELECT_KEEPER2   "What are the anomalies you speak of?"
@@ -84,13 +104,17 @@ CreatureAI* GetAI_mob_jadespine_basilisk(Creature* pCreature)
 #define GOSSIP_SELECT_KEEPER13  "Who are the Creators?"
 #define GOSSIP_SELECT_KEEPER14  "This is a lot to think about."
 #define GOSSIP_SELECT_KEEPER15  "I will access the discs now."
+
 bool GossipHello_npc_lore_keeper_of_norgannon(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(2278) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_KEEPER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(1079, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_lore_keeper_of_norgannon(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -162,13 +186,16 @@ bool GossipSelect_npc_lore_keeper_of_norgannon(Player* pPlayer, Creature* pCreat
     }
     return true;
 }
+
 void AddSC_uldaman()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_jadespine_basilisk";
     newscript->GetAI = &GetAI_mob_jadespine_basilisk;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_lore_keeper_of_norgannon";
     newscript->pGossipHello = &GossipHello_npc_lore_keeper_of_norgannon;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/undercity.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/undercity.cpp
index c1c72fd9f9b..ecfd0894ddf 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/undercity.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/undercity.cpp
@@ -13,29 +13,37 @@
  * along 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, 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              -1000357
 #define EMOTE_LAMENT_END            -1000358
+
 #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},
@@ -43,21 +51,27 @@ float HighborneLoc[4][3]=
     {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 TRINITY_DLL_DECL npc_lady_sylvanas_windrunnerAI : public ScriptedAI
 {
     npc_lady_sylvanas_windrunnerAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 LamentEvent_Timer;
     bool LamentEvent;
     uint64 targetGUID;
+
     void Reset()
     {
         LamentEvent_Timer = 5000;
         LamentEvent = false;
         targetGUID = 0;
     }
+
     void EnterCombat(Unit *who) {}
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned->GetEntry() == ENTRY_HIGHBORNE_BUNNY)
@@ -68,10 +82,12 @@ struct TRINITY_DLL_DECL npc_lady_sylvanas_windrunnerAI : public ScriptedAI
                 target->GetMap()->CreatureRelocation(m_creature, target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0, 0.0f);
                 summoned->CastSpell(target, SPELL_RIBBON_OF_SOULS, false);
             }
+
             summoned->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
             targetGUID = summoned->GetGUID();
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (LamentEvent)
@@ -79,6 +95,7 @@ struct TRINITY_DLL_DECL npc_lady_sylvanas_windrunnerAI : public ScriptedAI
             if (LamentEvent_Timer < diff)
             {
                 DoSummon(ENTRY_HIGHBORNE_BUNNY, me, 10.0f, 3000, TEMPSUMMON_TIMED_DESPAWN);
+
                 LamentEvent_Timer = 2000;
                 if (!m_creature->HasAura(SPELL_SYLVANAS_CAST))
                 {
@@ -88,8 +105,10 @@ struct TRINITY_DLL_DECL npc_lady_sylvanas_windrunnerAI : public ScriptedAI
                 }
             }else LamentEvent_Timer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -97,6 +116,7 @@ CreatureAI* GetAI_npc_lady_sylvanas_windrunner(Creature* pCreature)
 {
     return new npc_lady_sylvanas_windrunnerAI (pCreature);
 }
+
 bool ChooseReward_npc_lady_sylvanas_windrunner(Player* pPlayer, Creature* pCreature, const Quest *_Quest, uint32 slot)
 {
     if (_Quest->GetQuestId() == 9180)
@@ -104,21 +124,27 @@ bool ChooseReward_npc_lady_sylvanas_windrunner(Player* pPlayer, Creature* pCreat
         CAST_AI(npc_lady_sylvanas_windrunnerAI, pCreature->AI())->LamentEvent = true;
         CAST_AI(npc_lady_sylvanas_windrunnerAI, pCreature->AI())->DoPlaySoundToSet(pCreature,SOUND_CREDIT);
         pCreature->CastSpell(pCreature,SPELL_SYLVANAS_CAST,false);
-        for (uint8 i = 0; i < 4; ++i)
+
+        for(uint8 i = 0; i < 4; ++i)
             pCreature->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 TRINITY_DLL_DECL npc_highborne_lamenterAI : public ScriptedAI
 {
     npc_highborne_lamenterAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 EventMove_Timer;
     uint32 EventCast_Timer;
     bool EventMove;
     bool EventCast;
+
     void Reset()
     {
         EventMove_Timer = 10000;
@@ -126,7 +152,9 @@ struct TRINITY_DLL_DECL npc_highborne_lamenterAI : public ScriptedAI
         EventMove = true;
         EventCast = true;
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (EventMove)
@@ -153,17 +181,22 @@ CreatureAI* GetAI_npc_highborne_lamenter(Creature* pCreature)
 {
     return new npc_highborne_lamenterAI (pCreature);
 }
+
 /*######
 ## npc_parqual_fintallas
 ######*/
+
 #define SPELL_MARK_OF_SHAME 6767
+
 #define GOSSIP_HPF1 "Gul'dan"
 #define GOSSIP_HPF2 "Kel'Thuzad"
 #define GOSSIP_HPF3 "Ner'zhul"
+
 bool GossipHello_npc_parqual_fintallas(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(6628) == QUEST_STATUS_INCOMPLETE && !pPlayer->HasAura(SPELL_MARK_OF_SHAME))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HPF1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
@@ -173,8 +206,10 @@ bool GossipHello_npc_parqual_fintallas(Player* pPlayer, Creature* pCreature)
     }
     else
         pPlayer->SEND_GOSSIP_MENU(5821, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_parqual_fintallas(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -189,21 +224,26 @@ bool GossipSelect_npc_parqual_fintallas(Player* pPlayer, Creature* pCreature, ui
     }
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_highborne_lamenter";
     newscript->GetAI = &GetAI_npc_highborne_lamenter;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_parqual_fintallas";
     newscript->pGossipHello = &GossipHello_npc_parqual_fintallas;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/western_plaguelands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/western_plaguelands.cpp
index bf1bed2152b..4181bc89867 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/western_plaguelands.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/western_plaguelands.cpp
@@ -13,32 +13,40 @@
  * along 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_myranda_the_hag
 npc_the_scourge_cauldron
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## npcs_dithers_and_arbington
 ######*/
+
 #define GOSSIP_HDA1 "What does the Felstone Field Cauldron need?"
 #define GOSSIP_HDA2 "What does the Dalson's Tears Cauldron need?"
 #define GOSSIP_HDA3 "What does the Writhing Haunt Cauldron need?"
 #define GOSSIP_HDA4 "What does the Gahrron's Withering Cauldron need?"
+
 #define GOSSIP_SDA1 "Thanks, i need a Vitreous Focuser"
+
 bool GossipHello_npcs_dithers_and_arbington(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
     if (pCreature->isVendor())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     if (pPlayer->GetQuestRewardStatus(5237) || pPlayer->GetQuestRewardStatus(5238))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HDA1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
@@ -48,8 +56,10 @@ bool GossipHello_npcs_dithers_and_arbington(Player* pPlayer, Creature* pCreature
         pPlayer->SEND_GOSSIP_MENU(3985, pCreature->GetGUID());
     }else
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npcs_dithers_and_arbington(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -80,20 +90,25 @@ bool GossipSelect_npcs_dithers_and_arbington(Player* pPlayer, Creature* pCreatur
     }
     return true;
 }
+
 /*######
 ## npc_myranda_the_hag
 ######*/
+
 enum eMyranda
 {
     QUEST_SUBTERFUGE        = 5862,
     QUEST_IN_DREAMS         = 5944,
     SPELL_SCARLET_ILLUSION  = 17961
 };
+
 #define GOSSIP_ITEM_ILLUSION    "I am ready for the illusion, Myranda."
+
 bool GossipHello_npc_myranda_the_hag(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_SUBTERFUGE) == QUEST_STATUS_COMPLETE &&
         !pPlayer->GetQuestRewardStatus(QUEST_IN_DREAMS) && !pPlayer->HasAura(SPELL_SCARLET_ILLUSION))
     {
@@ -103,8 +118,10 @@ bool GossipHello_npc_myranda_the_hag(Player* pPlayer, Creature* pCreature)
     }
     else
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_myranda_the_hag(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -114,14 +131,19 @@ bool GossipSelect_npc_myranda_the_hag(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 /*######
 ## npc_the_scourge_cauldron
 ######*/
+
 struct TRINITY_DLL_DECL npc_the_scourge_cauldronAI : public ScriptedAI
 {
     npc_the_scourge_cauldronAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
+
     void EnterCombat(Unit* who) {}
+
     void DoDie()
     {
         //summoner dies here
@@ -131,10 +153,12 @@ struct TRINITY_DLL_DECL npc_the_scourge_cauldronAI : public ScriptedAI
         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())
@@ -179,22 +203,27 @@ CreatureAI* GetAI_npc_the_scourge_cauldron(Creature* pCreature)
 {
     return new npc_the_scourge_cauldronAI (pCreature);
 }
+
 /*######
 ##
 ######*/
+
 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_myranda_the_hag";
     newscript->pGossipHello = &GossipHello_npc_myranda_the_hag;
     newscript->pGossipSelect = &GossipSelect_npc_myranda_the_hag;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_the_scourge_cauldron";
     newscript->GetAI = &GetAI_npc_the_scourge_cauldron;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/westfall.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/westfall.cpp
index c25dd521c68..6a1df820efa 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/westfall.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/westfall.cpp
@@ -13,21 +13,26 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Westfall
 SD%Complete: 90
 SDComment: Quest support: 155, 1651
 SDCategory: Westfall
 EndScriptData */
+
 /* ContentData
 npc_daphne_stilwell
 npc_defias_traitor
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_daphne_stilwell
 ######*/
+
 enum eEnums
 {
     SAY_DS_START        = -1000402,
@@ -35,16 +40,20 @@ enum eEnums
     SAY_DS_DOWN_2       = -1000404,
     SAY_DS_DOWN_3       = -1000405,
     SAY_DS_PROLOGUE     = -1000406,
+
     SPELL_SHOOT         = 6660,
     QUEST_TOME_VALOR    = 1651,
     NPC_DEFIAS_RAIDER   = 6180,
     EQUIP_ID_RIFLE      = 2511
 };
+
 struct TRINITY_DLL_DECL npc_daphne_stilwellAI : public npc_escortAI
 {
     npc_daphne_stilwellAI(Creature* pCreature) : npc_escortAI(pCreature) {}
+
     uint32 uiWPHolder;
     uint32 uiShootTimer;
+
     void Reset()
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
@@ -58,14 +67,19 @@ struct TRINITY_DLL_DECL npc_daphne_stilwellAI : public npc_escortAI
         }
         else
             uiWPHolder = 0;
+
         uiShootTimer = 0;
     }
+
     void WaypointReached(uint32 uiPoint)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         uiWPHolder = uiPoint;
+
         switch(uiPoint)
         {
             case 4:
@@ -109,66 +123,85 @@ struct TRINITY_DLL_DECL npc_daphne_stilwellAI : public npc_escortAI
                 break;
         }
     }
+
     void AttackStart(Unit* pWho)
     {
         if (!pWho)
             return;
+
         if (m_creature->Attack(pWho, false))
         {
             m_creature->AddThreat(pWho, 0.0f);
             m_creature->SetInCombatWith(pWho);
             pWho->SetInCombatWith(m_creature);
+
             m_creature->GetMotionMaster()->MoveChase(pWho, 30.0f);
         }
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         pSummoned->AI()->AttackStart(m_creature);
     }
+
     void Update(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
+
         if (!UpdateVictim())
             return;
+
         if (uiShootTimer < diff)
         {
             uiShootTimer = 1500;
+
             if (!m_creature->IsWithinDist(m_creature->getVictim(), ATTACK_DISTANCE))
                 DoCast(m_creature->getVictim(), SPELL_SHOOT);
         }else uiShootTimer -= diff;
     }
 };
+
 bool QuestAccept_npc_daphne_stilwell(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_TOME_VALOR)
     {
         DoScriptText(SAY_DS_START, pCreature);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_daphne_stilwellAI, pCreature->AI()))
             pEscortAI->Start(true, true, pPlayer->GetGUID());
     }
+
     return true;
 }
+
 CreatureAI* GetAI_npc_daphne_stilwell(Creature* pCreature)
 {
     return new npc_daphne_stilwellAI(pCreature);
 }
+
 /*######
 ## npc_defias_traitor
 ######*/
+
 #define SAY_START                   -1000101
 #define SAY_PROGRESS                -1000102
 #define SAY_END                     -1000103
 #define SAY_AGGRO_1                 -1000104
 #define SAY_AGGRO_2                 -1000105
+
 #define QUEST_DEFIAS_BROTHERHOOD    155
+
 struct TRINITY_DLL_DECL npc_defias_traitorAI : public npc_escortAI
 {
     npc_defias_traitorAI(Creature *c) : npc_escortAI(c) { Reset(); }
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch (i)
         {
             case 35:
@@ -190,30 +223,38 @@ struct TRINITY_DLL_DECL npc_defias_traitorAI : public npc_escortAI
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2), m_creature, who);
     }
+
     void Reset() {}
 };
+
 bool QuestAccept_npc_defias_traitor(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_DEFIAS_BROTHERHOOD)
     {
         if (npc_escortAI* pEscortAI = CAST_AI(npc_defias_traitorAI, pCreature->AI()))
             pEscortAI->Start(true, true, pPlayer->GetGUID());
+
         DoScriptText(SAY_START, pCreature, pPlayer);
     }
+
     return true;
 }
+
 CreatureAI* GetAI_npc_defias_traitor(Creature* pCreature)
 {
     return new npc_defias_traitorAI(pCreature);
 }
+
 void AddSC_westfall()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_daphne_stilwell";
     newscript->GetAI = &GetAI_npc_daphne_stilwell;
     newscript->pQuestAccept = &QuestAccept_npc_daphne_stilwell;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_defias_traitor";
     newscript->GetAI = &GetAI_npc_defias_traitor;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/wetlands.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/wetlands.cpp
index 76bf0e7ee60..d50d0fa2d2d 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/wetlands.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/wetlands.cpp
@@ -13,21 +13,26 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Wetlands
 SD%Complete: 80
 SDComment: Quest support: 1249
 SDCategory: Wetlands
 EndScriptData */
+
 /* ContentData
 npc_mikhail
 npc_tapoke_slim_jahn
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_tapoke_slim_jahn
 ######*/
+
 enum eTapokeSlim
 {
     QUEST_MISSING_DIPLO_PT11    = 1249,
@@ -37,15 +42,19 @@ enum eTapokeSlim
     NPC_SLIMS_FRIEND            = 4971,
     NPC_TAPOKE_SLIM_JAHN        = 4962
 };
+
 struct TRINITY_DLL_DECL npc_tapoke_slim_jahnAI : public npc_escortAI
 {
     npc_tapoke_slim_jahnAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     bool m_bFriendSummoned;
+
     void Reset()
     {
         if (!HasEscortState(STATE_ESCORT_ESCORTING))
             m_bFriendSummoned = false;
     }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
@@ -53,34 +62,43 @@ struct TRINITY_DLL_DECL npc_tapoke_slim_jahnAI : public npc_escortAI
             case 2:
                 if (m_creature->HasStealthAura())
                     m_creature->RemoveAurasDueToSpell(SPELL_AURA_MOD_STEALTH);
+
                 SetRun();
                 m_creature->setFaction(FACTION_ENEMY);
                 break;
         }
     }
+
     void Aggro(Unit* pWho)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (HasEscortState(STATE_ESCORT_ESCORTING) && !m_bFriendSummoned && pPlayer)
         {
-            for (uint8 i = 0; i < 3; ++i)
+            for(uint8 i = 0; i < 3; ++i)
                 m_creature->CastSpell(m_creature, SPELL_CALL_FRIENDS, true);
+
             m_bFriendSummoned = true;
         }
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (Player* pPlayer = GetPlayerForEscort())
             pSummoned->AI()->AttackStart(pPlayer);
     }
+
     void AttackedBy(Unit* pAttacker)
     {
         if (m_creature->getVictim())
             return;
+
         if (m_creature->IsFriendlyTo(pAttacker))
             return;
+
         AttackStart(pAttacker);
     }
+
     void DamageTaken(Unit* pDoneBy, uint32& uiDamage)
     {
         if (m_creature->GetHealth()*100 < m_creature->GetMaxHealth()*20)
@@ -89,47 +107,60 @@ struct TRINITY_DLL_DECL npc_tapoke_slim_jahnAI : public npc_escortAI
             {
                 if (pPlayer->GetTypeId() == TYPEID_PLAYER)
                     CAST_PLR(pPlayer)->GroupEventHappens(QUEST_MISSING_DIPLO_PT11, m_creature);
+
                 uiDamage = 0;
+
                 me->RestoreFaction();
                 m_creature->RemoveAllAuras();
                 m_creature->DeleteThreatList();
                 m_creature->CombatStop(true);
+
                 SetRun(false);
             }
         }
     }
 };
+
 CreatureAI* GetAI_npc_tapoke_slim_jahn(Creature* pCreature)
 {
     return new npc_tapoke_slim_jahnAI(pCreature);
 }
+
 /*######
 ## npc_mikhail
 ######*/
+
 bool QuestAccept_npc_mikhail(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_MISSING_DIPLO_PT11)
     {
         Creature* pSlim = pCreature->FindNearestCreature(NPC_TAPOKE_SLIM_JAHN, 25.0f);
+
         if (!pSlim)
             return false;
+
         if (!pSlim->HasStealthAura())
             pSlim->CastSpell(pSlim, SPELL_STEALTH, true);
+
         if (npc_tapoke_slim_jahnAI* pEscortAI = CAST_AI(npc_tapoke_slim_jahnAI, pSlim->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
     }
     return false;
 }
+
 /*######
 ## AddSC
 ######*/
+
 void AddSC_wetlands()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_tapoke_slim_jahn";
     newscript->GetAI = &GetAI_npc_tapoke_slim_jahn;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_mikhail";
     newscript->pQuestAccept = &QuestAccept_npc_mikhail;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_akilzon.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_akilzon.cpp
index 2d2222fcbbd..8ac1d4166e6 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_akilzon.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_akilzon.cpp
@@ -13,16 +13,20 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: boss_Akilzon
 SD%Complete: 75%
 SDComment: Missing timer for Call Lightning and Sound ID's
 SQLUpdate:
 #Temporary fix for Soaring Eagles
+
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_zulaman.h"
 #include "Weather.h"
+
 #define SPELL_STATIC_DISRUPTION     43622
 #define SPELL_STATIC_VISUAL         45265
 #define SPELL_CALL_LIGHTNING        43661 //Missing timer
@@ -32,6 +36,7 @@ EndScriptData */
 #define SPELL_ELECTRICAL_DAMAGE     43657
 #define SPELL_ELECTRICAL_OVERLOAD   43658
 #define SPELL_EAGLE_SWOOP           44732
+
 //"Your death gonna be quick, strangers. You shoulda never have come to this place..."
 #define SAY_ONAGGRO "I be da predator! You da prey..."
 #define SAY_ONDEATH "You can't... kill... me spirit!"
@@ -45,11 +50,13 @@ EndScriptData */
 #define SOUND_ONSLAY2 12018
 #define SOUND_ONSUMMON 12014
 #define SOUND_ONENRAGE 12016
+
 #define MOB_SOARING_EAGLE 24858
 #define SE_LOC_X_MAX 400
 #define SE_LOC_X_MIN 335
 #define SE_LOC_Y_MAX 1435
 #define SE_LOC_Y_MIN 1370
+
 struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
 {
     boss_akilzonAI(Creature *c) : ScriptedAI(c)
@@ -60,40 +67,51 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
         pInstance = c->GetInstanceData();
     }
     ScriptedInstance *pInstance;
+
     uint64 BirdGUIDs[8];
     uint64 TargetGUID;
     uint64 CycloneGUID;
     uint64 CloudGUID;
+
     uint32 StaticDisruption_Timer;
     uint32 GustOfWind_Timer;
     uint32 CallLighting_Timer;
     uint32 ElectricalStorm_Timer;
     uint32 SummonEagles_Timer;
     uint32 Enrage_Timer;
+
     uint32 StormCount;
     uint32 StormSequenceTimer;
+
     bool isRaining;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_AKILZONEVENT, NOT_STARTED);
+
         StaticDisruption_Timer = (10+rand()%10)*1000; //10 to 20 seconds (bosskillers)
         GustOfWind_Timer = (20+rand()%10)*1000; //20 to 30 seconds(bosskillers)
         CallLighting_Timer = (10+rand()%10)*1000; //totaly random timer. can't find any info on this
         ElectricalStorm_Timer = 60*1000; //60 seconds(bosskillers)
         Enrage_Timer = 10*60*1000; //10 minutes till enrage(bosskillers)
         SummonEagles_Timer = 99999;
+
         TargetGUID = 0;
         CloudGUID = 0;
         CycloneGUID = 0;
         DespawnSummons();
-        for (uint8 i = 0; i < 8; ++i)
+        for(uint8 i = 0; i < 8; ++i)
             BirdGUIDs[i] = 0;
+
         StormCount = 0;
         StormSequenceTimer = 0;
+
         isRaining = false;
+
         SetWeather(WEATHER_STATE_FINE, 0.0f);
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->MonsterYell(SAY_ONAGGRO, LANG_UNIVERSAL, NULL);
@@ -102,6 +120,7 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(DATA_AKILZONEVENT, IN_PROGRESS);
     }
+
     void JustDied(Unit* Killer)
     {
         m_creature->MonsterYell(SAY_ONDEATH,LANG_UNIVERSAL,NULL);
@@ -110,6 +129,7 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
             pInstance->SetData(DATA_AKILZONEVENT, DONE);
         DespawnSummons();
     }
+
     void KilledUnit(Unit* victim)
     {
         switch(rand()%2)
@@ -124,6 +144,7 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
             break;
         }
     }
+
     void DespawnSummons()
     {
         for (uint8 i = 0; i < 8; ++i)
@@ -136,38 +157,47 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
             }
         }
     }
+
     void SetWeather(uint32 weather, float grade)
     {
         Map* pMap = m_creature->GetMap();
         if (!pMap->IsDungeon()) return;
+
         WorldPacket data(SMSG_WEATHER, (4+4+4));
         data << uint32(weather) << (float)grade << uint8(0);
+
         pMap->SendToPlayers(&data);
     }
+
     void HandleStormSequence(Unit *Cloud) // 1: begin, 2-9: tick, 10: end
     {
         if (StormCount < 10 && StormCount > 1)
         {
             // deal damage
             int32 bp0 = 800;
-            for (uint8 i = 2; i < StormCount; ++i)
+            for(uint8 i = 2; i < StormCount; ++i)
                 bp0 *= 2;
+
             CellPair p(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
             Cell cell(p);
             cell.data.Part.reserved = ALL_DISTRICT;
             cell.SetNoCreate();
+
             std::list tempUnitMap;
+
             {
                 Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(m_creature, m_creature, 999);
                 Trinity::UnitListSearcher searcher(m_creature, 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, *(m_creature->GetMap()));
                 cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap()));
             }
             //dealdamege
-            for (std::list::iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i)
+            for(std::list::iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i)
             {
                 if (!Cloud->IsWithinDist(*i, 6, false))
                 {
@@ -177,7 +207,7 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
             // visual
             float x,y,z;
             z = m_creature->GetPositionZ();
-            for (uint8 i = 0; i < 5+rand()%5; ++i)
+            for(uint8 i = 0; i < 5+rand()%5; ++i)
             {
                 x = 343+rand()%60;
                 y = 1380+rand()%60;
@@ -206,10 +236,12 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
         }
         StormSequenceTimer = 1000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (StormCount)
         {
             Unit* target = Unit::GetUnit(*m_creature, CloudGUID);
@@ -220,17 +252,20 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
             }
             else if (Unit* Cyclone = Unit::GetUnit(*m_creature, CycloneGUID))
                 Cyclone->CastSpell(target, 25160, true); // keep casting or...
+
             if (StormSequenceTimer < diff) {
                 HandleStormSequence(target);
             }else StormSequenceTimer -= diff;
             return;
         }
+
         if (Enrage_Timer < diff) {
             m_creature->MonsterYell(SAY_ONENRAGE, LANG_UNIVERSAL, NULL);
             DoPlaySoundToSet(m_creature, SOUND_ONENRAGE);
             m_creature->CastSpell(m_creature, SPELL_BERSERK, true);
             Enrage_Timer = 600000;
         }else Enrage_Timer -= diff;
+
         if (StaticDisruption_Timer < diff) {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
             if (!target) target = m_creature->getVictim();
@@ -238,23 +273,28 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
             m_creature->CastSpell(target, SPELL_STATIC_DISRUPTION, false);
             m_creature->SetInFront(m_creature->getVictim());
             StaticDisruption_Timer = (10+rand()%8)*1000; // < 20s
+
             /*if (float dist = m_creature->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f) dist = 5.0f;
             SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);*/
         }else StaticDisruption_Timer -= diff;
+
         if (GustOfWind_Timer < diff) {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
             if (!target) target = m_creature->getVictim();
             DoCast(target, SPELL_GUST_OF_WIND);
             GustOfWind_Timer = (20+rand()%10)*1000; //20 to 30 seconds(bosskillers)
         } else GustOfWind_Timer -= diff;
+
         if (CallLighting_Timer < diff) {
             DoCast(m_creature->getVictim(), SPELL_CALL_LIGHTNING);
             CallLighting_Timer = (12 + rand()%5)*1000; //totaly random timer. can't find any info on this
         } else CallLighting_Timer -= diff;
+
         if (!isRaining && ElectricalStorm_Timer < 8000 + rand()%5000) {
             SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f);
             isRaining = true;
         }
+
         if (ElectricalStorm_Timer < diff) {
             Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true);
             if (!target)
@@ -287,16 +327,19 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
             StormCount = 1;
             StormSequenceTimer = 0;
         } else ElectricalStorm_Timer -= diff;
+
         if (SummonEagles_Timer < diff)
         {
             m_creature->MonsterYell(SAY_ONSUMMON, LANG_UNIVERSAL, NULL);
             DoPlaySoundToSet(m_creature, SOUND_ONSUMMON);
+
             float x, y, z;
             m_creature->GetPosition(x, y, z);
+
             for (uint8 i = 0; i < 8; ++i)
             {
                 Unit* bird = Unit::GetUnit(*m_creature,BirdGUIDs[i]);
-                if (!bird) //they despawned on die
+                if (!bird)//they despawned on die
                 {
                     if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                     {
@@ -316,15 +359,19 @@ struct TRINITY_DLL_DECL boss_akilzonAI : public ScriptedAI
             }
             SummonEagles_Timer = 999999;
         } else SummonEagles_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_soaring_eagleAI : public ScriptedAI
 {
     mob_soaring_eagleAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 EagleSwoop_Timer;
     bool arrived;
     uint32 TargetGUID;
+
     void Reset()
     {
         EagleSwoop_Timer = 5000 + rand()%5000;
@@ -332,8 +379,11 @@ struct TRINITY_DLL_DECL mob_soaring_eagleAI : public ScriptedAI
         TargetGUID = 0;
         m_creature->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
     }
+
     void EnterCombat(Unit *who) {DoZoneInCombat();}
+
     void MoveInLineOfSight(Unit* who) {}
+
     void MovementInform(uint32, uint32)
     {
         arrived = true;
@@ -346,10 +396,12 @@ struct TRINITY_DLL_DECL mob_soaring_eagleAI : public ScriptedAI
             EagleSwoop_Timer = 5000 + rand()%5000;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (EagleSwoop_Timer < diff) EagleSwoop_Timer = 0;
         else EagleSwoop_Timer -= diff;
+
         if (arrived)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -375,22 +427,27 @@ struct TRINITY_DLL_DECL mob_soaring_eagleAI : public ScriptedAI
         }
     }
 };
+
 //Soaring Eagle
 CreatureAI* GetAI_mob_soaring_eagle(Creature* pCreature)
 {
     return new mob_soaring_eagleAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_akilzon(Creature* pCreature)
 {
     return new boss_akilzonAI(pCreature);
 }
+
 void AddSC_boss_akilzon()
 {
     Script *newscript = NULL;
+
     newscript = new Script;
     newscript->Name = "boss_akilzon";
     newscript->GetAI = &GetAI_boss_akilzon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_akilzon_eagle";
     newscript->GetAI = &GetAI_mob_soaring_eagle;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_halazzi.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_halazzi.cpp
index ff1a26e548c..2cced564afb 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_halazzi.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_halazzi.cpp
@@ -13,15 +13,18 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: boss_Halazzi
 SD%Complete: 80
 SDComment:
 SDCategory: Zul'Aman
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_zulaman.h"
 //#include "spell.h"
+
 #define YELL_AGGRO "Get on your knees and bow to da fang and claw!"
 #define SOUND_AGGRO                    12020
 #define YELL_SABER_ONE "You gonna leave in pieces!"
@@ -38,6 +41,7 @@ EndScriptData */
 #define SOUND_DEATH                    12028
 #define YELL_BERSERK "Whatch you be doing? Pissin' yourselves..."
 #define SOUND_BERSERK                12025
+
 #define SPELL_DUAL_WIELD                29651
 #define SPELL_SABER_LASH                43267
 #define SPELL_FRENZY                    43139
@@ -49,11 +53,14 @@ EndScriptData */
 #define SPELL_SUMMON_LYNX               43143
 #define SPELL_SUMMON_TOTEM              43302
 #define SPELL_BERSERK                   45078
+
 #define MOB_SPIRIT_LYNX                 24143
 #define SPELL_LYNX_FRENZY               43290
 #define SPELL_SHRED_ARMOR               43243
+
 #define MOB_TOTEM                       24224
 #define SPELL_LIGHTNING                 43301
+
 enum PhaseHalazzi
 {
     PHASE_NONE = 0,
@@ -63,6 +70,7 @@ enum PhaseHalazzi
     PHASE_MERGE = 4,
     PHASE_ENRAGE = 5
 };
+
 struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
 {
     boss_halazziAI(Creature *c) : ScriptedAI(c)
@@ -73,55 +81,72 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
         if (TempSpell && TempSpell->CastingTimeIndex != 5)
             TempSpell->CastingTimeIndex = 5; // 2000 ms casting time
     }
+
     ScriptedInstance *pInstance;
+
     uint32 FrenzyTimer;
     uint32 SaberlashTimer;
     uint32 ShockTimer;
     uint32 TotemTimer;
     uint32 CheckTimer;
     uint32 BerserkTimer;
+
     uint32 TransformCount;
+
     PhaseHalazzi Phase;
+
     uint64 LynxGUID;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_HALAZZIEVENT, NOT_STARTED);
+
         TransformCount = 0;
         BerserkTimer = 600000;
         CheckTimer = 1000;
+
         DoCast(m_creature, SPELL_DUAL_WIELD, true);
+
         Phase = PHASE_NONE;
         EnterPhase(PHASE_LYNX);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_HALAZZIEVENT, IN_PROGRESS);
+
         m_creature->MonsterYell(YELL_AGGRO, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_AGGRO);
+
         EnterPhase(PHASE_LYNX);
     }
+
     void JustSummoned(Creature* summon)
     {
         summon->AI()->AttackStart(m_creature->getVictim());
         if (summon->GetEntry() == MOB_SPIRIT_LYNX)
             LynxGUID = summon->GetGUID();
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth() && Phase != PHASE_ENRAGE)
             damage = 0;
     }
+
     void SpellHit(Unit*, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_TRANSFORM_SPLIT2)
             EnterPhase(PHASE_HUMAN);
     }
+
     void AttackStart(Unit *who)
     {
         if (Phase != PHASE_MERGE) ScriptedAI::AttackStart(who);
     }
+
     void EnterPhase(PhaseHalazzi NextPhase)
     {
         switch(NextPhase)
@@ -176,10 +201,12 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
         }
         Phase = NextPhase;
     }
+
      void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (BerserkTimer < diff)
         {
             m_creature->MonsterYell(YELL_BERSERK, LANG_UNIVERSAL, NULL);
@@ -187,6 +214,7 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
             DoCast(m_creature, SPELL_BERSERK, true);
             BerserkTimer = 60000;
         }else BerserkTimer -= diff;
+
         if (Phase == PHASE_LYNX || Phase == PHASE_ENRAGE)
         {
             if (SaberlashTimer < diff)
@@ -197,11 +225,13 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
                 //m_creature->RemoveAurasDueToSpell(41296);
                 SaberlashTimer = 30000;
             }else SaberlashTimer -= diff;
+
             if (FrenzyTimer < diff)
             {
                 DoCast(m_creature, SPELL_FRENZY);
                 FrenzyTimer = (10+rand()%5)*1000;
             }else FrenzyTimer -= diff;
+
             if (Phase == PHASE_LYNX)
                 if (CheckTimer < diff)
                 {
@@ -210,6 +240,7 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
                     CheckTimer = 1000;
                 }else CheckTimer -= diff;
         }
+
         if (Phase == PHASE_HUMAN || Phase == PHASE_ENRAGE)
         {
             if (TotemTimer < diff)
@@ -217,6 +248,7 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
                 DoCast(m_creature, SPELL_SUMMON_TOTEM);
                 TotemTimer = 20000;
             }else TotemTimer -= diff;
+
             if (ShockTimer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
@@ -228,6 +260,7 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
                     ShockTimer = 10000 + rand()%5000;
                 }
             }else ShockTimer -= diff;
+
             if (Phase == PHASE_HUMAN)
                 if (CheckTimer < diff)
                 {
@@ -242,6 +275,7 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
                     CheckTimer = 1000;
                 }else CheckTimer -= diff;
         }
+
         if (Phase == PHASE_MERGE)
         {
             if (CheckTimer < diff)
@@ -262,8 +296,10 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
                 CheckTimer = 1000;
             }else CheckTimer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
+
     void KilledUnit(Unit* victim)
     {
         switch(rand()%2)
@@ -272,67 +308,85 @@ struct TRINITY_DLL_DECL boss_halazziAI : public ScriptedAI
             m_creature->MonsterYell(YELL_KILL_ONE, LANG_UNIVERSAL, NULL);
             DoPlaySoundToSet(m_creature, SOUND_KILL_ONE);
             break;
+
         case 1:
             m_creature->MonsterYell(YELL_KILL_TWO, LANG_UNIVERSAL, NULL);
             DoPlaySoundToSet(m_creature, SOUND_KILL_TWO);
             break;
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_HALAZZIEVENT, DONE);
+
         m_creature->MonsterYell(YELL_DEATH, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_DEATH);
     }
 };
+
 // Spirits Lynx AI
+
 struct TRINITY_DLL_DECL boss_spiritlynxAI : public ScriptedAI
 {
     boss_spiritlynxAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 FrenzyTimer;
     uint32 shredder_timer;
+
     void Reset()
     {
         FrenzyTimer = (30+rand()%20)*1000;  //frenzy every 30-50 seconds
         shredder_timer = 4000;
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth())
             damage = 0;
     }
+
     void AttackStart(Unit *who)
     {
         if (!m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             ScriptedAI::AttackStart(who);
     }
+
     void EnterCombat(Unit *who) {/*DoZoneInCombat();*/}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (FrenzyTimer < diff)
         {
             DoCast(m_creature, SPELL_LYNX_FRENZY);
             FrenzyTimer = (30+rand()%20)*1000;
         }else FrenzyTimer -= diff;
+
         if (shredder_timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SHRED_ARMOR);
             shredder_timer = 4000;
         }else shredder_timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
 };
+
 CreatureAI* GetAI_boss_halazziAI(Creature* pCreature)
 {
     return new boss_halazziAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_spiritlynxAI(Creature* pCreature)
 {
     return new boss_spiritlynxAI (pCreature);
 }
+
 void AddSC_boss_halazzi()
 {
     Script *newscript;
@@ -340,6 +394,7 @@ void AddSC_boss_halazzi()
     newscript->Name = "boss_halazzi";
     newscript->GetAI = &GetAI_boss_halazziAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_halazzi_lynx";
     newscript->GetAI = &GetAI_boss_spiritlynxAI;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp
index 202634abbd1..d2933de614f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp
@@ -13,14 +13,17 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: Boss_Hex_Lord_Malacrass
 SD%Complete:
 SDComment:
 SDCategory: Zul'Aman
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_zulaman.h"
+
 #define YELL_AGGRO              "Da shadow gonna fall on you... "
 #define SOUND_YELL_AGGRO        12041
 #define YELL_SPIRIT_BOLTS       "Your soul gonna bleed!"
@@ -33,28 +36,36 @@ EndScriptData */
 #define SOUND_YELL_KILL_TWO     12044
 #define YELL_DEATH              "Dis not... da end of me..."
 #define SOUND_YELL_DEATH        12051
+
 #define SPELL_SPIRIT_BOLTS      43383
 #define SPELL_DRAIN_POWER       44131
 #define SPELL_SIPHON_SOUL       43501
+
 #define MOB_TEMP_TRIGGER        23920
+
 //Defines for various powers he uses after using soul drain
+
 //Druid
 #define SPELL_DR_LIFEBLOOM      43421
 #define SPELL_DR_THORNS         43420
 #define SPELL_DR_MOONFIRE       43545
+
 //Hunter
 #define SPELL_HU_EXPLOSIVE_TRAP 43444
 #define SPELL_HU_FREEZING_TRAP  43447
 #define SPELL_HU_SNAKE_TRAP     43449
+
 //Mage
 #define SPELL_MG_FIREBALL       41383
 #define SPELL_MG_FROSTBOLT      43428
 #define SPELL_MG_FROST_NOVA     43426
 #define SPELL_MG_ICE_LANCE      43427
+
 //Paladin
 #define SPELL_PA_CONSECRATION   43429
 #define SPELL_PA_HOLY_LIGHT     43451
 #define SPELL_PA_AVENGING_WRATH 43430
+
 //Priest
 #define SPELL_PR_HEAL           41372
 #define SPELL_PR_MIND_CONTROL   43550
@@ -62,26 +73,33 @@ EndScriptData */
 #define SPELL_PR_SW_DEATH       41375
 #define SPELL_PR_PSYCHIC_SCREAM 43432
 #define SPELL_PR_PAIN_SUPP      44416
+
 //Rogue
 #define SPELL_RO_BLIND          43433
 #define SPELL_RO_SLICE_DICE     43457
 #define SPELL_RO_WOUND_POISON   39665
+
 //Shaman
 #define SPELL_SH_FIRE_NOVA      43436
 #define SPELL_SH_HEALING_WAVE   43548
 #define SPELL_SH_CHAIN_LIGHT    43435
+
 //Warlock
 #define SPELL_WL_CURSE_OF_DOOM  43439
 #define SPELL_WL_RAIN_OF_FIRE   43440
 #define SPELL_WL_UNSTABLE_AFFL  35183
+
 //Warrior
 #define SPELL_WR_SPELL_REFLECT  43443
 #define SPELL_WR_WHIRLWIND      43442
 #define SPELL_WR_MORTAL_STRIKE  43441
+
 #define ORIENT                  1.5696
 #define POS_Y                   921.2795
 #define POS_Z                   33.8883
+
 static float Pos_X[4] = {112.8827, 107.8827, 122.8827, 127.8827};
+
 static uint32 AddEntryList[8]=
 {
     24240, //Alyson Antille
@@ -93,6 +111,7 @@ static uint32 AddEntryList[8]=
     24246, //Darkheart
     24247  //Koragg
 };
+
 enum AbilityTarget
 {
     ABILITY_TARGET_SELF = 0,
@@ -102,12 +121,14 @@ enum AbilityTarget
     ABILITY_TARGET_BUFF = 4,
     ABILITY_TARGET_SPECIAL = 5
 };
+
 struct PlayerAbilityStruct
 {
     uint32 spell;
     AbilityTarget target;
     uint32 cooldown;
 };
+
 static PlayerAbilityStruct PlayerAbility[][3] =
 {
     // 1 warrior
@@ -151,15 +172,20 @@ static PlayerAbilityStruct PlayerAbility[][3] =
     {SPELL_DR_THORNS, ABILITY_TARGET_SELF, 10000},
     {SPELL_DR_MOONFIRE, ABILITY_TARGET_ENEMY, 8000}}
 };
+
 struct TRINITY_DLL_DECL boss_hexlord_addAI : public ScriptedAI
 {
     ScriptedInstance* pInstance;
+
     boss_hexlord_addAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     void Reset() {}
+
     void EnterCombat(Unit* who) {DoZoneInCombat();}
+
     void UpdateAI(const uint32 diff)
     {
         if (pInstance && pInstance->GetData(DATA_HEXLORDEVENT) != IN_PROGRESS)
@@ -167,52 +193,67 @@ struct TRINITY_DLL_DECL boss_hexlord_addAI : public ScriptedAI
             EnterEvadeMode();
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
 {
     boss_hex_lord_malacrassAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
         SelectAddEntry();
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
             AddGUID[i] = 0;
     }
+
     ScriptedInstance *pInstance;
+
     uint64 AddGUID[4];
     uint32 AddEntry[4];
+
     uint64 PlayerGUID;
+
     uint32 SpiritBolts_Timer;
     uint32 DrainPower_Timer;
     uint32 SiphonSoul_Timer;
     uint32 PlayerAbility_Timer;
     uint32 CheckAddState_Timer;
     uint32 ResetTimer;
+
     uint32 PlayerClass;
+
     Unit* SoulDrainTarget;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_HEXLORDEVENT, NOT_STARTED);
+
         SpiritBolts_Timer = 20000;
         DrainPower_Timer = 60000;
         SiphonSoul_Timer = 100000;
         PlayerAbility_Timer = 99999;
         CheckAddState_Timer = 5000;
         ResetTimer = 5000;
+
         SpawnAdds();
+
         m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 46916);
         m_creature->SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE);
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
             pInstance->SetData(DATA_HEXLORDEVENT, IN_PROGRESS);
+
         DoZoneInCombat();
         m_creature->MonsterYell(YELL_AGGRO, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_YELL_AGGRO);
-        for (uint8 i = 0; i < 4; ++i)
+
+        for(uint8 i = 0; i < 4; ++i)
         {
             Unit* Temp = Unit::GetUnit((*m_creature),AddGUID[i]);
             if (Temp && Temp->isAlive())
@@ -224,6 +265,7 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         switch(rand()%2)
@@ -238,33 +280,41 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
             break;
         }
     }
+
     void JustDied(Unit* victim)
     {
         if (pInstance)
             pInstance->SetData(DATA_HEXLORDEVENT, DONE);
+
         m_creature->MonsterYell(YELL_DEATH, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_YELL_DEATH);
-        for (uint8 i = 0; i < 4 ; ++i)
+
+        for(uint8 i = 0; i < 4 ; ++i)
         {
             Unit* Temp = Unit::GetUnit((*m_creature),AddGUID[i]);
             if (Temp && Temp->isAlive())
                 Temp->DealDamage(Temp, Temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         }
     }
+
     void SelectAddEntry()
     {
         std::vector AddList;
-        for (uint8 i = 0; i < 8; ++i)
+
+        for(uint8 i = 0; i < 8; ++i)
             AddList.push_back(AddEntryList[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, ++i)
+        for(std::vector::iterator itr = AddList.begin(); itr != AddList.end(); ++itr, ++i)
             AddEntry[i] = *itr;
     }
+
     void SpawnAdds()
     {
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             Creature *pCreature = (Unit::GetCreature((*m_creature), AddGUID[i]));
             if (!pCreature || !pCreature->isAlive())
@@ -281,10 +331,12 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (ResetTimer < diff)
         {
             if (m_creature->IsWithinDist3d(119.223,1035.45,29.4481, 10))
@@ -294,9 +346,10 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
             }
             ResetTimer = 5000;
         }else ResetTimer -= diff;
+
         if (CheckAddState_Timer < diff)
         {
-            for (uint8 i = 0; i < 4; ++i)
+            for(uint8 i = 0; i < 4; ++i)
             {
                 Unit* Temp = Unit::GetUnit((*m_creature),AddGUID[i]);
                 if (Temp && Temp->isAlive() && !Temp->getVictim())
@@ -304,6 +357,7 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
             }
             CheckAddState_Timer = 5000;
         }else CheckAddState_Timer -= diff;
+
         if (DrainPower_Timer < diff)
         {
             m_creature->CastSpell(m_creature, SPELL_DRAIN_POWER, true);
@@ -311,6 +365,7 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
             DoPlaySoundToSet(m_creature, SOUND_YELL_DRAIN_POWER);
             DrainPower_Timer = 40000 + rand()%15000;    // must cast in 60 sec, or buff/debuff will disappear
         }else DrainPower_Timer -= diff;
+
         if (SpiritBolts_Timer < diff)
         {
             if (DrainPower_Timer < 12000)    // channel 10 sec
@@ -325,6 +380,7 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
                 PlayerAbility_Timer = 99999;
             }
         }else SpiritBolts_Timer -= diff;
+
         if (SiphonSoul_Timer < diff)
         {
             Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 70, true);
@@ -340,9 +396,11 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
                 trigger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                 trigger->CastSpell(target, SPELL_SIPHON_SOUL, true);
                 trigger->GetMotionMaster()->MoveChase(m_creature);
+
                 //m_creature->CastSpell(target, SPELL_SIPHON_SOUL, true);
                 //m_creature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, target->GetGUID());
                 //m_creature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SIPHON_SOUL);
+
                 PlayerGUID = target->GetGUID();
                 PlayerAbility_Timer = 8000 + rand()%2000;
                 PlayerClass = target->getClass() - 1;
@@ -351,6 +409,7 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
                 SiphonSoul_Timer = 99999;   // buff lasts 30 sec
             }
         }else SiphonSoul_Timer -= diff;
+
         if (PlayerAbility_Timer < diff)
         {
             //Unit* target = Unit::GetUnit(*m_creature, PlayerGUID);
@@ -360,8 +419,10 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
                 PlayerAbility_Timer = 8000 + rand()%2000;
             }
         }else PlayerAbility_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void UseAbility()
     {
         uint32 random = rand()%3;
@@ -392,23 +453,31 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
             m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false);
     }
 };
+
 #define SPELL_BLOODLUST       43578
 #define SPELL_CLEAVE          15496
+
 struct TRINITY_DLL_DECL boss_thurgAI : public boss_hexlord_addAI
 {
+
     boss_thurgAI(Creature *c) : boss_hexlord_addAI(c) {}
+
     uint32 bloodlust_timer;
     uint32 cleave_timer;
+
     void Reset()
     {
         bloodlust_timer = 15000;
         cleave_timer = 10000;
+
         boss_hexlord_addAI::Reset();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (bloodlust_timer < diff)
         {
             std::list templist = DoFindFriendlyMissingBuff(50, SPELL_BLOODLUST);
@@ -419,33 +488,43 @@ struct TRINITY_DLL_DECL boss_thurgAI : public boss_hexlord_addAI
             }
             bloodlust_timer = 12000;
         }else bloodlust_timer -= diff;
+
         if (cleave_timer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(),SPELL_CLEAVE, false);
             cleave_timer = 12000; //3 sec cast
         }else cleave_timer -= diff;
+
         boss_hexlord_addAI::UpdateAI(diff);
     }
 };
+
 #define SPELL_FLASH_HEAL     43575
 #define SPELL_DISPEL_MAGIC   43577
+
 struct TRINITY_DLL_DECL boss_alyson_antilleAI : public boss_hexlord_addAI
 {
     //Holy Priest
     boss_alyson_antilleAI(Creature *c) : boss_hexlord_addAI(c) {}
+
     uint32 flashheal_timer;
     uint32 dispelmagic_timer;
+
     void Reset()
     {
         flashheal_timer = 2500;
         dispelmagic_timer = 10000;
+
         //AcquireGUID();
+
         boss_hexlord_addAI::Reset();
     }
+
     void AttackStart(Unit* who)
     {
         if (!who)
             return;
+
         if (who->isTargetableForAttack())
         {
             if (m_creature->Attack(who, false))
@@ -455,10 +534,12 @@ struct TRINITY_DLL_DECL boss_alyson_antilleAI : public boss_hexlord_addAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (flashheal_timer < diff)
         {
             Unit* target = DoSelectLowestHpFriendly(99, 30000);
@@ -485,34 +566,44 @@ struct TRINITY_DLL_DECL boss_alyson_antilleAI : public boss_hexlord_addAI
             }
             flashheal_timer = 2500;
         }else flashheal_timer -= diff;
+
         /*if (dispelmagic_timer < diff)
         {
         if (rand()%2)
         {
         Unit* target = SelectTarget();
+
         m_creature->CastSpell(target, SPELL_DISPEL_MAGIC, false);
         }
         else
         m_creature->CastSpell(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DISPEL_MAGIC, false);
+
         dispelmagic_timer = 12000;
         }else dispelmagic_timer -= diff;*/
+
         boss_hexlord_addAI::UpdateAI(diff);
     }
 };
+
 #define SPELL_FIREBOLT        43584
+
 struct TRINITY_DLL_DECL boss_gazakrothAI : public boss_hexlord_addAI
 {
     boss_gazakrothAI(Creature *c) : boss_hexlord_addAI(c)  {}
+
     uint32 firebolt_timer;
+
     void Reset()
     {
         firebolt_timer = 2000;
         boss_hexlord_addAI::Reset();
     }
+
     void AttackStart(Unit* who)
     {
         if (!who)
             return;
+
         if (who->isTargetableForAttack())
         {
             if (m_creature->Attack(who, false))
@@ -522,85 +613,111 @@ struct TRINITY_DLL_DECL boss_gazakrothAI : public boss_hexlord_addAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (firebolt_timer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(),SPELL_FIREBOLT, false);
             firebolt_timer = 700;
         }else firebolt_timer -= diff;
+
         boss_hexlord_addAI::UpdateAI(diff);
     }
 };
+
 #define SPELL_FLAME_BREATH    43582
 #define SPELL_THUNDERCLAP     43583
+
 struct TRINITY_DLL_DECL boss_lord_raadanAI : public boss_hexlord_addAI
 {
     boss_lord_raadanAI(Creature *c) : boss_hexlord_addAI(c)  {}
+
     uint32 flamebreath_timer;
     uint32 thunderclap_timer;
+
     void Reset()
     {
         flamebreath_timer = 8000;
         thunderclap_timer = 13000;
+
         boss_hexlord_addAI::Reset();
+
     }
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (thunderclap_timer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(),SPELL_THUNDERCLAP, false);
             thunderclap_timer = 12000;
         }else thunderclap_timer -= diff;
+
         if (flamebreath_timer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(),SPELL_FLAME_BREATH, false);
             flamebreath_timer = 12000;
         }else flamebreath_timer -= diff;
+
         boss_hexlord_addAI::UpdateAI(diff);
     }
 };
+
 #define SPELL_PSYCHIC_WAIL   43590
+
 struct TRINITY_DLL_DECL boss_darkheartAI : public boss_hexlord_addAI
 {
     boss_darkheartAI(Creature *c) : boss_hexlord_addAI(c)  {}
+
     uint32 psychicwail_timer;
+
     void Reset()
     {
         psychicwail_timer = 8000;
+
         boss_hexlord_addAI::Reset();
+
     }
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (psychicwail_timer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(),SPELL_PSYCHIC_WAIL, false);
             psychicwail_timer = 12000;
         }else psychicwail_timer -= diff;
+
         boss_hexlord_addAI::UpdateAI(diff);
     }
 };
+
 #define SPELL_VENOM_SPIT    43579
+
 struct TRINITY_DLL_DECL boss_slitherAI : public boss_hexlord_addAI
 {
     boss_slitherAI(Creature *c) : boss_hexlord_addAI(c) {}
+
     uint32 venomspit_timer;
 
+
     void Reset()
     {
         venomspit_timer = 5000;
         boss_hexlord_addAI::Reset();
     }
+
     void AttackStart(Unit* who)
     {
         if (!who)
             return;
+
         if (who->isTargetableForAttack())
         {
             if (m_creature->Attack(who, false))
@@ -610,64 +727,80 @@ struct TRINITY_DLL_DECL boss_slitherAI : public boss_hexlord_addAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (venomspit_timer < diff)
         {
             if (Unit* victim = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 m_creature->CastSpell(victim,SPELL_VENOM_SPIT, false);
             venomspit_timer = 2500;
         }else venomspit_timer -= diff;
+
         boss_hexlord_addAI::UpdateAI(diff);
     }
 };
+
 //Fenstalker
 #define SPELL_VOLATILE_INFECTION 43586
+
 struct TRINITY_DLL_DECL boss_fenstalkerAI : public boss_hexlord_addAI
 {
     boss_fenstalkerAI(Creature *c) : boss_hexlord_addAI(c) {}
+
     uint32 volatileinf_timer;
 
+
     void Reset()
     {
         volatileinf_timer = 15000;
         boss_hexlord_addAI::Reset();
+
     }
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (volatileinf_timer < diff)
         {
             // core bug
             m_creature->getVictim()->CastSpell(m_creature->getVictim(),SPELL_VOLATILE_INFECTION, false);
             volatileinf_timer = 12000;
         }else volatileinf_timer -= diff;
+
         boss_hexlord_addAI::UpdateAI(diff);
     }
 };
+
 //Koragg
 #define SPELL_COLD_STARE      43593
 #define SPELL_MIGHTY_BLOW     43592
 
+
 struct TRINITY_DLL_DECL boss_koraggAI : public boss_hexlord_addAI
 {
     boss_koraggAI(Creature *c) : boss_hexlord_addAI(c) {}
+
     uint32 coldstare_timer;
     uint32 mightyblow_timer;
 
+
     void Reset()
     {
         coldstare_timer = 15000;
         mightyblow_timer = 10000;
         boss_hexlord_addAI::Reset();
+
     }
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (mightyblow_timer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(),SPELL_MIGHTY_BLOW, false);
@@ -679,41 +812,51 @@ struct TRINITY_DLL_DECL boss_koraggAI : public boss_hexlord_addAI
                 m_creature->CastSpell(victim,SPELL_COLD_STARE, false);
             coldstare_timer = 12000;
         }
+
         boss_hexlord_addAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_boss_hex_lord_malacrass(Creature* pCreature)
 {
     return new boss_hex_lord_malacrassAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_thurg(Creature* pCreature)
 {
     return new boss_thurgAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_alyson_antille(Creature* pCreature)
 {
     return new boss_alyson_antilleAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_gazakroth(Creature* pCreature)
 {
     return new boss_gazakrothAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_lord_raadan(Creature* pCreature)
 {
     return new boss_lord_raadanAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_darkheart(Creature* pCreature)
 {
     return new boss_darkheartAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_slither(Creature* pCreature)
 {
     return new boss_slitherAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_fenstalker(Creature* pCreature)
 {
     return new boss_fenstalkerAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_koragg(Creature* pCreature)
 {
     return new boss_koraggAI (pCreature);
@@ -725,34 +868,42 @@ void AddSC_boss_hex_lord_malacrass()
     newscript->Name = "boss_hexlord_malacrass";
     newscript->GetAI = &GetAI_boss_hex_lord_malacrass;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_thurg";
     newscript->GetAI = &GetAI_boss_thurg;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_gazakroth";
     newscript->GetAI = &GetAI_boss_gazakroth;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_lord_raadan";
     newscript->GetAI = &GetAI_boss_lord_raadan;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_darkheart";
     newscript->GetAI = &GetAI_boss_darkheart;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_slither";
     newscript->GetAI = &GetAI_boss_slither;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_fenstalker";
     newscript->GetAI = &GetAI_boss_fenstalker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_koragg";
     newscript->GetAI = &GetAI_boss_koragg;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_alyson_antille";
     newscript->GetAI = &GetAI_boss_alyson_antille;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_janalai.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_janalai.cpp
index b5ae692bc8f..d946b26ffdf 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_janalai.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_janalai.cpp
@@ -13,15 +13,18 @@
 * along with 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"
 #include "GridNotifiers.h"
+
 enum eEnums
 {
     SAY_AGGRO                   = -1568000,
@@ -34,6 +37,7 @@ enum eEnums
     SAY_DEATH                   = -1568007,
     SAY_EVENT_STRANGERS         = -1568008,
     SAY_EVENT_FRIENDS           = -1568009,
+
 // Jan'alai
     SPELL_FLAME_BREATH          = 43140,
     SPELL_FIRE_WALL             = 43113,
@@ -42,27 +46,34 @@ enum eEnums
     SPELL_TELE_TO_CENTER        = 43098, // coord
     SPELL_HATCH_ALL             = 43144,
     SPELL_BERSERK               = 45078,
+
 // -- Fire Bob Spells
     SPELL_FIRE_BOMB_CHANNEL     = 42621, // last forever
     SPELL_FIRE_BOMB_THROW       = 42628, // throw visual
     SPELL_FIRE_BOMB_DUMMY       = 42629, // bomb visual
     SPELL_FIRE_BOMB_DAMAGE      = 42630,
+
 // --Summons
     MOB_AMANI_HATCHER           = 23818,
     MOB_HATCHLING               = 23598,   // 42493
     MOB_EGG                     = 23817,
     MOB_FIRE_BOMB               = 23920,
+
 // -- Hatcher Spells
     SPELL_HATCH_EGG             = 43734,   // 42471
+
 // -- Hatchling Spells
     SPELL_FLAMEBUFFET           = 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},
@@ -70,6 +81,7 @@ float FireWallCoords[4][4] =
     {-54.80, 1150.08, 19, 0},
     {-33.93, 1175.68, 19, 1.5*3.1415}
 };
+
 float hatcherway[2][5][3] =
 {
     {
@@ -87,11 +99,13 @@ float hatcherway[2][5][3] =
         {-34.29,1095.22,19}
     }
 };
+
 struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
 {
     boss_janalaiAI(Creature *c) : ScriptedAI(c)
     {
         pInstance =c->GetInstanceData();
+
         SpellEntry *TempSpell = GET_SPELL(SPELL_HATCH_EGG);
         if (TempSpell && TempSpell->EffectImplicitTargetA[0] != 1)
         {
@@ -99,53 +113,70 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
             TempSpell->EffectImplicitTargetB[0] = 0;
         }
     }
+
     ScriptedInstance *pInstance;
+
     uint32 FireBreathTimer;
     uint32 BombTimer;
     uint32 BombSequenceTimer;
     uint32 BombCount;
     uint32 HatcherTimer;
     uint32 EnrageTimer;
+
     bool noeggs;
     bool enraged;
     bool isBombing;
+
     bool isFlameBreathing;
+
     uint64 FireBombGUIDs[40];
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_JANALAIEVENT, NOT_STARTED);
+
         FireBreathTimer = 8000;
         BombTimer = 30000;
         BombSequenceTimer = 1000;
         BombCount = 0;
         HatcherTimer = 10000;
         EnrageTimer = MINUTE*5*IN_MILISECONDS;
+
         noeggs = false;
         isBombing =false;
         enraged = false;
+
         isFlameBreathing = false;
-        for (uint8 i = 0; i < 40; ++i)
+
+        for(uint8 i = 0; i < 40; ++i)
             FireBombGUIDs[i] = 0;
+
         HatchAllEggs(1);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_JANALAIEVENT, DONE);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_JANALAIEVENT, IN_PROGRESS);
+
         DoScriptText(SAY_AGGRO, m_creature);
 //        DoZoneInCombat();
     }
+
     void DamageDeal(Unit* target, uint32 &damage)
     {
         if (isFlameBreathing)
@@ -154,17 +185,19 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
                 damage = 0;
         }
     }
+
     void FireWall()
     {
         uint8 WallNum;
         Creature* wall = NULL;
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (i == 0 || i == 2)
                 WallNum = 3;
             else
                 WallNum = 2;
-            for (uint8 j = 0; j < WallNum; j++)
+
+            for(uint8 j = 0; j < WallNum; j++)
             {
                 if (WallNum == 3)
                     wall = m_creature->SummonCreature(MOB_FIRE_BOMB, FireWallCoords[i][0],FireWallCoords[i][1]+5*(j-1),FireWallCoords[i][2],FireWallCoords[i][3],TEMPSUMMON_TIMED_DESPAWN,15000);
@@ -174,38 +207,47 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
             }
         }
     }
+
     void SpawnBombs()
     {
         float dx, dy;
-        for (int i(0); i < 40; ++i)
+        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, 15000);
             if (bomb) FireBombGUIDs[i] = bomb->GetGUID();
         }
         BombCount = 0;
     }
+
     bool HatchAllEggs(uint32 uiAction) //1: reset, 2: isHatching all
     {
         std::list templist;
         float x, y, z;
         m_creature->GetPosition(x, y, z);
+
         {
             CellPair pair(Trinity::ComputeCellPair(x, y));
             Cell cell(pair);
             cell.data.Part.reserved = ALL_DISTRICT;
             cell.SetNoCreate();
+
             Trinity::AllCreaturesOfEntryInRange check(m_creature, MOB_EGG, 100);
             Trinity::CreatureListSearcher searcher(m_creature, templist, check);
+
             TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher);
+
             CellLock cell_lock(cell, pair);
             cell_lock->Visit(cell_lock, cSearcher, *(m_creature->GetMap()));
         }
+
         //error_log("Eggs %d at middle", templist.size());
         if (!templist.size())
             return false;
-        for (std::list::iterator i = templist.begin(); i != templist.end(); ++i)
+
+        for(std::list::iterator i = templist.begin(); i != templist.end(); ++i)
         {
             if (uiAction == 1)
                (*i)->SetDisplayId(10056);
@@ -214,28 +256,34 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
         }
         return true;
     }
+
     void Boom()
     {
         std::list templist;
         float x, y, z;
         m_creature->GetPosition(x, y, z);
+
         {
             CellPair pair(Trinity::ComputeCellPair(x, y));
             Cell cell(pair);
             cell.data.Part.reserved = ALL_DISTRICT;
             cell.SetNoCreate();
+
             Trinity::AllCreaturesOfEntryInRange check(m_creature, MOB_FIRE_BOMB, 100);
             Trinity::CreatureListSearcher searcher(m_creature, templist, check);
+
             TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher);
+
             CellLock cell_lock(cell, pair);
             cell_lock->Visit(cell_lock, cSearcher, *(m_creature->GetMap()));
         }
-        for (std::list::iterator i = templist.begin(); i != templist.end(); ++i)
+        for(std::list::iterator i = templist.begin(); i != templist.end(); ++i)
         {
            (*i)->CastSpell(*i, SPELL_FIRE_BOMB_DAMAGE, true);
            (*i)->RemoveAllAuras();
         }
     }
+
     void HandleBombSequence()
     {
         if (BombCount < 40)
@@ -264,6 +312,7 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
                 EnrageTimer -= 10000;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (isFlameBreathing)
@@ -273,6 +322,7 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
                 isFlameBreathing = false;
             }else return;
         }
+
         if (isBombing)
         {
             if (BombSequenceTimer < diff)
@@ -281,11 +331,14 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
             }else BombSequenceTimer -= diff;
             return;
         }
+
         if (!UpdateVictim())
             return;
+
         //enrage if under 25% hp before 5 min.
         if (!enraged && m_creature->GetHealth() * 4 < m_creature->GetMaxHealth())
             EnrageTimer = 0;
+
         if (EnrageTimer < diff)
         {
             if (!enraged)
@@ -301,9 +354,11 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
                 EnrageTimer = 300000;
             }
         }else EnrageTimer -= diff;
+
         if (BombTimer < diff)
         {
             DoScriptText(SAY_FIRE_BOMBS, m_creature);
+
             m_creature->AttackStop();
             m_creature->GetMotionMaster()->Clear();
             DoTeleportTo(JanalainPos[0][0],JanalainPos[0][1],JanalainPos[0][2]);
@@ -311,15 +366,17 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
             m_creature->CastSpell(m_creature, SPELL_FIRE_BOMB_CHANNEL, false);
             //DoTeleportPlayer(m_creature, JanalainPos[0][0], JanalainPos[0][1],JanalainPos[0][2], 0);
             //m_creature->CastSpell(m_creature, SPELL_TELE_TO_CENTER, true);
+
             FireWall();
             SpawnBombs();
             isBombing = true;
             BombSequenceTimer = 100;
+
             //Teleport every Player into the middle
             Map* pMap = m_creature->GetMap();
             if (!pMap->IsDungeon()) return;
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
-            for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+            for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
             {
                 if (Player* i_pl = i->getSource())
                     if (i_pl->isAlive())
@@ -328,11 +385,13 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
             //m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far
             return;
         }else BombTimer -= diff;
+
         if (!noeggs)
         {
             if (100 * m_creature->GetHealth() < 35 * m_creature->GetMaxHealth())
             {
                 DoScriptText(SAY_ALL_EGGS, m_creature);
+
                 m_creature->AttackStop();
                 m_creature->GetMotionMaster()->Clear();
                 DoTeleportTo(JanalainPos[0][0],JanalainPos[0][1],JanalainPos[0][2]);
@@ -354,8 +413,11 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
                     noeggs = true;
             }else HatcherTimer -= diff;
         }
+
         EnterEvadeIfOutOfCombatArea(diff);
+
         DoMeleeAttackIfReady();
+
         if (FireBreathTimer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
@@ -370,41 +432,55 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
         }else FireBreathTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_janalaiAI(Creature* pCreature)
 {
     return new boss_janalaiAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_janalai_firebombAI : public ScriptedAI
 {
     mob_janalai_firebombAI(Creature *c) : ScriptedAI(c){}
+
     void Reset() {}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_FIRE_BOMB_THROW)
             m_creature->CastSpell(m_creature, SPELL_FIRE_BOMB_DUMMY, true);
     }
+
     void EnterCombat(Unit* who) {}
+
     void AttackStart(Unit* who) {}
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff) {}
 };
+
 CreatureAI* GetAI_mob_janalai_firebombAI(Creature* pCreature)
 {
     return new mob_janalai_firebombAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_amanishi_hatcherAI : public ScriptedAI
 {
     mob_amanishi_hatcherAI(Creature *c) : ScriptedAI(c)
     {
         pInstance =c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 waypoint;
     uint32 HatchNum;
     uint32 WaitTimer;
+
     bool side;
     bool hasChangedSide;
     bool isHatching;
+
     void Reset()
     {
         side =(m_creature->GetPositionY() < 1150);
@@ -414,24 +490,31 @@ struct TRINITY_DLL_DECL mob_amanishi_hatcherAI : public ScriptedAI
         WaitTimer = 1;
         HatchNum = 0;
     }
+
     bool HatchEggs(uint32 num)
     {
         std::list templist;
         float x, y, z;
         m_creature->GetPosition(x, y, z);
+
         {
             CellPair pair(Trinity::ComputeCellPair(x, y));
             Cell cell(pair);
             cell.data.Part.reserved = ALL_DISTRICT;
             cell.SetNoCreate();
+
             Trinity::AllCreaturesOfEntryInRange check(m_creature, 23817, 50);
             Trinity::CreatureListSearcher searcher(m_creature, templist, check);
+
             TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher);
+
             CellLock cell_lock(cell, pair);
             cell_lock->Visit(cell_lock, cSearcher, *(m_creature->GetMap()));
         }
+
         //error_log("Eggs %d at %d", templist.size(), side);
-        for (std::list::iterator i = templist.begin(); i != templist.end() && num > 0; ++i)
+
+        for(std::list::iterator i = templist.begin(); i != templist.end() && num > 0; ++i)
         {
             if ((*i)->GetDisplayId() != 11686)
             {
@@ -439,11 +522,13 @@ struct TRINITY_DLL_DECL mob_amanishi_hatcherAI : public ScriptedAI
                 num--;
             }
         }
+
         if (num)
             return false;   // no more templist
         else
             return true;
     }
+
     void EnterCombat(Unit* who) {}
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
@@ -458,6 +543,7 @@ struct TRINITY_DLL_DECL mob_amanishi_hatcherAI : public ScriptedAI
         else
             WaitTimer = 1;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!pInstance || !(pInstance->GetData(DATA_JANALAIEVENT) == IN_PROGRESS))
@@ -466,6 +552,7 @@ struct TRINITY_DLL_DECL mob_amanishi_hatcherAI : public ScriptedAI
             m_creature->setDeathState(JUST_DIED);
             return;
         }
+
         if (!isHatching)
         {
             if (WaitTimer)
@@ -502,18 +589,22 @@ struct TRINITY_DLL_DECL mob_amanishi_hatcherAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_mob_amanishi_hatcherAI(Creature* pCreature)
 {
     return new mob_amanishi_hatcherAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_hatchlingAI : public ScriptedAI
 {
     mob_hatchlingAI(Creature *c) : ScriptedAI(c)
     {
         pInstance =c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
     uint32 BuffetTimer;
+
     void Reset()
     {
         BuffetTimer = 7000;
@@ -521,9 +612,12 @@ struct TRINITY_DLL_DECL mob_hatchlingAI : public ScriptedAI
             m_creature->GetMotionMaster()->MovePoint(0, hatcherway[0][3][0]+rand()%4-2,1150+rand()%4-2,hatcherway[0][3][2]);
         else
             m_creature->GetMotionMaster()->MovePoint(0,hatcherway[1][3][0]+rand()%4-2,1150+rand()%4-2,hatcherway[1][3][2]);
+
         m_creature->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
     }
+
     void EnterCombat(Unit *who) {/*DoZoneInCombat();*/}
+
     void UpdateAI(const uint32 diff)
     {
         if (!pInstance || !(pInstance->GetData(DATA_JANALAIEVENT) == IN_PROGRESS))
@@ -532,20 +626,25 @@ struct TRINITY_DLL_DECL mob_hatchlingAI : public ScriptedAI
             m_creature->setDeathState(JUST_DIED);
             return;
         }
+
         if (!UpdateVictim())
             return;
+
         if (BuffetTimer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(), SPELL_FLAMEBUFFET, false);
             BuffetTimer = 10000;
         }else BuffetTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_hatchlingAI(Creature* pCreature)
 {
     return new mob_hatchlingAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_eggAI : public ScriptedAI
 {
     mob_eggAI(Creature *c) : ScriptedAI(c){}
@@ -554,6 +653,7 @@ struct TRINITY_DLL_DECL mob_eggAI : public ScriptedAI
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
     void UpdateAI(const uint32 diff) {}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_HATCH_EGG)
@@ -563,10 +663,12 @@ struct TRINITY_DLL_DECL mob_eggAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_mob_eggAI(Creature* pCreature)
 {
     return new mob_eggAI(pCreature);
 }
+
 void AddSC_boss_janalai()
 {
     Script *newscript;
@@ -574,18 +676,22 @@ void AddSC_boss_janalai()
     newscript->Name = "boss_janalai";
     newscript->GetAI = &GetAI_boss_janalaiAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_janalai_firebomb";
     newscript->GetAI = &GetAI_mob_janalai_firebombAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_janalai_hatcher";
     newscript->GetAI = &GetAI_mob_amanishi_hatcherAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_janalai_hatchling";
     newscript->GetAI = &GetAI_mob_hatchlingAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_janalai_egg";
     newscript->GetAI = &GetAI_mob_eggAI;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_nalorakk.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_nalorakk.cpp
index 4c1566b6c51..c15df162430 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_nalorakk.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_nalorakk.cpp
@@ -13,15 +13,18 @@
 * along with 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: 100
 SDComment:
 SDCategory: Zul'Aman
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_zulaman.h"
 #include "GridNotifiers.h"
+
 //Trash Waves
 float NalorakkWay[8][3] =
 {
@@ -34,6 +37,7 @@ float NalorakkWay[8][3] =
     {-80.072, 1314.398, 40.87},
     {-80.072, 1295.775, 48.60} // waypoint 4
 };
+
 #define YELL_NALORAKK_WAVE1     "Get da move on, guards! It be killin' time!"
 #define SOUND_NALORAKK_WAVE1    12066
 #define YELL_NALORAKK_WAVE2     "Guards, go already! Who you more afraid of, dem... or me?"
@@ -42,11 +46,13 @@ float NalorakkWay[8][3] =
 #define SOUND_NALORAKK_WAVE3    12068
 #define YELL_NALORAKK_WAVE4     "I be losin' me patience! Go on: make dem wish dey was never born!"
 #define SOUND_NALORAKK_WAVE4    12069
+
 //Unimplemented SoundIDs
 /*
 #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
@@ -58,24 +64,31 @@ float NalorakkWay[8][3] =
 #define SOUND_YELL_DEATH        12077
 #define YELL_BERSERK            "You had your chance, now it be too late!" //Never seen this being used, so just guessing from what I hear.
 #define SOUND_YELL_BERSERK      12074
+
 #define SPELL_BERSERK           45078
+
 //Defines for Troll form
 #define SPELL_BRUTALSWIPE       42384
 #define SPELL_MANGLE            42389
 #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 TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
 {
     boss_nalorakkAI(Creature *c) : ScriptedAI(c)
@@ -84,20 +97,26 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
         MovePhase = 0;
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 BrutalSwipe_Timer;
     uint32 Mangle_Timer;
     uint32 Surge_Timer;
+
     uint32 LaceratingSlash_Timer;
     uint32 RendFlesh_Timer;
     uint32 DeafeningRoar_Timer;
+
     uint32 ShapeShift_Timer;
     uint32 Berserk_Timer;
+
     bool inBearForm;
     bool MoveEvent;
     bool inMove;
     uint32 MovePhase;
     uint32 waitTimer;
+
     void Reset()
     {
         if (MoveEvent)
@@ -112,35 +131,45 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
         {
             (*m_creature).GetMotionMaster()->MovePoint(0,NalorakkWay[7][0],NalorakkWay[7][1],NalorakkWay[7][2]);
         }
+
         if (pInstance)
             pInstance->SetData(DATA_NALORAKKEVENT, NOT_STARTED);
+
         Surge_Timer = 15000 + rand()%5000;
         BrutalSwipe_Timer = 7000 + rand()%5000;
         Mangle_Timer = 10000 + rand()%5000;
         ShapeShift_Timer = 45000 + rand()%5000;
         Berserk_Timer = 600000;
+
         inBearForm = false;
         m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, 5122);
     }
+
     void SendAttacker(Unit* target)
     {
         std::list templist;
         float x, y, z;
         m_creature->GetPosition(x, y, z);
+
         {
             CellPair pair(Trinity::ComputeCellPair(x, y));
             Cell cell(pair);
             cell.data.Part.reserved = ALL_DISTRICT;
             cell.SetNoCreate();
+
             Trinity::AllFriendlyCreaturesInGrid check(m_creature);
             Trinity::CreatureListSearcher searcher(m_creature, templist, check);
+
             TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher);
+
             CellLock cell_lock(cell, pair);
             cell_lock->Visit(cell_lock, cSearcher, *(m_creature->GetMap()));
         }
+
         if (!templist.size())
             return;
-        for (std::list::iterator i = templist.begin(); i != templist.end(); ++i)
+
+        for(std::list::iterator i = templist.begin(); i != templist.end(); ++i)
         {
             if ((*i) && m_creature->IsWithinDistInMap((*i),25))
             {
@@ -149,11 +178,13 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
             }
         }
     }
+
     void AttackStart(Unit* who)
     {
         if (!MoveEvent)
             ScriptedAI::AttackStart(who);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!MoveEvent)
@@ -173,9 +204,11 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                             {
                                 m_creature->MonsterYell(YELL_NALORAKK_WAVE1, LANG_UNIVERSAL, NULL);
                                 DoPlaySoundToSet(m_creature, SOUND_NALORAKK_WAVE1);
+
                                 (*m_creature).GetMotionMaster()->MovePoint(1,NalorakkWay[1][0],NalorakkWay[1][1],NalorakkWay[1][2]);
                                 MovePhase ++;
                                 inMove = true;
+
                                 SendAttacker(who);
                             }
                             break;
@@ -184,9 +217,11 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                             {
                                 m_creature->MonsterYell(YELL_NALORAKK_WAVE2, LANG_UNIVERSAL, NULL);
                                 DoPlaySoundToSet(m_creature, SOUND_NALORAKK_WAVE2);
+
                                 (*m_creature).GetMotionMaster()->MovePoint(3,NalorakkWay[3][0],NalorakkWay[3][1],NalorakkWay[3][2]);
                                 MovePhase ++;
                                 inMove = true;
+
                                 SendAttacker(who);
                             }
                             break;
@@ -195,9 +230,11 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                             {
                                 m_creature->MonsterYell(YELL_NALORAKK_WAVE3, LANG_UNIVERSAL, NULL);
                                 DoPlaySoundToSet(m_creature, SOUND_NALORAKK_WAVE3);
+
                                 (*m_creature).GetMotionMaster()->MovePoint(6,NalorakkWay[6][0],NalorakkWay[6][1],NalorakkWay[6][2]);
                                 MovePhase ++;
                                 inMove = true;
+
                                 SendAttacker(who);
                             }
                             break;
@@ -205,10 +242,13 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                             if (m_creature->IsWithinDistInMap(who, 50))
                             {
                                 SendAttacker(who);
+
                                 m_creature->MonsterYell(YELL_NALORAKK_WAVE4, LANG_UNIVERSAL, NULL);
                                 DoPlaySoundToSet(m_creature, SOUND_NALORAKK_WAVE4);
+
                                 m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                 m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
                                 MoveEvent = false;
                             }
                             break;
@@ -217,21 +257,26 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
             }
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_NALORAKKEVENT, IN_PROGRESS);
+
         m_creature->MonsterYell(YELL_AGGRO, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_YELL_AGGRO);
         DoZoneInCombat();
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_NALORAKKEVENT, DONE);
+
         m_creature->MonsterYell(YELL_DEATH,LANG_UNIVERSAL,NULL);
         DoPlaySoundToSet(m_creature, SOUND_YELL_DEATH);
     }
+
     void KilledUnit(Unit* victim)
     {
         switch(rand()%2)
@@ -246,16 +291,20 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
             break;
         }
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (MoveEvent)
         {
             if (type != POINT_MOTION_TYPE)
                 return;
+
             if (!inMove)
                 return;
+
             if (MovePhase != id)
                 return;
+
             switch(MovePhase)
             {
                 case 2:
@@ -279,8 +328,10 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                     inMove = false;
                     return;
             }
+
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (waitTimer)
@@ -293,8 +344,10 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                     waitTimer = 0;
                 }else waitTimer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         if (Berserk_Timer < diff)
         {
             DoCast(m_creature, SPELL_BERSERK, true);
@@ -302,6 +355,7 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
             DoPlaySoundToSet(m_creature, SOUND_YELL_BERSERK);
             Berserk_Timer = 600000;
         }else Berserk_Timer -= diff;
+
         if (ShapeShift_Timer < diff)
         {
             if (inBearForm)
@@ -329,6 +383,7 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                 inBearForm = true;
             }
         }else ShapeShift_Timer -= diff;
+
         if (!inBearForm)
         {
             if (BrutalSwipe_Timer < diff)
@@ -336,6 +391,7 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                 DoCast(m_creature->getVictim(), SPELL_BRUTALSWIPE);
                 BrutalSwipe_Timer = 7000 + rand()%5000;
             }else BrutalSwipe_Timer -= diff;
+
             if (Mangle_Timer < diff)
             {
                 if (m_creature->getVictim() && !m_creature->getVictim()->HasAura(SPELL_MANGLEEFFECT))
@@ -345,6 +401,7 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                 }
                 else Mangle_Timer = 10000 + rand()%5000;
             }else Mangle_Timer -= diff;
+
             if (Surge_Timer < diff)
             {
                 m_creature->MonsterYell(YELL_SURGE, LANG_UNIVERSAL, NULL);
@@ -362,24 +419,29 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
                 DoCast(m_creature->getVictim(), SPELL_LACERATINGSLASH);
                 LaceratingSlash_Timer = 18000 + rand()%5000;
             }else LaceratingSlash_Timer -= diff;
+
             if (RendFlesh_Timer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_RENDFLESH);
                 RendFlesh_Timer = 5000 + rand()%5000;
             }else RendFlesh_Timer -= diff;
+
             if (DeafeningRoar_Timer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_DEAFENINGROAR);
                 DeafeningRoar_Timer = 15000 + rand()%5000;
             }else DeafeningRoar_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_nalorakk(Creature* pCreature)
 {
     return new boss_nalorakkAI (pCreature);
 }
+
 void AddSC_boss_nalorakk()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_zuljin.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_zuljin.cpp
index 1ce3feacdb6..a8df5202e64 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_zuljin.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/boss_zuljin.cpp
@@ -13,37 +13,51 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: Boss_ZulJin
 SD%Complete: 85%
 SDComment:
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_zulaman.h"
+
 //Speech
 #define YELL_TRANSFORM_TO_LYNX "Let me introduce to you my new bruddahs: fang and claw!"
 #define SOUND_TRANSFORM_TO_LYNX 12094
+
 #define YELL_TRANSFORM_TO_BEAR "Got me some new tricks...like me bruddah bear!"
 #define SOUND_TRANSFORM_TO_BEAR 12092
+
 #define YELL_TRANSFORM_TO_DRAGONHAWK "Ya don' have to look to da sky to see da dragonhawk!"
 #define SOUND_TRANSFORM_TO_DRAGONHAWK 12095
+
 #define YELL_TRANSFORM_TO_EAGLE "Dere be no hidin' from da eagle!"
 #define SOUND_TRANSFORM_TO_EAGLE 12093
+
 #define YELL_KILL_ONE "Da Amani de chuka!"
 #define SOUND_KILL_ONE 12098
+
 #define YELL_KILL_TWO "Lot more gonna fall like you!"
 #define SOUND_KILL_TWO 12099
+
 #define YELL_FIRE_BREATH "Fire kill you just as quick!"
 #define SOUND_FIRE_BRETH 12096
+
 #define YELL_AGGRO "Nobody badduh dan me!"
 #define SOUND_AGGRO 12091
+
 #define YELL_BERSERK "You too slow! Me too strong!"
 #define SOUND_BERSERK 12097
+
 #define YELL_DEATH "Mebbe me fall...but da Amani empire...never gonna die..."
 #define SOUND_DEATH 12100
+
 //Still not used, need more info
 #define YELL_INTRO "Everybody always wanna take from us. Now we gonna start takin' back. Anybody who get in our way...gonna drown in their own blood! De Amani empire be back now...seekin' vengeance. And we gonna start...with you!"
 #define SOUND_INTRO 12090
+
 //Spells:
 // ====== Troll Form
 #define SPELL_WHIRLWIND             17207
@@ -71,30 +85,37 @@ EndScriptData */
 #define SPELL_SUMMON_PILLAR         43216   // summon 24187
 #define CREATURE_COLUMN_OF_FIRE     24187
 #define SPELL_PILLAR_TRIGGER        43218   // trigger 43217
+
 //cosmetic
 #define SPELL_SPIRIT_AURA           42466
 #define SPELL_SIPHON_SOUL           43501
+
 //Transforms:
 #define SPELL_SHAPE_OF_THE_BEAR     42594   // 15% dmg
 #define SPELL_SHAPE_OF_THE_EAGLE    42606
 #define SPELL_SHAPE_OF_THE_LYNX     42607   // haste melee 30%
 #define SPELL_SHAPE_OF_THE_DRAGONHAWK   42608
+
 #define SPELL_BERSERK 45078
 
+
 #define PHASE_BEAR 0
 #define PHASE_EAGLE 1
 #define PHASE_LYNX 2
 #define PHASE_DRAGONHAWK 3
 #define PHASE_TROLL 4
+
 //coords for going for changing form
 #define CENTER_X 120.148811
 #define CENTER_Y 703.713684
 #define CENTER_Z 45.111477
+
 struct SpiritInfoStruct
 {
     uint32 entry;
     float x, y, z, orient;
 };
+
 static SpiritInfoStruct SpiritInfo[] =
 {
     {23878, 147.87, 706.51, 45.11, 3.04},
@@ -102,12 +123,14 @@ static SpiritInfoStruct SpiritInfo[] =
     {23877, 137.23, 725.98, 45.11, 3.71},
     {23879, 104.29, 726.43, 45.11, 5.43}
 };
+
 struct TransformStruct
 {
     uint32 sound;
     char* text;
     uint32 spell, unaura;
 };
+
 static TransformStruct Transform[] =
 {
     {SOUND_TRANSFORM_TO_BEAR, YELL_TRANSFORM_TO_BEAR, SPELL_SHAPE_OF_THE_BEAR, SPELL_WHIRLWIND},
@@ -115,6 +138,7 @@ static TransformStruct Transform[] =
     {SOUND_TRANSFORM_TO_LYNX, YELL_TRANSFORM_TO_LYNX, SPELL_SHAPE_OF_THE_LYNX, SPELL_SHAPE_OF_THE_EAGLE},
     {SOUND_TRANSFORM_TO_DRAGONHAWK, YELL_TRANSFORM_TO_DRAGONHAWK, SPELL_SHAPE_OF_THE_DRAGONHAWK, SPELL_SHAPE_OF_THE_LYNX}
 };
+
 struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
 {
     boss_zuljinAI(Creature *c) : ScriptedAI(c), Summons(m_creature)
@@ -122,65 +146,89 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
         pInstance = c->GetInstanceData();
     }
     ScriptedInstance *pInstance;
+
     uint64 SpiritGUID[4];
     uint64 ClawTargetGUID;
     uint64 TankGUID;
+
     uint32 Phase;
     uint32 health_20;
+
     uint32 Intro_Timer;
     uint32 Berserk_Timer;
+
     uint32 Whirlwind_Timer;
     uint32 Grievous_Throw_Timer;
+
     uint32 Creeping_Paralysis_Timer;
     uint32 Overpower_Timer;
+
     uint32 Claw_Rage_Timer;
     uint32 Lynx_Rush_Timer;
     uint32 Claw_Counter;
     uint32 Claw_Loop_Timer;
+
     uint32 Flame_Whirl_Timer;
     uint32 Flame_Breath_Timer;
     uint32 Pillar_Of_Fire_Timer;
+
     SummonList Summons;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_ZULJINEVENT, NOT_STARTED);
+
         Phase = 0;
+
         health_20 = m_creature->GetMaxHealth()*0.2;
+
         Intro_Timer = 37000;
         Berserk_Timer = 600000;
+
         Whirlwind_Timer = 7000;
         Grievous_Throw_Timer = 8000;
+
         Creeping_Paralysis_Timer = 7000;
         Overpower_Timer = 0;
+
         Claw_Rage_Timer = 5000;
         Lynx_Rush_Timer = 14000;
         Claw_Loop_Timer = 0;
         Claw_Counter = 0;
+
         Flame_Whirl_Timer = 5000;
         Flame_Breath_Timer = 6000;
         Pillar_Of_Fire_Timer = 7000;
+
         ClawTargetGUID = 0;
         TankGUID = 0;
+
         Summons.DespawnAll();
+
         m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 47174);
         //m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 218172674);
         //m_creature->SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_ZULJINEVENT, IN_PROGRESS);
+
         DoZoneInCombat();
+
         m_creature->MonsterYell(YELL_INTRO,LANG_UNIVERSAL,NULL);
         DoPlaySoundToSet(m_creature, SOUND_INTRO);
         SpawnAdds();
         EnterPhase(0);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (Intro_Timer)
             return;
+
         switch(rand()%2)
         {
         case 0:
@@ -193,16 +241,20 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
             break;
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_ZULJINEVENT, DONE);
+
         m_creature->MonsterYell(YELL_DEATH, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_DEATH);
         Summons.DespawnEntry(CREATURE_COLUMN_OF_FIRE);
+
         if (Unit *Temp = Unit::GetUnit(*m_creature, SpiritGUID[3]))
             Temp->SetUInt32Value(UNIT_FIELD_BYTES_1,UNIT_STAND_STATE_DEAD);
     }
+
     void AttackStart(Unit *who)
     {
         if (Phase == 2)
@@ -210,6 +262,7 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
         else
             ScriptedAI::AttackStart(who);
     }
+
     void DoMeleeAttackIfReady()
     {
         if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -230,10 +283,11 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
             }
         }
     }
+
     void SpawnAdds()
     {
         Creature *pCreature = NULL;
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             pCreature = m_creature->SummonCreature(SpiritInfo[i].entry, SpiritInfo[i].x, SpiritInfo[i].y, SpiritInfo[i].z, SpiritInfo[i].orient, TEMPSUMMON_DEAD_DESPAWN, 0);
             if (pCreature)
@@ -245,9 +299,10 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
             }
         }
     }
+
     void DespawnAdds()
     {
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             Unit* Temp = NULL;
             if (SpiritGUID[i])
@@ -261,14 +316,17 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
             SpiritGUID[i] = 0;
         }
     }
+
     void JustSummoned(Creature *summon)
     {
         Summons.Summon(summon);
     }
+
     void SummonedCreatureDespawn(Creature *summon)
     {
         Summons.Despawn(summon);
     }
+
     void EnterPhase(uint32 NextPhase)
     {
         switch(NextPhase)
@@ -297,7 +355,7 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
             {
                 m_creature->GetMotionMaster()->Clear();
                 m_creature->CastSpell(m_creature, SPELL_ENERGY_STORM, true); // enemy aura
-                for (uint8 i = 0; i < 4; ++i)
+                for(uint8 i = 0; i < 4; ++i)
                 {
                     Creature* Vortex = DoSpawnCreature(CREATURE_FEATHER_VORTEX, 0, 0, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                     if (Vortex)
@@ -325,15 +383,18 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
         }
         Phase = NextPhase;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!TankGUID)
         {
             if (!UpdateVictim())
                 return;
+
             if (m_creature->GetHealth() < health_20 * (4 - Phase))
                 EnterPhase(Phase + 1);
         }
+
         if (Berserk_Timer < diff)
         {
             m_creature->CastSpell(m_creature, SPELL_BERSERK, true);
@@ -341,6 +402,7 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
             DoPlaySoundToSet(m_creature, SOUND_BERSERK);
             Berserk_Timer = 60000;
         }else Berserk_Timer -= diff;
+
         switch (Phase)
         {
         case 0:
@@ -353,11 +415,13 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
                     Intro_Timer = 0;
                 }else Intro_Timer -= diff;
             }
+
             if (Whirlwind_Timer < diff)
             {
                 DoCast(m_creature, SPELL_WHIRLWIND);
                 Whirlwind_Timer = 15000 + rand()%5000;
             }else Whirlwind_Timer -= diff;
+
             if (Grievous_Throw_Timer < diff)
             {
                 if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -365,20 +429,24 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
                 Grievous_Throw_Timer = 10000;
             }else Grievous_Throw_Timer -= diff;
             break;
+
         case 1:
             if (Creeping_Paralysis_Timer < diff)
             {
                 DoCast(m_creature, SPELL_CREEPING_PARALYSIS);
                 Creeping_Paralysis_Timer = 20000;
             }else Creeping_Paralysis_Timer -= diff;
+
             if (Overpower_Timer < diff)
             {
                 // implemented in DoMeleeAttackIfReady()
                 Overpower_Timer = 0;
             }else Overpower_Timer -= diff;
             break;
+
         case 2:
             return;
+
         case 3:
             if (Claw_Rage_Timer <= diff)
             {
@@ -428,6 +496,7 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
                     }else Claw_Loop_Timer -= diff;
                 } //if (TankGUID)
             }else Claw_Rage_Timer -= diff;
+
             if (Lynx_Rush_Timer <= diff)
             {
                 if (!TankGUID)
@@ -473,6 +542,7 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
                     }
                 } //if (TankGUID)
             }else Lynx_Rush_Timer -= diff;
+
             break;
         case 4:
             if (Flame_Whirl_Timer < diff)
@@ -480,12 +550,14 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
                 DoCast(m_creature, SPELL_FLAME_WHIRL);
                 Flame_Whirl_Timer = 12000;
             }Flame_Whirl_Timer -= diff;
+
             if (Pillar_Of_Fire_Timer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                     DoCast(target, SPELL_SUMMON_PILLAR);
                 Pillar_Of_Fire_Timer = 10000;
             }else Pillar_Of_Fire_Timer -= diff;
+
             if (Flame_Breath_Timer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -494,27 +566,35 @@ struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI
                 Flame_Breath_Timer = 10000;
             }else Flame_Breath_Timer -= diff;
             break;
+
         default:
             break;
         }
+
         if (!TankGUID)
             DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_zuljin(Creature* pCreature)
 {
     return new boss_zuljinAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL feather_vortexAI : public ScriptedAI
 {
     feather_vortexAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
+
     void EnterCombat(Unit* target) {}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_ZAP_INFORM)
             m_creature->CastSpell(caster, SPELL_ZAP_DAMAGE, true);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //if the vortex reach the target, it change his target to another player
@@ -522,10 +602,12 @@ struct TRINITY_DLL_DECL feather_vortexAI : public ScriptedAI
             AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0));
     }
 };
+
 CreatureAI* GetAI_feather_vortexAI(Creature* pCreature)
 {
     return new feather_vortexAI (pCreature);
 }
+
 void AddSC_boss_zuljin()
 {
     Script *newscript;
@@ -533,6 +615,7 @@ void AddSC_boss_zuljin()
     newscript->Name = "boss_zuljin";
     newscript->GetAI = &GetAI_boss_zuljin;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_zuljin_vortex";
     newscript->GetAI = &GetAI_feather_vortexAI;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/def_zulaman.h b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/def_zulaman.h
index 082616146c6..6fb0ef173bd 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/def_zulaman.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/def_zulaman.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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_NALORAKKEVENT  1
 #define DATA_AKILZONEVENT   2
 #define DATA_JANALAIEVENT   3
@@ -12,5 +14,6 @@
 #define DATA_CHESTLOOTED    7
 #define TYPE_RAND_VENDOR_1  8
 #define TYPE_RAND_VENDOR_2  9
+
 #endif
 
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/instance_zulaman.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/instance_zulaman.cpp
index 327bda17592..74186442d9e 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/instance_zulaman.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/instance_zulaman.cpp
@@ -13,16 +13,20 @@
 * along 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 MAX_ENCOUNTER     6
 #define RAND_VENDOR    2
+
 //187021 //Harkor's Satchel
 //186648 //Tanzar's Trunk
 //186672 //Ashli's Bag
@@ -35,56 +39,71 @@ struct SHostageInfo
     uint32 npc, pGo;
     float x, y, z, o;
 };
+
 static SHostageInfo HostageInfo[] =
 {
     {23790, 186648, -57, 1343, 40.77, 3.2}, // bear
     {23999, 187021, 400, 1414, 74.36, 3.3}, // eagle
     {24001, 186672, -35, 1134, 18.71, 1.9}, // dragonhawk
     {24024, 186667, 413, 1117,  6.32, 3.1}  // lynx
+
 };
+
 struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
 {
     instance_zulaman(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 HarkorsSatchelGUID;
     uint64 TanzarsTrunkGUID;
     uint64 AshlisBagGUID;
     uint64 KrazsPackageGUID;
+
     uint64 HexLordGateGUID;
     uint64 ZulJinGateGUID;
     uint64 AkilzonDoorGUID;
     uint64 ZulJinDoorGUID;
     uint64 HalazziDoorGUID;
+
     uint32 QuestTimer;
     uint16 BossKilled;
     uint16 QuestMinute;
     uint16 ChestLooted;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     uint32 RandVendor[RAND_VENDOR];
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         HarkorsSatchelGUID = 0;
         TanzarsTrunkGUID = 0;
         AshlisBagGUID = 0;
         KrazsPackageGUID = 0;
+
         uint64 HexLordGateGUID = 0;
         uint64 ZulJinGateGUID = 0;
         uint64 AkilzonDoorGUID = 0;
         uint64 HalazziDoorGUID = 0;
         uint64 ZulJinDoorGUID = 0;
+
         QuestTimer = 0;
         QuestMinute = 21;
         BossKilled = 0;
         ChestLooted = 0;
-        for (uint8 i = 0; i < RAND_VENDOR; ++i)
+
+        for(uint8 i = 0; i < RAND_VENDOR; ++i)
             RandVendor[i] = NOT_STARTED;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -97,6 +116,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
         default: break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -106,21 +126,26 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
         case 186305: HexLordGateGUID = pGo->GetGUID(); break;
         case 186858: AkilzonDoorGUID = pGo->GetGUID(); break;
         case 186859: ZulJinDoorGUID  = pGo->GetGUID(); break;
+
         case 187021: HarkorsSatchelGUID  = pGo->GetGUID(); break;
         case 186648: TanzarsTrunkGUID = pGo->GetGUID(); break;
         case 186672: AshlisBagGUID = pGo->GetGUID(); break;
         case 186667: KrazsPackageGUID  = pGo->GetGUID(); break;
         default: break;
+
         }
         CheckInstanceStatus();
     }
+
     void SummonHostage(uint8 num)
     {
         if (!QuestMinute)
             return;
+
         Map::PlayerList const &PlayerList = instance->GetPlayers();
         if (PlayerList.isEmpty())
             return;
+
         Map::PlayerList::const_iterator i = PlayerList.begin();
         if (Player* i_pl = i->getSource())
         {
@@ -131,13 +156,16 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
             }
         }
     }
+
     void CheckInstanceStatus()
     {
         if (BossKilled >= 4)
             HandleGameObject(HexLordGateGUID, true);
+
         if (BossKilled >= 5)
             HandleGameObject(ZulJinGateGUID, true);
     }
+
     std::string GetSaveData()
     {
         std::ostringstream ss;
@@ -147,6 +175,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
         //error_log("TSCR: Zul'aman saved, %s.", data);
         return data;
     }
+
     void Load(const char* load)
     {
         if (!load) return;
@@ -163,6 +192,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
             QuestMinute = data3;
         }else error_log("TSCR: Zul'aman: corrupted save data.");
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -223,6 +253,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
             RandVendor[1] = data;
             break;
         }
+
         if (data == DONE)
         {
             BossKilled++;
@@ -235,6 +266,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
             SaveToDB();
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -251,6 +283,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
         default:                 return 0;
         }
     }
+
     void Update(uint32 diff)
     {
         if (QuestMinute)
@@ -270,10 +303,12 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
         }
     }
 };
+
 InstanceData* GetInstanceData_instance_zulaman(Map* pMap)
 {
     return new instance_zulaman(pMap);
 }
+
 void AddSC_instance_zulaman()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/zulaman.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/zulaman.cpp
index 57ab45ac944..e3142e50540 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/zulaman.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulaman/zulaman.cpp
@@ -13,32 +13,42 @@
 * along 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 TRINITY_DLL_DECL npc_forest_frogAI : public ScriptedAI
 {
     npc_forest_frogAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     void Reset() { }
+
     void EnterCombat(Unit *who) { }
+
     void DoSpawnRandom()
     {
         if (pInstance)
@@ -58,15 +68,19 @@ struct TRINITY_DLL_DECL npc_forest_frogAI : public ScriptedAI
                 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)
@@ -81,12 +95,16 @@ CreatureAI* GetAI_npc_forest_frog(Creature* pCreature)
 {
     return new npc_forest_frogAI (pCreature);
 }
+
 /*######
 ## npc_zulaman_hostage
 ######*/
+
 #define GOSSIP_HOSTAGE1        "I am glad to help you."
+
 static uint32 HostageEntry[] = {23790, 23999, 24024, 24001};
 static uint32 ChestEntry[] = {186648, 187021, 186672, 186667};
+
 struct TRINITY_DLL_DECL npc_zulaman_hostageAI : public ScriptedAI
 {
     npc_zulaman_hostageAI(Creature *c) : ScriptedAI(c) {IsLoot = false;}
@@ -104,19 +122,23 @@ struct TRINITY_DLL_DECL npc_zulaman_hostageAI : public ScriptedAI
         if (IsLoot) m_creature->CastSpell(m_creature, 7, false);
     }
 };
+
 bool GossipHello_npc_zulaman_hostage(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HOSTAGE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_zulaman_hostage(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
         pPlayer->CLOSE_GOSSIP_MENU();
+
     if (!pCreature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP))
         return true;
     pCreature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
     if (pInstance)
     {
@@ -125,7 +147,7 @@ bool GossipSelect_npc_zulaman_hostage(Player* pPlayer, Creature* pCreature, uint
         float x, y, z;
         pCreature->GetPosition(x, y, z);
         uint32 entry = pCreature->GetEntry();
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (HostageEntry[i] == entry)
             {
@@ -145,17 +167,21 @@ bool GossipSelect_npc_zulaman_hostage(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_zulaman_hostage(Creature* pCreature)
 {
     return new npc_zulaman_hostageAI(pCreature);
 }
+
 void AddSC_zulaman()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_forest_frog";
     newscript->GetAI = &GetAI_npc_forest_frog;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_zulaman_hostage";
     newscript->GetAI = &GetAI_npc_zulaman_hostage;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_arlokk.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_arlokk.cpp
index 4d5af424a2d..5244e5d3538 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_arlokk.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_arlokk.cpp
@@ -13,57 +13,73 @@
  * along with 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"
+
 bool GOHello_go_gong_of_bethekk(Player* pPlayer, GameObject* pGo)
 {
     if (ScriptedInstance* m_pInstance = pGo->GetInstanceData())
     {
         if (m_pInstance->GetData(TYPE_ARLOKK) == DONE || m_pInstance->GetData(TYPE_ARLOKK) == IN_PROGRESS)
             return true;
+
         m_pInstance->SetData(TYPE_ARLOKK, IN_PROGRESS);
     }
+
     return false;
 }
+
 enum eEnums
 {
     SAY_AGGRO                   = -1309011,
     SAY_FEAST_PANTHER           = -1309012,
     SAY_DEATH                   = -1309013,
+
     SPELL_SHADOWWORDPAIN        = 23952,
     SPELL_GOUGE                 = 24698,
     SPELL_MARK                  = 24210,
     SPELL_CLEAVE                = 26350,                    //Perhaps not right. Not a red aura...
     SPELL_PANTHER_TRANSFORM     = 24190,
+
     MODEL_ID_NORMAL             = 15218,
     MODEL_ID_PANTHER            = 15215,
     MODEL_ID_BLANK              = 11686,
+
     NPC_ZULIAN_PROWLER          = 15101
 };
+
 struct TRINITY_DLL_DECL boss_arlokkAI : public ScriptedAI
 {
     boss_arlokkAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     uint32 m_uiShadowWordPain_Timer;
     uint32 m_uiGouge_Timer;
     uint32 m_uiMark_Timer;
     uint32 m_uiCleave_Timer;
     uint32 m_uiVanish_Timer;
     uint32 m_uiVisible_Timer;
+
     uint32 m_uiSummon_Timer;
     uint32 m_uiSummonCount;
+
     Unit* m_pMarkedTarget;
+
     bool m_bIsPhaseTwo;
     bool m_bIsVanished;
+
     void Reset()
     {
         m_uiShadowWordPain_Timer = 8000;
@@ -72,50 +88,66 @@ struct TRINITY_DLL_DECL boss_arlokkAI : public ScriptedAI
         m_uiCleave_Timer = 4000;
         m_uiVanish_Timer = 60000;
         m_uiVisible_Timer = 6000;
+
         m_uiSummon_Timer = 5000;
         m_uiSummonCount = 0;
+
         m_bIsPhaseTwo = false;
         m_bIsVanished = false;
+
         m_pMarkedTarget = NULL;
+
         m_creature->SetDisplayId(MODEL_ID_NORMAL);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void JustReachedHome()
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_ARLOKK, NOT_STARTED);
+
         //we should be summoned, so despawn
         m_creature->ForcedDespawn();
     }
+
     void JustDied(Unit* pKiller)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         m_creature->SetDisplayId(MODEL_ID_NORMAL);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_ARLOKK, DONE);
     }
+
     void DoSummonPhanters()
     {
         if (m_pMarkedTarget)
             DoScriptText(SAY_FEAST_PANTHER, m_creature, m_pMarkedTarget);
+
         m_creature->SummonCreature(NPC_ZULIAN_PROWLER, -11532.7998, -1649.6734, 41.4800, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
         m_creature->SummonCreature(NPC_ZULIAN_PROWLER, -11532.9970, -1606.4840, 41.2979, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (m_pMarkedTarget)
             pSummoned->AI()->AttackStart(m_pMarkedTarget);
+
         ++m_uiSummonCount;
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         if (!m_bIsPhaseTwo)
         {
             if (m_uiShadowWordPain_Timer < uiDiff)
@@ -125,13 +157,16 @@ struct TRINITY_DLL_DECL boss_arlokkAI : public ScriptedAI
             }
             else
                 m_uiShadowWordPain_Timer -= uiDiff;
+
             if (m_uiMark_Timer < uiDiff)
             {
                 m_pMarkedTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
+
                 if (m_pMarkedTarget)
                     DoCast(m_pMarkedTarget, SPELL_MARK);
                 else
                     error_log("TSCR: boss_arlokk could not accuire m_pMarkedTarget.");
+
                 m_uiMark_Timer = 15000;
             }
             else
@@ -147,16 +182,20 @@ struct TRINITY_DLL_DECL boss_arlokkAI : public ScriptedAI
             }
             else
                 m_uiCleave_Timer -= uiDiff;
+
             //Gouge_Timer
             if (m_uiGouge_Timer < uiDiff)
             {
                 DoCast(m_creature->getVictim(), SPELL_GOUGE);
+
                 DoModifyThreatPercent(m_creature->getVictim(),-80);
+
                 m_uiGouge_Timer = 17000+rand()%10000;
             }
             else
                 m_uiGouge_Timer -= uiDiff;
         }
+
         if (m_uiSummonCount <= 30)
         {
             if (m_uiSummon_Timer < uiDiff)
@@ -167,19 +206,24 @@ struct TRINITY_DLL_DECL boss_arlokkAI : public ScriptedAI
             else
                 m_uiSummon_Timer -= uiDiff;
         }
+
         if (m_uiVanish_Timer < uiDiff)
         {
             //Invisble Model
             m_creature->SetDisplayId(MODEL_ID_BLANK);
             m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
             m_creature->AttackStop();
             DoResetThreat();
+
             m_bIsVanished = true;
+
             m_uiVanish_Timer = 45000;
             m_uiVisible_Timer = 6000;
         }
         else
             m_uiVanish_Timer -= uiDiff;
+
         if (m_bIsVanished)
         {
             if (m_uiVisible_Timer < uiDiff)
@@ -187,12 +231,15 @@ struct TRINITY_DLL_DECL boss_arlokkAI : public ScriptedAI
                 //The Panther Model
                 m_creature->SetDisplayId(MODEL_ID_PANTHER);
                 m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
                 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);
+
                 if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
                     AttackStart(pTarget);
+
                 m_bIsPhaseTwo = true;
                 m_bIsVanished = false;
             }
@@ -203,17 +250,21 @@ struct TRINITY_DLL_DECL boss_arlokkAI : public ScriptedAI
             DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_arlokk(Creature* pCreature)
 {
     return new boss_arlokkAI (pCreature);
 }
+
 void AddSC_boss_arlokk()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "go_gong_of_bethekk";
     newscript->pGOHello = &GOHello_go_gong_of_bethekk;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_arlokk";
     newscript->GetAI = &GetAI_boss_arlokk;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_gahzranka.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_gahzranka.cpp
index abcc3d71632..3de88e3af0f 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_gahzranka.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_gahzranka.cpp
@@ -13,55 +13,67 @@
  * along with 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            16099
 #define SPELL_MASSIVEGEYSER          22421                  //Not working. Cause its a summon...
 #define SPELL_SLAM                   24326
+
 struct TRINITY_DLL_DECL boss_gahzrankaAI : public ScriptedAI
 {
     boss_gahzrankaAI(Creature *c) : ScriptedAI(c) {}
     uint32 Frostbreath_Timer;
     uint32 MassiveGeyser_Timer;
     uint32 Slam_Timer;
+
     void Reset()
     {
         Frostbreath_Timer = 8000;
         MassiveGeyser_Timer = 25000;
         Slam_Timer = 17000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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();
     }
 };
@@ -69,6 +81,7 @@ CreatureAI* GetAI_boss_gahzranka(Creature* pCreature)
 {
     return new boss_gahzrankaAI (pCreature);
 }
+
 void AddSC_boss_gahzranka()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_grilek.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_grilek.cpp
index 957105f2b75..6475f7ab4e5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_grilek.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_grilek.cpp
@@ -13,52 +13,67 @@
  * along with 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 TRINITY_DLL_DECL boss_grilekAI : public ScriptedAI
 {
     boss_grilekAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Avartar_Timer;
     uint32 GroundTremor_Timer;
+
     void Reset()
     {
         Avartar_Timer = 15000 + rand()%10000;
         GroundTremor_Timer = 8000 + rand()%8000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Avartar_Timer
         if (Avartar_Timer < diff)
         {
+
             DoCast(m_creature, SPELL_AVARTAR);
             Unit* target = NULL;
+
             target = SelectUnit(SELECT_TARGET_RANDOM,1);
+
             if (DoGetThreat(m_creature->getVictim()))
                 DoModifyThreatPercent(m_creature->getVictim(),-50);
             if (target)
                 AttackStart(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();
     }
 };
@@ -66,6 +81,7 @@ CreatureAI* GetAI_boss_grilek(Creature* pCreature)
 {
     return new boss_grilekAI (pCreature);
 }
+
 void AddSC_boss_grilek()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_hakkar.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_hakkar.cpp
index 644a8018d89..be73374aafc 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_hakkar.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_hakkar.cpp
@@ -13,52 +13,64 @@
  * along with 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 SAY_AGGRO                   -1309020
 #define SAY_FLEEING                 -1309021
 #define SAY_MINION_DESTROY          -1309022                //where does it belong?
 #define SAY_PROTECT_ALTAR           -1309023                //where does it belong?
+
 #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
+
 struct TRINITY_DLL_DECL boss_hakkarAI : public ScriptedAI
 {
     boss_hakkarAI(Creature *c) : ScriptedAI(c)
     {
         m_pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *m_pInstance;
+
     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;
+
     bool Enraged;
+
     void Reset()
     {
         BloodSiphon_Timer = 90000;
@@ -66,57 +78,70 @@ struct TRINITY_DLL_DECL boss_hakkarAI : public ScriptedAI
         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 EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
         if (Unit* 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)
         {
             if (Unit* 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)
         {
@@ -133,6 +158,7 @@ struct TRINITY_DLL_DECL boss_hakkarAI : public ScriptedAI
             }
             CheckJeklik_Timer = 1000;
         }else CheckJeklik_Timer -= diff;
+
         //Checking if Venoxis is dead. If not we cast his Aspect
         if (CheckVenoxis_Timer < diff)
         {
@@ -149,6 +175,7 @@ struct TRINITY_DLL_DECL boss_hakkarAI : public ScriptedAI
             }
             CheckVenoxis_Timer = 1000;
         }else CheckVenoxis_Timer -= diff;
+
         //Checking if Marli is dead. If not we cast her Aspect
         if (CheckMarli_Timer < diff)
         {
@@ -161,10 +188,12 @@ struct TRINITY_DLL_DECL boss_hakkarAI : public ScriptedAI
                         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)
         {
@@ -181,6 +210,7 @@ struct TRINITY_DLL_DECL boss_hakkarAI : public ScriptedAI
             }
             CheckThekal_Timer = 1000;
         }else CheckThekal_Timer -= diff;
+
         //Checking if Arlokk is dead. If yes we cast her Aspect
         if (CheckArlokk_Timer < diff)
         {
@@ -192,19 +222,23 @@ struct TRINITY_DLL_DECL boss_hakkarAI : public ScriptedAI
                     {
                         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* pCreature)
 {
     return new boss_hakkarAI (pCreature);
 }
+
 void AddSC_boss_hakkar()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_hazzarah.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_hazzarah.cpp
index f07106df754..0b11bd59d6c 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_hazzarah.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_hazzarah.cpp
@@ -13,65 +13,79 @@
  * along with 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 TRINITY_DLL_DECL boss_hazzarahAI : public ScriptedAI
 {
     boss_hazzarahAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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 (uint8 i = 0; i < 3; ++i)
+            for(uint8 i = 0; i < 3; ++i)
             {
                 target = SelectUnit(SELECT_TARGET_RANDOM,0);
                 if (!target)
                     return;
+
                 Illusion = m_creature->SummonCreature(15163,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,30000);
                 if (Illusion)
                     (Illusion->AI())->AttackStart(target);
             }
+
             Illusions_Timer = 15000 + rand()%10000;
         }else Illusions_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -79,6 +93,7 @@ CreatureAI* GetAI_boss_hazzarah(Creature* pCreature)
 {
     return new boss_hazzarahAI (pCreature);
 }
+
 void AddSC_boss_hazzarah()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_jeklik.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_jeklik.cpp
index 39ed24ede8b..27d9fc56443 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_jeklik.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_jeklik.cpp
@@ -13,17 +13,21 @@
  * along with 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 SAY_AGGRO                   -1309002
 #define SAY_RAIN_FIRE               -1309003
 #define SAY_DEATH                   -1309004
+
 #define SPELL_CHARGE              22911
 #define SPELL_SONICBURST          23918
 #define SPELL_SCREECH             6605
@@ -32,15 +36,20 @@ EndScriptData */
 #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...
+
 struct TRINITY_DLL_DECL boss_jeklikAI : public ScriptedAI
 {
     boss_jeklikAI(Creature *c) : ScriptedAI(c)
     {
         m_pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *m_pInstance;
+
     uint32 Charge_Timer;
     uint32 SonicBurst_Timer;
     uint32 Screech_Timer;
@@ -50,7 +59,9 @@ struct TRINITY_DLL_DECL boss_jeklikAI : public ScriptedAI
     uint32 ChainMindFlay_Timer;
     uint32 GreaterHeal_Timer;
     uint32 SpawnFlyingBats_Timer;
+
     bool PhaseTwo;
+
     void Reset()
     {
         Charge_Timer = 20000;
@@ -62,23 +73,29 @@ struct TRINITY_DLL_DECL boss_jeklikAI : public ScriptedAI
         ChainMindFlay_Timer = 26000;
         GreaterHeal_Timer = 50000;
         SpawnFlyingBats_Timer = 10000;
+
         PhaseTwo = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoCast(m_creature,SPELL_BAT_FORM);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_JEKLIK, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (m_creature->getVictim() && m_creature->isAlive())
         {
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 50))
@@ -90,34 +107,44 @@ struct TRINITY_DLL_DECL boss_jeklikAI : public ScriptedAI
                         DoCast(target,SPELL_CHARGE);
                         AttackStart(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;
             }
@@ -133,31 +160,37 @@ struct TRINITY_DLL_DECL boss_jeklikAI : public ScriptedAI
                             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);
                         if (!target)
                             return;
+
                         Creature* FlyingBat = m_creature->SummonCreature(14965, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()+15, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                         if (FlyingBat)
                             FlyingBat->AI()->AttackStart(target);
+
                         SpawnFlyingBats_Timer = 10000 + rand()%5000;
                     }else SpawnFlyingBats_Timer -=diff;
                 }
@@ -168,10 +201,12 @@ struct TRINITY_DLL_DECL boss_jeklikAI : public ScriptedAI
                     PhaseTwo = true;
                 }
             }
+
             DoMeleeAttackIfReady();
         }
     }
 };
+
 //Flying Bat
 struct TRINITY_DLL_DECL mob_batriderAI : public ScriptedAI
 {
@@ -179,20 +214,27 @@ struct TRINITY_DLL_DECL mob_batriderAI : public ScriptedAI
     {
         m_pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *m_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 EnterCombat(Unit *who) {}
+
     void UpdateAI (const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //Bomb_Timer
         if (Bomb_Timer < diff)
         {
@@ -202,6 +244,7 @@ struct TRINITY_DLL_DECL mob_batriderAI : public ScriptedAI
                 Bomb_Timer = 5000;
             }
         }else Bomb_Timer -= diff;
+
         //Check_Timer
         if (Check_Timer < diff)
         {
@@ -214,19 +257,24 @@ struct TRINITY_DLL_DECL mob_batriderAI : public ScriptedAI
                     return;
                 }
             }
+
             Check_Timer = 1000;
         }else Check_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_jeklik(Creature* pCreature)
 {
     return new boss_jeklikAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_batrider(Creature* pCreature)
 {
     return new mob_batriderAI (pCreature);
 }
+
 void AddSC_boss_jeklik()
 {
     Script *newscript;
@@ -234,6 +282,7 @@ void AddSC_boss_jeklik()
     newscript->Name = "boss_jeklik";
     newscript->GetAI = &GetAI_boss_jeklik;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_batrider";
     newscript->GetAI = &GetAI_mob_batrider;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_jindo.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_jindo.cpp
index 09700f4193e..3fa3090abdb 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_jindo.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_jindo.cpp
@@ -13,33 +13,42 @@
  * along with 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 SAY_AGGRO                       -1309014
+
 #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
+
 struct TRINITY_DLL_DECL boss_jindoAI : public ScriptedAI
 {
     boss_jindoAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 BrainWashTotem_Timer;
     uint32 HealingWard_Timer;
     uint32 Hex_Timer;
     uint32 Delusions_Timer;
     uint32 Teleport_Timer;
+
     void Reset()
     {
         BrainWashTotem_Timer = 20000;
@@ -48,20 +57,24 @@ struct TRINITY_DLL_DECL boss_jindoAI : public ScriptedAI
         Delusions_Timer = 10000;
         Teleport_Timer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
@@ -69,26 +82,33 @@ struct TRINITY_DLL_DECL boss_jindoAI : public ScriptedAI
             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 (DoGetThreat(m_creature->getVictim()))
                 DoModifyThreatPercent(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)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
             {
                 DoCast(target, SPELL_DELUSIONSOFJINDO);
+
                 Creature *Shade = m_creature->SummonCreature(14986, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                 if (Shade)
                     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)
         {
@@ -97,8 +117,10 @@ struct TRINITY_DLL_DECL boss_jindoAI : public ScriptedAI
             if (target && target->GetTypeId() == TYPEID_PLAYER)
             {
                 DoTeleportPlayer(target, -11583.7783,-1249.4278,77.5471,4.745);
+
                 if (DoGetThreat(m_creature->getVictim()))
                     DoModifyThreatPercent(target,-100);
+
                 Creature *Skeletons;
                 Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                 if (Skeletons)
@@ -128,11 +150,14 @@ struct TRINITY_DLL_DECL boss_jindoAI : public ScriptedAI
                 if (Skeletons)
                     Skeletons->AI()->AttackStart(target);
             }
+
             Teleport_Timer = 15000 + rand()%8000;
         }else Teleport_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Healing Ward
 struct TRINITY_DLL_DECL mob_healing_wardAI : public ScriptedAI
 {
@@ -140,15 +165,20 @@ struct TRINITY_DLL_DECL mob_healing_wardAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 Heal_Timer;
+
     ScriptedInstance *pInstance;
+
     void Reset()
     {
         Heal_Timer = 2000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI (const uint32 diff)
     {
         //Heal_Timer
@@ -162,56 +192,71 @@ struct TRINITY_DLL_DECL mob_healing_wardAI : public ScriptedAI
             }
             Heal_Timer = 3000;
         }else Heal_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Shade of Jindo
 struct TRINITY_DLL_DECL mob_shade_of_jindoAI : public ScriptedAI
 {
     mob_shade_of_jindoAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowShock_Timer;
+
     void Reset()
     {
         ShadowShock_Timer = 1000;
         m_creature->CastSpell(m_creature, SPELL_INVISIBLE,true);
     }
+
     void EnterCombat(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* pCreature)
 {
     return new boss_jindoAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_healing_ward(Creature* pCreature)
 {
     return new mob_healing_wardAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_shade_of_jindo(Creature* pCreature)
 {
     return new mob_shade_of_jindoAI (pCreature);
 }
+
 void AddSC_boss_jindo()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_jindo";
     newscript->GetAI = &GetAI_boss_jindo;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_healing_ward";
     newscript->GetAI = &GetAI_mob_healing_ward;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_shade_of_jindo";
     newscript->GetAI = &GetAI_mob_shade_of_jindo;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_mandokir.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_mandokir.cpp
index c15a9a12904..0408cdc1e95 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_mandokir.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_mandokir.cpp
@@ -13,19 +13,23 @@
  * along with 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 SAY_AGGRO               -1309015
 #define SAY_DING_KILL           -1309016
 #define SAY_GRATS_JINDO         -1309017
 #define SAY_WATCH               -1309018
 #define SAY_WATCH_WHISPER       -1309019                    //is this text for real? easter egg?
+
 #define SPELL_CHARGE            24315
 #define SPELL_CLEAVE            20691
 #define SPELL_FEAR              29321
@@ -34,14 +38,17 @@ EndScriptData */
 #define SPELL_ENRAGE            23537
 #define SPELL_WATCH             24314
 #define SPELL_LEVEL_UP          24312
+
 //Ohgans Spells
 #define SPELL_SUNDERARMOR       24317
+
 struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
 {
     boss_mandokirAI(Creature *c) : ScriptedAI(c)
     {
         m_pInstance = c->GetInstanceData();
     }
+
     uint32 KillCount;
     uint32 Watch_Timer;
     uint32 TargetInRange;
@@ -53,12 +60,16 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
     float targetX;
     float targetY;
     float targetZ;
+
     ScriptedInstance *m_pInstance;
+
     bool endWatch;
     bool someWatched;
     bool RaptorDead;
     bool CombatStart;
+
     uint64 WatchTarget;
+
     void Reset()
     {
         KillCount = 0;
@@ -68,25 +79,32 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
         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)
         {
             ++KillCount;
+
             if (KillCount == 3)
             {
                 DoScriptText(SAY_DING_KILL, m_creature);
+
                 if (m_pInstance)
                 {
                     uint64 JindoGUID = m_pInstance->GetData64(DATA_JINDO);
@@ -104,29 +122,35 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
             }
         }
     }
+
     void EnterCombat(Unit *who)
     {
      DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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() ||
@@ -148,6 +172,7 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
                 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
             {
                 if (Unit* p = SelectUnit(SELECT_TARGET_RANDOM,0))
@@ -159,6 +184,7 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
                     endWatch = true;
                 }
             }
+
             if ((Watch_Timer < 1000) && endWatch)           //1 sec before the debuf expire, store the target position
             {
                 Unit* pUnit = Unit::GetUnit(*m_creature, WatchTarget);
@@ -170,6 +196,7 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
                 }
                 endWatch = false;
             }
+
             if (!someWatched)
             {
                 //Cleave
@@ -178,27 +205,33 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
                     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)
+                    for(; i != m_creature->getThreatManager().getThreatList().end(); ++i)
                     {
                         Unit* pUnit = Unit::GetUnit(*m_creature, (*i)->getUnitGuid());
                         if (pUnit && m_creature->IsWithinMeleeRange(pUnit))
                             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() && m_creature->getVictim()->GetHealth() < m_creature->getVictim()->GetMaxHealth()*0.5)
                 {
@@ -223,12 +256,15 @@ struct TRINITY_DLL_DECL boss_mandokirAI : public ScriptedAI
                         }
                     }
                 }
+
                 Check_Timer = 1000;
             }else Check_Timer -= diff;
+
             DoMeleeAttackIfReady();
         }
     }
 };
+
 //Ohgan
 struct TRINITY_DLL_DECL mob_ohganAI : public ScriptedAI
 {
@@ -236,47 +272,59 @@ struct TRINITY_DLL_DECL mob_ohganAI : public ScriptedAI
     {
         m_pInstance = c->GetInstanceData();
     }
+
     uint32 SunderArmor_Timer;
     ScriptedInstance *m_pInstance;
+
     void Reset()
     {
         SunderArmor_Timer = 5000;
     }
+
     void EnterCombat(Unit *who) {}
+
     void JustDied(Unit* Killer)
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_OHGAN, DONE);
     }
+
     void UpdateAI (const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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* pCreature)
 {
     return new boss_mandokirAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_ohgan(Creature* pCreature)
 {
     return new mob_ohganAI (pCreature);
 }
+
 void AddSC_boss_mandokir()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_mandokir";
     newscript->GetAI = &GetAI_boss_mandokir;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ohgan";
     newscript->GetAI = &GetAI_mob_ohgan;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp
index 6c39a2b1f10..ef29657f559 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp
@@ -13,32 +13,40 @@
  * along with 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 SAY_AGGRO               -1309005
 #define SAY_TRANSFORM           -1309006
 #define SAY_SPIDER_SPAWN        -1309007
 #define SAY_DEATH               -1309008
+
 #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.
+
 struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI
 {
     boss_marliAI(Creature *c) : ScriptedAI(c)
     {
         m_pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *m_pInstance;
+
     uint32 SpawnStartSpiders_Timer;
     uint32 PoisonVolley_Timer;
     uint32 SpawnSpider_Timer;
@@ -46,9 +54,11 @@ struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI
     uint32 Aspect_Timer;
     uint32 Transform_Timer;
     uint32 TransformBack_Timer;
+
     Creature *Spider;
     bool Spawned;
     bool PhaseTwo;
+
     void Reset()
     {
         SpawnStartSpiders_Timer = 1000;
@@ -58,23 +68,28 @@ struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI
         Aspect_Timer = 12000;
         Transform_Timer = 45000;
         TransformBack_Timer = 25000;
+
         Spawned = false;
         PhaseTwo = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
         if (m_pInstance)
             m_pInstance->SetData(TYPE_MARLI, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (m_creature->getVictim() && m_creature->isAlive())
         {
             if (PoisonVolley_Timer < diff)
@@ -82,17 +97,21 @@ struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI
                 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)
             {
                 DoScriptText(SAY_SPIDER_SPAWN, m_creature);
+
                 Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
                 if (!target)
                     return;
+
                 Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                 if (Spider)
                     Spider->AI()->AttackStart(target);
@@ -105,18 +124,22 @@ struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI
                 Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                 if (Spider)
                     Spider->AI()->AttackStart(target);
+
                 Spawned = true;
             }else SpawnStartSpiders_Timer -= diff;
+
             if (SpawnSpider_Timer < diff)
             {
                 Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
                 if (!target)
                     return;
+
                 Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                 if (Spider)
                     Spider->AI()->AttackStart(target);
                 SpawnSpider_Timer = 12000 + rand()%5000;
             }else SpawnSpider_Timer -= diff;
+
             if (!PhaseTwo && Transform_Timer < diff)
             {
                 DoScriptText(SAY_TRANSFORM, m_creature);
@@ -126,11 +149,14 @@ struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI
                 m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35)));
                 m_creature->UpdateDamagePhysical(BASE_ATTACK);
                 DoCast(m_creature->getVictim(),SPELL_ENVOLWINGWEB);
+
                 if (DoGetThreat(m_creature->getVictim()))
                     DoModifyThreatPercent(m_creature->getVictim(),-100);
+
                 PhaseTwo = true;
                 Transform_Timer = 35000 + rand()%25000;
             }else Transform_Timer -= diff;
+
             if (PhaseTwo)
             {
                 if (Charge_Timer < diff)
@@ -152,8 +178,10 @@ struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI
                         //m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1);
                         AttackStart(target);
                     }
+
                     Charge_Timer = 8000;
                 }else Charge_Timer -= diff;
+
                 if (TransformBack_Timer < diff)
                 {
                     m_creature->SetDisplayId(15220);
@@ -161,55 +189,70 @@ struct TRINITY_DLL_DECL boss_marliAI : public ScriptedAI
                     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 TRINITY_DLL_DECL mob_spawn_of_marliAI : public ScriptedAI
 {
     mob_spawn_of_marliAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 LevelUp_Timer;
+
     void Reset()
     {
         LevelUp_Timer = 3000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI (const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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* pCreature)
 {
     return new boss_marliAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_spawn_of_marli(Creature* pCreature)
 {
     return new mob_spawn_of_marliAI (pCreature);
 }
+
 void AddSC_boss_marli()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_marli";
     newscript->GetAI = &GetAI_boss_marli;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_spawn_of_marli";
     newscript->GetAI = &GetAI_mob_spawn_of_marli;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_renataki.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_renataki.cpp
index 49feb913ed8..bc6be61e253 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_renataki.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_renataki.cpp
@@ -13,27 +13,35 @@
  * along with 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
+
 #define EQUIP_ID_MAIN_HAND      0           //was item display id 31818, but this id does not exist
+
 struct TRINITY_DLL_DECL boss_renatakiAI : public ScriptedAI
 {
     boss_renatakiAI(Creature *c) : ScriptedAI(c) {}
+
     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;
@@ -41,26 +49,34 @@ struct TRINITY_DLL_DECL boss_renatakiAI : public ScriptedAI
         Visible_Timer = 4000;
         Aggro_Timer = 15000 + rand()%10000;
         ThousandBlades_Timer = 4000 + rand()%4000;
+
         Invisible = false;
         Ambushed = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //Invisible_Timer
         if (Invisible_Timer < diff)
         {
             m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
+
             SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE);
             m_creature->SetDisplayId(11686);
+
             m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
             Invisible = true;
+
             Invisible_Timer = 15000 + rand()%15000;
         }else Invisible_Timer -= diff;
+
         if (Invisible)
         {
             if (Ambush_Timer < diff)
@@ -72,40 +88,51 @@ struct TRINITY_DLL_DECL boss_renatakiAI : public ScriptedAI
                     DoTeleportTo(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
                     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->SetDisplayId(15268);
                 SetEquipmentSlots(false, EQUIP_ID_MAIN_HAND, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE);
+
                 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 (DoGetThreat(m_creature->getVictim()))
                 DoModifyThreatPercent(m_creature->getVictim(),-50);
+
             if (target)
                 AttackStart(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();
     }
 };
@@ -113,6 +140,7 @@ CreatureAI* GetAI_boss_renataki(Creature* pCreature)
 {
     return new boss_renatakiAI (pCreature);
 }
+
 void AddSC_boss_renataki()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_thekal.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_thekal.cpp
index 3127d1e0ec0..a0693a0cdc4 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_thekal.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_thekal.cpp
@@ -13,16 +13,20 @@
  * along with 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 SAY_AGGRO               -1309009
 #define SAY_DEATH               -1309010
+
 #define SPELL_MORTALCLEAVE        22859
 #define SPELL_SILENCE             23207
 #define SPELL_FRENZY              23342
@@ -32,23 +36,27 @@ EndScriptData */
 #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
+
 struct TRINITY_DLL_DECL boss_thekalAI : public ScriptedAI
 {
     boss_thekalAI(Creature *c) : ScriptedAI(c)
     {
         m_pInstance = c->GetInstanceData();
     }
+
     uint32 MortalCleave_Timer;
     uint32 Silence_Timer;
     uint32 Frenzy_Timer;
@@ -58,10 +66,12 @@ struct TRINITY_DLL_DECL boss_thekalAI : public ScriptedAI
     uint32 SummonTigers_Timer;
     uint32 Check_Timer;
     uint32 Resurrect_Timer;
+
     ScriptedInstance *m_pInstance;
     bool Enraged;
     bool PhaseTwo;
     bool WasDead;
+
     void Reset()
     {
         MortalCleave_Timer = 4000;
@@ -73,29 +83,35 @@ struct TRINITY_DLL_DECL boss_thekalAI : public ScriptedAI
         SummonTigers_Timer = 25000;
         Check_Timer = 10000;
         Resurrect_Timer = 10000;
+
         Enraged = false;
         PhaseTwo = false;
         WasDead = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
         if (m_pInstance)
             m_pInstance->SetData(TYPE_THEKAL, DONE);
     }
+
     void JustReachedHome()
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_THEKAL, NOT_STARTED);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
             //Check_Timer for the death of LorKhan and Zath.
             if (!WasDead && Check_Timer < diff)
             {
@@ -110,9 +126,11 @@ struct TRINITY_DLL_DECL boss_thekalAI : public ScriptedAI
                             pLorKhan->setFaction(14);
                             pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                             pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0));
+
                             m_pInstance->SetData(TYPE_LORKHAN, DONE);
                         }
                     }
+
                     if (m_pInstance->GetData(TYPE_ZATH) == SPECIAL)
                     {
                         //Resurrect Zath
@@ -123,31 +141,39 @@ struct TRINITY_DLL_DECL boss_thekalAI : public ScriptedAI
                             pZath->setFaction(14);
                             pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                             pZath->SetHealth(int(pZath->GetMaxHealth()*1.0));
+
                             m_pInstance->SetData(TYPE_ZATH, DONE);
                         }
                     }
                 }
+
                 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->SetStandState(UNIT_STAND_STATE_SLEEP);
                 m_creature->AttackStop();
+
                 if (m_pInstance)
                     m_pInstance->SetData(TYPE_THEKAL, SPECIAL);
+
                 WasDead=true;
             }
+
             //Thekal will transform to Tiger if he died and was not resurrected after 10 seconds.
             if (!PhaseTwo && WasDead)
             {
@@ -166,10 +192,12 @@ struct TRINITY_DLL_DECL boss_thekalAI : public ScriptedAI
                     PhaseTwo = true;
                 }else Resurrect_Timer -= diff;
             }
+
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() == 100) && WasDead)
             {
                 WasDead = false;
             }
+
             if (PhaseTwo)
             {
                 if (Charge_Timer < diff)
@@ -180,32 +208,40 @@ struct TRINITY_DLL_DECL boss_thekalAI : public ScriptedAI
                         DoResetThreat();
                         AttackStart(target);
                     }
+
                     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 TRINITY_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI
 {
@@ -213,13 +249,17 @@ struct TRINITY_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI
     {
         m_pInstance = c->GetInstanceData();
     }
+
     uint32 Shield_Timer;
     uint32 BloodLust_Timer;
     uint32 GreaterHeal_Timer;
     uint32 Disarm_Timer;
     uint32 Check_Timer;
+
     bool FakeDeath;
+
     ScriptedInstance *m_pInstance;
+
     void Reset()
     {
         Shield_Timer = 1000;
@@ -227,31 +267,39 @@ struct TRINITY_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI
         GreaterHeal_Timer = 32000;
         Disarm_Timer = 6000;
         Check_Timer = 10000;
+
         FakeDeath = false;
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_LORKHAN, NOT_STARTED);
+
         m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI (const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
@@ -259,8 +307,10 @@ struct TRINITY_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI
             {
                 Unit *pThekal = Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_THEKAL));
                 Unit *pZath = Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_ZATH));
+
                 if (!pThekal || !pZath)
                     return;
+
                 switch(rand()%2)
                 {
                     case 0:
@@ -273,14 +323,17 @@ struct TRINITY_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI
                         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)
         {
@@ -297,6 +350,7 @@ struct TRINITY_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI
                         pThekal->SetHealth(int(pThekal->GetMaxHealth()*1.0));
                     }
                 }
+
                 if (m_pInstance->GetData(TYPE_ZATH) == SPECIAL)
                 {
                     //Resurrect Zath
@@ -309,21 +363,27 @@ struct TRINITY_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI
                     }
                 }
             }
+
             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->SetStandState(UNIT_STAND_STATE_SLEEP);
             m_creature->setFaction(35);
             m_creature->AttackStop();
+
             if (m_pInstance)
                 m_pInstance->SetData(TYPE_LORKHAN, SPECIAL);
+
             FakeDeath = true;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Zealot Zath
 struct TRINITY_DLL_DECL mob_zealot_zathAI : public ScriptedAI
 {
@@ -331,14 +391,18 @@ struct TRINITY_DLL_DECL mob_zealot_zathAI : public ScriptedAI
     {
         m_pInstance = c->GetInstanceData();
     }
+
     uint32 SweepingStrikes_Timer;
     uint32 SinisterStrike_Timer;
     uint32 Gouge_Timer;
     uint32 Kick_Timer;
     uint32 Blind_Timer;
     uint32 Check_Timer;
+
     bool FakeDeath;
+
     ScriptedInstance *m_pInstance;
+
     void Reset()
     {
         SweepingStrikes_Timer = 13000;
@@ -347,51 +411,64 @@ struct TRINITY_DLL_DECL mob_zealot_zathAI : public ScriptedAI
         Kick_Timer = 18000;
         Blind_Timer = 5000;
         Check_Timer = 10000;
+
         FakeDeath = false;
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_ZATH, NOT_STARTED);
+
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI (const uint32 diff)
     {
         if (!UpdateVictim())
             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 (DoGetThreat(m_creature->getVictim()))
                 DoModifyThreatPercent(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)
         {
@@ -408,6 +485,7 @@ struct TRINITY_DLL_DECL mob_zealot_zathAI : public ScriptedAI
                         pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0));
                     }
                 }
+
                 if (m_pInstance->GetData(TYPE_THEKAL) == SPECIAL)
                 {
                     //Resurrect Thekal
@@ -420,44 +498,56 @@ struct TRINITY_DLL_DECL mob_zealot_zathAI : public ScriptedAI
                     }
                 }
             }
+
             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->SetStandState(UNIT_STAND_STATE_SLEEP);
             m_creature->setFaction(35);
             m_creature->AttackStop();
+
             if (m_pInstance)
                 m_pInstance->SetData(TYPE_ZATH, SPECIAL);
+
             FakeDeath = true;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_thekal(Creature* pCreature)
 {
     return new boss_thekalAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_zealot_lorkhan(Creature* pCreature)
 {
     return new mob_zealot_lorkhanAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_zealot_zath(Creature* pCreature)
 {
     return new mob_zealot_zathAI (pCreature);
 }
+
 void AddSC_boss_thekal()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_thekal";
     newscript->GetAI = &GetAI_boss_thekal;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_zealot_lorkhan";
     newscript->GetAI = &GetAI_mob_zealot_lorkhan;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_zealot_zath";
     newscript->GetAI = &GetAI_mob_zealot_zath;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_venoxis.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_venoxis.cpp
index 65dc89a3362..2ff7597f0fa 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_venoxis.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_venoxis.cpp
@@ -13,16 +13,20 @@
  * along with 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 SAY_TRANSFORM       -1309000
 #define SAY_DEATH           -1309001
+
 #define SPELL_HOLY_FIRE     23860
 #define SPELL_HOLY_WRATH    28883                           //Not sure if this or 23979
 #define SPELL_VENOMSPIT     23862
@@ -32,13 +36,16 @@ EndScriptData */
 #define SPELL_RENEW         23895
 #define SPELL_BERSERK       23537
 #define SPELL_DISPELL       23859
+
 struct TRINITY_DLL_DECL boss_venoxisAI : public ScriptedAI
 {
     boss_venoxisAI(Creature *c) : ScriptedAI(c)
     {
         m_pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *m_pInstance;
+
     uint32 HolyFire_Timer;
     uint32 HolyWrath_Timer;
     uint32 VenomSpit_Timer;
@@ -47,8 +54,10 @@ struct TRINITY_DLL_DECL boss_venoxisAI : public ScriptedAI
     uint32 HolyNova_Timer;
     uint32 Dispell_Timer;
     uint32 TargetInRange;
+
     bool PhaseTwo;
     bool InBerserk;
+
     void Reset()
     {
         HolyFire_Timer = 10000;
@@ -59,22 +68,27 @@ struct TRINITY_DLL_DECL boss_venoxisAI : public ScriptedAI
         HolyNova_Timer = 5000;
         Dispell_Timer = 35000;
         TargetInRange = 0;
+
         PhaseTwo = false;
         InBerserk= false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
         if (m_pInstance)
             m_pInstance->SetData(TYPE_VENOXIS, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
           if (!UpdateVictim())
             return;
+
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 50))
             {
                 if (Dispell_Timer < diff)
@@ -82,25 +96,29 @@ struct TRINITY_DLL_DECL boss_venoxisAI : public ScriptedAI
                     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)
                 {
                     TargetInRange = 0;
-                    for (uint8 i=0; i<10; ++i)
+                    for(uint8 i=0; i<10; ++i)
                     {
                         if (Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO,i))
                             if (m_creature->IsWithinMeleeRange(target))
                                 TargetInRange++;
                     }
+
                     if (TargetInRange > 1)
                     {
                         DoCast(m_creature->getVictim(),SPELL_HOLY_NOVA);
@@ -110,11 +128,14 @@ struct TRINITY_DLL_DECL boss_venoxisAI : public ScriptedAI
                     {
                         HolyNova_Timer = 2000;
                     }
+
                 }else HolyNova_Timer -= diff;
+
                 if (HolyFire_Timer < diff && TargetInRange < 3)
                 {
                     if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                         DoCast(target, SPELL_HOLY_FIRE);
+
                     HolyFire_Timer = 8000;
                 }else HolyFire_Timer -= diff;
             }
@@ -133,17 +154,21 @@ struct TRINITY_DLL_DECL boss_venoxisAI : public ScriptedAI
                     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)
                 {
                     if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                         DoCast(target, SPELL_VENOMSPIT);
+
                     VenomSpit_Timer = 15000 + rand()%5000;
                 }else VenomSpit_Timer -= diff;
+
                 if (PhaseTwo && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11))
                 {
                     if (!InBerserk)
@@ -157,10 +182,12 @@ struct TRINITY_DLL_DECL boss_venoxisAI : public ScriptedAI
             DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_venoxis(Creature* pCreature)
 {
     return new boss_venoxisAI (pCreature);
 }
+
 void AddSC_boss_venoxis()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_wushoolay.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_wushoolay.cpp
index bc4af57b510..4ba494a2b0a 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_wushoolay.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/boss_wushoolay.cpp
@@ -13,47 +13,59 @@
  * along with 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 TRINITY_DLL_DECL boss_wushoolayAI : public ScriptedAI
 {
     boss_wushoolayAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 LightningCloud_Timer;
     uint32 LightningWave_Timer;
+
     void Reset()
     {
         LightningCloud_Timer = 5000 + rand()%5000;
         LightningWave_Timer = 8000 + rand()%8000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -61,6 +73,7 @@ CreatureAI* GetAI_boss_wushoolay(Creature* pCreature)
 {
     return new boss_wushoolayAI (pCreature);
 }
+
 void AddSC_boss_wushoolay()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/def_zulgurub.h b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/def_zulgurub.h
index 773076effa8..bf55a54c1d5 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/def_zulgurub.h
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/def_zulgurub.h
@@ -1,11 +1,14 @@
 /* Copyright (C) 2006 - 2009 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
+
 enum eTypes
 {
     MAX_ENCOUNTERS          = 8,
+
     TYPE_ARLOKK             = 1,
     TYPE_JEKLIK             = 2,
     TYPE_VENOXIS            = 3,
@@ -14,10 +17,12 @@ enum eTypes
     TYPE_THEKAL             = 6,
     TYPE_ZATH               = 7,
     TYPE_LORKHAN            = 8,
+
     DATA_JINDO              = 10,
     DATA_LORKHAN            = 11,
     DATA_THEKAL             = 12,
     DATA_ZATH               = 13
 };
+
 #endif
 
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/instance_zulgurub.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/instance_zulgurub.cpp
index 311083b270a..03b3e64c5e6 100644
--- a/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/instance_zulgurub.cpp
+++ b/src/bindings/scripts/scripts/eastern_kingdoms/zulgurub/instance_zulgurub.cpp
@@ -13,37 +13,46 @@
  * along 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 TRINITY_DLL_DECL instance_zulgurub : public ScriptedInstance
 {
     instance_zulgurub(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     //If all High Priest bosses were killed. Lorkhan, Zath and Ohgan are added too.
     uint32 m_auiEncounter[MAX_ENCOUNTERS];
+
     //Storing Lorkhan, Zath and Thekal because we need to cast on them later. Jindo is needed for healfunction too.
     uint64 m_uiLorKhanGUID;
     uint64 m_uiZathGUID;
     uint64 m_uiThekalGUID;
     uint64 m_uiJindoGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         m_uiLorKhanGUID = 0;
         m_uiZathGUID = 0;
         m_uiThekalGUID = 0;
         m_uiJindoGUID = 0;
     }
+
     bool IsEncounterInProgress() const
     {
         //not active in Zul'Gurub
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature)
     {
         switch(pCreature->GetEntry())
@@ -54,6 +63,7 @@ struct TRINITY_DLL_DECL instance_zulgurub : public ScriptedInstance
             case 11380: m_uiJindoGUID = pCreature->GetGUID(); break;
         }
     }
+
     void SetData(uint32 uiType, uint32 uiData)
     {
         switch(uiType)
@@ -61,29 +71,37 @@ struct TRINITY_DLL_DECL instance_zulgurub : public ScriptedInstance
             case TYPE_ARLOKK:
                 m_auiEncounter[0] = uiData;
                 break;
+
             case TYPE_JEKLIK:
                 m_auiEncounter[1] = uiData;
                 break;
+
             case TYPE_VENOXIS:
                 m_auiEncounter[2] = uiData;
                 break;
+
             case TYPE_MARLI:
                 m_auiEncounter[3] = uiData;
                 break;
+
             case TYPE_THEKAL:
                 m_auiEncounter[4] = uiData;
                 break;
+
             case TYPE_LORKHAN:
                 m_auiEncounter[5] = uiData;
                 break;
+
             case TYPE_ZATH:
                 m_auiEncounter[6] = uiData;
                 break;
+
             case TYPE_OHGAN:
                 m_auiEncounter[7] = uiData;
                 break;
         }
     }
+
     uint32 GetData(uint32 uiType)
     {
         switch(uiType)
@@ -107,6 +125,7 @@ struct TRINITY_DLL_DECL instance_zulgurub : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 uiData)
     {
         switch(uiData)
@@ -123,10 +142,12 @@ struct TRINITY_DLL_DECL instance_zulgurub : public ScriptedInstance
         return 0;
     }
 };
+
 InstanceData* GetInstanceData_instance_zulgurub(Map* pMap)
 {
     return new instance_zulgurub(pMap);
 }
+
 void AddSC_instance_zulgurub()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/examples/example_creature.cpp b/src/bindings/scripts/scripts/examples/example_creature.cpp
index bd82225f599..c932f3387f9 100644
--- a/src/bindings/scripts/scripts/examples/example_creature.cpp
+++ b/src/bindings/scripts/scripts/examples/example_creature.cpp
@@ -13,22 +13,28 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Example_Creature
 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
+
 enum eEnums
 {
     //List of text id's. The text is stored in database, also in a localized version
@@ -44,6 +50,7 @@ enum eEnums
     SAY_PHASE       = -1999907,
     SAY_DANCE       = -1999908,
     SAY_SALUTE      = -1999909,
+
     //List of spells. Not required to define them in this way, but will make it easier to maintain in case spellId change
     SPELL_BUFF      = 25661,
     SPELL_ONE       = 12555,
@@ -52,18 +59,23 @@ enum eEnums
     SPELL_THREE     = 26027,
     SPELL_ENRAGE    = 23537,
     SPELL_BESERK    = 32309,
+
     FACTION_WORGEN  = 24
 };
+
 //List of gossip item texts. Items will appear in the gossip window.
 #define GOSSIP_ITEM     "I'm looking for a fight"
+
 struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
 {
     //*** HANDLED FUNCTION ***
     //This is the constructor, called only once when the Creature is first created
     example_creatureAI(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 m_uiSay_Timer;                                   //Timer for random chat
     uint32 m_uiRebuff_Timer;                                //Timer for rebuffing
     uint32 m_uiSpell_1_Timer;                               //Timer for spell 1 when in combat
@@ -72,6 +84,7 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
     uint32 m_uiBeserk_Timer;                                //Timer until we go into Beserk (enraged) mode
     uint32 m_uiPhase;                                       //The current battle phase we are in
     uint32 m_uiPhase_Timer;                                 //Timer until phase transition
+
     //*** HANDLED FUNCTION ***
     //This is called whenever the core decides we need to evade
     void Reset()
@@ -83,6 +96,7 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
         m_uiSpell_3_Timer = 19000;                          //19 seconds
         m_uiBeserk_Timer = 120000;                          //2 minutes
     }
+
     //*** HANDLED FUNCTION ***
     //Attack Start is called whenever someone hits us.
     void EnterCombat(Unit* pWho)
@@ -90,10 +104,12 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
         //Say some stuff
         DoScriptText(SAY_AGGRO, m_creature, pWho);
     }
+
     //Our Recive emote function
     void ReceiveEmote(Player* pPlayer, uint32 uiTextEmote)
     {
         m_creature->HandleEmoteCommand(uiTextEmote);
+
         switch(uiTextEmote)
         {
             case TEXTEMOTE_DANCE:
@@ -104,6 +120,7 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
                 break;
         }
      }
+
     //*** 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 uiDiff)
@@ -116,10 +133,12 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
             {
                 //Random switch between 5 outcomes
                 DoScriptText(RAND(SAY_RANDOM_0,SAY_RANDOM_1,SAY_RANDOM_2,SAY_RANDOM_3,SAY_RANDOM_4), m_creature);
+
                 m_uiSay_Timer = 45000;                      //Say something agian in 45 seconds
             }
             else
                 m_uiSay_Timer -= uiDiff;
+
             //Rebuff timer
             if (m_uiRebuff_Timer < uiDiff)
             {
@@ -129,9 +148,11 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
             else
                 m_uiRebuff_Timer -= uiDiff;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Spell 1 timer
         if (m_uiSpell_1_Timer < uiDiff)
         {
@@ -140,10 +161,12 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
                 DoCast(m_creature->getVictim(), SPELL_ONE_ALT);
             else if (m_creature->IsWithinDist(m_creature->getVictim(), 25.0f))
                 DoCast(m_creature->getVictim(), SPELL_ONE);
+
             m_uiSpell_1_Timer = 5000;
         }
         else
             m_uiSpell_1_Timer -= uiDiff;
+
         //Spell 2 timer
         if (m_uiSpell_2_Timer < uiDiff)
         {
@@ -153,6 +176,7 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
         }
         else
             m_uiSpell_2_Timer -= uiDiff;
+
         //Beserk timer
         if (m_uiPhase > 1)
         {
@@ -161,15 +185,18 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
             {
                 //Cast spell one on our current target.
                 DoCast(m_creature->getVictim(), SPELL_THREE);
+
                 m_uiSpell_3_Timer = 19000;
             }
             else
                 m_uiSpell_3_Timer -= uiDiff;
+
             if (m_uiBeserk_Timer < uiDiff)
             {
                 //Say our line then cast uber death spell
                 DoScriptText(SAY_BESERK, m_creature, m_creature->getVictim());
                 DoCast(m_creature->getVictim(), SPELL_BESERK);
+
                 //Cast our beserk spell agian in 12 seconds if we didn't kill everyone
                 m_uiBeserk_Timer = 12000;
             }
@@ -188,15 +215,18 @@ struct TRINITY_DLL_DECL example_creatureAI : public ScriptedAI
             else
                 m_uiPhase_Timer -= uiDiff;
         }
+
         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_example_creature(Creature* pCreature)
 {
     return new example_creatureAI (pCreature);
 }
+
 //This function is called when the player clicks an option on the gossip menu
 bool GossipSelect_example_creature(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
@@ -207,20 +237,25 @@ bool GossipSelect_example_creature(Player* pPlayer, Creature* pCreature, uint32
         pCreature->setFaction(FACTION_WORGEN);
         pCreature->AI()->AttackStart(pPlayer);
     }
+
     return true;
 }
+
 //This function is called when the player opens the gossip menu
 bool GossipHello_example_creature(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
     pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID());
+
     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
 void AddSC_example_creature()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "example_creature";
     newscript->GetAI = &GetAI_example_creature;
diff --git a/src/bindings/scripts/scripts/examples/example_escort.cpp b/src/bindings/scripts/scripts/examples/example_escort.cpp
index 973d870a9da..027268a9325 100644
--- a/src/bindings/scripts/scripts/examples/example_escort.cpp
+++ b/src/bindings/scripts/scripts/examples/example_escort.cpp
@@ -13,20 +13,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Example_Escort
 SD%Complete: 100
 SDComment: Script used for testing escortAI
 SDCategory: Script Examples
 EndScriptData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 enum eEnums
 {
     NPC_FELBOAR                 = 21878,
+
     SPELL_DEATH_COIL            = 33130,
     SPELL_ELIXIR_OF_FORTITUDE   = 3593,
     SPELL_BLUE_FIREWORK         = 11540,
+
     SAY_AGGRO1                  = -1999910,
     SAY_AGGRO2                  = -1999911,
     SAY_WP_1                    = -1999912,
@@ -40,19 +45,24 @@ enum eEnums
     SAY_RAND_1                  = -1999920,
     SAY_RAND_2                  = -1999921
 };
+
 #define GOSSIP_ITEM_1   "Click to Test Escort(Attack, Run)"
 #define GOSSIP_ITEM_2   "Click to Test Escort(NoAttack, Walk)"
 #define GOSSIP_ITEM_3   "Click to Test Escort(NoAttack, Run)"
+
 struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI
 {
     // CreatureAI functions
     example_escortAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     uint32 m_uiDeathCoilTimer;
     uint32 m_uiChatTimer;
+
     void JustSummoned(Creature* pSummoned)
     {
         pSummoned->AI()->AttackStart(m_creature);
     }
+
     // Pure Virtual Functions (Have to be implemented)
     void WaypointReached(uint32 uiWP)
     {
@@ -76,6 +86,7 @@ struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI
                 break;
         }
     }
+
     void EnterCombat(Unit* pWho)
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
@@ -86,11 +97,13 @@ struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI
         else
             DoScriptText(SAY_AGGRO2, m_creature);
     }
+
     void Reset()
     {
         m_uiDeathCoilTimer = 4000;
         m_uiChatTimer = 4000;
     }
+
     void JustDied(Unit* pKiller)
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
@@ -109,10 +122,12 @@ struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI
         else
             DoScriptText(SAY_DEATH_3, m_creature);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Must update npc_escortAI
         npc_escortAI::UpdateAI(uiDiff);
+
         //Combat check
         if (m_creature->getVictim())
         {
@@ -142,6 +157,7 @@ struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI
                         DoScriptText(SAY_RAND_2, m_creature);
                         m_creature->CastSpell(m_creature, SPELL_ELIXIR_OF_FORTITUDE, false);
                     }
+
                     m_uiChatTimer = 12000;
                 }
                 else
@@ -150,45 +166,57 @@ struct TRINITY_DLL_DECL example_escortAI : public npc_escortAI
         }
     }
 };
+
 CreatureAI* GetAI_example_escort(Creature* pCreature)
 {
     return new example_escortAI(pCreature);
 }
+
 bool GossipHello_example_escort(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
     pCreature->prepareGossipMenu(pPlayer, 0);
+
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
+
     pCreature->sendPreparedGossip(pPlayer);
+
     return true;
 }
+
 bool GossipSelect_example_escort(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     npc_escortAI* pEscortAI = CAST_AI(example_escortAI, pCreature->AI());
+
     switch(uiAction)
     {
         case GOSSIP_ACTION_INFO_DEF+1:
             pPlayer->CLOSE_GOSSIP_MENU();
+
             if (pEscortAI)
                 pEscortAI->Start(true, true, pPlayer->GetGUID());
             break;
         case GOSSIP_ACTION_INFO_DEF+2:
             pPlayer->CLOSE_GOSSIP_MENU();
+
             if (pEscortAI)
                 pEscortAI->Start(false, false, pPlayer->GetGUID());
             break;
         case GOSSIP_ACTION_INFO_DEF+3:
             pPlayer->CLOSE_GOSSIP_MENU();
+
             if (pEscortAI)
                 pEscortAI->Start(false, true, pPlayer->GetGUID());
             break;
         default:
             return false;                                   // nothing defined      -> trinity core handling
     }
+
     return true;                                            // no default handling  -> prevent trinity core handling
 }
+
 void AddSC_example_escort()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/examples/example_gossip_codebox.cpp b/src/bindings/scripts/scripts/examples/example_gossip_codebox.cpp
index 80f8ff3325a..9a51d4d4c9a 100644
--- a/src/bindings/scripts/scripts/examples/example_gossip_codebox.cpp
+++ b/src/bindings/scripts/scripts/examples/example_gossip_codebox.cpp
@@ -13,32 +13,41 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Example_Gossip_Codebox
 SD%Complete: 100
 SDComment: Show a codebox in gossip option
 SDCategory: Script Examples
 EndScriptData */
+
 #include "precompiled.h"
 #include 
+
 enum eEnums
 {
     SPELL_POLYMORPH         = 12826,
     SPELL_MARK_OF_THE_WILD  = 26990,
+
     SAY_NOT_INTERESTED      = -1999922,
     SAY_WRONG               = -1999923,
     SAY_CORRECT             = -1999924
 };
+
 #define GOSSIP_ITEM_1       "A quiz: what's your name?"
 #define GOSSIP_ITEM_2       "I'm not interested"
+
 //This function is called when the player opens the gossip menubool
 bool GossipHello_example_gossip_codebox(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+
     pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());
+
     return true;
 }
+
 //This function is called when the player clicks an option on the gossip menubool
 bool GossipSelect_example_gossip_codebox(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
@@ -47,8 +56,10 @@ bool GossipSelect_example_gossip_codebox(Player* pPlayer, Creature* pCreature, u
         DoScriptText(SAY_NOT_INTERESTED, pCreature);
         pPlayer->CLOSE_GOSSIP_MENU();
     }
+
     return true;
 }
+
 bool GossipSelectWithCode_example_gossip_codebox(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode)
 {
     if (uiSender == GOSSIP_SENDER_MAIN)
@@ -67,14 +78,18 @@ bool GossipSelectWithCode_example_gossip_codebox(Player* pPlayer, Creature* pCre
                 pCreature->CastSpell(pPlayer, SPELL_MARK_OF_THE_WILD, true);
             }
             pPlayer->CLOSE_GOSSIP_MENU();
+
             return true;
         }
     }
+
     return false;
 }
+
 void AddSC_example_gossip_codebox()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "example_gossip_codebox";
     newscript->pGossipHello = &GossipHello_example_gossip_codebox;
diff --git a/src/bindings/scripts/scripts/examples/example_misc.cpp b/src/bindings/scripts/scripts/examples/example_misc.cpp
index a68a4a59729..667c30ad1b6 100644
--- a/src/bindings/scripts/scripts/examples/example_misc.cpp
+++ b/src/bindings/scripts/scripts/examples/example_misc.cpp
@@ -13,44 +13,54 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Example_Misc
 SD%Complete: 100
 SDComment: Item, Areatrigger and other small code examples
 SDCategory: Script Examples
 EndScriptData */
+
 #include "precompiled.h"
+
 enum eSay
 {
     SAY_HI  = -1999925
 };
+
 bool AT_example_areatrigger(Player* pPlayer, AreaTriggerEntry *pAt)
 {
     DoScriptText(SAY_HI, pPlayer);
     return true;
 }
+
 extern void LoadDatabase();
 bool ItemUse_example_item(Player* pPlayer, Item* pItem, SpellCastTargets const& scTargets)
 {
     LoadDatabase();
     return true;
 }
+
 bool GOHello_example_go_teleporter(Player* pPlayer, GameObject* pGo)
 {
     pPlayer->TeleportTo(0, 1807.07f, 336.105f, 70.3975f, 0.0f);
     return false;
 }
+
 void AddSC_example_misc()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "example_areatrigger";
     newscript->pAreaTrigger = &AT_example_areatrigger;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "example_item";
     newscript->pItemUse = &ItemUse_example_item;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "example_go_teleporter";
     newscript->pGOHello = &GOHello_example_go_teleporter;
diff --git a/src/bindings/scripts/scripts/kalimdor/ashenvale.cpp b/src/bindings/scripts/scripts/kalimdor/ashenvale.cpp
index 1f71cc3a05a..7bb193b98be 100644
--- a/src/bindings/scripts/scripts/kalimdor/ashenvale.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ashenvale.cpp
@@ -13,44 +13,57 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: Ashenvale
 SD%Complete: 70
 SDComment: Quest support: 6544, 6482
 SDCategory: Ashenvale Forest
 EndScriptData */
+
 /* ContentData
 npc_torek
 npc_ruul_snowhoof
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*####
 # npc_torek
 ####*/
+
 #define SAY_READY                   -1000106
 #define SAY_MOVE                    -1000107
 #define SAY_PREPARE                 -1000108
 #define SAY_WIN                     -1000109
 #define SAY_END                     -1000110
+
 #define SPELL_REND                  11977
 #define SPELL_THUNDERCLAP           8078
+
 #define QUEST_TOREK_ASSULT          6544
+
 #define ENTRY_SPLINTERTREE_RAIDER   12859
 #define ENTRY_DURIEL                12860
 #define ENTRY_SILVERWING_SENTINEL   12896
 #define ENTRY_SILVERWING_WARRIOR    12897
+
 struct TRINITY_DLL_DECL npc_torekAI : public npc_escortAI
 {
     npc_torekAI(Creature *c) : npc_escortAI(c) {}
+
     uint32 Rend_Timer;
     uint32 Thunderclap_Timer;
     bool Completed;
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch (i)
         {
         case 1:
@@ -76,29 +89,36 @@ struct TRINITY_DLL_DECL npc_torekAI : public npc_escortAI
             break;
         }
     }
+
     void Reset()
     {
         Rend_Timer = 5000;
         Thunderclap_Timer = 8000;
         Completed = false;
     }
+
     void EnterCombat(Unit* who)
     {
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
+
         if (!UpdateVictim())
             return;
+
         if (Rend_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_REND);
             Rend_Timer = 20000;
         }else Rend_Timer -= diff;
+
         if (Thunderclap_Timer < diff)
         {
             DoCast(m_creature,SPELL_THUNDERCLAP);
@@ -106,6 +126,7 @@ struct TRINITY_DLL_DECL npc_torekAI : public npc_escortAI
         }else Thunderclap_Timer -= diff;
     }
 };
+
 bool QuestAccept_npc_torek(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_TOREK_ASSULT)
@@ -113,28 +134,37 @@ bool QuestAccept_npc_torek(Player* pPlayer, Creature* pCreature, Quest const* qu
         //TODO: find companions, make them follow Torek, at any time (possibly done by mangos/database in future?)
         DoScriptText(SAY_READY, pCreature, pPlayer);
         pCreature->setFaction(113);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_torekAI, pCreature->AI()))
             pEscortAI->Start(true, true, pPlayer->GetGUID());
     }
+
     return true;
 }
+
 CreatureAI* GetAI_npc_torek(Creature* pCreature)
 {
     return new npc_torekAI(pCreature);
 }
+
 /*####
 # npc_ruul_snowhoof
 ####*/
+
 #define QUEST_FREEDOM_TO_RUUL    6482
 #define GO_CAGE                  178147
+
 struct TRINITY_DLL_DECL npc_ruul_snowhoofAI : public npc_escortAI
 {
     npc_ruul_snowhoofAI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
         case 0:    {
@@ -153,50 +183,62 @@ struct TRINITY_DLL_DECL npc_ruul_snowhoofAI : public npc_escortAI
                 m_creature->SummonCreature(3921, 3506.265625, -490.531006, 186.740128, 4.239277, TEMPSUMMON_DEAD_DESPAWN, 60000);
                 m_creature->SummonCreature(3926, 3503.682373, -489.393799, 186.629684, 4.349232, TEMPSUMMON_DEAD_DESPAWN, 60000);
                 break;
+
         case 21:{
                 if (pPlayer)
                     pPlayer->GroupEventHappens(QUEST_FREEDOM_TO_RUUL, m_creature);
+
                 break;  }
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void Reset()
     {
         GameObject* Cage = m_creature->FindNearestGameObject(GO_CAGE, 20);
         if (Cage)
             Cage->SetGoState(GO_STATE_READY);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
     }
 };
+
 bool QuestAccept_npc_ruul_snowhoof(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_FREEDOM_TO_RUUL)
     {
         pCreature->setFaction(113);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_ruul_snowhoofAI, (pCreature->AI())))
             pEscortAI->Start(true, false, pPlayer->GetGUID());
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_ruul_snowhoofAI(Creature* pCreature)
 {
     return new npc_ruul_snowhoofAI(pCreature);
 }
+
 void AddSC_ashenvale()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_torek";
     newscript->GetAI = &GetAI_npc_torek;
     newscript->pQuestAccept = &QuestAccept_npc_torek;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_ruul_snowhoof";
     newscript->GetAI = &GetAI_npc_ruul_snowhoofAI;
diff --git a/src/bindings/scripts/scripts/kalimdor/azshara.cpp b/src/bindings/scripts/scripts/kalimdor/azshara.cpp
index c9d03c7a2a4..d0d7fad255c 100644
--- a/src/bindings/scripts/scripts/kalimdor/azshara.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/azshara.cpp
@@ -13,35 +13,44 @@
  * along 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, 10994
 SDCategory: Azshara
 EndScriptData */
+
 /* ContentData
 mobs_spitelashes
 npc_loramus_thalipedes
 mob_rizzle_sprysprocket
 mob_depth_charge
 EndContentData */
+
 #include "precompiled.h"
 #include "World.h"
 #include "WorldPacket.h"
+
 /*######
 ## mobs_spitelashes
 ######*/
+
 struct TRINITY_DLL_DECL mobs_spitelashesAI : public ScriptedAI
 {
     mobs_spitelashesAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 morphtimer;
     bool spellhit;
+
     void Reset()
     {
         morphtimer = 0;
         spellhit = false;
     }
+
     void EnterCombat(Unit *who) { }
+
     void SpellHit(Unit *Hitter, const SpellEntry *Spellkind)
     {
         if (!spellhit &&
@@ -53,6 +62,7 @@ struct TRINITY_DLL_DECL mobs_spitelashesAI : public ScriptedAI
             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
@@ -73,6 +83,7 @@ struct TRINITY_DLL_DECL mobs_spitelashesAI : public ScriptedAI
         }
         if (!UpdateVictim())
             return;
+
         //TODO: add abilities for the different creatures
         DoMeleeAttackIfReady();
     }
@@ -81,9 +92,11 @@ CreatureAI* GetAI_mobs_spitelashes(Creature* pCreature)
 {
     return new mobs_spitelashesAI (pCreature);
 }
+
 /*######
 ## npc_loramus_thalipedes
 ######*/
+
 #define GOSSIP_HELLO_LT1    "Can you help me?"
 #define GOSSIP_HELLO_LT2    "Tell me your story"
 #define GOSSIP_SELECT_LT1   "Please continue"
@@ -91,17 +104,23 @@ CreatureAI* GetAI_mobs_spitelashes(Creature* pCreature)
 #define GOSSIP_SELECT_LT3   "Indeed"
 #define GOSSIP_SELECT_LT4   "I will do this with or your help, Loramus"
 #define GOSSIP_SELECT_LT5   "Yes"
+
 bool GossipHello_npc_loramus_thalipedes(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(2744) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_LT1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     if (pPlayer->GetQuestStatus(3141) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_LT2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_loramus_thalipedes(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -110,6 +129,7 @@ bool GossipSelect_npc_loramus_thalipedes(Player* pPlayer, Creature* pCreature, u
             pPlayer->CLOSE_GOSSIP_MENU();
             pPlayer->AreaExploredOrEventHappens(2744);
             break;
+
         case GOSSIP_ACTION_INFO_DEF+2:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_LT1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21);
             pPlayer->SEND_GOSSIP_MENU(1813, pCreature->GetGUID());
@@ -137,9 +157,11 @@ bool GossipSelect_npc_loramus_thalipedes(Player* pPlayer, Creature* pCreature, u
     }
     return true;
 }
+
 /*####
 # mob_rizzle_sprysprocket
 ####*/
+
 #define MOB_DEPTH_CHARGE 23025
 #define SPELL_RIZZLE_BLACKJACK 39865
 #define SPELL_RIZZLE_ESCAPE 39871
@@ -147,12 +169,16 @@ bool GossipSelect_npc_loramus_thalipedes(Player* pPlayer, Creature* pCreature, u
 #define SPELL_DEPTH_CHARGE_TRAP 38576
 #define SPELL_PERIODIC_DEPTH_CHARGE 39912
 #define SPELL_GIVE_SOUTHFURY_MOONSTONE 39886
+
 #define SAY_RIZZLE_START -1000245
 #define SAY_RIZZLE_GRENADE -1000246
 #define SAY_RIZZLE_FINAL -1000247
+
 #define GOSSIP_GET_MOONSTONE "Hand over the Southfury moonstone and I'll let you go."
+
 //next message must be send to player when Rizzle jump into river, not implemented
 #define MSG_ESCAPE_NOTICE "Rizzle Sprysprocket takes the Southfury moonstone and escapes into the river. Follow her!"
+
 float WPs[58][4] =
 {
 //pos_x   pos_y     pos_z    orien
@@ -215,20 +241,25 @@ float WPs[58][4] =
 {1927.09, -3679.56, 33.9118, 3.42},
 {1873.57, -3695.32, 33.9118, 3.44}
 };
+
 struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
 {
     mob_rizzle_sprysprocketAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 spellEscape_Timer;
     uint32 Teleport_Timer;
     uint32 Check_Timer;
     uint32 Grenade_Timer;
     uint32 Must_Die_Timer;
     uint32 CurrWP;
+
     uint64 PlayerGUID;
+
     bool Must_Die;
     bool Escape;
     bool ContinueWP;
     bool Reached;
+
     void Reset()
     {
         spellEscape_Timer = 1300;
@@ -237,12 +268,15 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
         Grenade_Timer = 30000;
         Must_Die_Timer = 3000;
         CurrWP = 0;
+
         PlayerGUID = 0;
+
         Must_Die = false;
         Escape = false;
         ContinueWP = false;
         Reached = false;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Must_Die)
@@ -251,15 +285,18 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
                 m_creature->ForcedDespawn();
                 return;
             } else Must_Die_Timer -= diff;
+
         if (!Escape)
         {
             if (!PlayerGUID)
                 return;
+
             if (spellEscape_Timer < diff)
             {
                 DoCast(m_creature, SPELL_RIZZLE_ESCAPE, false);
                 spellEscape_Timer = 10000;
             } else spellEscape_Timer -= diff;
+
             if (Teleport_Timer < diff)
             {
                 //temp solution - unit can't be teleported by core using spelleffect 5, only players
@@ -279,13 +316,16 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
                 m_creature->GetMotionMaster()->MovePoint(CurrWP, WPs[CurrWP][0], WPs[CurrWP][1], WPs[CurrWP][2]);
                 Escape = true;
             } else Teleport_Timer -= diff;
+
             return;
         }
+
         if (ContinueWP)
         {
             m_creature->GetMotionMaster()->MovePoint(CurrWP, WPs[CurrWP][0], WPs[CurrWP][1], WPs[CurrWP][2]);
             ContinueWP = false;
         }
+
         if (Grenade_Timer < diff)
         {
             Player* pPlayer = Unit::GetPlayer(PlayerGUID);
@@ -296,6 +336,7 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
             }
             Grenade_Timer = 30000;
         } else Grenade_Timer -= diff;
+
         if (Check_Timer < diff)
         {
             Player* pPlayer = Unit::GetPlayer(PlayerGUID);
@@ -304,6 +345,7 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
                 m_creature->ForcedDespawn();
                 return;
             }
+
             if (m_creature->IsWithinDist(pPlayer, 10) && m_creature->GetPositionX() > pPlayer->GetPositionX() && !Reached)
             {
                 DoScriptText(SAY_RIZZLE_FINAL, m_creature);
@@ -313,9 +355,12 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
                 m_creature->RemoveAurasDueToSpell(SPELL_PERIODIC_DEPTH_CHARGE);
                 Reached = true;
             }
+
             Check_Timer = 1000;
         } else Check_Timer -= diff;
+
     }
+
     void SendText(const char *text, Player* pPlayer)
     {
         WorldPacket data(SMSG_SERVER_MESSAGE, 0);              // guess size
@@ -323,10 +368,12 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
         if (pPlayer)
             pPlayer->GetSession()->SendPacket(&data);
     }
+
     void AttackStart(Unit *who)
     {
         if (!who || PlayerGUID)
             return;
+
         if (who->GetTypeId() == TYPEID_PLAYER && CAST_PLR(who)->GetQuestStatus(10994) == QUEST_STATUS_INCOMPLETE)
         {
             PlayerGUID = who->GetGUID();
@@ -335,20 +382,26 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
             return;
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
             return;
+
         if (id == 57)
         {
             m_creature->ForcedDespawn();
             return;
         }
+
         ++CurrWP;
         ContinueWP = true;
     }
+
 };
+
 bool GossipHello_mob_rizzle_sprysprocket(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(10994) != QUEST_STATUS_INCOMPLETE)
@@ -357,6 +410,7 @@ bool GossipHello_mob_rizzle_sprysprocket(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(10811, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_mob_rizzle_sprysprocket(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1 && pPlayer->GetQuestStatus(10994) == QUEST_STATUS_INCOMPLETE)
@@ -368,18 +422,23 @@ bool GossipSelect_mob_rizzle_sprysprocket(Player* pPlayer, Creature* pCreature,
     }
     return true;
 }
+
 CreatureAI* GetAI_mob_rizzle_sprysprocket(Creature* pCreature)
 {
     return new mob_rizzle_sprysprocketAI (pCreature);
 }
+
 /*####
 # mob_depth_charge
 ####*/
+
 struct TRINITY_DLL_DECL mob_depth_chargeAI : public ScriptedAI
 {
     mob_depth_chargeAI(Creature *c) : ScriptedAI(c) {}
+
     bool we_must_die;
     uint32 must_die_timer;
+
     void Reset()
     {
         m_creature->SetUnitMovementFlags(MOVEMENTFLAG_HOVER | MOVEMENTFLAG_SWIMMING);
@@ -387,6 +446,7 @@ struct TRINITY_DLL_DECL mob_depth_chargeAI : public ScriptedAI
         we_must_die = false;
         must_die_timer = 1000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (we_must_die)
@@ -396,10 +456,12 @@ struct TRINITY_DLL_DECL mob_depth_chargeAI : public ScriptedAI
             } else must_die_timer -= diff;
         return;
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who)
             return;
+
         if (who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 5))
         {
             DoCast(who, SPELL_DEPTH_CHARGE_TRAP);
@@ -407,37 +469,45 @@ struct TRINITY_DLL_DECL mob_depth_chargeAI : public ScriptedAI
             return;
         }
     }
+
     void AttackStart(Unit *who)
     {
         return;
     }
+
     void EnterCombat(Unit* who)
     {
         return;
     }
 };
+
 CreatureAI* GetAI_mob_depth_charge(Creature* pCreature)
 {
     return new mob_depth_chargeAI (pCreature);
 }
+
 void AddSC_azshara()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mobs_spitelashes";
     newscript->GetAI = &GetAI_mobs_spitelashes;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_loramus_thalipedes";
     newscript->pGossipHello =  &GossipHello_npc_loramus_thalipedes;
     newscript->pGossipSelect = &GossipSelect_npc_loramus_thalipedes;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_rizzle_sprysprocket";
     newscript->GetAI = &GetAI_mob_rizzle_sprysprocket;
     newscript->pGossipHello =  &GossipHello_mob_rizzle_sprysprocket;
     newscript->pGossipSelect = &GossipSelect_mob_rizzle_sprysprocket;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_depth_charge";
     newscript->GetAI = &GetAI_mob_depth_charge;
diff --git a/src/bindings/scripts/scripts/kalimdor/azuremyst_isle.cpp b/src/bindings/scripts/scripts/kalimdor/azuremyst_isle.cpp
index 9dfd5f1cdfa..76d7ff0e4af 100644
--- a/src/bindings/scripts/scripts/kalimdor/azuremyst_isle.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/azuremyst_isle.cpp
@@ -13,12 +13,14 @@
  * along 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, 9582, 9554, 9531, 9303(special flight path, proper model for mount missing). Injured Draenei cosmetic only
 SDCategory: Azuremyst Isle
 EndScriptData */
+
 /* ContentData
 npc_draenei_survivor
 npc_engineer_spark_overgrind
@@ -27,68 +29,90 @@ npc_magwin
 npc_geezle
 mob_nestlewood_owlkin
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include 
+
 /*######
 ## npc_draenei_survivor
 ######*/
+
 enum eEnums
 {
     SAY_HEAL1           = -1000248,
     SAY_HEAL2           = -1000249,
     SAY_HEAL3           = -1000250,
     SAY_HEAL4           = -1000251,
+
     SAY_HELP1           = -1000252,
     SAY_HELP2           = -1000253,
     SAY_HELP3           = -1000254,
     SAY_HELP4           = -1000255,
+
     SPELL_IRRIDATION    = 35046,
     SPELL_STUNNED       = 28630
 };
+
 struct TRINITY_DLL_DECL npc_draenei_survivorAI : public ScriptedAI
 {
     npc_draenei_survivorAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 pCaster;
+
     uint32 SayThanksTimer;
     uint32 RunAwayTimer;
     uint32 SayHelpTimer;
+
     bool CanSayHelp;
+
     void Reset()
     {
         pCaster = 0;
+
         SayThanksTimer = 0;
         RunAwayTimer = 0;
         SayHelpTimer = 10000;
+
         CanSayHelp = true;
+
         m_creature->CastSpell(m_creature, SPELL_IRRIDATION, true);
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
         m_creature->SetHealth(int(m_creature->GetMaxHealth()*.1));
         m_creature->SetStandState(UNIT_STAND_STATE_SLEEP);
     }
+
     void EnterCombat(Unit *who) {}
+
     void MoveInLineOfSight(Unit *who)
     {
         if (CanSayHelp && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsFriendlyTo(who) && m_creature->IsWithinDistInMap(who, 25.0f))
         {
             //Random switch between 4 texts
             DoScriptText(RAND(SAY_HELP1, SAY_HELP2, SAY_HELP3, SAY_HELP4), m_creature, who);
+
             SayHelpTimer = 20000;
             CanSayHelp = false;
         }
     }
+
     void SpellHit(Unit *Caster, const SpellEntry *Spell)
     {
         if (Spell->SpellFamilyFlags[2] & 0x080000000)
         {
             m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
             m_creature->SetStandState(UNIT_STAND_STATE_STAND);
+
             m_creature->CastSpell(m_creature, SPELL_STUNNED, true);
+
             pCaster = Caster->GetGUID();
+
             SayThanksTimer = 5000;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (SayThanksTimer)
@@ -96,26 +120,34 @@ struct TRINITY_DLL_DECL npc_draenei_survivorAI : public ScriptedAI
             if (SayThanksTimer <= diff)
             {
                 m_creature->RemoveAurasDueToSpell(SPELL_IRRIDATION);
+
                 if (Player* pPlayer = Unit::GetPlayer(pCaster))
                 {
                     DoScriptText(RAND(SAY_HEAL1, SAY_HEAL2, SAY_HEAL3, SAY_HEAL4), m_creature, pPlayer);
+
                     pPlayer->TalkedToCreature(m_creature->GetEntry(),m_creature->GetGUID());
                 }
+
                 m_creature->GetMotionMaster()->Clear();
                 m_creature->GetMotionMaster()->MovePoint(0, -4115.053711f, -13754.831055f, 73.508949f);
+
                 RunAwayTimer = 10000;
                 SayThanksTimer = 0;
             }else SayThanksTimer -= diff;
+
             return;
         }
+
         if (RunAwayTimer)
         {
             if (RunAwayTimer <= diff)
                 m_creature->ForcedDespawn();
             else
                 RunAwayTimer -= diff;
+
             return;
         }
+
         if (SayHelpTimer < diff)
         {
             CanSayHelp = true;
@@ -127,47 +159,61 @@ CreatureAI* GetAI_npc_draenei_survivor(Creature* pCreature)
 {
     return new npc_draenei_survivorAI (pCreature);
 }
+
 /*######
 ## npc_engineer_spark_overgrind
 ######*/
+
 enum eOvergrind
 {
     SAY_TEXT        = -1000256,
     SAY_EMOTE       = -1000257,
     ATTACK_YELL     = -1000258,
+
     AREA_COVE       = 3579,
     AREA_ISLE       = 3639,
     QUEST_GNOMERCY  = 9537,
     FACTION_HOSTILE = 14,
     SPELL_DYNAMITE  = 7978
 };
+
 #define GOSSIP_FIGHT "Traitor! You will be brought to justice!"
+
 struct TRINITY_DLL_DECL npc_engineer_spark_overgrindAI : public ScriptedAI
 {
     npc_engineer_spark_overgrindAI(Creature *c) : ScriptedAI(c)
     {
         NormFaction = c->getFaction();
         NpcFlags = c->GetUInt32Value(UNIT_NPC_FLAGS);
+
         if (c->GetAreaId() == AREA_COVE || c->GetAreaId() == AREA_ISLE)
             IsTreeEvent = true;
     }
+
     uint32 NormFaction;
     uint32 NpcFlags;
+
     uint32 Dynamite_Timer;
     uint32 Emote_Timer;
+
     bool IsTreeEvent;
+
     void Reset()
     {
         Dynamite_Timer = 8000;
         Emote_Timer = 120000 + rand()%30000;
+
         m_creature->setFaction(NormFaction);
         m_creature->SetUInt32Value(UNIT_NPC_FLAGS, NpcFlags);
+
         IsTreeEvent = false;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(ATTACK_YELL, m_creature, who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->isInCombat() && !IsTreeEvent)
@@ -181,27 +227,34 @@ struct TRINITY_DLL_DECL npc_engineer_spark_overgrindAI : public ScriptedAI
         }
         else if (IsTreeEvent)
             return;
+
         if (!UpdateVictim())
             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* pCreature)
 {
     return new npc_engineer_spark_overgrindAI (pCreature);
 }
+
 bool GossipHello_npc_engineer_spark_overgrind(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_GNOMERCY) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_FIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_engineer_spark_overgrind(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
@@ -212,12 +265,15 @@ bool GossipSelect_npc_engineer_spark_overgrind(Player* pPlayer, Creature* pCreat
     }
     return true;
 }
+
 /*######
 ## npc_injured_draenei
 ######*/
+
 struct TRINITY_DLL_DECL npc_injured_draeneiAI : public ScriptedAI
 {
     npc_injured_draeneiAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
@@ -228,23 +284,29 @@ struct TRINITY_DLL_DECL npc_injured_draeneiAI : public ScriptedAI
             case 1: m_creature->SetStandState(UNIT_STAND_STATE_SLEEP); break;
         }
     }
+
     void EnterCombat(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* pCreature)
 {
     return new npc_injured_draeneiAI (pCreature);
 }
+
 /*######
 ## npc_magwin
 ######*/
+
 enum eMagwin
 {
     SAY_START                   = -1000111,
@@ -253,17 +315,22 @@ enum eMagwin
     SAY_END1                    = -1000114,
     SAY_END2                    = -1000115,
     EMOTE_HUG                   = -1000116,
+
     QUEST_A_CRY_FOR_SAY_HELP    = 9528
 };
+
 struct TRINITY_DLL_DECL npc_magwinAI : public npc_escortAI
 {
     npc_magwinAI(Creature *c) : npc_escortAI(c) {}
 
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
         case 0:
@@ -282,12 +349,15 @@ struct TRINITY_DLL_DECL npc_magwinAI : public npc_escortAI
             break;
         }
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature, who);
     }
+
     void Reset() { }
 };
+
 bool QuestAccept_npc_magwin(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_A_CRY_FOR_SAY_HELP)
@@ -298,17 +368,22 @@ bool QuestAccept_npc_magwin(Player* pPlayer, Creature* pCreature, Quest const* q
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_magwinAI(Creature* pCreature)
 {
     return new npc_magwinAI(pCreature);
 }
+
 /*######
 ## npc_geezle
 ######*/
+
 enum eGeezle
 {
     QUEST_TREES_COMPANY = 9531,
+
     SPELL_TREE_DISGUISE = 30298,
+
     GEEZLE_SAY_1    = -1000259,
     SPARK_SAY_2     = -1000260,
     SPARK_SAY_3     = -1000261,
@@ -316,25 +391,35 @@ enum eGeezle
     SPARK_SAY_5     = -1000263,
     SPARK_SAY_6     = -1000264,
     GEEZLE_SAY_7    = -1000265,
+
     EMOTE_SPARK     = -1000266,
+
     MOB_SPARK       = 17243,
     GO_NAGA_FLAG    = 181694
 };
+
 static float SparkPos[3] = {-5029.91, -11291.79, 8.096};
+
 struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
 {
     npc_geezleAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 SparkGUID;
+
     uint32 Step;
     uint32 SayTimer;
+
     bool EventStarted;
+
     void Reset()
     {
         SparkGUID = 0;
         Step = 0;
         StartEvent();
     }
+
     void EnterCombat(Unit* who){}
+
     void StartEvent()
     {
         Step = 0;
@@ -348,9 +433,11 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
         }
         SayTimer = 8000;
     }
+
     uint32 NextStep(uint32 Step)
     {
         Creature* Spark = Unit::GetCreature(*m_creature, SparkGUID);
+
         switch(Step)
         {
         case 0:
@@ -390,6 +477,7 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
         default: return 99999999;
         }
     }
+
     // will complete Tree's company quest for all nearby players that are disguised as trees
     void CompleteQuest()
     {
@@ -398,7 +486,8 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
         Trinity::AnyPlayerInObjectRangeCheck checker(m_creature, radius);
         Trinity::PlayerListSearcher searcher(m_creature, players, checker);
         m_creature->VisitNearbyWorldObject(radius, searcher);
-        for (std::list::iterator itr = players.begin(); itr != players.end(); ++itr)
+
+        for(std::list::iterator itr = players.begin(); itr != players.end(); ++itr)
         {
             if((*itr)->GetQuestStatus(QUEST_TREES_COMPANY)==QUEST_STATUS_INCOMPLETE
                 &&(*itr)->HasAuraEffect(SPELL_TREE_DISGUISE,3) )
@@ -407,13 +496,15 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
             }
         }
     }
+
     void DespawnNagaFlag(bool despawn)
     {
         std::list FlagList;
         m_creature->GetGameObjectListWithEntryInGrid(FlagList,GO_NAGA_FLAG, 100.0f);
+
         if (!FlagList.empty())
         {
-            for (std::list::iterator itr = FlagList.begin(); itr != FlagList.end(); ++itr)
+            for(std::list::iterator itr = FlagList.begin(); itr != FlagList.end(); ++itr)
             {
                 if (despawn)
                 {
@@ -424,6 +515,7 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
             }
         } else error_log("SD2 ERROR: FlagList is empty!");
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (SayTimer < diff)
@@ -435,27 +527,34 @@ struct TRINITY_DLL_DECL npc_geezleAI : public ScriptedAI
         }else SayTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_npc_geezleAI(Creature* pCreature)
 {
     return new npc_geezleAI(pCreature);
 }
+
 /*######
 ## mob_nestlewood_owlkin
 ######*/
+
 enum eOwlkin
 {
     SPELL_INOCULATE_OWLKIN  = 29528,
     ENTRY_OWLKIN            = 16518,
     ENTRY_OWLKIN_INOC       = 16534
 };
+
 struct TRINITY_DLL_DECL npc_nestlewood_owlkinAI : public ScriptedAI
 {
     npc_nestlewood_owlkinAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 DespawnTimer;
+
     void Reset()
     {
         DespawnTimer = 0;
     }
+
     void UpdateAI(const uint32 diff)
     {
         //timer gets adjusted by the triggered aura effect
@@ -468,15 +567,19 @@ struct TRINITY_DLL_DECL npc_nestlewood_owlkinAI : public ScriptedAI
                 return;
             }else DespawnTimer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_nestlewood_owlkinAI(Creature* pCreature)
 {
     return new npc_nestlewood_owlkinAI (pCreature);
 }
+
 bool EffectDummyCreature_npc_nestlewood_owlkin(Unit *pCaster, uint32 spellId, uint32 effIndex, Creature *pCreatureTarget)
 {
     //always check spellid and effectindex
@@ -484,40 +587,50 @@ bool EffectDummyCreature_npc_nestlewood_owlkin(Unit *pCaster, uint32 spellId, ui
     {
         if (pCreatureTarget->GetEntry() != ENTRY_OWLKIN)
             return true;
+
         pCreatureTarget->UpdateEntry(ENTRY_OWLKIN_INOC);
+
         //set despawn timer, since we want to remove Creature after a short time
         CAST_AI(npc_nestlewood_owlkinAI, pCreatureTarget->AI())->DespawnTimer = 15000;
+
         //always return true when we are handling this spell and effect
         return true;
     }
     return false;
 }
+
 void AddSC_azuremyst_isle()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_draenei_survivor";
     newscript->GetAI = &GetAI_npc_draenei_survivor;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_injured_draenei";
     newscript->GetAI = &GetAI_npc_injured_draenei;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_magwin";
     newscript->GetAI = &GetAI_npc_magwinAI;
     newscript->pQuestAccept = &QuestAccept_npc_magwin;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_geezle";
     newscript->GetAI = &GetAI_npc_geezleAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_nestlewood_owlkin";
     newscript->GetAI = &GetAI_npc_nestlewood_owlkinAI;
diff --git a/src/bindings/scripts/scripts/kalimdor/blackfathom_depths/def_blackfathom_deeps.h b/src/bindings/scripts/scripts/kalimdor/blackfathom_depths/def_blackfathom_deeps.h
index 20cf6610a94..097554708b7 100644
--- a/src/bindings/scripts/scripts/kalimdor/blackfathom_depths/def_blackfathom_deeps.h
+++ b/src/bindings/scripts/scripts/kalimdor/blackfathom_depths/def_blackfathom_deeps.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_BFD_H
 #define DEF_BFD_H
+
 enum eEnums
 {
     DATA_SHRINE1                = 1,
@@ -13,7 +15,9 @@ enum eEnums
     DATA_SHRINE_OF_GELIHAST     = 6,
     DATA_ALTAR_OF_THE_DEEPS     = 7,
     DATA_MAINDOOR               = 8,
+
     TYPE_KELRIS                 = 10,
     TYPE_SHRINE                 = 11
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/kalimdor/blackfathom_depths/instance_blackfathom_deeps.cpp b/src/bindings/scripts/scripts/kalimdor/blackfathom_depths/instance_blackfathom_deeps.cpp
index 36277c56450..0845396ffa3 100644
--- a/src/bindings/scripts/scripts/kalimdor/blackfathom_depths/instance_blackfathom_deeps.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/blackfathom_depths/instance_blackfathom_deeps.cpp
@@ -13,22 +13,28 @@
  * along 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_Blackfathom_Deeps
 SD%Complete: 50
 SDComment:
 SDCategory: Blackfathom Deeps
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_blackfathom_deeps.h"
+
 #define MAX_ENCOUNTER 2
+
 /* Encounter 0 = Twilight Lord Kelris
    Encounter 1 = Shrine event
    Must kill twilight lord for shrine event to be possible
  */
+
 struct TRINITY_DLL_DECL instance_blackfathom_deeps : public ScriptedInstance
 {
     instance_blackfathom_deeps(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 m_uiTwilightLordKelrisGUID;
     uint64 m_uiShrine1GUID;
     uint64 m_uiShrine2GUID;
@@ -37,10 +43,13 @@ struct TRINITY_DLL_DECL instance_blackfathom_deeps : public ScriptedInstance
     uint64 m_uiShrineOfGelihastGUID;
     uint64 m_uiAltarOfTheDeepsGUID;
     uint64 m_uiMainDoorGUID;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         m_uiTwilightLordKelrisGUID = 0;
         m_uiShrine1GUID = 0;
         m_uiShrine2GUID = 0;
@@ -50,11 +59,13 @@ struct TRINITY_DLL_DECL instance_blackfathom_deeps : public ScriptedInstance
         m_uiAltarOfTheDeepsGUID = 0;
         m_uiMainDoorGUID = 0;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         if (pCreature->GetEntry() == 4832)
             m_uiTwilightLordKelrisGUID = pCreature->GetGUID();
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -68,6 +79,7 @@ struct TRINITY_DLL_DECL instance_blackfathom_deeps : public ScriptedInstance
             case 21117:     m_uiMainDoorGUID = pGo->GetGUID();          break;
         }
     }
+
     void SetData(uint32 uiType, uint32 uiData)
     {
         switch(uiType)
@@ -80,6 +92,7 @@ struct TRINITY_DLL_DECL instance_blackfathom_deeps : public ScriptedInstance
                 break;
         }
     }
+
     uint32 GetData(uint32 uiType)
     {
         switch(uiType)
@@ -89,8 +102,10 @@ struct TRINITY_DLL_DECL instance_blackfathom_deeps : public ScriptedInstance
             case TYPE_SHRINE:
                 return m_auiEncounter[1];
         }
+
         return 0;
     }
+
     uint64 GetData64(uint32 uiData)
     {
         switch(uiData)
@@ -110,8 +125,10 @@ struct TRINITY_DLL_DECL instance_blackfathom_deeps : public ScriptedInstance
             case DATA_MAINDOOR:
                 return m_uiMainDoorGUID;
         }
+
         return 0;
     }
+
     void CheckFires()
     {
         GameObject *pShrine1 = instance->GetGameObject(m_uiShrine1GUID);
@@ -125,13 +142,16 @@ struct TRINITY_DLL_DECL instance_blackfathom_deeps : public ScriptedInstance
             HandleGameObject(m_uiMainDoorGUID,true);
     }
 };
+
 InstanceData* GetInstanceData_instance_blackfathom_deeps(Map* pMap)
 {
     return new instance_blackfathom_deeps(pMap);
 }
+
 bool GoHello_fire(Player *pPlayer, GameObject* pGo)
 {
     ScriptedInstance *pInstance = pGo->GetInstanceData();
+
     if (pInstance)
     {
         pGo->SetGoState(GO_STATE_ACTIVE);
@@ -139,6 +159,7 @@ bool GoHello_fire(Player *pPlayer, GameObject* pGo)
     }
     return false;
 }
+
 void AddSC_instance_blackfathom_deeps()
 {
     Script *newscript;
@@ -146,6 +167,7 @@ void AddSC_instance_blackfathom_deeps()
     newscript->Name = "instance_blackfathom_deeps";
     newscript->GetInstanceData = &GetInstanceData_instance_blackfathom_deeps;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_blackfathom_fire";
     newscript->pGOHello = &GoHello_fire;
diff --git a/src/bindings/scripts/scripts/kalimdor/bloodmyst_isle.cpp b/src/bindings/scripts/scripts/kalimdor/bloodmyst_isle.cpp
index 774094b49ac..5dce0a0e9d9 100644
--- a/src/bindings/scripts/scripts/kalimdor/bloodmyst_isle.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/bloodmyst_isle.cpp
@@ -13,34 +13,44 @@
  * along 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 TRINITY_DLL_DECL mob_webbed_creatureAI : public ScriptedAI
 {
     mob_webbed_creatureAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
     }
+
     void EnterCombat(Unit* who)
     {
     }
+
     void JustDied(Unit* Killer)
     {
         uint32 spawnCreatureID = 0;
+
         switch(rand()%3)
         {
             case 0:
@@ -53,6 +63,7 @@ struct TRINITY_DLL_DECL mob_webbed_creatureAI : public ScriptedAI
                 spawnCreatureID = possibleSpawns[rand()%31];
                 break;
         }
+
         if (spawnCreatureID)
             m_creature->SummonCreature(spawnCreatureID, 0.0f, 0.0f, 0.0f, m_creature->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
     }
@@ -61,16 +72,20 @@ CreatureAI* GetAI_mob_webbed_creature(Creature* pCreature)
 {
     return new mob_webbed_creatureAI (pCreature);
 }
+
 /*######
 ## npc_captured_sunhawk_agent
 ######*/
+
 #define C_SUNHAWK_TRIGGER 17974
+
 #define GOSSIP_HELLO_CSA     "[PH] "
 #define GOSSIP_SELECT_CSA1   "[PH] "
 #define GOSSIP_SELECT_CSA2   "[PH] "
 #define GOSSIP_SELECT_CSA3   "[PH] "
 #define GOSSIP_SELECT_CSA4   "[PH] "
 #define GOSSIP_SELECT_CSA5   "[PH] "
+
 bool GossipHello_npc_captured_sunhawk_agent(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->HasAura(31609) && pPlayer->GetQuestStatus(9756) == QUEST_STATUS_INCOMPLETE)
@@ -80,8 +95,10 @@ bool GossipHello_npc_captured_sunhawk_agent(Player* pPlayer, Creature* pCreature
     }
     else
         pPlayer->SEND_GOSSIP_MENU(9134, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_captured_sunhawk_agent(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -113,13 +130,16 @@ bool GossipSelect_npc_captured_sunhawk_agent(Player* pPlayer, Creature* pCreatur
     }
     return true;
 }
+
 void AddSC_bloodmyst_isle()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_webbed_creature";
     newscript->GetAI = &GetAI_mob_webbed_creature;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_captured_sunhawk_agent";
     newscript->pGossipHello =  &GossipHello_npc_captured_sunhawk_agent;
diff --git a/src/bindings/scripts/scripts/kalimdor/boss_azuregos.cpp b/src/bindings/scripts/scripts/kalimdor/boss_azuregos.cpp
index 629541b0d91..56efc4f71cf 100644
--- a/src/bindings/scripts/scripts/kalimdor/boss_azuregos.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/boss_azuregos.cpp
@@ -13,14 +13,18 @@
  * along with 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 SAY_TELEPORT            -1000100
+
 #define SPELL_MARKOFFROST        23182
 #define SPELL_MANASTORM          21097
 #define SPELL_CHILL              21098
@@ -28,9 +32,11 @@ EndScriptData */
 #define SPELL_REFLECT            22067
 #define SPELL_CLEAVE              8255                      //Perhaps not right ID
 #define SPELL_ENRAGE             23537
+
 struct TRINITY_DLL_DECL boss_azuregosAI : public ScriptedAI
 {
     boss_azuregosAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 MarkOfFrost_Timer;
     uint32 ManaStorm_Timer;
     uint32 Chill_Timer;
@@ -40,6 +46,7 @@ struct TRINITY_DLL_DECL boss_azuregosAI : public ScriptedAI
     uint32 Cleave_Timer;
     uint32 Enrage_Timer;
     bool Enraged;
+
     void Reset()
     {
         MarkOfFrost_Timer = 35000;
@@ -52,12 +59,15 @@ struct TRINITY_DLL_DECL boss_azuregosAI : public ScriptedAI
         Enrage_Timer = 0;
         Enraged = false;
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (Teleport_Timer < diff)
         {
             DoScriptText(SAY_TELEPORT, m_creature);
@@ -71,27 +81,32 @@ struct TRINITY_DLL_DECL boss_azuregosAI : public ScriptedAI
                     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)
         {
@@ -99,24 +114,28 @@ struct TRINITY_DLL_DECL boss_azuregosAI : public ScriptedAI
                 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();
     }
 };
@@ -124,6 +143,7 @@ CreatureAI* GetAI_boss_azuregos(Creature* pCreature)
 {
     return new boss_azuregosAI (pCreature);
 }
+
 void AddSC_boss_azuregos()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_epoch.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_epoch.cpp
index 830b3f55e08..3d9c1c3fcbf 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_epoch.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_epoch.cpp
@@ -5,16 +5,19 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Spells
 #define SPELL_CURSE_OF_EXERTION                   52772
 #define SPELL_TIME_WARP                           52766 //Time slows down, reducing attack, casting and movement speed by 70% for 6 sec.
 #define SPELL_TIME_STOP                           58848 //Stops time in a 50 yard sphere for 2 sec.
 #define SPELL_WOUNDING_STRIKE_N                   52771 //Used only on the tank
 #define SPELL_WOUNDING_STRIKE_H                   58830
+
 //not in db
 //Say
 #define SAY_INTRO                                -1595000 //"Prince Arthas Menethil, on this day, a powerful darkness has taken hold of your soul. The death you are destined to visit upon others will this day be your own."
@@ -26,14 +29,18 @@ update creature_template set scriptname = '' where entry = '';
 #define SAY_SLAY_2                               -1595006 //"This is the hour of our greatest triumph!"
 #define SAY_SLAY_3                               -1595007 //"You were destined to fail. "
 #define SAY_DEATH                                -1595008 //"*gurgles*"
+
 struct TRINITY_DLL_DECL boss_epochAI : public ScriptedAI
 {
     boss_epochAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
     void UpdateAI(const uint32 diff)
@@ -41,26 +48,33 @@ struct TRINITY_DLL_DECL boss_epochAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_epoch(Creature* pCreature)
 {
     return new boss_epochAI (pCreature);
 }
+
 void AddSC_boss_epoch()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_epoch";
     newscript->GetAI = &GetAI_boss_epoch;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_mal_ganis.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_mal_ganis.cpp
index 9d6375b870a..b94d01ce4de 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_mal_ganis.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_mal_ganis.cpp
@@ -5,10 +5,12 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_mal_ganis' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Spells
 #define SPELL_CARRION_SWARM_N                         52720 //A cresting wave of chaotic magic splashes over enemies in front of the caster, dealing 3230 to 3570 Shadow damage and 380 to 420 Shadow damage every 3 sec. for 15 sec.
 #define SPELL_CARRION_SWARM_H                         58852
@@ -16,6 +18,7 @@ update creature_template set scriptname = 'boss_mal_ganis' where entry = '';
 #define SPELL_MIND_BLAST_H                            58850
 #define SPELL_SLEEP                                   52721 //Puts an enemy to sleep for up to 10 sec. Any damage caused will awaken the target.
 #define SPELL_VAMPIRIC_TOUCH                          52723 //Heals the caster for half the damage dealt by a melee attack.
+
 //not in db
 //Yell Mal'ganis
 #define SAY_INTRO_1                                  -1595009
@@ -35,22 +38,27 @@ update creature_template set scriptname = 'boss_mal_ganis' where entry = '';
 #define SAY_15HEALTH                                 -1595023
 #define SAY_ESCAPE_SPEECH_1                          -1595024
 #define SAY_ESCAPE_SPEECH_2                          -1595025
+
 struct TRINITY_DLL_DECL boss_mal_ganisAI : public ScriptedAI
 {
     boss_mal_ganisAI(Creature *c) : ScriptedAI(c) {}
+
     bool yelled,
          yelled2,
          yelled3;
+
     void Reset()
     {
          yelled = false;
          yelled2 = false;
          yelled3 = false;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
     void UpdateAI(const uint32 diff)
@@ -58,6 +66,7 @@ struct TRINITY_DLL_DECL boss_mal_ganisAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (!yelled)
         {
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30)
@@ -66,6 +75,7 @@ struct TRINITY_DLL_DECL boss_mal_ganisAI : public ScriptedAI
                 yelled = true;
             }
         }
+
         if (!yelled2)
         {
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 15)
@@ -74,10 +84,12 @@ struct TRINITY_DLL_DECL boss_mal_ganisAI : public ScriptedAI
                 yelled2 = true;
             }
         }
+
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 1)
         {
             //Handle Escape Event
         }
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)  {}
@@ -85,16 +97,20 @@ struct TRINITY_DLL_DECL boss_mal_ganisAI : public ScriptedAI
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3,SAY_SLAY_4), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_mal_ganis(Creature* pCreature)
 {
     return new boss_mal_ganisAI (pCreature);
 }
+
 void AddSC_boss_mal_ganis()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_mal_ganis";
     newscript->GetAI = &GetAI_boss_mal_ganis;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_meathook.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_meathook.cpp
index 2a14cec9350..261ed4a5ca0 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_meathook.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_meathook.cpp
@@ -5,16 +5,19 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_meathook' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Spell
 #define SPELL_CONSTRICTING_CHAINS_N                  52696 //Encases the targets in chains, dealing 1800 Physical damage every 1 sec. and stunning the target for 5 sec.
 #define SPELL_CONSTRICTING_CHAINS_H                  58823
 #define SPELL_DISEASE_EXPULSION_N                    52666 //Meathook belches out a cloud of disease, dealing 1710 to 1890 Nature damage and interrupting the spell casting of nearby enemy targets for 4 sec.
 #define SPELL_DISEASE_EXPULSION_H                    58824
 #define SPELL_FRENZY                                 58841 //Increases the caster's Physical damage by 10% for 30 sec.
+
 //not in db
 //Yell
 #define SAY_AGGRO                                 -1595026
@@ -23,23 +26,29 @@ update creature_template set scriptname = 'boss_meathook' where entry = '';
 #define SAY_SLAY_3                                -1595029
 #define SAY_SPAWN                                 -1595030
 #define SAY_DEATH                                 -1595031
+
 struct TRINITY_DLL_DECL boss_meathookAI : public ScriptedAI
 {
     boss_meathookAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Chain_Timer,
            Disease_Timer,
            Frenzy_Timer;
+
     void Reset()
     {
         Chain_Timer =   12000 + rand()%5000;   //seen on video 13, 17, 15, 12, 16
         Disease_Timer =  2000 + rand()%1000;  //approx 3s
         Frenzy_Timer =  20000 + rand()%10000; //made it up
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void AttackStart(Unit* who) {}
+
     std::list pList;
     void MoveInLineOfSight(Unit* who, const uint32 diff)
     {
@@ -48,62 +57,76 @@ struct TRINITY_DLL_DECL boss_meathookAI : public ScriptedAI
         pList.append(who);
         }*/
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (Disease_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_DISEASE_EXPULSION_N);
             Disease_Timer = 1500 + rand()%2500;
         }else Disease_Timer -= diff;
+
         if (Frenzy_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_FRENZY);
             Frenzy_Timer = 20000 + rand()%10000;
         }else Frenzy_Timer -= diff;
+
         if (Chain_Timer < diff)
         {
+
         /*
             std::list& m_threatlist = m_creature->getThreatManager().getThreatList();
             std::list::iterator itr;
+
             int st=0;
-            for (itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr)
+            for(itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr)
             {
                 //st++;
                 m_creature->getThreatManager().
             }
             Unit* targets[st];
             int st2=0;
-            for (int i=1; i<=st; ++i){
+            for(int i=1; i<=st; ++i){
                 if (!IsWithinLOSInMap(targets[i])
                     st2++;
             }
             Unit* targets_out_of_LOS[st2];*/
+
             DoCast(SelectUnit(SELECT_TARGET_RANDOM, 1), SPELL_CONSTRICTING_CHAINS_N); //anyone but the tank
             Chain_Timer = 2000 + rand()%1000;
         }else Chain_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_meathook(Creature* pCreature)
 {
     return new boss_meathookAI (pCreature);
 }
+
 void AddSC_boss_meathook()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_meathook";
     newscript->GetAI = &GetAI_boss_meathook;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_salramm.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_salramm.cpp
index 6829cd70dd2..2982eb5a1b8 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_salramm.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_salramm.cpp
@@ -5,10 +5,12 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_salramm' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Spells
 #define SPELL_CURSE_OF_TWISTED_FLESH                58845
 #define SPELL_EXPLODE_GHOUL_N                       52480
@@ -17,6 +19,7 @@ update creature_template set scriptname = 'boss_salramm' where entry = '';
 #define SPELL_SHADOW_BOLT_H                         58828
 #define SPELL_STEAL_FLESH                           52708
 #define SPELL_SUMMON_GHOULS                         52451
+
 //not in db
 //Yell
 #define SAY_AGGRO                                -1595032
@@ -32,14 +35,17 @@ update creature_template set scriptname = 'boss_salramm' where entry = '';
 #define SAY_STEAL_FLESH_3                        -1595042
 #define SAY_SUMMON_GHOULS_1                      -1595043
 #define SAY_SUMMON_GHOULS_2                      -1595044
+
 struct TRINITY_DLL_DECL boss_salrammAI : public ScriptedAI
 {
     boss_salrammAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Curse_flesh_Timer,
            Explode_ghoul_Timer,
            Shadow_bolt_Timer,
            Steal_flesh_Timer,
            Summon_ghouls_Timer;
+
     void Reset()
     {
          Curse_flesh_Timer =   30000;  //30s DBM
@@ -48,8 +54,10 @@ struct TRINITY_DLL_DECL boss_salrammAI : public ScriptedAI
          Steal_flesh_Timer =   12345;
          Summon_ghouls_Timer = 19000 + rand()%5000; //on a video approx 24s after aggro
     }
+
     void EnterCombat(Unit* who)
         {DoScriptText(SAY_AGGRO, m_creature);}
+
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
     void UpdateAI(const uint32 diff)
@@ -57,13 +65,16 @@ struct TRINITY_DLL_DECL boss_salrammAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         Unit* random_target = SelectUnit(SELECT_TARGET_RANDOM, 0);
+
         //Curse of twisted flesh timer
         if (Curse_flesh_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_CURSE_OF_TWISTED_FLESH);
             Curse_flesh_Timer = 37000;
         }else Curse_flesh_Timer -= diff;
+
         //Shadow bolt timer
         if (Shadow_bolt_Timer < diff)
         {
@@ -71,6 +82,7 @@ struct TRINITY_DLL_DECL boss_salrammAI : public ScriptedAI
                 DoCast(random_target,SPELL_SHADOW_BOLT_N);
             Shadow_bolt_Timer = 8000 + rand()%4000;
         }else Shadow_bolt_Timer -= diff;
+
         //Steal Flesh timer
         if (Steal_flesh_Timer < diff)
         {
@@ -90,6 +102,7 @@ struct TRINITY_DLL_DECL boss_salrammAI : public ScriptedAI
                 DoCast(random_target,SPELL_STEAL_FLESH);
             Steal_flesh_Timer = 10000;
         }else Steal_flesh_Timer -= diff;
+
         //Summon ghouls timer
         if (Summon_ghouls_Timer < diff)
         {
@@ -106,24 +119,31 @@ struct TRINITY_DLL_DECL boss_salrammAI : public ScriptedAI
                 DoCast(random_target,SPELL_SUMMON_GHOULS);
             Summon_ghouls_Timer = 10000;
         }else Summon_ghouls_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {DoScriptText(SAY_DEATH, m_creature);}
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_salramm(Creature* pCreature)
 {
     return new boss_salrammAI (pCreature);
 }
+
 void AddSC_boss_salramm()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_salramm";
     newscript->GetAI = &GetAI_boss_salramm;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/def_culling_of_stratholme.h b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/def_culling_of_stratholme.h
index ae7e93dc32b..849549e8f99 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/def_culling_of_stratholme.h
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/def_culling_of_stratholme.h
@@ -1,3 +1,4 @@
 #ifndef DEF_CULLING_OF_STRATHOLME_H
 #define DEF_CULLING_OF_STRATHOLME_H
+
 #endif
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/instance_culling_of_stratholme.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/instance_culling_of_stratholme.cpp
index 81abb37776c..35ee68ea991 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/instance_culling_of_stratholme.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/culling_of_stratholme/instance_culling_of_stratholme.cpp
@@ -1,13 +1,16 @@
 #include "precompiled.h"
 #include "def_culling_of_stratholme.h"
+
 struct TRINITY_DLL_DECL instance_culling_of_stratholme : public ScriptedInstance
 {
     instance_culling_of_stratholme(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
 };
+
 InstanceData* GetInstanceData_instance_culling_of_stratholme(Map* pMap)
 {
     return new instance_culling_of_stratholme(pMap);
 }
+
 void AddSC_instance_culling_of_stratholme()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_aeonus.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_aeonus.cpp
index b743501788d..ea3bdc45a6f 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_aeonus.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_aeonus.cpp
@@ -13,14 +13,17 @@
  * along with 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: 80
 SDComment: Some spells not implemented
 SDCategory: Caverns of Time, The Dark Portal
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_dark_portal.h"
+
 enum eEnums
 {
     SAY_ENTER           = -1269012,
@@ -30,12 +33,14 @@ enum eEnums
     SAY_SLAY2           = -1269016,
     SAY_DEATH           = -1269017,
     EMOTE_FRENZY        = -1269018,
+
     SPELL_CLEAVE        = 40504,
     SPELL_TIME_STOP     = 31422,
     SPELL_ENRAGE        = 37605,
     SPELL_SAND_BREATH   = 31473,
     H_SPELL_SAND_BREATH = 39049
 };
+
 struct TRINITY_DLL_DECL boss_aeonusAI : public ScriptedAI
 {
     boss_aeonusAI(Creature *c) : ScriptedAI(c)
@@ -43,21 +48,26 @@ struct TRINITY_DLL_DECL boss_aeonusAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance *pInstance;
     bool HeroicMode;
+
     uint32 SandBreath_Timer;
     uint32 TimeStop_Timer;
     uint32 Frenzy_Timer;
+
     void Reset()
     {
         SandBreath_Timer = 15000+rand()%15000;
         TimeStop_Timer = 10000+rand()%5000;
         Frenzy_Timer = 30000+rand()%15000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         //Despawn Time Keeper
@@ -69,38 +79,46 @@ struct TRINITY_DLL_DECL boss_aeonusAI : public ScriptedAI
                 m_creature->DealDamage(who, who->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
             }
         }
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
          if (pInstance)
          {
              pInstance->SetData(TYPE_RIFT,DONE);
              pInstance->SetData(TYPE_MEDIVH,DONE);//FIXME: later should be removed
          }
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Sand Breath
         if (SandBreath_Timer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_SAND_BREATH, H_SPELL_SAND_BREATH));
             SandBreath_Timer = 15000+rand()%10000;
         }else SandBreath_Timer -= diff;
+
         //Time Stop
         if (TimeStop_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_TIME_STOP);
             TimeStop_Timer = 20000+rand()%15000;
         }else TimeStop_Timer -= diff;
+
         //Frenzy
         if (Frenzy_Timer < diff)
         {
@@ -108,13 +126,16 @@ struct TRINITY_DLL_DECL boss_aeonusAI : public ScriptedAI
             DoCast(m_creature, SPELL_ENRAGE);
             Frenzy_Timer = 20000+rand()%15000;
         }else Frenzy_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_aeonus(Creature* pCreature)
 {
     return new boss_aeonusAI (pCreature);
 }
+
 void AddSC_boss_aeonus()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp
index f5dce6ba27c..eb0471fc278 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp
@@ -13,14 +13,17 @@
  * along with 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: 65
 SDComment: All abilities not implemented
 SDCategory: Caverns of Time, The Dark Portal
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_dark_portal.h"
+
 enum eEnums
 {
     SAY_ENTER                   = -1269006,
@@ -29,6 +32,7 @@ enum eEnums
     SAY_SLAY1                   = -1269009,
     SAY_SLAY2                   = -1269010,
     SAY_DEATH                   = -1269011,
+
     SPELL_ARCANE_BLAST          = 31457,
     H_SPELL_ARCANE_BLAST        = 38538,
     SPELL_ARCANE_DISCHARGE      = 31472,
@@ -36,6 +40,7 @@ enum eEnums
     SPELL_TIME_LAPSE            = 31467,
     SPELL_ATTRACTION            = 38540                       //Not Implemented (Heroic mode)
 };
+
 struct TRINITY_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI
 {
     boss_chrono_lord_dejaAI(Creature *c) : ScriptedAI(c)
@@ -43,12 +48,15 @@ struct TRINITY_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance *pInstance;
     bool HeroicMode;
+
     uint32 ArcaneBlast_Timer;
     uint32 TimeLapse_Timer;
     uint32 Attraction_Timer;
     uint32 ArcaneDischarge_Timer;
+
     void Reset()
     {
         ArcaneBlast_Timer = 18000+rand()%5000;
@@ -56,10 +64,12 @@ struct TRINITY_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI
         ArcaneDischarge_Timer = 20000+rand()%10000;
         Attraction_Timer = 25000+rand()%10000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         //Despawn Time Keeper
@@ -71,29 +81,36 @@ struct TRINITY_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI
                 m_creature->DealDamage(who, who->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
             }
         }
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_RIFT,SPECIAL);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Arcane Blast
         if (ArcaneBlast_Timer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_ARCANE_BLAST, H_SPELL_ARCANE_BLAST));
             ArcaneBlast_Timer = 15000+rand()%10000;
         }else ArcaneBlast_Timer -= diff;
+
         //Arcane Discharge
         if (ArcaneDischarge_Timer < diff)
         {
@@ -101,6 +118,7 @@ struct TRINITY_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI
             DoCast(target,HEROIC(SPELL_ARCANE_DISCHARGE, H_SPELL_ARCANE_DISCHARGE));
             ArcaneDischarge_Timer = 20000+rand()%10000;
         }else ArcaneDischarge_Timer -= diff;
+
         //Time Lapse
         if (TimeLapse_Timer < diff)
         {
@@ -108,6 +126,7 @@ struct TRINITY_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI
             DoCast(m_creature, SPELL_TIME_LAPSE);
             TimeLapse_Timer = 15000+rand()%10000;
         }else TimeLapse_Timer -= diff;
+
         if (HeroicMode)
         {
             if (Attraction_Timer < diff)
@@ -116,13 +135,16 @@ struct TRINITY_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI
                 Attraction_Timer = 25000+rand()%10000;
             }else Attraction_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_chrono_lord_deja(Creature* pCreature)
 {
     return new boss_chrono_lord_dejaAI (pCreature);
 }
+
 void AddSC_boss_chrono_lord_deja()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_temporus.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_temporus.cpp
index fda6c49ae94..5b09e4cb117 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_temporus.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/boss_temporus.cpp
@@ -13,14 +13,17 @@
  * along with 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: 75
 SDComment: More abilities need to be implemented
 SDCategory: Caverns of Time, The Dark Portal
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_dark_portal.h"
+
 enum eEnums
 {
     SAY_ENTER               = -1269000,
@@ -29,12 +32,14 @@ enum eEnums
     SAY_SLAY1               = -1269003,
     SAY_SLAY2               = -1269004,
     SAY_DEATH               = -1269005,
+
     SPELL_HASTE             = 31458,
     SPELL_MORTAL_WOUND      = 31464,
     SPELL_WING_BUFFET       = 31475,
     H_SPELL_WING_BUFFET     = 38593,
     SPELL_REFLECT           = 38592                       //Not Implemented (Heroic mod)
 };
+
 struct TRINITY_DLL_DECL boss_temporusAI : public ScriptedAI
 {
     boss_temporusAI(Creature *c) : ScriptedAI(c)
@@ -42,12 +47,15 @@ struct TRINITY_DLL_DECL boss_temporusAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance *pInstance;
     bool HeroicMode;
+
     uint32 Haste_Timer;
     uint32 SpellReflection_Timer;
     uint32 MortalWound_Timer;
     uint32 WingBuffet_Timer;
+
     void Reset()
     {
         Haste_Timer = 15000+rand()%8000;
@@ -55,20 +63,25 @@ struct TRINITY_DLL_DECL boss_temporusAI : public ScriptedAI
         MortalWound_Timer = 8000;
         WingBuffet_Timer = 25000+rand()%10000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_RIFT,SPECIAL);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         //Despawn Time Keeper
@@ -77,34 +90,41 @@ struct TRINITY_DLL_DECL boss_temporusAI : public ScriptedAI
             if (m_creature->IsWithinDistInMap(who,20.0f))
             {
                 DoScriptText(SAY_BANISH, m_creature);
+
                 m_creature->DealDamage(who, who->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
             }
         }
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Attack Haste
         if (Haste_Timer < diff)
         {
             DoCast(m_creature, SPELL_HASTE);
             Haste_Timer = 20000+rand()%5000;
         }else Haste_Timer -= diff;
+
         //MortalWound_Timer
         if (MortalWound_Timer < diff)
         {
             DoCast(m_creature, SPELL_MORTAL_WOUND);
             MortalWound_Timer = 10000+rand()%10000;
         }else MortalWound_Timer -= diff;
+
         //Wing ruffet
         if (WingBuffet_Timer < diff)
         {
             DoCast(m_creature,HEROIC(SPELL_WING_BUFFET, H_SPELL_WING_BUFFET));
             WingBuffet_Timer = 20000+rand()%10000;
         }else WingBuffet_Timer -= diff;
+
         if (HeroicMode)
         {
             if (SpellReflection_Timer < diff)
@@ -113,13 +133,16 @@ struct TRINITY_DLL_DECL boss_temporusAI : public ScriptedAI
                 SpellReflection_Timer = 25000+rand()%10000;
             }else SpellReflection_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_temporus(Creature* pCreature)
 {
     return new boss_temporusAI (pCreature);
 }
+
 void AddSC_boss_temporus()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/dark_portal.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/dark_portal.cpp
index b8721cd8666..6984f287950 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/dark_portal.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/dark_portal.cpp
@@ -13,19 +13,23 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: Dark_Portal
 SD%Complete: 30
 SDComment: Misc NPC's and mobs for instance. Most here far from complete.
 SDCategory: Caverns of Time, The Dark Portal
 EndScriptData */
+
 /* ContentData
 npc_medivh_bm
 npc_time_rift
 npc_saat
 EndContentData */
+
 #include "precompiled.h"
 #include "def_dark_portal.h"
+
 #define SAY_ENTER               -1269020                    //where does this belong?
 #define SAY_INTRO               -1269021
 #define SAY_WEAK75              -1269022
@@ -35,46 +39,62 @@ EndContentData */
 #define SAY_WIN                 -1269026
 #define SAY_ORCS_ENTER          -1269027
 #define SAY_ORCS_ANSWER         -1269028
+
 #define SPELL_CHANNEL           31556
 #define SPELL_PORTAL_RUNE       32570                       //aura(portal on ground effect)
+
 #define SPELL_BLACK_CRYSTAL     32563                       //aura
 #define SPELL_PORTAL_CRYSTAL    32564                       //summon
+
 #define SPELL_BANISH_PURPLE     32566                       //aura
 #define SPELL_BANISH_GREEN      32567                       //aura
+
 #define SPELL_CORRUPT           31326
 #define SPELL_CORRUPT_AEONUS    37853
+
 #define C_COUNCIL_ENFORCER      17023
+
 struct TRINITY_DLL_DECL npc_medivh_bmAI : public ScriptedAI
 {
     npc_medivh_bmAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 SpellCorrupt_Timer;
     uint32 Check_Timer;
+
     bool Life75;
     bool Life50;
     bool Life25;
+
     void Reset()
     {
         SpellCorrupt_Timer = 0;
+
         if (!pInstance)
             return;
+
         if (pInstance->GetData(TYPE_MEDIVH) == IN_PROGRESS)
             m_creature->CastSpell(m_creature,SPELL_CHANNEL,true);
         else if (m_creature->HasAura(SPELL_CHANNEL))
             m_creature->RemoveAura(SPELL_CHANNEL);
+
         m_creature->CastSpell(m_creature,SPELL_PORTAL_RUNE,true);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!pInstance)
             return;
+
         if (who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 10.0f))
         {
             if (pInstance->GetData(TYPE_MEDIVH) == IN_PROGRESS || pInstance->GetData(TYPE_MEDIVH) == DONE)
                 return;
+
             DoScriptText(SAY_INTRO, m_creature);
             pInstance->SetData(TYPE_MEDIVH,IN_PROGRESS);
             m_creature->CastSpell(m_creature,SPELL_CHANNEL,false);
@@ -84,6 +104,7 @@ struct TRINITY_DLL_DECL npc_medivh_bmAI : public ScriptedAI
         {
             if (pInstance->GetData(TYPE_MEDIVH) != IN_PROGRESS)
                 return;
+
             uint32 entry = who->GetEntry();
             if (entry == C_ASSAS || entry == C_WHELP || entry == C_CHRON || entry == C_EXECU || entry == C_VANQU)
             {
@@ -97,37 +118,48 @@ struct TRINITY_DLL_DECL npc_medivh_bmAI : public ScriptedAI
             }
         }
     }
+
     void AttackStart(Unit *who)
     {
         //if (pInstance && pInstance->GetData(TYPE_MEDIVH) == IN_PROGRESS)
         //return;
+
         //ScriptedAI::AttackStart(who);
     }
+
     void EnterCombat(Unit *who) {}
+
     void SpellHit(Unit* caster, const SpellEntry* spell)
     {
         if (SpellCorrupt_Timer)
             return;
+
         if (spell->Id == SPELL_CORRUPT_AEONUS)
             SpellCorrupt_Timer = 1000;
+
         if (spell->Id == SPELL_CORRUPT)
             SpellCorrupt_Timer = 3000;
     }
+
     void JustDied(Unit* Killer)
     {
         if (Killer->GetEntry() == m_creature->GetEntry())
             return;
+
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!pInstance)
             return;
+
         if (SpellCorrupt_Timer)
         {
             if (SpellCorrupt_Timer <= diff)
             {
                     pInstance->SetData(TYPE_MEDIVH,SPECIAL);
+
                 if (m_creature->HasAura(SPELL_CORRUPT_AEONUS))
                     SpellCorrupt_Timer = 1000;
                 else if (m_creature->HasAura(SPELL_CORRUPT))
@@ -136,12 +168,15 @@ struct TRINITY_DLL_DECL npc_medivh_bmAI : public ScriptedAI
                     SpellCorrupt_Timer = 0;
             }else SpellCorrupt_Timer -= diff;
         }
+
         if (Check_Timer)
         {
             if (Check_Timer <= diff)
             {
                 uint32 pct = pInstance->GetData(DATA_SHIELD);
+
                 Check_Timer = 5000;
+
                 if (Life25 && pct <= 25)
                 {
                     DoScriptText(SAY_WEAK25, m_creature);
@@ -157,6 +192,7 @@ struct TRINITY_DLL_DECL npc_medivh_bmAI : public ScriptedAI
                     DoScriptText(SAY_WEAK75, m_creature);
                     Life75 = false;
                 }
+
                 //if we reach this it means event was running but at some point reset.
                 if (pInstance->GetData(TYPE_MEDIVH) == NOT_STARTED)
                 {
@@ -165,122 +201,159 @@ struct TRINITY_DLL_DECL npc_medivh_bmAI : public ScriptedAI
                     m_creature->Respawn();
                     return;
                 }
+
                 if (pInstance->GetData(TYPE_RIFT) == DONE)
                 {
                     DoScriptText(SAY_WIN, m_creature);
                     Check_Timer = 0;
+
                     if (m_creature->HasAura(SPELL_CHANNEL))
                         m_creature->RemoveAura(SPELL_CHANNEL);
+
                     //TODO: start the post-event here
                     pInstance->SetData(TYPE_MEDIVH,DONE);
                 }
             }else Check_Timer -= diff;
         }
+
         //if (!UpdateVictim())
         //return;
+
         //DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_medivh_bm(Creature* pCreature)
 {
     return new npc_medivh_bmAI (pCreature);
 }
+
 struct Wave
 {
     uint32 PortalMob[4];                                    //spawns for portal waves (in order)
 };
+
 static Wave PortalWaves[]=
 {
     {C_ASSAS, C_WHELP, C_CHRON, 0},
     {C_EXECU, C_CHRON, C_WHELP, C_ASSAS},
     {C_EXECU, C_VANQU, C_CHRON, C_ASSAS}
 };
+
 struct TRINITY_DLL_DECL npc_time_riftAI : public ScriptedAI
 {
     npc_time_riftAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 TimeRiftWave_Timer;
     uint8 mRiftWaveCount;
     uint8 mPortalCount;
     uint8 mWaveId;
+
     void Reset()
     {
+
         TimeRiftWave_Timer = 15000;
         mRiftWaveCount = 0;
+
         if (!pInstance)
             return;
+
         mPortalCount = pInstance->GetData(DATA_PORTAL_COUNT);
+
         if (mPortalCount < 6)
             mWaveId = 0;
         else if (mPortalCount > 12)
             mWaveId = 2;
         else mWaveId = 1;
+
     }
     void EnterCombat(Unit *who) {}
+
     void DoSummonAtRift(uint32 creature_entry)
     {
         if (!creature_entry)
             return;
+
         if (pInstance && pInstance->GetData(TYPE_MEDIVH) != IN_PROGRESS)
         {
             m_creature->InterruptNonMeleeSpells(true);
             m_creature->RemoveAllAuras();
             return;
         }
+
         Position pos;
         m_creature->GetRandomNearPosition(pos, 10.0f);
+
         //normalize Z-level if we can, if rift is not at ground level.
         pos.m_positionZ = std::max(m_creature->GetMap()->GetHeight(pos.m_positionX, pos.m_positionY, MAX_HEIGHT), m_creature->GetMap()->GetWaterLevel(pos.m_positionX, pos.m_positionY));
+
         if(Unit *Summon = DoSummon(creature_entry, pos, 30000, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT))
             if (Unit *temp = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_MEDIVH) : 0))
                 Summon->AddThreat(temp,0.0f);
     }
+
     void DoSelectSummon()
     {
         uint32 entry = 0;
+
         if ((mRiftWaveCount > 2 && mWaveId < 1) || mRiftWaveCount > 3)
             mRiftWaveCount = 0;
+
         entry = PortalWaves[mWaveId].PortalMob[mRiftWaveCount];
         debug_log("TSCR: npc_time_rift: summoning wave Creature (Wave %u, Entry %u).",mRiftWaveCount,entry);
+
         ++mRiftWaveCount;
+
         if (entry == C_WHELP)
         {
-            for (uint8 i = 0; i < 3; ++i)
+            for(uint8 i = 0; i < 3; ++i)
                 DoSummonAtRift(entry);
         }else DoSummonAtRift(entry);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!pInstance)
             return;
+
         if (TimeRiftWave_Timer < diff)
         {
             DoSelectSummon();
             TimeRiftWave_Timer = 15000;
         }else TimeRiftWave_Timer -= diff;
+
         if (m_creature->IsNonMeleeSpellCasted(false))
             return;
+
         debug_log("TSCR: npc_time_rift: not casting anylonger, i need to die.");
         m_creature->setDeathState(JUST_DIED);
+
         if (pInstance->GetData(TYPE_RIFT) == IN_PROGRESS)
             pInstance->SetData(TYPE_RIFT,SPECIAL);
     }
 };
+
 CreatureAI* GetAI_npc_time_rift(Creature* pCreature)
 {
     return new npc_time_riftAI (pCreature);
 }
+
 #define SAY_SAAT_WELCOME        -1269019
+
 #define GOSSIP_ITEM_OBTAIN      "[PH] Obtain Chrono-Beacon"
 #define SPELL_CHRONO_BEACON     34975
 #define ITEM_CHRONO_BEACON      24289
+
 bool GossipHello_npc_saat(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE && !pPlayer->HasItemCount(ITEM_CHRONO_BEACON,1))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT,GOSSIP_ITEM_OBTAIN,GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+1);
@@ -293,9 +366,11 @@ bool GossipHello_npc_saat(Player* pPlayer, Creature* pCreature)
         pPlayer->SEND_GOSSIP_MENU(10001, pCreature->GetGUID());
         return true;
     }
+
     pPlayer->SEND_GOSSIP_MENU(10002, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_saat(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -305,17 +380,21 @@ bool GossipSelect_npc_saat(Player* pPlayer, Creature* pCreature, uint32 uiSender
     }
     return true;
 }
+
 void AddSC_dark_portal()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_medivh_bm";
     newscript->GetAI = &GetAI_npc_medivh_bm;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_time_rift";
     newscript->GetAI = &GetAI_npc_time_rift;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_saat";
     newscript->pGossipHello = &GossipHello_npc_saat;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/def_dark_portal.h b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/def_dark_portal.h
index 6c2572c4fe8..7bfd8c917d7 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/def_dark_portal.h
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/def_dark_portal.h
@@ -1,18 +1,24 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
 * This program is free software licensed under GPL version 2
 * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_DARKPORTAL_H
 #define DEF_DARKPORTAL_H
+
 #define TYPE_MEDIVH             1
 #define TYPE_RIFT               2
+
 #define DATA_MEDIVH             10
 #define DATA_PORTAL_COUNT       11
 #define DATA_SHIELD             12
+
 #define WORLD_STATE_BM          2541
 #define WORLD_STATE_BM_SHIELD   2540
 #define WORLD_STATE_BM_RIFT     2784
+
 #define QUEST_OPENING_PORTAL    10297
 #define QUEST_MASTER_TOUCH      9836
+
 #define C_TIME_KEEPER           17918
 #define C_RKEEP                 21104
 #define C_RLORD                 17839
@@ -24,5 +30,6 @@
 #define C_CHRON                 17892
 #define C_EXECU                 18994
 #define C_VANQU                 18995
+
 #endif
 
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/instance_dark_portal.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/instance_dark_portal.cpp
index f12a20e929c..b6d08ee82d8 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/instance_dark_portal.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/dark_portal/instance_dark_portal.cpp
@@ -13,20 +13,28 @@
 * along 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_Dark_Portal
 SD%Complete: 50
 SDComment: Quest support: 9836, 10297. Currently in progress.
 SDCategory: Caverns of Time, The Dark Portal
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_dark_portal.h"
+
 #define MAX_ENCOUNTER              2
+
 #define C_MEDIVH                15608
 #define C_TIME_RIFT             17838
+
 #define SPELL_RIFT_CHANNEL      31387
+
 #define RIFT_BOSS               1
+
 inline uint32 RandRiftBoss() { return ((rand()%2) ? C_RKEEP : C_RLORD); }
+
 float PortalLocation[4][4]=
 {
     {-2041.06, 7042.08, 29.99, 1.30},
@@ -34,11 +42,13 @@ float PortalLocation[4][4]=
     {-1885.82, 7107.36, 22.32, 3.07},
     {-1928.11, 7175.95, 22.11, 3.44}
 };
+
 struct Wave
 {
     uint32 PortalBoss;                                      //protector of current portal
     uint32 NextPortalTime;                                  //time to next portal, or 0 if portal boss need to be killed
 };
+
 static Wave RiftWaves[]=
 {
     {RIFT_BOSS, 0},
@@ -48,62 +58,81 @@ static Wave RiftWaves[]=
     {RIFT_BOSS, 120000},
     {C_AEONUS, 0}
 };
+
 struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
 {
     instance_dark_portal(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     uint32 mRiftPortalCount;
     uint32 mShieldPercent;
     uint8 mRiftWaveCount;
     uint8 mRiftWaveId;
+
     uint32 NextPortal_Timer;
+
     uint64 MedivhGUID;
     uint8 CurrentRiftId;
+
     void Initialize()
     {
         MedivhGUID          = 0;
         Clear();
     }
+
     void Clear()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         mRiftPortalCount    = 0;
         mShieldPercent      = 100;
         mRiftWaveCount      = 0;
         mRiftWaveId         = 0;
+
         CurrentRiftId = 0;
+
         NextPortal_Timer    = 0;
     }
+
     void InitWorldState(bool Enable = true)
     {
         DoUpdateWorldState(WORLD_STATE_BM,Enable ? 1 : 0);
         DoUpdateWorldState(WORLD_STATE_BM_SHIELD, 100);
         DoUpdateWorldState(WORLD_STATE_BM_RIFT, 0);
     }
+
     bool IsEncounterInProgress()
     {
         if (GetData(TYPE_MEDIVH) == IN_PROGRESS)
             return true;
+
         return false;
     }
+
     void OnPlayerEnter(Player* pPlayer)
     {
         if (GetData(TYPE_MEDIVH) == IN_PROGRESS)
             return;
+
         pPlayer->SendUpdateWorldState(WORLD_STATE_BM,0);
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         if (pCreature->GetEntry() == C_MEDIVH)
             MedivhGUID = pCreature->GetGUID();
     }
+
     //what other conditions to check?
     bool CanProgressEvent()
     {
         if (instance->GetPlayers().isEmpty())
             return false;
+
         return true;
     }
+
     uint8 GetRiftWaveId()
     {
         switch(mRiftPortalCount)
@@ -120,6 +149,7 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
             return mRiftWaveId;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -128,7 +158,9 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
             if (data == SPECIAL && m_auiEncounter[0] == IN_PROGRESS)
             {
                 --mShieldPercent;
+
                 DoUpdateWorldState(WORLD_STATE_BM_SHIELD, mShieldPercent);
+
                 if (!mShieldPercent)
                 {
                     if (Creature* pMedivh = instance->GetCreature(MedivhGUID))
@@ -151,25 +183,29 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
                     m_auiEncounter[1] = IN_PROGRESS;
                     NextPortal_Timer = 15000;
                 }
+
                 if (data == DONE)
                 {
                     //this may be completed further out in the post-event
                     debug_log("TSCR: Instance Dark Portal: Event completed.");
                     Map::PlayerList const& players = instance->GetPlayers();
+
                     if (!players.isEmpty())
                     {
-                        for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                        for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         {
                             if (Player* pPlayer = itr->getSource())
                             {
                                 if (pPlayer->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE)
                                     pPlayer->AreaExploredOrEventHappens(QUEST_OPENING_PORTAL);
+
                                 if (pPlayer->GetQuestStatus(QUEST_MASTER_TOUCH) == QUEST_STATUS_INCOMPLETE)
                                     pPlayer->AreaExploredOrEventHappens(QUEST_MASTER_TOUCH);
                             }
                         }
                     }
                 }
+
                 m_auiEncounter[0] = data;
             }
             break;
@@ -184,6 +220,7 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
             break;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -199,44 +236,59 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 data)
     {
         if (data == DATA_MEDIVH)
             return MedivhGUID;
+
         return 0;
     }
+
     Creature* SummonedPortalBoss(Creature* m_creature)
     {
         uint32 entry = RiftWaves[GetRiftWaveId()].PortalBoss;
+
         if (entry == RIFT_BOSS)
             entry = RandRiftBoss();
+
         debug_log("TSCR: Instance Dark Portal: Summoning rift boss entry %u.",entry);
+
         Position pos;
         m_creature->GetRandomNearPosition(pos, 10.0f);
+
         //normalize Z-level if we can, if rift is not at ground level.
         pos.m_positionZ = std::max(m_creature->GetMap()->GetHeight(pos.m_positionX, pos.m_positionY, MAX_HEIGHT), m_creature->GetMap()->GetWaterLevel(pos.m_positionX, pos.m_positionY));
+
         if(Creature *summon = m_creature->SummonCreature(entry, pos, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000))
             return summon;
+
         debug_log("TSCR: Instance Dark Portal: what just happened there? No boss, no loot, no fun...");
         return NULL;
     }
+
     void DoSpawnPortal()
     {
         if (Creature* pMedivh = instance->GetCreature(MedivhGUID))
         {
             int tmp = rand()%(4-1);
+
             if (tmp >= CurrentRiftId)
                 tmp++;
                     debug_log("TSCR: Instance Dark Portal: Creating Time Rift at locationId %i (old locationId was %u).",tmp,CurrentRiftId);
+
                     CurrentRiftId = tmp;
+
                     Creature* pTemp = pMedivh->SummonCreature(C_TIME_RIFT,
                         PortalLocation[tmp][0],PortalLocation[tmp][1],PortalLocation[tmp][2],PortalLocation[tmp][3],
                         TEMPSUMMON_CORPSE_DESPAWN,0);
                     if (pTemp)
                     {
+
                         pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                         pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
 
+
                         if (Creature* pBoss = SummonedPortalBoss(pTemp))
                         {
                             if (pBoss->GetEntry() == C_AEONUS)
@@ -252,35 +304,43 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
                     }
         }
     }
+
     void Update(uint32 diff)
     {
         if (m_auiEncounter[1] != IN_PROGRESS)
             return;
+
         //add delay timer?
         if (!CanProgressEvent())
         {
             Clear();
             return;
         }
+
         if (NextPortal_Timer)
         {
             if (NextPortal_Timer <= diff)
             {
                 ++mRiftPortalCount;
+
                 DoUpdateWorldState(WORLD_STATE_BM_RIFT, mRiftPortalCount);
+
                 DoSpawnPortal();
                 NextPortal_Timer = RiftWaves[GetRiftWaveId()].NextPortalTime;
             }else NextPortal_Timer -= diff;
         }
     }
 };
+
 InstanceData* GetInstanceData_instance_dark_portal(Map* pMap)
 {
     return new instance_dark_portal(pMap);
 }
+
 void AddSC_instance_dark_portal()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "instance_dark_portal";
     newscript->GetInstanceData = &GetInstanceData_instance_dark_portal;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_anetheron.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_anetheron.cpp
index b0a299f9c09..96e56462385 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_anetheron.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_anetheron.cpp
@@ -2,32 +2,40 @@
 #include "precompiled.h"
 #include "def_hyjal.h"
 #include "hyjal_trash.h"
+
 #define SPELL_CARRION_SWARM 31306
 #define SPELL_SLEEP 31298
 #define SPELL_VAMPIRIC_AURA 38196
 #define SPELL_INFERNO 31299
+
 #define SAY_ONDEATH "The clock... is still... ticking."
 #define SOUND_ONDEATH 10982
+
 #define SAY_ONSLAY1 "Your hopes are lost!"
 #define SAY_ONSLAY2 "Scream for me!"
 #define SAY_ONSLAY3 "Pity, no time for a slow death!"
 #define SOUND_ONSLAY1 10981
 #define SOUND_ONSLAY2 11038
 #define SOUND_ONSLAY3 11039
+
 #define SAY_SWARM1 "The swarm is eager to feed!"
 #define SAY_SWARM2 "Pestilence upon you!"
 #define SOUND_SWARM1 10979
 #define SOUND_SWARM2 11037
+
 #define SAY_SLEEP1 "You look tired..."
 #define SAY_SLEEP2 "Sweet dreams..."
 #define SOUND_SLEEP1 10978
 #define SOUND_SLEEP2 11545
+
 #define SAY_INFERNO1 "Let fire rain from above!"
 #define SAY_INFERNO2 "Earth and sky shall burn!"
 #define SOUND_INFERNO1 10980
 #define SOUND_INFERNO2 11036
+
 #define SAY_ONAGGRO "You are defenders of a doomed world! Flee here, and perhaps you will prolong your pathetic lives!"
 #define SOUND_ONAGGRO 10977
+
 struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
 {
     boss_anetheronAI(Creature *c) : hyjal_trashAI(c)
@@ -42,12 +50,14 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
             TempSpell->EffectImplicitTargetB[0] = 0;
         }
     }
+
     uint32 SwarmTimer;
     uint32 SleepTimer;
     uint32 AuraTimer;
     uint32 InfernoTimer;
     bool pGo;
     uint32 pos;
+
     void Reset()
     {
         damageTaken = 0;
@@ -55,9 +65,11 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
         SleepTimer = 60000;
         AuraTimer = 5000;
         InfernoTimer = 45000;
+
         if (pInstance && IsEvent)
             pInstance->SetData(DATA_ANETHERONEVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance && IsEvent)
@@ -65,6 +77,7 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
         DoPlaySoundToSet(m_creature, SOUND_ONAGGRO);
         m_creature->MonsterYell(SAY_ONAGGRO, LANG_UNIVERSAL, 0);
     }
+
     void KilledUnit(Unit *victim)
     {
         switch(rand()%3)
@@ -83,6 +96,7 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
                 break;
         }
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
@@ -93,6 +107,7 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
                 m_creature->AddThreat(target,0.0);
         }
     }
+
     void JustDied(Unit *victim)
     {
         hyjal_trashAI::JustDied(victim);
@@ -101,6 +116,7 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
         DoPlaySoundToSet(m_creature, SOUND_ONDEATH);
         m_creature->MonsterYell(SAY_ONDEATH, LANG_UNIVERSAL, 0);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IsEvent)
@@ -125,13 +141,16 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
                 }
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (SwarmTimer < diff)
         {
             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM,0,100,true))
                 DoCast(target,SPELL_CARRION_SWARM);
+
             SwarmTimer = 45000+rand()%15000;
             switch(rand()%2)
             {
@@ -145,9 +164,10 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
                     break;
             }
         }else SwarmTimer -= diff;
+
         if (SleepTimer < diff)
         {
-            for (uint8 i=0; i<3; ++i)
+            for(uint8 i=0;i<3; ++i)
             {
                 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM,0,100,true))
                     target->CastSpell(target,SPELL_SLEEP,true);
@@ -186,15 +206,19 @@ struct TRINITY_DLL_DECL boss_anetheronAI : public hyjal_trashAI
                     break;
             }
         }else InfernoTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_anetheron(Creature* pCreature)
 {
     return new boss_anetheronAI (pCreature);
 }
+
 #define SPELL_IMMOLATION 31303
 #define SPELL_INFERNO_EFFECT 31302
+
 struct TRINITY_DLL_DECL mob_towering_infernalAI : public ScriptedAI
 {
     mob_towering_infernalAI(Creature *c) : ScriptedAI(c)
@@ -203,30 +227,40 @@ struct TRINITY_DLL_DECL mob_towering_infernalAI : public ScriptedAI
         if (pInstance)
             AnetheronGUID = pInstance->GetData64(DATA_ANETHERON);
     }
+
     uint32 ImmolationTimer;
     uint32 CheckTimer;
     uint64 AnetheronGUID;
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         DoCast(m_creature, SPELL_INFERNO_EFFECT);
         ImmolationTimer = 5000;
         CheckTimer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
+
     }
+
     void KilledUnit(Unit *victim)
     {
+
     }
+
     void JustDied(Unit *victim)
     {
+
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (m_creature->IsWithinDist(who, 50) && !m_creature->isInCombat() && m_creature->IsHostileTo(who))
             AttackStart(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (CheckTimer < diff)
@@ -243,21 +277,26 @@ struct TRINITY_DLL_DECL mob_towering_infernalAI : public ScriptedAI
             }
             CheckTimer = 5000;
         }else CheckTimer -= diff;
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (ImmolationTimer < diff)
         {
             DoCast(m_creature, SPELL_IMMOLATION);
             ImmolationTimer = 5000;
         }else ImmolationTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_towering_infernal(Creature* pCreature)
 {
     return new mob_towering_infernalAI (pCreature);
 }
+
 void AddSC_boss_anetheron()
 {
     Script *newscript;
@@ -265,6 +304,7 @@ void AddSC_boss_anetheron()
     newscript->Name = "boss_anetheron";
     newscript->GetAI = &GetAI_boss_anetheron;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_towering_infernal";
     newscript->GetAI = &GetAI_mob_towering_infernal;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_archimonde.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_archimonde.cpp
index b2c4d377b8a..fa4c779d9b8 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_archimonde.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_archimonde.cpp
@@ -13,16 +13,19 @@
  * along with 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: 85
 SDComment: Doomfires not completely offlike due to core limitations for random moving. Tyrande and second phase not fully implemented.
 SDCategory: Caverns of Time, Mount Hyjal
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_hyjal.h"
 #include "SpellAuras.h"
 #include "hyjal_trash.h"
+
 //text id -1534018 are the text used when previous events complete. Not part of this script.
 #define SAY_AGGRO                   -1534019
 #define SAY_DOOMFIRE1               -1534020
@@ -36,11 +39,14 @@ EndScriptData */
 #define SAY_DEATH                   -1534028
 #define SAY_SOUL_CHARGE1            -1534029
 #define SAY_SOUL_CHARGE2            -1534030
+
 #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
@@ -55,14 +61,17 @@ EndScriptData */
 #define SPELL_UNLEASH_SOUL_GREEN    32057
 #define SPELL_UNLEASH_SOUL_RED      32053
 #define SPELL_FEAR                  31970
+
 #define CREATURE_ARCHIMONDE             17968
 #define CREATURE_DOOMFIRE               18095
 #define CREATURE_DOOMFIRE_SPIRIT        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)
@@ -70,18 +79,25 @@ struct mob_ancient_wispAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         ArchimondeGUID = 0;
     }
+
     ScriptedInstance* pInstance;
     uint64 ArchimondeGUID;
     uint32 CheckTimer;
+
     void Reset()
     {
         CheckTimer = 1000;
+
         if (pInstance)
             ArchimondeGUID = pInstance->GetData64(DATA_ARCHIMONDE);
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
     }
+
     void EnterCombat(Unit* who) {}
+
     void DamageTaken(Unit* done_by, uint32 &damage) { damage = 0; }
+
     void UpdateAI(const uint32 diff)
     {
         if (CheckTimer < diff)
@@ -97,28 +113,35 @@ struct mob_ancient_wispAI : public ScriptedAI
         }else CheckTimer -= diff;
     }
 };
+
 /* This script is merely a placeholder for the Doomfire that triggers Doomfire spell. It will
    MoveChase the Doomfire Spirit always, until despawn (AttackStart is called upon it's spawn) */
 struct TRINITY_DLL_DECL mob_doomfireAI : public ScriptedAI
 {
     mob_doomfireAI(Creature* c) : ScriptedAI(c) {}
+
     void Reset() { }
+
     void MoveInLineOfSight(Unit* who) { }
     void EnterCombat(Unit* who) { }
     void DamageTaken(Unit *done_by, uint32 &damage) { damage = 0; }
 };
+
 /* This is the script for the Doomfire Spirit Mob. This mob simply follow players or
    travels in random directions if target cannot be found. */
 struct TRINITY_DLL_DECL mob_doomfire_targettingAI : public ScriptedAI
 {
     mob_doomfire_targettingAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 TargetGUID;
     uint32 ChangeTargetTimer;
+
     void Reset()
     {
         TargetGUID = 0;
         ChangeTargetTimer = 5000;
     }
+
     void MoveInLineOfSight(Unit* who)
     {
         //will update once TargetGUID is 0. In case noone actually moves(not likely) and this is 0
@@ -126,8 +149,11 @@ struct TRINITY_DLL_DECL mob_doomfire_targettingAI : public ScriptedAI
         if (!TargetGUID && who->GetTypeId() == TYPEID_PLAYER)
             TargetGUID = who->GetGUID();
     }
+
     void EnterCombat(Unit* who) {}
+
     void DamageTaken(Unit *done_by, uint32 &damage) { damage = 0; }
+
     void UpdateAI(const uint32 diff)
     {
         if (ChangeTargetTimer < diff)
@@ -143,10 +169,12 @@ struct TRINITY_DLL_DECL mob_doomfire_targettingAI : public ScriptedAI
                 m_creature->GetRandomNearPosition(pos, 40);
                 m_creature->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
             }
+
             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
@@ -154,15 +182,19 @@ struct TRINITY_DLL_DECL mob_doomfire_targettingAI : public ScriptedAI
    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 Spirit) for the Doomfire mob to follow. It's spirit will
    randomly select it's target to follow and then we create the random movement making it unpredictable. */
+
 struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
 {
     boss_archimondeAI(Creature *c) : hyjal_trashAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint64 DoomfireSpiritGUID;
     uint64 WorldTreeGUID;
+
     uint32 DrainNordrassilTimer;
     uint32 FearTimer;
     uint32 AirBurstTimer;
@@ -176,17 +208,21 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
     uint32 WispCount;
     uint32 EnrageTimer;
     uint32 CheckDistanceTimer;
+
     bool Enraged;
     bool BelowTenPercent;
     bool HasProtected;
     bool IsChanneling;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_ARCHIMONDEEVENT, NOT_STARTED);
+
         DoomfireSpiritGUID = 0;
         damageTaken = 0;
         WorldTreeGUID = 0;
+
         DrainNordrassilTimer = 0;
         FearTimer = 42000;
         AirBurstTimer = 30000;
@@ -200,25 +236,31 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
         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
         SummonWispTimer = 0;
+
         Enraged = false;
         BelowTenPercent = false;
         HasProtected = false;
         IsChanneling = false;
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->InterruptSpell(CURRENT_CHANNELED_SPELL);
         DoScriptText(SAY_AGGRO, m_creature);
         DoZoneInCombat();
+
         if (pInstance)
             pInstance->SetData(DATA_ARCHIMONDEEVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
+
         if (victim && (victim->GetTypeId() == TYPEID_PLAYER))
             GainSoulCharge(CAST_PLR(victim));
     }
+
     void GainSoulCharge(Player* victim)
     {
         switch(victim->getClass())
@@ -239,35 +281,43 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                 victim->CastSpell(m_creature, SPELL_SOUL_CHARGE_GREEN, true);
                 break;
         }
+
         SoulChargeTimer = 2000 + rand()%28000;
         ++SoulChargeCount;
     }
+
     void JustDied(Unit *victim)
     {
         hyjal_trashAI::JustDied(victim);
         DoScriptText(SAY_DEATH, m_creature);
+
         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)
+        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(ObjectDistanceOrder(m_creature));
         Unit* target = targets.front();
         if (target)
@@ -277,8 +327,10 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
             else                                            // This target is closest, he is our new tank
                 m_creature->AddThreat(target, m_creature->getThreatManager().getThreat(m_creature->getVictim()));
         }
+
         return false;
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned->GetEntry() == CREATURE_ANCIENT_WISP)
@@ -289,14 +341,17 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
             summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
             summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         }
+
         if (summoned->GetEntry() == CREATURE_DOOMFIRE_SPIRIT)
         {
             DoomfireSpiritGUID = summoned->GetGUID();
         }
+
         if (summoned->GetEntry() == CREATURE_DOOMFIRE)
         {
             summoned->CastSpell(summoned,SPELL_DOOMFIRE_SPAWN,false);
             summoned->CastSpell(summoned,SPELL_DOOMFIRE,true,0,0,m_creature->GetGUID());
+
             if (Unit *DoomfireSpirit = Unit::GetUnit(*m_creature, DoomfireSpiritGUID))
             {
                 summoned->GetMotionMaster()->MoveFollow(DoomfireSpirit,0.0f,0.0f);
@@ -304,22 +359,27 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
             }
         }
     }
+
     //this is code doing close to what the summoning spell would do (spell 31903)
     void SummonDoomfire(Unit* target)
     {
         m_creature->SummonCreature(CREATURE_DOOMFIRE_SPIRIT,
             target->GetPositionX()+15.0,target->GetPositionY()+15.0,target->GetPositionZ(),0,
             TEMPSUMMON_TIMED_DESPAWN, 27000);
+
         m_creature->SummonCreature(CREATURE_DOOMFIRE,
             target->GetPositionX()-15.0,target->GetPositionY()-15.0,target->GetPositionZ(),0,
             TEMPSUMMON_TIMED_DESPAWN, 27000);
     }
+
     void UnleashSoulCharge()
     {
         m_creature->InterruptNonMeleeSpells(false);
+
         bool HasCast = false;
         uint32 chargeSpell = 0;
         uint32 unleashSpell = 0;
+
         switch(rand()%3)
         {
             case 0:
@@ -335,6 +395,7 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                 unleashSpell = SPELL_UNLEASH_SOUL_GREEN;
                 break;
         }
+
         if (m_creature->HasAura(chargeSpell))
         {
             m_creature->RemoveAuraFromStack(chargeSpell);
@@ -342,9 +403,11 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
             HasCast = true;
             SoulChargeCount--;
         }
+
         if (HasCast)
             SoulChargeTimer = 2000 + rand()%28000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->isInCombat())
@@ -363,13 +426,16 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                     m_creature->SetVisibility(VISIBILITY_ON);
                 }
             }
+
             if (DrainNordrassilTimer < diff)
             {
                 if (!IsChanneling)
                 {
                     Creature *temp = m_creature->SummonCreature(CREATURE_CHANNEL_TARGET, NORDRASSIL_X, NORDRASSIL_Y, NORDRASSIL_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 1200000);
+
                     if (temp)
                         WorldTreeGUID = temp->GetGUID();
+
                     if (Unit *Nordrassil = Unit::GetUnit(*m_creature, WorldTreeGUID))
                     {
                         Nordrassil->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -378,6 +444,7 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                         IsChanneling = true;
                     }
                 }
+
                 if (Unit *Nordrassil = Unit::GetUnit(*m_creature, WorldTreeGUID))
                 {
                     Nordrassil->CastSpell(m_creature, SPELL_DRAIN_WORLD_TREE_2, true);
@@ -385,10 +452,13 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                 }
             }else DrainNordrassilTimer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !BelowTenPercent && !Enraged)
             BelowTenPercent = true;
+
         if (!Enraged)
         {
             if (EnrageTimer < diff)
@@ -401,6 +471,7 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                     DoScriptText(SAY_ENRAGE, m_creature);
                 }
             }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
@@ -408,6 +479,7 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                 if (Check)
                 {
                     Check->SetVisibility(VISIBILITY_OFF);
+
                     if (m_creature->IsWithinDistInMap(Check, 75))
                     {
                         m_creature->GetMotionMaster()->Clear(false);
@@ -419,26 +491,31 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                 CheckDistanceTimer = 5000;
             }else CheckDistanceTimer -= diff;
         }
+
         if (BelowTenPercent)
         {
             if (!HasProtected)
             {
                 m_creature->GetMotionMaster()->Clear(false);
                 m_creature->GetMotionMaster()->MoveIdle();
+
                 //all members of raid must get this buff
                 DoCast(m_creature->getVictim(), SPELL_PROTECTION_OF_ELUNE);
                 HasProtected = true;
                 Enraged = true;
             }
+
             if (SummonWispTimer < diff)
             {
                 DoSpawnCreature(CREATURE_ANCIENT_WISP, rand()%40, rand()%40, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                 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)
@@ -448,45 +525,55 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
             }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)
                 DoScriptText(SAY_AIR_BURST1, m_creature);
             else
                 DoScriptText(SAY_AIR_BURST2, m_creature);
+
             DoCast(SelectUnit(SELECT_TARGET_RANDOM, 1), SPELL_AIR_BURST);//not on tank
             AirBurstTimer = 25000 + rand()%15000;
         }else AirBurstTimer -= diff;
+
         if (FearTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_FEAR);
             FearTimer = 42000;
         }else FearTimer -= diff;
+
         if (DoomfireTimer < diff)
         {
             if (rand()%2 == 0)
                 DoScriptText(SAY_DOOMFIRE1, m_creature);
             else
                 DoScriptText(SAY_DOOMFIRE2, m_creature);
+
             Unit *temp = SelectUnit(SELECT_TARGET_RANDOM, 1);
             if (!temp)
                 temp = m_creature->getVictim();
+
             //replace with spell cast 31903 once implicitTarget 73 implemented
             SummonDoomfire(temp);
+
             //supposedly three doomfire can be up at the same time
             DoomfireTimer = 20000;
         }else DoomfireTimer -= diff;
+
         if (MeleeRangeCheckTimer < diff)
         {
             if (CanUseFingerOfDeath())
@@ -494,28 +581,35 @@ struct TRINITY_DLL_DECL boss_archimondeAI : public hyjal_trashAI
                 DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FINGER_OF_DEATH);
                 MeleeRangeCheckTimer = 1000;
             }
+
             MeleeRangeCheckTimer = 5000;
         }else MeleeRangeCheckTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
     void WaypointReached(uint32 i){}
 };
+
 CreatureAI* GetAI_boss_archimonde(Creature* pCreature)
 {
     return new boss_archimondeAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_doomfire(Creature* pCreature)
 {
     return new mob_doomfireAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_doomfire_targetting(Creature* pCreature)
 {
     return new mob_doomfire_targettingAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_ancient_wisp(Creature* pCreature)
 {
     return new mob_ancient_wispAI(pCreature);
 }
+
 void AddSC_boss_archimonde()
 {
     Script *newscript;
@@ -523,14 +617,17 @@ void AddSC_boss_archimonde()
     newscript->Name = "boss_archimonde";
     newscript->GetAI = &GetAI_boss_archimonde;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_doomfire";
     newscript->GetAI = &GetAI_mob_doomfire;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_doomfire_targetting";
     newscript->GetAI = &GetAI_mob_doomfire_targetting;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ancient_wisp";
     newscript->GetAI = &GetAI_mob_ancient_wisp;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_azgalor.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_azgalor.cpp
index 1e4280c182e..a61d009284f 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_azgalor.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_azgalor.cpp
@@ -2,25 +2,31 @@
 #include "precompiled.h"
 #include "def_hyjal.h"
 #include "hyjal_trash.h"
+
 #define SPELL_RAIN_OF_FIRE 31340
 #define SPELL_DOOM 31347
 #define SPELL_HOWL_OF_AZGALOR 31344
 #define SPELL_CLEAVE 31345
 #define SPELL_BERSERK 26662
+
 #define SAY_ONDEATH "Your time is almost... up"
 #define SOUND_ONDEATH 11002
+
 #define SAY_ONSLAY1 "Reesh, hokta!"
 #define SAY_ONSLAY2 "Don't fight it"
 #define SAY_ONSLAY3 "No one is going to save you"
 #define SOUND_ONSLAY1 11001
 #define SOUND_ONSLAY2 11048
 #define SOUND_ONSLAY3 11047
+
 #define SAY_DOOM1 "Just a taste... of what awaits you"
 #define SAY_DOOM2 "Suffer you despicable insect!"
 #define SOUND_DOOM1 11046
 #define SOUND_DOOM2 11000
+
 #define SAY_ONAGGRO "Abandon all hope! The legion has returned to finish what was begun so many years ago. This time there will be no escape!"
 #define SOUND_ONAGGRO 10999
+
 struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
 {
     boss_azgalorAI(Creature *c) : hyjal_trashAI(c)
@@ -32,14 +38,17 @@ struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
         if (TempSpell)
             TempSpell->EffectRadiusIndex[0] = 12;//100yards instead of 50000?!
     }
+
     uint32 RainTimer;
     uint32 DoomTimer;
     uint32 HowlTimer;
     uint32 CleaveTimer;
     uint32 EnrageTimer;
     bool enraged;
+
     bool pGo;
     uint32 pos;
+
     void Reset()
     {
         damageTaken = 0;
@@ -49,9 +58,11 @@ struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
         CleaveTimer = 10000;
         EnrageTimer = 600000;
         enraged = false;
+
         if (pInstance && IsEvent)
             pInstance->SetData(DATA_AZGALOREVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance && IsEvent)
@@ -59,6 +70,7 @@ struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
         DoPlaySoundToSet(m_creature, SOUND_ONAGGRO);
         m_creature->MonsterYell(SAY_ONAGGRO, LANG_UNIVERSAL, NULL);
     }
+
     void KilledUnit(Unit *victim)
     {
         switch(rand()%3)
@@ -77,6 +89,7 @@ struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
                 break;
         }
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
@@ -87,6 +100,7 @@ struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
                 m_creature->AddThreat(target,0.0);
         }
     }
+
     void JustDied(Unit *victim)
     {
         hyjal_trashAI::JustDied(victim);
@@ -94,6 +108,7 @@ struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
             pInstance->SetData(DATA_AZGALOREVENT, DONE);
         DoPlaySoundToSet(m_creature, SOUND_ONDEATH);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IsEvent)
@@ -118,29 +133,35 @@ struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
                 }
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (RainTimer < diff)
         {
             DoCast(SelectTarget(SELECT_TARGET_RANDOM,0,30,true), SPELL_RAIN_OF_FIRE);
             RainTimer = 20000+rand()%15000;
         }else RainTimer -= diff;
+
         if (DoomTimer < diff)
         {
             DoCast(SelectTarget(SELECT_TARGET_RANDOM,1,100,true), SPELL_DOOM);//never on tank
             DoomTimer = 45000+rand()%5000;
         }else DoomTimer -= diff;
+
         if (HowlTimer < diff)
         {
             DoCast(m_creature, SPELL_HOWL_OF_AZGALOR);
             HowlTimer = 30000;
         }else HowlTimer -= diff;
+
         if (CleaveTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_CLEAVE);
             CleaveTimer = 10000+rand()%5000;
         }else CleaveTimer -= diff;
+
         if (EnrageTimer < diff && !enraged)
         {
             m_creature->InterruptNonMeleeSpells(false);
@@ -148,16 +169,20 @@ struct TRINITY_DLL_DECL boss_azgalorAI : public hyjal_trashAI
             enraged = true;
             EnrageTimer = 600000;
         }else EnrageTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_azgalor(Creature* pCreature)
 {
     return new boss_azgalorAI (pCreature);
 }
+
 #define SPELL_THRASH 12787
 #define SPELL_CRIPPLE 31406
 #define SPELL_WARSTOMP 31408
+
 struct TRINITY_DLL_DECL mob_lesser_doomguardAI : public hyjal_trashAI
 {
     mob_lesser_doomguardAI(Creature *c) : hyjal_trashAI(c)
@@ -166,11 +191,13 @@ struct TRINITY_DLL_DECL mob_lesser_doomguardAI : public hyjal_trashAI
         if (pInstance)
             AzgalorGUID = pInstance->GetData64(DATA_AZGALOR);
     }
+
     uint32 CrippleTimer;
     uint32 WarstompTimer;
     uint32 CheckTimer;
     uint64 AzgalorGUID;
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         CrippleTimer = 50000;
@@ -178,23 +205,32 @@ struct TRINITY_DLL_DECL mob_lesser_doomguardAI : public hyjal_trashAI
         DoCast(m_creature, SPELL_THRASH);
         CheckTimer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void KilledUnit(Unit *victim)
     {
+
     }
+
     void WaypointReached(uint32 i)
     {
+
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (m_creature->IsWithinDist(who, 50) && !m_creature->isInCombat() && m_creature->IsHostileTo(who))
             AttackStart(who);
     }
+
     void JustDied(Unit *victim)
     {
+
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (CheckTimer < diff)
@@ -211,26 +247,32 @@ struct TRINITY_DLL_DECL mob_lesser_doomguardAI : public hyjal_trashAI
             }
             CheckTimer = 5000;
         }else CheckTimer -= diff;
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (WarstompTimer < diff)
         {
             DoCast(m_creature, SPELL_WARSTOMP);
             WarstompTimer = 10000+rand()%5000;
         }else WarstompTimer -= diff;
+
         if (CrippleTimer < diff)
         {
             DoCast(SelectTarget(SELECT_TARGET_RANDOM,0,100,true), SPELL_CRIPPLE);
             CrippleTimer = 25000+rand()%5000;
         }else CrippleTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_lesser_doomguard(Creature* pCreature)
 {
     return new mob_lesser_doomguardAI (pCreature);
 }
+
 void AddSC_boss_azgalor()
 {
     Script *newscript;
@@ -238,6 +280,7 @@ void AddSC_boss_azgalor()
     newscript->Name = "boss_azgalor";
     newscript->GetAI = &GetAI_boss_azgalor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_lesser_doomguard";
     newscript->GetAI = &GetAI_mob_lesser_doomguard;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_kazrogal.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_kazrogal.cpp
index 57d88073fa1..d3f87daec28 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_kazrogal.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_kazrogal.cpp
@@ -2,22 +2,28 @@
 #include "precompiled.h"
 #include "def_hyjal.h"
 #include "hyjal_trash.h"
+
 #define SPELL_CLEAVE 31436
 #define SPELL_WARSTOMP 31480
 #define SPELL_MARK 31447
+
 #define SOUND_ONDEATH 11018
+
 #define SAY_ONSLAY1 "Shaza-Kiel!"
 #define SAY_ONSLAY2 "You... are nothing!"
 #define SAY_ONSLAY3 "Miserable nuisance!"
 #define SOUND_ONSLAY1 11017
 #define SOUND_ONSLAY2 11053
 #define SOUND_ONSLAY3 11054
+
 #define SAY_MARK1 "Your death will be a painful one."
 #define SAY_MARK2 "You... are marked."
 #define SOUND_MARK1 11016
 #define SOUND_MARK2 11052
+
 #define SAY_ONAGGRO "Cry for mercy! Your meaningless lives will soon be forfeit."
 #define SOUND_ONAGGRO 11015
+
 struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
 {
     boss_kazrogalAI(Creature *c) : hyjal_trashAI(c)
@@ -32,12 +38,14 @@ struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
             TempSpell->EffectImplicitTargetB[0] = 0;
         }
     }
+
     uint32 CleaveTimer;
     uint32 WarStompTimer;
     uint32 MarkTimer;
     uint32 MarkTimerBase;
     bool pGo;
     uint32 pos;
+
     void Reset()
     {
         damageTaken = 0;
@@ -45,9 +53,11 @@ struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
         WarStompTimer = 15000;
         MarkTimer = 45000;
         MarkTimerBase = 45000;
+
         if (pInstance && IsEvent)
             pInstance->SetData(DATA_KAZROGALEVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance && IsEvent)
@@ -55,6 +65,7 @@ struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
         DoPlaySoundToSet(m_creature, SOUND_ONAGGRO);
         m_creature->MonsterYell(SAY_ONAGGRO, LANG_UNIVERSAL, NULL);
     }
+
     void KilledUnit(Unit *victim)
     {
         switch(rand()%3)
@@ -73,6 +84,7 @@ struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
                 break;
         }
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
@@ -83,6 +95,7 @@ struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
                 m_creature->AddThreat(target,0.0);
         }
     }
+
     void JustDied(Unit *victim)
     {
         hyjal_trashAI::JustDied(victim);
@@ -90,6 +103,7 @@ struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
             pInstance->SetData(DATA_KAZROGALEVENT, DONE);
         DoPlaySoundToSet(m_creature, SOUND_ONDEATH);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IsEvent)
@@ -114,27 +128,32 @@ struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
                 }
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (CleaveTimer < diff)
         {
             DoCast(m_creature, SPELL_CLEAVE);
             CleaveTimer = 6000+rand()%15000;
         }else CleaveTimer -= diff;
+
         if (WarStompTimer < diff)
         {
             DoCast(m_creature, SPELL_WARSTOMP);
             WarStompTimer = 60000;
         }else WarStompTimer -= diff;
+
         if (m_creature->HasAura(SPELL_MARK))
             m_creature->RemoveAurasDueToSpell(SPELL_MARK);
         if (MarkTimer < diff)
         {
             //cast dummy, useful for bos addons
             m_creature->CastCustomSpell(m_creature, SPELL_MARK, NULL, NULL, NULL, false, NULL, NULL, m_creature->GetGUID());
+
             std::list t_list = m_creature->getThreatManager().getThreatList();
-            for (std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
+            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->getPowerType() == POWER_MANA)
@@ -158,13 +177,16 @@ struct TRINITY_DLL_DECL boss_kazrogalAI : public hyjal_trashAI
                     break;
             }
         }else MarkTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_kazrogal(Creature* pCreature)
 {
     return new boss_kazrogalAI (pCreature);
 }
+
 void AddSC_boss_kazrogal()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_rage_winterchill.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_rage_winterchill.cpp
index 856b8b374cb..da0d6c2dd5a 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_rage_winterchill.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/boss_rage_winterchill.cpp
@@ -2,26 +2,34 @@
 #include "precompiled.h"
 #include "def_hyjal.h"
 #include "hyjal_trash.h"
+
 #define SPELL_FROST_ARMOR 31256
 #define SPELL_DEATH_AND_DECAY 31258
+
 #define SPELL_FROST_NOVA 31250
 #define SPELL_ICEBOLT 31249
+
 #define SAY_ONDEATH "You have won this battle, but not... the... war"
 #define SOUND_ONDEATH 11026
+
 #define SAY_ONSLAY1 "All life must perish!"
 #define SAY_ONSLAY2 "Victory to the Legion!"
 #define SOUND_ONSLAY1 11025
 #define SOUND_ONSLAY2 11057
+
 #define SAY_DECAY1 "Crumble and rot!"
 #define SAY_DECAY2 "Ashes to ashes, dust to dust"
 #define SOUND_DECAY1 11023
 #define SOUND_DECAY2 11055
+
 #define SAY_NOVA1 "Succumb to the icy chill... of death!"
 #define SAY_NOVA2 "It will be much colder in your grave"
 #define SOUND_NOVA1 11024
 #define SOUND_NOVA2 11058
+
 #define SAY_ONAGGRO "The Legion's final conquest has begun! Once again the subjugation of this world is within our grasp. Let none survive!"
 #define SOUND_ONAGGRO 11022
+
 struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
 {
     boss_rage_winterchillAI(Creature *c) : hyjal_trashAI(c)
@@ -30,12 +38,14 @@ struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
         pGo = false;
         pos = 0;
     }
+
     uint32 FrostArmorTimer;
     uint32 DecayTimer;
     uint32 NovaTimer;
     uint32 IceboltTimer;
     bool pGo;
     uint32 pos;
+
     void Reset()
     {
         damageTaken = 0;
@@ -43,9 +53,11 @@ struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
         DecayTimer = 45000;
         NovaTimer = 15000;
         IceboltTimer = 10000;
+
         if (pInstance && IsEvent)
             pInstance->SetData(DATA_RAGEWINTERCHILLEVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance && IsEvent)
@@ -53,6 +65,7 @@ struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
         DoPlaySoundToSet(m_creature, SOUND_ONAGGRO);
         m_creature->MonsterYell(SAY_ONAGGRO, LANG_UNIVERSAL, 0);
     }
+
     void KilledUnit(Unit *victim)
     {
         switch(rand()%2)
@@ -67,6 +80,7 @@ struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
                 break;
         }
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
@@ -77,6 +91,7 @@ struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
                 m_creature->AddThreat(target,0.0);
         }
     }
+
     void JustDied(Unit *victim)
     {
         hyjal_trashAI::JustDied(victim);
@@ -85,6 +100,7 @@ struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
         DoPlaySoundToSet(m_creature, SOUND_ONDEATH);
         m_creature->MonsterYell(SAY_ONDEATH, LANG_UNIVERSAL, NULL);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IsEvent)
@@ -109,9 +125,11 @@ struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
                 }
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (FrostArmorTimer < diff)
         {
             DoCast(m_creature, SPELL_FROST_ARMOR);
@@ -154,13 +172,16 @@ struct TRINITY_DLL_DECL boss_rage_winterchillAI : public hyjal_trashAI
             DoCast(SelectTarget(SELECT_TARGET_RANDOM,0,40,true), SPELL_ICEBOLT);
             IceboltTimer = 11000+rand()%20000;
         }else IceboltTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_rage_winterchill(Creature* pCreature)
 {
     return new boss_rage_winterchillAI (pCreature);
 }
+
 void AddSC_boss_rage_winterchill()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/def_hyjal.h b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/def_hyjal.h
index 7aa8c9d5517..bf2d6d99f90 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/def_hyjal.h
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/def_hyjal.h
@@ -1,14 +1,18 @@
 /* Copyright (C) 2006 - 2009 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 ERROR_INST_DATA     "TSCR: Instance data not set properly for Mount Hyjal. Encounters will be buggy"
+
 enum eTypes
 {
     WORLD_STATE_WAVES         = 2842,
     WORLD_STATE_ENEMY         = 2453,
     WORLD_STATE_ENEMYCOUNT    = 2454,
+
     DATA_ANETHERON            = 1,
     DATA_ANETHERONEVENT       = 2,
     DATA_ARCHIMONDE           = 3,
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal.cpp
index e34eb7446fd..eb6e72452c0 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal.cpp
@@ -13,49 +13,65 @@
  * along 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: 80
 SDComment: gossip text id's unknown
 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      "My companions and I are with you, Lady Proudmoore."
 #define GOSSIP_ITEM_ANETHERON       "We are ready for whatever Archimonde might send our way, Lady Proudmoore."
+
 #define GOSSIP_ITEM_BEGIN_HORDE     "I am with you, Thrall."
 #define GOSSIP_ITEM_AZGALOR         "We have nothing to fear."
+
 #define GOSSIP_ITEM_RETREAT         "We can't keep this up. Let's retreat!"
+
 #define GOSSIP_ITEM_TYRANDE         "Aid us in defending Nordrassil"
 #define ITEM_TEAR_OF_GODDESS        24494
+
 #define GOSSIP_ITEM_GM1             "[GM] Toggle Debug Timers"
 
+
 CreatureAI* GetAI_npc_jaina_proudmoore(Creature* pCreature)
 {
     hyjalAI* ai = new hyjalAI(pCreature);
+
     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 = 5500 + rand()%4000;
     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* pPlayer, Creature* pCreature)
 {
     hyjalAI* ai = CAST_AI(hyjalAI, pCreature->AI());
     if (ai->EventBegun)
         return false;
+
     uint32 RageEncounter = ai->GetInstanceData(DATA_RAGEWINTERCHILLEVENT);
     uint32 AnetheronEncounter = ai->GetInstanceData(DATA_ANETHERONEVENT);
     if (RageEncounter == NOT_STARTED)
@@ -64,11 +80,14 @@ bool GossipHello_npc_jaina_proudmoore(Player* pPlayer, Creature* pCreature)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ANETHERON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
     else if (RageEncounter == DONE && AnetheronEncounter == DONE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_RETREAT, GOSSIP_SENDER_MAIN,    GOSSIP_ACTION_INFO_DEF + 3);
+
     if (pPlayer->isGameMaster())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_ITEM_GM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_jaina_proudmoore(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     hyjalAI* ai = CAST_AI(hyjalAI, pCreature->AI());
@@ -92,24 +111,31 @@ bool GossipSelect_npc_jaina_proudmoore(Player* pPlayer, Creature* pCreature, uin
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_thrall(Creature* pCreature)
 {
     hyjalAI* ai = new hyjalAI(pCreature);
+
     ai->Reset();
     ai->EnterEvadeMode();
+
     ai->Spell[0].SpellId = SPELL_CHAIN_LIGHTNING;
     ai->Spell[0].Cooldown = 3000 + 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* pPlayer, Creature* pCreature)
 {
     hyjalAI* ai = CAST_AI(hyjalAI, pCreature->AI());
     if (ai->EventBegun)
         return false;
+
     uint32 AnetheronEvent = ai->GetInstanceData(DATA_ANETHERONEVENT);
     // Only let them start the Horde phases if Anetheron is dead.
     if (AnetheronEvent == DONE && ai->GetInstanceData(DATA_ALLIANCE_RETREAT))
@@ -123,11 +149,14 @@ bool GossipHello_npc_thrall(Player* pPlayer, Creature* pCreature)
         else if (AzgalorEvent == DONE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_RETREAT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
     }
+
     if (pPlayer->isGameMaster())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_ITEM_GM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_thrall(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     hyjalAI* ai = CAST_AI(hyjalAI, pCreature->AI());
@@ -152,6 +181,7 @@ bool GossipSelect_npc_thrall(Player* pPlayer, Creature* pCreature, uint32 uiSend
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_tyrande_whisperwind(Creature* pCreature)
 {
     hyjalAI* ai = new hyjalAI(pCreature);
@@ -159,16 +189,19 @@ CreatureAI* GetAI_npc_tyrande_whisperwind(Creature* pCreature)
     ai->EnterEvadeMode();
     return ai;
 }
+
 bool GossipHello_npc_tyrande_whisperwind(Player* pPlayer, Creature* pCreature)
 {
     hyjalAI* ai = CAST_AI(hyjalAI, pCreature->AI());
     uint32 AzgalorEvent = ai->GetInstanceData(DATA_AZGALOREVENT);
+
     // Only let them get item if Azgalor is dead.
     if (AzgalorEvent == DONE && !pPlayer->HasItemCount(ITEM_TEAR_OF_GODDESS,1))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TYRANDE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
     pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_tyrande_whisperwind(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
@@ -186,21 +219,25 @@ bool GossipSelect_npc_tyrande_whisperwind(Player* pPlayer, Creature* pCreature,
     }
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_thrall";
     newscript->GetAI = &GetAI_npc_thrall;
     newscript->pGossipHello = &GossipHello_npc_thrall;
     newscript->pGossipSelect = &GossipSelect_npc_thrall;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_tyrande_whisperwind";
     newscript->pGossipHello = &GossipHello_npc_tyrande_whisperwind;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjalAI.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjalAI.cpp
index f408f7b3bf1..e8bf7d8ceeb 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjalAI.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjalAI.cpp
@@ -13,12 +13,14 @@
  * along 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: 90
 SDComment:
 SDCategory: Caverns of Time, Mount Hyjal
 EndScriptData */
+
 #include "precompiled.h"
 #include "hyjalAI.h"
 #include "hyjal_trash.h"
@@ -26,10 +28,13 @@ EndScriptData */
 #include "Language.h"
 #include "Chat.h"
 #include "Object.h"
+
 #define SPAWN_GARG_GATE 0
 #define SPAWN_WYRM_GATE 1
 #define SPAWN_NEAR_TOWER 2
+
 #define YELL_HURRY  "Hurry, we don't have much time"
+
 // Locations for summoning gargoyls and frost wyrms in special cases
 float SpawnPointSpecial[3][3]=
 {
@@ -37,6 +42,7 @@ float SpawnPointSpecial[3][3]=
     {5624.53,    -2548.12,    1551.54}, //spawn point for the frost wyrm near the horde gate
     {5604.41,   -2811.98,   1547.77}  //spawn point for the gargoyles and wyrms near the horde tower
 };
+
 // Locations for summoning waves in Alliance base
 float AllianceBase[4][3]=
 {
@@ -45,12 +51,14 @@ float AllianceBase[4][3]=
     {4928.41,    -1510.35,    1327.99},
     {4938.35,    -1521.00,    1326.69}
 };
+
 float JainaDummySpawn[2][4]=
 {
     {5497.01, -2719.03, 1483.08, 2.90426},
     {5484.98, -2721.69, 1483.39, 6.00656}
 };
 
+
 // Locations for summoning waves in Horde base
 float HordeBase[4][3]=
 {
@@ -59,12 +67,14 @@ float HordeBase[4][3]=
     {5468.45,    -2355.13,    1459.99},
     {5479.06,    -2344.16,    1461.74}
 };
+
 // Lady Jaina's waypoints when retreathing
 float JainaWPs[2][3]=
 {
     {5078.56,    -1789.79,    1320.73},//next to the small stairs
     {5037.38,    -1778.39,    1322.61},//center of alliance base
 };
+
 float InfernalPos[8][3]=//spawn points for the infernals in the horde base
 {
     {5453.59,    -2764.52,    1493.50},
@@ -76,6 +86,7 @@ float InfernalPos[8][3]=//spawn points for the infernals in the horde base
     {5510.16,    -2691.75,    1479.66},
     {5482.39,    -2689.19,    1481.09}
 };
+
 float InfernalSPWP[26][4]=//spawn points for the infernals in the horde base used in the cleaning wave
 {
     {5490.96, -2718.72, 1482.96, 0.49773},
@@ -105,6 +116,7 @@ float InfernalSPWP[26][4]=//spawn points for the infernals in the horde base use
     {5549.76, -2692.93, 1482.68, 2.19414},
     {5459.78, -2755.71, 1490.68, 1.05139}
 };
+
 float VeinPos[14][8]=//spawn points of the ancient gem veins
 {
     {5184.84,    -1982.59,    1382.66,    2.58079,    0,    0,    0.960944,    0.276742},  //alliance
@@ -122,6 +134,7 @@ float VeinPos[14][8]=//spawn points of the ancient gem veins
     {5374.3,    -3420.59,    1653.43,    1.45762,    0,    0,    0.665981,    0.745969},    //horde
     {5441.54,    -3321.59,    1651.55,    0.258306,    0,    0,    0.128794,    0.991671}   //horde
 };
+
 float AllianceOverrunGargPos[5][4]=//gargoyle spawn points in the alliance overrun
 {
     {5279.94, -2049.68, 1311.38, 0},//garg1
@@ -130,6 +143,7 @@ float AllianceOverrunGargPos[5][4]=//gargoyle spawn points in the alliance overr
     {5071.52, -2425.63, 1454.48, 5.54},//garg4
     {5120.65, -2467.92, 1463.93, 2.54}//garg5
 };
+
 float AllianceFirePos[92][8]=//spawn points for the fire visuals (GO) in the alliance base
 {
     {5039.9,    -1796.84,    1323.88,    2.59222,    0,    0,    0.962511,    0.271243},
@@ -225,6 +239,7 @@ float AllianceFirePos[92][8]=//spawn points for the fire visuals (GO) in the all
     {5332.5    ,    -2181.28,    1279.95,    4.6906,        0,    0,    0.714768,    -0.699362},
     {5108.2    ,    -2429.84,    1427.73,    4.5194,        0,    0,    0.771943,    -0.635691}
 };
+
 float HordeFirePos[65][8]=//spawn points for the fire visuals (GO) in the horde base
 {
     {5524.11,    -2612.73,    1483.38,    1.96198,    0,    0,    0.831047,    0.556202},
@@ -293,12 +308,13 @@ float HordeFirePos[65][8]=//spawn points for the fire visuals (GO) in the horde
     {5534.15,    -2679.35,    1483.61,    0.428685,    0,    0,    0.212705,    0.977116},
     {5545.43,    -2647.82,    1483.05,    5.38848,    0,    0,    0.432578,    -0.901596}
 };
+
 hyjalAI::hyjalAI(Creature *c) : npc_escortAI(c), Summons(m_creature)
 {
     pInstance = c->GetInstanceData();
     VeinsSpawned[0] = false;
     VeinsSpawned[1] = false;
-    for (uint8 i=0; i<14; ++i)
+    for(uint8 i=0;i<14; ++i)
         VeinGUID[i] = 0;
     InfernalCount = 0;
     TeleportTimer = 1000;
@@ -314,14 +330,17 @@ hyjalAI::hyjalAI(Creature *c) : npc_escortAI(c), Summons(m_creature)
     MassTeleportTimer = 0;
     DoMassTeleport = false;
 }
+
 void hyjalAI::JustSummoned(Creature *summoned)
 {
     Summons.Summon(summoned);
 }
+
 void hyjalAI::SummonedCreatureDespawn(Creature* summoned)
 {
     Summons.Despawn(summoned);
 }
+
 void hyjalAI::Reset()
 {
     IsDummy = false;
@@ -330,13 +349,16 @@ void hyjalAI::Reset()
     PlayerGUID = 0;
     BossGUID[0] = 0;
     BossGUID[1] = 0;
+
     // Timers
     NextWaveTimer = 10000;
     CheckTimer = 0;
     RetreatTimer = 1000;
+
     // Misc
     WaveCount = 0;
     EnemyCount = 0;
+
     // Set faction properly based on Creature entry
     switch(m_creature->GetEntry())
     {
@@ -344,13 +366,16 @@ void hyjalAI::Reset()
             Faction = 0;
             DoCast(m_creature, SPELL_BRILLIANCE_AURA, true);
             break;
+
         case THRALL:
             Faction = 1;
             break;
+
         case TYRANDE:
             Faction = 2;
             break;
     }
+
     //Bools
     EventBegun = false;
     FirstBossDead = false;
@@ -359,11 +384,15 @@ void hyjalAI::Reset()
     bRetreat = false;
     Debug = false;
 
+
     //Flags
     m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+
     //Initialize spells
     memset(Spell, 0, sizeof(Spell));
 
+
+
     //Reset Instance Data for trash count
     if (pInstance)
     {
@@ -376,9 +405,11 @@ void hyjalAI::Reset()
             pInstance->SetData(DATA_RESET_TRASH_COUNT, 0);
         }
     }else error_log(ERROR_INST_DATA);
+
     //Visibility
     DoHide = true;
 }
+
 void hyjalAI::EnterEvadeMode()
 {
     if (m_creature->GetEntry() != JAINA)
@@ -386,30 +417,37 @@ void hyjalAI::EnterEvadeMode()
     m_creature->DeleteThreatList();
     m_creature->CombatStop(true);
     m_creature->LoadCreaturesAddon();
+
     if (m_creature->isAlive())
         m_creature->GetMotionMaster()->MoveTargetedHome();
+
     m_creature->SetLootRecipient(NULL);
 }
+
 void hyjalAI::EnterCombat(Unit *who)
 {
-    if (IsDummy)
-        return;
-    for (uint8 i = 0; i < 3; ++i)
+    if (IsDummy)return;
+    for(uint8 i = 0; i < 3; ++i)
         if (Spell[i].Cooldown)
             SpellTimer[i] = Spell[i].Cooldown;
+
     Talk(ATTACKED);
 }
+
 void hyjalAI::MoveInLineOfSight(Unit *who)
 {
     if (IsDummy)
         return;
+
     npc_escortAI::MoveInLineOfSight(who);
 }
+
 void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
 {
     uint32 random = rand()%4;
     float SpawnLoc[3];
-    for (uint8 i = 0; i < 3; ++i)
+
+    for(uint8 i = 0; i < 3; ++i)
     {
         SpawnLoc[i] = Base[random][i];
     }
@@ -417,14 +455,13 @@ void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
     switch(entry)
     {
             case 17906:    //GARGOYLE
+
                 if (!FirstBossDead && (WaveCount == 1 || WaveCount == 3))
                 {//summon at tower
                     pCreature = m_creature->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0]+irand(-20,20), SpawnPointSpecial[SPAWN_NEAR_TOWER][1]+irand(-20,20), SpawnPointSpecial[SPAWN_NEAR_TOWER][2]+irand(-10,10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                     if (pCreature)
                         CAST_AI(hyjal_trashAI, pCreature->AI())->useFlyPath = true;
-                }
-                else
-                {//summon at gate
+                }else{//summon at gate
                     pCreature = m_creature->SummonCreature(entry, SpawnPointSpecial[SPAWN_GARG_GATE][0]+irand(-10,10), SpawnPointSpecial[SPAWN_GARG_GATE][1]+irand(-10,10), SpawnPointSpecial[SPAWN_GARG_GATE][2]+irand(-10,10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                 }
                 break;
@@ -432,9 +469,7 @@ void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
                 if (FirstBossDead && WaveCount == 1)
                 {//summon at gate
                     pCreature = m_creature->SummonCreature(entry, SpawnPointSpecial[SPAWN_WYRM_GATE][0],SpawnPointSpecial[SPAWN_WYRM_GATE][1],SpawnPointSpecial[SPAWN_WYRM_GATE][2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
-                }
-                else
-                {
+                }else{
                     pCreature = m_creature->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0], SpawnPointSpecial[SPAWN_NEAR_TOWER][1],SpawnPointSpecial[SPAWN_NEAR_TOWER][2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                     if (pCreature)
                         CAST_AI(hyjal_trashAI, pCreature->AI())->useFlyPath = true;
@@ -448,11 +483,14 @@ void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
             default:
                 pCreature = m_creature->SummonCreature(entry, SpawnLoc[0], SpawnLoc[1], SpawnLoc[2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                 break;
+
     }
+
     if (pCreature)
     {
         // Increment Enemy Count to be used in World States and instance script
         ++EnemyCount;
+
         pCreature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
         pCreature->setActive(true);
         switch(entry)
@@ -487,33 +525,40 @@ void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
         }
     }
 }
+
 void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3])
 {
     // 1 in 4 chance we give a rally yell. Not sure if the chance is offilike.
     if (rand()%4 == 0)
         Talk(RALLY);
+
     if (!pInstance)
     {
         error_log(ERROR_INST_DATA);
         return;
     }
     InfernalCount = 0;//reset infernal count every new wave
+
     EnemyCount = pInstance->GetData(DATA_TRASH);
-    for (uint8 i = 0; i < 18; ++i)
+    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
+
         // Set world state to our current wave number
         pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, stateValue);    // Set world state to our current wave number
         // Enable world state
         pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 1);             // Enable world state
+
         pInstance->SetData(DATA_TRASH, EnemyCount);         // Send data for instance script to update count
+
         if (!Debug)
             NextWaveTimer = wave[Count].WaveTimer;
         else
@@ -527,39 +572,51 @@ void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3])
         // Set world state for waves to 0 to disable it.
         pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
         pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 1);
+
         // Set World State for enemies invading to 1.
         pInstance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 1);
+
         Summon = false;
     }
     CheckTimer = 5000;
 }
+
 void hyjalAI::StartEvent(Player* pPlayer)
 {
     if (!pPlayer || IsDummy || !pInstance)
         return;
+
     Talk(BEGIN);
+
     EventBegun = true;
     Summon = true;
+
     NextWaveTimer = 15000;
     CheckTimer = 5000;
     PlayerGUID = pPlayer->GetGUID();
+
     m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+
     pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
     pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0);
     pInstance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0);
+
     DeSpawnVeins();
 }
+
 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 < 9; ++i)
+    for(uint8 i = 0; i < 9; ++i)
     {
         if (Faction == 0)                                    // Alliance
         {
@@ -572,9 +629,12 @@ void hyjalAI::Talk(uint32 id)
                 index.push_back(i);
         }
     }
+
     if (index.empty())
         return;                                             // No quotes found, no use to continue
+
     uint8 ind = *(index.begin()) + rand()%index.size();
+
     int32 YellId = 0;
     if (Faction == 0)                                        // Alliance
     {
@@ -584,14 +644,17 @@ void hyjalAI::Talk(uint32 id)
     {
         YellId = ThrallQuotes[ind].textid;
     }
+
     if (YellId)
         DoScriptText(YellId, m_creature);
 }
+
 void hyjalAI::Retreat()
 {
     if (pInstance)
     {
         pInstance->SetData(TYPE_RETREAT,SPECIAL);
+
         if (Faction == 0)
         {
             pInstance->SetData(DATA_ALLIANCE_RETREAT, 1);
@@ -619,11 +682,12 @@ void hyjalAI::Retreat()
     Overrun = true;
     m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);//cant talk after overrun event started
 }
+
 void hyjalAI::SpawnVeins()
 {
     if (Faction == 0)
     {
-        if (VeinsSpawned[0]) //prevent any buggers
+        if (VeinsSpawned[0])//prevent any buggers
             return;
         for (uint8 i = 0; i<7; ++i)
         {
@@ -632,9 +696,7 @@ void hyjalAI::SpawnVeins()
                 VeinGUID[i]=gem->GetGUID();
         }
         VeinsSpawned[0] = true;
-    }
-    else
-    {
+    }else{
         if (VeinsSpawned[1])
             return;
         for (uint8 i = 7; i<14; ++i)
@@ -646,6 +708,7 @@ void hyjalAI::SpawnVeins()
         VeinsSpawned[1] = true;
     }
 }
+
 void hyjalAI::DeSpawnVeins()
 {
     if (!pInstance)
@@ -674,6 +737,7 @@ void hyjalAI::DeSpawnVeins()
         }
     }
 }
+
 void hyjalAI::UpdateAI(const uint32 diff)
 {
     if (IsDummy)
@@ -696,8 +760,9 @@ void hyjalAI::UpdateAI(const uint32 diff)
                     m_creature->SetVisibility(VISIBILITY_OFF);
                     HideNearPos(m_creature->GetPositionX(), m_creature->GetPositionY());
                     HideNearPos(5037.76, -1889.71);
-                    for (uint8 i = 0; i < 92; ++i) //summon fires
+                    for(uint8 i = 0; i < 92; ++i)//summon fires
                         m_creature->SummonGameObject(FLAMEOBJECT,AllianceFirePos[i][0],AllianceFirePos[i][1],AllianceFirePos[i][2],AllianceFirePos[i][3],AllianceFirePos[i][4],AllianceFirePos[i][5],AllianceFirePos[i][6],AllianceFirePos[i][7],0);
+
                 }
                 else m_creature->SetVisibility(VISIBILITY_ON);
                 break;
@@ -708,8 +773,9 @@ void hyjalAI::UpdateAI(const uint32 diff)
                     HideNearPos(m_creature->GetPositionX(), m_creature->GetPositionY());
                     HideNearPos(5563, -2763.19);
                     HideNearPos(5542.2, -2629.36);
-                    for (uint8 i = 0; i < 65; ++i) //summon fires
+                    for(uint8 i = 0; i < 65; ++i)//summon fires
                         m_creature->SummonGameObject(FLAMEOBJECT,HordeFirePos[i][0],HordeFirePos[i][1],HordeFirePos[i][2],HordeFirePos[i][3],HordeFirePos[i][4],HordeFirePos[i][5],HordeFirePos[i][6],HordeFirePos[i][7],0);
+
                 }
                 else m_creature->SetVisibility(VISIBILITY_ON);
                 break;
@@ -730,9 +796,7 @@ void hyjalAI::UpdateAI(const uint32 diff)
                 RespawnNearPos(5542.2, -2629.36);
             }
             m_creature->SetVisibility(VISIBILITY_ON);
-        }
-        else
-        {
+        }else{
             RespawnTimer -= diff;
             m_creature->SetVisibility(VISIBILITY_OFF);
         }
@@ -761,8 +825,10 @@ void hyjalAI::UpdateAI(const uint32 diff)
             m_creature->SetVisibility(VISIBILITY_OFF);
         }else RetreatTimer -= diff;
     }
+
     if (!EventBegun)
         return;
+
     if (Summon)
     {
         if (pInstance && EnemyCount)
@@ -771,6 +837,7 @@ void hyjalAI::UpdateAI(const uint32 diff)
             if (!EnemyCount)
                 NextWaveTimer = 5000;
         }
+
         if (NextWaveTimer < diff)
         {
             if (Faction == 0)
@@ -780,9 +847,10 @@ void hyjalAI::UpdateAI(const uint32 diff)
             ++WaveCount;
         }else NextWaveTimer -= diff;
     }
+
     if (CheckTimer < diff)
     {
-        for (uint8 i = 0; i < 2; ++i)
+        for(uint8 i = 0; i < 2; ++i)
         {
             if (BossGUID[i])
             {
@@ -810,9 +878,11 @@ void hyjalAI::UpdateAI(const uint32 diff)
         }
         CheckTimer = 5000;
     }else CheckTimer -= diff;
+
     if (!UpdateVictim())
         return;
-    for (uint8 i = 0; i < 3; ++i)
+
+    for(uint8 i = 0; i < 3; ++i)
     {
         if (Spell[i].SpellId)
         {
@@ -820,13 +890,16 @@ void hyjalAI::UpdateAI(const uint32 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);
@@ -835,6 +908,7 @@ void hyjalAI::UpdateAI(const uint32 diff)
             }else SpellTimer[i] -= diff;
         }
     }
+
     DoMeleeAttackIfReady();
 }
 void hyjalAI::JustDied(Unit* killer)
@@ -865,6 +939,7 @@ void hyjalAI::HideNearPos(float x, float y)
     Cell cell(pair);
     cell.data.Part.reserved = ALL_DISTRICT;
     cell.SetNoCreate();
+
     // First get all creatures.
     std::list creatures;
     Trinity::AllFriendlyCreaturesInGrid creature_check(m_creature);
@@ -872,12 +947,14 @@ void hyjalAI::HideNearPos(float x, float y)
     TypeContainerVisitor
         ,
         GridTypeMapContainer> creature_visitor(creature_searcher);
+
     CellLock cell_lock(cell, pair);
                                                             // Get Creatures
     cell_lock->Visit(cell_lock, creature_visitor, *(m_creature->GetMap()));
+
     if (!creatures.empty())
     {
-        for (std::list::iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
+        for(std::list::iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
         {
             (*itr)->SetVisibility(VISIBILITY_OFF);
             (*itr)->setFaction(35);//make them friendly so mobs won't attack them
@@ -890,6 +967,7 @@ void hyjalAI::RespawnNearPos(float x, float y)
     Cell cell(p);
     cell.data.Part.reserved = ALL_DISTRICT;
     cell.SetNoCreate();
+
     Trinity::RespawnDo u_do;
     Trinity::WorldObjectWorker worker(m_creature, u_do);
     TypeContainerVisitor, GridTypeMapContainer > obj_worker(worker);
@@ -921,6 +999,7 @@ void hyjalAI::WaypointReached(uint32 i)
         Cell cell(pair);
         cell.data.Part.reserved = ALL_DISTRICT;
         cell.SetNoCreate();
+
         // First get all creatures.
         std::list creatures;
         Trinity::AllFriendlyCreaturesInGrid creature_check(m_creature);
@@ -928,11 +1007,13 @@ void hyjalAI::WaypointReached(uint32 i)
         TypeContainerVisitor
             ,
             GridTypeMapContainer> creature_visitor(creature_searcher);
+
         CellLock cell_lock(cell, pair);
         cell_lock->Visit(cell_lock, creature_visitor, *(m_creature->GetMap()));
+
         if (!creatures.empty())
         {
-            for (std::list::iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
+            for(std::list::iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
             {
                 if ((*itr) && (*itr)->isAlive() && (*itr) != m_creature && (*itr)->GetEntry() != JAINA)
                 {
@@ -961,17 +1042,20 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
             Cell cell(pair);
             cell.data.Part.reserved = ALL_DISTRICT;
             cell.SetNoCreate();
+
             std::list creatures;
             Trinity::AllFriendlyCreaturesInGrid creature_check(m_creature);
             Trinity::CreatureListSearcher creature_searcher(m_creature, creatures, creature_check);
             TypeContainerVisitor
                 ,
                 GridTypeMapContainer> creature_visitor(creature_searcher);
+
             CellLock cell_lock(cell, pair);
             cell_lock->Visit(cell_lock, creature_visitor, *(m_creature->GetMap()));
+
             if (!creatures.empty())
             {
-                for (std::list::iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
+                for(std::list::iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
                 {
                     if ((*itr) && (*itr)->isAlive())
                     {
@@ -984,6 +1068,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
                 bRetreat = true;
                 RetreatTimer = 1000;
             }
+
             WaitForTeleport = false;
             Teleported = true;
         }TeleportTimer -= diff;
@@ -994,9 +1079,10 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
     switch(faction)
     {
         case 0://alliance
-            for (uint8 i = 0; i < 92; ++i) //summon fires
+            for(uint8 i = 0; i < 92; ++i)//summon fires
                 m_creature->SummonGameObject(FLAMEOBJECT,AllianceFirePos[i][0],AllianceFirePos[i][1],AllianceFirePos[i][2],AllianceFirePos[i][3],AllianceFirePos[i][4],AllianceFirePos[i][5],AllianceFirePos[i][6],AllianceFirePos[i][7],0);
-            for (uint8 i = 0; i < 25; ++i) //summon 25 ghouls
+
+            for(uint8 i = 0; i < 25; ++i)//summon 25 ghouls
             {
                 uint8 r = rand()%4;
                 Creature* pUnit = m_creature->SummonCreature(GHOUL, AllianceBase[r][0]+irand(-15,15), AllianceBase[r][1]+irand(-15,15), AllianceBase[r][2], 0, TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
@@ -1008,7 +1094,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
                     pUnit->setActive(true);
                 }
             }
-            for (uint8 i = 0; i < 3; ++i) //summon 3 abominations
+            for(uint8 i = 0; i < 3; ++i)//summon 3 abominations
             {
                 uint8 r = rand()%4;
                 Creature* pUnit = m_creature->SummonCreature(ABOMINATION, AllianceBase[r][0]+irand(-15,15), AllianceBase[r][1]+irand(-15,15), AllianceBase[r][2], 0, TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
@@ -1020,7 +1106,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
                     pUnit->setActive(true);
                 }
             }
-            for (uint8 i = 0; i < 5; ++i) //summon 5 gargoyles
+            for(uint8 i = 0; i < 5; ++i)//summon 5 gargoyles
             {
                 Creature* pUnit = m_creature->SummonCreature(GARGOYLE, AllianceOverrunGargPos[i][0], AllianceOverrunGargPos[i][1], AllianceOverrunGargPos[i][2], AllianceOverrunGargPos[i][3], TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
                 if (pUnit)
@@ -1034,9 +1120,10 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
             }
             break;
         case 1://horde
-            for (uint8 i = 0; i < 65; ++i) //summon fires
+            for(uint8 i = 0; i < 65; ++i)//summon fires
                 m_creature->SummonGameObject(FLAMEOBJECT,HordeFirePos[i][0],HordeFirePos[i][1],HordeFirePos[i][2],HordeFirePos[i][3],HordeFirePos[i][4],HordeFirePos[i][5],HordeFirePos[i][6],HordeFirePos[i][7],0);
-            for (uint8 i = 0; i < 26; ++i) //summon infernals
+
+            for(uint8 i = 0; i < 26; ++i)//summon infernals
             {
                 Creature* pUnit = m_creature->SummonCreature(GIANT_INFERNAL, InfernalSPWP[i][0], InfernalSPWP[i][1], InfernalSPWP[i][2], InfernalSPWP[i][3], TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
                 if (pUnit)
@@ -1048,7 +1135,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
                     pUnit->setActive(true);
                 }
             }
-            for (uint8 i = 0; i < 25; ++i) //summon 25 ghouls
+            for(uint8 i = 0; i < 25; ++i)//summon 25 ghouls
             {
                 uint8 r = rand()%4;
                 Creature* pUnit = m_creature->SummonCreature(GHOUL, HordeBase[r][0]+irand(-15,15), HordeBase[r][1]+irand(-15,15), HordeBase[r][2], 0, TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
@@ -1060,7 +1147,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
                     pUnit->setActive(true);
                 }
             }
-            for (uint8 i = 0; i < 5; ++i) //summon 5 abominations
+            for(uint8 i = 0; i < 5; ++i)//summon 5 abominations
             {
                 uint8 r = rand()%4;
                 Creature* pUnit = m_creature->SummonCreature(ABOMINATION, HordeBase[r][0]+irand(-15,15), HordeBase[r][1]+irand(-15,15), HordeBase[r][2], 0, TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjalAI.h b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjalAI.h
index 3a2a189d311..c646c47699c 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjalAI.h
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjalAI.h
@@ -1,10 +1,13 @@
 /* Copyright (C) 2006 - 2009 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"
 #include "escort_ai.h"
+
 // Trash Mobs summoned in waves
 #define NECROMANCER         17899//done
 #define ABOMINATION         17898//done
@@ -15,33 +18,41 @@
 #define FROST_WYRM          17907//done
 #define GIANT_INFERNAL      17908//done
 #define FEL_STALKER         17916//done
+
 #define JAINA               17772
 #define THRALL              17852
 #define TYRANDE             17948
+
 #define ANCIENT_VEIN        185557
 #define FLAMEOBJECT         182592
+
 // 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 SPELL_MASS_TELEPORT       16807
+
 //Spells for Jaina
 #define SPELL_BRILLIANCE_AURA     31260                     // The database must handle this spell via creature_addon(it should, but is removed in evade..)
 #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
 {   // Rage Winterchill Wave 1-8
     {GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, 0, 0, 0, 0, 0, 0, 0, 0, 120000, false},
@@ -66,6 +77,7 @@ static Wave AllianceWaves[]=                                // Waves that will b
     // 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
 {   // Kaz'Rogal Wave 1-8
     {GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, BANSHEE, BANSHEE, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 180000, false},
@@ -90,17 +102,20 @@ static Wave HordeWaves[]=                                   // Waves that are su
     // 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)
     int32 textid;                                           // The text id to be yelled
 };
+
 enum YellId
 {
     ATTACKED     = 0,                                       // Used when attacked and set in combat
@@ -111,6 +126,7 @@ enum YellId
     SUCCESS      = 5,                                       // Used when the raid has sucessfully defeated a wave phase
     DEATH        = 6,                                       // Used on death
 };
+
 static Yells JainaQuotes[]=
 {
     {ATTACKED, -1534000},
@@ -123,6 +139,7 @@ static Yells JainaQuotes[]=
     {SUCCESS, -1534007},
     {DEATH, -1534008},
 };
+
 static Yells ThrallQuotes[]=
 {
     {ATTACKED, -1534009},
@@ -135,19 +152,28 @@ static Yells ThrallQuotes[]=
     {SUCCESS, -1534016},
     {DEATH, -1534017},
 };
+
 struct TRINITY_DLL_DECL hyjalAI : public npc_escortAI
 {
     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 EnterCombat(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.
+
     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 SpawnVeins();
     void DeSpawnVeins();
     void JustSummoned(Creature *summoned);
@@ -157,23 +183,32 @@ struct TRINITY_DLL_DECL hyjalAI : public npc_escortAI
     void WaypointReached(uint32 i);
     void DoOverrun(uint32 faction, const uint32 diff);
     void MoveInLineOfSight(Unit *who);
+
     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
+
     public:
         ScriptedInstance* pInstance;
+
         uint64 PlayerGUID;
         uint64 BossGUID[2];
         uint64 VeinGUID[14];
+
         uint32 NextWaveTimer;
         uint32 WaveCount;
         uint32 CheckTimer;
         uint32 Faction;
         uint32 EnemyCount;
         uint32 RetreatTimer;
+
         bool EventBegun;
         bool FirstBossDead;
         bool SecondBossDead;
@@ -197,12 +232,14 @@ struct TRINITY_DLL_DECL hyjalAI : public npc_escortAI
         uint32 MassTeleportTimer;
         bool DoMassTeleport;
         uint64 DummyGuid;
+
         struct Spell
         {
             uint32 SpellId;
             uint32 Cooldown;
             uint32 TargetType;
         }Spell[3];
+
     private:
         uint32 SpellTimer[3];
         //std::list CreatureList;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp
index a0216c3c608..705039a6d09 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp
@@ -3,11 +3,13 @@
 #include "def_hyjal.h"
 #include "hyjal_trash.h"
 #include "hyjalAI.h"
+
 #define SPELL_METEOR 33814 //infernal visual
 #define SPELL_IMMOLATION 37059
 #define SPELL_FLAME_BUFFET 31724
 #define NPC_TRIGGER  21987 //World Trigger (Tiny)
 #define MODEL_INVIS  11686 //invisible model
+
 float HordeWPs[8][3]=//basic waypoints from spawn to leader
 {
     {5492.91,    -2404.61,    1462.63},
@@ -30,24 +32,28 @@ float AllianceWPs[8][3]=//basic waypoints from spawn to leader
     {5037.77,    -1770.56,    1324.36},
     {5067.23,    -1789.95,    1321.17}
 };
+
 float FrostWyrmWPs[3][3]=//waypoints for the frost wyrms in horde base
 {
     {5580.82,    -2628.83,    1528.28},
     {5550.90,    -2667.16,    1505.45},
     {5459.64,    -2725.91,    1484.83}
 };
+
 float GargoyleWPs[3][3]=//waypoints for the gargoyles in horde base
 {
     {5533.66,    -2634.32,    1495.33},
     {5517.88,    -2712.05,    1490.54},
     {5459.64,    -2725.91,    1484.83}
 };
+
 float FlyPathWPs[3][3]=//waypoints for the gargoyls and frost wyrms in horde base in wave 1/3
 {
     {5531.96, -2772.83, 1516.68},
     {5498.32, -2734.84, 1497.01},
     {5456.67, -2725.48, 1493.08}
 };
+
 float AllianceOverrunWP[55][3]=//waypoints in the alliance base used in the end in the cleaning wave
 {
     {4976.37,-1708.02,1339.43},//0spawn
@@ -105,7 +111,9 @@ float AllianceOverrunWP[55][3]=//waypoints in the alliance base used in the end
     {5180.41, -2121.87, 1292.62},//52 garg target3
     {5088.68, -2432.04, 1441.73},//53 garg target4
     {5111.26, -2454.73, 1449.63}//54 garg target5
+
 };
+
 float HordeOverrunWP[21][3]=//waypoints in the horde base used in the end in the cleaning wave
 {
     {5490.72,-2702.94,1482.14},//0 start
@@ -130,6 +138,7 @@ float HordeOverrunWP[21][3]=//waypoints in the horde base used in the end in the
     {5433.25,-2712.93,1493.02},//19 end 1
     {5429.91,-2718.44,1493.42}//20 end 2
 };
+
 hyjal_trashAI::hyjal_trashAI(Creature *c) : npc_escortAI(c)
 {
     pInstance = c->GetInstanceData();
@@ -144,6 +153,7 @@ hyjal_trashAI::hyjal_trashAI(Creature *c) : npc_escortAI(c)
     damageTaken = 0;
     Reset();
 }
+
 void hyjal_trashAI::DamageTaken(Unit *done_by, uint32 &damage)
 {
     if (done_by->GetTypeId() == TYPEID_PLAYER || (done_by->GetTypeId() == TYPEID_UNIT && CAST_CRE(done_by)->isPet()))
@@ -153,6 +163,7 @@ void hyjal_trashAI::DamageTaken(Unit *done_by, uint32 &damage)
             pInstance->SetData(DATA_RAIDDAMAGE,damage);//store raid's damage
     }
 }
+
 void hyjal_trashAI::UpdateAI(const uint32 diff)
 {
     if (IsOverrun && !SetupOverrun)
@@ -168,7 +179,7 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
             }
             if (m_creature->GetEntry() == ABOMINATION)
             {
-                for (uint8 i = 0; i < 4; ++i)
+                for(uint8 i = 0; i < 4; ++i)
                     AddWaypoint(i, AllianceWPs[i][0]+irand(-3,3), AllianceWPs[i][1]+irand(-3,3), AllianceWPs[i][2]);
                 switch(OverrunType)
                 {
@@ -180,6 +191,7 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
                         AddWaypoint(8, AllianceOverrunWP[26][0]+irand(-3,3), AllianceOverrunWP[26][1]+irand(-3,3), AllianceOverrunWP[26][2]);
                         AddWaypoint(9, AllianceOverrunWP[27][0]+irand(-3,3), AllianceOverrunWP[27][1]+irand(-3,3), AllianceOverrunWP[27][2]);
                         AddWaypoint(10, AllianceOverrunWP[28][0]+irand(-3,3), AllianceOverrunWP[28][1]+irand(-3,3), AllianceOverrunWP[28][2]);
+
                         AddWaypoint(11, AllianceOverrunWP[36][0]+irand(-3,3), AllianceOverrunWP[36][1]+irand(-3,3), AllianceOverrunWP[36][2]);
                         AddWaypoint(12, AllianceOverrunWP[37][0]+irand(-3,3), AllianceOverrunWP[37][1]+irand(-3,3), AllianceOverrunWP[37][2]);
                         AddWaypoint(13, AllianceOverrunWP[38][0]+irand(-3,3), AllianceOverrunWP[38][1]+irand(-3,3), AllianceOverrunWP[38][2]);
@@ -201,6 +213,7 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
                         AddWaypoint(8, AllianceOverrunWP[26][0]+irand(-3,3), AllianceOverrunWP[26][1]+irand(-3,3), AllianceOverrunWP[26][2]);
                         AddWaypoint(9, AllianceOverrunWP[27][0]+irand(-3,3), AllianceOverrunWP[27][1]+irand(-3,3), AllianceOverrunWP[27][2]);
                         AddWaypoint(10, AllianceOverrunWP[28][0]+irand(-3,3), AllianceOverrunWP[28][1]+irand(-3,3), AllianceOverrunWP[28][2]);
+
                         AddWaypoint(11, AllianceOverrunWP[36][0]+irand(-3,3), AllianceOverrunWP[36][1]+irand(-3,3), AllianceOverrunWP[36][2]);
                         AddWaypoint(12, AllianceOverrunWP[37][0]+irand(-3,3), AllianceOverrunWP[37][1]+irand(-3,3), AllianceOverrunWP[37][2]);
                         AddWaypoint(13, AllianceOverrunWP[38][0]+irand(-3,3), AllianceOverrunWP[38][1]+irand(-3,3), AllianceOverrunWP[38][2]);
@@ -215,8 +228,9 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
                         Start(true, true);
                         break;
                     default:
-                        for (uint8 i = 22; i < 36; ++i)
+                        for(uint8 i = 22; i < 36; ++i)
                             AddWaypoint(i-18, AllianceOverrunWP[i][0]+irand(-3,3), AllianceOverrunWP[i][1]+irand(-3,3), AllianceOverrunWP[i][2]);
+
                         SetDespawnAtEnd(true);
                         LastOverronPos = 17;
                         Start(true, true);
@@ -225,7 +239,7 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
             }
             if (m_creature->GetEntry() == GHOUL)
             {
-                for (uint8 i = 0; i < 4; ++i)
+                for(uint8 i = 0; i < 4; ++i)
                     AddWaypoint(i, AllianceWPs[i][0]+irand(-3,3), AllianceWPs[i][1]+irand(-3,3), AllianceWPs[i][2]);
                 switch(OverrunType)
                 {
@@ -287,7 +301,7 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
                         Start(true, true);
                         break;
                     default:
-                        for (uint8 i = 22; i < 36; ++i)
+                        for(uint8 i = 22; i < 36; ++i)
                             AddWaypoint(i-18, AllianceOverrunWP[i][0]+irand(-3,3), AllianceOverrunWP[i][1]+irand(-3,3), AllianceOverrunWP[i][2]);
                         SetDespawnAtEnd(true);
                         LastOverronPos = 17;
@@ -300,7 +314,7 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
         {
             if (m_creature->GetEntry() == GHOUL)
             {
-                for (uint8 i = 0; i < 6; ++i)
+                for(uint8 i = 0; i < 6; ++i)
                     AddWaypoint(i, HordeWPs[i][0]+irand(-3,3), HordeWPs[i][1]+irand(-3,3), HordeWPs[i][2]);
                 switch(OverrunType)
                 {
@@ -325,7 +339,7 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
                         Start(true, true);
                         break;
                     default:
-                        for (uint8 i = 0; i < 16; ++i)
+                        for(uint8 i = 0; i < 16; ++i)
                             AddWaypoint(i+6, HordeOverrunWP[i][0]+irand(-10,10), HordeOverrunWP[i][1]+irand(-10,10), HordeOverrunWP[i][2]);
                         SetDespawnAtEnd(true);
                         LastOverronPos = 21;
@@ -335,9 +349,9 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
             }
             if (m_creature->GetEntry() == ABOMINATION)
             {
-                for (uint8 i = 0; i < 6; ++i)
+                for(uint8 i = 0; i < 6; ++i)
                     AddWaypoint(i, HordeWPs[i][0]+irand(-10,10), HordeWPs[i][1]+irand(-10,10), HordeWPs[i][2]);
-                for (uint8 i = 0; i < 16; ++i)
+                for(uint8 i = 0; i < 16; ++i)
                     AddWaypoint(i+6, HordeOverrunWP[i][0]+irand(-10,10), HordeOverrunWP[i][1]+irand(-10,10), HordeOverrunWP[i][2]);
                 SetDespawnAtEnd(true);
                 LastOverronPos = 21;
@@ -346,15 +360,18 @@ void hyjal_trashAI::UpdateAI(const uint32 diff)
         }
     }
 }
+
 void hyjal_trashAI::JustDied(Unit *victim)
 {
     if (!pInstance)
         return;
     if (IsEvent && !m_creature->isWorldBoss())
         pInstance->SetData(DATA_TRASH, 0);//signal trash is dead
+
     if ((pInstance->GetData(DATA_RAIDDAMAGE) < MINRAIDDAMAGE && !m_creature->isWorldBoss()) || (damageTaken < m_creature->GetMaxHealth()/4 && m_creature->isWorldBoss()))
         m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);//no loot
 }
+
 struct mob_giant_infernalAI : public hyjal_trashAI
 {
     mob_giant_infernalAI(Creature* c) : hyjal_trashAI(c)
@@ -370,6 +387,7 @@ struct mob_giant_infernalAI : public hyjal_trashAI
         pos = 0;
         Reset();
     }
+
     bool meteor;
     bool CanMove;
     bool WpEnabled;
@@ -378,19 +396,22 @@ struct mob_giant_infernalAI : public hyjal_trashAI
     uint32 spawnTimer;
     uint32 FlameBuffetTimer;
     bool imol;
+
     void Reset()
     {
         spawnTimer = 2000;
         FlameBuffetTimer= 2000;
         imol = false;
     }
+
     void EnterCombat(Unit* who) {}
+
     void WaypointReached(uint32 i)
     {
         pos = i;
         if (i == 0 && pInstance && !IsOverrun)
         {
-            if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, attack thrall
+            if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall
             {
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
                 if (target && target->isAlive())
@@ -398,13 +419,14 @@ struct mob_giant_infernalAI : public hyjal_trashAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
-        if (Delay < diff)
-            Delay = 0;
-        else
+        if (DelayGetMotionMaster()->Clear();
             meteor = true;
-        }
-        else if (!CanMove)
-        {
+        }else if (!CanMove){
             if (spawnTimerRemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -437,16 +457,13 @@ struct mob_giant_infernalAI : public hyjal_trashAI
                         Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
                         if (target && target->isAlive())
                             m_creature->AddThreat(target,0.0);
-                    }
-                    else if (pInstance->GetData(DATA_ALLIANCE_RETREAT) && pInstance->GetData(DATA_HORDE_RETREAT))
-                    {
+                    }else if (pInstance->GetData(DATA_ALLIANCE_RETREAT) && pInstance->GetData(DATA_HORDE_RETREAT)){
                         //do overrun
                     }
                 }
             }else spawnTimer -= diff;
         }
-        if (!CanMove)
-            return;
+        if (!CanMove)return;
         hyjal_trashAI::UpdateAI(diff);
         if (IsEvent || IsOverrun)
             npc_escortAI::UpdateAI(diff);
@@ -463,6 +480,7 @@ struct mob_giant_infernalAI : public hyjal_trashAI
                 }
             }
         }
+
         if (!UpdateVictim())
             return;
         if (!imol)
@@ -479,12 +497,15 @@ struct mob_giant_infernalAI : public hyjal_trashAI
     }
 };
 
+
 CreatureAI* GetAI_mob_giant_infernal(Creature* pCreature)
 {
     return new mob_giant_infernalAI(pCreature);
 }
+
 #define SPELL_DISEASE_CLOUD 31607
 #define SPELL_KNOCKDOWN 31610
+
 struct mob_abominationAI : public hyjal_trashAI
 {
     mob_abominationAI(Creature* c) : hyjal_trashAI(c)
@@ -494,6 +515,7 @@ struct mob_abominationAI : public hyjal_trashAI
         pos = 0;
         Reset();
     }
+
     bool pGo;
     uint32 KnockDownTimer;
     uint32 pos;
@@ -501,19 +523,18 @@ struct mob_abominationAI : public hyjal_trashAI
     {
         KnockDownTimer = 10000;
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
         if (i == 7 && pInstance && !IsOverrun)
         {
-            if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, attack thrall
+            if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall
             {
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
-            }
-            else
-            {
+            }else{
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JAINAPROUDMOORE));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
@@ -528,7 +549,9 @@ struct mob_abominationAI : public hyjal_trashAI
             }
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         hyjal_trashAI::UpdateAI(diff);
@@ -541,7 +564,7 @@ struct mob_abominationAI : public hyjal_trashAI
                 pGo = true;
                 if (pInstance)
                 {
-                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, use horde WPs
+                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
                     {
                         for (uint8 i = 0; i < 8; ++i)
                             AddWaypoint(i, HordeWPs[i][0]+irand(-3,3),    HordeWPs[i][1]+irand(-3,3),    HordeWPs[i][2]);
@@ -570,11 +593,14 @@ struct mob_abominationAI : public hyjal_trashAI
     }
 };
 
+
 CreatureAI* GetAI_mob_abomination(Creature* pCreature)
 {
     return new mob_abominationAI(pCreature);
 }
+
 #define SPELL_FRENZY 31540
+
 struct mob_ghoulAI : public hyjal_trashAI
 {
     mob_ghoulAI(Creature* c) : hyjal_trashAI(c)
@@ -584,6 +610,7 @@ struct mob_ghoulAI : public hyjal_trashAI
         pos = 0;
         Reset();
     }
+
     bool pGo;
     uint32 FrenzyTimer;
     uint32 pos;
@@ -595,19 +622,18 @@ struct mob_ghoulAI : public hyjal_trashAI
         MoveTimer = 2000;
         RandomMove = false;
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
         if (i == 7 && pInstance && !IsOverrun)
         {
-            if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, attack thrall
+            if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall
             {
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
-            }
-            else
-            {
+            }else{
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JAINAPROUDMOORE));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
@@ -621,9 +647,12 @@ struct mob_ghoulAI : public hyjal_trashAI
                 m_creature->setDeathState(DEAD);
                 m_creature->RemoveCorpse();
             }
+
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         hyjal_trashAI::UpdateAI(diff);
@@ -636,7 +665,7 @@ struct mob_ghoulAI : public hyjal_trashAI
                 pGo = true;
                 if (pInstance)
                 {
-                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, use horde WPs
+                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
                     {
                         for (uint8 i = 0; i < 8; ++i)
                             AddWaypoint(i, HordeWPs[i][0]+irand(-3,3),    HordeWPs[i][1]+irand(-3,3),    HordeWPs[i][2]);
@@ -659,18 +688,22 @@ struct mob_ghoulAI : public hyjal_trashAI
         }else FrenzyTimer -= diff;
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
 
+
 CreatureAI* GetAI_mob_ghoul(Creature* pCreature)
 {
     return new mob_ghoulAI(pCreature);
 }
+
 #define SPELL_RAISE_DEAD_1 31617
 #define SPELL_RAISE_DEAD_2 31624
 #define SPELL_RAISE_DEAD_3 31625
 #define SPELL_SHADOW_BOLT 31627
+
 struct mob_necromancerAI : public hyjal_trashAI
 {
     mob_necromancerAI(Creature* c) : hyjal_trashAI(c), summons(m_creature)
@@ -689,6 +722,7 @@ struct mob_necromancerAI : public hyjal_trashAI
         ShadowBoltTimer = 1000+rand()%5000;
         summons.DespawnAll();
     }
+
     void JustSummoned(Creature* summon)
     {
         Unit* target = SelectTarget(SELECT_TARGET_RANDOM,0,30,true);
@@ -702,20 +736,19 @@ struct mob_necromancerAI : public hyjal_trashAI
         pos = i;
         if (i == 7 && pInstance && !IsOverrun)
         {
-            if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, attack thrall
+            if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall
             {
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
-            }
-            else
-            {
+            }else{
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JAINAPROUDMOORE));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
             }
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         switch (rand()%3)
@@ -736,7 +769,9 @@ struct mob_necromancerAI : public hyjal_trashAI
                 break;
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         hyjal_trashAI::UpdateAI(diff);
@@ -749,7 +784,7 @@ struct mob_necromancerAI : public hyjal_trashAI
                 pGo = true;
                 if (pInstance)
                 {
-                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, use horde WPs
+                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
                     {
                         for (uint8 i = 0; i < 8; ++i)
                             AddWaypoint(i, HordeWPs[i][0]+irand(-3,3),    HordeWPs[i][1]+irand(-3,3),    HordeWPs[i][2]);
@@ -772,17 +807,21 @@ struct mob_necromancerAI : public hyjal_trashAI
             DoCast(m_creature->getVictim(),SPELL_SHADOW_BOLT);
             ShadowBoltTimer = 20000+rand()%10000;
         }else ShadowBoltTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
 
+
 CreatureAI* GetAI_mob_necromancer(Creature* pCreature)
 {
     return new mob_necromancerAI(pCreature);
 }
+
 #define SPELL_BANSHEE_CURSE 31651
 #define SPELL_BANSHEE_WAIL 38183
 #define SPELL_ANTI_MAGIC_SHELL 31662
+
 struct mob_bansheeAI : public hyjal_trashAI
 {
     mob_bansheeAI(Creature* c) : hyjal_trashAI(c)
@@ -792,6 +831,7 @@ struct mob_bansheeAI : public hyjal_trashAI
         pos = 0;
         Reset();
     }
+
     bool pGo;
     uint32 CourseTimer;
     uint32 WailTimer;
@@ -803,26 +843,27 @@ struct mob_bansheeAI : public hyjal_trashAI
         WailTimer = 15000+rand()%5000;
         ShellTimer = 50000+rand()%10000;
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
         if (i == 7 && pInstance && !IsOverrun)
         {
-            if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, attack thrall
+            if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall
             {
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
-            }
-            else
-            {
+            }else{
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JAINAPROUDMOORE));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
             }
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         hyjal_trashAI::UpdateAI(diff);
@@ -835,7 +876,7 @@ struct mob_bansheeAI : public hyjal_trashAI
                 pGo = true;
                 if (pInstance)
                 {
-                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, use horde WPs
+                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
                     {
                         for (uint8 i = 0; i < 8; ++i)
                             AddWaypoint(i, HordeWPs[i][0]+irand(-3,3),    HordeWPs[i][1]+irand(-3,3),    HordeWPs[i][2]);
@@ -872,11 +913,14 @@ struct mob_bansheeAI : public hyjal_trashAI
     }
 };
 
+
 CreatureAI* GetAI_mob_banshee(Creature* pCreature)
 {
     return new mob_bansheeAI(pCreature);
 }
+
 #define SPELL_WEB 28991
+
 struct mob_crypt_fiendAI : public hyjal_trashAI
 {
     mob_crypt_fiendAI(Creature* c) : hyjal_trashAI(c)
@@ -886,6 +930,7 @@ struct mob_crypt_fiendAI : public hyjal_trashAI
         pos = 0;
         Reset();
     }
+
     bool pGo;
     uint32 WebTimer;
     uint32 pos;
@@ -893,26 +938,27 @@ struct mob_crypt_fiendAI : public hyjal_trashAI
     {
         WebTimer = 20000+rand()%5000;
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
         if (i == 7 && pInstance && !IsOverrun)
         {
-            if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, attack thrall
+            if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall
             {
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
-            }
-            else
-            {
+            }else{
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JAINAPROUDMOORE));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
             }
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         hyjal_trashAI::UpdateAI(diff);
@@ -925,7 +971,7 @@ struct mob_crypt_fiendAI : public hyjal_trashAI
                 pGo = true;
                 if (pInstance)
                 {
-                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, use horde WPs
+                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
                     {
                         for (uint8 i = 0; i < 8; ++i)
                             AddWaypoint(i, HordeWPs[i][0]+irand(-3,3),    HordeWPs[i][1]+irand(-3,3),    HordeWPs[i][2]);
@@ -938,6 +984,7 @@ struct mob_crypt_fiendAI : public hyjal_trashAI
                         Start(false, true);
                         SetDespawnAtEnd(false);
                     }
+
                 }
             }
         }
@@ -952,11 +999,14 @@ struct mob_crypt_fiendAI : public hyjal_trashAI
     }
 };
 
+
 CreatureAI* GetAI_mob_crypt_fiend(Creature* pCreature)
 {
     return new mob_crypt_fiendAI(pCreature);
 }
+
 #define SPELL_MANA_BURN 31729
+
 struct mob_fel_stalkerAI : public hyjal_trashAI
 {
     mob_fel_stalkerAI(Creature* c) : hyjal_trashAI(c)
@@ -966,6 +1016,7 @@ struct mob_fel_stalkerAI : public hyjal_trashAI
         pos = 0;
         Reset();
     }
+
     bool pGo;
     uint32 ManaBurnTimer;
     uint32 pos;
@@ -973,26 +1024,27 @@ struct mob_fel_stalkerAI : public hyjal_trashAI
     {
         ManaBurnTimer = 9000+rand()%5000;
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
         if (i == 7 && pInstance && !IsOverrun)
         {
-            if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, attack thrall
+            if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, attack thrall
             {
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
-            }
-            else
-            {
+            }else{
                 Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JAINAPROUDMOORE));
                 if (target && target->isAlive())
                     m_creature->AddThreat(target,0.0);
             }
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         hyjal_trashAI::UpdateAI(diff);
@@ -1005,7 +1057,7 @@ struct mob_fel_stalkerAI : public hyjal_trashAI
                 pGo = true;
                 if (pInstance)
                 {
-                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT)) //2.alliance boss down, use horde WPs
+                    if (pInstance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
                     {
                         for (uint8 i = 0; i < 8; ++i)
                             AddWaypoint(i, HordeWPs[i][0]+irand(-3,3),    HordeWPs[i][1]+irand(-3,3),    HordeWPs[i][2]);
@@ -1018,6 +1070,7 @@ struct mob_fel_stalkerAI : public hyjal_trashAI
                         Start(false, true);
                         SetDespawnAtEnd(false);
                     }
+
                 }
             }
         }
@@ -1032,11 +1085,14 @@ struct mob_fel_stalkerAI : public hyjal_trashAI
     }
 };
 
+
 CreatureAI* GetAI_mob_fel_stalker(Creature* pCreature)
 {
     return new mob_fel_stalkerAI(pCreature);
 }
+
 #define SPELL_FROST_BREATH 31688
+
 struct mob_frost_wyrmAI : public hyjal_trashAI
 {
     mob_frost_wyrmAI(Creature* c) : hyjal_trashAI(c)
@@ -1046,16 +1102,19 @@ struct mob_frost_wyrmAI : public hyjal_trashAI
         pos = 0;
         Reset();
     }
+
     bool pGo;
     uint32 FrostBreathTimer;
     uint32 pos;
     uint32 MoveTimer;
+
     void Reset()
     {
         FrostBreathTimer = 5000;
         MoveTimer = 0;
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
@@ -1069,17 +1128,21 @@ struct mob_frost_wyrmAI : public hyjal_trashAI
             }
         }
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance && IsEvent)
             pInstance->SetData(DATA_TRASH, 0);//signal trash is dead
+
         float x,y,z;
         m_creature->GetPosition(x,y,z);
         z = m_creature->GetMap()->GetVmapHeight(x, y, z, true);
         m_creature->GetMotionMaster()->MovePoint(0,x,y,z);
         m_creature->GetMap()->CreatureRelocation(m_creature, x,y,z,0);
     }
+
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         hyjal_trashAI::UpdateAI(diff);
@@ -1101,9 +1164,7 @@ struct mob_frost_wyrmAI : public hyjal_trashAI
                             AddWaypoint(i, FrostWyrmWPs[i][0],    FrostWyrmWPs[i][1],    FrostWyrmWPs[i][2]);
                         Start(false, true);
                         SetDespawnAtEnd(false);
-                    }
-                    else
-                    {//fly path FlyPathWPs
+                    }else{//fly path FlyPathWPs
                         for (uint8 i = 0; i < 3; ++i)
                             AddWaypoint(i, FlyPathWPs[i][0]+irand(-10,10),    FlyPathWPs[i][1]+irand(-10,10),    FlyPathWPs[i][2]);
                         Start(false, true);
@@ -1121,6 +1182,7 @@ struct mob_frost_wyrmAI : public hyjal_trashAI
                 MoveTimer = 2000;
             }else MoveTimer-=diff;
         }
+
         if (FrostBreathTimerIsWithinDist(m_creature->getVictim(), 25))
@@ -1134,11 +1196,14 @@ struct mob_frost_wyrmAI : public hyjal_trashAI
     }
 };
 
+
 CreatureAI* GetAI_mob_frost_wyrm(Creature* pCreature)
 {
     return new mob_frost_wyrmAI(pCreature);
 }
+
 #define SPELL_GARGOYLE_STRIKE 31664
+
 struct mob_gargoyleAI : public hyjal_trashAI
 {
     mob_gargoyleAI(Creature* c) : hyjal_trashAI(c)
@@ -1149,12 +1214,14 @@ struct mob_gargoyleAI : public hyjal_trashAI
         DummyTarget[0] = 0;DummyTarget[1] = 0;DummyTarget[2] = 0;
         Reset();
     }
+
     bool pGo;
     uint32 StrikeTimer;
     uint32 pos;
     uint32 MoveTimer;
     float Zpos;
     bool forcemove;
+
     void Reset()
     {
         forcemove = true;
@@ -1163,6 +1230,7 @@ struct mob_gargoyleAI : public hyjal_trashAI
         MoveTimer = 0;
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
     }
+
     void WaypointReached(uint32 i)
     {
         pos = i;
@@ -1176,6 +1244,7 @@ struct mob_gargoyleAI : public hyjal_trashAI
             }
         }
     }
+
     void JustDied(Unit *victim)
     {
         float x,y,z;
@@ -1185,6 +1254,7 @@ struct mob_gargoyleAI : public hyjal_trashAI
         m_creature->GetMap()->CreatureRelocation(m_creature, x,y,z,0);
         hyjal_trashAI::JustDied(victim);
     }
+
     void UpdateAI(const uint32 diff)
     {
         hyjal_trashAI::UpdateAI(diff);
@@ -1206,9 +1276,7 @@ struct mob_gargoyleAI : public hyjal_trashAI
                             AddWaypoint(i, GargoyleWPs[i][0]+irand(-10,10), GargoyleWPs[i][1]+irand(-10,10), GargoyleWPs[i][2]);
                         Start(false, true);
                         SetDespawnAtEnd(false);
-                    }
-                    else
-                    {//fly path FlyPathWPs
+                    }else{//fly path FlyPathWPs
                         for (uint8 i = 0; i < 3; ++i)
                             AddWaypoint(i, FlyPathWPs[i][0]+irand(-10,10),    FlyPathWPs[i][1]+irand(-10,10),    FlyPathWPs[i][2]);
                         Start(false, true);
@@ -1219,7 +1287,7 @@ struct mob_gargoyleAI : public hyjal_trashAI
         }
         if (IsOverrun && !UpdateVictim())
         {
-            if (faction == 0) //alliance
+            if (faction == 0)//alliance
             {
                 if (StrikeTimergetVictim())
             return;
+
         if (who->isTargetableForAttack() && m_creature->IsHostileTo(who))
         {
             float attackRadius = m_creature->GetAttackDistance(who);
@@ -1294,9 +1370,11 @@ struct TRINITY_DLL_DECL alliance_riflemanAI : public Scripted_NoMovementAI
             }
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Check if we have a target
@@ -1316,48 +1394,59 @@ struct TRINITY_DLL_DECL alliance_riflemanAI : public Scripted_NoMovementAI
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_alliance_rifleman(Creature* pCreature)
 {
     return new alliance_riflemanAI(pCreature);
 }
+
 void AddSC_hyjal_trash()
 {
     Script *newscript = new Script;
     newscript->Name = "mob_giant_infernal";
     newscript->GetAI = &GetAI_mob_giant_infernal;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_abomination";
     newscript->GetAI = &GetAI_mob_abomination;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ghoul";
     newscript->GetAI = &GetAI_mob_ghoul;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_necromancer";
     newscript->GetAI = &GetAI_mob_necromancer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_banshee";
     newscript->GetAI = &GetAI_mob_banshee;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_crypt_fiend";
     newscript->GetAI = &GetAI_mob_crypt_fiend;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_fel_stalker";
     newscript->GetAI = &GetAI_mob_fel_stalker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_frost_wyrm";
     newscript->GetAI = &GetAI_mob_frost_wyrm;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_gargoyle";
     newscript->GetAI = &GetAI_mob_gargoyle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "alliance_rifleman";
     newscript->GetAI = &GetAI_alliance_rifleman;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.h b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.h
index ed5031ef1a8..17fdbad5fda 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.h
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.h
@@ -1,15 +1,22 @@
 
 #ifndef SC_HYJAL_TRASH_AI_H
 #define SC_HYJAL_TRASH_AI_H
+
 #include "def_hyjal.h"
 #include "escort_ai.h"
+
 #define MINRAIDDAMAGE  700000//minimal damage before trash can drop loot and reputation, resets if faction leader dies
+
 struct TRINITY_DLL_DECL hyjal_trashAI : public npc_escortAI
 {
     hyjal_trashAI(Creature *c);
+
     void UpdateAI(const uint32 diff);
+
     void JustDied(Unit* killer);
+
     void DamageTaken(Unit *done_by, uint32 &damage);
+
     public:
         ScriptedInstance* pInstance;
         bool IsEvent;
@@ -22,6 +29,7 @@ struct TRINITY_DLL_DECL hyjal_trashAI : public npc_escortAI
         bool useFlyPath;
         uint32 damageTaken;
         float DummyTarget[3];
+
     //private:
 };
-#endif
+#endif
\ No newline at end of file
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/instance_hyjal.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/instance_hyjal.cpp
index 2a69e02caea..81b51507463 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/instance_hyjal.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/instance_hyjal.cpp
@@ -13,18 +13,22 @@
  * along 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 "hyjal_trash.h"
+
 enum eEnums
 {
     MAX_ENCOUNTER       = 5,
+
     GO_ANCIENT_GEM      = 185557
 };
 /* Battle of Mount Hyjal encounters:
@@ -34,12 +38,16 @@ enum eEnums
 3 - Azgalor event
 4 - Archimonde event
 */
+
 struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
 {
     instance_mount_hyjal(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     std::string str_data;
+
     std::list m_uiAncientGemGUID;
+
     uint64 RageWinterchill;
     uint64 Anetheron;
     uint64 Kazrogal;
@@ -50,18 +58,25 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
     uint64 TyrandeWhisperwind;
     uint64 HordeGate;
     uint64 ElfGate;
+
     uint32 Trash;
 
+
     uint32 hordeRetreat;
     uint32 allianceRetreat;
     bool ArchiYell;
+
     uint32 RaidDamage;
+
     #define YELL_EFFORTS        "All of your efforts have been in vain, for the draining of the World Tree has already begun. Soon the heart of your world will beat no more."
     #define YELL_EFFORTS_NAME   "Archimonde"
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         m_uiAncientGemGUID.clear();
+
         RageWinterchill = 0;
         Anetheron = 0;
         Kazrogal = 0;
@@ -74,16 +89,21 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
         ElfGate = 0;
         ArchiYell = false;
         RaidDamage = 0;
+
         Trash = 0;
+
         hordeRetreat = 0;
         allianceRetreat = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -107,6 +127,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
                 break;
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -121,6 +142,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
             case 17948: TyrandeWhisperwind = pCreature->GetGUID(); break;
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -134,8 +156,10 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
             case DATA_THRALL: return Thrall;
             case DATA_TYRANDEWHISPERWIND: return TyrandeWhisperwind;
         }
+
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -152,10 +176,12 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
                     {
                         if (ArchiYell)break;
                         ArchiYell = true;
+
                         Creature* pCreature = instance->GetCreature(Azgalor);
                         if (pCreature)
                         {
                             Creature* pUnit = pCreature->SummonCreature(21987,pCreature->GetPositionX(),pCreature->GetPositionY(),pCreature->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN,10000);
+
                             Map* pMap = pCreature->GetMap();
                             if (pMap->IsDungeon() && pUnit)
                             {
@@ -163,6 +189,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
                                 Map::PlayerList const &PlayerList = pMap->GetPlayers();
                                 if (PlayerList.isEmpty())
                                      return;
+
                                 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                                 {
                                      if (i->getSource())
@@ -170,6 +197,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
                                         WorldPacket data(SMSG_MESSAGECHAT, 200);
                                         pUnit->BuildMonsterChat(&data,CHAT_MSG_MONSTER_YELL,YELL_EFFORTS,0,YELL_EFFORTS_NAME,i->getSource()->GetGUID());
                                         i->getSource()->GetSession()->SendPacket(&data);
+
                                         WorldPacket data2(SMSG_PLAY_SOUND, 4);
                                         data2 << 10986;
                                         i->getSource()->GetSession()->SendPacket(&data2);
@@ -182,6 +210,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
                 break;
             case DATA_ARCHIMONDEEVENT:      m_auiEncounter[4] = data; break;
             case DATA_RESET_TRASH_COUNT:    Trash = 0;            break;
+
             case DATA_TRASH:
                 if (data) Trash = data;
                 else     Trash--;
@@ -192,7 +221,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
                 {
                     if (!m_uiAncientGemGUID.empty())
                     {
-                        for (std::list::iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
+                        for(std::list::iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
                         {
                             //don't know how long it expected
                             DoRespawnGameObject(*itr,DAY);
@@ -219,20 +248,27 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
                 RaidDamage = 0;
                 break;
         }
+
          debug_log("TSCR: Instance Hyjal: Instance data updated for event %u (Data=%u)",type,data);
+
         if (data == DONE)
         {
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
             saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                 << m_auiEncounter[3] << " " << m_auiEncounter[4]
                 << " " << allianceRetreat << " " << hordeRetreat
                 << " " << RaidDamage;
+
             str_data = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
+
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -249,10 +285,12 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
         }
         return 0;
     }
+
     std::string GetSaveData()
     {
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -260,19 +298,22 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
         std::istringstream loadStream(in);
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3] >> m_auiEncounter[4] >> allianceRetreat >> hordeRetreat >> RaidDamage;
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)                // Do not load an encounter as IN_PROGRESS - reset it instead.
                 m_auiEncounter[i] = NOT_STARTED;
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_mount_hyjal(Map* pMap)
 {
     return new instance_mount_hyjal(pMap);
 }
+
 void AddSC_instance_mount_hyjal()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp
index 130b34e0ee3..6582e114049 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp
@@ -13,39 +13,47 @@
  * along with 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 SAY_ENTER                   -1560000
 #define SAY_TAUNT1                  -1560001
 #define SAY_TAUNT2                  -1560002
 #define SAY_SLAY1                   -1560003
 #define SAY_SLAY2                   -1560004
 #define SAY_DEATH                   -1560005
+
 #define SPELL_HOLY_LIGHT            29427
 #define SPELL_CLEANSE               29380
 #define SPELL_HAMMER_OF_JUSTICE     13005
 #define SPELL_HOLY_SHIELD           31904
 #define SPELL_DEVOTION_AURA         8258
 #define SPELL_CONSECRATION          38385
+
 struct TRINITY_DLL_DECL boss_captain_skarlocAI : public ScriptedAI
 {
     boss_captain_skarlocAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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 = 20000 + rand()%10000;
@@ -55,70 +63,84 @@ struct TRINITY_DLL_DECL boss_captain_skarlocAI : public ScriptedAI
         DevotionAura_Timer = 3000;
         Consecration_Timer = 8000;
     }
+
     void EnterCombat(Unit *who)
     {
         //This is not correct. Should taunt Thrall before engage in combat
         DoScriptText(SAY_TAUNT1, m_creature);
         DoScriptText(SAY_TAUNT2, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         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 (!UpdateVictim())
             return;
+
         //Holy_Light
         if (Holy_Light_Timer < diff)
         {
             DoCast(m_creature, SPELL_HOLY_LIGHT);
             Holy_Light_Timer = 30000;
         }else Holy_Light_Timer -= diff;
+
         //Cleanse
         if (Cleanse_Timer  < diff)
         {
             DoCast(m_creature, SPELL_CLEANSE);
             Cleanse_Timer = 10000;
         } else Cleanse_Timer -= diff;
+
         //Hammer of Justice
         if (HammerOfJustice_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_HAMMER_OF_JUSTICE);
             HammerOfJustice_Timer = 60000;
         }else HammerOfJustice_Timer -= diff;
+
         //Holy Shield
         if (HolyShield_Timer < diff)
         {
             DoCast(m_creature, SPELL_HOLY_SHIELD);
             HolyShield_Timer = 240000;
         }else HolyShield_Timer -= diff;
+
         //Devotion_Aura
         if (DevotionAura_Timer < diff)
         {
             DoCast(m_creature, SPELL_DEVOTION_AURA);
             DevotionAura_Timer = 45000 + rand()%10000;
         }else DevotionAura_Timer -= diff;
+
         //Consecration
         if (Consecration_Timer < diff)
         {
             //DoCast(m_creature->getVictim(), SPELL_CONSECRATION);
             Consecration_Timer = 5000 + rand()%5000;
         }else Consecration_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_captain_skarloc(Creature* pCreature)
 {
     return new boss_captain_skarlocAI (pCreature);
 }
+
 void AddSC_boss_captain_skarloc()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp
index bb8012bfa48..d430cf92863 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp
@@ -13,14 +13,17 @@
  * along with 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                  -1560013
 #define SAY_ENTER2                  -1560014
 #define SAY_ENTER3                  -1560015
@@ -31,21 +34,26 @@ EndScriptData */
 #define SAY_BREATH1                 -1560020
 #define SAY_BREATH2                 -1560021
 #define SAY_DEATH                   -1560022
+
 #define SPELL_SAND_BREATH           31914
 #define SPELL_IMPENDING_DEATH       31916
 #define SPELL_MAGIC_DISRUPTION_AURA 33834
 #define SPELL_WING_BUFFET           31475
+
 struct TRINITY_DLL_DECL boss_epoch_hunterAI : public ScriptedAI
 {
     boss_epoch_hunterAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 SandBreath_Timer;
     uint32 ImpendingDeath_Timer;
     uint32 WingBuffet_Timer;
     uint32 Mda_Timer;
+
     void Reset()
     {
         SandBreath_Timer = 8000 + rand()%8000;
@@ -53,57 +61,72 @@ struct TRINITY_DLL_DECL boss_epoch_hunterAI : public ScriptedAI
         WingBuffet_Timer = 35000;
         Mda_Timer = 40000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2), m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         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 (!UpdateVictim())
             return;
+
         //Sand Breath
         if (SandBreath_Timer < diff)
         {
             if (m_creature->IsNonMeleeSpellCasted(false))
                 m_creature->InterruptNonMeleeSpells(false);
+
             DoCast(m_creature->getVictim(),SPELL_SAND_BREATH);
+
             DoScriptText(RAND(SAY_BREATH1,SAY_BREATH2), m_creature);
+
             SandBreath_Timer = 10000 + rand()%10000;
         }else SandBreath_Timer -= diff;
+
         if (ImpendingDeath_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_IMPENDING_DEATH);
             ImpendingDeath_Timer = 25000+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* pCreature)
 {
     return new boss_epoch_hunterAI (pCreature);
 }
+
 void AddSC_boss_epoch_hunter()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp
index 3a607c0ff6a..f396c556dae 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp
@@ -13,31 +13,39 @@
  * along with 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. Script for GO (barrels) quest 10283
 SDCategory: Caverns of Time, Old Hillsbrad Foothills
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_old_hillsbrad.h"
 #include "escort_ai.h"
+
 /*######
 ## go_barrel_old_hillsbrad
 ######*/
+
 bool GOHello_go_barrel_old_hillsbrad(Player* pPlayer, GameObject* pGO)
 {
     if (ScriptedInstance* pInstance = pGO->GetInstanceData())
     {
         if (pInstance->GetData(TYPE_BARREL_DIVERSION) == DONE)
             return false;
+
         pInstance->SetData(TYPE_BARREL_DIVERSION, IN_PROGRESS);
     }
+
     return false;
 }
+
 /*######
 ## boss_lieutenant_drake
 ######*/
+
 #define SAY_ENTER               -1560006
 #define SAY_AGGRO               -1560007
 #define SAY_SLAY1               -1560008
@@ -45,10 +53,12 @@ bool GOHello_go_barrel_old_hillsbrad(Player* pPlayer, GameObject* pGO)
 #define SAY_MORTAL              -1560010
 #define SAY_SHOUT               -1560011
 #define SAY_DEATH               -1560012
+
 #define SPELL_WHIRLWIND         31909
 #define SPELL_HAMSTRING         9080
 #define SPELL_MORTAL_STRIKE     31911
 #define SPELL_FRIGHTENING_SHOUT 33789
+
 struct Location
 {
     uint32 wpId;
@@ -56,6 +66,7 @@ struct Location
     float y;
     float z;
 };
+
 static Location DrakeWP[]=
 {
     {0, 2125.84, 88.2535, 54.8830},
@@ -78,36 +89,45 @@ static Location DrakeWP[]=
     {17, 2125.50, 88.9481, 54.7953},
     {18, 2128.20, 70.9763, 64.4221}
 };
+
 struct TRINITY_DLL_DECL boss_lieutenant_drakeAI : public ScriptedAI
 {
     boss_lieutenant_drakeAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //TODO: make this work
@@ -116,15 +136,18 @@ struct TRINITY_DLL_DECL boss_lieutenant_drakeAI : public ScriptedAI
             m_creature->GetMotionMaster()->MovePoint(DrakeWP[0].wpId, DrakeWP[0].x, DrakeWP[0].y, DrakeWP[0].z);
             wpId++;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Whirlwind
         if (Whirlwind_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_WHIRLWIND);
             Whirlwind_Timer = 20000+rand()%5000;
         }else Whirlwind_Timer -= diff;
+
         //Fear
         if (Fear_Timer < diff)
         {
@@ -132,6 +155,7 @@ struct TRINITY_DLL_DECL boss_lieutenant_drakeAI : public ScriptedAI
             DoCast(m_creature->getVictim(), SPELL_FRIGHTENING_SHOUT);
             Fear_Timer = 25000+rand()%10000;
         }else Fear_Timer -= diff;
+
         //Mortal Strike
         if (MortalStrike_Timer < diff)
         {
@@ -139,20 +163,25 @@ struct TRINITY_DLL_DECL boss_lieutenant_drakeAI : public ScriptedAI
             DoCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE);
             MortalStrike_Timer = 20000+rand()%10000;
         }else MortalStrike_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_lieutenant_drake(Creature* pCreature)
 {
     return new boss_lieutenant_drakeAI (pCreature);
 }
+
 void AddSC_boss_lieutenant_drake()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "go_barrel_old_hillsbrad";
     newscript->pGOHello = &GOHello_go_barrel_old_hillsbrad;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_lieutenant_drake";
     newscript->GetAI = &GetAI_boss_lieutenant_drake;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h
index d57c5e9d313..3253a384217 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp
index 0f976484190..b8ec8f2e111 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp
@@ -13,65 +13,82 @@
  * along 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: 75
 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 */
+
 #include "precompiled.h"
 #include "def_old_hillsbrad.h"
+
 #define MAX_ENCOUNTER      6
+
 #define THRALL_ENTRY    17876
 #define TARETHA_ENTRY   18887
 #define EPOCH_ENTRY    18096
+
 #define DRAKE_ENTRY             17848
+
 #define QUEST_ENTRY_DIVERSION   10283
 #define LODGE_QUEST_TRIGGER     20155
+
 struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
 {
     instance_old_hillsbrad(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     uint32 mBarrelCount;
     uint32 mThrallEventCount;
+
     uint64 ThrallGUID;
     uint64 TarethaGUID;
     uint64 EpochGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         mBarrelCount        = 0;
         mThrallEventCount   = 0;
         ThrallGUID          = 0;
         TarethaGUID         = 0;
         EpochGUID        = 0;
     }
+
     Player* GetPlayerInMap()
     {
         Map::PlayerList const& players = instance->GetPlayers();
+
         if (!players.isEmpty())
         {
-            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+            for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
             {
                 if (Player* plr = itr->getSource())
                     return plr;
             }
         }
+
         debug_log("TSCR: Instance Old Hillsbrad: GetPlayerInMap, but PlayerList is empty!");
         return NULL;
     }
+
     void UpdateQuestCredit()
     {
         Map::PlayerList const& players = instance->GetPlayers();
+
         if (!players.isEmpty())
         {
-            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+            for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
             {
                 if (Player* pPlayer = itr->getSource())
                     pPlayer->KilledMonsterCredit(LODGE_QUEST_TRIGGER,0);
             }
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -87,14 +104,17 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
         break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         Player* pPlayer = GetPlayerInMap();
+
         if (!pPlayer)
         {
             debug_log("TSCR: Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any player.", type, data);
             return;
         }
+
         switch(type)
         {
             case TYPE_BARREL_DIVERSION:
@@ -103,10 +123,14 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
                 {
                     if (mBarrelCount >= 5)
                         return;
+
                     ++mBarrelCount;
                     DoUpdateWorldState(WORLD_STATE_OH, mBarrelCount);
+
                     debug_log("TSCR: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u",mBarrelCount);
+
                     m_auiEncounter[0] = IN_PROGRESS;
+
                     if (mBarrelCount == 5)
                     {
                         UpdateQuestCredit();
@@ -163,6 +187,7 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
                 break;
         }
     }
+
     uint32 GetData(uint32 data)
     {
         switch(data)
@@ -182,6 +207,7 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 data)
     {
         switch(data)
@@ -200,6 +226,7 @@ InstanceData* GetInstanceData_instance_old_hillsbrad(Map* pMap)
 {
     return new instance_old_hillsbrad(pMap);
 }
+
 void AddSC_instance_old_hillsbrad()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp
index 5408fdd8308..9fdd713e639 100644
--- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp
@@ -13,42 +13,54 @@
  * along 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: Quest support: 10283, 10284. 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_erozion
 npc_thrall_old_hillsbrad
 npc_taretha
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.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
+
 #define GOSSIP_HELLO_EROZION1   "I need a pack of Incendiary Bombs."
 #define GOSSIP_HELLO_EROZION2   "[PH] Teleport please, i'm tired."
+
 /*######
 ## npc_erozion
 ######*/
+
 bool GossipHello_npc_erozion(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
     if (pInstance && pInstance->GetData(TYPE_BARREL_DIVERSION) != DONE && !pPlayer->HasItemCount(ITEM_ENTRY_BOMBS,1))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_EROZION1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     if (!pPlayer->GetQuestRewardStatus(QUEST_ENTRY_RETURN) && pPlayer->GetQuestStatus(QUEST_ENTRY_RETURN) == QUEST_STATUS_COMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_EROZION2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+
     pPlayer->SEND_GOSSIP_MENU(9778, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_erozion(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -67,9 +79,11 @@ bool GossipSelect_npc_erozion(Player* pPlayer, Creature* pCreature, uint32 uiSen
     }
     return true;
 }
+
 /*######
 ## npc_thrall_old_hillsbrad
 ######*/
+
 //Thrall texts
 #define SAY_TH_START_EVENT_PART1    -1560023
 #define SAY_TH_ARMORY               -1560024
@@ -82,57 +96,73 @@ bool GossipSelect_npc_erozion(Player* pPlayer, Creature* pCreature, uint32 uiSen
 #define SAY_TH_EPOCH_WONDER         -1560031
 #define SAY_TH_EPOCH_KILL_TARETHA   -1560032
 #define SAY_TH_EVENT_COMPLETE       -1560033
+
 #define SAY_TH_RANDOM_LOW_HP1       -1560034
 #define SAY_TH_RANDOM_LOW_HP2       -1560035
+
 #define SAY_TH_RANDOM_DIE1          -1560036
 #define SAY_TH_RANDOM_DIE2          -1560037
+
 #define SAY_TH_RANDOM_AGGRO1        -1560038
 #define SAY_TH_RANDOM_AGGRO2        -1560039
 #define SAY_TH_RANDOM_AGGRO3        -1560040
 #define SAY_TH_RANDOM_AGGRO4        -1560041
+
 #define SAY_TH_RANDOM_KILL1         -1560042
 #define SAY_TH_RANDOM_KILL2         -1560043
 #define SAY_TH_RANDOM_KILL3         -1560044
+
 #define SAY_TH_LEAVE_COMBAT1        -1560045
 #define SAY_TH_LEAVE_COMBAT2        -1560046
 #define SAY_TH_LEAVE_COMBAT3        -1560047
+
 //Taretha texts
 #define SAY_TA_FREE                 -1560048
 #define SAY_TA_ESCAPED              -1560049
+
 //Misc for Thrall
 #define SPELL_STRIKE                14516
 #define SPELL_SHIELD_BLOCK          12169
 #define SPELL_SUMMON_EROZION_IMAGE  33954                   //if thrall dies during escort?
+
 #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
+
 //Misc Creature entries
 #define ENTRY_ARMORER               18764
 #define ENTRY_SCARLOC               17862
+
 #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 ENTRY_EPOCH                 18096
+
 //gossip items
 #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...
@@ -140,10 +170,14 @@ bool GossipSelect_npc_erozion(Player* pPlayer, Creature* pCreature, uint32 uiSen
 #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 GOSSIP_ITEM_WALKING     "[PH] Start walking."
+
 struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
 {
     npc_thrall_old_hillsbradAI(Creature *c) : npc_escortAI(c)
@@ -152,14 +186,19 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
         HadMount = false;
         m_creature->setActive(true);
     }
+
     ScriptedInstance *pInstance;
+
     uint64 TarethaGUID;
+
     bool LowHp;
     bool HadMount;
+
     void WaypointReached(uint32 i)
     {
         if (!pInstance)
             return;
+
         switch(i)
         {
             case 8:
@@ -292,6 +331,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
                 //trigger epoch Yell("Thrall! Come outside and face your fate! ....")
                 //from here, thrall should not never be allowed to move to point 106 which he currently does.
                 break;
+
             case 106:
                 {
                     //trigger taretha to run down outside
@@ -300,17 +340,19 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
                         if (Player* pPlayer = GetPlayerForEscort())
                             CAST_AI(npc_escortAI, (Taretha->AI()))->Start(false, true, pPlayer->GetGUID());
                     }
+
                     //kill credit Creature for quest
                     Map* pMap = m_creature->GetMap();
                     Map::PlayerList const& players = pMap->GetPlayers();
                     if (!players.isEmpty() && pMap->IsDungeon())
                     {
-                        for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                        for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         {
                             if (Player* pPlayer = itr->getSource())
                                 pPlayer->KilledMonsterCredit(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);
                 }
@@ -322,11 +364,14 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
         }
     }
 
+
     void Reset()
     {
         LowHp = false;
+
         if (HadMount)
             DoMount();
+
         if (!HasEscortState(STATE_ESCORT_ESCORTING))
         {
             DoUnmount();
@@ -364,6 +409,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
             HadMount = true;
         }
     }
+
     void JustSummoned(Creature* summoned)
     {
          switch(summoned->GetEntry())
@@ -380,6 +426,7 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
              break;
          }
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_TH_RANDOM_KILL1,SAY_TH_RANDOM_KILL2,SAY_TH_RANDOM_KILL3), m_creature);
@@ -388,16 +435,21 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
     {
         if (pInstance)
             pInstance->SetData(TYPE_THRALL_EVENT,FAIL);
+
         // Don't do a yell if he kills self (if player goes too far or at the end).
         if (slayer == m_creature)
             return;
+
         DoScriptText(RAND(SAY_TH_RANDOM_DIE1,SAY_TH_RANDOM_DIE2), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
+
         if (!UpdateVictim())
             return;
+
              //TODO: add his abilities'n-crap here
             if (!LowHp && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20))
             {
@@ -406,10 +458,12 @@ struct TRINITY_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI
             }
     }
 };
+
 CreatureAI* GetAI_npc_thrall_old_hillsbrad(Creature* pCreature)
 {
     return new npc_thrall_old_hillsbradAI(pCreature);
 }
+
 bool GossipHello_npc_thrall_old_hillsbrad(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
@@ -417,6 +471,7 @@ bool GossipHello_npc_thrall_old_hillsbrad(Player* pPlayer, Creature* pCreature)
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
         pPlayer->SendPreparedQuest(pCreature->GetGUID());
     }
+
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
     if (pInstance)
     {
@@ -425,11 +480,13 @@ bool GossipHello_npc_thrall_old_hillsbrad(Player* pPlayer, Creature* pCreature)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_WALKING, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
             pPlayer->SEND_GOSSIP_MENU(GOSSIP_ID_START, pCreature->GetGUID());
         }
+
         if (pInstance->GetData(TYPE_THRALL_PART1) == DONE && !pInstance->GetData(TYPE_THRALL_PART2))
         {
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_SKARLOC1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
             pPlayer->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC1, pCreature->GetGUID());
         }
+
         if (pInstance->GetData(TYPE_THRALL_PART2) == DONE && !pInstance->GetData(TYPE_THRALL_PART3))
         {
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TARREN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
@@ -438,6 +495,7 @@ bool GossipHello_npc_thrall_old_hillsbrad(Player* pPlayer, Creature* pCreature)
     }
     return true;
 }
+
 bool GossipSelect_npc_thrall_old_hillsbrad(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
@@ -450,25 +508,33 @@ bool GossipSelect_npc_thrall_old_hillsbrad(Player* pPlayer, Creature* pCreature,
                 pInstance->SetData(TYPE_THRALL_EVENT,IN_PROGRESS);
                 pInstance->SetData(TYPE_THRALL_PART1,IN_PROGRESS);
             }
+
             DoScriptText(SAY_TH_START_EVENT_PART1, pCreature);
+
             if (npc_escortAI* pEscortAI = CAST_AI(npc_thrall_old_hillsbradAI, pCreature->AI()))
                 pEscortAI->Start(true, true, pPlayer->GetGUID());
+
             CAST_AI(npc_escortAI, (pCreature->AI()))->SetMaxPlayerDistance(100.0f);//not really needed, because it will not despawn if player is too far
             CAST_AI(npc_escortAI, (pCreature->AI()))->SetDespawnAtEnd(false);
             CAST_AI(npc_escortAI, (pCreature->AI()))->SetDespawnAtFar(false);
             break;
+
         case GOSSIP_ACTION_INFO_DEF+2:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_SKARLOC2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20);
             pPlayer->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC2, pCreature->GetGUID());
             break;
+
         case GOSSIP_ACTION_INFO_DEF+20:
             pPlayer->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC3, pCreature->GetGUID());
             pCreature->SummonCreature(SKARLOC_MOUNT,2038.81,270.26,63.20,5.41,TEMPSUMMON_TIMED_DESPAWN,12000);
             if (pInstance)
                 pInstance->SetData(TYPE_THRALL_PART2,IN_PROGRESS);
+
             DoScriptText(SAY_TH_START_EVENT_PART2, pCreature);
+
             CAST_AI(npc_thrall_old_hillsbradAI, pCreature->AI())->StartWP();
             break;
+
         case GOSSIP_ACTION_INFO_DEF+3:
             pPlayer->CLOSE_GOSSIP_MENU();
             if (pInstance)
@@ -478,20 +544,25 @@ bool GossipSelect_npc_thrall_old_hillsbrad(Player* pPlayer, Creature* pCreature,
     }
     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."
+
 struct TRINITY_DLL_DECL npc_tarethaAI : public npc_escortAI
 {
     npc_tarethaAI(Creature *c) : npc_escortAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     void WaypointReached(uint32 i)
     {
         switch(i)
@@ -506,6 +577,7 @@ struct TRINITY_DLL_DECL npc_tarethaAI : public npc_escortAI
     }
     void Reset() {}
     void EnterCombat(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
@@ -515,6 +587,7 @@ CreatureAI* GetAI_npc_taretha(Creature* pCreature)
 {
     return new npc_tarethaAI(pCreature);
 }
+
 bool GossipHello_npc_taretha(Player* pPlayer, Creature* pCreature)
 {
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
@@ -525,6 +598,7 @@ bool GossipHello_npc_taretha(Player* pPlayer, Creature* pCreature)
     }
     return true;
 }
+
 bool GossipSelect_npc_taretha(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
@@ -536,11 +610,13 @@ bool GossipSelect_npc_taretha(Player* pPlayer, Creature* pCreature, uint32 uiSen
     if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
     {
         pPlayer->CLOSE_GOSSIP_MENU();
+
         if (pInstance && pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS)
         {
             pInstance->SetData(TYPE_THRALL_PART4,IN_PROGRESS);
             if (pInstance->GetData64(DATA_EPOCH) == 0)
                  pCreature->SummonCreature(ENTRY_EPOCH,2639.13,698.55,65.43,4.59,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000);
+
              if (uint64 ThrallGUID = pInstance->GetData64(DATA_THRALL))
              {
                  Creature* Thrall = (Unit::GetCreature((*pCreature), ThrallGUID));
@@ -551,23 +627,28 @@ bool GossipSelect_npc_taretha(Player* pPlayer, Creature* pCreature, uint32 uiSen
     }
     return true;
 }
+
 /*######
 ## AddSC
 ######*/
+
 void AddSC_old_hillsbrad()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_erozion";
     newscript->pGossipHello =   &GossipHello_npc_erozion;
     newscript->pGossipSelect =  &GossipSelect_npc_erozion;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_taretha";
     newscript->pGossipHello =   &GossipHello_npc_taretha;
diff --git a/src/bindings/scripts/scripts/kalimdor/darkshore.cpp b/src/bindings/scripts/scripts/kalimdor/darkshore.cpp
index 4c1485586e5..1354c2bc861 100644
--- a/src/bindings/scripts/scripts/kalimdor/darkshore.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/darkshore.cpp
@@ -13,55 +13,71 @@
  * along 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: 100
 SDComment: Quest support: 731, 2078, 5321
 SDCategory: Darkshore
 EndScriptData */
+
 /* ContentData
 npc_kerlonian
 npc_prospector_remtravel
 npc_threshwackonator
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "follower_ai.h"
+
 /*####
 # npc_kerlonian
 ####*/
+
 enum eKerlonian
 {
     SAY_KER_START               = -1000434,
+
     EMOTE_KER_SLEEP_1           = -1000435,
     EMOTE_KER_SLEEP_2           = -1000436,
     EMOTE_KER_SLEEP_3           = -1000437,
+
     SAY_KER_SLEEP_1             = -1000438,
     SAY_KER_SLEEP_2             = -1000439,
     SAY_KER_SLEEP_3             = -1000440,
     SAY_KER_SLEEP_4             = -1000441,
+
     EMOTE_KER_AWAKEN            = -1000445,
+
     SAY_KER_ALERT_1             = -1000442,
     SAY_KER_ALERT_2             = -1000443,
+
     SAY_KER_END                 = -1000444,
+
     SPELL_SLEEP_VISUAL          = 25148,
     SPELL_AWAKEN                = 17536,
     QUEST_SLEEPER_AWAKENED      = 5321,
     NPC_LILADRIS                = 11219,                    //attackers entries unknown
     FACTION_KER_ESCORTEE        = 113
 };
+
 //TODO: make concept similar as "ringo" -escort. Find a way to run the scripted attacks, _if_ player are choosing road.
 struct TRINITY_DLL_DECL npc_kerlonianAI : public FollowerAI
 {
     npc_kerlonianAI(Creature* pCreature) : FollowerAI(pCreature) { }
+
     uint32 m_uiFallAsleepTimer;
+
     void Reset()
     {
         m_uiFallAsleepTimer = urand(10000, 45000);
     }
+
     void MoveInLineOfSight(Unit *pWho)
     {
         FollowerAI::MoveInLineOfSight(pWho);
+
         if (!m_creature->getVictim() && !HasFollowState(STATE_FOLLOW_COMPLETE) && pWho->GetEntry() == NPC_LILADRIS)
         {
             if (m_creature->IsWithinDistInMap(pWho, INTERACTION_DISTANCE*5))
@@ -70,38 +86,50 @@ struct TRINITY_DLL_DECL npc_kerlonianAI : public FollowerAI
                 {
                     if (pPlayer->GetQuestStatus(QUEST_SLEEPER_AWAKENED) == QUEST_STATUS_INCOMPLETE)
                         pPlayer->GroupEventHappens(QUEST_SLEEPER_AWAKENED, m_creature);
+
                     DoScriptText(SAY_KER_END, m_creature);
                 }
+
                 SetFollowComplete();
             }
         }
     }
+
     void SpellHit(Unit* pCaster, const SpellEntry* pSpell)
     {
         if (HasFollowState(STATE_FOLLOW_INPROGRESS | STATE_FOLLOW_PAUSED) && pSpell->Id == SPELL_AWAKEN)
             ClearSleeping();
     }
+
     void SetSleeping()
     {
         SetFollowPaused(true);
+
         DoScriptText(RAND(EMOTE_KER_SLEEP_1,EMOTE_KER_SLEEP_2,EMOTE_KER_SLEEP_3), m_creature);
+
         DoScriptText(RAND(SAY_KER_SLEEP_1,SAY_KER_SLEEP_2,SAY_KER_SLEEP_3,SAY_KER_SLEEP_4), m_creature);
+
         m_creature->SetStandState(UNIT_STAND_STATE_SLEEP);
         m_creature->CastSpell(m_creature, SPELL_SLEEP_VISUAL, false);
     }
+
     void ClearSleeping()
     {
         m_creature->RemoveAurasDueToSpell(SPELL_SLEEP_VISUAL);
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
+
         DoScriptText(EMOTE_KER_AWAKEN, m_creature);
+
         SetFollowPaused(false);
     }
+
     void UpdateFollowerAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
         {
             if (!HasFollowState(STATE_FOLLOW_INPROGRESS))
                 return;
+
             if (!HasFollowState(STATE_FOLLOW_PAUSED))
             {
                 if (m_uiFallAsleepTimer < uiDiff)
@@ -112,15 +140,19 @@ struct TRINITY_DLL_DECL npc_kerlonianAI : public FollowerAI
                 else
                     m_uiFallAsleepTimer -= uiDiff;
             }
+
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_kerlonian(Creature* pCreature)
 {
     return new npc_kerlonianAI(pCreature);
 }
+
 bool QuestAccept_npc_kerlonian(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_SLEEPER_AWAKENED)
@@ -132,11 +164,14 @@ bool QuestAccept_npc_kerlonian(Player* pPlayer, Creature* pCreature, const Quest
             pKerlonianAI->StartFollow(pPlayer, FACTION_KER_ESCORTEE, pQuest);
         }
     }
+
     return true;
 }
+
 /*####
 # npc_prospector_remtravel
 ####*/
+
 enum eRemtravel
 {
     SAY_REM_START               = -1000415, // signed for 4966
@@ -152,20 +187,25 @@ enum eRemtravel
     SAY_REM_PROGRESS            = -1000424, // signed for 9999
     SAY_REM_REMEMBER            = -1000425, // signed for 9999
     EMOTE_REM_END               = -1000426, // signed for 9999
+
     FACTION_ESCORTEE            = 10,
     QUEST_ABSENT_MINDED_PT2     = 731,
     NPC_GRAVEL_SCOUT            = 2158,
     NPC_GRAVEL_BONE             = 2159,
     NPC_GRAVEL_GEO              = 2160
 };
+
 struct TRINITY_DLL_DECL npc_prospector_remtravelAI : public npc_escortAI
 {
     npc_prospector_remtravelAI(Creature* pCreature) : npc_escortAI(pCreature) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
             case 0:
@@ -221,35 +261,44 @@ struct TRINITY_DLL_DECL npc_prospector_remtravelAI : public npc_escortAI
                 break;
         }
     }
+
     void Reset() {}
+
     void EnterCombat(Unit* who)
     {
         if (rand()%2)
             DoScriptText(SAY_REM_AGGRO, me, who);
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         //unsure if it should be any
         //pSummoned->AI()->AttackStart(m_creature);
     }
 };
+
 CreatureAI* GetAI_npc_prospector_remtravel(Creature* pCreature)
 {
     return new npc_prospector_remtravelAI(pCreature);
 }
+
 bool QuestAccept_npc_prospector_remtravel(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_ABSENT_MINDED_PT2)
     {
         if (npc_escortAI* pEscortAI = CAST_AI(npc_prospector_remtravelAI, pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID());
+
         pCreature->setFaction(FACTION_ESCORTEE);
     }
+
     return true;
 }
+
 /*####
 # npc_threshwackonator
 ####*/
+
 enum eThreshwackonator
 {
     EMOTE_START             = -1000413, //signed for 4966
@@ -258,14 +307,19 @@ enum eThreshwackonator
     NPC_GELKAK              = 6667,
     FACTION_HOSTILE         = 14
 };
+
 #define GOSSIP_ITEM_INSERT_KEY  "[PH] Insert key"
+
 struct TRINITY_DLL_DECL npc_threshwackonatorAI : public FollowerAI
 {
     npc_threshwackonatorAI(Creature* pCreature) : FollowerAI(pCreature) { }
+
     void Reset() { }
+
     void MoveInLineOfSight(Unit* pWho)
     {
         FollowerAI::MoveInLineOfSight(pWho);
+
         if (!m_creature->getVictim() && !HasFollowState(STATE_FOLLOW_COMPLETE) && pWho->GetEntry() == NPC_GELKAK)
         {
             if (m_creature->IsWithinDistInMap(pWho, 10.0f))
@@ -275,51 +329,64 @@ struct TRINITY_DLL_DECL npc_threshwackonatorAI : public FollowerAI
             }
         }
     }
+
     void DoAtEnd()
     {
         me->setFaction(FACTION_HOSTILE);
+
         if (Player* pHolder = GetLeaderForFollower())
             me->AI()->AttackStart(pHolder);
+
         SetFollowComplete();
     }
 };
+
 CreatureAI* GetAI_npc_threshwackonator(Creature* pCreature)
 {
     return new npc_threshwackonatorAI(pCreature);
 }
+
 bool GossipHello_npc_threshwackonator(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_GYROMAST_REV) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_INSERT_KEY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_threshwackonator(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
     {
         pPlayer->CLOSE_GOSSIP_MENU();
+
         if (npc_threshwackonatorAI* pThreshAI = CAST_AI(npc_threshwackonatorAI, pCreature->AI()))
         {
             DoScriptText(EMOTE_START, pCreature);
             pThreshAI->StartFollow(pPlayer);
         }
     }
+
     return true;
 }
+
 void AddSC_darkshore()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_kerlonian";
     newscript->GetAI = &GetAI_npc_kerlonian;
     newscript->pQuestAccept = &QuestAccept_npc_kerlonian;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_prospector_remtravel";
     newscript->GetAI = &GetAI_npc_prospector_remtravel;
     newscript->pQuestAccept = &QuestAccept_npc_prospector_remtravel;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_threshwackonator";
     newscript->GetAI = &GetAI_npc_threshwackonator;
diff --git a/src/bindings/scripts/scripts/kalimdor/desolace.cpp b/src/bindings/scripts/scripts/kalimdor/desolace.cpp
index 8555b3190f0..02702f77c15 100644
--- a/src/bindings/scripts/scripts/kalimdor/desolace.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/desolace.cpp
@@ -13,55 +13,70 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Desolace
 SD%Complete: 100
 SDComment: Quest support: 5561
 SDCategory: Desolace
 EndScriptData */
+
 /* ContentData
 npc_aged_dying_ancient_kodo
 EndContentData */
+
 #include "precompiled.h"
+
 enum eDyingKodo
 {
     // signed for 9999
     SAY_SMEED_HOME_1                = -1000428,
     SAY_SMEED_HOME_2                = -1000429,
     SAY_SMEED_HOME_3                = -1000430,
+
     QUEST_KODO                      = 5561,
+
     NPC_SMEED                       = 11596,
     NPC_AGED_KODO                   = 4700,
     NPC_DYING_KODO                  = 4701,
     NPC_ANCIENT_KODO                = 4702,
     NPC_TAMED_KODO                  = 11627,
+
     SPELL_KODO_KOMBO_ITEM           = 18153,
     SPELL_KODO_KOMBO_PLAYER_BUFF    = 18172,                //spells here have unclear function, but using them at least for visual parts and checks
     SPELL_KODO_KOMBO_DESPAWN_BUFF   = 18377,
     SPELL_KODO_KOMBO_GOSSIP         = 18362
+
 };
+
 struct TRINITY_DLL_DECL npc_aged_dying_ancient_kodoAI : public ScriptedAI
 {
     npc_aged_dying_ancient_kodoAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); }
+
     uint32 m_uiDespawnTimer;
+
     void Reset()
     {
         m_uiDespawnTimer = 0;
     }
+
     void MoveInLineOfSight(Unit* pWho)
     {
         if (pWho->GetEntry() == NPC_SMEED)
         {
             if (m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP))
                 return;
+
             if (m_creature->IsWithinDistInMap(pWho, 10.0f))
             {
                 DoScriptText(RAND(SAY_SMEED_HOME_1,SAY_SMEED_HOME_2,SAY_SMEED_HOME_3), pWho);
+
                 //spell have no implemented effect (dummy), so useful to notify spellHit
                 m_creature->CastSpell(m_creature,SPELL_KODO_KOMBO_GOSSIP,true);
             }
         }
     }
+
     void SpellHit(Unit* pCaster, SpellEntry const* pSpell)
     {
         if (pSpell->Id == SPELL_KODO_KOMBO_GOSSIP)
@@ -70,6 +85,7 @@ struct TRINITY_DLL_DECL npc_aged_dying_ancient_kodoAI : public ScriptedAI
             m_uiDespawnTimer = 60000;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //timer should always be == 0 unless we already updated entry of creature. Then not expect this updated to ever be in combat.
@@ -83,15 +99,19 @@ struct TRINITY_DLL_DECL npc_aged_dying_ancient_kodoAI : public ScriptedAI
                 return;
             }
         } else m_uiDespawnTimer -= diff;
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_aged_dying_ancient_kodo(Creature* pCreature)
 {
     return new npc_aged_dying_ancient_kodoAI(pCreature);
 }
+
 bool EffectDummyCreature_npc_aged_dying_ancient_kodo(Unit *pCaster, uint32 spellId, uint32 effIndex, Creature *pCreatureTarget)
 {
     //always check spellid and effectindex
@@ -100,37 +120,47 @@ bool EffectDummyCreature_npc_aged_dying_ancient_kodo(Unit *pCaster, uint32 spell
         //no effect if player/creature already have aura from spells
         if (pCaster->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) || pCreatureTarget->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF))
             return true;
+
         if (pCreatureTarget->GetEntry() == NPC_AGED_KODO ||
             pCreatureTarget->GetEntry() == NPC_DYING_KODO ||
             pCreatureTarget->GetEntry() == NPC_ANCIENT_KODO)
         {
             pCaster->CastSpell(pCaster,SPELL_KODO_KOMBO_PLAYER_BUFF,true);
+
             pCreatureTarget->UpdateEntry(NPC_TAMED_KODO);
             pCreatureTarget->CastSpell(pCreatureTarget,SPELL_KODO_KOMBO_DESPAWN_BUFF,false);
+
             if (pCreatureTarget->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
                 pCreatureTarget->GetMotionMaster()->MoveIdle();
+
             pCreatureTarget->GetMotionMaster()->MoveFollow(pCaster, PET_FOLLOW_DIST,  pCreatureTarget->GetFollowAngle());
         }
+
         //always return true when we are handling this spell and effect
         return true;
     }
     return false;
 }
+
 bool GossipHello_npc_aged_dying_ancient_kodo(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) && pCreature->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF))
     {
         //the expected quest objective
         pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
+
         pPlayer->RemoveAurasDueToSpell(SPELL_KODO_KOMBO_PLAYER_BUFF);
         pCreature->GetMotionMaster()->MoveIdle();
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 void AddSC_desolace()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_aged_dying_ancient_kodo";
     newscript->GetAI = &GetAI_npc_aged_dying_ancient_kodo;
diff --git a/src/bindings/scripts/scripts/kalimdor/dustwallow_marsh.cpp b/src/bindings/scripts/scripts/kalimdor/dustwallow_marsh.cpp
index 1a278abb78c..8f33a569c3e 100644
--- a/src/bindings/scripts/scripts/kalimdor/dustwallow_marsh.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/dustwallow_marsh.cpp
@@ -13,12 +13,14 @@
  * along 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, 11142, 11180. Vendor Nat Pagle
 SDCategory: Dustwallow Marsh
 EndScriptData */
+
 /* ContentData
 mobs_risen_husk_spirit
 npc_restless_apparition
@@ -28,10 +30,13 @@ npc_nat_pagle
 npc_private_hendel
 npc_cassa_crimsonwing - handled by npc_taxi
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## mobs_risen_husk_spirit
 ######*/
+
 enum eHuskSpirit
 {
     QUEST_WHATS_HAUNTING_WITCH_HILL  = 11180,
@@ -41,16 +46,20 @@ enum eHuskSpirit
     NPC_RISEN_HUSK                   = 23555,
     NPC_RISEN_SPIRIT                 = 23554
 };
+
 struct TRINITY_DLL_DECL mobs_risen_husk_spiritAI : public ScriptedAI
 {
     mobs_risen_husk_spiritAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 m_uiConsumeFlesh_Timer;
     uint32 m_uiIntangiblePresence_Timer;
+
     void Reset()
     {
         m_uiConsumeFlesh_Timer = 10000;
         m_uiIntangiblePresence_Timer = 5000;
     }
+
     void DamageTaken(Unit* pDoneBy, uint32 &damage)
     {
         if (pDoneBy->GetTypeId() == TYPEID_PLAYER)
@@ -59,63 +68,80 @@ struct TRINITY_DLL_DECL mobs_risen_husk_spiritAI : public ScriptedAI
                 m_creature->CastSpell(pDoneBy, SPELL_SUMMON_RESTLESS_APPARITION, false);
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         if (m_uiConsumeFlesh_Timer < uiDiff)
         {
             if (m_creature->GetEntry() == NPC_RISEN_HUSK)
                 DoCast(m_creature->getVictim(), SPELL_CONSUME_FLESH);
+
             m_uiConsumeFlesh_Timer = 15000;
         }
         else
             m_uiConsumeFlesh_Timer -= uiDiff;
+
         if (m_uiIntangiblePresence_Timer < uiDiff)
         {
             if (m_creature->GetEntry() == NPC_RISEN_SPIRIT)
                 DoCast(m_creature->getVictim(), SPELL_INTANGIBLE_PRESENCE);
+
             m_uiIntangiblePresence_Timer = 20000;
         }
         else
             m_uiIntangiblePresence_Timer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mobs_risen_husk_spirit(Creature* pCreature)
 {
     return new mobs_risen_husk_spiritAI (pCreature);
 }
+
 /*######
 ## npc_restless_apparition
 ######*/
+
 bool GossipHello_npc_restless_apparition(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
     pCreature->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
     return true;
 }
+
 /*######
 ## npc_deserter_agitator
 ######*/
+
 enum eAgitator
 {
     QUEST_TRAITORS_AMONG_US = 11126,
     FACTION_THER_DESERTER   = 1883
 };
+
 struct TRINITY_DLL_DECL npc_deserter_agitatorAI : public ScriptedAI
 {
     npc_deserter_agitatorAI(Creature* pCreature) : ScriptedAI(pCreature) { }
+
     void Reset()
     {
         me->RestoreFaction();
     }
 };
+
 CreatureAI* GetAI_npc_deserter_agitator(Creature* pCreature)
 {
     return new npc_deserter_agitatorAI (pCreature);
 }
+
 bool GossipHello_npc_deserter_agitator(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_TRAITORS_AMONG_US) == QUEST_STATUS_INCOMPLETE)
@@ -125,26 +151,35 @@ bool GossipHello_npc_deserter_agitator(Player* pPlayer, Creature* pCreature)
     }
     else
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 ## npc_lady_jaina_proudmoore
 ######*/
+
 enum eLadyJaina
 {
     QUEST_JAINAS_AUTOGRAPH = 558,
     SPELL_JAINAS_AUTOGRAPH = 23122
 };
+
 #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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_JAINAS_AUTOGRAPH) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_JAINA, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_lady_jaina_proudmoore(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_SENDER_INFO)
@@ -154,17 +189,21 @@ bool GossipSelect_npc_lady_jaina_proudmoore(Player* pPlayer, Creature* pCreature
     }
     return true;
 }
+
 /*######
 ## npc_nat_pagle
 ######*/
+
 enum eNatPagle
 {
     QUEST_NATS_MEASURING_TAPE = 8227
 };
+
 bool GossipHello_npc_nat_pagle(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor() && pPlayer->GetQuestRewardStatus(QUEST_NATS_MEASURING_TAPE))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
@@ -172,17 +211,22 @@ bool GossipHello_npc_nat_pagle(Player* pPlayer, Creature* pCreature)
     }
     else
         pPlayer->SEND_GOSSIP_MENU(7638, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_nat_pagle(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 ## npc_private_hendel
 ######*/
+
 enum eHendel
 {
     // looks like all this text ids are wrong.
@@ -191,79 +235,100 @@ enum eHendel
     SAY_PROGRESS_3_TER          = -1000413,
     SAY_PROGRESS_4_TER          = -1000414,
     EMOTE_SURRENDER             = -1000415,
+
     QUEST_MISSING_DIPLO_PT16    = 1324,
     FACTION_HOSTILE             = 168,                      //guessed, may be different
+
     NPC_SENTRY                  = 5184,                     //helps hendel
     NPC_JAINA                   = 4968,                     //appears once hendel gives up
     NPC_TERVOSH                 = 4967
 };
+
 //TODO: develop this further, end event not created
 struct TRINITY_DLL_DECL npc_private_hendelAI : public ScriptedAI
 {
     npc_private_hendelAI(Creature* pCreature) : ScriptedAI(pCreature) { }
+
     void Reset()
     {
         me->RestoreFaction();
     }
+
     void AttackedBy(Unit* pAttacker)
     {
         if (m_creature->getVictim())
             return;
+
         if (m_creature->IsFriendlyTo(pAttacker))
             return;
+
         AttackStart(pAttacker);
     }
+
     void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
     {
         if (uiDamage > m_creature->GetHealth() || ((m_creature->GetHealth() - uiDamage)*100 / m_creature->GetMaxHealth() < 20))
         {
             uiDamage = 0;
+
             if (Player* pPlayer = pDoneBy->GetCharmerOrOwnerPlayerOrPlayerItself())
                 pPlayer->GroupEventHappens(QUEST_MISSING_DIPLO_PT16, m_creature);
+
             DoScriptText(EMOTE_SURRENDER, m_creature);
             EnterEvadeMode();
         }
     }
 };
+
 bool QuestAccept_npc_private_hendel(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_MISSING_DIPLO_PT16)
         pCreature->setFaction(FACTION_HOSTILE);
+
     return true;
 }
+
 CreatureAI* GetAI_npc_private_hendel(Creature* pCreature)
 {
     return new npc_private_hendelAI(pCreature);
 }
+
 /*######
 ##
 ######*/
+
 void AddSC_dustwallow_marsh()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mobs_risen_husk_spirit";
     newscript->GetAI = &GetAI_mobs_risen_husk_spirit;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_restless_apparition";
     newscript->pGossipHello =   &GossipHello_npc_restless_apparition;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_deserter_agitator";
     newscript->GetAI = &GetAI_npc_deserter_agitator;
     newscript->pGossipHello = &GossipHello_npc_deserter_agitator;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_lady_jaina_proudmoore";
     newscript->pGossipHello = &GossipHello_npc_lady_jaina_proudmoore;
     newscript->pGossipSelect = &GossipSelect_npc_lady_jaina_proudmoore;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_nat_pagle";
     newscript->pGossipHello = &GossipHello_npc_nat_pagle;
     newscript->pGossipSelect = &GossipSelect_npc_nat_pagle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_private_hendel";
     newscript->GetAI = &GetAI_npc_private_hendel;
diff --git a/src/bindings/scripts/scripts/kalimdor/felwood.cpp b/src/bindings/scripts/scripts/kalimdor/felwood.cpp
index 1baee7b02bb..4a676ec5366 100644
--- a/src/bindings/scripts/scripts/kalimdor/felwood.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/felwood.cpp
@@ -13,25 +13,33 @@
  * along 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: 4101, 4102
 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* pPlayer, Creature* pCreature)
 {
     uint32 eCreature = pCreature->GetEntry();
+
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (eCreature==9528)
     {
         if (pPlayer->GetQuestRewardStatus(4101))
@@ -43,6 +51,7 @@ bool GossipHello_npcs_riverbreeze_and_silversky(Player* pPlayer, Creature* pCrea
         else
             pPlayer->SEND_GOSSIP_MENU(2844, pCreature->GetGUID());
     }
+
     if (eCreature==9529)
     {
         if (pPlayer->GetQuestRewardStatus(4102))
@@ -54,8 +63,10 @@ bool GossipHello_npcs_riverbreeze_and_silversky(Player* pPlayer, Creature* pCrea
         else
             pPlayer->SEND_GOSSIP_MENU(2842, pCreature->GetGUID());
     }
+
     return true;
 }
+
 bool GossipSelect_npcs_riverbreeze_and_silversky(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction ==GOSSIP_ACTION_INFO_DEF+1)
@@ -65,9 +76,11 @@ bool GossipSelect_npcs_riverbreeze_and_silversky(Player* pPlayer, Creature* pCre
     }
     return true;
 }
+
 void AddSC_felwood()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npcs_riverbreeze_and_silversky";
     newscript->pGossipHello = &GossipHello_npcs_riverbreeze_and_silversky;
diff --git a/src/bindings/scripts/scripts/kalimdor/feralas.cpp b/src/bindings/scripts/scripts/kalimdor/feralas.cpp
index aec906510e8..9a3df7c06e2 100644
--- a/src/bindings/scripts/scripts/kalimdor/feralas.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/feralas.cpp
@@ -13,27 +13,35 @@
  * along 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, 2767, Special vendor Gregan Brewspewer
 SDCategory: Feralas
 EndScriptData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_gregan_brewspewer
 ######*/
+
 #define GOSSIP_HELLO "Buy somethin', will ya?"
+
 bool GossipHello_npc_gregan_brewspewer(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor() && pPlayer->GetQuestStatus(3909) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(2433, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_gregan_brewspewer(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -45,9 +53,11 @@ bool GossipSelect_npc_gregan_brewspewer(Player* pPlayer, Creature* pCreature, ui
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
     return true;
 }
+
 /*######
 ## npc_oox22fe
 ######*/
+
 enum eOOX
 {
     //signed for 7806
@@ -56,19 +66,23 @@ enum eOOX
     SAY_OOX_AGGRO2          = -1000289,
     SAY_OOX_AMBUSH          = -1000290,
     SAY_OOX_END             = -1000292,
+
     NPC_YETI                = 7848,
     NPC_GORILLA             = 5260,
     NPC_WOODPAW_REAVER      = 5255,
     NPC_WOODPAW_BRUTE       = 5253,
     NPC_WOODPAW_ALPHA       = 5258,
     NPC_WOODPAW_MYSTIC      = 5254,
+
     QUEST_RESCUE_OOX22FE    = 2767,
     FACTION_ESCORTEE_A      = 774,
     FACTION_ESCORTEE_H      = 775
 };
+
 struct TRINITY_DLL_DECL npc_oox22feAI : public npc_escortAI
 {
     npc_oox22feAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     void WaypointReached(uint32 i)
     {
         switch (i)
@@ -105,26 +119,31 @@ struct TRINITY_DLL_DECL npc_oox22feAI : public npc_escortAI
                 break;
         }
     }
+
     void Reset()
     {
         if (!HasEscortState(STATE_ESCORT_ESCORTING))
             m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
     }
+
     void EnterCombat(Unit* who)
     {
         //For an small probability the npc says something when he get aggro
         if (urand(0,9) > 7)
             DoScriptText(RAND(SAY_OOX_AGGRO1,SAY_OOX_AGGRO2), m_creature);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
 };
+
 CreatureAI* GetAI_npc_oox22fe(Creature* pCreature)
 {
     return new npc_oox22feAI(pCreature);
 }
+
 bool QuestAccept_npc_oox22fe(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_RESCUE_OOX22FE)
@@ -132,41 +151,53 @@ bool QuestAccept_npc_oox22fe(Player* pPlayer, Creature* pCreature, const Quest*
         DoScriptText(SAY_OOX_START, pCreature);
         //change that the npc is not lying dead on the ground
         pCreature->SetStandState(UNIT_STAND_STATE_STAND);
+
         if (pPlayer->GetTeam() == ALLIANCE)
             pCreature->setFaction(FACTION_ESCORTEE_A);
+
         if (pPlayer->GetTeam() == HORDE)
             pCreature->setFaction(FACTION_ESCORTEE_H);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_oox22feAI, pCreature->AI()))
             pEscortAI->Start(true, false, pPlayer->GetGUID());
+
     }
     return true;
 }
+
 /*######
 ## npc_screecher_spirit
 ######*/
+
 bool GossipHello_npc_screecher_spirit(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->SEND_GOSSIP_MENU(2039, pCreature->GetGUID());
     pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
     pCreature->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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_oox22fe";
     newscript->GetAI = &GetAI_npc_oox22fe;
     newscript->pQuestAccept = &QuestAccept_npc_oox22fe;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_screecher_spirit";
     newscript->pGossipHello = &GossipHello_npc_screecher_spirit;
diff --git a/src/bindings/scripts/scripts/kalimdor/maraudon/boss_celebras_the_cursed.cpp b/src/bindings/scripts/scripts/kalimdor/maraudon/boss_celebras_the_cursed.cpp
index 8eabe72c3fc..de33f5253df 100644
--- a/src/bindings/scripts/scripts/kalimdor/maraudon/boss_celebras_the_cursed.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/maraudon/boss_celebras_the_cursed.cpp
@@ -13,37 +13,47 @@
  * along with 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 TRINITY_DLL_DECL celebras_the_cursedAI : public ScriptedAI
 {
     celebras_the_cursedAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Wrath_Timer;
     uint32 EntanglingRoots_Timer;
     uint32 CorruptForces_Timer;
+
     void Reset()
     {
         Wrath_Timer = 8000;
         EntanglingRoots_Timer = 2000;
         CorruptForces_Timer = 30000;
     }
+
     void EnterCombat(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 (!UpdateVictim())
             return;
+
         //Wrath
         if (Wrath_Timer < diff)
         {
@@ -53,12 +63,14 @@ struct TRINITY_DLL_DECL celebras_the_cursedAI : public ScriptedAI
                 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)
         {
@@ -66,6 +78,7 @@ struct TRINITY_DLL_DECL celebras_the_cursedAI : public ScriptedAI
             DoCast(m_creature,SPELL_CORRUPT_FORCES);
             CorruptForces_Timer = 20000;
         }else CorruptForces_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -73,6 +86,7 @@ CreatureAI* GetAI_celebras_the_cursed(Creature* pCreature)
 {
     return new celebras_the_cursedAI (pCreature);
 }
+
 void AddSC_boss_celebras_the_cursed()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/maraudon/boss_landslide.cpp b/src/bindings/scripts/scripts/kalimdor/maraudon/boss_landslide.cpp
index 4babfab7223..736636b69ee 100644
--- a/src/bindings/scripts/scripts/kalimdor/maraudon/boss_landslide.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/maraudon/boss_landslide.cpp
@@ -13,47 +13,58 @@
  * along with 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 TRINITY_DLL_DECL boss_landslideAI : public ScriptedAI
 {
     boss_landslideAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 KnockAway_Timer;
     uint32 Trample_Timer;
     uint32 Landslide_Timer;
+
     void Reset()
     {
         KnockAway_Timer = 8000;
         Trample_Timer = 2000;
         Landslide_Timer = 0;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
@@ -64,6 +75,7 @@ struct TRINITY_DLL_DECL boss_landslideAI : public ScriptedAI
                 Landslide_Timer = 60000;
             } else Landslide_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -71,6 +83,7 @@ CreatureAI* GetAI_boss_landslide(Creature* pCreature)
 {
     return new boss_landslideAI (pCreature);
 }
+
 void AddSC_boss_landslide()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/maraudon/boss_noxxion.cpp b/src/bindings/scripts/scripts/kalimdor/maraudon/boss_noxxion.cpp
index fd26e8126b5..add73e2c60f 100644
--- a/src/bindings/scripts/scripts/kalimdor/maraudon/boss_noxxion.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/maraudon/boss_noxxion.cpp
@@ -13,18 +13,23 @@
  * along with 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 TRINITY_DLL_DECL boss_noxxionAI : public ScriptedAI
 {
     boss_noxxionAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ToxicVolley_Timer;
     uint32 Uppercut_Timer;
     uint32 Adds_Timer;
@@ -34,6 +39,7 @@ struct TRINITY_DLL_DECL boss_noxxionAI : public ScriptedAI
     int RandX;
     int RandY;
     Creature* Summoned;
+
     void Reset()
     {
         ToxicVolley_Timer = 7000;
@@ -42,9 +48,11 @@ struct TRINITY_DLL_DECL boss_noxxionAI : public ScriptedAI
         Invisible_Timer = 15000;                            //Too much too low?
         Invisible = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void SummonAdds(Unit* victim)
     {
         Rand = rand()%8;
@@ -65,6 +73,7 @@ struct TRINITY_DLL_DECL boss_noxxionAI : public ScriptedAI
         if (Summoned)
             (Summoned->AI())->AttackStart(victim);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Invisible && Invisible_Timer < diff)
@@ -82,21 +91,25 @@ struct TRINITY_DLL_DECL boss_noxxionAI : public ScriptedAI
             //Do nothing while invisible
             return;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -114,8 +127,10 @@ struct TRINITY_DLL_DECL boss_noxxionAI : public ScriptedAI
             SummonAdds(m_creature->getVictim());
             Invisible = true;
             Invisible_Timer = 15000;
+
             Adds_Timer = 40000;
         }else Adds_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -123,6 +138,7 @@ CreatureAI* GetAI_boss_noxxion(Creature* pCreature)
 {
     return new boss_noxxionAI (pCreature);
 }
+
 void AddSC_boss_noxxion()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/maraudon/boss_princess_theradras.cpp b/src/bindings/scripts/scripts/kalimdor/maraudon/boss_princess_theradras.cpp
index 3e799b88ad7..53544d9dcdb 100644
--- a/src/bindings/scripts/scripts/kalimdor/maraudon/boss_princess_theradras.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/maraudon/boss_princess_theradras.cpp
@@ -13,24 +13,30 @@
  * along with 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 TRINITY_DLL_DECL boss_ptheradrasAI : public ScriptedAI
 {
     boss_ptheradrasAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Dustfield_Timer;
     uint32 Boulder_Timer;
     uint32 Thrash_Timer;
     uint32 RepulsiveGaze_Timer;
+
     void Reset()
     {
         Dustfield_Timer = 8000;
@@ -38,23 +44,28 @@ struct TRINITY_DLL_DECL boss_ptheradrasAI : public ScriptedAI
         Thrash_Timer = 5000;
         RepulsiveGaze_Timer = 23000;
     }
+
     void EnterCombat(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 (!UpdateVictim())
             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)
         {
@@ -64,18 +75,21 @@ struct TRINITY_DLL_DECL boss_ptheradrasAI : public ScriptedAI
                 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();
     }
 };
@@ -83,6 +97,7 @@ CreatureAI* GetAI_boss_ptheradras(Creature* pCreature)
 {
     return new boss_ptheradrasAI (pCreature);
 }
+
 void AddSC_boss_ptheradras()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/moonglade.cpp b/src/bindings/scripts/scripts/kalimdor/moonglade.cpp
index b50a3b3e932..7e52c16b74d 100644
--- a/src/bindings/scripts/scripts/kalimdor/moonglade.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/moonglade.cpp
@@ -13,12 +13,14 @@
  * along 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, 10965. Special Flight Paths for Druid class.
 SDCategory: Moonglade
 EndScriptData */
+
 /* ContentData
 npc_bunthen_plainswind
 npc_great_bear_spirit
@@ -26,11 +28,14 @@ npc_silva_filnaveth
 npc_clintar_spirit
 npc_clintar_dreamwalker
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_bunthen_plainswind
 ######*/
+
 enum eBunthen
 {
     QUEST_SEA_LION_HORDE        = 30,
@@ -38,8 +43,10 @@ enum eBunthen
     TAXI_PATH_ID_ALLY           = 315,
     TAXI_PATH_ID_HORDE          = 316
 };
+
 #define GOSSIP_ITEM_THUNDER     "I'd like to fly to Thunder Bluff."
 #define GOSSIP_ITEM_AQ_END      "Do you know where I can find Half Pendant of Aquatic Endurance?"
+
 bool GossipHello_npc_bunthen_plainswind(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->getClass() != CLASS_DRUID)
@@ -48,17 +55,21 @@ bool GossipHello_npc_bunthen_plainswind(Player* pPlayer, Creature* pCreature)
     {
         if (pPlayer->GetQuestStatus(QUEST_SEA_LION_ALLY) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_AQ_END, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
+
         pPlayer->SEND_GOSSIP_MENU(4917, pCreature->GetGUID());
     }
     else if (pPlayer->getClass() == CLASS_DRUID && pPlayer->GetTeam() == HORDE)
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_THUNDER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
         if (pPlayer->GetQuestStatus(QUEST_SEA_LION_HORDE) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_AQ_END, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
+
         pPlayer->SEND_GOSSIP_MENU(4918, pCreature->GetGUID());
     }
     return true;
 }
+
 bool GossipSelect_npc_bunthen_plainswind(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -77,13 +88,16 @@ bool GossipSelect_npc_bunthen_plainswind(Player* pPlayer, Creature* pCreature, u
     }
     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* pPlayer, Creature* pCreature)
 {
     //ally or horde quest
@@ -94,8 +108,10 @@ bool GossipHello_npc_great_bear_spirit(Player* pPlayer, Creature* pCreature)
     }
     else
         pPlayer->SEND_GOSSIP_MENU(4718, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_great_bear_spirit(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -122,11 +138,14 @@ bool GossipSelect_npc_great_bear_spirit(Player* pPlayer, Creature* pCreature, ui
     }
     return true;
 }
+
 /*######
 ## npc_silva_filnaveth
 ######*/
+
 #define GOSSIP_ITEM_RUTHERAN    "I'd like to fly to Rut'theran Village."
 #define GOSSIP_ITEM_AQ_AGI      "Do you know where I can find Half Pendant of Aquatic Agility?"
+
 bool GossipHello_npc_silva_filnaveth(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->getClass() != CLASS_DRUID)
@@ -135,17 +154,21 @@ bool GossipHello_npc_silva_filnaveth(Player* pPlayer, Creature* pCreature)
     {
         if (pPlayer->GetQuestStatus(QUEST_SEA_LION_HORDE) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_AQ_AGI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
+
         pPlayer->SEND_GOSSIP_MENU(4915, pCreature->GetGUID());
     }
     else if (pPlayer->getClass() == CLASS_DRUID && pPlayer->GetTeam() == ALLIANCE)
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_RUTHERAN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
         if (pPlayer->GetQuestStatus(QUEST_SEA_LION_ALLY) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_AQ_AGI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
+
         pPlayer->SEND_GOSSIP_MENU(4914, pCreature->GetGUID());
     }
     return true;
 }
+
 bool GossipSelect_npc_silva_filnaveth(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -164,9 +187,11 @@ bool GossipSelect_npc_silva_filnaveth(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 /*######
 ## npc_clintar_spirit
 ######*/
+
 float Clintar_spirit_WP[41][5] =
 {
  //pos_x   pos_y    pos_z    orien waitTime
@@ -212,7 +237,9 @@ float Clintar_spirit_WP[41][5] =
 {7518.37, -3057.42, 445.584, 0.74, 0},
 {7517.51, -3056.3,  444.568, 2.49, 4500}
 };
+
 #define ASPECT_RAVEN 22915
+
 #define ASPECT_RAVEN_SUMMON_X 7472.96
 #define ASPECT_RAVEN_SUMMON_Y -3074.18
 #define ASPECT_RAVEN_SUMMON_Z 427.566
@@ -220,6 +247,7 @@ float Clintar_spirit_WP[41][5] =
 #define CLINTAR_SPIRIT_SUMMON_Y -3122.5632
 #define CLINTAR_SPIRIT_SUMMON_Z 438.9842
 #define CLINTAR_SPIRIT_SUMMON_O 0.8594
+
 //from -1000292 to -1000287 are signed for 7806. but all this texts ids wrong.
 #define CLINTAR_SPIRIT_SAY_START -1000286
 #define CLINTAR_SPIRIT_SAY_UNDER_ATTACK_1 -1000287
@@ -228,16 +256,21 @@ float Clintar_spirit_WP[41][5] =
 #define CLINTAR_SPIRIT_SAY_GET_TWO -1000290
 #define CLINTAR_SPIRIT_SAY_GET_THREE -1000291
 #define CLINTAR_SPIRIT_SAY_GET_FINAL -1000292
+
 struct TRINITY_DLL_DECL npc_clintar_spiritAI : public npc_escortAI
 {
 public:
     npc_clintar_spiritAI(Creature *c) : npc_escortAI(c) {}
+
     uint32 Step;
     uint32 CurrWP;
     uint32 Event_Timer;
     uint32 checkPlayer_Timer;
+
     uint64 PlayerGUID;
+
     bool Event_onWait;
+
     void Reset()
     {
         if (!PlayerGUID)
@@ -250,10 +283,12 @@ public:
             Event_onWait = false;
         }
     }
+
     void JustDied(Unit *killer)
     {
         if (!PlayerGUID)
             return;
+
         Player* pPlayer = Unit::GetPlayer(PlayerGUID);
         if (pPlayer && pPlayer->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE)
         {
@@ -262,6 +297,7 @@ public:
             Reset();
         }
     }
+
     void EnterEvadeMode()
     {
         Player* pPlayer = Unit::GetPlayer(PlayerGUID);
@@ -272,6 +308,7 @@ public:
         }
         npc_escortAI::EnterEvadeMode();
     }
+
     void EnterCombat(Unit* who)
     {
         uint32 rnd = rand()%2;
@@ -281,13 +318,14 @@ public:
             case 1: DoScriptText(CLINTAR_SPIRIT_SAY_UNDER_ATTACK_2, m_creature, who); break;
         }
     }
+
     void StartEvent(Player* pPlayer)
     {
         if (!pPlayer)
             return;
         if (pPlayer->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE)
         {
-            for (uint8 i = 0; i < 41; ++i)
+            for(uint8 i = 0; i < 41; ++i)
             {
                 AddWaypoint(i, Clintar_spirit_WP[i][0], Clintar_spirit_WP[i][1], Clintar_spirit_WP[i][2], (uint32)Clintar_spirit_WP[i][4]);
             }
@@ -296,14 +334,17 @@ public:
         }
         return;
     }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
+
         if (!PlayerGUID)
         {
             m_creature->setDeathState(JUST_DIED);
             return;
         }
+
         if (!m_creature->isInCombat() && !Event_onWait)
         {
             if (checkPlayer_Timer < diff)
@@ -314,14 +355,17 @@ public:
                 checkPlayer_Timer = 1000;
             }else checkPlayer_Timer -= diff;
         }
+
         if (Event_onWait && Event_Timer < diff)
         {
+
             Player* pPlayer = Unit::GetPlayer(PlayerGUID);
             if (!pPlayer || (pPlayer && pPlayer->GetQuestStatus(10965) == QUEST_STATUS_NONE))
             {
                 m_creature->setDeathState(JUST_DIED);
                 return;
             }
+
             switch(CurrWP)
             {
                 case 0:
@@ -453,8 +497,10 @@ public:
                     Event_onWait = false;
                     break;
             }
+
         } else if (Event_onWait) Event_Timer -= diff;
     }
+
     void WaypointReached(uint32 id)
     {
         CurrWP = id;
@@ -463,14 +509,18 @@ public:
         Event_onWait = true;
     }
 };
+
 CreatureAI* GetAI_npc_clintar_spirit(Creature* pCreature)
 {
     return new npc_clintar_spiritAI (pCreature);
 }
+
 /*####
 # npc_clintar_dreamwalker
 ####*/
+
 #define CLINTAR_SPIRIT 22916
+
 bool QuestAccept_npc_clintar_dreamwalker(Player* pPlayer, Creature* pCreature, Quest const *quest)
 {
     if (quest->GetQuestId() == 10965)
@@ -481,31 +531,38 @@ bool QuestAccept_npc_clintar_dreamwalker(Player* pPlayer, Creature* pCreature, Q
     }
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_great_bear_spirit";
     newscript->pGossipHello =  &GossipHello_npc_great_bear_spirit;
     newscript->pGossipSelect = &GossipSelect_npc_great_bear_spirit;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_silva_filnaveth";
     newscript->pGossipHello =  &GossipHello_npc_silva_filnaveth;
     newscript->pGossipSelect = &GossipSelect_npc_silva_filnaveth;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_clintar_dreamwalker";
     newscript->pQuestAccept = &QuestAccept_npc_clintar_dreamwalker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_clintar_spirit";
     newscript->GetAI = &GetAI_npc_clintar_spirit;
diff --git a/src/bindings/scripts/scripts/kalimdor/mulgore.cpp b/src/bindings/scripts/scripts/kalimdor/mulgore.cpp
index 974402849a0..0fcd62cd8df 100644
--- a/src/bindings/scripts/scripts/kalimdor/mulgore.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/mulgore.cpp
@@ -13,60 +13,77 @@
  * along 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: Support for quest: 11129, 772
 SDCategory: Mulgore
 EndScriptData */
+
 /* ContentData
 npc_skorn_whitecloud
 npc_kyle_frenzied
 npc_plains_vision
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 # npc_skorn_whitecloud
 ######*/
+
 #define GOSSIP_SW "Tell me a story, Skorn."
+
 bool GossipHello_npc_skorn_whitecloud(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (!pPlayer->GetQuestRewardStatus(770))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SW, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(522, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_skorn_whitecloud(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
         pPlayer->SEND_GOSSIP_MENU(523, pCreature->GetGUID());
+
     return true;
 }
+
 /*#####
 # npc_kyle_frenzied
 ######*/
+
 enum eKyleFrenzied
 {
     //emote signed for 7780 but propably thats wrong id.
     EMOTE_SEE_LUNCH         = -1000407,
     EMOTE_EAT_LUNCH         = -1000408,
     EMOTE_DANCE             = -1000409,
+
     SPELL_LUNCH             = 42222,
     NPC_KYLE_FRENZIED       = 23616,
     NPC_KYLE_FRIENDLY       = 23622,
     POINT_ID                = 1
 };
+
 struct TRINITY_DLL_DECL npc_kyle_frenziedAI : public ScriptedAI
 {
     npc_kyle_frenziedAI(Creature *c) : ScriptedAI(c) {}
+
     bool bEvent;
     bool m_bIsMovingToLunch;
     uint64 uiPlayerGUID;
     uint32 uiEventTimer;
     uint8 uiEventPhase;
+
     void Reset()
     {
         bEvent = false;
@@ -74,43 +91,52 @@ struct TRINITY_DLL_DECL npc_kyle_frenziedAI : public ScriptedAI
         uiPlayerGUID = 0;
         uiEventTimer = 5000;
         uiEventPhase = 0;
+
         if (m_creature->GetEntry() == NPC_KYLE_FRIENDLY)
             m_creature->UpdateEntry(NPC_KYLE_FRENZIED);
     }
+
     void SpellHit(Unit* pCaster, SpellEntry const* pSpell)
     {
         if (!m_creature->getVictim() && !bEvent && pSpell->Id == SPELL_LUNCH)
         {
             if (pCaster->GetTypeId() == TYPEID_PLAYER)
                 uiPlayerGUID = pCaster->GetGUID();
+
             if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
             {
                 m_creature->GetMotionMaster()->MovementExpired();
                 m_creature->GetMotionMaster()->MoveIdle();
                 m_creature->StopMoving();
             }
+
             bEvent = true;
             DoScriptText(EMOTE_SEE_LUNCH, m_creature);
             m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_CREATURE_SPECIAL);
         }
     }
+
     void MovementInform(uint32 uiType, uint32 uiPointId)
     {
         if (uiType != POINT_MOTION_TYPE || !bEvent)
             return;
+
         if (uiPointId == POINT_ID)
             m_bIsMovingToLunch = false;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (bEvent)
         {
             if (m_bIsMovingToLunch)
                 return;
+
             if (uiEventTimer < diff)
             {
                 uiEventTimer = 5000;
                 ++uiEventPhase;
+
                 switch(uiEventPhase)
                 {
                     case 1:
@@ -130,6 +156,7 @@ struct TRINITY_DLL_DECL npc_kyle_frenziedAI : public ScriptedAI
                     case 3:
                         if (Player* pUnit = Unit::GetPlayer(uiPlayerGUID))
                             pUnit->TalkedToCreature(m_creature->GetEntry(), m_creature->GetGUID());
+
                         m_creature->UpdateEntry(NPC_KYLE_FRIENDLY);
                         break;
                     case 4:
@@ -149,13 +176,16 @@ struct TRINITY_DLL_DECL npc_kyle_frenziedAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_kyle_frenzied(Creature* pCreature)
 {
     return new npc_kyle_frenziedAI (pCreature);
 }
+
 /*#####
 # npc_plains_vision
 ######*/
+
 float wp_plain_vision[50][3] =
 {
     {-2226.32,  -408.095,   -9.36235},
@@ -209,23 +239,29 @@ float wp_plain_vision[50][3] =
     {-1511.39,  362.537,    62.4539},
     {-1508.68,  366.822,    62.733}
 };
+
 struct TRINITY_DLL_DECL npc_plains_visionAI  : public ScriptedAI
 {
     npc_plains_visionAI(Creature *c) : ScriptedAI(c) {}
+
     bool newWaypoint;
     uint8 WayPointId;
     uint8 amountWP;
+
     void Reset()
     {
         WayPointId = 0;
         newWaypoint = true;
         amountWP  = 49;
     }
+
     void EnterCombat(Unit* who){}
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
             return;
+
         if (id < amountWP)
         {
             ++WayPointId;
@@ -237,6 +273,7 @@ struct TRINITY_DLL_DECL npc_plains_visionAI  : public ScriptedAI
             m_creature->RemoveCorpse();
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (newWaypoint)
@@ -246,25 +283,31 @@ struct TRINITY_DLL_DECL npc_plains_visionAI  : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_plains_vision(Creature* pCreature)
 {
       return new npc_plains_visionAI (pCreature);
 }
+
 /*#####
 #
 ######*/
+
 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_kyle_frenzied";
     newscript->GetAI = &GetAI_npc_kyle_frenzied;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_plains_vision";
     newscript->GetAI = &GetAI_npc_plains_vision;
diff --git a/src/bindings/scripts/scripts/kalimdor/onyxias_lair/boss_onyxia.cpp b/src/bindings/scripts/scripts/kalimdor/onyxias_lair/boss_onyxia.cpp
index fe1b71f0b04..3c635526d2e 100644
--- a/src/bindings/scripts/scripts/kalimdor/onyxias_lair/boss_onyxia.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/onyxias_lair/boss_onyxia.cpp
@@ -13,30 +13,39 @@
  * along with 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: 90
 SDComment: Spell Heated Ground is wrong, flying animation, visual for area effect
 SDCategory: Onyxia's Lair
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SAY_AGGRO                   -1249000
 #define SAY_KILL                    -1249001
 #define SAY_PHASE_2_TRANS           -1249002
 #define SAY_PHASE_3_TRANS           -1249003
 #define EMOTE_BREATH                -1249004
+
 #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       //Wrong Spell
+
 #define SPELL_SUMMONWHELP           17646
+
 #define CREATURE_WHELP      11262
+
 static float MovementLocations[4][3]=
 {
     {-64.0523, -213.0619, -68.2985},
@@ -44,6 +53,7 @@ static float MovementLocations[4][3]=
     {-38.8391, -182.3220, -68.9457},
     {-37.0390, -244.8760, -68.1278}
 };
+
 static float SpawnLocations[4][3]=
 {
     {-30.127, -254.463, -89.440},
@@ -51,10 +61,13 @@ static float SpawnLocations[4][3]=
     {14.480, -241.560, -85.6300},
     {17.372, -190.840, -85.2810},
 };
+
 struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
 {
     boss_onyxiaAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 Phase;
+
     uint32 FlameBreathTimer;
     uint32 CleaveTimer;
     uint32 TailSweepTimer;
@@ -65,10 +78,13 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
     uint32 WingBuffetTimer;
     uint32 KnockAwayTimer;
     uint32 FireballTimer;
+
     bool InitialSpawn;
+
     void Reset()
     {
         Phase = 1;
+
         FlameBreathTimer = 20000;
         TailSweepTimer = 2000;
         CleaveTimer = 15000;
@@ -79,24 +95,30 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
         WingBuffetTimer = 17000;
         KnockAwayTimer = 15000;
         FireballTimer = 18000;
+
         InitialSpawn = true;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoZoneInCombat();
     }
+
     void JustDied(Unit* Killer)
     {
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 60) && (Phase == 1))
         {
             Phase = 2;
@@ -106,6 +128,7 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
             m_creature->GetMotionMaster()->MoveIdle();
             DoScriptText(SAY_PHASE_2_TRANS, m_creature);
         }
+
         if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 40) && (Phase == 2))
         {
             Phase = 3;
@@ -117,6 +140,7 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
             DoScriptText(SAY_PHASE_3_TRANS, m_creature);
             m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
         }
+
         if (Phase == 1 || Phase == 3)
         {
             if (FlameBreathTimer < diff)
@@ -124,23 +148,28 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
                 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;
+
             if (KnockAwayTimer < diff)
             {
                 if (rand() <= 30)
@@ -149,27 +178,34 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
                 }
                 KnockAwayTimer = 15000;
             }else KnockAwayTimer -= diff;
+
             if (Phase == 3)
             {
                 if (BellowingRoarTimer < diff)
                 {
                     DoCast(m_creature->getVictim(), SPELL_BELLOWINGROAR);
+
                     BellowingRoarTimer = 30000;
                 }else BellowingRoarTimer -= diff;
+
                 if (SummonWhelpsTimer < diff)
                 {
                     SummonWhelps(Phase);
+
                     SummonWhelpsTimer = 45000;
                 }else SummonWhelpsTimer -= diff;
             }
+
             DoMeleeAttackIfReady();
         }
+
         if (Phase == 2)
         {
             if (InitialSpawn)
             {
                 InitialSpawn = false;
-                for (uint32 i = 0; i < 10; ++i)
+
+                for(uint32 i = 0; i < 10; ++i)
                 {
                     uint32 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);
@@ -177,19 +213,24 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
                         Whelp->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0));
                 }
             }
+
             if (EngulfingFlamesTimer < diff)
             {
                 DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_ENGULFINGFLAMES);
                 m_creature->HandleEmoteCommand(ANIM_FLY);
+
                 EngulfingFlamesTimer = 10000;
             }
             else EngulfingFlamesTimer -= diff;
+
             if (FireballTimer < diff)
             {
                 DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FIREBALL);
+
                 FireballTimer = 18000;
             }
             else FireballTimer -= diff;
+
             if (MovementTimer < diff)
             {
                 if (rand()%100 < 30)
@@ -198,28 +239,33 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
                     DoCast(m_creature->getVictim(), SPELL_DEEPBREATH);
                 }
                 else ChangePosition();
+
                 MovementTimer = 25000;
             }else MovementTimer -= diff;
+
             if (SummonWhelpsTimer < diff)
             {
                 SummonWhelps(Phase);
+
                 SummonWhelpsTimer = 45000;
             }
             else SummonWhelpsTimer -= diff;
         }
     }
+
     void ChangePosition()
     {
         uint32 random = rand() % 4;
         if (random<4){
             m_creature->GetMotionMaster()->MovePoint(0, MovementLocations[random][0], MovementLocations[random][1], MovementLocations[random][2]);}
     }
+
     void SummonWhelps(uint32 Phase)
     {
         if (Phase == 2)
         {
             uint32 max = rand()%10;
-            for (uint32 i = 0; i < max; ++i)
+            for(uint32 i = 0; i < max; ++i)
             {
                 uint32 random = rand()%3;
                 Creature* Whelp = m_creature->SummonCreature(CREATURE_WHELP, SpawnLocations[random][0], SpawnLocations[random][1], SpawnLocations[random][2], 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
@@ -227,12 +273,13 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
                     Whelp->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0));
             }
         }
+
         if (Phase == 3)
         {
             uint32 max = rand() % 10 +1;
             if (max < 5)
             {
-                for (uint32 i = 0; i < max; ++i)
+                for(uint32 i = 0; i < max; ++i)
                 {
                     uint32 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);
@@ -243,10 +290,12 @@ struct TRINITY_DLL_DECL boss_onyxiaAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_onyxiaAI(Creature* pCreature)
 {
     return new boss_onyxiaAI (pCreature);
 }
+
 void AddSC_boss_onyxia()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/orgrimmar.cpp b/src/bindings/scripts/scripts/kalimdor/orgrimmar.cpp
index 9ace405eefc..30129b7e037 100644
--- a/src/bindings/scripts/scripts/kalimdor/orgrimmar.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/orgrimmar.cpp
@@ -13,33 +13,42 @@
  * along 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
+
 #define GOSSIP_HNF "You may speak frankly, Neeru..."
 #define GOSSIP_SNF "[PH] ..."
 bool GossipHello_npc_neeru_fireblade(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_5727) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HNF, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(4513, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_neeru_fireblade(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -55,21 +64,26 @@ bool GossipSelect_npc_neeru_fireblade(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 /*######
 ## npc_shenthul
 ######*/
+
 enum eShenthul
 {
     QUEST_SHATTERED_SALUTE  = 2460
 };
+
 struct TRINITY_DLL_DECL npc_shenthulAI : public ScriptedAI
 {
     npc_shenthulAI(Creature* c) : ScriptedAI(c) {}
+
     bool CanTalk;
     bool CanEmote;
     uint32 Salute_Timer;
     uint32 Reset_Timer;
     uint64 PlayerGUID;
+
     void Reset()
     {
         CanTalk = false;
@@ -78,7 +92,9 @@ struct TRINITY_DLL_DECL npc_shenthulAI : public ScriptedAI
         Reset_Timer = 0;
         PlayerGUID = 0;
     }
+
     void EnterCombat(Unit* who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (CanEmote)
@@ -93,6 +109,7 @@ struct TRINITY_DLL_DECL npc_shenthulAI : public ScriptedAI
                 Reset();
             } else Reset_Timer -= diff;
         }
+
         if (CanTalk && !CanEmote)
         {
             if (Salute_Timer < diff)
@@ -102,10 +119,13 @@ struct TRINITY_DLL_DECL npc_shenthulAI : public ScriptedAI
                 Reset_Timer = 60000;
             } else Salute_Timer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void ReceiveEmote(Player* pPlayer, uint32 emote)
     {
         if (emote == TEXTEMOTE_SALUTE && pPlayer->GetQuestStatus(QUEST_SHATTERED_SALUTE) == QUEST_STATUS_INCOMPLETE)
@@ -118,10 +138,12 @@ struct TRINITY_DLL_DECL npc_shenthulAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_shenthul(Creature* pCreature)
 {
     return new npc_shenthulAI (pCreature);
 }
+
 bool QuestAccept_npc_shenthul(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_SHATTERED_SALUTE)
@@ -131,12 +153,16 @@ bool QuestAccept_npc_shenthul(Player* pPlayer, Creature* pCreature, Quest const*
     }
     return true;
 }
+
 /*######
 ## npc_thrall_warchief
 ######*/
+
 #define QUEST_6566              6566
+
 #define SPELL_CHAIN_LIGHTNING   16033
 #define SPELL_SHOCK             16034
+
 #define GOSSIP_HTW "Please share your wisdom with me, Warchief."
 #define GOSSIP_STW1 "What discoveries?"
 #define GOSSIP_STW2 "Usurper?"
@@ -144,32 +170,40 @@ bool QuestAccept_npc_shenthul(Player* pPlayer, Creature* pCreature, Quest const*
 #define GOSSIP_STW4 "I... I did not think of it that way, Warchief."
 #define GOSSIP_STW5 "I live only to serve, Warchief! My life is empty and meaningless without your guidance."
 #define GOSSIP_STW6 "Of course, Warchief!"
+
 //TODO: verify abilities/timers
 struct TRINITY_DLL_DECL npc_thrall_warchiefAI : public ScriptedAI
 {
     npc_thrall_warchiefAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 ChainLightning_Timer;
     uint32 Shock_Timer;
+
     void Reset()
     {
         ChainLightning_Timer = 2000;
         Shock_Timer = 8000;
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -177,15 +211,19 @@ CreatureAI* GetAI_npc_thrall_warchief(Creature* pCreature)
 {
     return new npc_thrall_warchiefAI (pCreature);
 }
+
 bool GossipHello_npc_thrall_warchief(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_6566) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HTW, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_thrall_warchief(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -221,19 +259,23 @@ bool GossipSelect_npc_thrall_warchief(Player* pPlayer, Creature* pCreature, uint
     }
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_shenthul";
     newscript->GetAI = &GetAI_npc_shenthul;
     newscript->pQuestAccept =  &QuestAccept_npc_shenthul;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_thrall_warchief";
     newscript->GetAI = &GetAI_npc_thrall_warchief;
diff --git a/src/bindings/scripts/scripts/kalimdor/razorfen_downs/boss_amnennar_the_coldbringer.cpp b/src/bindings/scripts/scripts/kalimdor/razorfen_downs/boss_amnennar_the_coldbringer.cpp
index 435a38bf477..10f211666a1 100644
--- a/src/bindings/scripts/scripts/kalimdor/razorfen_downs/boss_amnennar_the_coldbringer.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/razorfen_downs/boss_amnennar_the_coldbringer.cpp
@@ -13,31 +13,38 @@
  * along with 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_AGGRO               -1129000
 #define SAY_SUMMON60            -1129001
 #define SAY_SUMMON30            -1129002
 #define SAY_HP                  -1129003
 #define SAY_KILL                -1129004
+
 #define SPELL_AMNENNARSWRATH    13009
 #define SPELL_FROSTBOLT         15530
 #define SPELL_FROST_NOVA        15531
 #define SPELL_FROST_SPECTRES    12642
+
 struct TRINITY_DLL_DECL boss_amnennar_the_coldbringerAI : public ScriptedAI
 {
     boss_amnennar_the_coldbringerAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 AmnenarsWrath_Timer;
     uint32 FrostBolt_Timer;
     uint32 FrostNova_Timer;
     bool Spectrals60;
     bool Spectrals30;
     bool Hp;
+
     void Reset()
     {
         AmnenarsWrath_Timer = 8000;
@@ -47,59 +54,71 @@ struct TRINITY_DLL_DECL boss_amnennar_the_coldbringerAI : public ScriptedAI
         Spectrals60 = false;
         Hp = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void KilledUnit()
     {
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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)
         {
             DoCast(m_creature->getVictim(),SPELL_FROSTBOLT);
             FrostBolt_Timer = 8000;
         } else FrostBolt_Timer -= diff;
+
         if (FrostNova_Timer < diff)
         {
             DoCast(m_creature,SPELL_FROST_NOVA);
             FrostNova_Timer = 15000;
         } else FrostNova_Timer -= diff;
+
         if (!Spectrals60 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 60)
         {
             DoScriptText(SAY_SUMMON60, m_creature);
             DoCast(m_creature->getVictim(),SPELL_FROST_SPECTRES);
             Spectrals60 = true;
         }
+
         if (!Hp && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50)
         {
             DoScriptText(SAY_HP, m_creature);
             Hp = true;
         }
+
         if (!Spectrals30 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30)
         {
             DoScriptText(SAY_SUMMON30, m_creature);
             DoCast(m_creature->getVictim(),SPELL_FROST_SPECTRES);
             Spectrals30 = true;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_amnennar_the_coldbringer(Creature* pCreature)
 {
     return new boss_amnennar_the_coldbringerAI (pCreature);
 }
+
 void AddSC_boss_amnennar_the_coldbringer()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/razorfen_downs/razorfen_downs.cpp b/src/bindings/scripts/scripts/kalimdor/razorfen_downs/razorfen_downs.cpp
index 4f580fa7efd..0d133a0db0b 100644
--- a/src/bindings/scripts/scripts/kalimdor/razorfen_downs/razorfen_downs.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/razorfen_downs/razorfen_downs.cpp
@@ -13,19 +13,24 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Razorfen_Downs
 SD%Complete: 100
 SDComment: Support for Henry Stern(2 recipes)
 SDCategory: Razorfen Downs
 EndScriptData */
+
 /* ContentData
 npc_henry_stern
 EndContentData */
+
 #include "precompiled.h"
+
 /*###
 # npc_henry_stern
 ####*/
+
 enum eEnums
 {
     SPELL_GOLDTHORN_TEA                         = 13028,
@@ -35,17 +40,22 @@ enum eEnums
     GOSSIP_TEXT_TEA_ANSWER                      = 2114,
     GOSSIP_TEXT_POTION_ANSWER                   = 2115,
 };
+
 #define GOSSIP_ITEM_TEA     "Teach me the cooking recipe"
 #define GOSSIP_ITEM_POTION  "Teach me the alchemy recipe"
+
 bool GossipHello_npc_henry_stern (Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetBaseSkillValue(SKILL_COOKING) >= 175 && !pPlayer->HasSpell(SPELL_GOLDTHORN_TEA))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TEA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
     if (pPlayer->GetBaseSkillValue(SKILL_ALCHEMY) >= 180 && !pPlayer->HasSpell(SPELL_MIGHT_TROLLS_BLOOD_POTION))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_POTION, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_henry_stern (Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -53,16 +63,20 @@ bool GossipSelect_npc_henry_stern (Player* pPlayer, Creature* pCreature, uint32
         pCreature->CastSpell(pPlayer, SPELL_TEACHING_GOLDTHORN_TEA, true);
         pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXT_TEA_ANSWER, pCreature->GetGUID());
     }
+
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 2)
     {
         pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXT_POTION_ANSWER, pCreature->GetGUID());
         pCreature->CastSpell(pPlayer, SPELL_TEACHING_MIGHTY_TROLLS_BLOOD_POTION, true);
     }
+
     return true;
 }
+
 void AddSC_razorfen_downs()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "npc_henry_stern";
     newscript->pGossipHello = &GossipHello_npc_henry_stern;
diff --git a/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/def_razorfen_kraul.h b/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/def_razorfen_kraul.h
index f9bc63e7c0a..d40abd7f2fd 100644
--- a/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/def_razorfen_kraul.h
+++ b/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/def_razorfen_kraul.h
@@ -13,7 +13,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef DEF_RAZORFEN_KRAUL_H
 #define DEF_RAZORFEN_KRAUL_H
+
 #define TYPE_WARD_KEEPERS       1
-#endif
+#endif
\ No newline at end of file
diff --git a/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/instance_razorfen_kraul.cpp b/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/instance_razorfen_kraul.cpp
index 2899d279f77..ed139ea45e9 100644
--- a/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/instance_razorfen_kraul.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/instance_razorfen_kraul.cpp
@@ -13,34 +13,42 @@
  * along 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_Razorfen_Kraul
 SD%Complete:
 SDComment:
 SDCategory: Razorfen Kraul
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_razorfen_kraul.h"
 
+
 #define WARD_KEEPERS_NR 2
+
 struct TRINITY_DLL_DECL instance_razorfen_kraul : public ScriptedInstance
 {
     instance_razorfen_kraul(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 DoorWardGUID;
     uint32 WardCheck_Timer;
     int WardKeeperAlive;
+
     void Initialize()
     {
         WardKeeperAlive = 1;
         WardCheck_Timer = 4000;
         DoorWardGUID = 0;
     }
+
     Player* GetPlayerInMap()
     {
         Map::PlayerList const& players = instance->GetPlayers();
+
         if (!players.isEmpty())
         {
-            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+            for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
             {
                 if (Player* plr = itr->getSource())
                     return plr;
@@ -49,6 +57,7 @@ struct TRINITY_DLL_DECL instance_razorfen_kraul : public ScriptedInstance
         debug_log("TSCR: Instance Razorfen Kraul: GetPlayerInMap, but PlayerList is empty!");
         return NULL;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool apply)
     {
         switch(pGo->GetEntry())
@@ -56,6 +65,7 @@ struct TRINITY_DLL_DECL instance_razorfen_kraul : public ScriptedInstance
         case 21099: DoorWardGUID = pGo->GetGUID(); break;
         }
     }
+
     void Update(uint32 diff)
     {
         if (WardCheck_Timer < diff)
@@ -66,6 +76,7 @@ struct TRINITY_DLL_DECL instance_razorfen_kraul : public ScriptedInstance
         }else
             WardCheck_Timer -= diff;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -76,11 +87,14 @@ struct TRINITY_DLL_DECL instance_razorfen_kraul : public ScriptedInstance
                 break;
         }
     }
+
 };
+
 InstanceData* GetInstanceData_instance_razorfen_kraul(Map* pMap)
 {
     return new instance_razorfen_kraul(pMap);
 }
+
 void AddSC_instance_razorfen_kraul()
 {
     Script *newscript;
@@ -88,4 +102,4 @@ void AddSC_instance_razorfen_kraul()
     newscript->Name = "instance_razorfen_kraul";
     newscript->GetInstanceData = &GetInstanceData_instance_razorfen_kraul;
     newscript->RegisterSelf();
-}
+}
\ No newline at end of file
diff --git a/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/razorfen_kraul.cpp b/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/razorfen_kraul.cpp
index 42de72fb63c..fec2cf711da 100644
--- a/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/razorfen_kraul.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/razorfen_kraul/razorfen_kraul.cpp
@@ -13,18 +13,22 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Razorfen Kraul
 SD%Complete: 100
 SDComment: Quest support: 1144
 SDCategory: Razorfen Kraul
 EndScriptData */
+
 /* ContentData
 npc_willix
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "def_razorfen_kraul.h"
+
 #define SAY_READY -1047000
 #define SAY_POINT -10470001
 #define SAY_AGGRO1 -1047002
@@ -36,17 +40,22 @@ EndContentData */
 #define SAY_FINALY -1047008
 #define SAY_WIN -1047009
 #define SAY_END -1047010
+
 #define QUEST_WILLIX_THE_IMPORTER 1144
 #define ENTRY_BOAR 4514
 #define SPELL_QUILLBOAR_CHANNELING 7083
+
 struct TRINITY_DLL_DECL npc_willixAI : public npc_escortAI
 {
     npc_willixAI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch (i)
         {
         case 3:
@@ -90,21 +99,26 @@ struct TRINITY_DLL_DECL npc_willixAI : public npc_escortAI
             break;
         }
     }
+
     void Reset() {}
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO1, m_creature, NULL);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
+
     void JustDied(Unit* killer)
     {
         if (Player* pPlayer = GetPlayerForEscort())
             CAST_PLR(pPlayer)->FailQuest(QUEST_WILLIX_THE_IMPORTER);
     }
 };
+
 bool QuestAccept_npc_willix(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_WILLIX_THE_IMPORTER)
@@ -113,26 +127,33 @@ bool QuestAccept_npc_willix(Player* pPlayer, Creature* pCreature, Quest const* q
         DoScriptText(SAY_READY, pCreature, pPlayer);
         pCreature->setFaction(113);
     }
+
     return true;
 }
+
 struct TRINITY_DLL_DECL npc_deaths_head_ward_keeperAI : public ScriptedAI
 {
     npc_deaths_head_ward_keeperAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
     uint32 QuillboarChanneling_Timer;
+
     void Reset()
     {
         QuillboarChanneling_Timer = 1500;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->isAlive())
             return;
+
         if (pInstance)
             pInstance->SetData(TYPE_WARD_KEEPERS, NOT_STARTED);
+
         if (QuillboarChanneling_Timer < diff)
         {
             if (m_creature->IsNonMeleeSpellCasted(false))
@@ -140,24 +161,30 @@ struct TRINITY_DLL_DECL npc_deaths_head_ward_keeperAI : public ScriptedAI
             DoCast(m_creature, SPELL_QUILLBOAR_CHANNELING);
             QuillboarChanneling_Timer = 1100;
         }else QuillboarChanneling_Timer -= diff;
+
     }
 };
+
 CreatureAI* GetAI_npc_deaths_head_ward_keeper(Creature* pCreature)
 {
     return new npc_deaths_head_ward_keeperAI(pCreature);
 }
+
 CreatureAI* GetAI_npc_willix(Creature* pCreature)
 {
     return new npc_willixAI(pCreature);
 }
+
 void AddSC_razorfen_kraul()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_willix";
     newscript->GetAI = &GetAI_npc_willix;
     newscript->pQuestAccept = &QuestAccept_npc_willix;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_deaths_head_ward_keeper";
     newscript->GetAI = &GetAI_npc_deaths_head_ward_keeper;
diff --git a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_ayamiss.cpp b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_ayamiss.cpp
index d6bb995dbd6..84e34924958 100644
--- a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_ayamiss.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_ayamiss.cpp
@@ -13,29 +13,36 @@
  * along with 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 TRINITY_DLL_DECL boss_ayamissAI : public ScriptedAI
 {
     boss_ayamissAI(Creature *c) : ScriptedAI(c) {}
+
     Unit *pTarget;
     uint32 STINGERSPRAY_Timer;
     uint32 POISONSTINGER_Timer;
     uint32 SUMMONSWARMER_Timer;
     uint32 phase;
+
     void Reset()
     {
         pTarget = NULL;
@@ -44,37 +51,44 @@ struct TRINITY_DLL_DECL boss_ayamissAI : public ScriptedAI
         SUMMONSWARMER_Timer = 60000;
         phase=1;
     }
+
     void EnterCombat(Unit *who)
     {
         pTarget = who;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -82,6 +96,7 @@ CreatureAI* GetAI_boss_ayamiss(Creature* pCreature)
 {
     return new boss_ayamissAI (pCreature);
 }
+
 void AddSC_boss_ayamiss()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_buru.cpp b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_buru.cpp
index 80dd3bff06f..58c48540362 100644
--- a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_buru.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_buru.cpp
@@ -13,12 +13,15 @@
  * along with 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"
+
  #define EMOTE_TARGET        -1509002
 
diff --git a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_kurinnaxx.cpp b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_kurinnaxx.cpp
index 03222740da2..5096b60ccdf 100644
--- a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_kurinnaxx.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_kurinnaxx.cpp
@@ -13,23 +13,29 @@
  * along with 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 TRINITY_DLL_DECL boss_kurinnaxxAI : public ScriptedAI
 {
     boss_kurinnaxxAI(Creature *c) : ScriptedAI(c) {}
+
     Unit *pTarget;
     uint32 MORTALWOUND_Timer;
     uint32 SANDTRAP_Timer;
     uint32 i;
+
     void Reset()
     {
         i=0;
@@ -37,32 +43,38 @@ struct TRINITY_DLL_DECL boss_kurinnaxxAI : public ScriptedAI
         MORTALWOUND_Timer = 30000;
         SANDTRAP_Timer = 30000;
     }
+
     void EnterCombat(Unit *who)
     {
         pTarget = who;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
 };
@@ -70,6 +82,7 @@ CreatureAI* GetAI_boss_kurinnaxx(Creature* pCreature)
 {
     return new boss_kurinnaxxAI (pCreature);
 }
+
 void AddSC_boss_kurinnaxx()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_moam.cpp b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_moam.cpp
index 7be14a98f3c..1e5ca42d044 100644
--- a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_moam.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_moam.cpp
@@ -13,29 +13,36 @@
  * along with 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 EMOTE_AGGRO             -1509000
 #define EMOTE_MANA_FULL         -1509001
+
 #define SPELL_TRAMPLE           15550
 #define SPELL_DRAINMANA         27256
 #define SPELL_ARCANEERUPTION    25672
 #define SPELL_SUMMONMANA        25681
 #define SPELL_GRDRSLEEP         24360                       //Greater Dreamless Sleep
+
 struct TRINITY_DLL_DECL boss_moamAI : public ScriptedAI
 {
     boss_moamAI(Creature *c) : ScriptedAI(c) {}
+
     Unit *pTarget;
     uint32 TRAMPLE_Timer;
     uint32 DRAINMANA_Timer;
     uint32 SUMMONMANA_Timer;
     uint32 i;
     uint32 j;
+
     void Reset()
     {
         i=0;
@@ -44,21 +51,25 @@ struct TRINITY_DLL_DECL boss_moamAI : public ScriptedAI
         TRAMPLE_Timer = 30000;
         DRAINMANA_Timer = 30000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(EMOTE_AGGRO, m_creature);
         pTarget = who;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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);
             DoScriptText(EMOTE_MANA_FULL, m_creature);
         }
+
         //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))
         {
@@ -66,25 +77,30 @@ struct TRINITY_DLL_DECL boss_moamAI : public ScriptedAI
             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();
     }
 };
@@ -92,6 +108,7 @@ CreatureAI* GetAI_boss_moam(Creature* pCreature)
 {
     return new boss_moamAI (pCreature);
 }
+
 void AddSC_boss_moam()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_ossirian.cpp b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_ossirian.cpp
index cd5e65a29bd..5652b706917 100644
--- a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_ossirian.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_ossirian.cpp
@@ -13,20 +13,26 @@
  * along with 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"
+
 #define SAY_SURPREME2   -1509019
 #define SAY_SURPREME3   -1509020
+
 #define SAY_RAND_INTRO1 -1509021
 #define SAY_RAND_INTRO2 -1509022
 #define SAY_RAND_INTRO3 -1509023
 #define SAY_RAND_INTRO4 -1509024                            //possibly old?
+
 #define SAY_AGGRO       -1509025
+
 #define SAY_SLAY        -1509026
 #define SAY_DEATH       -1509027
 
diff --git a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_rajaxx.cpp b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_rajaxx.cpp
index 6587e92e342..fb2c92ff59f 100644
--- a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_rajaxx.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/boss_rajaxx.cpp
@@ -13,26 +13,33 @@
  * along with 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"
+
 #define SAY_ANDOROV_INTRO   -1509003
 #define SAY_ANDOROV_ATTACK  -1509004
+
 #define SAY_WAVE3           -1509005
 #define SAY_WAVE4           -1509006
 #define SAY_WAVE5           -1509007
 #define SAY_WAVE6           -1509008
 #define SAY_WAVE7           -1509009
 #define SAY_INTRO           -1509010
+
 #define SAY_UNK1            -1509011
 #define SAY_UNK2            -1509012
 #define SAY_UNK3            -1509013
 #define SAY_UNK4            -1509014
+
 #define SAY_DEAGGRO         -1509015
 #define SAY_KILLS_ANDOROV   -1509016
+
 #define SAY_COMPLETE_QUEST  -1509017                        //Yell when realm complete quest 8743 for world event
 
diff --git a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp
index 3c42cb587c8..b94e6f16a80 100644
--- a/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp
@@ -13,11 +13,13 @@
  * along 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/kalimdor/silithus.cpp b/src/bindings/scripts/scripts/kalimdor/silithus.cpp
index c9d2ae36aec..45313fbbc73 100644
--- a/src/bindings/scripts/scripts/kalimdor/silithus.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/silithus.cpp
@@ -13,21 +13,26 @@
  * along 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: 7785, 8304, 8507.
 SDCategory: Silithus
 EndScriptData */
+
 /* ContentData
 npc_highlord_demitrian
 npcs_rutgar_and_frankal
 quest_a_pawn_on_the_eternal_pawn
 EndContentData */
+
 #include "precompiled.h"
+
 /*###
 ## npc_highlord_demitrian
 ###*/
+
 #define GOSSIP_DEMITRIAN1 "What do you know of it?"
 #define GOSSIP_DEMITRIAN2 "I am listening , Demitrian."
 #define GOSSIP_DEMITRIAN3 "Continue, please."
@@ -35,16 +40,20 @@ EndContentData */
 #define GOSSIP_DEMITRIAN5 ""
 #define GOSSIP_DEMITRIAN6 "Caught unaware? How?"
 #define GOSSIP_DEMITRIAN7 "So what did Ragnaros do next?"
+
 bool GossipHello_npc_highlord_demitrian(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(7785) == QUEST_STATUS_NONE &&
         (pPlayer->HasItemCount(18563,1,false) || pPlayer->HasItemCount(18564,1,false)))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DEMITRIAN1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(6812, pCreature->GetGUID());
         return true;
 }
+
 bool GossipSelect_npc_highlord_demitrian(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -75,6 +84,7 @@ bool GossipSelect_npc_highlord_demitrian(Player* pPlayer, Creature* pCreature, u
         break;
     case GOSSIP_ACTION_INFO_DEF+6:
         pPlayer->SEND_GOSSIP_MENU(6870, pCreature->GetGUID());
+
         ItemPosCountVec dest;
         uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 19016, 1);
         if (msg == EQUIP_ERR_OK)
@@ -83,40 +93,51 @@ bool GossipSelect_npc_highlord_demitrian(Player* pPlayer, Creature* pCreature, u
     }
     return true;
 }
+
 /*###
 ## 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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE &&
         pCreature->GetEntry() == 15170 &&
         !pPlayer->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     if (pPlayer->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE &&
         pCreature->GetEntry() == 15171 &&
         pPlayer->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9);
+
     pPlayer->SEND_GOSSIP_MENU(7754, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npcs_rutgar_and_frankal(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -150,6 +171,7 @@ bool GossipSelect_npcs_rutgar_and_frankal(Player* pPlayer, Creature* pCreature,
                                                             //'kill' our trigger to update quest status
             pPlayer->KilledMonsterCredit(TRIGGER_RUTGAR, pCreature->GetGUID());
             break;
+
         case GOSSIP_ACTION_INFO_DEF + 9:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM11, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11);
             pPlayer->SEND_GOSSIP_MENU(7762, pCreature->GetGUID());
@@ -178,19 +200,23 @@ bool GossipSelect_npcs_rutgar_and_frankal(Player* pPlayer, Creature* pCreature,
     }
     return true;
 }
+
 /*####
 # quest_a_pawn_on_the_eternal_board (Defines)
 ####*/
 enum eEternalBoard
 {
     QUEST_A_PAWN_ON_THE_ETERNAL_BOARD = 8519,
+
     FACTION_HOSTILE = 14,
     FACTION_FRIENDLY = 35,
+
     C_ANACHRONOS = 15381,
     C_FANDRAL_STAGHELM = 15382,
     C_ARYGOS = 15380,
     C_MERITHRA = 15378,
     C_CAELESTRASZ = 15379,
+
     ANACHRONOS_SAY_1 = -1350000,
     ANACHRONOS_SAY_2 = -1350001,
     ANACHRONOS_SAY_3 = -1350002,
@@ -204,6 +230,7 @@ enum eEternalBoard
     ANACHRONOS_EMOTE_1 = -1350010,
     ANACHRONOS_EMOTE_2 = -1350011,
     ANACHRONOS_EMOTE_3 = -1350012,
+
     FANDRAL_SAY_1 = -1350013,
     FANDRAL_SAY_2 = -1350014,
     FANDRAL_SAY_3 = -1350015,
@@ -212,16 +239,20 @@ enum eEternalBoard
     FANDRAL_SAY_6 = -1350018,
     FANDRAL_EMOTE_1 = -1350019,
     FANDRAL_EMOTE_2 = -1350020,
+
     CAELESTRASZ_SAY_1 = -1350021,
     CAELESTRASZ_SAY_2 = -1350022,
     CAELESTRASZ_YELL_1 = -1350023,
+
     ARYGOS_SAY_1 = -1350024,
     ARYGOS_YELL_1 = -1350025,
     ARYGOS_EMOTE_1 = -1350026,
+
     MERITHRA_SAY_1 = -1350027,
     MERITHRA_SAY_2 = -1350028,
     MERITHRA_YELL_1 = -1350029,
     MERITHRA_EMOTE_1 = -1350030,
+
     GO_GATE_OF_AHN_QIRAJ = 176146,
     GO_GLYPH_OF_AHN_QIRAJ = 176148,
     GO_ROOTS_OF_AHN_QIRAJ = 176147
@@ -229,6 +260,7 @@ enum eEternalBoard
 /*#####
 # Quest: A Pawn on the Eternal Board
 #####*/
+
 /* ContentData
 A Pawn on the Eternal Board - creatures, gameobjects and defines
 mob_qiraj_war_spawn : Adds that are summoned in the Qiraj gates battle.
@@ -238,14 +270,17 @@ go_crystalline_tear : GameObject that begins the event and hands out quest
 TO DO: get correct spell IDs and timings for spells cast upon dragon transformations
 TO DO: Dragons should use the HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF) after transformation,but for some unknown reason it doesnt work.
 EndContentData */
+
 #define QUEST_A_PAWN_ON_THE_ETERNAL_BOARD 8519
 #define EVENT_AREA_RADIUS 65 //65yds
 #define EVENT_COOLDOWN 500000 //in ms. appear after event completed or failed (should be = Adds despawn time)
+
 struct QuestCinematic
 {
     int32 TextId;
     uint32 Creature, Timer;
 };
+
 // Creature 0 - Anachronos, 1 - Fandral, 2 - Arygos, 3 - Merithra, 4 - Caelestrasz
 static QuestCinematic EventAnim[]=
 {
@@ -318,10 +353,12 @@ static QuestCinematic EventAnim[]=
     {NULL, 0, 5000},
     {NULL, 0, NULL}
 };
+
 struct Location
 {
     float x, y, z, o;
 };
+
 //Cordinates for Spawns
 static Location SpawnLocation[]=
 {
@@ -330,11 +367,13 @@ static Location SpawnLocation[]=
     {-8085, 1524, 2.61, 3.141592},//Kaldorei Infantry
     {-8080, 1522, 2.61, 3.141592},//Kaldorei Infantry
     {-8085, 1520, 2.61, 3.141592},//Kaldorei Infantry
+
     {-8085, 1524, 2.61, 3.141592},//Kaldorei Infantry
     {-8080, 1522, 2.61, 3.141592},//Kaldorei Infantry
     {-8085, 1520, 2.61, 3.141592},//Kaldorei Infantry
     {-8080, 1518, 2.61, 3.141592},//Kaldorei Infantry
     {-8085, 1516, 2.61, 3.141592},//Kaldorei Infantry
+
     {-8085, 1518, 2.61, 3.141592},//Kaldorei Infantry
     {-8080, 1516, 2.61, 3.141592},//Kaldorei Infantry
     {-8080, 1520, 2.61, 3.141592},//Kaldorei Infantry
@@ -346,52 +385,62 @@ static Location SpawnLocation[]=
     {-8082, 1524, 2.61, 3.141592},//Kaldorei Infantry
     {-8078, 1526, 2.61, 3.141592},//Kaldorei Infantry
     {-8082, 1527, 2.61, 3.141592},//Kaldorei Infantry
+
     {-8082, 1524, 2.61, 3.141592},//Kaldorei Infantry
     {-8078, 1522, 2.61, 3.141592},//Kaldorei Infantry
     {-8082, 1520, 2.61, 3.141592},//Kaldorei Infantry
     {-8078, 1518, 2.61, 3.141592},//Kaldorei Infantry
     {-8082, 1516, 2.61, 3.141592},//Kaldorei Infantry
+
     {-8082, 1523, 2.61, 3.141592},//Kaldorei Infantry
     {-8078, 1521, 2.61, 3.141592},//Kaldorei Infantry
     {-8082, 1528, 2.61, 3.141592},//Kaldorei Infantry
     {-8078, 1519, 2.61, 3.141592},//Kaldorei Infantry
     {-8082, 1526, 2.61, 3.141592},//Kaldorei Infantry
+
     {-8082, 1524, 2.61, 3.141592},//Kaldorei Infantry
     {-8078, 1522, 2.61, 3.141592},//Kaldorei Infantry
     {-8082, 1520, 2.61, 3.141592},//Kaldorei Infantry
     {-8078, 1518, 2.61, 3.141592},//Kaldorei Infantry
     {-8082, 1516, 2.61, 3.141592},//Kaldorei Infantry
+
     {-8088, 1510, 2.61, 0},//Anubisath Conqueror
     {-8084, 1520, 2.61, 0},//Anubisath Conqueror
     {-8088, 1530, 2.61, 0},//Anubisath Conqueror
+
     {-8080, 1513, 2.61, 0},//Qiraj Wasp
     {-8082, 1523, 2.61, 0},//Qiraj Wasp
     {-8085, 1518, 2.61, 0},//Qiraj Wasp
     {-8082, 1516, 2.61, 0},//Qiraj Wasp
     {-8085, 1520, 2.61, 0},//Qiraj Wasp
     {-8080, 1528, 2.61, 0},//Qiraj Wasp
+
     {-8082, 1513, 2.61, 0},//Qiraj Wasp
     {-8079, 1523, 2.61, 0},//Qiraj Wasp
     {-8080, 1531, 2.61, 0},//Qiraj Wasp
     {-8079, 1516, 2.61, 0},//Qiraj Wasp
     {-8082, 1520, 2.61, 0},//Qiraj Wasp
     {-8080, 1518, 2.61, 0},//Qiraj Wasp
+
     {-8081, 1514, 2.61, 0},//Qiraj Tank
     {-8081, 1520, 2.61, 0},//Qiraj Tank
     {-8081, 1526, 2.61, 0},//Qiraj Tank
     {-8081, 1512, 2.61, 0},//Qiraj Tank
     {-8082, 1520, 2.61, 0},//Qiraj Tank
     {-8081, 1528, 2.61, 0},//Qiraj Tank
+
     {-8082, 1513, 2.61, 3.141592},//Anubisath Conqueror
     {-8082, 1520, 2.61, 3.141592},//Anubisath Conqueror
     {-8082, 1527, 2.61, 3.141592},//Anubisath Conqueror
 };
+
 struct WaveData
 {
     uint8 SpawnCount, UsedSpawnPoint;
     uint32 CreatureId, SpawnTimer, YellTimer, DespTimer;
     int32 WaveTextId;
 };
+
 static WaveData WavesInfo[] =
 {
     {30, 0, 15423, 0, 0,24000, NULL},   //Kaldorei Soldier
@@ -399,11 +448,14 @@ static WaveData WavesInfo[] =
     {12, 38, 15414, 0, 0,24000, NULL},  //Qiraji Wasps
     {6, 50, 15422, 0, 0,24000, NULL},   //Qiraji Tanks
     {15, 15, 15423, 0, 0,24000, NULL}   //Kaldorei Soldier
+
 };
+
 struct SpawnSpells
 {
     uint32 Timer1, Timer2, SpellId;
 };
+
 static SpawnSpells SpawnCast[]=//
 {
     {100000, 2000, 33652},   // Stop Time
@@ -417,8 +469,10 @@ static SpawnSpells SpawnCast[]=//
 struct TRINITY_DLL_DECL npc_anachronos_the_ancientAI : public ScriptedAI
 {
     npc_anachronos_the_ancientAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 AnimationTimer;
     uint8 AnimationCount;
+
     uint64 AnachronosQuestTriggerGUID;
     uint64 MerithraGUID;
     uint64 ArygosGUID;
@@ -426,6 +480,7 @@ struct TRINITY_DLL_DECL npc_anachronos_the_ancientAI : public ScriptedAI
     uint64 FandralGUID;
     uint64 PlayerGUID;
     bool eventEnd;
+
     void Reset()
     {
         AnimationTimer = 1500;
@@ -437,19 +492,24 @@ struct TRINITY_DLL_DECL npc_anachronos_the_ancientAI : public ScriptedAI
         FandralGUID = 0;
         PlayerGUID = 0;
         eventEnd = false;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
     }
+
     void HandleAnimation()
     {
         Player* plr = Unit::GetPlayer(PlayerGUID);
         if(!plr)
             return;
+
         Unit* Fandral = plr->FindNearestCreature(C_FANDRAL_STAGHELM, 100, m_creature);
         Unit* Arygos = plr->FindNearestCreature(C_ARYGOS, 100,m_creature);
         Unit* Caelestrasz = plr->FindNearestCreature(C_CAELESTRASZ, 100, m_creature);
         Unit* Merithra = plr->FindNearestCreature(C_MERITHRA, 100,m_creature);
+
         if(!Fandral || !Arygos || !Caelestrasz || !Merithra)
             return;
+
         Unit* mob;
         AnimationTimer = EventAnim[AnimationCount].Timer;
         if (eventEnd == false)
@@ -710,12 +770,15 @@ struct TRINITY_DLL_DECL npc_anachronos_the_ancientAI : public ScriptedAI
             m_creature->AI()->EnterEvadeMode();
     }
 };
+
 /*######
 # mob_qiraj_war_spawn
 ######*/
+
 struct TRINITY_DLL_DECL mob_qiraj_war_spawnAI : public ScriptedAI
 {
     mob_qiraj_war_spawnAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 MobGUID;
     uint64 PlayerGUID;
     uint32 SpellTimer1, SpellTimer2, SpellTimer3,SpellTimer4;
@@ -729,12 +792,15 @@ struct TRINITY_DLL_DECL mob_qiraj_war_spawnAI : public ScriptedAI
         Timers = false;
         hasTarget = false;
     }
+
     void EnterCombat(Unit* who) {}
     void JustDied(Unit* slayer);
+
     void UpdateAI(const uint32 diff)
     {
         Unit* target;
         Player* plr = m_creature->GetPlayer(PlayerGUID);
+
         if(!Timers)
         {
             if(m_creature->GetEntry() == 15424 || m_creature->GetEntry() == 15422 || m_creature->GetEntry() == 15414) //all but Kaldorei Soldiers
@@ -784,6 +850,7 @@ struct TRINITY_DLL_DECL mob_qiraj_war_spawnAI : public ScriptedAI
             {
                 uint8 tar;
                 tar = rand()%3;
+
                 if (tar == 0)
                     target = m_creature->FindNearestCreature(15422,20,true);
                 else if (tar == 1)
@@ -797,40 +864,53 @@ struct TRINITY_DLL_DECL mob_qiraj_war_spawnAI : public ScriptedAI
         }
         if (!(trigger = m_creature->FindNearestCreature(15379,100)))
             DoCast(m_creature, 33652);
+
         if (!UpdateVictim())
         {
             hasTarget = false;
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 /*#####
 # npc_anachronos_quest_trigger
 #####*/
+
 struct TRINITY_DLL_DECL npc_anachronos_quest_triggerAI : public ScriptedAI
 {
     npc_anachronos_quest_triggerAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 PlayerGUID;
+
     uint32 WaveTimer;
     uint32 AnnounceTimer;
+
     int8 LiveCount;
     uint8 WaveCount;
+
     bool EventStarted;
     bool Announced;
     bool Failed;
+
     void Reset()
     {
         PlayerGUID = 0;
+
         WaveTimer = 2000;
         AnnounceTimer = 1000;
         LiveCount = 0;
         WaveCount = 0;
+
         EventStarted = false;
         Announced = false;
         Failed = false;
+
         m_creature->SetVisibility(VISIBILITY_OFF);
     }
+
     void SummonNextWave()
     {
         uint8 count = WavesInfo[WaveCount].SpawnCount;
@@ -839,7 +919,7 @@ struct TRINITY_DLL_DECL npc_anachronos_quest_triggerAI : public ScriptedAI
         uint8 KaldoreiSoldierCount = 0;
         uint8 AnubisathConquerorCount = 0;
         uint8 QirajiWaspCount = 0;
-        for (uint8 i = 0; i < 67; ++i)
+        for(uint8 i = 0; i < 67; ++i)
         {
             Creature* Spawn = NULL;
             float X = SpawnLocation[locIndex + i].x;
@@ -848,6 +928,7 @@ struct TRINITY_DLL_DECL npc_anachronos_quest_triggerAI : public ScriptedAI
             float O = SpawnLocation[locIndex + i].o;
             uint32 desptimer = WavesInfo[WaveCount].DespTimer;
             Spawn = m_creature->SummonCreature(WavesInfo[WaveCount].CreatureId, X, Y, Z, O, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, desptimer);
+
             if(Spawn)
             {
                 Spawn->LoadCreaturesAddon();
@@ -857,6 +938,7 @@ struct TRINITY_DLL_DECL npc_anachronos_quest_triggerAI : public ScriptedAI
                 if (i >= 33) WaveCount = 2;
                 if (i >= 45) WaveCount = 3;
                 if (i >= 51) WaveCount = 4;
+
                 if(WaveCount < 5) //1-4 Wave
                 {
                     ((mob_qiraj_war_spawnAI*)Spawn->AI())->MobGUID = m_creature->GetGUID();
@@ -867,19 +949,25 @@ struct TRINITY_DLL_DECL npc_anachronos_quest_triggerAI : public ScriptedAI
         WaveTimer = WavesInfo[WaveCount].SpawnTimer;
         AnnounceTimer = WavesInfo[WaveCount].YellTimer;
     }
+
     void CheckEventFail()
     {
         Player* pPlayer = Unit::GetPlayer(PlayerGUID);
+
         if(!pPlayer)
             return;
+
         if(Group *EventGroup = pPlayer->GetGroup())
         {
             Player* GroupMember;
+
             uint8 GroupMemberCount = 0;
             uint8 DeadMemberCount = 0;
             uint8 FailedMemberCount = 0;
+
             const Group::MemberSlotList members = EventGroup->GetMemberSlots();
-            for (Group::member_citerator itr = members.begin(); itr!= members.end(); itr++)
+
+            for(Group::member_citerator itr = members.begin(); itr!= members.end(); itr++)
             {
                 GroupMember = (Unit::GetPlayer(itr->guid));
                 if(!GroupMember)
@@ -891,23 +979,28 @@ struct TRINITY_DLL_DECL npc_anachronos_quest_triggerAI : public ScriptedAI
                     ++FailedMemberCount;
                 }
                 ++GroupMemberCount;
+
                 if(GroupMember->isDead())
                     ++DeadMemberCount;
             }
+
             if(GroupMemberCount == FailedMemberCount || !pPlayer->IsWithinDistInMap(m_creature, EVENT_AREA_RADIUS))
                 Failed = true; //only so event can restart
         }
     }
+
     void LiveCounter()
     {
         --LiveCount;
         if(!LiveCount)
             Announced = false;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(!PlayerGUID || !EventStarted)
             return;
+
         if(WaveCount < 4)
         {
             if(!Announced && AnnounceTimer < diff)
@@ -915,6 +1008,7 @@ struct TRINITY_DLL_DECL npc_anachronos_quest_triggerAI : public ScriptedAI
                 DoScriptText(WavesInfo[WaveCount].WaveTextId, m_creature);
                 Announced = true;
             } else AnnounceTimer -= diff;
+
             if(WaveTimer < diff)
                 SummonNextWave();
             else WaveTimer -= diff;
@@ -922,28 +1016,33 @@ struct TRINITY_DLL_DECL npc_anachronos_quest_triggerAI : public ScriptedAI
         CheckEventFail();
         if (WaveCount == 4 || Failed)
             EnterEvadeMode();
-    };
+	};
 };
 void mob_qiraj_war_spawnAI::JustDied(Unit* slayer)
 {
     m_creature->RemoveCorpse();
     if(Creature* Mob = (Unit::GetCreature(*m_creature, MobGUID)))
         ((npc_anachronos_quest_triggerAI*)Mob->AI())->LiveCounter();
+
 };
 /*#####
 # go_crystalline_tear
 ######*/
+
 bool GOQuestAccept_GO_crystalline_tear(Player* plr, GameObject* go, Quest const* quest)
 {
     if(quest->GetQuestId() == QUEST_A_PAWN_ON_THE_ETERNAL_BOARD)
     {
+
         if(Unit* Anachronos_Quest_Trigger = go->FindNearestCreature(15454, 100, plr))
         {
+
             Unit *Merithra = Anachronos_Quest_Trigger->SummonCreature(15378,-8034.535,1535.14,2.61,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,150000);
             Unit *Caelestrasz = Anachronos_Quest_Trigger->SummonCreature(15379,-8032.767, 1533.148,2.61, 1.5,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,150000);
             Unit *Arygos = Anachronos_Quest_Trigger->SummonCreature(15380,-8034.52, 1537.843, 2.61, 5.7,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,150000);
             Unit *Fandral = Anachronos_Quest_Trigger->SummonCreature(15382,-8028.462, 1535.843, 2.61, 3.141592,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,215000);
             Creature *Anachronos = Anachronos_Quest_Trigger->SummonCreature(15381,-8028.75, 1538.795, 2.61, 4,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,220000);
+
             if(Merithra)
             {
                 Merithra->SetUInt32Value(UNIT_NPC_FLAGS, 0);
@@ -951,6 +1050,7 @@ bool GOQuestAccept_GO_crystalline_tear(Player* plr, GameObject* go, Quest const*
                 Merithra->SetUInt32Value(UNIT_FIELD_DISPLAYID,15420);
                 Merithra->setFaction(35);
             }
+
             if(Caelestrasz)
             {
                 Caelestrasz->SetUInt32Value(UNIT_NPC_FLAGS, 0);
@@ -958,6 +1058,7 @@ bool GOQuestAccept_GO_crystalline_tear(Player* plr, GameObject* go, Quest const*
                 Caelestrasz->SetUInt32Value(UNIT_FIELD_DISPLAYID,15419);
                 Caelestrasz->setFaction(35);
             }
+
             if(Arygos)
             {
                 Arygos->SetUInt32Value(UNIT_NPC_FLAGS, 0);
@@ -965,6 +1066,7 @@ bool GOQuestAccept_GO_crystalline_tear(Player* plr, GameObject* go, Quest const*
                 Arygos->SetUInt32Value(UNIT_FIELD_DISPLAYID,15418);
                 Arygos->setFaction(35);
             }
+
             if(Anachronos)
             {
                 ((npc_anachronos_the_ancientAI*)Anachronos->AI())->PlayerGUID = plr->GetGUID();
@@ -977,42 +1079,52 @@ bool GOQuestAccept_GO_crystalline_tear(Player* plr, GameObject* go, Quest const*
     }
  return true;
 }
+
 CreatureAI* GetAI_npc_anachronos_quest_trigger(Creature* c)
 {
     return new npc_anachronos_quest_triggerAI(c);
 }
+
 CreatureAI* GetAI_mob_qiraj_war_spawn(Creature* c)
 {
     return new mob_qiraj_war_spawnAI(c);
 }
+
 CreatureAI* GetAI_npc_anachronos_the_ancient(Creature* c)
 {
     return new npc_anachronos_the_ancientAI(c);
 }
+
 void AddSC_silithus()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "go_crystalline_tear";
     newscript->pGOQuestAccept = &GOQuestAccept_GO_crystalline_tear;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_anachronos_quest_trigger";
     newscript->GetAI = &GetAI_npc_anachronos_quest_trigger;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_anachronos_the_ancient";
     newscript->GetAI = &GetAI_npc_anachronos_the_ancient;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_qiraj_war_spawn";
     newscript->GetAI = &GetAI_mob_qiraj_war_spawn;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_highlord_demitrian";
     newscript->pGossipHello =  &GossipHello_npc_highlord_demitrian;
     newscript->pGossipSelect = &GossipSelect_npc_highlord_demitrian;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npcs_rutgar_and_frankal";
     newscript->pGossipHello =   &GossipHello_npcs_rutgar_and_frankal;
diff --git a/src/bindings/scripts/scripts/kalimdor/stonetalon_mountains.cpp b/src/bindings/scripts/scripts/kalimdor/stonetalon_mountains.cpp
index 3c93aeb32b9..2e1ebc683fd 100644
--- a/src/bindings/scripts/scripts/kalimdor/stonetalon_mountains.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/stonetalon_mountains.cpp
@@ -13,30 +13,37 @@
  * along 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, 6523
 SDCategory: Stonetalon Mountains
 EndScriptData */
+
 /* ContentData
 npc_braug_dimspirit
 npc_kaya_flathoof
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_braug_dimspirit
 ######*/
+
 #define GOSSIP_HBD1 "Ysera"
 #define GOSSIP_HBD2 "Neltharion"
 #define GOSSIP_HBD3 "Nozdormu"
 #define GOSSIP_HBD4 "Alexstrasza"
 #define GOSSIP_HBD5 "Malygos"
+
 bool GossipHello_npc_braug_dimspirit(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(6627) == QUEST_STATUS_INCOMPLETE)
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HBD1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
@@ -44,18 +51,22 @@ bool GossipHello_npc_braug_dimspirit(Player* pPlayer, Creature* pCreature)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HBD3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HBD4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HBD5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
         pPlayer->SEND_GOSSIP_MENU(5820, pCreature->GetGUID());
     }
     else
         pPlayer->SEND_GOSSIP_MENU(5819, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_braug_dimspirit(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
     {
         pPlayer->CLOSE_GOSSIP_MENU();
         pCreature->CastSpell(pPlayer,6766,false);
+
     }
     if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
     {
@@ -64,28 +75,37 @@ bool GossipSelect_npc_braug_dimspirit(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 /*######
 ## npc_kaya_flathoof
 ######*/
+
 enum eKaya
 {
     FACTION_ESCORTEE_H          = 775,
+
     NPC_GRIMTOTEM_RUFFIAN       = 11910,
     NPC_GRIMTOTEM_BRUTE         = 11912,
     NPC_GRIMTOTEM_SORCERER      = 11913,
+
     SAY_START                   = -1000347,
     SAY_AMBUSH                  = -1000348,
     SAY_END                     = -1000349,
+
     QUEST_PROTECT_KAYA          = 6523
 };
+
 struct TRINITY_DLL_DECL npc_kaya_flathoofAI : public npc_escortAI
 {
     npc_kaya_flathoofAI(Creature* c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
         case 16:
@@ -101,39 +121,48 @@ struct TRINITY_DLL_DECL npc_kaya_flathoofAI : public npc_escortAI
             break;
         }
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
+
     void Reset(){}
 };
+
 bool QuestAccept_npc_kaya_flathoof(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_PROTECT_KAYA)
     {
         if (npc_escortAI* pEscortAI = CAST_AI(npc_kaya_flathoofAI, pCreature->AI()))
             pEscortAI->Start(true, false, pPlayer->GetGUID());
+
         DoScriptText(SAY_START, pCreature);
         pCreature->setFaction(113);
         pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_kaya_flathoofAI(Creature* pCreature)
 {
     return new npc_kaya_flathoofAI(pCreature);
 }
+
 /*######
 ## 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_kaya_flathoof";
     newscript->GetAI = &GetAI_npc_kaya_flathoofAI;
diff --git a/src/bindings/scripts/scripts/kalimdor/tanaris.cpp b/src/bindings/scripts/scripts/kalimdor/tanaris.cpp
index a9998c6f533..2b21db67794 100644
--- a/src/bindings/scripts/scripts/kalimdor/tanaris.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/tanaris.cpp
@@ -13,12 +13,14 @@
  * along 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: 648, 1560, 2954, 4005, 10277, 10279(Special flight path). Noggenfogger vendor
 SDCategory: Tanaris
 EndScriptData */
+
 /* ContentData
 mob_aquementas
 npc_custodian_of_time
@@ -28,32 +30,42 @@ npc_stone_watcher_of_norgannon
 npc_OOX17
 npc_tooga
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "follower_ai.h"
+
 /*######
 ## mob_aquementas
 ######*/
+
 #define AGGRO_YELL_AQUE     -1000350
+
 #define SPELL_AQUA_JET      13586
 #define SPELL_FROST_SHOCK   15089
+
 struct TRINITY_DLL_DECL mob_aquementasAI : public ScriptedAI
 {
     mob_aquementasAI(Creature *c) : ScriptedAI(c) {}
+
     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 (CAST_PLR(receiver)->HasItemCount(11169,1,false) &&
@@ -67,10 +79,12 @@ struct TRINITY_DLL_DECL mob_aquementasAI : public ScriptedAI
                 CAST_PLR(receiver)->StoreNewItem(dest, 11522, 1, true);
         }
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(AGGRO_YELL_AQUE, m_creature, who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (isFriendly)
@@ -81,8 +95,10 @@ struct TRINITY_DLL_DECL mob_aquementasAI : public ScriptedAI
                 isFriendly = false;
             }else SwitchFaction_Timer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         if (!isFriendly)
         {
             if (SendItem_Timer < diff)
@@ -92,16 +108,19 @@ struct TRINITY_DLL_DECL mob_aquementasAI : public ScriptedAI
                 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();
     }
 };
@@ -109,9 +128,11 @@ CreatureAI* GetAI_mob_aquementas(Creature* pCreature)
 {
     return new mob_aquementasAI (pCreature);
 }
+
 /*######
 ## npc_custodian_of_time
 ######*/
+
 #define WHISPER_CUSTODIAN_1     -1000150
 #define WHISPER_CUSTODIAN_2     -1000151
 #define WHISPER_CUSTODIAN_3     -1000152
@@ -126,14 +147,17 @@ CreatureAI* GetAI_mob_aquementas(Creature* pCreature)
 #define WHISPER_CUSTODIAN_12    -1000161
 #define WHISPER_CUSTODIAN_13    -1000162
 #define WHISPER_CUSTODIAN_14    -1000163
+
 struct TRINITY_DLL_DECL npc_custodian_of_timeAI : public npc_escortAI
 {
     npc_custodian_of_timeAI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player *pPlayer = GetPlayerForEscort();
         if (!pPlayer)
             return;
+
         switch(i)
         {
             case 0: DoScriptText(WHISPER_CUSTODIAN_1, m_creature, pPlayer); break;
@@ -161,10 +185,12 @@ struct TRINITY_DLL_DECL npc_custodian_of_timeAI : public npc_escortAI
                 break;
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
             return;
+
         if (who->GetTypeId() == TYPEID_PLAYER)
         {
             if (who->HasAura(34877) && CAST_PLR(who)->GetQuestStatus(10277) == QUEST_STATUS_INCOMPLETE)
@@ -177,43 +203,57 @@ struct TRINITY_DLL_DECL npc_custodian_of_timeAI : public npc_escortAI
             }
         }
     }
+
     void EnterCombat(Unit* who) { }
     void Reset() { }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_npc_custodian_of_time(Creature* pCreature)
 {
     return new npc_custodian_of_timeAI(pCreature);
 }
+
 /*######
 ## npc_marin_noggenfogger
 ######*/
+
 bool GossipHello_npc_marin_noggenfogger(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor() && pPlayer->GetQuestRewardStatus(2662))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_marin_noggenfogger(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(10279) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestRewardStatus(10279))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -221,38 +261,50 @@ bool GossipHello_npc_steward_of_time(Player* pPlayer, Creature* pCreature)
     }
     else
         pPlayer->SEND_GOSSIP_MENU(9977, pCreature->GetGUID());
+
     return true;
 }
+
 bool QuestAccept_npc_steward_of_time(Player* pPlayer, Creature* pCreature, Quest const *quest)
 {
     if (quest->GetQuestId() == 10279)                      //Quest: To The Master's Lair
         pPlayer->CastSpell(pPlayer,34891,true);               //(Flight through Caverns)
+
     return false;
 }
+
 bool GossipSelect_npc_steward_of_time(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
         pPlayer->CastSpell(pPlayer,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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(2954) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_NORGANNON_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(1674, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_stone_watcher_of_norgannon(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -284,9 +336,11 @@ bool GossipSelect_npc_stone_watcher_of_norgannon(Player* pPlayer, Creature* pCre
     }
     return true;
 }
+
 /*######
 ## npc_OOX17
 ######*/
+
 enum e00X17
 {
     //texts are signed for 7806
@@ -296,19 +350,24 @@ enum e00X17
     SAY_OOX_AMBUSH          = -1000290,
     SAY_OOX17_AMBUSH_REPLY  = -1000291,
     SAY_OOX_END             = -1000292,
+
     Q_OOX17                 = 648,
     SPAWN_FIRST             = 7803,
     SPAWN_SECOND_1          = 5617,
     SPAWN_SECOND_2          = 7805
 };
+
 struct TRINITY_DLL_DECL npc_OOX17AI : public npc_escortAI
 {
     npc_OOX17AI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i) {
             case 23:
                 m_creature->SummonCreature(SPAWN_FIRST, -8350.96, -4445.79, 10.10, 6.20, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
@@ -316,6 +375,7 @@ struct TRINITY_DLL_DECL npc_OOX17AI : public npc_escortAI
                 m_creature->SummonCreature(SPAWN_FIRST, -8353.96, -4442.79, 10.10, 6.08, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                 DoScriptText(SAY_OOX_AMBUSH, m_creature);
                 break;
+
             case 56:
                 m_creature->SummonCreature(SPAWN_SECOND_1, -7510.07, -4795.50, 9.35, 6.06, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                 m_creature->SummonCreature(SPAWN_SECOND_2, -7515.07, -4797.50, 9.35, 6.22, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
@@ -324,6 +384,7 @@ struct TRINITY_DLL_DECL npc_OOX17AI : public npc_escortAI
                 if (Unit* scoff = me->FindNearestCreature(SPAWN_SECOND_2, 30))
                     DoScriptText(SAY_OOX17_AMBUSH_REPLY, scoff);
                 break;
+
             case 86:
                 if (pPlayer)
                 {
@@ -333,16 +394,20 @@ struct TRINITY_DLL_DECL npc_OOX17AI : public npc_escortAI
                 break;
         }
     }
+
     void Reset(){}
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(RAND(SAY_OOX_AGGRO1,SAY_OOX_AGGRO2), m_creature);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
 };
+
 bool QuestAccept_npc_OOX17(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == Q_OOX17)
@@ -352,18 +417,22 @@ bool QuestAccept_npc_OOX17(Player* pPlayer, Creature* pCreature, Quest const* qu
         pCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0);
         pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
         DoScriptText(SAY_OOX_START, pCreature);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_OOX17AI, pCreature->AI()))
             pEscortAI->Start(true, false, pPlayer->GetGUID());
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_OOX17(Creature* pCreature)
 {
     return new npc_OOX17AI(pCreature);
 }
+
 /*####
 # npc_tooga
 ####*/
+
 enum eTooga
 {
     SAY_TOOG_THIRST             = -1000391,
@@ -374,29 +443,39 @@ enum eTooga
     SAY_TORT_POST_4             = -1000396,
     SAY_TOOG_POST_5             = -1000397,
     SAY_TORT_POST_6             = -1000398,
+
     QUEST_TOOGA                 = 1560,
     NPC_TORTA                   = 6015,
+
     POINT_ID_TO_WATER           = 1,
     FACTION_TOOG_ESCORTEE       = 113
 };
+
 const float m_afToWaterLoc[] = {-7032.664551, -4906.199219, -1.606446};
+
 struct TRINITY_DLL_DECL npc_toogaAI : public FollowerAI
 {
     npc_toogaAI(Creature* pCreature) : FollowerAI(pCreature) { }
+
     uint32 m_uiCheckSpeechTimer;
     uint32 m_uiPostEventTimer;
     uint32 m_uiPhasePostEvent;
+
     Unit* pTorta;
+
     void Reset()
     {
         m_uiCheckSpeechTimer = 2500;
         m_uiPostEventTimer = 1000;
         m_uiPhasePostEvent = 0;
+
         pTorta = NULL;
     }
+
     void MoveInLineOfSight(Unit *pWho)
     {
         FollowerAI::MoveInLineOfSight(pWho);
+
         if (!m_creature->getVictim() && !HasFollowState(STATE_FOLLOW_COMPLETE | STATE_FOLLOW_POSTEVENT) && pWho->GetEntry() == NPC_TORTA)
         {
             if (m_creature->IsWithinDistInMap(pWho, INTERACTION_DISTANCE))
@@ -406,19 +485,24 @@ struct TRINITY_DLL_DECL npc_toogaAI : public FollowerAI
                     if (pPlayer->GetQuestStatus(QUEST_TOOGA) == QUEST_STATUS_INCOMPLETE)
                         pPlayer->GroupEventHappens(QUEST_TOOGA, m_creature);
                 }
+
                 pTorta = pWho;
                 SetFollowComplete(true);
             }
         }
     }
+
     void MovementInform(uint32 uiMotionType, uint32 uiPointId)
     {
         FollowerAI::MovementInform(uiMotionType, uiPointId);
+
         if (uiMotionType != POINT_MOTION_TYPE)
             return;
+
         if (uiPointId == POINT_ID_TO_WATER)
             SetFollowComplete();
     }
+
     void UpdateFollowerAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
@@ -429,12 +513,14 @@ struct TRINITY_DLL_DECL npc_toogaAI : public FollowerAI
                 if (m_uiPostEventTimer < uiDiff)
                 {
                     m_uiPostEventTimer = 5000;
+
                     if (!pTorta || !pTorta->isAlive())
                     {
                         //something happened, so just complete
                         SetFollowComplete();
                         return;
                     }
+
                     switch(m_uiPhasePostEvent)
                     {
                         case 1:
@@ -457,6 +543,7 @@ struct TRINITY_DLL_DECL npc_toogaAI : public FollowerAI
                             m_creature->GetMotionMaster()->MovePoint(POINT_ID_TO_WATER, m_afToWaterLoc[0], m_afToWaterLoc[1], m_afToWaterLoc[2]);
                             break;
                     }
+
                     ++m_uiPhasePostEvent;
                 }
                 else
@@ -468,21 +555,26 @@ struct TRINITY_DLL_DECL npc_toogaAI : public FollowerAI
                 if (m_uiCheckSpeechTimer < uiDiff)
                 {
                     m_uiCheckSpeechTimer = 5000;
+
                     if (urand(0,9) > 8)
                         DoScriptText(RAND(SAY_TOOG_THIRST,SAY_TOOG_WORRIED), m_creature);
                 }
                 else
                     m_uiCheckSpeechTimer -= uiDiff;
             }
+
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_tooga(Creature* pCreature)
 {
     return new npc_toogaAI(pCreature);
 }
+
 bool QuestAccept_npc_tooga(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_TOOGA)
@@ -490,40 +582,49 @@ bool QuestAccept_npc_tooga(Player* pPlayer, Creature* pCreature, const Quest* pQ
         if (npc_toogaAI* pToogaAI = CAST_AI(npc_toogaAI, pCreature->AI()))
             pToogaAI->StartFollow(pPlayer, FACTION_TOOG_ESCORTEE, pQuest);
     }
+
     return true;
 }
+
 void AddSC_tanaris()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_aquementas";
     newscript->GetAI = &GetAI_mob_aquementas;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_custodian_of_time";
     newscript->GetAI = &GetAI_npc_custodian_of_time;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_marin_noggenfogger";
     newscript->pGossipHello =  &GossipHello_npc_marin_noggenfogger;
     newscript->pGossipSelect = &GossipSelect_npc_marin_noggenfogger;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_OOX17";
     newscript->GetAI = &GetAI_npc_OOX17;
     newscript->pQuestAccept = &QuestAccept_npc_OOX17;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_tooga";
     newscript->GetAI = &GetAI_npc_tooga;
diff --git a/src/bindings/scripts/scripts/kalimdor/teldrassil.cpp b/src/bindings/scripts/scripts/kalimdor/teldrassil.cpp
index b1a6e130b79..8ab8d98218a 100644
--- a/src/bindings/scripts/scripts/kalimdor/teldrassil.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/teldrassil.cpp
@@ -13,20 +13,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Teldrassil
 SD%Complete: 100
 SDComment: Quest support: 938
 SDCategory: Teldrassil
 EndScriptData */
+
 /* ContentData
 npc_mist
 EndContentData */
+
 #include "precompiled.h"
 #include "follower_ai.h"
+
 /*####
 # npc_mist
 ####*/
+
 enum eMist
 {
     SAY_AT_HOME             = -1000411,
@@ -35,13 +40,17 @@ enum eMist
     NPC_ARYNIA              = 3519,
     FACTION_DARNASSUS       = 79
 };
+
 struct TRINITY_DLL_DECL npc_mistAI : public FollowerAI
 {
     npc_mistAI(Creature* pCreature) : FollowerAI(pCreature) { }
+
     void Reset() { }
+
     void MoveInLineOfSight(Unit *pWho)
     {
         FollowerAI::MoveInLineOfSight(pWho);
+
         if (!m_creature->getVictim() && !HasFollowState(STATE_FOLLOW_COMPLETE) && pWho->GetEntry() == NPC_ARYNIA)
         {
             if (m_creature->IsWithinDistInMap(pWho, 10.0f))
@@ -51,29 +60,36 @@ struct TRINITY_DLL_DECL npc_mistAI : public FollowerAI
             }
         }
     }
+
     void DoComplete()
     {
         DoScriptText(EMOTE_AT_HOME, m_creature);
+
         if (Player* pPlayer = GetLeaderForFollower())
         {
             if (pPlayer->GetQuestStatus(QUEST_MIST) == QUEST_STATUS_INCOMPLETE)
                 pPlayer->GroupEventHappens(QUEST_MIST, m_creature);
         }
+
         //The follow is over (and for later development, run off to the woods before really end)
         SetFollowComplete();
     }
+
     //call not needed here, no known abilities
     /*void UpdateFollowerAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }*/
 };
+
 CreatureAI* GetAI_npc_mist(Creature* pCreature)
 {
     return new npc_mistAI(pCreature);
 }
+
 bool QuestAccept_npc_mist(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_MIST)
@@ -81,11 +97,14 @@ bool QuestAccept_npc_mist(Player* pPlayer, Creature* pCreature, Quest const* pQu
         if (npc_mistAI* pMistAI = CAST_AI(npc_mistAI, pCreature->AI()))
             pMistAI->StartFollow(pPlayer, FACTION_DARNASSUS, pQuest);
     }
+
     return true;
 }
+
 void AddSC_teldrassil()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_mist";
     newscript->GetAI = &GetAI_npc_mist;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_bug_trio.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_bug_trio.cpp
index 9619a4398dd..d8ce45872e5 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_bug_trio.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_bug_trio.cpp
@@ -13,45 +13,58 @@
  * along with 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 TRINITY_DLL_DECL boss_kriAI : public ScriptedAI
 {
     boss_kriAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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 EnterCombat(Unit *who)
     {
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
@@ -59,6 +72,7 @@ struct TRINITY_DLL_DECL boss_kriAI : public ScriptedAI
             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);
         }
     }
@@ -67,23 +81,27 @@ struct TRINITY_DLL_DECL boss_kriAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             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.
@@ -97,27 +115,35 @@ struct TRINITY_DLL_DECL boss_kriAI : public ScriptedAI
                 Check_Timer = 2000;
             }else Check_Timer -=diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_vemAI : public ScriptedAI
 {
     boss_vemAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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)
@@ -129,14 +155,17 @@ struct TRINITY_DLL_DECL boss_vemAI : public ScriptedAI
             pInstance->SetData(DATA_BUG_TRIO_DEATH, 1);
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Charge_Timer
         if (Charge_Timer < diff)
         {
@@ -148,8 +177,10 @@ struct TRINITY_DLL_DECL boss_vemAI : public ScriptedAI
                 //m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1);
                 AttackStart(target);
             }
+
             Charge_Timer = 8000 + rand()%8000;
         }else Charge_Timer -= diff;
+
         //KnockBack_Timer
         if (KnockBack_Timer < diff)
         {
@@ -158,33 +189,42 @@ struct TRINITY_DLL_DECL boss_vemAI : public ScriptedAI
                 DoModifyThreatPercent(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 TRINITY_DLL_DECL boss_yaujAI : public ScriptedAI
 {
     boss_yaujAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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)
@@ -194,7 +234,8 @@ struct TRINITY_DLL_DECL boss_yaujAI : public ScriptedAI
                 m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
             pInstance->SetData(DATA_BUG_TRIO_DEATH, 1);
         }
-        for (uint8 i = 0; i < 10; ++i)
+
+        for(uint8 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);
@@ -202,14 +243,17 @@ struct TRINITY_DLL_DECL boss_yaujAI : public ScriptedAI
                 (Summoned->AI())->AttackStart(target);
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Fear_Timer
         if (Fear_Timer < diff)
         {
@@ -217,6 +261,7 @@ struct TRINITY_DLL_DECL boss_yaujAI : public ScriptedAI
             DoResetThreat();
             Fear_Timer = 20000;
         }else Fear_Timer -= diff;
+
         //Casting Heal to other twins or herself.
         if (Heal_Timer < diff)
         {
@@ -224,6 +269,7 @@ struct TRINITY_DLL_DECL boss_yaujAI : public ScriptedAI
             {
                 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:
@@ -239,8 +285,10 @@ struct TRINITY_DLL_DECL boss_yaujAI : public ScriptedAI
                         break;
                 }
             }
+
             Heal_Timer = 15000+rand()%15000;
         }else Heal_Timer -= diff;
+
         //Checking if Vem is dead. If yes we will enrage.
         if (Check_Timer < diff)
         {
@@ -257,21 +305,26 @@ struct TRINITY_DLL_DECL boss_yaujAI : public ScriptedAI
             }
             Check_Timer = 2000;
         }else Check_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_yauj(Creature* pCreature)
 {
     return new boss_yaujAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_vem(Creature* pCreature)
 {
     return new boss_vemAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_kri(Creature* pCreature)
 {
     return new boss_kriAI (pCreature);
 }
+
 void AddSC_bug_trio()
 {
     Script *newscript;
@@ -279,10 +332,12 @@ void AddSC_bug_trio()
     newscript->Name = "boss_kri";
     newscript->GetAI = &GetAI_boss_kri;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_vem";
     newscript->GetAI = &GetAI_boss_vem;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_yauj";
     newscript->GetAI = &GetAI_boss_yauj;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_cthun.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_cthun.cpp
index a758c1ff1ea..541d16b7f2b 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_cthun.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_cthun.cpp
@@ -13,98 +13,128 @@
  * along with 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"
+
 //Text emote
 #define EMOTE_WEAKENED              -1531011
+
 #define PI                          3.14
+
 //****** Out of Combat ******
 //Random Wispers - No txt only sound
 #define RANDOM_SOUND_WHISPER        8663
+
 //***** 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
+
 //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 TRINITY_DLL_DECL flesh_tentacleAI : public ScriptedAI
 {
     flesh_tentacleAI(Creature *c) : ScriptedAI(c), Parent(0)
     {
         SetCombatMovement(false);
     }
+
     uint64 Parent;
     uint32 CheckTimer;
+
     void SpawnedByCthun(uint64 p)
     {
         Parent = p;
     }
+
     void Reset()
     {
         CheckTimer = 1000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff);
+
     void JustDied(Unit* killer);
 };
+
 struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
 {
     eye_of_cthunAI(Creature *c) : Scripted_NoMovementAI(c)
@@ -113,56 +143,70 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
         if (!pInst)
             error_log("TSCR: No Instance eye_of_cthunAI");
     }
+
     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 EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void SpawnEyeTentacle(float x, float y)
     {
         if (Creature* Spawned = me->SummonCreature(MOB_EYE_TENTACLE,m_creature->GetPositionX()+x,m_creature->GetPositionY()+y,m_creature->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500))
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 Spawned->AI()->AttackStart(target);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Check if we have a target
         if (!UpdateVictim())
             return;
+
         //No instance
         if (!pInst)
             return;
+
         switch (pInst->GetData(DATA_CTHUN_PHASE))
         {
             case 0:
@@ -177,12 +221,15 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
                     {
                         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)
                 {
@@ -191,14 +238,18 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
                     if (target)
                     {
                         Creature* Spawned = NULL;
+
                         //Spawn claw tentacle on the random target
                         Spawned = me->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)
                 {
@@ -207,39 +258,50 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
                     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
+
                     //Darkbeam for 35 seconds
                     PhaseTimer = 35000;
                 }else PhaseTimer -= diff;
+
             }
             break;
             case 1:
@@ -250,37 +312,49 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
                     {
                         //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(m_creature, 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->SetUInt32Value(UNIT_FIELD_FLAGS, 0);
+
                     //Eye Beam for 50 seconds
                     PhaseTimer = 50000;
                 } else PhaseTimer -= diff;
             }
             break;
+
             //Transition phase
             case 2:
             {
@@ -288,6 +362,7 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
                 m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0);
                 m_creature->SetHealth(0);
             }
+
             //Dead phase
             case 5:
             {
@@ -295,11 +370,13 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
             }
         }
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         //No instance
         if (!pInst)
             return;
+
         switch (pInst->GetData(DATA_CTHUN_PHASE))
         {
             case 0:
@@ -308,27 +385,36 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
                 //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->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
@@ -339,23 +425,31 @@ struct TRINITY_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
 {
     cthunAI(Creature *c) : ScriptedAI(c)
     {
         SetCombatMovement(false);
+
         pInst = c->GetInstanceData();
         if (!pInst)
             error_log("TSCR: No Instance eye_of_cthunAI");
     }
+
     ScriptedInstance* pInst;
+
     //Out of combat whisper timer
     uint32 WisperTimer;
+
     //Global variables
     uint32 PhaseTimer;
+
     //-------------------
+
     //Phase transition
     uint64 HoldPlayer;
+
     //Body Phase
     uint32 EyeTentacleTimer;
     uint8 FleshTentaclesKilled;
@@ -365,16 +459,21 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
     uint32 StomachEnterTimer;
     uint32 StomachEnterVisTimer;
     uint64 StomachEnterTarget;
+
     //Stomach map, bool = true then in stomach
     UNORDERED_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;
@@ -384,18 +483,23 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
         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 EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void SpawnEyeTentacle(float x, float y)
     {
         Creature* Spawned;
@@ -403,36 +507,49 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
         if (Spawned)
         {
             Unit* target;
+
             target = SelectRandomNotStomach();
+
             if (target)
                 Spawned->AI()->AttackStart(target);
         }
     }
+
     Unit* SelectRandomNotStomach()
     {
         if (Stomach_Map.empty())
             return NULL;
+
         UNORDERED_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
@@ -444,25 +561,32 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
             {
                 Map* pMap = m_creature->GetMap();
                 if (!pMap->IsDungeon()) return;
+
                 //Play random sound to the zone
                 Map::PlayerList const &PlayerList = pMap->GetPlayers();
+
                 if (!PlayerList.isEmpty())
                 {
-                    for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
                     {
                         if (Player* pPlr = itr->getSource())
                             pPlr->PlayDirectSound(RANDOM_SOUND_WHISPER,pPlr);
                     }
                 }
+
                 //One random wisper every 90 - 300 seconds
                 WisperTimer = urand(90000,300000);
             } else WisperTimer -= diff;
+
             return;
         }
+
         m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0);
+
         //No instance
         if (!pInst)
             return;
+
         switch (pInst->GetData(DATA_CTHUN_PHASE))
         {
             //Transition phase
@@ -473,109 +597,143 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
                 {
                     //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, HoldpPlayer));
                     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 = me->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS1_X, TENTACLE_POS1_Y, TENTACLE_POS1_Z, TENTACLE_POS1_O, TEMPSUMMON_CORPSE_DESPAWN, 0);
+
                     if (!Spawned)
                         FleshTentaclesKilled++;
                     else
                         CAST_AI(flesh_tentacleAI, (Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID());
+
                     //Spawn flesh tentacle
                     Spawned = me->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS2_X, TENTACLE_POS2_Y, TENTACLE_POS2_Z, TENTACLE_POS2_O, TEMPSUMMON_CORPSE_DESPAWN, 0);
+
                     if (!Spawned)
                         FleshTentaclesKilled++;
                     else
                         CAST_AI(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);
+
                     DoScriptText(EMOTE_WEAKENED, m_creature);
                     PhaseTimer = 45000;
+
                     DoCast(m_creature, SPELL_RED_COLORATION, true);
+
                     UNORDERED_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
                     UNORDERED_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->IsWithinDist3d(KICK_X, KICK_Y, KICK_Z, 15.0f))
                             {
                                 //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
@@ -585,20 +743,25 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
                         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)
                 {
@@ -607,14 +770,18 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
                     if (target)
                     {
                         Creature* Spawned = NULL;
+
                         //Spawn claw tentacle on the random target
                         Spawned = me->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)
                 {
@@ -622,15 +789,20 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
                     target = SelectRandomNotStomach();
                     if (target)
                     {
+
                         Creature* Spawned = NULL;
+
                         //Spawn claw tentacle on the random target
                         Spawned = me->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)
                 {
@@ -639,14 +811,18 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
                     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:
             {
@@ -655,39 +831,50 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
                 {
                     //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 = me->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS1_X, TENTACLE_POS1_Y, TENTACLE_POS1_Z, TENTACLE_POS1_O, TEMPSUMMON_CORPSE_DESPAWN, 0);
+
                     if (!Spawned)
                         ++FleshTentaclesKilled;
                     else
                         CAST_AI(flesh_tentacleAI, (Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID());
+
                     //Spawn flesh tentacle
                     Spawned = me->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS2_X, TENTACLE_POS2_Y, TENTACLE_POS2_Z, TENTACLE_POS2_O, TEMPSUMMON_CORPSE_DESPAWN, 0);
+
                     if (!Spawned)
                         ++FleshTentaclesKilled;
                     else
                         CAST_AI(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:
@@ -695,93 +882,114 @@ struct TRINITY_DLL_DECL cthunAI : public ScriptedAI
                 //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 TRINITY_DLL_DECL eye_tentacleAI : public ScriptedAI
 {
     eye_tentacleAI(Creature *c) : ScriptedAI(c)
     {
         SetCombatMovement(false);
+
         if (Unit* pPortal = m_creature->SummonCreature(MOB_SMALL_PORTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0))
             Portal = pPortal->GetGUID();
     }
+
     uint32 MindflayTimer;
     uint32 KillSelfTimer;
     uint64 Portal;
+
     void JustDied(Unit* who)
     {
         if (Unit* p = Unit::GetUnit(*m_creature, Portal))
             p->Kill(p);
     }
+
     void Reset()
     {
         //Mind flay half a second after we spawn
         MindflayTimer = 500;
+
         //This prevents eyes from overlapping
         KillSelfTimer = 35000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Check if we have a target
         if (!UpdateVictim())
             return;
+
         //KillSelfTimer
         if (KillSelfTimer < diff)
         {
             m_creature->Kill(m_creature);
             return;
         } else KillSelfTimer -= diff;
+
         //MindflayTimer
         if (MindflayTimer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
             if (target && !target->HasAura(SPELL_DIGESTIVE_ACID))
                 DoCast(target,SPELL_MIND_FLAY);
+
             //Mindflay every 10 seconds
             MindflayTimer = 10000;
         } else MindflayTimer -= diff;
     }
 };
+
 struct TRINITY_DLL_DECL claw_tentacleAI : public ScriptedAI
 {
     claw_tentacleAI(Creature *c) : ScriptedAI(c)
     {
         SetCombatMovement(false);
+
         if (Unit* pPortal = m_creature->SummonCreature(MOB_SMALL_PORTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0))
             Portal = pPortal->GetGUID();
     }
+
     uint32 GroundRuptureTimer;
     uint32 HamstringTimer;
     uint32 EvadeTimer;
     uint64 Portal;
+
     void JustDied(Unit* who)
     {
         if (Unit* p = Unit::GetUnit(*m_creature, Portal))
             p->Kill(p);
     }
+
     void Reset()
     {
         //First rupture should happen half a second after we spawn
@@ -789,74 +997,90 @@ struct TRINITY_DLL_DECL claw_tentacleAI : public ScriptedAI
         HamstringTimer = 2000;
         EvadeTimer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Check if we have a target
         if (!UpdateVictim())
             return;
+
         //EvadeTimer
         if (!m_creature->IsWithinMeleeRange(m_creature->getVictim()))
             if (EvadeTimer < diff)
             {
                 if (Unit* p = Unit::GetUnit(*m_creature, Portal))
                     p->Kill(p);
+
                 //Dissapear and reappear at new position
                 m_creature->SetVisibility(VISIBILITY_OFF);
+
                 Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
                 if (!target)
                 {
                     m_creature->Kill(m_creature);
                     return;
                 }
+
                 if (!target->HasAura(SPELL_DIGESTIVE_ACID))
                 {
                     m_creature->GetMap()->CreatureRelocation(m_creature, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);
                     if (Unit* pPortal = m_creature->SummonCreature(MOB_SMALL_PORTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0))
                         Portal = pPortal->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 TRINITY_DLL_DECL giant_claw_tentacleAI : public ScriptedAI
 {
     giant_claw_tentacleAI(Creature *c) : ScriptedAI(c)
     {
         SetCombatMovement(false);
+
         if (Unit* pPortal = m_creature->SummonCreature(MOB_GIANT_PORTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0))
             Portal = pPortal->GetGUID();
     }
+
     uint32 GroundRuptureTimer;
     uint32 ThrashTimer;
     uint32 HamstringTimer;
     uint32 EvadeTimer;
     uint64 Portal;
+
     void JustDied(Unit* who)
     {
         if (Unit* p = Unit::GetUnit(*m_creature, Portal))
             p->Kill(p);
     }
+
     void Reset()
     {
         //First rupture should happen half a second after we spawn
@@ -865,123 +1089,151 @@ struct TRINITY_DLL_DECL giant_claw_tentacleAI : public ScriptedAI
         ThrashTimer = 5000;
         EvadeTimer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Check if we have a target
         if (!UpdateVictim())
             return;
+
         //EvadeTimer
         if (!m_creature->IsWithinMeleeRange(m_creature->getVictim()))
             if (EvadeTimer < diff)
         {
             if (Unit* p = Unit::GetUnit(*m_creature, Portal))
                 p->Kill(p);
+
             //Dissapear and reappear at new position
             m_creature->SetVisibility(VISIBILITY_OFF);
+
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
             if (!target)
             {
                 m_creature->Kill(m_creature);
                 return;
             }
+
             if (!target->HasAura(SPELL_DIGESTIVE_ACID))
             {
                 m_creature->GetMap()->CreatureRelocation(m_creature, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);
                 if (Unit* pPortal = m_creature->SummonCreature(MOB_GIANT_PORTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0))
                     Portal = pPortal->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 TRINITY_DLL_DECL giant_eye_tentacleAI : public ScriptedAI
 {
     giant_eye_tentacleAI(Creature *c) : ScriptedAI(c)
     {
         SetCombatMovement(false);
+
         if (Unit* pPortal = m_creature->SummonCreature(MOB_GIANT_PORTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0))
             Portal = pPortal->GetGUID();
     }
+
     uint32 BeamTimer;
     uint64 Portal;
+
     void JustDied(Unit* who)
     {
         if (Unit* p = Unit::GetUnit(*m_creature, Portal))
             p->Kill(p);
     }
+
     void Reset()
     {
         //Green Beam half a second after we spawn
         BeamTimer = 500;
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Check if we have a target
         if (!UpdateVictim())
             return;
+
         //BeamTimer
         if (BeamTimer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
             if (target && !target->HasAura(SPELL_DIGESTIVE_ACID))
                 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 (!UpdateVictim())
         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)
@@ -989,68 +1241,85 @@ void flesh_tentacleAI::JustDied(Unit* killer)
         error_log("TSCR: flesh_tentacle: No Parent variable");
         return;
     }
+
     Creature* Cthun = Unit::GetCreature(*m_creature, Parent);
+
     if (Cthun)
         CAST_AI(cthunAI, (Cthun->AI()))->FleshTentcleKilled();
     else error_log("TSCR: flesh_tentacle: No Cthun");
 }
+
 //GetAIs
 CreatureAI* GetAI_eye_of_cthun(Creature* pCreature)
 {
     return new eye_of_cthunAI (pCreature);
 }
+
 CreatureAI* GetAI_cthun(Creature* pCreature)
 {
     return new cthunAI (pCreature);
 }
+
 CreatureAI* GetAI_eye_tentacle(Creature* pCreature)
 {
     return new eye_tentacleAI (pCreature);
 }
+
 CreatureAI* GetAI_claw_tentacle(Creature* pCreature)
 {
     return new claw_tentacleAI (pCreature);
 }
+
 CreatureAI* GetAI_giant_claw_tentacle(Creature* pCreature)
 {
     return new giant_claw_tentacleAI (pCreature);
 }
+
 CreatureAI* GetAI_giant_eye_tentacle(Creature* pCreature)
 {
     return new giant_eye_tentacleAI (pCreature);
 }
+
 CreatureAI* GetAI_flesh_tentacle(Creature* pCreature)
 {
     return new flesh_tentacleAI (pCreature);
 }
+
 void AddSC_boss_cthun()
 {
     Script *newscript;
+
     //Eye
     newscript = new Script;
     newscript->Name = "boss_eye_of_cthun";
     newscript->GetAI = &GetAI_eye_of_cthun;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_cthun";
     newscript->GetAI = &GetAI_cthun;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_eye_tentacle";
     newscript->GetAI = &GetAI_eye_tentacle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_claw_tentacle";
     newscript->GetAI = &GetAI_claw_tentacle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_giant_claw_tentacle";
     newscript->GetAI = &GetAI_giant_claw_tentacle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_giant_eye_tentacle";
     newscript->GetAI = &GetAI_giant_eye_tentacle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_giant_flesh_tentacle";
     newscript->GetAI = &GetAI_flesh_tentacle;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_fankriss.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_fankriss.cpp
index 3ee6d881994..2dce14cb9ec 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_fankriss.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_fankriss.cpp
@@ -13,43 +13,54 @@
  * along with 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 TRINITY_DLL_DECL boss_fankrissAI : public ScriptedAI
 {
     boss_fankrissAI(Creature *c) : ScriptedAI(c) {}
+
     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)
     {
         if (!victim)
             return;
+
         Rand = 10 + (rand()%10);
         switch (rand()%2)
         {
@@ -68,20 +79,24 @@ struct TRINITY_DLL_DECL boss_fankrissAI : public ScriptedAI
         if (Spawn)
             (Spawn->AI())->AttackStart(victim);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -102,6 +117,7 @@ struct TRINITY_DLL_DECL boss_fankrissAI : public ScriptedAI
             }
             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)
@@ -113,8 +129,10 @@ struct TRINITY_DLL_DECL boss_fankrissAI : public ScriptedAI
                 if (target && target->GetTypeId() == TYPEID_PLAYER)
                 {
                     DoCast(target, SPELL_ROOT);
+
                     if (DoGetThreat(target))
                         DoModifyThreatPercent(target, -100);
+
                     switch(rand()%3)
                     {
                         case 0:
@@ -167,13 +185,16 @@ struct TRINITY_DLL_DECL boss_fankrissAI : public ScriptedAI
                 SpawnHatchlings_Timer = 45000 + rand()%15000;
             }else SpawnHatchlings_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_fankriss(Creature* pCreature)
 {
     return new boss_fankrissAI (pCreature);
 }
+
 void AddSC_boss_fankriss()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_huhuran.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_huhuran.cpp
index 83b189f4b4f..9df6912a3df 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_huhuran.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_huhuran.cpp
@@ -13,32 +13,40 @@
  * along with 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 EMOTE_GENERIC_FRENZY_KILL   -1000001
 #define EMOTE_GENERIC_BERSERK       -1000004
+
 #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 TRINITY_DLL_DECL boss_huhuranAI : public ScriptedAI
 {
     boss_huhuranAI(Creature *c) : ScriptedAI(c) {}
+
     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;
@@ -47,17 +55,21 @@ struct TRINITY_DLL_DECL boss_huhuranAI : public ScriptedAI
         PoisonBolt_Timer = 4000;
         NoxiousPoison_Timer = 10000 + rand()%10000;
         FrenzyBack_Timer = 15000;
+
         Frenzy = false;
         Berserk = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Frenzy_Timer
         if (!Frenzy && Frenzy_Timer < diff)
         {
@@ -67,6 +79,7 @@ struct TRINITY_DLL_DECL boss_huhuranAI : public ScriptedAI
             PoisonBolt_Timer = 3000;
             Frenzy_Timer = 25000 + rand()%10000;
         }else Frenzy_Timer -= diff;
+
         // Wyvern Timer
         if (Wyvern_Timer < diff)
         {
@@ -74,18 +87,21 @@ struct TRINITY_DLL_DECL boss_huhuranAI : public ScriptedAI
                 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)
         {
@@ -95,6 +111,7 @@ struct TRINITY_DLL_DECL boss_huhuranAI : public ScriptedAI
                 PoisonBolt_Timer = 3000;
             }else PoisonBolt_Timer -= diff;
         }
+
         //FrenzyBack_Timer
         if (Frenzy && FrenzyBack_Timer < diff)
         {
@@ -102,6 +119,7 @@ struct TRINITY_DLL_DECL boss_huhuranAI : public ScriptedAI
             Frenzy = false;
             FrenzyBack_Timer = 15000;
         }else FrenzyBack_Timer -= diff;
+
         if (!Berserk && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 31)
         {
             m_creature->InterruptNonMeleeSpells(false);
@@ -109,13 +127,16 @@ struct TRINITY_DLL_DECL boss_huhuranAI : public ScriptedAI
             DoCast(m_creature, SPELL_BERSERK);
             Berserk = true;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_huhuran(Creature* pCreature)
 {
     return new boss_huhuranAI (pCreature);
 }
+
 void AddSC_boss_huhuran()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_ouro.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_ouro.cpp
index 079a5367903..13bf15fe66a 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_ouro.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_ouro.cpp
@@ -13,30 +13,38 @@
  * along with 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 TRINITY_DLL_DECL boss_ouroAI : public ScriptedAI
 {
     boss_ouroAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Sweep_Timer;
     uint32 SandBlast_Timer;
     uint32 Submerge_Timer;
     uint32 Back_Timer;
     uint32 ChangeTarget_Timer;
     uint32 Spawn_Timer;
+
     bool Enrage;
     bool Submerged;
+
     void Reset()
     {
         Sweep_Timer = 5000 + rand()%5000;
@@ -45,30 +53,36 @@ struct TRINITY_DLL_DECL boss_ouroAI : public ScriptedAI
         Back_Timer = 30000 + rand()%15000;
         ChangeTarget_Timer = 5000 + rand()%3000;
         Spawn_Timer = 10000 + rand()%10000;
+
         Enrage = false;
         Submerged = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoCast(m_creature->getVictim(), SPELL_BIRTH);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -77,34 +91,44 @@ struct TRINITY_DLL_DECL boss_ouroAI : public ScriptedAI
             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);
+
             if (target)
                 DoTeleportTo(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
+
             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* pCreature)
 {
     return new boss_ouroAI (pCreature);
 }
+
 void AddSC_boss_ouro()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_sartura.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_sartura.cpp
index 1e6dde30323..0494cc2fdd1 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_sartura.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_sartura.cpp
@@ -13,36 +13,45 @@
  * along with 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: 95
 SDComment:
 SDCategory: Temple of Ahn'Qiraj
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SAY_AGGRO                   -1531008
 #define SAY_SLAY                    -1531009
 #define SAY_DEATH                   -1531010
+
 #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 TRINITY_DLL_DECL boss_sarturaAI : public ScriptedAI
 {
     boss_sarturaAI(Creature *c) : ScriptedAI(c) {}
+
     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;
@@ -51,28 +60,35 @@ struct TRINITY_DLL_DECL boss_sarturaAI : public ScriptedAI
         AggroReset_Timer = 45000 + rand()%10000;
         AggroResetEnd_Timer = 5000;
         EnrageHard_Timer = 10*60000;
+
         WhirlWind = false;
         AggroReset = false;
         Enraged = false;
         EnragedHard = false;
+
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
      void JustDied(Unit* Killer)
      {
          DoScriptText(SAY_DEATH, m_creature);
      }
+
      void KilledUnit(Unit* victim)
      {
          DoScriptText(SAY_SLAY, m_creature);
      }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (WhirlWind)
         {
             if (WhirlWindRandom_Timer < diff)
@@ -84,14 +100,17 @@ struct TRINITY_DLL_DECL boss_sarturaAI : public ScriptedAI
                 m_creature->AddThreat(target, 1.0f);
                 m_creature->TauntApply(target);
                 AttackStart(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)
@@ -100,6 +119,7 @@ struct TRINITY_DLL_DECL boss_sarturaAI : public ScriptedAI
                 WhirlWind = true;
                 WhirlWindEnd_Timer = 15000;
             }else WhirlWind_Timer -= diff;
+
             if (AggroReset_Timer < diff)
             {
                 //Attack random Gamers
@@ -109,9 +129,11 @@ struct TRINITY_DLL_DECL boss_sarturaAI : public ScriptedAI
                 m_creature->AddThreat(target, 1.0f);
                 m_creature->TauntApply(target);
                 AttackStart(target);
+
                     AggroReset = true;
                     AggroReset_Timer = 2000 + rand()%3000;
             }else AggroReset_Timer -= diff;
+
             if (AggroReset)
             {
                 if (AggroResetEnd_Timer AddThreat(target, 1.0f);
                 m_creature->TauntApply(target);
                 AttackStart(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)
@@ -209,15 +246,18 @@ struct TRINITY_DLL_DECL mob_sartura_royal_guardAI : public ScriptedAI
                 m_creature->AddThreat(target, 1.0f);
                 m_creature->TauntApply(target);
                 AttackStart(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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_sartura_royal_guard";
     newscript->GetAI = &GetAI_mob_sartura_royal_guard;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_skeram.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_skeram.cpp
index 8ec42dee092..1c988387993 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_skeram.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_skeram.cpp
@@ -13,15 +13,18 @@
  * along with 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 SAY_AGGRO1                  -1531000
 #define SAY_AGGRO2                  -1531001
 #define SAY_AGGRO3                  -1531002
@@ -30,10 +33,12 @@ EndScriptData */
 #define SAY_SLAY3                   -1531005
 #define SAY_SPLIT                   -1531006
 #define SAY_DEATH                   -1531007
+
 #define SPELL_ARCANE_EXPLOSION      25679
 #define SPELL_EARTH_SHOCK           26194
 #define SPELL_TRUE_FULFILLMENT4     26526
 #define SPELL_BLINK                 28391
+
 class ov_mycoordinates
 {
     public:
@@ -43,23 +48,28 @@ class ov_mycoordinates
             x = cx; y = cy; z = cz; r = cr;
         }
 };
+
 struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
 {
     boss_skeramAI(Creature *c) : ScriptedAI(c)
     {
         IsImage = false;
     }
+
     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;
@@ -67,41 +77,50 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
         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)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         if (!IsImage)
             DoScriptText(SAY_DEATH, m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         if (IsImage || Images75)
             return;
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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->IsWithinMeleeRange(m_creature->getVictim()))
         {
@@ -120,6 +139,7 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
                 EarthShock_Timer = 1000;
             }else EarthShock_Timer -= diff;
         }
+
         //Blink_Timer
         if (Blink_Timer < diff)
         {
@@ -140,19 +160,25 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
                     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)
         {
@@ -161,19 +187,25 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
                 //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 */)
     {
         DoScriptText(SAY_SPLIT, m_creature);
+
         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:
@@ -192,6 +224,7 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
                 i2=place2;
                 break;
         }
+
         for (int tryi = 0; tryi < 41; tryi ++)
         {
             Unit *targetpl = SelectUnit(SELECT_TARGET_RANDOM, 0);
@@ -209,6 +242,7 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
                 break;
             }
         }
+
         m_creature->RemoveAllAuras();
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetVisibility(VISIBILITY_OFF);
@@ -219,13 +253,16 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
         delete place3;
         DoResetThreat();
         DoStopAttack();
+
         switch (atPercent)
         {
             case 75: Images75 = true; break;
             case 50: Images50 = true; break;
             case 25: Images25 = true; break;
         }
+
         Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
+
         Image1 = m_creature->SummonCreature(15263, i1->x, i1->y, i1->z, i1->r, TEMPSUMMON_CORPSE_DESPAWN, 30000);
         if (Image1)
         {
@@ -235,6 +272,7 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
                 Image1->AI()->AttackStart(target);
             CAST_AI(boss_skeramAI, Image1->AI())->IsImage = true;
         }
+
         Image2 = m_creature->SummonCreature(15263,i2->x, i2->y, i2->z, i2->r, TEMPSUMMON_CORPSE_DESPAWN, 30000);
         if (Image2)
         {
@@ -246,11 +284,14 @@ struct TRINITY_DLL_DECL boss_skeramAI : public ScriptedAI
         }
         Invisible = true;
     }
+
 };
+
 CreatureAI* GetAI_boss_skeram(Creature* pCreature)
 {
     return new boss_skeramAI (pCreature);
 }
+
 void AddSC_boss_skeram()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp
index a477c30950d..72dfcdb08f3 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp
@@ -13,45 +13,59 @@
  * along with 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 TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
 {
     boss_twinemperorsAI(Creature *c): ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 Heal_Timer;
     uint32 Teleport_Timer;
     bool AfterTeleport;
@@ -60,9 +74,11 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
     uint32 Abuse_Bug_Timer, BugsTimer;
     bool tspellcasted;
     uint32 EnrageTimer;
+
     virtual bool IAmVeklor() = 0;
     virtual void Reset() = 0;
     virtual void CastSpellOnBug(Creature *target) = 0;
+
     void TwinReset()
     {
         Heal_Timer = 0;                                     // first heal immediately when they get close together
@@ -76,6 +92,7 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
         DontYellWhenDead = false;
         EnrageTimer = 15*60000;
     }
+
     Creature *GetOtherBoss()
     {
         if (pInstance)
@@ -83,6 +100,7 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
         else
             return NULL;
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         Unit *pOtherBoss = GetOtherBoss();
@@ -99,6 +117,7 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             }
         }
     }
+
     void JustDied(Unit* Killer)
     {
         Creature *pOtherBoss = GetOtherBoss();
@@ -112,10 +131,12 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
         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 EnterCombat(Unit *who)
     {
         DoZoneInCombat();
@@ -133,13 +154,16 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             }
         }
     }
+
     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);
@@ -147,6 +171,7 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             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)
@@ -160,10 +185,12 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             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();
@@ -174,13 +201,17 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             }
         } else Heal_Timer -= diff;
     }
+
     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)
         {
@@ -189,14 +220,17 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             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();
             CAST_AI(boss_twinemperorsAI,  pOtherBoss->AI())->SetAfterTeleport();
         }
     }
+
     void SetAfterTeleport()
     {
         m_creature->InterruptNonMeleeSpells(false);
@@ -208,6 +242,7 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
         AfterTeleportTimer = 2000;
         tspellcasted = false;
     }
+
     bool TryActivateAfterTTelep(uint32 diff)
     {
         if (AfterTeleport)
@@ -218,7 +253,9 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
                 DoCast(m_creature, SPELL_TWIN_TELEPORT);
                 m_creature->addUnitState(UNIT_STAT_STUNNED);
             }
+
             tspellcasted = true;
+
             if (AfterTeleportTimer < diff)
             {
                 AfterTeleport = false;
@@ -252,10 +289,12 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             return true;
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || m_creature->getVictim())
             return;
+
         if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(m_creature) && m_creature->IsHostileTo(who))
         {
             float attackRadius = m_creature->GetAttackDistance(who);
@@ -269,15 +308,19 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             }
         }
     }
+
     Creature *RespawnNearbyBugsAndGetOne()
     {
         std::list lUnitList;
         m_creature->GetCreatureListWithEntryInGrid(lUnitList,15316,150.0f);
         m_creature->GetCreatureListWithEntryInGrid(lUnitList,15317,150.0f);
+
         if (lUnitList.empty())
             return NULL;
+
         Creature *nearb = NULL;
-        for (std::list::iterator iter = lUnitList.begin(); iter != lUnitList.end(); ++iter)
+
+        for(std::list::iterator iter = lUnitList.begin(); iter != lUnitList.end(); ++iter)
         {
             Creature *c = *iter;
             if (c)
@@ -297,6 +340,7 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
         }
         return nearb;
     }
+
     void HandleBugs(uint32 diff)
     {
         if (BugsTimer < diff || Abuse_Bug_Timer < diff)
@@ -326,6 +370,7 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
             Abuse_Bug_Timer -= diff;
         }
     }
+
     void CheckEnrage(uint32 diff)
     {
         if (EnrageTimer < diff)
@@ -338,26 +383,32 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
         } else EnrageTimer-=diff;
     }
 };
+
 struct TRINITY_DLL_DECL boss_veknilashAI : public boss_twinemperorsAI
 {
     bool IAmVeklor() {return false;}
     boss_veknilashAI(Creature *c) : boss_twinemperorsAI(c) {}
+
     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);
@@ -373,19 +424,23 @@ struct TRINITY_DLL_DECL boss_veknilashAI : public boss_twinemperorsAI
         target->AddAura(new Aura(spell, eff_mask, target, target, target));
         target->SetHealth(target->GetMaxHealth());
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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 = SelectTarget(SELECT_TARGET_RANDOM, 0, NOMINAL_MELEE_RANGE, true);
@@ -393,22 +448,29 @@ struct TRINITY_DLL_DECL boss_veknilashAI : public boss_twinemperorsAI
                 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 TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
 {
     bool IAmVeklor() {return true;}
     boss_veklorAI(Creature *c) : boss_twinemperorsAI(c) {}
+
     uint32 ShadowBolt_Timer;
     uint32 Blizzard_Timer;
     uint32 ArcaneBurst_Timer;
@@ -416,7 +478,9 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
     int Rand;
     int RandX;
     int RandY;
+
     Creature* Summoned;
+
     void Reset()
     {
         TwinReset();
@@ -424,11 +488,13 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
         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);
@@ -443,11 +509,13 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
         target->AddAura(new Aura(spell, eff_mask, target, target, target));
         target->SetHealth(target->GetMaxHealth());
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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
@@ -455,6 +523,7 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
             ArcaneBurst_Timer = 5000;
         if (!TryActivateAfterTTelep(diff))
             return;
+
         //ShadowBolt_Timer
         if (ShadowBolt_Timer < diff)
         {
@@ -464,6 +533,7 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
                 DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT);
             ShadowBolt_Timer = 2000;
         }else ShadowBolt_Timer -= diff;
+
         //Blizzard_Timer
         if (Blizzard_Timer < diff)
         {
@@ -473,6 +543,7 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
                 DoCast(target,SPELL_BLIZZARD);
             Blizzard_Timer = 15000+rand()%15000;
         }else Blizzard_Timer -= diff;
+
         if (ArcaneBurst_Timer < diff)
         {
             Unit *mvic;
@@ -482,22 +553,29 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
                 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
@@ -509,21 +587,26 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_veknilash(Creature* pCreature)
 {
     return new boss_veknilashAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_veklor(Creature* pCreature)
 {
     return new boss_veklorAI (pCreature);
 }
+
 void AddSC_boss_twinemperors()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_veknilash";
     newscript->GetAI = &GetAI_boss_veknilash;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_veklor";
     newscript->GetAI = &GetAI_boss_veklor;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_viscidus.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_viscidus.cpp
index 9b782f23644..2bb9f1bfb0b 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_viscidus.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/boss_viscidus.cpp
@@ -13,14 +13,18 @@
  * along with 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/kalimdor/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h
index 2d41894e32d..5d545ed7c74 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
@@ -15,6 +17,7 @@
 #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/kalimdor/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp
index 75c2a218cbb..489a415cf81 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp
@@ -13,40 +13,52 @@
  * along 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 TRINITY_DLL_DECL instance_temple_of_ahnqiraj : public ScriptedInstance
 {
     instance_temple_of_ahnqiraj(Map* pMap) : ScriptedInstance(pMap) {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* pCreature, bool add)
     {
         switch (pCreature->GetEntry())
@@ -58,11 +70,13 @@ struct TRINITY_DLL_DECL instance_temple_of_ahnqiraj : public ScriptedInstance
             case 15275: VeknilashGUID = pCreature->GetGUID(); break;
         }
     }
+
     bool IsEncounterInProgress() const
     {
         //not active in AQ40
         return false;
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -71,21 +85,26 @@ struct TRINITY_DLL_DECL instance_temple_of_ahnqiraj : public ScriptedInstance
                 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)
@@ -103,6 +122,7 @@ struct TRINITY_DLL_DECL instance_temple_of_ahnqiraj : public ScriptedInstance
         }
         return 0;
     }                                                       // end GetData64
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -110,25 +130,31 @@ struct TRINITY_DLL_DECL instance_temple_of_ahnqiraj : public ScriptedInstance
             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* pMap)
 {
     return new instance_temple_of_ahnqiraj(pMap);
 }
+
 void AddSC_instance_temple_of_ahnqiraj()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp
index a7814ea3ede..04e31d7eebd 100644
--- a/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp
@@ -13,35 +13,46 @@
  * along 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
+
 struct TRINITY_DLL_DECL aqsentinelAI;
 class TRINITY_DLL_DECL SentinelAbilityAura : public Aura
 {
@@ -54,10 +65,12 @@ class TRINITY_DLL_DECL SentinelAbilityAura : public Aura
         int32 currentBasePoints;
         uint32 abilityId;
 };
+
 struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
 {
     uint32 ability;
     int abselected;
+
     void selectAbility(int asel)
     {
         switch (asel)
@@ -73,16 +86,20 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
             case 8: ability = SPELL_STORM_BUFF;break;
         }
     }
+
     aqsentinelAI(Creature *c) : ScriptedAI(c)
     {
         ClearBuddyList();
         abselected = 0;                                     // just initialization of variable
     }
+
     Creature *nearby[3];
+
     void ClearBuddyList()
     {
         nearby[0] = nearby[1] = nearby[2] = NULL;
     }
+
     void AddBuddyToList(Creature *c)
     {
         if (c==m_creature)
@@ -98,6 +115,7 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
             }
         }
     }
+
     void GiveBuddyMyList(Creature *c)
     {
         aqsentinelAI *cai = CAST_AI(aqsentinelAI, (c)->AI());
@@ -106,12 +124,14 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
                 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)
@@ -128,15 +148,19 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
             }
         }
     }
+
     void AddSentinelsNear(Unit *nears)
     {
         std::list assistList;
         m_creature->GetCreatureListWithEntryInGrid(assistList,15264,70.0f);
+
         if (assistList.empty())
             return;
-        for (std::list::iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
+
+        for(std::list::iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
             AddBuddyToList((*iter));
     }
+
     int pickAbilityRandom(bool *chosenAbilities)
     {
         for (int t = 0; t < 2; ++t)
@@ -152,11 +176,13 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
         }
         return 0;                                           // should never happen
     }
+
     void GetOtherSentinels(Unit *who)
     {
         bool *chosenAbilities = new bool[9];
         memset(chosenAbilities, 0, 9*sizeof(bool));
         selectAbility(pickAbilityRandom(chosenAbilities));
+
         ClearBuddyList();
         AddSentinelsNear(m_creature);
         int bli;
@@ -172,9 +198,12 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
             DoYell("I dont have enough buddies.", LANG_NEUTRAL, 0);*/
         SendMyListToBuddies();
         CallBuddiesToAttack(who);
+
         delete[] chosenAbilities;
     }
+
     bool gatherOthersWhenAggro;
+
     void Reset()
     {
         if (!m_creature->isDead())
@@ -190,6 +219,7 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
         ClearBuddyList();
         gatherOthersWhenAggro = true;
     }
+
     void GainSentinelAbility(uint32 id)
     {
         const SpellEntry *spell = GetSpellStore()->LookupEntry(id);
@@ -203,13 +233,16 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
         SentinelAbilityAura *a = new SentinelAbilityAura(this, (SpellEntry*)spell, id, eff_mask);
         m_creature->AddAura(a);
     }
+
     void EnterCombat(Unit *who)
     {
         if (gatherOthersWhenAggro)
             GetOtherSentinels(who);
+
         GainSentinelAbility(ability);
         DoZoneInCombat();
     }
+
     void JustDied(Unit* who)
     {
         for (int ni=0; ni<3; ++ni)
@@ -226,10 +259,11 @@ struct TRINITY_DLL_DECL aqsentinelAI : public ScriptedAI
             CAST_AI(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)
+        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)
@@ -242,6 +276,7 @@ CreatureAI* GetAI_mob_anubisath_sentinelAI(Creature* pCreature)
 {
     return new aqsentinelAI (pCreature);
 }
+
 void AddSC_mob_anubisath_sentinel()
 {
     Script *newscript;
@@ -250,6 +285,7 @@ void AddSC_mob_anubisath_sentinel()
     newscript->GetAI = &GetAI_mob_anubisath_sentinelAI;
     newscript->RegisterSelf();
 }
+
 SentinelAbilityAura::~SentinelAbilityAura() {}
 Unit* SentinelAbilityAura::GetTriggerTarget() const
 {
@@ -260,8 +296,10 @@ Unit* SentinelAbilityAura::GetTriggerTarget() const
         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:
@@ -270,6 +308,7 @@ Unit* SentinelAbilityAura::GetTriggerTarget() const
             return aOwner->m_creature;
     }
 }
+
 SentinelAbilityAura::SentinelAbilityAura(aqsentinelAI *abilityOwner, SpellEntry *spell, uint32 ability, uint32 eff)
 : Aura(spell, eff, abilityOwner->m_creature, abilityOwner->m_creature, abilityOwner->m_creature, NULL)
 {
diff --git a/src/bindings/scripts/scripts/kalimdor/the_barrens.cpp b/src/bindings/scripts/scripts/kalimdor/the_barrens.cpp
index c3e984ab2f5..70e0b3e5e28 100644
--- a/src/bindings/scripts/scripts/kalimdor/the_barrens.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/the_barrens.cpp
@@ -13,12 +13,14 @@
  * along 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: 863, 898, 1719, 2458, 4921, 6981,
 SDCategory: Barrens
 EndScriptData */
+
 /* ContentData
 npc_beaten_corpse
 npc_gilthares
@@ -27,23 +29,30 @@ npc_taskmaster_fizzule
 npc_twiggy_flathead
 npc_wizzlecrank_shredder
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_beaten_corpse
 ######*/
+
 #define GOSSIP_CORPSE "Examine corpse in detail..."
+
 enum eQuests
 {
     QUEST_LOST_IN_BATTLE    = 4921
 };
+
 bool GossipHello_npc_beaten_corpse(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_LOST_IN_BATTLE) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestStatus(QUEST_LOST_IN_BATTLE) == QUEST_STATUS_COMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CORPSE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(3557, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_beaten_corpse(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF +1)
@@ -53,9 +62,11 @@ bool GossipSelect_npc_beaten_corpse(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*######
 # npc_gilthares
 ######*/
+
 enum eGilthares
 {
     SAY_GIL_START               = -1000370,
@@ -69,19 +80,25 @@ enum eGilthares
     SAY_GIL_ALMOST              = -1000378,
     SAY_GIL_SWEET               = -1000379,
     SAY_GIL_FREED               = -1000380,
+
     QUEST_FREE_FROM_HOLD        = 898,
     AREA_MERCHANT_COAST         = 391,
     FACTION_ESCORTEE            = 232                       //guessed, possible not needed for this quest
 };
+
 struct TRINITY_DLL_DECL npc_giltharesAI : public npc_escortAI
 {
     npc_giltharesAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     void Reset() { }
+
     void WaypointReached(uint32 uiPointId)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(uiPointId)
         {
             case 16:
@@ -105,11 +122,13 @@ struct TRINITY_DLL_DECL npc_giltharesAI : public npc_escortAI
                 break;
         }
     }
+
     void Aggro(Unit* pWho)
     {
         //not always use
         if (rand()%4)
             return;
+
         //only aggro text if not player and only in this area
         if (pWho->GetTypeId() != TYPEID_PLAYER && m_creature->GetAreaId() == AREA_MERCHANT_COAST)
         {
@@ -118,35 +137,45 @@ struct TRINITY_DLL_DECL npc_giltharesAI : public npc_escortAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_gilthares(Creature* pCreature)
 {
     return new npc_giltharesAI(pCreature);
 }
+
 bool QuestAccept_npc_gilthares(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_FREE_FROM_HOLD)
     {
         pCreature->setFaction(FACTION_ESCORTEE);
         pCreature->SetStandState(UNIT_STAND_STATE_STAND);
+
         DoScriptText(SAY_GIL_START, pCreature, pPlayer);
+
         if (npc_giltharesAI* pEscortAI = CAST_AI(npc_giltharesAI, pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
     }
     return true;
 }
+
 /*######
 ## npc_sputtervalve
 ######*/
+
 #define GOSSIP_SPUTTERVALVE "Can you tell me about this shard?"
+
 bool GossipHello_npc_sputtervalve(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(6981) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SPUTTERVALVE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_sputtervalve(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
@@ -156,25 +185,30 @@ bool GossipSelect_npc_sputtervalve(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*######
 ## npc_taskmaster_fizzule
 ######*/
+
 enum eEnums
 {
     FACTION_FRIENDLY_F  = 35,
     SPELL_FLARE         = 10113,
     SPELL_FOLLY         = 10137,
 };
+
 struct TRINITY_DLL_DECL npc_taskmaster_fizzuleAI : public ScriptedAI
 {
     npc_taskmaster_fizzuleAI(Creature* c) : ScriptedAI(c)
     {
         factionNorm = c->getFaction();
     }
+
     uint32 factionNorm;
     bool IsFriend;
     uint32 Reset_Timer;
     uint8 FlareCount;
+
     void Reset()
     {
         IsFriend = false;
@@ -182,26 +216,33 @@ struct TRINITY_DLL_DECL npc_taskmaster_fizzuleAI : public ScriptedAI
         FlareCount = 0;
         m_creature->setFaction(factionNorm);
     }
+
     void DoFriend()
     {
         m_creature->RemoveAllAuras();
         m_creature->DeleteThreatList();
         m_creature->CombatStop(true);
+
         m_creature->StopMoving();
         m_creature->GetMotionMaster()->MoveIdle();
+
         m_creature->setFaction(FACTION_FRIENDLY_F);
         m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_FLARE || spell->Id == SPELL_FOLLY)
         {
             ++FlareCount;
+
             if (FlareCount >= 2)
                 IsFriend = true;
         }
     }
+
     void EnterCombat(Unit* who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (IsFriend)
@@ -212,10 +253,13 @@ struct TRINITY_DLL_DECL npc_taskmaster_fizzuleAI : public ScriptedAI
                 return;
             } else Reset_Timer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void ReceiveEmote(Player* pPlayer, uint32 emote)
     {
         if (emote == TEXTEMOTE_SALUTE)
@@ -224,18 +268,22 @@ struct TRINITY_DLL_DECL npc_taskmaster_fizzuleAI : public ScriptedAI
             {
                 if (m_creature->getFaction() == FACTION_FRIENDLY_F)
                     return;
+
                 DoFriend();
             }
         }
     }
 };
+
 CreatureAI* GetAI_npc_taskmaster_fizzule(Creature* pCreature)
 {
     return new npc_taskmaster_fizzuleAI(pCreature);
 }
+
 /*#####
 ## npc_twiggy_flathead
 #####*/
+
 #define BIG_WILL 6238
 #define AFFRAY_CHALLENGER 6240
 #define SAY_BIG_WILL_READY                  -1000267
@@ -243,6 +291,7 @@ CreatureAI* GetAI_npc_taskmaster_fizzule(Creature* pCreature)
 #define SAY_TWIGGY_FLATHEAD_FRAY            -1000269
 #define SAY_TWIGGY_FLATHEAD_DOWN            -1000270
 #define SAY_TWIGGY_FLATHEAD_OVER            -1000271
+
 float AffrayChallengerLoc[6][4]=
 {
     {-1683, -4326, 2.79, 0},
@@ -252,9 +301,11 @@ float AffrayChallengerLoc[6][4]=
     {-1674, -4326, 2.79, 3.49},
     {-1677, -4334, 2.79, 1.66}
 };
+
 struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI
 {
     npc_twiggy_flatheadAI(Creature *c) : ScriptedAI(c) {}
+
     bool EventInProgress;
     bool EventGrate;
     bool EventBigWill;
@@ -265,6 +316,7 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI
     uint64 PlayerGUID;
     uint64 AffrayChallenger[6];
     uint64 BigWill;
+
     void Reset()
     {
         EventInProgress = false;
@@ -274,37 +326,47 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI
         Challenger_checker = 0;
         Wave = 0;
         PlayerGUID = 0;
-        for (uint8 i = 0; i < 6; ++i)
+
+        for(uint8 i = 0; i < 6; ++i)
         {
             AffrayChallenger[i] = 0;
             Challenger_down[i] = false;
         }
         BigWill = 0;
     }
+
     void EnterCombat(Unit *who) { }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || (!who->isAlive())) return;
+
         if (m_creature->IsWithinDistInMap(who, 10.0f) && (who->GetTypeId() == TYPEID_PLAYER) && CAST_PLR(who)->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE && !EventInProgress)
         {
             PlayerGUID = who->GetGUID();
             EventInProgress = true;
         }
     }
+
     void KilledUnit(Unit *victim) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (EventInProgress) {
             Player* pWarrior = NULL;
+
             if (PlayerGUID)
                 pWarrior = Unit::GetPlayer(PlayerGUID);
+
             if (!pWarrior)
                 return;
+
             if (!pWarrior->isAlive() && pWarrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE) {
                 EventInProgress = false;
                 DoScriptText(SAY_TWIGGY_FLATHEAD_DOWN, m_creature);
                 pWarrior->FailQuest(1719);
-                for (uint8 i = 0; i < 6; ++i)
+
+                for(uint8 i = 0; i < 6; ++i)
                 {
                     if (AffrayChallenger[i])
                     {
@@ -321,6 +383,7 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI
                     AffrayChallenger[i] = 0;
                     Challenger_down[i] = false;
                 }
+
                 if (BigWill)
                 {
                     Creature* pCreature = Unit::GetCreature((*m_creature), BigWill);
@@ -334,14 +397,17 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI
                 }
                 BigWill = 0;
             }
+
             if (!EventGrate && EventInProgress)
             {
                 float x,y,z;
                 pWarrior->GetPosition(x, y, z);
+
                 if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324) {
                     pWarrior->AreaExploredOrEventHappens(1719);
                     DoScriptText(SAY_TWIGGY_FLATHEAD_BEGIN, m_creature);
-                    for (uint8 i = 0; i < 6; ++i)
+
+                    for(uint8 i = 0; i < 6; ++i)
                     {
                         Creature* pCreature = m_creature->SummonCreature(AFFRAY_CHALLENGER, AffrayChallengerLoc[i][0], AffrayChallengerLoc[i][1], AffrayChallengerLoc[i][2], AffrayChallengerLoc[i][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                         if (!pCreature)
@@ -361,7 +427,7 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI
             {
                 if (Challenger_checker < diff)
                 {
-                    for (uint8 i = 0; i < 6; ++i)
+                    for(uint8 i = 0; i < 6; ++i)
                     {
                         if (AffrayChallenger[i])
                         {
@@ -375,6 +441,7 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI
                     }
                     Challenger_checker = 1000;
                 } else Challenger_checker -= diff;
+
                 if (Wave_Timer < diff)
                 {
                     if (AffrayChallenger[Wave] && Wave < 6 && !EventBigWill)
@@ -422,13 +489,16 @@ struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_twiggy_flathead(Creature* pCreature)
 {
     return new npc_twiggy_flatheadAI (pCreature);
 }
+
 /*#####
 ## npc_wizzlecrank_shredder
 #####*/
+
 enum eEnums_Wizzlecrank
 {
     SAY_START           = -1000272,
@@ -439,11 +509,13 @@ enum eEnums_Wizzlecrank
     SAY_PROGRESS_2      = -1000277,
     SAY_PROGRESS_3      = -1000278,
     SAY_END             = -1000279,
+
     QUEST_ESCAPE        = 863,
     FACTION_RATCHET     = 637,
     NPC_PILOT_WIZZ      = 3451,
     NPC_MERCENARY       = 3282,
 };
+
 struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI
 {
     npc_wizzlecrank_shredderAI(Creature* pCreature) : npc_escortAI(pCreature)
@@ -452,25 +524,31 @@ struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI
         m_uiPostEventTimer = 1000;
         m_uiPostEventCount = 0;
     }
+
     bool m_bIsPostEvent;
     uint32 m_uiPostEventTimer;
     uint32 m_uiPostEventCount;
+
     void Reset()
     {
         if (!HasEscortState(STATE_ESCORT_ESCORTING))
         {
             if (m_creature->getStandState() == UNIT_STAND_STATE_DEAD)
                  m_creature->SetStandState(UNIT_STAND_STATE_STAND);
+
             m_bIsPostEvent = false;
             m_uiPostEventTimer = 1000;
             m_uiPostEventCount = 0;
         }
     }
+
     void WaypointReached(uint32 uiPointId)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(uiPointId)
         {
         case 0:
@@ -491,11 +569,14 @@ struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI
             break;
         }
     }
+
     void WaypointStart(uint32 uiPointId)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(uiPointId)
         {
             case 9:
@@ -507,13 +588,16 @@ struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI
                 break;
         }
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (pSummoned->GetEntry() == NPC_PILOT_WIZZ)
             m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
+
         if (pSummoned->GetEntry() == NPC_MERCENARY)
             pSummoned->AI()->AttackStart(m_creature);
     }
+
     void UpdateEscortAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
@@ -541,17 +625,21 @@ struct TRINITY_DLL_DECL npc_wizzlecrank_shredderAI : public npc_escortAI
                             }
                             break;
                     }
+
                     ++m_uiPostEventCount;
                     m_uiPostEventTimer = 5000;
                 }
                 else
                     m_uiPostEventTimer -= uiDiff;
             }
+
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 bool QuestAccept_npc_wizzlecrank_shredder(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_ESCAPE)
@@ -562,36 +650,44 @@ bool QuestAccept_npc_wizzlecrank_shredder(Player* pPlayer, Creature* pCreature,
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_wizzlecrank_shredderAI(Creature* pCreature)
 {
     return new npc_wizzlecrank_shredderAI(pCreature);
 }
+
 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_gilthares";
     newscript->GetAI = &GetAI_npc_gilthares;
     newscript->pQuestAccept = &QuestAccept_npc_gilthares;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_sputtervalve";
     newscript->pGossipHello = &GossipHello_npc_sputtervalve;
     newscript->pGossipSelect = &GossipSelect_npc_sputtervalve;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_taskmaster_fizzule";
     newscript->GetAI = &GetAI_npc_taskmaster_fizzule;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_twiggy_flathead";
     newscript->GetAI = &GetAI_npc_twiggy_flathead;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_wizzlecrank_shredder";
     newscript->GetAI = &GetAI_npc_wizzlecrank_shredderAI;
diff --git a/src/bindings/scripts/scripts/kalimdor/thousand_needles.cpp b/src/bindings/scripts/scripts/kalimdor/thousand_needles.cpp
index c8f19e44edd..9616aa4acf6 100644
--- a/src/bindings/scripts/scripts/kalimdor/thousand_needles.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/thousand_needles.cpp
@@ -13,34 +13,44 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Thousand Needles
 SD%Complete: 100
 SDComment: Support for Quest: 1950, 4770, 4904, 4966
 SDCategory: Thousand Needles
 EndScriptData */
+
 /* ContentData
 npc_kanati
 npc_lakota_windsong
 npc_swiftmountain
 npc_plucky
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*#####
 # npc_kanati
 ######*/
+
 enum eKanati
 {
     SAY_KAN_START              = -1000410,
+
     QUEST_PROTECT_KANATI        = 4966,
     NPC_GALAK_ASS               = 10720
 };
+
 const float m_afGalakLoc[]= {-4867.387695, -1357.353760, -48.226 };
+
 struct TRINITY_DLL_DECL npc_kanatiAI : public npc_escortAI
 {
     npc_kanatiAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     void Reset() { }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
@@ -55,22 +65,26 @@ struct TRINITY_DLL_DECL npc_kanatiAI : public npc_escortAI
                 break;
         }
     }
+
     void DoSpawnGalak()
     {
-        for (int i = 0; i < 3; ++i)
+        for(int i = 0; i < 3; ++i)
             m_creature->SummonCreature(NPC_GALAK_ASS,
             m_afGalakLoc[0], m_afGalakLoc[1], m_afGalakLoc[2], 0.0f,
             TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         pSummoned->AI()->AttackStart(m_creature);
     }
 };
+
 CreatureAI* GetAI_npc_kanati(Creature* pCreature)
 {
     return new npc_kanatiAI(pCreature);
 }
+
 bool QuestAccept_npc_kanati(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_PROTECT_KANATI)
@@ -80,9 +94,11 @@ bool QuestAccept_npc_kanati(Player* pPlayer, Creature* pCreature, const Quest* p
     }
     return true;
 }
+
 /*######
 # npc_lakota_windsong
 ######*/
+
 enum eLakota
 {
     SAY_LAKO_START              = -1000365,
@@ -90,13 +106,16 @@ enum eLakota
     SAY_LAKO_HERE_COME          = -1000367,
     SAY_LAKO_MORE               = -1000368,
     SAY_LAKO_END                = -1000369,
+
     QUEST_FREE_AT_LAST          = 4904,
     NPC_GRIM_BANDIT             = 10758,
     FACTION_ESCORTEE_LAKO       = 232,                      //guessed
+
     ID_AMBUSH_1                 = 0,
     ID_AMBUSH_2                 = 2,
     ID_AMBUSH_3                 = 4
 };
+
 float m_afBanditLoc[6][6]=
 {
     {-4905.479492, -2062.732666, 84.352},
@@ -106,10 +125,13 @@ float m_afBanditLoc[6][6]=
     {-4767.985352, -1873.169189, 90.192},
     {-4788.861328, -1888.007813, 89.888}
 };
+
 struct TRINITY_DLL_DECL npc_lakota_windsongAI : public npc_escortAI
 {
     npc_lakota_windsongAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     void Reset() { }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
@@ -132,51 +154,62 @@ struct TRINITY_DLL_DECL npc_lakota_windsongAI : public npc_escortAI
                 break;
         }
     }
+
     void DoSpawnBandits(int uiAmbushId)
     {
-        for (int i = 0; i < 2; ++i)
+        for(int i = 0; i < 2; ++i)
             m_creature->SummonCreature(NPC_GRIM_BANDIT,
             m_afBanditLoc[i+uiAmbushId][0], m_afBanditLoc[i+uiAmbushId][1], m_afBanditLoc[i+uiAmbushId][2], 0.0f,
             TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000);
     }
 };
+
 CreatureAI* GetAI_npc_lakota_windsong(Creature* pCreature)
 {
     return new npc_lakota_windsongAI(pCreature);
 }
+
 bool QuestAccept_npc_lakota_windsong(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_FREE_AT_LAST)
     {
         DoScriptText(SAY_LAKO_START, pCreature, pPlayer);
         pCreature->setFaction(FACTION_ESCORTEE_LAKO);
+
         if (npc_lakota_windsongAI* pEscortAI = CAST_AI(npc_lakota_windsongAI, pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
     }
     return true;
 }
+
 /*######
 # npc_paoka_swiftmountain
 ######*/
+
 enum ePacka
 {
     SAY_START           = -1000147,
     SAY_WYVERN          = -1000148,
     SAY_COMPLETE        = -1000149,
+
     QUEST_HOMEWARD      = 4770,
     NPC_WYVERN          = 4107,
     FACTION_ESCORTEE    = 232                               //guessed
 };
+
 float m_afWyvernLoc[3][3]=
 {
     {-4990.606, -906.057, -5.343},
     {-4970.241, -927.378, -4.951},
     {-4985.364, -952.528, -5.199}
 };
+
 struct TRINITY_DLL_DECL npc_paoka_swiftmountainAI : public npc_escortAI
 {
     npc_paoka_swiftmountainAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     void Reset() { }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
@@ -194,33 +227,40 @@ struct TRINITY_DLL_DECL npc_paoka_swiftmountainAI : public npc_escortAI
                 break;
         }
     }
+
     void DoSpawnWyvern()
     {
-        for (int i = 0; i < 3; ++i)
+        for(int i = 0; i < 3; ++i)
             m_creature->SummonCreature(NPC_WYVERN,
             m_afWyvernLoc[i][0], m_afWyvernLoc[i][1], m_afWyvernLoc[i][2], 0.0f,
             TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000);
     }
 };
+
 CreatureAI* GetAI_npc_paoka_swiftmountain(Creature* pCreature)
 {
     return new npc_paoka_swiftmountainAI(pCreature);
 }
+
 bool QuestAccept_npc_paoka_swiftmountain(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_HOMEWARD)
     {
         DoScriptText(SAY_START, pCreature, pPlayer);
         pCreature->setFaction(FACTION_ESCORTEE);
+
         if (npc_paoka_swiftmountainAI* pEscortAI = CAST_AI(npc_paoka_swiftmountainAI,pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
     }
     return true;
 }
+
 /*#####
 # npc_plucky
 ######*/
+
 #define GOSSIP_P    "Please tell me the Phrase.."
+
 enum ePlucky
 {
     FACTION_FRIENDLY        = 35,
@@ -228,20 +268,27 @@ enum ePlucky
     SPELL_PLUCKY_HUMAN      = 9192,
     SPELL_PLUCKY_CHICKEN    = 9220
 };
+
 struct TRINITY_DLL_DECL npc_pluckyAI : public ScriptedAI
 {
     npc_pluckyAI(Creature *c) : ScriptedAI(c) { m_uiNormFaction = c->getFaction(); }
+
     uint32 m_uiNormFaction;
     uint32 m_uiResetTimer;
+
     void Reset()
     {
         m_uiResetTimer = 120000;
+
         if (m_creature->getFaction() != m_uiNormFaction)
             m_creature->setFaction(m_uiNormFaction);
+
         if (m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP))
             m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+
         m_creature->CastSpell(m_creature, SPELL_PLUCKY_CHICKEN, false);
     }
+
     void ReceiveEmote(Player* pPlayer, uint32 uiTextEmote)
     {
         if (pPlayer->GetQuestStatus(QUEST_SCOOP) == QUEST_STATUS_INCOMPLETE)
@@ -253,6 +300,7 @@ struct TRINITY_DLL_DECL npc_pluckyAI : public ScriptedAI
                 m_creature->CastSpell(m_creature, SPELL_PLUCKY_HUMAN, false);
             }
         }
+
         if (uiTextEmote == TEXTEMOTE_CHICKEN)
         {
             if (m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP))
@@ -266,6 +314,7 @@ struct TRINITY_DLL_DECL npc_pluckyAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP))
@@ -276,23 +325,29 @@ struct TRINITY_DLL_DECL npc_pluckyAI : public ScriptedAI
                     EnterEvadeMode();
                 else
                     m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+
                 return;
             }
             else
                 m_uiResetTimer -= uiDiff;
         }
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 bool GossipHello_npc_plucky(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_SCOOP) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_P, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     pPlayer->SEND_GOSSIP_MENU(738, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_plucky(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -304,31 +359,38 @@ bool GossipSelect_npc_plucky(Player* pPlayer, Creature* pCreature, uint32 uiSend
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_plucky(Creature* pCreature)
 {
     return new npc_pluckyAI(pCreature);
 }
+
 /*#####
 #
 ######*/
+
 void AddSC_thousand_needles()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_kanati";
     newscript->GetAI = &GetAI_npc_kanati;
     newscript->pQuestAccept = &QuestAccept_npc_kanati;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_lakota_windsong";
     newscript->GetAI = &GetAI_npc_lakota_windsong;
     newscript->pQuestAccept = &QuestAccept_npc_lakota_windsong;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_paoka_swiftmountain";
     newscript->GetAI = &GetAI_npc_paoka_swiftmountain;
     newscript->pQuestAccept = &QuestAccept_npc_paoka_swiftmountain;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_plucky";
     newscript->GetAI = &GetAI_npc_plucky;
diff --git a/src/bindings/scripts/scripts/kalimdor/thunder_bluff.cpp b/src/bindings/scripts/scripts/kalimdor/thunder_bluff.cpp
index f5b5c49ae6c..f94a31a0dc9 100644
--- a/src/bindings/scripts/scripts/kalimdor/thunder_bluff.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/thunder_bluff.cpp
@@ -13,31 +13,38 @@
  * along 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
+
 #define GOSSIP_HCB "I know this is rather silly but a young ward who is a bit shy would like your hoofprint."
 //TODO: verify abilities/timers
 struct TRINITY_DLL_DECL npc_cairne_bloodhoofAI : public ScriptedAI
 {
     npc_cairne_bloodhoofAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 BerserkerCharge_Timer;
     uint32 Cleave_Timer;
     uint32 MortalStrike_Timer;
     uint32 Thunderclap_Timer;
     uint32 Uppercut_Timer;
+
     void Reset()
     {
         BerserkerCharge_Timer = 30000;
@@ -46,11 +53,14 @@ struct TRINITY_DLL_DECL npc_cairne_bloodhoofAI : public ScriptedAI
         Thunderclap_Timer = 15000;
         Uppercut_Timer = 10000;
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (BerserkerCharge_Timer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
@@ -58,26 +68,31 @@ struct TRINITY_DLL_DECL npc_cairne_bloodhoofAI : public ScriptedAI
                 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();
     }
 };
@@ -85,15 +100,20 @@ CreatureAI* GetAI_npc_cairne_bloodhoof(Creature* pCreature)
 {
     return new npc_cairne_bloodhoofAI (pCreature);
 }
+
 bool GossipHello_npc_cairne_bloodhoof(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(925) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HCB, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO);
+
     pPlayer->SEND_GOSSIP_MENU(7013, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_cairne_bloodhoof(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_SENDER_INFO)
@@ -103,9 +123,11 @@ bool GossipSelect_npc_cairne_bloodhoof(Player* pPlayer, Creature* pCreature, uin
     }
     return true;
 }
+
 void AddSC_thunder_bluff()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_cairne_bloodhoof";
     newscript->GetAI = &GetAI_npc_cairne_bloodhoof;
diff --git a/src/bindings/scripts/scripts/kalimdor/ungoro_crater.cpp b/src/bindings/scripts/scripts/kalimdor/ungoro_crater.cpp
index cc20f7c1022..eac657fd727 100644
--- a/src/bindings/scripts/scripts/kalimdor/ungoro_crater.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/ungoro_crater.cpp
@@ -13,42 +13,54 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
+
 /* ScriptData
 SDName: Ungoro Crater
 SD%Complete: 100
 SDComment: Support for Quest: 4245, 4491
 SDCategory: Ungoro Crater
 EndScriptData */
+
 /* ContentData
 npc_a-me
 npc_ringo
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "follower_ai.h"
+
 #define SAY_READY -1000200
 #define SAY_AGGRO1 -1000201
 #define SAY_SEARCH -1000202
 #define SAY_AGGRO2 -1000203
 #define SAY_AGGRO3 -1000204
 #define SAY_FINISH -1000205
+
 #define SPELL_DEMORALIZINGSHOUT  13730
+
 #define QUEST_CHASING_AME 4245
 #define ENTRY_TARLORD 6519
 #define ENTRY_TARLORD1 6519
 #define ENTRY_STOMPER 6513
 
+
 struct TRINITY_DLL_DECL npc_ameAI : public npc_escortAI
 {
     npc_ameAI(Creature *c) : npc_escortAI(c) {}
+
     uint32 DEMORALIZINGSHOUT_Timer;
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch (i)
         {
+
          case 19:
             m_creature->SummonCreature(ENTRY_STOMPER, -6391.69, -1730.49, -272.83, 4.96, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
             DoScriptText(SAY_AGGRO1, m_creature, pPlayer);
@@ -69,33 +81,41 @@ struct TRINITY_DLL_DECL npc_ameAI : public npc_escortAI
             if (pPlayer)
                 pPlayer->GroupEventHappens(QUEST_CHASING_AME,m_creature);
             break;
+
         }
     }
+
     void Reset()
     {
       DEMORALIZINGSHOUT_Timer = 5000;
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
+
     void JustDied(Unit* killer)
     {
         if (Player* pPlayer = GetPlayerForEscort())
             pPlayer->FailQuest(QUEST_CHASING_AME);
     }
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
         if (!UpdateVictim())
             return;
+
         if (DEMORALIZINGSHOUT_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_DEMORALIZINGSHOUT);
             DEMORALIZINGSHOUT_Timer = 70000;
         }else DEMORALIZINGSHOUT_Timer -= diff;
+
     }
 };
+
 bool QuestAccept_npc_ame(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_CHASING_AME)
@@ -108,25 +128,31 @@ bool QuestAccept_npc_ame(Player* pPlayer, Creature* pCreature, Quest const* ques
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_ame(Creature* pCreature)
 {
     return new npc_ameAI(pCreature);
 }
+
 /*####
 # npc_ringo
 ####*/
+
 enum eRingo
 {
     SAY_RIN_START_1             = -1000416,
     SAY_RIN_START_2             = -1000417,
+
     SAY_FAINT_1                 = -1000418,
     SAY_FAINT_2                 = -1000419,
     SAY_FAINT_3                 = -1000420,
     SAY_FAINT_4                 = -1000421,
+
     SAY_WAKE_1                  = -1000422,
     SAY_WAKE_2                  = -1000423,
     SAY_WAKE_3                  = -1000424,
     SAY_WAKE_4                  = -1000425,
+
     SAY_RIN_END_1               = -1000426,
     SAY_SPR_END_2               = -1000427,
     SAY_RIN_END_3               = -1000428,
@@ -135,18 +161,23 @@ enum eRingo
     SAY_RIN_END_6               = -1000431, // signed for 6784
     SAY_SPR_END_7               = -1000432,
     EMOTE_RIN_END_8             = -1000433,
+
     SPELL_REVIVE_RINGO          = 15591,
     QUEST_A_LITTLE_HELP         = 4491,
     NPC_SPRAGGLE                = 9997,
     FACTION_ESCORTEE            = 113
 };
+
 struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
 {
     npc_ringoAI(Creature* pCreature) : FollowerAI(pCreature) { }
+
     uint32 m_uiFaintTimer;
     uint32 m_uiEndEventProgress;
     uint32 m_uiEndEventTimer;
+
     Unit* pSpraggle;
+
     void Reset()
     {
         m_uiFaintTimer = urand(30000, 60000);
@@ -154,9 +185,11 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
         m_uiEndEventTimer = 1000;
         pSpraggle = NULL;
     }
+
     void MoveInLineOfSight(Unit *pWho)
     {
         FollowerAI::MoveInLineOfSight(pWho);
+
         if (!m_creature->getVictim() && !HasFollowState(STATE_FOLLOW_COMPLETE) && pWho->GetEntry() == NPC_SPRAGGLE)
         {
             if (m_creature->IsWithinDistInMap(pWho, INTERACTION_DISTANCE))
@@ -166,34 +199,44 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
                     if (pPlayer->GetQuestStatus(QUEST_A_LITTLE_HELP) == QUEST_STATUS_INCOMPLETE)
                         pPlayer->GroupEventHappens(QUEST_A_LITTLE_HELP, m_creature);
                 }
+
                 pSpraggle = pWho;
                 SetFollowComplete(true);
             }
         }
     }
+
     void SpellHit(Unit* pCaster, const SpellEntry* pSpell)
     {
         if (HasFollowState(STATE_FOLLOW_INPROGRESS | STATE_FOLLOW_PAUSED) && pSpell->Id == SPELL_REVIVE_RINGO)
             ClearFaint();
     }
+
     void SetFaint()
     {
         if (!HasFollowState(STATE_FOLLOW_POSTEVENT))
         {
             SetFollowPaused(true);
+
             DoScriptText(RAND(SAY_FAINT_1,SAY_FAINT_2,SAY_FAINT_3,SAY_FAINT_4), m_creature);
         }
+
         //what does actually happen here? Emote? Aura?
         m_creature->SetStandState(UNIT_STAND_STATE_SLEEP);
     }
+
     void ClearFaint()
     {
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
+
         if (HasFollowState(STATE_FOLLOW_POSTEVENT))
             return;
+
         DoScriptText(RAND(SAY_WAKE_1,SAY_WAKE_2,SAY_WAKE_3,SAY_WAKE_4), m_creature);
+
         SetFollowPaused(false);
     }
+
     void UpdateFollowerAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
@@ -207,6 +250,7 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
                         SetFollowComplete();
                         return;
                     }
+
                     switch(m_uiEndEventProgress)
                     {
                         case 1:
@@ -247,6 +291,7 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
                             SetFollowComplete();
                             break;
                     }
+
                     ++m_uiEndEventProgress;
                 }
                 else
@@ -265,15 +310,19 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
                         m_uiFaintTimer -= uiDiff;
                 }
             }
+
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_ringo(Creature* pCreature)
 {
     return new npc_ringoAI(pCreature);
 }
+
 bool QuestAccept_npc_ringo(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_A_LITTLE_HELP)
@@ -284,16 +333,20 @@ bool QuestAccept_npc_ringo(Player* pPlayer, Creature* pCreature, const Quest* pQ
             pRingoAI->StartFollow(pPlayer, FACTION_ESCORTEE, pQuest);
         }
     }
+
     return true;
 }
+
 void AddSC_ungoro_crater()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_ame";
     newscript->GetAI = &GetAI_npc_ame;
     newscript->pQuestAccept = &QuestAccept_npc_ame;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_ringo";
     newscript->GetAI = &GetAI_npc_ringo;
diff --git a/src/bindings/scripts/scripts/kalimdor/wailing_caverns/def_wailing_caverns.h b/src/bindings/scripts/scripts/kalimdor/wailing_caverns/def_wailing_caverns.h
index 87a93c9a386..f6c7bee8571 100644
--- a/src/bindings/scripts/scripts/kalimdor/wailing_caverns/def_wailing_caverns.h
+++ b/src/bindings/scripts/scripts/kalimdor/wailing_caverns/def_wailing_caverns.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_WAILING_CAVERNS_H
 #define DEF_WAILING_CAVERNS_H
+
 enum eTypes
 {
     TYPE_LORD_COBRAHN         = 1,
@@ -15,6 +17,8 @@ enum eTypes
     TYPE_NARALEX_PART3        = 8,
     TYPE_MUTANUS_THE_DEVOURER = 9,
     TYPE_NARALEX_YELLED       = 10,
+
     DATA_NARALEX              = 3679,
 };
-#endif
+
+#endif
\ No newline at end of file
diff --git a/src/bindings/scripts/scripts/kalimdor/wailing_caverns/instance_wailing_caverns.cpp b/src/bindings/scripts/scripts/kalimdor/wailing_caverns/instance_wailing_caverns.cpp
index c446c3beb6b..d955226e1c3 100644
--- a/src/bindings/scripts/scripts/kalimdor/wailing_caverns/instance_wailing_caverns.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/wailing_caverns/instance_wailing_caverns.cpp
@@ -13,32 +13,42 @@
  * along 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: 99
 SDComment: Everything seems to work, still need some checking
 SDCategory: Wailing Caverns
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_wailing_caverns.h"
+
 #define MAX_ENCOUNTER   9
+
 struct TRINITY_DLL_DECL instance_wailing_caverns : public ScriptedInstance
 {
     instance_wailing_caverns(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     bool yelled;
     uint64 NaralexGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         yelled = false;
         NaralexGUID = 0;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         if (pCreature->GetEntry() == DATA_NARALEX)
             NaralexGUID = pCreature->GetGUID();
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch (type)
@@ -56,6 +66,7 @@ struct TRINITY_DLL_DECL instance_wailing_caverns : public ScriptedInstance
         }
         if (data == DONE)SaveToDB();
     }
+
     uint32 GetData(uint32 type)
     {
         switch (type)
@@ -73,21 +84,26 @@ struct TRINITY_DLL_DECL instance_wailing_caverns : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 data)
     {
         if (data == DATA_NARALEX)return NaralexGUID;
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::ostringstream saveStream;
         saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
             << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " "
             << m_auiEncounter[6] << " " << m_auiEncounter[7] << " " << m_auiEncounter[8];
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return saveStream.str();
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -95,20 +111,27 @@ struct TRINITY_DLL_DECL instance_wailing_caverns : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         std::istringstream loadStream(in);
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3]
         >> m_auiEncounter[4] >> m_auiEncounter[5] >> m_auiEncounter[6] >> m_auiEncounter[7] >> m_auiEncounter[8];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] != DONE)
                 m_auiEncounter[i] = NOT_STARTED;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
+
 };
+
 InstanceData* GetInstanceData_instance_wailing_caverns(Map* pMap)
 {
     return new instance_wailing_caverns(pMap);
 }
+
 void AddSC_instance_wailing_caverns()
 {
     Script *newscript;
@@ -116,4 +139,4 @@ void AddSC_instance_wailing_caverns()
     newscript->Name = "instance_wailing_caverns";
     newscript->GetInstanceData = &GetInstanceData_instance_wailing_caverns;
     newscript->RegisterSelf();
-}
+}
\ No newline at end of file
diff --git a/src/bindings/scripts/scripts/kalimdor/wailing_caverns/wailing_caverns.cpp b/src/bindings/scripts/scripts/kalimdor/wailing_caverns/wailing_caverns.cpp
index 75c23a4121e..d734e32d13b 100644
--- a/src/bindings/scripts/scripts/kalimdor/wailing_caverns/wailing_caverns.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/wailing_caverns/wailing_caverns.cpp
@@ -13,20 +13,25 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: Wailing Caverns
 SD%Complete: 95
 SDComment: Need to add skill usage for Disciple of Naralex
 SDCategory: Wailing Caverns
 EndScriptData */
+
 /* ContentData
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "def_wailing_caverns.h"
+
 /*######
 ## npc_disciple_of_naralex
 ######*/
+
 enum eEnums
 {
     //say
@@ -62,10 +67,12 @@ enum eEnums
     NPC_NIGHTMARE_ECTOPLASM       = 5763,
     NPC_MUTANUS_THE_DEVOURER      = 3654,
 };
+
 #define GOSSIP_ID_START_1       698  //Naralex sleeps again!
 #define GOSSIP_ID_START_2       699  //The fanglords are dead!
 #define GOSSIP_ITEM_NARALEX     "Let the event begin!"
 #define ACHIEVEMENT_WAILING_CAVERNS 630
+
 struct TRINITY_DLL_DECL npc_disciple_of_naralexAI : public npc_escortAI
 {
     npc_disciple_of_naralexAI(Creature *c) : npc_escortAI(c)
@@ -77,14 +84,17 @@ struct TRINITY_DLL_DECL npc_disciple_of_naralexAI : public npc_escortAI
         m_creature->setActive(true);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
     }
+
     uint32 eventTimer;
     uint32 currentEvent;
     uint32 eventProgress;
     ScriptedInstance *pInstance;
+
     void WaypointReached(uint32 i)
     {
         if (!pInstance)
             return;
+
         switch (i)
         {
             case 4:
@@ -111,13 +121,17 @@ struct TRINITY_DLL_DECL npc_disciple_of_naralexAI : public npc_escortAI
             break;
         }
     }
+
     void Reset()
     {
+
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_ATTACKED, m_creature, who);
     }
+
     void JustDied(Unit *slayer)
     {
         if (pInstance)
@@ -128,14 +142,17 @@ struct TRINITY_DLL_DECL npc_disciple_of_naralexAI : public npc_escortAI
             pInstance->SetData(TYPE_NARALEX_PART3, FAIL);
         }
     }
+
     void JustSummoned(Creature* summoned)
     {
          summoned->AI()->AttackStart(m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (currentEvent != TYPE_NARALEX_PART3)
             npc_escortAI::UpdateAI(diff);
+
         if (!pInstance)
             return;
         if (eventTimer <= diff)
@@ -244,7 +261,7 @@ struct TRINITY_DLL_DECL npc_disciple_of_naralexAI : public npc_escortAI
                                     if (pMap && pMap->IsDungeon())
                                     {
                                         Map::PlayerList const &players = pMap->GetPlayers();
-                                        for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                                        for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                                             itr->getSource()->CompletedAchievement(AchievWC);
                                     }
                                 }
@@ -312,13 +329,16 @@ struct TRINITY_DLL_DECL npc_disciple_of_naralexAI : public npc_escortAI
         }else eventTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_npc_disciple_of_naralex(Creature* pCreature)
 {
     return new npc_disciple_of_naralexAI(pCreature);
 }
+
 bool GossipHello_npc_disciple_of_naralex(Player* pPlayer, Creature* pCreature)
 {
     ScriptedInstance *pInstance = pCreature->GetInstanceData();
+
     if (pInstance)
     {
         pCreature->CastSpell(pPlayer, SPELL_MARK_OF_THE_WILD_RANK_2, true);
@@ -327,6 +347,7 @@ bool GossipHello_npc_disciple_of_naralex(Player* pPlayer, Creature* pCreature)
         {
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_NARALEX, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
             pPlayer->SEND_GOSSIP_MENU(GOSSIP_ID_START_2, pCreature->GetGUID());
+
             if (!pInstance->GetData(TYPE_NARALEX_YELLED))
             {
                 DoScriptText(SAY_AT_LAST, pCreature);
@@ -340,6 +361,7 @@ bool GossipHello_npc_disciple_of_naralex(Player* pPlayer, Creature* pCreature)
     }
     return true;
 }
+
 bool GossipSelect_npc_disciple_of_naralex(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     ScriptedInstance *pInstance = pCreature->GetInstanceData();
@@ -348,18 +370,23 @@ bool GossipSelect_npc_disciple_of_naralex(Player* pPlayer, Creature* pCreature,
         pPlayer->CLOSE_GOSSIP_MENU();
         if (pInstance)
             pInstance->SetData(TYPE_NARALEX_EVENT, IN_PROGRESS);
+
         DoScriptText(SAY_MAKE_PREPARATIONS, pCreature);
+
         pCreature->setFaction(250);
         pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
+
         CAST_AI(npc_escortAI, (pCreature->AI()))->Start(false, false, pPlayer->GetGUID());
         CAST_AI(npc_escortAI, (pCreature->AI()))->SetDespawnAtFar(false);
         CAST_AI(npc_escortAI, (pCreature->AI()))->SetDespawnAtEnd(false);
     }
     return true;
 }
+
 void AddSC_wailing_caverns()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_disciple_of_naralex";
     newscript->pGossipHello =  &GossipHello_npc_disciple_of_naralex;
diff --git a/src/bindings/scripts/scripts/kalimdor/winterspring.cpp b/src/bindings/scripts/scripts/kalimdor/winterspring.cpp
index ba9e628a270..cf4f019f705 100644
--- a/src/bindings/scripts/scripts/kalimdor/winterspring.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/winterspring.cpp
@@ -13,36 +13,47 @@
  * along 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
 ######*/
+
 #define GOSSIP_HL "Talk to me"
+
 #define GOSSIP_SL1 "What do you do here?"
 #define GOSSIP_SL2 "I can help you"
 #define GOSSIP_SL3 "What deal?"
 #define GOSSIP_SL4 "Then what happened?"
 #define GOSSIP_SL5 "He is not safe, i'll make sure of that."
+
 bool GossipHello_npc_lorax(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(5126) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_lorax(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -74,40 +85,53 @@ bool GossipSelect_npc_lorax(Player* pPlayer, Creature* pCreature, uint32 uiSende
     }
     return true;
 }
+
 /*######
 ## npc_rivern_frostwind
 ######*/
+
 bool GossipHello_npc_rivern_frostwind(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor() && pPlayer->GetReputationRank(589) == REP_EXALTED)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_rivern_frostwind(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 ## npc_witch_doctor_mauari
 ######*/
+
 #define GOSSIP_HWDM "I'd like you to make me a new Cache of Mau'ari please."
+
 bool GossipHello_npc_witch_doctor_mauari(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestRewardStatus(975))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HWDM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->SEND_GOSSIP_MENU(3377, pCreature->GetGUID());
     }else
         pPlayer->SEND_GOSSIP_MENU(3375, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_witch_doctor_mauari(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction ==GOSSIP_ACTION_INFO_DEF+1)
@@ -115,21 +139,26 @@ bool GossipSelect_npc_witch_doctor_mauari(Player* pPlayer, Creature* pCreature,
         pPlayer->CLOSE_GOSSIP_MENU();
         pCreature->CastSpell(pPlayer, 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_rivern_frostwind";
     newscript->pGossipHello =  &GossipHello_npc_rivern_frostwind;
     newscript->pGossipSelect = &GossipSelect_npc_rivern_frostwind;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_witch_doctor_mauari";
     newscript->pGossipHello =  &GossipHello_npc_witch_doctor_mauari;
diff --git a/src/bindings/scripts/scripts/kalimdor/zulfarrak/zulfarrak.cpp b/src/bindings/scripts/scripts/kalimdor/zulfarrak/zulfarrak.cpp
index 97c62595708..d0111410bbd 100644
--- a/src/bindings/scripts/scripts/kalimdor/zulfarrak/zulfarrak.cpp
+++ b/src/bindings/scripts/scripts/kalimdor/zulfarrak/zulfarrak.cpp
@@ -13,66 +13,85 @@
  * along 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 TRINITY_DLL_DECL npc_sergeant_blyAI : public ScriptedAI
 {
     npc_sergeant_blyAI(Creature *c) : ScriptedAI(c)
     {
         //pInstance = c->GetInstanceData();
     }
+
     //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. Trinity support required.
+
     void Reset()
     {
         ShieldBash_Timer = 5000;
         Revenge_Timer = 8000;
+
         m_creature->setFaction(FACTION_FRIENDLY);
+
         /*if (pInstance)
             pInstance->SetData(0, NOT_STARTED);*/
     }
+
     void EnterCombat(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 (!UpdateVictim())
             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();
     }
 };
@@ -80,6 +99,7 @@ CreatureAI* GetAI_npc_sergeant_bly(Creature* pCreature)
 {
     return new npc_sergeant_blyAI (pCreature);
 }
+
 bool GossipHello_npc_sergeant_bly(Player* pPlayer, Creature* pCreature)
 {
     /*if (pInstance->GetData(0) == DONE)
@@ -91,8 +111,10 @@ bool GossipHello_npc_sergeant_bly(Player* pPlayer, Creature* pCreature)
         pPlayer->SEND_GOSSIP_MENU(1516, pCreature->GetGUID());
     else
         pPlayer->SEND_GOSSIP_MENU(1515, pCreature->GetGUID());*/
+
     return true;
 }
+
 bool GossipSelect_npc_sergeant_bly(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -103,40 +125,50 @@ bool GossipSelect_npc_sergeant_bly(Player* pPlayer, Creature* pCreature, uint32
     }
     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 TRINITY_DLL_DECL npc_weegli_blastfuseAI : public ScriptedAI
 {
     npc_weegli_blastfuseAI(Creature *c) : ScriptedAI(c)
     {
         //pInstance = c->GetInstanceData();
     }
+
     //ScriptedInstance* pInstance;
+
     void Reset()
     {
         /*if (pInstance)
             pInstance->SetData(0, NOT_STARTED);*/
     }
+
     void EnterCombat(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 (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -144,6 +176,7 @@ CreatureAI* GetAI_npc_weegli_blastfuse(Creature* pCreature)
 {
     return new npc_weegli_blastfuseAI (pCreature);
 }
+
 bool GossipHello_npc_weegli_blastfuse(Player* pPlayer, Creature* pCreature)
 {
     //event not implemented yet, this is only placeholder for future developement
@@ -158,6 +191,7 @@ bool GossipHello_npc_weegli_blastfuse(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(1511, pCreature->GetGUID());   //if event not started
     return true;
 }
+
 bool GossipSelect_npc_weegli_blastfuse(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -167,15 +201,18 @@ bool GossipSelect_npc_weegli_blastfuse(Player* pPlayer, Creature* pCreature, uin
     }
     return true;
 }
+
 /*######
 ## go_shallow_grave
 ######*/
+
 enum {
     ZOMBIE = 7286,
     DEAD_HERO = 7276,
     ZOMBIE_CHANCE = 65,
     DEAD_HERO_CHANCE = 10
 };
+
 bool GOHello_go_shallow_grave(Player* pPlayer, GameObject* pGo)
 {
     // randomly summon a zombie or dead hero the first time a grave is used
@@ -190,42 +227,53 @@ bool GOHello_go_shallow_grave(Player* pPlayer, GameObject* pGo)
     pGo->AddUse();
     return false;
 }
+
 /*######
 ## at_zumrah
 ######*/
+
 enum {
     ZUMRAH_ID = 7271,
     ZUMRAH_HOSTILE_FACTION = 37
 };
+
 bool AreaTrigger_at_zumrah(Player* pPlayer, AreaTriggerEntry *at)
 {
     Creature* Zumrah = pPlayer->FindNearestCreature(ZUMRAH_ID, 30.0f);
+
     if (!Zumrah)
         return false;
+
     Zumrah->setFaction(ZUMRAH_HOSTILE_FACTION);
     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;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_shallow_grave";
     newscript->pGOHello = &GOHello_go_shallow_grave;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "at_zumrah";
     newscript->pAreaTrigger = &AreaTrigger_at_zumrah;
     newscript->RegisterSelf();
+
 }
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_amanitar.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_amanitar.cpp
index caad936d0f9..8a77a455da0 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_amanitar.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_amanitar.cpp
@@ -15,6 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* Script Data Start
 SDName: boss_amanitar
 SDAuthor: WarHead
@@ -22,23 +23,31 @@ SD%Complete: 80%
 SDComment:  Find correct mushrooms spell to make them visible - buffs of the mushrooms not ever applied to the users...
 SDCategory: Ahn'kahet
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_amanitar' where entry = '30258';
 UPDATE `creature_template` SET `ScriptName`='mob_amanitar_mushrooms' WHERE `entry` IN ('30435','30391');
 *** SQL END ***/
+
 #include "precompiled.h"
 #include "def_ahnkahet.h"
+
 #define SPELL_BASH              57094 // Victim
 #define SPELL_ENTANGLING_ROOTS  57095 // Random Victim 100Y
 #define SPELL_MINI              57055 // Self
 #define SPELL_VENOM_BOLT_VOLLEY 57088 // Random Victim 100Y
+
 #define HEALTHY_MUSHROOM_SPELL_POTENT_FUNGUS    56648 // Killer 3Y
+
 #define POISONOUS_MUSHROOM_SPELL_POISON_CLOUD   57061 // Self - Duration 8 Sec
 #define POISONOUS_MUSHROOM_SPELL_VISUAL_AREA    61566 // Self
 #define POISONOUS_MUSHROOM_SPELL_VISUAL_AURA    56741 // Self
+
 #define SPELL_PUTRID_MUSHROOM   31690 // To make the mushrooms visible
+
 #define HealthyMushroom     30391
 #define PoisonousMushroom   30435
+
 struct MANGOS_DLL_DECL boss_amanitarAI : public ScriptedAI
 {
     boss_amanitarAI(Creature *c) : ScriptedAI(c)
@@ -46,26 +55,35 @@ struct MANGOS_DLL_DECL boss_amanitarAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         FirstTime = true;
     }
+
     ScriptedInstance* pInstance;
+
     uint32 roottimer,
         bashtimer,
         bolttimer,
         spawntimer;
+
     bool FirstTime;
+
     void Reset()
     {
         roottimer = urand(5000,9000);
         bashtimer = urand(10000,14000);
         bolttimer = urand(15000,30000);
         spawntimer = 0;
+
         m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_NATURE);
         m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true);
+
         if (pInstance && !FirstTime)
             pInstance->SetData(DATA_AMANITAR, FAIL);
+
         FirstTime = false;
+
         if (pInstance)
             pInstance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MINI);
     }
+
     void JustDied(Unit *Killer)
     {
         if (pInstance)
@@ -74,20 +92,26 @@ struct MANGOS_DLL_DECL boss_amanitarAI : public ScriptedAI
             pInstance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MINI);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->SetInCombatWithZone();
+
         if (pInstance) pInstance->SetData(DATA_AMANITAR, IN_PROGRESS);
+
         m_creature->CastSpell(m_creature, SPELL_MINI, false);
     }
+
     void SpawnAdds()
     {
         uint32 DSpwTime = 30000;
         float x = 0.0f, y = 0.0f, z = 0.0f;
         TempSummonType DSpwType = TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN;
+
         for (uint8 i = 0; i < 30; ++i)
         {
             Unit* victim = SelectUnit(SELECT_TARGET_RANDOM, 0);
+
             if (victim)
             {
                 Position pos;
@@ -98,53 +122,66 @@ struct MANGOS_DLL_DECL boss_amanitarAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim()) return;
+
         if (spawntimer < diff)
         {
             SpawnAdds();
             spawntimer = urand(35000,40000);
         } else spawntimer -= diff;
+
         if (roottimer < diff)
         {
             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 m_creature->CastSpell(target, SPELL_ENTANGLING_ROOTS, false);
             roottimer = urand(15000,30000);
         }
+
         if (bashtimer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(), SPELL_BASH, false);
             bashtimer = urand(15000,30000);
         } else bashtimer -= diff;
+
         if (bolttimer < diff)
         {
             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 m_creature->CastSpell(target, SPELL_VENOM_BOLT_VOLLEY, false);
             bolttimer = urand(15000,30000);
         } else bolttimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct MANGOS_DLL_DECL mob_amanitar_mushroomsAI : public Scripted_NoMovementAI
 {
     mob_amanitar_mushroomsAI(Creature* c) : Scripted_NoMovementAI(c)
     {
         c->SetUInt32Value(UNIT_FIELD_DISPLAYID, 26981); // Unsichtbar...
     }
+
     uint32 auratimer,
         deathtimer; // Without not all will despawn after 30000! :-(
+
     void Reset()
     {
         m_creature->CastSpell(m_creature, SPELL_PUTRID_MUSHROOM, true); // Hack, to make the mushrooms visible, can't find orig. spell...
+
         if (m_creature->GetEntry() == PoisonousMushroom) m_creature->CastSpell(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AURA, true);
+
         auratimer = 0;
         deathtimer = 30000;
     }
+
     void DamageTaken(Unit *killer, uint32 &damage)
     {
         if (!killer || !damage) return;
+
         if (m_creature->GetEntry() == HealthyMushroom && damage >= m_creature->GetHealth())
         {
             if (killer->GetTypeId() == TYPEID_PLAYER && m_creature->GetDistance(killer) <= 3.0f)
@@ -154,8 +191,10 @@ struct MANGOS_DLL_DECL mob_amanitar_mushroomsAI : public Scripted_NoMovementAI
             }
         }
     }
+
     void EnterCombat(Unit *who) { }
     void AttackStart(Unit *victim) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (m_creature->GetEntry() == PoisonousMushroom)
@@ -175,21 +214,26 @@ struct MANGOS_DLL_DECL mob_amanitar_mushroomsAI : public Scripted_NoMovementAI
         } else deathtimer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_amanitar(Creature* pCreature)
 {
     return new boss_amanitarAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_amanitar_mushrooms(Creature *pCreature)
 {
     return new mob_amanitar_mushroomsAI (pCreature);
 }
+
 void AddSC_boss_amanitar()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_amanitar";
     newscript->GetAI = &GetAI_boss_amanitar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_amanitar_mushrooms";
     newscript->GetAI = &GetAI_mob_amanitar_mushrooms;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_elder_nadox.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_elder_nadox.cpp
index 654ae06190e..35827c0aac1 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_elder_nadox.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_elder_nadox.cpp
@@ -15,16 +15,21 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: boss_elder_nadox
 SD%Complete: 100
 SDComment:
 SDCategory: Ahn'kahet
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_ahnkahet.h"
+
 bool DeadAhnkaharGuardian; // needed for achievement: Respect Your Elders(2038)
+
 #define ACHIEVEMENT_RESPECT_YOUR_ELDERS     2038
+
 //not in db
 #define SAY_AGGRO                              -1619014
 #define SAY_SLAY_1                             -1619015
@@ -33,16 +38,21 @@ bool DeadAhnkaharGuardian; // needed for achievement: Respect Your Elders(2038)
 #define SAY_DEATH                              -1619018
 #define SAY_EGG_SAC_1                          -1619019
 #define SAY_EGG_SAC_2                          -1619020
+
 #define SPELL_BROOD_PLAGUE                  56130
 #define H_SPELL_BROOD_PLAGUE                59467
 #define H_SPELL_BROOD_RAGE                  59465
 #define SPELL_ENRAGE                        26662// Enraged if too far away from home
+
 #define MOB_AHNKAHAR_SWARMER                30178
 #define SPELL_SUMMON_SWARMERS               56119//2x 30178  -- 2x every 10secs
+
 #define MOB_AHNKAHAR_GUARDIAN_ENTRY         30176
 #define SPELL_SUMMON_SWARM_GUARD            56120//1x 30176  -- every 25secs
 #define SPELL_GUARDIAN_AURA                 56151
+
 #define EMOTE_HATCHES                       "An Ahn'kahar Guardian hatches!"
+
 struct TRINITY_DLL_DECL boss_elder_nadoxAI : public ScriptedAI
 {
     boss_elder_nadoxAI(Creature *c) : ScriptedAI(c)
@@ -50,40 +60,53 @@ struct TRINITY_DLL_DECL boss_elder_nadoxAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
     uint32 plague_Timer;
     uint32 rage_Timer;
+
     uint32 swarmer_spawn_Timer;
     uint32 guard_spawn_Timer;
     uint32 enrage_Timer;
 
+
     ScriptedInstance *pInstance;
+
     void Reset()
     {
         plague_Timer = 13000;
         rage_Timer = 20000;
+
         swarmer_spawn_Timer = 10000;
         guard_spawn_Timer = 25000;
+
         enrage_Timer = 5000;
+
         DeadAhnkaharGuardian = false;
+
         if (pInstance)
             pInstance->SetData(DATA_ELDER_NADOX_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_DEATH,m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_ELDER_NADOX_EVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_SLAY_3,m_creature);
+
         if (HeroicMode && !DeadAhnkaharGuardian)
         {
             AchievementEntry const *AchievRespectYourElders = GetAchievementStore()->LookupEntry(ACHIEVEMENT_RESPECT_YOUR_ELDERS);
@@ -93,33 +116,39 @@ struct TRINITY_DLL_DECL boss_elder_nadoxAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievRespectYourElders);
                 }
             }
         }
+
         if (pInstance)
             pInstance->SetData(DATA_ELDER_NADOX_EVENT, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (plague_Timer < diff)
         {
             DoCast(m_creature->getVictim(),HEROIC(SPELL_BROOD_PLAGUE, H_SPELL_BROOD_PLAGUE));
             plague_Timer = 15000;
         }else plague_Timer -= diff;
+
         if (HeroicMode)
             if (rage_Timer < diff)
             {
                 Unit* Swarmer = m_creature->FindNearestCreature(MOB_AHNKAHAR_SWARMER, 35);
+
                 if (Swarmer)
                 {
                     DoCast(Swarmer,H_SPELL_BROOD_RAGE,true);
                     rage_Timer = 15000;
                 }
             }else rage_Timer -= diff;
+
         if (swarmer_spawn_Timer < diff)
         {
             DoCast(m_creature,SPELL_SUMMON_SWARMERS,true);
@@ -130,16 +159,19 @@ struct TRINITY_DLL_DECL boss_elder_nadoxAI : public ScriptedAI
             }
             swarmer_spawn_Timer = 10000;
         }else swarmer_spawn_Timer -= diff;
+
         if (guard_spawn_Timer < diff)
         {
             m_creature->MonsterTextEmote(EMOTE_HATCHES,m_creature->GetGUID(),true);
             DoCast(m_creature,SPELL_SUMMON_SWARM_GUARD);
             guard_spawn_Timer = 25000;
         }else guard_spawn_Timer -= diff;
+
         if (enrage_Timer < diff)
         {
             if (m_creature->HasAura(SPELL_ENRAGE,0))
                 return;
+
             float x, y, z, o;
             m_creature->GetHomePosition(x, y, z, o);
             if (z < 24)
@@ -151,38 +183,48 @@ struct TRINITY_DLL_DECL boss_elder_nadoxAI : public ScriptedAI
             }
             enrage_Timer = 5000;
         }else enrage_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_elder_nadox(Creature* pCreature)
 {
     return new boss_elder_nadoxAI(pCreature);
 }
+
 #define SPELL_SPRINT            56354
+
 struct TRINITY_DLL_DECL mob_ahnkahar_nerubianAI : public ScriptedAI
 {
     mob_ahnkahar_nerubianAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
     uint32 sprint_Timer;
+
     void Reset()
     {
         if (m_creature->GetEntry() == 30176)
             DoCast(m_creature,SPELL_GUARDIAN_AURA,true);
         sprint_Timer = 10000;
     }
+
     void JustDied(Unit *killer)
     {
         if (m_creature->GetEntry() == MOB_AHNKAHAR_GUARDIAN_ENTRY)
             DeadAhnkaharGuardian = true;
     }
+
     void EnterCombat(Unit *who){}
+
     void UpdateAI(const uint32 diff)
     {
         if (m_creature->GetEntry() == 30176)
             m_creature->RemoveAurasDueToSpell(SPELL_GUARDIAN_AURA);
+
         if (pInstance)
         {
             if (pInstance->GetData(DATA_ELDER_NADOX_EVENT) != IN_PROGRESS)
@@ -191,27 +233,34 @@ struct TRINITY_DLL_DECL mob_ahnkahar_nerubianAI : public ScriptedAI
                 m_creature->RemoveCorpse();
             }
         }
+
         if (!UpdateVictim())
             return;
+
         if (sprint_Timer < diff)
         {
             DoCast(m_creature,SPELL_SPRINT);
             sprint_Timer = 25000;
         }else sprint_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_ahnkahar_nerubian(Creature* pCreature)
 {
     return new mob_ahnkahar_nerubianAI(pCreature);
 }
+
 void AddSC_boss_elder_nadox()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_elder_nadox";
     newscript->GetAI = &GetAI_boss_elder_nadox;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ahnkahar_nerubian";
     newscript->GetAI = &GetAI_mob_ahnkahar_nerubian;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_herald_volazj.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_herald_volazj.cpp
index 4ec6df3173d..33c3ba42011 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_herald_volazj.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_herald_volazj.cpp
@@ -15,6 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: boss_herald_volazj
 SDAuthor: Tartalo
@@ -22,8 +23,10 @@ SD%Complete: 20
 SDComment: Coded all but Insanity
 SDCategory: Ahn'kahet
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_ahnkahet.h"
+
 enum Spells
 {
     SPELL_INSANITY                         = 57496, //Dummy
@@ -35,6 +38,7 @@ enum Spells
     SPELL_SHIVER                           = 57949,
     H_SPELL_SHIVER                         = 59978
 };
+
 //not in db
 enum Yells
 {
@@ -46,88 +50,110 @@ enum Yells
     SAY_DEATH_2                             = -1619035,
     SAY_PHASE                               = -1619036
 };
+
 enum Achievements
 {
     ACHIEVEMENT_QUICK_DEMISE                = 1862
 };
+
 struct TRINITY_DLL_DECL boss_volazjAI : public ScriptedAI
 {
     boss_volazjAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 uiMindFlayTimer;
     uint32 uiShadowBoltVolleyTimer;
     uint32 uiShiverTimer;
     uint32 uiEncounterTimer;
+
     void Reset()
     {
         uiEncounterTimer = 0;
         uiMindFlayTimer = 8000;
         uiShadowBoltVolleyTimer = 5000;
         uiShiverTimer = 15000;
+
         if (pInstance)
             pInstance->SetData(DATA_HERALD_VOLAZJ, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_HERALD_VOLAZJ, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiMindFlayTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_MIND_FLAY, H_SPELL_MIND_FLAY));
             uiMindFlayTimer = 20000;
         } else uiMindFlayTimer -= diff;
+
         if (uiShadowBoltVolleyTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_SHADOW_BOLT_VOLLEY, H_SPELL_SHADOW_BOLT_VOLLEY));
             uiShadowBoltVolleyTimer = 5000;
         } else uiShadowBoltVolleyTimer -= diff;
+
         if (uiShiverTimer < diff)
         {
             if (Unit * target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(target, HEROIC(SPELL_SHIVER, H_SPELL_SHIVER));
             uiShiverTimer = 15000;
         } else uiShiverTimer -= diff;
+
         uiEncounterTimer += diff;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH_1, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_HERALD_VOLAZJ, DONE);
+
         AchievementEntry const *AchievQuickDemise = GetAchievementStore()->LookupEntry(ACHIEVEMENT_QUICK_DEMISE);
         Map* pMap = m_creature->GetMap();
+
         if (HeroicMode && uiEncounterTimer < 120000 && pMap && pMap->IsDungeon() && AchievQuickDemise)
         {
             Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievQuickDemise);
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_volazj(Creature* pCreature)
 {
     return new boss_volazjAI (pCreature);
 }
+
 void AddSC_boss_volazj()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_volazj";
     newscript->GetAI = &GetAI_boss_volazj;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_jedoga_shadowseeker.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_jedoga_shadowseeker.cpp
index 4def5f611ef..a239c961bfa 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_jedoga_shadowseeker.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_jedoga_shadowseeker.cpp
@@ -15,6 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: boss_jedoga_shadowseeker
 SDAuthor: LordVanMartin
@@ -22,11 +23,14 @@ SD%Complete: 0
 SDComment:
 SDCategory: Ahn'kahet
 EndScriptData */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_jedoga' where entry = '';
 *** SQL END ***/
+
 #include "precompiled.h"
 #include "def_ahnkahet.h"
+
 #define SPELL_CYCLONE_STRIKE                    56855
 #define H_SPELL_CYCLONE_STRIKE                  60030//kein unterschied zu 56855 außer das 60030 1,5sec cast ist
 #define SPELL_LIGHTNING_BOLT                    56891
@@ -34,6 +38,7 @@ update creature_template set scriptname = 'boss_jedoga' where entry = '';
 #define SPELL_THUNDERSHOCK                      56926//AOE works
 #define H_SPELL_THUNDERSHOCK                    60029//AOE works
 #define SPELL_GIFT_OF_THE_HERALD                56219//triggert if sucessfull sacreficed
+
 //not in db
 #define SAY_AGGRO                                 -1619000
 #define SAY_C_SACRIFICE_1                         -1619001
@@ -49,9 +54,11 @@ update creature_template set scriptname = 'boss_jedoga' where entry = '';
 #define SAY_PREACHING_3                           -1619011
 #define SAY_PREACHING_4                           -1619012
 #define SAY_PREACHING_5                           -1619013
+
 struct TRINITY_DLL_DECL boss_jedogaAI : public ScriptedAI
 {
     boss_jedogaAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit* who)
     {
@@ -64,26 +71,33 @@ struct TRINITY_DLL_DECL boss_jedogaAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_jedoga(Creature* pCreature)
 {
     return new boss_jedogaAI (pCreature);
 }
+
 void AddSC_boss_jedoga()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_jedoga";
     newscript->GetAI = &GetAI_boss_jedoga;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_prince_taldaram.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_prince_taldaram.cpp
index 04e8aa0b498..b6b1ac586eb 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_prince_taldaram.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_prince_taldaram.cpp
@@ -15,6 +15,7 @@
  * along with 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_taldaram
 SDAuthor: Tartalo & tlexii
@@ -22,8 +23,10 @@ SD%Complete: 0
 SDComment:
 SDCategory: Ahn'kahet
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_ahnkahet.h"
+
 enum Spells
 {
     SPELL_BLOODTHIRST                   = 55968, //Trigger Spell + add aura
@@ -75,6 +78,7 @@ enum CombatPhase
     VANISHED,
     FEEDING
 };
+
 struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
 {
     boss_taldaramAI(Creature *c) : ScriptedAI(c)
@@ -83,6 +87,7 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
     }
+
     uint32 uiBloodthirstTimer;
     uint32 uiVanishTimer;
     uint32 uiWaitTimer;
@@ -90,12 +95,18 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
     uint32 uiEmbraceTakenDamage;
     uint32 uiFlamesphereTimer;
     uint32 uiPhaseTimer;
+
     uint64 uiSphereGuids[2];
+
     Unit *pEmbraceTarget;
     Unit *pSphereTarget;
+
     Creature* pSpheres[3];
+
     CombatPhase Phase;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiBloodthirstTimer = 10000;
@@ -109,12 +120,14 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(DATA_PRINCE_TALDARAM_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
             pInstance->SetData(DATA_PRINCE_TALDARAM_EVENT, IN_PROGRESS);
             DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -154,6 +167,7 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
                             pSpheres[2]->GetMotionMaster()->MovePoint(0, x, y, pSpheres[2]->GetPositionZ());
                         }
                     }
+
                     Phase = NORMAL;
                     uiPhaseTimer = 0;
                 break;
@@ -183,6 +197,7 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
                         DoCast(m_creature->getVictim(),SPELL_BLOODTHIRST);
                         uiBloodthirstTimer = 10000;
                     } else uiBloodthirstTimer -= diff;
+
                     if (uiFlamesphereTimer < diff)
                     {
                         DoCast(m_creature, SPELL_CONJURE_FLAME_SPHERE);
@@ -190,13 +205,14 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
                         uiPhaseTimer = 3000 + diff;
                         uiFlamesphereTimer = 15000;
                     } else uiFlamesphereTimer -= diff;
+
                     if (uiVanishTimer < diff )
                     {
                         //Count alive players
                         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)
+                        for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                         {
                             target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                             // exclude pets & totems
@@ -215,11 +231,13 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
                         }
                         uiVanishTimer = urand(25000,35000);
                     } else uiVanishTimer -= diff;
+
                     DoMeleeAttackIfReady();
                 break;
             }
         } else uiPhaseTimer -= diff;
     }
+
     void DamageTaken(Unit* done_by, uint32 &damage)
     {
         if (Phase == FEEDING && pEmbraceTarget && pEmbraceTarget->isAlive())
@@ -234,12 +252,15 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
           }
         }
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(DATA_PRINCE_TALDARAM_EVENT, DONE);
+
             //The Party's Over achievement:
             AchievementEntry const *AchievThePartyIsOver = GetAchievementStore()->LookupEntry(ACHIEVEMENT_THE_PARTY_IS_OVER);
             Map* pMap = m_creature->GetMap();
@@ -247,14 +268,15 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
             {
                 Map::PlayerList const &players = pMap->GetPlayers();
                 uint8 count = 0;
-                for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                   ++count;
                 if (count < 5)
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievThePartyIsOver);
             }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
@@ -267,24 +289,27 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
         }
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     bool CheckSpheres()
     {
         if(!pInstance)
-            return false;
+	        return false;
         uiSphereGuids[0] = pInstance->GetData64(DATA_SPHERE1);
         uiSphereGuids[1] = pInstance->GetData64(DATA_SPHERE2);
+
         GameObject *pSpheres[2];
         for (uint8 i=0; i < 2; ++i)
         {
-            pSpheres[i] = pInstance->instance->GetGameObject(uiSphereGuids[i]);
-            if (!pSpheres[i])
-                return false;
-            if (pSpheres[i]->GetGoState() != GO_STATE_ACTIVE)
-                return false;
+	        pSpheres[i] = pInstance->instance->GetGameObject(uiSphereGuids[i]);
+	        if (!pSpheres[i])
+	            return false;
+	        if (pSpheres[i]->GetGoState() != GO_STATE_ACTIVE)
+	            return false;
         }
         RemovePrison();
         return true;
     }
+
     void RemovePrison()
     {
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
@@ -296,14 +321,17 @@ struct TRINITY_DLL_DECL boss_taldaramAI : public ScriptedAI
         pInstance->HandleGameObject(prison_GUID,true);
     }
 };
+
 struct TRINITY_DLL_DECL mob_taldaram_flamesphereAI : public ScriptedAI
 {
     mob_taldaram_flamesphereAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiDespawnTimer;
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -315,12 +343,15 @@ struct TRINITY_DLL_DECL mob_taldaram_flamesphereAI : public ScriptedAI
         DoCast(m_creature, HEROIC(SPELL_FLAME_SPHERE_PERIODIC, H_SPELL_FLAME_SPHERE_PERIODIC));
         uiDespawnTimer = 10000;
     }
+
     void EnterCombat(Unit *who) {}
     void MoveInLineOfSight(Unit *who) {}
+
     void JustDied(Unit* slayer)
     {
         DoCast(m_creature, SPELL_FLAME_SPHERE_DEATH_EFFECT);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (uiDespawnTimer < diff)
@@ -329,43 +360,53 @@ struct TRINITY_DLL_DECL mob_taldaram_flamesphereAI : public ScriptedAI
             uiDespawnTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_taldaram(Creature* pCreature)
 {
     return new boss_taldaramAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_taldaram_flamesphere(Creature* pCreature)
 {
     return new mob_taldaram_flamesphereAI (pCreature);
 }
+
 bool GOHello_prince_taldaram_sphere(Player *pPlayer, GameObject *pGO)
 {
     ScriptedInstance *pInstance = pGO->GetInstanceData();
+
     Creature *pPrinceTaldaram = Unit::GetCreature(*pGO, pInstance ? pInstance->GetData64(DATA_PRINCE_TALDARAM) : 0);
     if (pPrinceTaldaram && pPrinceTaldaram->isAlive())
     {
         // maybe these are hacks :(
         pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
         pGO->SetGoState(GO_STATE_ACTIVE);
+
         switch(pGO->GetEntry())
         {
             case 193093: pInstance->SetData(DATA_SPHERE1_EVENT,IN_PROGRESS); break;
             case 193094: pInstance->SetData(DATA_SPHERE2_EVENT,IN_PROGRESS); break;
         }
+
         CAST_AI(boss_taldaramAI, pPrinceTaldaram->AI())->CheckSpheres();
     }
     return true;
 }
+
 void AddSC_boss_taldaram()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_taldaram";
     newscript->GetAI = &GetAI_boss_taldaram;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_taldaram_flamesphere";
     newscript->GetAI = &GetAI_mob_taldaram_flamesphere;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "prince_taldaram_sphere";
     newscript->pGOHello = &GOHello_prince_taldaram_sphere;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/def_ahnkahet.h b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/def_ahnkahet.h
index c988d44688c..9c17171d019 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/def_ahnkahet.h
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/def_ahnkahet.h
@@ -15,21 +15,26 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef DEF_AHNKAHET_H
 #define DEF_AHNKAHET_H
+
 #define DATA_ELDER_NADOX            1
 #define DATA_PRINCE_TALDARAM        2
 #define DATA_JEDOGA_SHADOWSEEKER    3
 #define DATA_HERALD_VOLAZJ          4
 #define DATA_AMANITAR               5
+
 #define DATA_ELDER_NADOX_EVENT          6
 #define DATA_PRINCE_TALDARAM_EVENT      7
 #define DATA_JEDOGA_SHADOWSEEKER_EVENT  8
 #define DATA_HERALD_VOLAZJ_EVENT        9
 #define DATA_AMANITAR_EVENT             10
+
 #define DATA_SPHERE1                    11
 #define DATA_SPHERE2                    12
 #define DATA_SPHERE1_EVENT              13
 #define DATA_SPHERE2_EVENT              14
 #define DATA_PRINCE_TALDARAM_PLATFORM   15
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/instance_ahnkahet.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/instance_ahnkahet.cpp
index bb522258266..c8a0fc22c3c 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/instance_ahnkahet.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/instance_ahnkahet.cpp
@@ -15,15 +15,19 @@
  * along 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_Azjol_Nerub
 SD%Complete: 0
 SDComment:
 SDCategory: Azjol Nerub
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_ahnkahet.h"
+
 #define MAX_ENCOUNTER     5
+
 /* Ahn'kahet encounters:
 0 - Elder Nadox
 1 - Prince Taldaram
@@ -31,19 +35,24 @@ EndScriptData */
 3 - Herald Volazj
 4 - Amanitar (Heroic only)
 */
+
 struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
 {
     instance_ahnkahet(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 Elder_Nadox;
     uint64 Prince_Taldaram;
     uint64 Jedoga_Shadowseeker;
     uint64 Herald_Volazj;
     uint64 Amanitar;
+
     uint64 Prince_TaldaramSpheres[2];
     uint64 Prince_TaldaramPlatform;
     uint64 Prince_TaldaramGate;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     uint32 spheres[2];
+
     void Initialize()
     {
          Elder_Nadox =0;
@@ -51,18 +60,22 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
          Jedoga_Shadowseeker =0;
          Herald_Volazj =0;
          Amanitar =0;
-         for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+         for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
              m_auiEncounter[i] = NOT_STARTED;
         spheres[0] = NOT_STARTED;
         spheres[1] = NOT_STARTED;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
 
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -74,6 +87,7 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
             case 30258:    Amanitar = pCreature->GetGUID();                      break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -100,6 +114,7 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
                 if (m_auiEncounter[1] == DONE)HandleGameObject(NULL,true,pGo);break;
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -115,37 +130,37 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
         {
-            case DATA_ELDER_NADOX_EVENT:
-                m_auiEncounter[0] = data;
-                break;
-            case DATA_PRINCE_TALDARAM_EVENT:
-                if (data == DONE)
-                    HandleGameObject(Prince_TaldaramGate,true);
-                m_auiEncounter[1] = data;
-                break;
-            case DATA_JEDOGA_SHADOWSEEKER_EVENT:
-                m_auiEncounter[2] = data;
-                break;
-            case DATA_HERALD_VOLAZJ:
-                m_auiEncounter[3] = data;
-                break;
-            case DATA_AMANITAR:
-                m_auiEncounter[4] = data;
-                break;
-            case DATA_SPHERE1_EVENT:
-                spheres[0] = data;
-                break;
-            case DATA_SPHERE2_EVENT:
-                spheres[1] = data;
-                break;
-    }
+        case DATA_ELDER_NADOX_EVENT:
+            m_auiEncounter[0] = data;break;
+        case DATA_PRINCE_TALDARAM_EVENT:
+	    if (data == DONE)
+	    {
+	        HandleGameObject(Prince_TaldaramGate,true);
+	    }
+            m_auiEncounter[1] = data; break;
+        case DATA_JEDOGA_SHADOWSEEKER_EVENT:
+            m_auiEncounter[2] = data; break;
+        case DATA_HERALD_VOLAZJ:
+            m_auiEncounter[3] = data; break;
+        case DATA_AMANITAR:
+            m_auiEncounter[4] = data; break;
+        case DATA_SPHERE1_EVENT:
+            spheres[0] = data; break;
+        case DATA_SPHERE2_EVENT:
+            spheres[1] = data; break;
+	}
+
         if (data == DONE)
+        {
             SaveToDB();
+        }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -160,18 +175,24 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
         }
         return 0;
     }
+
    std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::string str_data;
+
         std::ostringstream saveStream;
         saveStream << "A K " << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
             << m_auiEncounter[2] << " " << m_auiEncounter[3] << " " << m_auiEncounter[4] << " "
             << spheres[0] << " " << spheres[1];
+
         str_data = saveStream.str();
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -179,11 +200,15 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         char dataHead1, dataHead2;
         uint16 data0,data1,data2,data3,data4, data5, data6;
+
         std::istringstream loadStream(in);
         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3 >> data4 >> data5 >> data6;
+
         if (dataHead1 == 'A' && dataHead2 == 'K')
         {
             m_auiEncounter[0] = data0;
@@ -191,19 +216,25 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
             m_auiEncounter[2] = data2;
             m_auiEncounter[3] = data3;
             m_auiEncounter[4] = data4;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 if (m_auiEncounter[i] == IN_PROGRESS)
                     m_auiEncounter[i] = NOT_STARTED;
+
             spheres[0] = data5;
             spheres[1] = data6;
+
         }else OUT_LOAD_INST_DATA_FAIL;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_ahnkahet(Map* pMap)
 {
    return new instance_ahnkahet(pMap);
 }
+
 void AddSC_instance_ahnkahet()
 {
    Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_anubarak.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_anubarak.cpp
index 18b95192c96..8172c9a3f66 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_anubarak.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_anubarak.cpp
@@ -15,6 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: boss_anubarak
 SDAuthor: LordVanMartin
@@ -22,16 +23,20 @@ SD%Complete: 0
 SDComment:
 SDCategory: Azjol Nerub
 EndScriptData */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_anub_arak' where entry = '';
 *** SQL END ***/
+
 #include "precompiled.h"
 #include "def_azjol_nerub.h"
+
 //Spells
 #define SPELL_CARRION_BEETLES                         53520
 #define SPELL_LOCUST_SWARM                            53467
 #define SPELL_IMPALE                                  53454
 #define SPELL_POUND                                   53472
+
 // not in db
 //Yell
 #define SAY_INTRO                                  -1601010
@@ -45,10 +50,13 @@ update creature_template set scriptname = 'boss_anub_arak' where entry = '';
 #define SAY_SUBMERGE_1                             -1601008
 #define SAY_SUBMERGE_2                             -1601009
 #define SAY_DEATH                                  -1601004
+
 struct TRINITY_DLL_DECL boss_anub_arakAI : public ScriptedAI
 {
     boss_anub_arakAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 phase;
+
     void Reset() {}
     void EnterCombat(Unit* who)
     {
@@ -61,11 +69,14 @@ struct TRINITY_DLL_DECL boss_anub_arakAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         phase =1;
+
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 33)
             phase = 2;
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) == 15)
             phase = 3;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
@@ -76,16 +87,20 @@ struct TRINITY_DLL_DECL boss_anub_arakAI : public ScriptedAI
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_anub_arak(Creature* pCreature)
 {
     return new boss_anub_arakAI (pCreature);
 }
+
 void AddSC_boss_anub_arak()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_anub_arak";
     newscript->GetAI = &GetAI_boss_anub_arak;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_hadronox.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_hadronox.cpp
index d27997ee8cd..b9a0a7e670d 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_hadronox.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_hadronox.cpp
@@ -15,15 +15,19 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: boss_hadronox
 SD%Complete: 0
 SDComment: Placeholder
 SDCategory: Azjol Nerub
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_azjol_nerub.h"
+
 #define SPELL_WEB_FRONT_DOORS               53177//dummy
+
 #define SPELL_ACID_CLOUD                    53400
 #define H_SPELL_ACID_CLOUD                  59419
 #define SPELL_LEECH_POISON                  53030
@@ -32,6 +36,7 @@ EndScriptData */
 #define SPELL_PIECE_ARMOR                   53418
 #define SPELL_WEB_GRAB                      53406
 #define H_SPELL_WEB_GRAB                    59420
+
 /* Script Data Start
 SDName: Boss hadronox
 SDAuthor: LordVanMartin
@@ -39,27 +44,35 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_hadronox' where entry = '';
 *** SQL END ***/
+
 //Spells
 #define SPELL_LEECH_POISON                            53030
 #define SPELL_ACID_CLOUD                              53400
 #define SPELL_PIERCE_ARMOR                            53418 //Source SUN++
 #define SPELL_WEB_GRAB                                53406
+
 //Phase 0 => Gauntlet Event described below
 //Phase 1 => Boss Encounter
+
 /*When your group enters the main room (the one after the bridge), you will notice a group of 3 Nerubians.
 When you engage them, 2 more groups like this one spawn behind the first one - it is important to pull the first group back,
 so you don't aggro all 3. Hadronox will be under you, fighting Nerubians.
+
 This is the timed gauntlet - waves of non-elite spiders
  will spawn from the 3 doors located a little above the main room, and will then head down to fight Hadronox. After clearing the
  main room, it is recommended to just stay in it, kill the occasional non-elites that will attack you instead of the boss, and wait for
  Hadronox to make his way to you. When Hadronox enters the main room, she will web the doors, and no more non-elites will spawn.*/
+
 struct TRINITY_DLL_DECL boss_hadronoxAI : public ScriptedAI
 {
     boss_hadronoxAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 phase;
+
     void Reset() {}
     void EnterCombat(Unit* who) {}
     void AttackStart(Unit* who) {}
@@ -69,24 +82,31 @@ struct TRINITY_DLL_DECL boss_hadronoxAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         phase =1;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)  {}
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
     //when Hadronox kills any enemy (that includes a party member) she will regain 10% of her HP if the target had Leech Poison on
     }
 };
+
 CreatureAI* GetAI_boss_hadronox(Creature* pCreature)
 {
     return new boss_hadronoxAI (pCreature);
 }
+
 void AddSC_boss_hadronox()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_hadronox";
     newscript->GetAI = &GetAI_boss_hadronox;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp
index 5fbca03945f..377a9d58c8f 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp
@@ -15,17 +15,21 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: boss_krikthir_the_gatewatcher
 SD%Complete: 80 %
 SDComment: Find in the future best timers and the event is not implemented.
 SDCategory: Azjol Nerub
 EndScriptData */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_krik_thir' where entry = '';
 *** SQL END ***/
+
 #include "precompiled.h"
 #include "def_azjol_nerub.h"
+
 enum Spells
 {
     SPELL_MIND_FLAY                        =   52586,
@@ -33,33 +37,44 @@ enum Spells
     SPELL_CURSE_OF_FATIGUE                 =   52592,
     H_SPELL_CURSE_OF_FATIGUE               =   59368,
     SPELL_FRENZY                           =   28747, //maybe 53361
+
     SPELL_SUMMON_SKITTERING_SWARMER        =   52438, //AOE Effect 140, maybe 52439
     SPELL_SUMMON_SKITTERING_SWARMER_1      =   52439, //Summon 3x 28735
+
     H_SPELL_ACID_SPLASH                    =   59363,
     SPELL_ACID_SPLASH                      =   52446,
+
     SPELL_CHARGE                           =   16979,//maybe is another spell
     SPELL_BACKSTAB                         =   52540,
+
     SPELL_SHADOW_BOLT                      =   52534,
     H_SPELL_SHADOW_BOLT                    =   59357,
     SPELL_SHADOW_NOVA                      =   52535,
     H_SPELL_SHADOW_NOVA                    =   59358,
+
     SPELL_STRIKE                           =   52532,
     SPELL_CLEAVE                           =   49806,
+
     SPELL_ENRAGE                           =   52470,
+
     SPELL_INFECTED_BITE                    =   52469,
     H_SPELL_INFECTED_BITE                  =   59364,
     SPELL_WEB_WRAP                         =   52086,//the spell is not working propperly
+
     SPELL_BLINDING_WEBS                    =   52524,
     H_SPELL_BLINDING_WEBS                  =   59365,
+
     SPELL_POSION_SPRAY                     =   52493,
     H_SPELL_POSION_SPRAY                   =   59366,
 };
+
 enum Mobs
 {
     MOB_SKITTERING_SWARMER                 =   28735,
     MOB_SKITTERING_SWARMER_CONTROLLER      =   32593,
     MOB_SKITTERING_INFECTIOR               =   28736,
 };
+
 enum Yells
 {
     SAY_AGGRO                              =   -1601000,
@@ -87,26 +102,33 @@ struct TRINITY_DLL_DECL boss_krik_thirAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool HeroicMode;
+
     uint32 MindFlayTimer;
     uint32 CurseFatigueTimer;
     uint32 SummonTimer;
+
     void Reset()
     {
         MindFlayTimer        = 15000;
         CurseFatigueTimer   = 12000;
+
         if (pInstance)
             pInstance->SetData(DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         Summon();
         SummonTimer = 15000;
+
         if (pInstance)
             pInstance->SetData(DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, IN_PROGRESS);
     }
+
     void Summon()
     {
             m_creature->SummonCreature(MOB_SKITTERING_SWARMER,566.164,682.087,769.079,2.21657,TEMPSUMMON_TIMED_DESPAWN,25000);
@@ -126,37 +148,46 @@ struct TRINITY_DLL_DECL boss_krik_thirAI : public ScriptedAI
             m_creature->SummonCreature(MOB_SKITTERING_SWARMER,552.625,706.408,777.177,3.4383,TEMPSUMMON_TIMED_DESPAWN,25000);
             m_creature->SummonCreature(MOB_SKITTERING_SWARMER,552.625,706.408,777.177,3.4383,TEMPSUMMON_TIMED_DESPAWN,25000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
 
+
         if(SummonTimer < diff)
         {
             Summon();
             SummonTimer = 15000;
         } else SummonTimer -= diff;
+
         if (MindFlayTimer < diff)
         {
                 DoCast(m_creature->getVictim(), HEROIC(SPELL_MIND_FLAY, H_SPELL_MIND_FLAY));
                 MindFlayTimer = 15000;
             } else MindFlayTimer -= diff;
+
         if (CurseFatigueTimer < diff)
         {
             //WowWiki say "Curse of Fatigue-Kirk'thir will cast Curse of Fatigue on 2-3 targets periodically. "
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
             Unit* target_1 = SelectUnit(SELECT_TARGET_RANDOM, 1);
+
             DoCast(target, HEROIC(SPELL_CURSE_OF_FATIGUE, H_SPELL_CURSE_OF_FATIGUE));
             DoCast(target_1, HEROIC(SPELL_CURSE_OF_FATIGUE, H_SPELL_CURSE_OF_FATIGUE));
+
             CurseFatigueTimer = 10000;
         } else CurseFatigueTimer -= diff;
+
         if (!m_creature->HasAura(SPELL_FRENZY) && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 10)
             m_creature->CastSpell(m_creature,SPELL_FRENZY,true);
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, DONE);
@@ -170,7 +201,7 @@ struct TRINITY_DLL_DECL boss_krik_thirAI : public ScriptedAI
                 HeroicMode && pMap && pMap->IsDungeon() && AchievWatchHimDie)
             {
                 Map::PlayerList const &players = pMap->GetPlayers();
-                for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                     itr->getSource()->CompletedAchievement(AchievWatchHimDie);
             }
         }
@@ -179,36 +210,46 @@ struct TRINITY_DLL_DECL boss_krik_thirAI : public ScriptedAI
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->GetMotionMaster()->MovePoint(m_creature->GetEntry(),m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ());
     }
 };
+
 struct TRINITY_DLL_DECL npc_skittering_infectorAI : public ScriptedAI
 {
     npc_skittering_infectorAI(Creature *c) : ScriptedAI(c) {}
+
     void JustDied(Unit* killer)
     {
         //The spell is not working propperly
         DoCast(m_creature->getVictim(),HEROIC(SPELL_ACID_SPLASH, H_SPELL_ACID_SPLASH), true);
     }
+
 };
+
 struct TRINITY_DLL_DECL npc_anub_ar_skirmisherAI : public ScriptedAI
 {
     npc_anub_ar_skirmisherAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ChargeTimer;
     uint32 BackstabTimer;
+
     void Reset()
     {
         ChargeTimer   = 11000;
         BackstabTimer = 7000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(ChargeTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
@@ -217,238 +258,301 @@ struct TRINITY_DLL_DECL npc_anub_ar_skirmisherAI : public ScriptedAI
                 m_creature->AddThreat(pTarget,1.0f);
                 DoCast(pTarget,SPELL_CHARGE,true);
             }
+
             ChargeTimer = 15000;
         } else ChargeTimer -= diff;
+
         if(BackstabTimer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_BACKSTAB);
             BackstabTimer = 12000;
         } else BackstabTimer -= diff;
+
         DoMeleeAttackIfReady();
+
     }
 };
+
 struct TRINITY_DLL_DECL npc_anub_ar_shadowcasterAI : public ScriptedAI
 {
     npc_anub_ar_shadowcasterAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowBoltTimer;
     uint32 ShadowNovaTimer;
+
     void Reset()
     {
         ShadowBoltTimer = 6000;
         ShadowNovaTimer = 15000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(ShadowBoltTimer < diff)
         {
             if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM,0,100,true))
                  DoCast(target, HEROIC(SPELL_SHADOW_BOLT, H_SPELL_SHADOW_BOLT), true);
             ShadowBoltTimer = 15000;
         } else ShadowBoltTimer -= diff;
+
         if(ShadowNovaTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_SHADOW_NOVA, H_SPELL_SHADOW_NOVA), true);
             ShadowNovaTimer = 17000;
         } else ShadowNovaTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL npc_anub_ar_warriorAI : public ScriptedAI
 {
     npc_anub_ar_warriorAI(Creature *c) : ScriptedAI(c){}
+
     uint32 CleaveTimer;
     uint32 StrikeTimer;
+
     void Reset()
     {
         CleaveTimer = 11000;
         StrikeTimer = 6000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(StrikeTimer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(), SPELL_STRIKE, true);
             StrikeTimer = 15000;
         } else StrikeTimer -= diff;
+
         if(CleaveTimer < diff)
         {
             m_creature->CastSpell(m_creature->getVictim(), SPELL_CLEAVE, true);
             CleaveTimer = 17000;
         } else CleaveTimer -= diff;
+
         DoMeleeAttackIfReady();
+
     }
+
 };
+
 struct TRINITY_DLL_DECL npc_watcher_gashraAI : public ScriptedAI
 {
     npc_watcher_gashraAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 WebWrapTimer;
     uint32 InfectedBiteTimer;
+
     void Reset()
     {
         WebWrapTimer      = 11000;
         InfectedBiteTimer = 4000;
     }
 
+
     void EnterCombat(Unit* who)
     {
         m_creature->CastSpell(m_creature,SPELL_ENRAGE,true);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(WebWrapTimer < diff)
         {
             if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM,0,100,true))
                 m_creature->CastSpell(target, SPELL_WEB_WRAP,true);
             WebWrapTimer = 17000;
         } else WebWrapTimer -= diff;
+
         if(InfectedBiteTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_INFECTED_BITE, H_SPELL_INFECTED_BITE), true);
             InfectedBiteTimer = 15000;
         } else InfectedBiteTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL npc_watcher_narjilAI : public ScriptedAI
 {
     npc_watcher_narjilAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 WebWrapTimer;
     uint32 InfectedBiteTimer;
     uint32 BlindingWebsTimer;
+
     void Reset()
     {
         WebWrapTimer      = 11000;
         InfectedBiteTimer = 4000;
         BlindingWebsTimer = 17000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(WebWrapTimer < diff)
         {
             if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM,0,100,true))
                 DoCast(target, SPELL_WEB_WRAP,true);
             WebWrapTimer = 15000;
         } else WebWrapTimer -= diff;
+
         if(InfectedBiteTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_INFECTED_BITE, H_SPELL_INFECTED_BITE), true);
             InfectedBiteTimer = 11000;
         } else InfectedBiteTimer -= diff;
+
         if(BlindingWebsTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_BLINDING_WEBS, H_SPELL_BLINDING_WEBS), true);
             BlindingWebsTimer = 17000;
         } else BlindingWebsTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL npc_watcher_silthikAI : public ScriptedAI
 {
     npc_watcher_silthikAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 WebWrapTimer;
     uint32 InfectedBiteTimer;
     uint32 PosionSprayTimer;
+
     void Reset()
     {
         WebWrapTimer      = 11000;
         InfectedBiteTimer = 4000;
         PosionSprayTimer  = 15000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(WebWrapTimer < diff)
         {
             if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM,0,100,true))
                 DoCast(target, SPELL_WEB_WRAP,true);
+
             WebWrapTimer = 15000;
         } else WebWrapTimer -= diff;
+
         if(InfectedBiteTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_INFECTED_BITE, H_SPELL_INFECTED_BITE), true);
             InfectedBiteTimer = 15000;
         } else InfectedBiteTimer -= diff;
+
         if(PosionSprayTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_POSION_SPRAY, H_SPELL_POSION_SPRAY), true);
             PosionSprayTimer = 17000;
         } else PosionSprayTimer -= diff;
+
         DoMeleeAttackIfReady();
+
     }
 };
+
 CreatureAI* GetAI_boss_krik_thir(Creature* pCreature)
 {
     return new boss_krik_thirAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_anub_ar_skirmisher (Creature* pCreature)
 {
     return new npc_anub_ar_skirmisherAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_skittering_infector (Creature* pCreature)
 {
     return new npc_skittering_infectorAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_anub_ar_shadowcaster (Creature* pCreature)
 {
     return new npc_anub_ar_shadowcasterAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_anub_ar_warrior (Creature* pCreature)
 {
     return new npc_anub_ar_warriorAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_watcher_gashra (Creature* pCreature)
 {
     return new npc_watcher_gashraAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_watcher_narjil (Creature* pCreature)
 {
     return new npc_watcher_narjilAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_watcher_silthik (Creature* pCreature)
 {
     return new npc_watcher_silthikAI (pCreature);
 }
 
+
 void AddSC_boss_krik_thir()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_krik_thir";
     newscript->GetAI = &GetAI_boss_krik_thir;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_skittering_infector";
     newscript->GetAI = &GetAI_npc_skittering_infector;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_anub_ar_skirmisher";
     newscript->GetAI = &GetAI_npc_anub_ar_skirmisher;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_anub_ar_shadowcaster";
     newscript->GetAI = &GetAI_npc_anub_ar_shadowcaster;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_watcher_gashra";
     newscript->GetAI = &GetAI_npc_watcher_gashra;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_anub_ar_warrior";
     newscript->GetAI = &GetAI_npc_anub_ar_warrior;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_watcher_silthik";
     newscript->GetAI = &GetAI_npc_watcher_silthik;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_watcher_narjil";
     newscript->GetAI = &GetAI_npc_watcher_narjil;
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/def_azjol_nerub.h b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/def_azjol_nerub.h
index 64bb38d235c..df02f9e13d3 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/def_azjol_nerub.h
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/def_azjol_nerub.h
@@ -15,8 +15,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef DEF_AZJOL_NERUB_H
 #define DEF_AZJOL_NERUB_H
+
 enum Data64
 {
     DATA_KRIKTHIR_THE_GATEWATCHER,
@@ -32,4 +34,5 @@ enum Data
     DATA_HADRONOX_EVENT,
     DATA_ANUBARAK_EVENT
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp
index 05b507c9ffa..d06335bdbd3 100644
--- a/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp
+++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp
@@ -15,34 +15,44 @@
  * along 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_Azjol_Nerub
 SD%Complete: 0
 SDComment: Placeholder
 SDCategory: Azjol Nerub
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_azjol_nerub.h"
+
 #define MAX_ENCOUNTER     3
+
 /* Azjol Nerub encounters:
 0 - Krik'thir the Gatewatcher
 1 - Hadronox
 2 - Anub'arak
 */
+
 struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
 {
     instance_azjol_nerub(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 m_uiKrikthir;
     uint64 m_uiHadronox;
     uint64 m_uiAnubarak;
     uint64 m_uiWatcherGashra;
     uint64 m_uiWatcherSilthik;
     uint64 m_uiWatcherNarjil;
+
     uint64 m_uiKrikthirDoor;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
    void Initialize()
    {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         m_uiKrikthir = 0;
         m_uiHadronox = 0;
         m_uiAnubarak = 0;
@@ -51,13 +61,16 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
         m_uiWatcherNarjil = 0;
         m_uiKrikthirDoor = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
 
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -70,6 +83,7 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
             case 28729:    m_uiWatcherNarjil = pCreature->GetGUID();   break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch (pGo->GetEntry())
@@ -81,6 +95,7 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
                 break;
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -92,8 +107,10 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
             case DATA_WATCHER_SILTHIK:              return m_uiWatcherSilthik;
             case DATA_WATCHER_NARJIL:               return m_uiWatcherNarjil;
         }
+
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -108,11 +125,13 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
         case DATA_ANUBARAK_EVENT:
             m_auiEncounter[2] = data; break;
         }
+
         if (data == DONE)
         {
             SaveToDB();
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -121,19 +140,26 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
             case DATA_HADRONOX_EVENT:                   return m_auiEncounter[1];
             case DATA_ANUBARAK_EVENT:                   return m_auiEncounter[2];
         }
+
         return 0;
     }
+
    std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::string str_data;
+
         std::ostringstream saveStream;
         saveStream << "A N " << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
             << m_auiEncounter[2];
+
         str_data = saveStream.str();
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -141,27 +167,36 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         char dataHead1, dataHead2;
         uint16 data0,data1,data2;
+
         std::istringstream loadStream(in);
         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2;
+
         if (dataHead1 == 'A' && dataHead2 == 'N')
         {
             m_auiEncounter[0] = data0;
             m_auiEncounter[1] = data1;
             m_auiEncounter[2] = data2;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 if (m_auiEncounter[i] == IN_PROGRESS)
                     m_auiEncounter[i] = NOT_STARTED;
+
         }else OUT_LOAD_INST_DATA_FAIL;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_azjol_nerub(Map* pMap)
 {
    return new instance_azjol_nerub(pMap);
 }
+
 void AddSC_instance_azjol_nerub()
 {
    Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/borean_tundra.cpp b/src/bindings/scripts/scripts/northrend/borean_tundra.cpp
index 3bed5fb8e54..85fc89940db 100644
--- a/src/bindings/scripts/scripts/northrend/borean_tundra.cpp
+++ b/src/bindings/scripts/scripts/northrend/borean_tundra.cpp
@@ -13,12 +13,14 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Borean_Tundra
 SD%Complete: 100
 SDComment: Quest support: 11708. Taxi vendors.
 SDCategory: Borean Tundra
 EndScriptData */
+
 /* ContentData
 npc_fizzcrank_fullthrottle
 npc_surristrasz
@@ -26,12 +28,16 @@ npc_tiare
 npc_iruk
 npc_corastrasza
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## npc_fizzcrank_fullthrottle
 ######*/
+
 #define GOSSIP_ITEM_GO_ON   "Go on."
 #define GOSSIP_ITEM_TELL_ME "Tell me what's going on out here, Fizzcrank."
+
 enum eFizzcrank
 {
     GOSSIP_TEXTID_FIZZCRANK1    = 12456,
@@ -43,17 +49,22 @@ enum eFizzcrank
     GOSSIP_TEXTID_FIZZCRANK7    = 12462,
     GOSSIP_TEXTID_FIZZCRANK8    = 12463,
     GOSSIP_TEXTID_FIZZCRANK9    = 12464,
+
     QUEST_THE_MECHAGNOMES       = 11708
 };
+
 bool GossipHello_npc_fizzcrank_fullthrottle(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_THE_MECHAGNOMES) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELL_ME, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_fizzcrank_fullthrottle(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -97,53 +108,68 @@ bool GossipSelect_npc_fizzcrank_fullthrottle(Player* pPlayer, Creature* pCreatur
     }
     return true;
 }
+
 /*######
 ## npc_surristrasz
 ######*/
+
 #define GOSSIP_ITEM_FREE_FLIGHT "I'd like passage to the Transitus Shield."
 #define GOSSIP_ITEM_FLIGHT      "May I use a drake to fly elsewhere?"
+
 enum eSurristrasz
 {
     SPELL_ABMER_TO_COLDARRA     = 46064
 };
+
 bool GossipHello_npc_surristrasz(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isTaxi())
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_FREE_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_GOSSIP);
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_ITEM_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_TAXIVENDOR);
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_surristrasz(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_OPTION_GOSSIP)
     {
         pPlayer->CLOSE_GOSSIP_MENU();
+
         //TaxiPath 795 (amber to coldarra)
         pPlayer->CastSpell(pPlayer, SPELL_ABMER_TO_COLDARRA, true);
     }
+
     if (uiAction == GOSSIP_OPTION_TAXIVENDOR)
         pPlayer->GetSession()->SendTaxiMenu(pCreature);
+
     return true;
 }
+
 /*######
 ## npc_tiare
 ######*/
+
 #define GOSSIP_ITEM_TELEPORT    "Teleport me to Amber Ledge, please."
+
 enum eTiare
 {
     SPELL_TELEPORT_COLDARRA     = 50135
 };
+
 bool GossipHello_npc_tiare(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELEPORT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_GOSSIP);
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_tiare(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_OPTION_GOSSIP)
@@ -153,9 +179,11 @@ bool GossipSelect_npc_tiare(Player* pPlayer, Creature* pCreature, uint32 uiSende
     }
     return true;
 }
+
 /*######
 ## npc_sinkhole_kill_credit
 ######*/
+
 enum eSinkhole
 {
     SPELL_SET_CART                = 46797,
@@ -163,22 +191,27 @@ enum eSinkhole
     SPELL_SUMMON_CART             = 46798,
     SPELL_SUMMON_WORM             = 46800,
 };
+
 struct TRINITY_DLL_DECL npc_sinkhole_kill_creditAI : public ScriptedAI
 {
     npc_sinkhole_kill_creditAI(Creature* c) : ScriptedAI(c){}
+
     uint32 Phase_Timer;
     uint8  Phase;
     uint64 casterGuid;
+
     void Reset()
     {
         Phase_Timer = 500;
         Phase = 0;
         casterGuid = 0;
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (Phase)
             return;
+
         if (spell->Id == SPELL_SET_CART && caster->GetTypeId() == TYPEID_PLAYER
             && CAST_PLR(caster)->GetQuestStatus(11897) == QUEST_STATUS_INCOMPLETE)
         {
@@ -186,11 +219,14 @@ struct TRINITY_DLL_DECL npc_sinkhole_kill_creditAI : public ScriptedAI
             casterGuid = caster->GetGUID();
         }
     }
+
     void EnterCombat(Unit* who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Phase)
             return;
+
         if (Phase_Timer < diff)
         {
             switch (Phase)
@@ -246,23 +282,31 @@ struct TRINITY_DLL_DECL npc_sinkhole_kill_creditAI : public ScriptedAI
                     break;
             }
         } else Phase_Timer -= diff;
+
     }
+
 };
+
 CreatureAI* GetAI_npc_sinkhole_kill_credit(Creature* pCreature)
 {
     return new npc_sinkhole_kill_creditAI(pCreature);
 }
+
 /*######
 ## npc_khunok_the_behemoth
 ######*/
+
 struct TRINITY_DLL_DECL npc_khunok_the_behemothAI : public ScriptedAI
 {
     npc_khunok_the_behemothAI(Creature *c) : ScriptedAI(c) {}
+
     void MoveInLineOfSight(Unit *who)
     {
         ScriptedAI::MoveInLineOfSight(who);
+
         if (who->GetTypeId() != TYPEID_UNIT)
             return;
+
         if (who->GetEntry() == 25861 && me->IsWithinDistInMap(who, 10.0f))
         {
             if (Unit *owner = who->GetOwner())
@@ -276,27 +320,36 @@ struct TRINITY_DLL_DECL npc_khunok_the_behemothAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_khunok_the_behemoth(Creature* pCreature)
 {
     return new npc_khunok_the_behemothAI(pCreature);
 }
+
 /*######
 ## npc_keristrasza
 ######*/
+
 enum eKeristrasza
 {
     SPELL_TELEPORT_TO_SARAGOSA = 46772
 };
+
 #define GOSSIP_HELLO_KERI   "I am prepared to face Saragosa!"
+
 bool GossipHello_npc_keristrasza(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(11957) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_KERI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_keristrasza(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -304,57 +357,76 @@ bool GossipSelect_npc_keristrasza(Player* pPlayer, Creature* pCreature, uint32 u
         pPlayer->CLOSE_GOSSIP_MENU();
         pPlayer->CastSpell(pPlayer, SPELL_TELEPORT_TO_SARAGOSA, true);
     }
+
     return true;
 }
+
 /*######
 ## npc_corastrasza
 ######*/
+
 #define GOSSIP_ITEM_C_1 "I... I think so..."
+
 enum eCorastrasza
 {
     SPELL_SUMMON_WYRMREST_SKYTALON               = 61240,
     SPELL_WYRMREST_SKYTALON_RIDE_PERIODIC        = 61244,
+
     QUEST_ACES_HIGH_DAILY                        = 13414,
     QUEST_ACES_HIGH                              = 13413
 };
+
 bool GossipHello_npc_corastrasza(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_ACES_HIGH) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestStatus(QUEST_ACES_HIGH_DAILY) == QUEST_STATUS_INCOMPLETE) //It's the same dragon for both quests.
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_C_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_corastrasza(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
     {
         pPlayer->CLOSE_GOSSIP_MENU();
+
         pPlayer->CastSpell(pPlayer, SPELL_SUMMON_WYRMREST_SKYTALON, true);
         pPlayer->CastSpell(pPlayer, SPELL_WYRMREST_SKYTALON_RIDE_PERIODIC, true);
+
     }
+
     return true;
 }
+
 /*######
 ## npc_iruk
 ######*/
+
 #define GOSSIP_ITEM_I  ""
+
 enum eIruk
 {
     QUEST_SPIRITS_WATCH_OVER_US             = 11961,
     SPELL_CREATURE_TOTEM_OF_ISSLIRUK        = 46816,
     GOSSIP_TEXT_I                           = 12585
 };
+
 bool GossipHello_npc_iruk(Player* pPlayer, Creature* pCreature)
 {
+
     if (pPlayer->GetQuestStatus(QUEST_SPIRITS_WATCH_OVER_US) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_I, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->PlayerTalkClass->SendGossipMenu(GOSSIP_TEXT_I, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_iruk(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -363,13 +435,16 @@ bool GossipSelect_npc_iruk(Player* pPlayer, Creature* pCreature, uint32 uiSender
             pPlayer->CastSpell(pPlayer, SPELL_CREATURE_TOTEM_OF_ISSLIRUK, true);
             pPlayer->CLOSE_GOSSIP_MENU();
             break;
+
     }
     return true;
 }
 /*######
 ## mob_nerubar_victim
 ######*/
+
 #define WARSONG_PEON        25270
+
 const uint32 nerubarVictims[3] =
 {
     45526, 45527, 45514
@@ -377,9 +452,11 @@ const uint32 nerubarVictims[3] =
 struct TRINITY_DLL_DECL mob_nerubar_victimAI : public ScriptedAI
 {
     mob_nerubar_victimAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit *who) {}
     void MoveInLineOfSight(Unit *who) {}
+
     void JustDied(Unit* Killer)
     {
         if(Killer->GetTypeId() == TYPEID_PLAYER)
@@ -405,44 +482,53 @@ CreatureAI* GetAI_mob_nerubar_victim(Creature *pCreature)
 void AddSC_borean_tundra()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_fizzcrank_fullthrottle";
     newscript->pGossipHello = &GossipHello_npc_fizzcrank_fullthrottle;
     newscript->pGossipSelect = &GossipSelect_npc_fizzcrank_fullthrottle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_surristrasz";
     newscript->pGossipHello = &GossipHello_npc_surristrasz;
     newscript->pGossipSelect = &GossipSelect_npc_surristrasz;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_tiare";
     newscript->pGossipHello = &GossipHello_npc_tiare;
     newscript->pGossipSelect = &GossipSelect_npc_tiare;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_sinkhole_kill_credit";
     newscript->GetAI = &GetAI_npc_sinkhole_kill_credit;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_khunok_the_behemoth";
     newscript->GetAI = &GetAI_npc_khunok_the_behemoth;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_keristrasza";
     newscript->pGossipHello = &GossipHello_npc_keristrasza;
     newscript->pGossipSelect = &GossipSelect_npc_keristrasza;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_corastrasza";
     newscript->pGossipHello = &GossipHello_npc_corastrasza;
     newscript->pGossipSelect = &GossipSelect_npc_corastrasza;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_iruk";
     newscript->pGossipHello = &GossipHello_npc_iruk;
     newscript->pGossipSelect = &GossipSelect_npc_iruk;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_nerubar_victim";
     newscript->GetAI = &GetAI_mob_nerubar_victim;
diff --git a/src/bindings/scripts/scripts/northrend/dragonblight.cpp b/src/bindings/scripts/scripts/northrend/dragonblight.cpp
index b129285a320..31deb88c069 100644
--- a/src/bindings/scripts/scripts/northrend/dragonblight.cpp
+++ b/src/bindings/scripts/scripts/northrend/dragonblight.cpp
@@ -13,32 +13,41 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Dragonblight
 SD%Complete: 100
 SDComment:
 SDCategory: Dragonblight
 EndScriptData */
+
 /* ContentData
 npc_alexstrasza_wr_gate
 EndContentData */
+
 #include "precompiled.h"
+
 enum eEnums
 {
     QUEST_RETURN_TO_AG_A    = 12499,
     QUEST_RETURN_TO_AG_H    = 12500,
     MOVIE_ID_GATES          = 14
 };
+
 #define GOSSIP_ITEM_WHAT_HAPPENED   "Alexstrasza, can you show me what happened here?"
+
 bool GossipHello_npc_alexstrasza_wr_gate(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestRewardStatus(QUEST_RETURN_TO_AG_A) || pPlayer->GetQuestRewardStatus(QUEST_RETURN_TO_AG_H))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_WHAT_HAPPENED, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_alexstrasza_wr_gate(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -46,11 +55,14 @@ bool GossipSelect_npc_alexstrasza_wr_gate(Player* pPlayer, Creature* pCreature,
         pPlayer->CLOSE_GOSSIP_MENU();
         pPlayer->SendMovieStart(MOVIE_ID_GATES);
     }
+
     return true;
 }
+
 void AddSC_dragonblight()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_alexstrasza_wr_gate";
     newscript->pGossipHello = &GossipHello_npc_alexstrasza_wr_gate;
diff --git a/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_dred.cpp b/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_dred.cpp
index b4b8d22c5fa..eedc97e3e36 100644
--- a/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_dred.cpp
+++ b/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_dred.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_drak_tharon_keep.h"
+
 enum Spells
 {
     SPELL_BELLOWING_ROAR                     = 44863, // fears the group, can be resisted/dispelled
@@ -20,43 +22,53 @@ enum Spells
     SPELL_PIERCING_SLASH                     = 48878, //debuff -->Armor reduced by 75%
     SPELL_RAPTOR_CALL                        = 59416 //dummy
 };
+
 struct TRINITY_DLL_DECL boss_dredAI : public ScriptedAI
 {
     boss_dredAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_DRED_EVENT,NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
             pInstance->SetData(DATA_DRED_EVENT,IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_DRED_EVENT,DONE);
     }
 };
+
 CreatureAI* GetAI_boss_dred(Creature* pCreature)
 {
     return new boss_dredAI (pCreature);
 }
+
 void AddSC_boss_dred()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_dred";
     newscript->GetAI = &GetAI_boss_dred;
diff --git a/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_novos.cpp b/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_novos.cpp
index eead65d916f..2f07378c992 100644
--- a/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_novos.cpp
+++ b/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_novos.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_novos' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_drak_tharon_keep.h"
+
 enum Spells
 {
     SPELL_ARCANE_BLAST                        = 49198,
@@ -50,12 +52,15 @@ enum Achievement
 {
     ACHIEVEMENT_OH_NOVOS                   = 2057
 };
+
 struct Location
 {
     float x,y,z;
 };
+
 static Location AddSpawnPoint = { -379.20, -816.76, 59.70};
 static Location AddDestinyPoint = { -282.169, -711.369, 27.375};
+
 struct TRINITY_DLL_DECL boss_novosAI : public Scripted_NoMovementAI
 {
     boss_novosAI(Creature *c) : Scripted_NoMovementAI(c)
@@ -63,12 +68,18 @@ struct TRINITY_DLL_DECL boss_novosAI : public Scripted_NoMovementAI
         pInstance = c->GetInstanceData();
         Reset();
     }
+
     uint32 uiTimer;
     uint32 uiCrystalHandlerTimer;
+
     bool bAchiev;
+
     std::list luiCrystals;
+
     CombatPhase Phase;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         Phase = IDLE;
@@ -88,6 +99,7 @@ struct TRINITY_DLL_DECL boss_novosAI : public Scripted_NoMovementAI
             }
         }
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
@@ -108,6 +120,7 @@ struct TRINITY_DLL_DECL boss_novosAI : public Scripted_NoMovementAI
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         switch (Phase)
@@ -147,6 +160,7 @@ struct TRINITY_DLL_DECL boss_novosAI : public Scripted_NoMovementAI
     {
         if (pInstance)
             pInstance->SetData(DATA_NOVOS_EVENT, DONE);
+
         if (HeroicMode && bAchiev)
         {
             AchievementEntry const *AchievOhNovos = GetAchievementStore()->LookupEntry(ACHIEVEMENT_OH_NOVOS);
@@ -156,18 +170,20 @@ struct TRINITY_DLL_DECL boss_novosAI : public Scripted_NoMovementAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievOhNovos);
                 }
             }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void RemoveCrystal()
     {
         if (!luiCrystals.empty())
@@ -188,26 +204,32 @@ struct TRINITY_DLL_DECL boss_novosAI : public Scripted_NoMovementAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_crystal_handlerAI : public ScriptedAI
 {
     mob_crystal_handlerAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     void JustDied(Unit* killer)
     {
         if (Creature* pNovos = Unit::GetCreature(*m_creature, pInstance ? pInstance->GetData64(DATA_NOVOS) : 0))
             CAST_AI(boss_novosAI,pNovos->AI())->RemoveCrystal();
     }
 };
+
 struct TRINITY_DLL_DECL mob_novos_minionAI : public ScriptedAI
 {
     mob_novos_minionAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     void MovementInform(uint32 type, uint32 id)
     {
         if(type != POINT_MOTION_TYPE)
@@ -216,29 +238,36 @@ struct TRINITY_DLL_DECL mob_novos_minionAI : public ScriptedAI
             CAST_AI(boss_novosAI, pNovos->AI())->bAchiev = false;
     }
 };
+
 CreatureAI* GetAI_boss_novos(Creature* pCreature)
 {
     return new boss_novosAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_crystal_handler(Creature* pCreature)
 {
     return new mob_crystal_handlerAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_novos_minion(Creature* pCreature)
 {
     return new mob_novos_minionAI (pCreature);
 }
+
 void AddSC_boss_novos()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_novos";
     newscript->GetAI = &GetAI_boss_novos;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_crystal_handler";
     newscript->GetAI = &GetAI_mob_crystal_handler;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_novos_minion";
     newscript->GetAI = &GetAI_mob_novos_minion;
diff --git a/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_tharon_ja.cpp b/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_tharon_ja.cpp
index 3d65f24fc89..185d062b11a 100644
--- a/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_tharon_ja.cpp
+++ b/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_tharon_ja.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_tharon_ja' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_drak_tharon_keep.h"
+
 enum Spells
 {
     SPELL_COURSE_OF_LIFE                          = 49527,
@@ -38,6 +40,7 @@ enum PlayerSkills
 };
 //Phase 1 all abilities except Eye beam
 //Phase 2 turns players to skeletons with new abilities, boss grows skin
+
 //not in db
 enum Yells
 {
@@ -50,13 +53,16 @@ enum Yells
     SAY_SKELETON_2                              = -1600017,
     SAY_DEATH                                   = -1600018
 };
+
 struct TRINITY_DLL_DECL boss_tharon_jaAI : public ScriptedAI
 {
     boss_tharon_jaAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         if (pInstance)
@@ -65,6 +71,7 @@ struct TRINITY_DLL_DECL boss_tharon_jaAI : public ScriptedAI
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_THARON_JA_EVENT, IN_PROGRESS);
     }
@@ -75,26 +82,33 @@ struct TRINITY_DLL_DECL boss_tharon_jaAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2),m_creature);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH,m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_THARON_JA_EVENT, DONE);
     }
 };
+
 CreatureAI* GetAI_boss_tharon_ja(Creature* pCreature)
 {
     return new boss_tharon_jaAI (pCreature);
 }
+
 void AddSC_boss_tharon_ja()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_tharon_ja";
     newscript->GetAI = &GetAI_boss_tharon_ja;
diff --git a/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_trollgore.cpp b/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_trollgore.cpp
index b2b16a8b234..64c476296cc 100644
--- a/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_trollgore.cpp
+++ b/src/bindings/scripts/scripts/northrend/draktharon_keep/boss_trollgore.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_trollgore' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_drak_tharon_keep.h"
+
 enum Spells
 {
     SPELL_INFECTED_WOUND                          = 49637,
@@ -29,21 +31,26 @@ enum Yells
     SAY_EXPLODE                                = -1600009,
     SAY_DEATH                                  = -1600010
 };
+
 struct TRINITY_DLL_DECL boss_trollgoreAI : public ScriptedAI
 {
     boss_trollgoreAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_TROLLGORE_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_TROLLGORE_EVENT, IN_PROGRESS);
     }
@@ -54,11 +61,13 @@ struct TRINITY_DLL_DECL boss_trollgoreAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_TROLLGORE_EVENT, DONE);
     }
@@ -69,13 +78,16 @@ struct TRINITY_DLL_DECL boss_trollgoreAI : public ScriptedAI
         DoScriptText(SAY_KILL, m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_trollgore(Creature* pCreature)
 {
     return new boss_trollgoreAI (pCreature);
 }
+
 void AddSC_boss_trollgore()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_trollgore";
     newscript->GetAI = &GetAI_boss_trollgore;
diff --git a/src/bindings/scripts/scripts/northrend/draktharon_keep/instance_drak_tharon_keep.cpp b/src/bindings/scripts/scripts/northrend/draktharon_keep/instance_drak_tharon_keep.cpp
index bfbf25b80f7..4b498223838 100644
--- a/src/bindings/scripts/scripts/northrend/draktharon_keep/instance_drak_tharon_keep.cpp
+++ b/src/bindings/scripts/scripts/northrend/draktharon_keep/instance_drak_tharon_keep.cpp
@@ -1,5 +1,6 @@
 #include "precompiled.h"
 #include "def_drak_tharon_keep.h"
+
 #define MAX_ENCOUNTER     4
 /* Drak'Tharon Keep encounters:
 0 - Trollgore
@@ -7,19 +8,25 @@
 2 - King Dred
 3 - Tharon Ja
 */
+
 struct TRINITY_DLL_DECL instance_drak_tharon : public ScriptedInstance
 {
     instance_drak_tharon(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 uiTrollgore;
     uint64 uiNovos;
     uint64 uiDred;
     uint64 uiTharonJa;
+
     uint64 uiNovosCrystal1;
     uint64 uiNovosCrystal2;
     uint64 uiNovosCrystal3;
     uint64 uiNovosCrystal4;
+
     uint8 m_auiEncounter[MAX_ENCOUNTER];
+
     std::string str_data;
+
     void Initialize()
     {
         uiTrollgore = 0;
@@ -31,12 +38,15 @@ struct TRINITY_DLL_DECL instance_drak_tharon : public ScriptedInstance
         uiNovosCrystal3 = 0;
         uiNovosCrystal4 = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -55,6 +65,7 @@ struct TRINITY_DLL_DECL instance_drak_tharon : public ScriptedInstance
                 break;
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -73,6 +84,7 @@ struct TRINITY_DLL_DECL instance_drak_tharon : public ScriptedInstance
                 break;
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -86,8 +98,10 @@ struct TRINITY_DLL_DECL instance_drak_tharon : public ScriptedInstance
             case DATA_NOVOS_CRYSTAL_3:    return uiNovosCrystal3;
             case DATA_NOVOS_CRYSTAL_4:    return uiNovosCrystal4;
         }
+
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -105,11 +119,13 @@ struct TRINITY_DLL_DECL instance_drak_tharon : public ScriptedInstance
                 m_auiEncounter[3] = data;
                 break;
         }
+
         if (data == DONE)
         {
             SaveToDB();
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch (type)
@@ -121,17 +137,23 @@ struct TRINITY_DLL_DECL instance_drak_tharon : public ScriptedInstance
         }
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::string str_data;
+
         std::ostringstream saveStream;
         saveStream << "D K " << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
             << m_auiEncounter[2] << " " << m_auiEncounter[3];
+
         str_data = saveStream.str();
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -139,28 +161,36 @@ struct TRINITY_DLL_DECL instance_drak_tharon : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         char dataHead1, dataHead2;
         uint16 data0,data1,data2,data3;
+
         std::istringstream loadStream(in);
         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3;
+
         if (dataHead1 == 'D' && dataHead2 == 'K')
         {
             m_auiEncounter[0] = data0;
             m_auiEncounter[1] = data1;
             m_auiEncounter[2] = data2;
             m_auiEncounter[3] = data3;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 if (m_auiEncounter[i] == IN_PROGRESS)
                     m_auiEncounter[i] = NOT_STARTED;
         }else OUT_LOAD_INST_DATA_FAIL;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_drak_tharon(Map* pMap)
 {
     return new instance_drak_tharon(pMap);
 }
+
 void AddSC_instance_drak_tharon()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/grizzly_hills.cpp b/src/bindings/scripts/scripts/northrend/grizzly_hills.cpp
index 0e289b2dfbc..2d115bcdeb8 100644
--- a/src/bindings/scripts/scripts/northrend/grizzly_hills.cpp
+++ b/src/bindings/scripts/scripts/northrend/grizzly_hills.cpp
@@ -13,40 +13,51 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Grizzly_Hills
 SD%Complete: 80
 SDComment: Quest support: 12231, 12247
 SDCategory: Grizzly Hills
 EndScriptData */
+
 /* ContentData
 npc_orsonn_and_kodian
 EndContentData */
+
 #include "precompiled.h"
+
 #define GOSSIP_ITEM1 "You're free to go Orsonn, but first tell me what's wrong with the furbolg."
 #define GOSSIP_ITEM2 "What happened then?"
 #define GOSSIP_ITEM3 "Thank you, Son of Ursoc. I'll see what can be done."
 #define GOSSIP_ITEM4 "Who was this stranger?"
 #define GOSSIP_ITEM5 "Thank you, Kodian. I'll do what I can."
+
 enum eEnums
 {
     GOSSIP_TEXTID_ORSONN1       = 12793,
     GOSSIP_TEXTID_ORSONN2       = 12794,
     GOSSIP_TEXTID_ORSONN3       = 12796,
+
     GOSSIP_TEXTID_KODIAN1       = 12797,
     GOSSIP_TEXTID_KODIAN2       = 12798,
+
     NPC_ORSONN                  = 27274,
     NPC_KODIAN                  = 27275,
+
     //trigger creatures
     NPC_ORSONN_CREDIT           = 27322,
     NPC_KODIAN_CREDIT           = 27321,
+
     QUEST_CHILDREN_OF_URSOC     = 12247,
     QUEST_THE_BEAR_GODS_OFFSPRING        = 12231
 };
+
 bool GossipHello_npc_orsonn_and_kodian(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_CHILDREN_OF_URSOC) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestStatus(QUEST_THE_BEAR_GODS_OFFSPRING) == QUEST_STATUS_INCOMPLETE)
     {
         switch(pCreature->GetEntry())
@@ -69,9 +80,11 @@ bool GossipHello_npc_orsonn_and_kodian(Player* pPlayer, Creature* pCreature)
                 break;
         }
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_orsonn_and_kodian(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -88,6 +101,7 @@ bool GossipSelect_npc_orsonn_and_kodian(Player* pPlayer, Creature* pCreature, ui
             pPlayer->CLOSE_GOSSIP_MENU();
             pPlayer->TalkedToCreature(NPC_ORSONN_CREDIT, pCreature->GetGUID());
             break;
+
         case GOSSIP_ACTION_INFO_DEF+4:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
             pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_KODIAN2, pCreature->GetGUID());
@@ -97,11 +111,14 @@ bool GossipSelect_npc_orsonn_and_kodian(Player* pPlayer, Creature* pCreature, ui
             pPlayer->TalkedToCreature(NPC_KODIAN_CREDIT, pCreature->GetGUID());
             break;
     }
+
     return true;
 }
+
 void AddSC_grizzly_hills()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "npc_orsonn_and_kodian";
     newscript->pGossipHello = &GossipHello_npc_orsonn_and_kodian;
diff --git a/src/bindings/scripts/scripts/northrend/gundrak/boss_drakkari_colossus.cpp b/src/bindings/scripts/scripts/northrend/gundrak/boss_drakkari_colossus.cpp
index 4542cbd124f..3ca1abdd8f1 100644
--- a/src/bindings/scripts/scripts/northrend/gundrak/boss_drakkari_colossus.cpp
+++ b/src/bindings/scripts/scripts/northrend/gundrak/boss_drakkari_colossus.cpp
@@ -15,6 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* Script Data Start
 SDName: Boss Drakkari Colossus
 SDAuthor: Manuel
@@ -22,137 +23,178 @@ SD%Complete: 95 %
 SDComment: The event with the Living Mojos is not implemented, just is done that when one of the mojos around the boss take damage will make that the boss enter in combat!
 SDCategory:
 Script Data End */
+
 #include "precompiled.h"
 #include "def_gundrak.h"
+
 enum Spells
 {
     SPELL_EMERGE        = 54850,
     SPELL_EMERGE_2      = 54851,
+
     SPELL_MIGHTY_BLOW   = 54719,
+
     SPELL_MERGE         = 54878,
     SPELL_SURGE         = 54801,
+
     SPELL_FREEZE_ANIM   = 16245,
+
     SPELL_MOJO_PUDDLE   = 55627,
     H_SPELL_MOJO_PUDDLE = 58994,
+
     SPELL_MOJO_WAVE     = 55626,
     H_SPELL_MOJO_WAVE   = 58993
 };
+
 enum Entries
 {
     DRAKKARI_COLOSSUS   = 29307,
     //DRAKKARI_ELEMENTAL  = 29573
 };
+
 struct TRINITY_DLL_DECL boss_drakkari_colossusAI : public ScriptedAI
 {
     boss_drakkari_colossusAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     bool Summoned;
+
     uint32 Summon_Timer;
     uint32 MightyBlowTimer;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_DRAKKARI_COLOSSUS_EVENT, NOT_STARTED);
+
         m_creature->clearUnitState(UNIT_STAT_STUNNED);
         m_creature->SetReactState(REACT_PASSIVE);
+
         Summoned = false;
+
         MightyBlowTimer = 10000;
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
             pInstance->SetData(DATA_DRAKKARI_COLOSSUS_EVENT, IN_PROGRESS);
     }
+
     void PrepareToSummonElemental()
     {
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->addUnitState(UNIT_STAT_STUNNED);
         m_creature->CastSpell(m_creature,SPELL_EMERGE,false);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (Summoned == false && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 6)
         {
             PrepareToSummonElemental();
             m_creature->CastSpell(m_creature->getVictim(), SPELL_EMERGE_2, true);
             Summoned = true;
         }
+
         if (Summoned == true && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 5)
         {
             m_creature->RemoveAllAuras();
             m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
             m_creature->addUnitState(UNIT_STAT_STUNNED);
             m_creature->RemoveAllAuras();
+
             Summoned = false;
         }
+
         if (MightyBlowTimer < diff)
         {
             if (!m_creature->hasUnitState(UNIT_STAT_STUNNED))
             {
                 m_creature->CastSpell(m_creature->getVictim(),SPELL_MIGHTY_BLOW,true);
             }
+
             MightyBlowTimer = 10000;
         } else MightyBlowTimer -= diff;
+
         if (!m_creature->hasUnitState(UNIT_STAT_STUNNED))
             DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_DRAKKARI_COLOSSUS_EVENT, DONE);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature->getVictim());
     }
 };
+
 struct TRINITY_DLL_DECL boss_drakkari_elementalAI : public ScriptedAI
 {
     boss_drakkari_elementalAI(Creature *c) : ScriptedAI(c)
     {
         Colossus = c->FindNearestCreature(DRAKKARI_COLOSSUS, 30.0f, true);
     }
+
     Creature* Colossus;
+
     uint32 SurgeTimer;
+
     bool PreparationDone;
     bool GoToColossus;
     bool Checked;
+
     void Reset()
     {
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->clearUnitState(UNIT_STAT_STUNNED);
+
         SurgeTimer = 7000;
+
         GoToColossus = false;
         PreparationDone = false;
         Checked = false;
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if(!UpdateVictim())
             return;
+
         if(GoToColossus == false && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50)
         {
             m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
             m_creature->CastSpell(Colossus ,SPELL_MERGE,true);
+
             GoToColossus = true;
             PreparationDone = true;
         }
+
         if(GoToColossus == true && PreparationDone == true)
         {
             m_creature->addUnitState(UNIT_STAT_STUNNED);
             m_creature->SetVisibility(VISIBILITY_OFF);
             m_creature->CastSpell(Colossus ,SPELL_MERGE,true);
+
             PreparationDone = false;
+
             Colossus->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
             Colossus->clearUnitState(UNIT_STAT_STUNNED);
         }
+
         if (SurgeTimer < diff)
         {
             if(m_creature->GetVisibility() == VISIBILITY_ON)
@@ -160,8 +202,10 @@ struct TRINITY_DLL_DECL boss_drakkari_elementalAI : public ScriptedAI
                 Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
                 m_creature->CastSpell(target,SPELL_SURGE,false);
             }
+
             SurgeTimer = 7000;
         } else SurgeTimer -= diff;
+
         if(Checked == false && Colossus->GetHealth()*100 / Colossus->GetMaxHealth() <= 5)
         {
             m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -169,24 +213,30 @@ struct TRINITY_DLL_DECL boss_drakkari_elementalAI : public ScriptedAI
             m_creature->SetVisibility(VISIBILITY_ON);
             Checked = true;
         }
+
         //prevent do melee if is invisible
         if(m_creature->GetVisibility() == VISIBILITY_ON)
             DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         Colossus->Kill(Colossus);
     }
 };
+
 struct TRINITY_DLL_DECL npc_living_mojoAI : public ScriptedAI
 {
     npc_living_mojoAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
+
     uint32 MojoWaveTimer;
     uint32 MojoPuddleTimer;
+
     void Reset()
     {
         //Check if the npc is near of Drakkari Colossus.
@@ -199,6 +249,7 @@ struct TRINITY_DLL_DECL npc_living_mojoAI : public ScriptedAI
             MojoPuddleTimer = 7000;
         }
     }
+
     void DamageTaken(Unit* pDone_by, uint32& uiDamage)
     {
         if (m_creature->HasReactState(REACT_PASSIVE))
@@ -213,47 +264,59 @@ struct TRINITY_DLL_DECL npc_living_mojoAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (MojoWaveTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_MOJO_WAVE, H_SPELL_MOJO_WAVE));
             MojoWaveTimer = 15000;
         } else MojoWaveTimer -= diff;
+
         if (MojoPuddleTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_MOJO_PUDDLE, H_SPELL_MOJO_PUDDLE));
             MojoPuddleTimer = 18000;
         } else MojoPuddleTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
 };
+
 CreatureAI* GetAI_boss_drakkari_colossus(Creature* pCreature)
 {
     return new boss_drakkari_colossusAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_drakkari_elemental(Creature* pCreature)
 {
     return new boss_drakkari_elementalAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_living_mojo(Creature* pCreature)
 {
     return new npc_living_mojoAI (pCreature);
 }
+
 void AddSC_boss_drakkari_colossus()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_drakkari_colossus";
     newscript->GetAI = &GetAI_boss_drakkari_colossus;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_drakkari_elemental";
     newscript->GetAI = &GetAI_boss_drakkari_elemental;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_living_mojo";
     newscript->GetAI = &GetAI_npc_living_mojo;
diff --git a/src/bindings/scripts/scripts/northrend/gundrak/boss_eck.cpp b/src/bindings/scripts/scripts/northrend/gundrak/boss_eck.cpp
index ed428f3730b..af0ebba511b 100644
--- a/src/bindings/scripts/scripts/northrend/gundrak/boss_eck.cpp
+++ b/src/bindings/scripts/scripts/northrend/gundrak/boss_eck.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment: Only appears in Heroic mode
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_gundrak.h"
+
 enum Spells
 {
     SPELL_ECK_BERSERK                       = 55816, //Eck goes berserk, increasing his attack speed by 150% and all damage he deals by 500%.
@@ -24,42 +26,53 @@ struct TRINITY_DLL_DECL boss_eckAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiBerserkTimer;
     uint32 uiBiteTimer;
     uint32 uiSpitTimer;
     uint32 uiSpringTimer;
+
     bool bBerserk;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiBerserkTimer = 60000 + rand()%30000; //60-90 secs according to wowwiki
         uiBiteTimer = 5000;
         uiSpitTimer = 10000;
         uiSpringTimer = 8000;
+
         bBerserk = false;
+
         if (pInstance)
             pInstance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
             pInstance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiBiteTimer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_ECK_BITE);
             uiBiteTimer = 8000 + rand()%4000;
         } else uiBiteTimer -= diff;
+
         if (uiSpitTimer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_ECK_SPIT);
             uiSpitTimer = 6000 + rand()%8000;
         } else uiSpitTimer -= diff;
+
         if (uiSpringTimer < diff)
         {
             Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,1);
@@ -69,6 +82,7 @@ struct TRINITY_DLL_DECL boss_eckAI : public ScriptedAI
                 uiSpringTimer = 5000 + rand()%10000;
             }
         } else uiSpringTimer -= diff;
+
         //Berserk on timer or 20% of health
         if (!bBerserk)
         {
@@ -87,21 +101,26 @@ struct TRINITY_DLL_DECL boss_eckAI : public ScriptedAI
                 }
             }
         }
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, DONE);
     }
 };
+
 CreatureAI* GetAI_boss_eck(Creature* pCreature)
 {
     return new boss_eckAI (pCreature);
 }
+
 void AddSC_boss_eck()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_eck";
     newscript->GetAI = &GetAI_boss_eck;
diff --git a/src/bindings/scripts/scripts/northrend/gundrak/boss_gal_darah.cpp b/src/bindings/scripts/scripts/northrend/gundrak/boss_gal_darah.cpp
index 36a08a7394a..b82f937c157 100644
--- a/src/bindings/scripts/scripts/northrend/gundrak/boss_gal_darah.cpp
+++ b/src/bindings/scripts/scripts/northrend/gundrak/boss_gal_darah.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_gundrak.h"
+
 //Spells
 enum Spells
 {
@@ -25,6 +27,7 @@ enum Spells
     SPELL_WHIRLING_SLASH                          = 55249,
     H_SPELL_WHIRLING_SLASH                        = 55825
 };
+
 //Yells
 enum Yells
 {
@@ -39,26 +42,33 @@ enum Yells
     SAY_TRANSFORM_1                            = -1604008,  //Phase change
     SAY_TRANSFORM_2                            = -1604009
 };
+
 enum CombatPhase
 {
     TROLL,
     RHINO
 };
+
 struct TRINITY_DLL_DECL boss_gal_darahAI : public ScriptedAI
 {
     boss_gal_darahAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiStampedeTimer;
     uint32 uiWhirlingSlashTimer;
     uint32 uiPunctureTimer;
     uint32 uiEnrageTimer;
     uint32 uiImpalingChargeTimer;
     uint32 uiStompTimer;
+
     CombatPhase Phase;
+
     uint8 uiPhaseCounter;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiStampedeTimer = 10000;
@@ -67,21 +77,27 @@ struct TRINITY_DLL_DECL boss_gal_darahAI : public ScriptedAI
         uiEnrageTimer = 15000;
         uiImpalingChargeTimer = 20000;
         uiStompTimer = 25000;
+
         Phase = TROLL;
+
         if (pInstance)
             pInstance->SetData(DATA_GAL_DARAH_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_GAL_DARAH_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         switch (Phase)
         {
             case TROLL:
@@ -100,6 +116,7 @@ struct TRINITY_DLL_DECL boss_gal_darahAI : public ScriptedAI
                         DoScriptText(RAND(SAY_SUMMON_RHINO_1,SAY_SUMMON_RHINO_2,SAY_SUMMON_RHINO_3),m_creature);
                         uiStampedeTimer = 15000;
                     } else uiStampedeTimer -= diff;
+
                     if (uiWhirlingSlashTimer < diff)
                     {
                         DoCast(m_creature->getVictim(), HEROIC(SPELL_WHIRLING_SLASH, H_SPELL_WHIRLING_SLASH));
@@ -123,16 +140,19 @@ struct TRINITY_DLL_DECL boss_gal_darahAI : public ScriptedAI
                         DoCast(m_creature->getVictim(), HEROIC(SPELL_PUNCTURE, H_SPELL_PUNCTURE));
                         uiPunctureTimer = 8000;
                     } else uiPunctureTimer -= diff;
+
                     if (uiEnrageTimer < diff)
                     {
                         DoCast(m_creature->getVictim(), HEROIC(SPELL_ENRAGE, H_SPELL_ENRAGE));
                         uiEnrageTimer = 20000;
                     } else uiEnrageTimer -= diff;
+
                     if(uiStompTimer < diff)
                     {
                         DoCast(m_creature->getVictim(), HEROIC(SPELL_STOMP, H_SPELL_STOMP));
                         uiStompTimer = 20000;
                     } else uiStompTimer -= diff;
+
                     if (uiImpalingChargeTimer < diff)
                     {
                         if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
@@ -143,28 +163,36 @@ struct TRINITY_DLL_DECL boss_gal_darahAI : public ScriptedAI
                 }
             break;
         }
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_GAL_DARAH_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_gal_darah(Creature* pCreature)
 {
     return new boss_gal_darahAI (pCreature);
 }
+
 void AddSC_boss_gal_darah()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_gal_darah";
     newscript->GetAI = &GetAI_boss_gal_darah;
diff --git a/src/bindings/scripts/scripts/northrend/gundrak/boss_moorabi.cpp b/src/bindings/scripts/scripts/northrend/gundrak/boss_moorabi.cpp
index eaf6a35c34e..a352310a78d 100644
--- a/src/bindings/scripts/scripts/northrend/gundrak/boss_moorabi.cpp
+++ b/src/bindings/scripts/scripts/northrend/gundrak/boss_moorabi.cpp
@@ -5,19 +5,26 @@ SD%Complete: 100%
 SDComment: Maybe needs better timers.
 SDCategory: Gundrak
 Script Data End */
+
 #include "precompiled.h"
 #include "def_gundrak.h"
+
 //Spells
+
 #define SPELL_DETERMINED_STAB                        55104
 #define SPELL_GROUND_TREMOR                          55142
 #define SPELL_NUMBING_SHOUT                          55106
+
 #define SPELL_DETERMINED_GORE                        55102
 #define SPELL_DETERMINED_GORE_1                      59444
 #define SPELL_QUAKE                                  55101
 #define SPELL_NUMBING_ROAR                           55100
+
 #define SPELL_MOJO_FRENZY                            55163
 #define SPELL_TRANSFORMATION                         55098 //Periodic, The caster transforms into a powerful mammoth, increasing Physical damage done by 25% and granting immunity to Stun effects.
+
 #define ACHIEVEMENT_LESS_RABI                         2040
+
 //Yell
 #define SAY_AGGRO                                 -1604010
 //#define SAY_SLAY_1                                -1604011 // not in db
@@ -27,12 +34,14 @@ Script Data End */
 #define SAY_TRANSFORM                             -1604015
 #define SAY_QUAKE                                 -1604016
 #define EMOTE_TRANSFORM                           -1604017
+
 struct TRINITY_DLL_DECL boss_moorabiAI : public ScriptedAI
 {
     boss_moorabiAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     bool Phase;
     uint32 SPELL_QUAKE_TIMER;
@@ -40,6 +49,7 @@ struct TRINITY_DLL_DECL boss_moorabiAI : public ScriptedAI
     uint32 SPELL_GROUND_TREMOR_TIMER;
     uint32 SPELL_DETERMINED_STAB_TIMER;
     uint32 SPELL_TRANSFORMATION_TIMER;
+
     void Reset()
     {
           SPELL_GROUND_TREMOR_TIMER = 18000;
@@ -47,37 +57,46 @@ struct TRINITY_DLL_DECL boss_moorabiAI : public ScriptedAI
           SPELL_DETERMINED_STAB_TIMER = 20000;
           SPELL_TRANSFORMATION_TIMER = 12000;
           Phase = false;
+
           if (pInstance)
             pInstance->SetData(DATA_MOORABI_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         m_creature->CastSpell(m_creature,SPELL_MOJO_FRENZY,true);
+
         if (pInstance)
             pInstance->SetData(DATA_MOORABI_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
          if (!UpdateVictim())
              return;
+
         if(Phase == false && m_creature->HasAura(SPELL_TRANSFORMATION))
             Phase = true;
+
         if(Phase == true)
         {
             m_creature->RemoveAura(SPELL_MOJO_FRENZY);
+
             if (SPELL_GROUND_TREMOR_TIMER < diff)
             {
                 DoScriptText(SAY_QUAKE, m_creature);
                 m_creature->CastSpell(m_creature->getVictim(),SPELL_QUAKE,true);
                 SPELL_GROUND_TREMOR_TIMER = 10000;
             } else SPELL_GROUND_TREMOR_TIMER -= diff;
+
             if (SPELL_NUMBING_SHOUT_TIMER < diff)
             {
                 m_creature->CastSpell(m_creature->getVictim(),SPELL_NUMBING_ROAR,true);
                 SPELL_NUMBING_SHOUT_TIMER = 10000;
             } else SPELL_NUMBING_SHOUT_TIMER -=diff;
+
             if (SPELL_DETERMINED_STAB_TIMER < diff)
             {
                 DoCast(m_creature->getVictim(), HEROIC(SPELL_DETERMINED_GORE, SPELL_DETERMINED_GORE_1));
@@ -94,6 +113,7 @@ struct TRINITY_DLL_DECL boss_moorabiAI : public ScriptedAI
                 m_creature->CastSpell(m_creature,SPELL_TRANSFORMATION,false);
                 SPELL_TRANSFORMATION_TIMER = 10000;
             } else SPELL_TRANSFORMATION_TIMER -= diff;
+
             //CAST GROUND TERMOR || QUAKE
             if (SPELL_GROUND_TREMOR_TIMER < diff)
             {
@@ -101,23 +121,27 @@ struct TRINITY_DLL_DECL boss_moorabiAI : public ScriptedAI
                 m_creature->CastSpell(m_creature->getVictim(),SPELL_GROUND_TREMOR,true);
                 SPELL_GROUND_TREMOR_TIMER = 10000;
             } else SPELL_GROUND_TREMOR_TIMER -= diff;
+
             //CAST NUMBING SHOUT || DETERMINED_STAB
             if (SPELL_NUMBING_SHOUT_TIMER < diff)
             {
                 m_creature->CastSpell(m_creature->getVictim(),SPELL_NUMBING_SHOUT,true);
                 SPELL_NUMBING_SHOUT_TIMER = 10000;
             } else SPELL_NUMBING_SHOUT_TIMER -= diff;
+
             if (SPELL_DETERMINED_STAB_TIMER < diff)
             {
                 m_creature->CastSpell(m_creature->getVictim(),SPELL_DETERMINED_STAB,true);
                 SPELL_DETERMINED_STAB_TIMER = 8000;
             } else SPELL_DETERMINED_STAB_TIMER -= diff;
         }
+
          DoMeleeAttackIfReady();
      }
      void JustDied(Unit *killer)
      {
          DoScriptText(SAY_DEATH, m_creature);
+
         if (HeroicMode && Phase == false)
         {
             AchievementEntry const *AchievLessRabi = GetAchievementStore()->LookupEntry(ACHIEVEMENT_LESS_RABI);
@@ -127,11 +151,12 @@ struct TRINITY_DLL_DECL boss_moorabiAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievLessRabi);
                 }
             }
         }
+
         if (pInstance)
             pInstance->SetData(DATA_MOORABI_EVENT, DONE);
     }
@@ -139,16 +164,20 @@ struct TRINITY_DLL_DECL boss_moorabiAI : public ScriptedAI
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI *GetAI_boss_moorabi(Creature *pCreature)
 {
     return new boss_moorabiAI(pCreature);
 }
+
 void AddSC_boss_moorabi()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_moorabi";
     newscript->GetAI = &GetAI_boss_moorabi;
diff --git a/src/bindings/scripts/scripts/northrend/gundrak/boss_slad_ran.cpp b/src/bindings/scripts/scripts/northrend/gundrak/boss_slad_ran.cpp
index 81767b128d1..95f74af7e35 100644
--- a/src/bindings/scripts/scripts/northrend/gundrak/boss_slad_ran.cpp
+++ b/src/bindings/scripts/scripts/northrend/gundrak/boss_slad_ran.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_slad_ran' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_gundrak.h"
+
 //Spells
 enum Spells
 {
@@ -20,6 +22,7 @@ enum Spells
     SPELL_VENOM_BOLT                            = 54970,
     H_SPELL_VENOM_BOLT                          = 59839
 };
+
 //Yell
 enum Yells
 {
@@ -31,12 +34,14 @@ enum Yells
     SAY_SUMMON_SNAKES                         = -1604022,
     SAY_SUMMON_CONSTRICTORS                   = -1604023
 };
+
 //Creatures
 enum Creatures
 {
     CREATURE_SNAKE                            = 29680,
     CREATURE_CONSTRICTORS                     = 29713
 };
+
 //Creatures' spells
 enum ConstrictorSpells
 {
@@ -44,11 +49,13 @@ enum ConstrictorSpells
     SPELL_VENOMOUS_BITE                       = 54987,
     H_SPELL_VENOMOUS_BITE                     = 58996
 };
+
 // Spawning locations
 struct Locations
 {
     float x, y, z, orientation;
 };
+
 static Locations SpawnLoc[]=
 {
   {1783.81, 646.637, 133.948, 3.71755},
@@ -57,18 +64,23 @@ static Locations SpawnLoc[]=
   {1765.66, 646.542, 134.02,  5.11381},
   {1716.76, 635.159, 129.282, 0.191986}
 };
+
 struct TRINITY_DLL_DECL boss_slad_ranAI : public ScriptedAI
 {
     boss_slad_ranAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiPoisonNovaTimer;
     uint32 uiPowerfullBiteTimer;
     uint32 uiVenomBoltTimer;
     uint32 uiSpawnTimer;
+
     uint8 uiPhase;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiPoisonNovaTimer = 10000;
@@ -76,48 +88,57 @@ struct TRINITY_DLL_DECL boss_slad_ranAI : public ScriptedAI
         uiVenomBoltTimer = 15000;
         uiSpawnTimer = 5000;
         uiPhase = 0;
+
         if (pInstance)
             pInstance->SetData(DATA_SLAD_RAN_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_SLAD_RAN_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiPoisonNovaTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_POISON_NOVA, H_SPELL_POISON_NOVA));
             uiPoisonNovaTimer = 15000;
         } else uiPoisonNovaTimer -= diff;
+
         if (uiPowerfullBiteTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_POWERFULL_BITE, H_SPELL_POWERFULL_BITE));
             uiPowerfullBiteTimer = 10000;
         } else uiPowerfullBiteTimer -= diff;
+
         if (uiVenomBoltTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_VENOM_BOLT, H_SPELL_VENOM_BOLT));
             uiVenomBoltTimer = 10000;
         } else uiVenomBoltTimer -= diff;
+
         if (uiPhase)
         {
             if(uiSpawnTimer < diff)
             {
                 if (uiPhase == 1)
-                    for (uint8 i = 0; i < (HeroicMode ? 5 : 3); ++i)
+                    for (uint8 i = 0;i < (HeroicMode ? 5 : 3); ++i)
                         m_creature->SummonCreature(CREATURE_SNAKE, SpawnLoc[i].x, SpawnLoc[i].y, SpawnLoc[i].z, SpawnLoc[i].orientation, TEMPSUMMON_CORPSE_TIMED_DESPAWN,20000);
                 if (uiPhase == 2)
-                    for (uint8 i = 0; i < (HeroicMode ? 5 : 3); ++i)
+                    for (uint8 i = 0;i < (HeroicMode ? 5 : 3); ++i)
                         m_creature->SummonCreature(CREATURE_CONSTRICTORS, SpawnLoc[i].x, SpawnLoc[i].y, SpawnLoc[i].z, SpawnLoc[i].orientation, TEMPSUMMON_CORPSE_TIMED_DESPAWN,20000);
                 uiSpawnTimer = 5000;
             } else uiSpawnTimer -= diff;
         }
+
         if ((uiPhase == 0) && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30)
         {
             DoScriptText(SAY_SUMMON_SNAKES,m_creature);
@@ -128,31 +149,41 @@ struct TRINITY_DLL_DECL boss_slad_ranAI : public ScriptedAI
             DoScriptText(SAY_SUMMON_CONSTRICTORS,m_creature);
             uiPhase = 2;
         }
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_SLAD_RAN_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->GetMotionMaster()->MovePoint(0,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ());
+
     }
 };
+
 struct TRINITY_DLL_DECL mob_slad_ran_constrictorAI : public ScriptedAI
 {
     mob_slad_ran_constrictorAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 uiGripOfSladRanTimer;
+
     void Reset()
     {
         uiGripOfSladRanTimer = 1000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -163,21 +194,28 @@ struct TRINITY_DLL_DECL mob_slad_ran_constrictorAI : public ScriptedAI
             uiGripOfSladRanTimer = 5000;
         } else uiGripOfSladRanTimer -= diff;;
     }
+
     ScriptedInstance* pInstance;
 };
+
 struct TRINITY_DLL_DECL mob_slad_ran_viperAI : public ScriptedAI
 {
     mob_slad_ran_viperAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 uiVenomousBiteTimer;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiVenomousBiteTimer = 2000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (uiVenomousBiteTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_VENOMOUS_BITE, H_SPELL_VENOMOUS_BITE));
@@ -185,29 +223,36 @@ struct TRINITY_DLL_DECL mob_slad_ran_viperAI : public ScriptedAI
         } else uiVenomousBiteTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_slad_ran(Creature* pCreature)
 {
     return new boss_slad_ranAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_slad_ran_constrictor(Creature* pCreature)
 {
     return new mob_slad_ran_constrictorAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_slad_ran_viper(Creature* pCreature)
 {
     return new mob_slad_ran_viperAI (pCreature);
 }
+
 void AddSC_boss_slad_ran()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_slad_ran";
     newscript->GetAI = &GetAI_boss_slad_ran;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_slad_ran_constrictor";
     newscript->GetAI = &GetAI_mob_slad_ran_constrictor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_slad_ran_viper";
     newscript->GetAI = &GetAI_mob_slad_ran_viper;
diff --git a/src/bindings/scripts/scripts/northrend/gundrak/def_gundrak.h b/src/bindings/scripts/scripts/northrend/gundrak/def_gundrak.h
index 3428b6dd0e3..957bb9d2367 100644
--- a/src/bindings/scripts/scripts/northrend/gundrak/def_gundrak.h
+++ b/src/bindings/scripts/scripts/northrend/gundrak/def_gundrak.h
@@ -1,5 +1,6 @@
 #ifndef DEF_GUNDRAK_H
 #define DEF_GUNDRAK_H
+
 enum Data
 {
     DATA_SLAD_RAN_EVENT,
@@ -8,6 +9,7 @@ enum Data
     DATA_GAL_DARAH_EVENT,
     DATA_ECK_THE_FEROCIOUS_EVENT
 };
+
 enum Data64
 {
     DATA_SLAD_RAN_ALTAR,
@@ -17,4 +19,5 @@ enum Data64
     DATA_MOORABI_STATUE,
     DATA_DRAKKARI_COLOSSUS_STATUE
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/gundrak/instance_gundrak.cpp b/src/bindings/scripts/scripts/northrend/gundrak/instance_gundrak.cpp
index e67c3888a61..3b8dd7edea2 100644
--- a/src/bindings/scripts/scripts/northrend/gundrak/instance_gundrak.cpp
+++ b/src/bindings/scripts/scripts/northrend/gundrak/instance_gundrak.cpp
@@ -1,6 +1,8 @@
 #include "precompiled.h"
 #include "def_gundrak.h"
+
 #define MAX_ENCOUNTER     5
+
 /* GunDrak encounters:
 0 - Slad'Ran
 1 - Moorabi
@@ -8,6 +10,7 @@
 3 - Gal'Darah
 4 - Eck the Ferocious
 */
+
 struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
 {
     instance_gundrak(Map* pMap) : ScriptedInstance(pMap)
@@ -15,12 +18,15 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
         bHeroicMode = pMap->IsHeroic();
         Initialize();
     };
+
     bool bHeroicMode;
+
     uint64 uiSladRan;
     uint64 uiMoorabi;
     uint64 uiDrakkariColossus;
     uint64 uiGalDarah;
     uint64 uiEckTheFerocious;
+
     uint64 uiSladRanAltar;
     uint64 uiMoorabiAltar;
     uint64 uiDrakkariColossusAltar;
@@ -32,8 +38,11 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
     uint64 uiGalDarahDoor2;
     uint64 uiBridge;
     uint64 uiCollision;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     std::string str_data;
+
     void Initialize()
    {
        uiSladRan = 0;
@@ -41,25 +50,33 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
        uiDrakkariColossus = 0;
        uiGalDarah = 0;
        uiEckTheFerocious = 0;
+
        uiSladRanAltar = 0;
        uiMoorabiAltar = 0;
        uiDrakkariColossusAltar = 0;
+
        uiSladRanStatue = 0;
        uiMoorabiStatue = 0;
        uiDrakkariColossusStatue = 0;
+
        uiEckTheFerociousDoor = 0;
        uiGalDarahDoor1 = 0;
        uiGalDarahDoor2 = 0;
+
        uiBridge = 0;
        uiCollision = 0;
+
        memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
    }
+
    bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -71,6 +88,7 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
             case 29932: uiEckTheFerocious = pCreature->GetGUID(); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -124,6 +142,7 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
                 break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -169,9 +188,11 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
             m_auiEncounter[4] = data;
             break;
         }
+
         if (data == DONE)
             SaveToDB();
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -182,8 +203,10 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
             case DATA_DRAKKARI_COLOSSUS_EVENT:    return m_auiEncounter[3];
             case DATA_ECK_THE_FEROCIOUS_EVENT:    return m_auiEncounter[4];
         }
+
         return 0;
     }
+
     uint64 GetData64(uint32 type)
     {
         switch(type)
@@ -195,18 +218,24 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
             case DATA_MOORABI_STATUE:             return uiMoorabiStatue;
             case DATA_DRAKKARI_COLOSSUS_STATUE:   return uiDrakkariColossusStatue;
         }
+
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::ostringstream saveStream;
         saveStream << "G D " << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
             << m_auiEncounter[2] << " " << m_auiEncounter[3] << " " << m_auiEncounter[4];
+
         str_data = saveStream.str();
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -214,11 +243,15 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         char dataHead1, dataHead2;
         uint16 data0, data1, data2, data3, data4;
+
         std::istringstream loadStream(in);
         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3 >> data4;
+
         if (dataHead1 == 'G' && dataHead2 == 'D')
         {
             m_auiEncounter[0] = data0;
@@ -226,17 +259,21 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
             m_auiEncounter[2] = data2;
             m_auiEncounter[3] = data3;
             m_auiEncounter[4] = data4;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 if (m_auiEncounter[i] == IN_PROGRESS)
                     m_auiEncounter[i] = NOT_STARTED;
         }else OUT_LOAD_INST_DATA_FAIL;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
+
     void CheckAltars()
     {
         GameObject* pSladRanAltar = instance->GetGameObject(uiSladRanAltar);
         GameObject* pMoorabiAltar = instance->GetGameObject(uiMoorabiAltar);
         GameObject* pDrakkariColossusAltar = instance->GetGameObject(uiDrakkariColossusAltar);
+
         if (pSladRanAltar && pSladRanAltar->GetGoState() == GO_STATE_ACTIVE &&
             pMoorabiAltar && pMoorabiAltar->GetGoState() == GO_STATE_ACTIVE &&
             pDrakkariColossusAltar && pDrakkariColossusAltar->GetGoState() == GO_STATE_ACTIVE)
@@ -246,12 +283,15 @@ struct TRINITY_DLL_DECL instance_gundrak : public ScriptedInstance
         }
     }
 };
+
 bool GOHello_altar(Player *pPlayer, GameObject *pGO)
 {
     ScriptedInstance *pInstance = pGO->GetInstanceData();
     uint32 uiStatue;
+
     pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
     pGO->SetGoState(GO_STATE_ACTIVE);
+
     if (pInstance)
     {
         switch(pGO->GetEntry())
@@ -266,10 +306,12 @@ bool GOHello_altar(Player *pPlayer, GameObject *pGO)
     }
     return false;
 }
+
 InstanceData* GetInstanceData_instance_gundrak(Map* pMap)
 {
     return new instance_gundrak(pMap);
 }
+
 void AddSC_instance_gundrak()
 {
     Script *newscript;
@@ -277,6 +319,7 @@ void AddSC_instance_gundrak()
     newscript->Name = "instance_gundrak";
     newscript->GetInstanceData = &GetInstanceData_instance_gundrak;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_gundrak_altar";
     newscript->pGOHello = &GOHello_altar;
diff --git a/src/bindings/scripts/scripts/northrend/howling_fjord.cpp b/src/bindings/scripts/scripts/northrend/howling_fjord.cpp
index e7df7d38ce5..cabb00d748f 100644
--- a/src/bindings/scripts/scripts/northrend/howling_fjord.cpp
+++ b/src/bindings/scripts/scripts/northrend/howling_fjord.cpp
@@ -14,18 +14,22 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Sholazar_Basin
 SD%Complete: 100
 SDComment: Quest support: 11253, 11241.
 SDCategory: howling_fjord
 EndScriptData */
+
 /* ContentData
 npc_plaguehound_tracker
 npc_apothecary_hanes
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_apothecary_hanes
 ######*/
@@ -38,6 +42,7 @@ enum Entries
     QUEST_TRAIL_OF_FIRE          = 11241,
     SPELL_COSMETIC_LOW_POLY_FIRE = 56274
 };
+
 bool QuestAccept_npc_apothecary_hanes(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_TRAIL_OF_FIRE)
@@ -55,20 +60,24 @@ bool QuestAccept_npc_apothecary_hanes(Player* pPlayer, Creature* pCreature, Ques
     }
     return true;
 }
+
 struct TRINITY_DLL_DECL npc_Apothecary_HanesAI : public npc_escortAI
 {
     npc_Apothecary_HanesAI(Creature* pCreature) : npc_escortAI(pCreature){}
     uint32 PotTimer;
+
     void Reset ()
     {
         SetDespawnAtFar(false);
         PotTimer = 10000; //10 sec cooldown on potion
     }
+
     void JustDied(Unit* killer)
     {
         if (Player* pPlayer = GetPlayerForEscort())
             pPlayer->FailQuest(QUEST_TRAIL_OF_FIRE);
     }
+
     void UpdateEscortAI(const uint32 diff)
     {
         if(HealthBelowPct(75))
@@ -82,6 +91,7 @@ struct TRINITY_DLL_DECL npc_Apothecary_HanesAI : public npc_escortAI
         if (GetAttack() && UpdateVictim())
             DoMeleeAttackIfReady();
     }
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
@@ -138,18 +148,22 @@ CreatureAI* GetAI_npc_apothecary_hanes(Creature* pCreature)
 /*######
 ## npc_plaguehound_tracker
 ######*/
+
 enum ePlaguehound
 {
     QUEST_SNIFF_OUT_ENEMY        = 11253
 };
+
 struct TRINITY_DLL_DECL npc_plaguehound_trackerAI : public npc_escortAI
 {
     npc_plaguehound_trackerAI(Creature* pCreature) : npc_escortAI(pCreature) { }
 
+
     void Reset()
     {
         InitScriptData();
     }
+
     void InitScriptData()
     {
         Player* pPlayer = NULL;
@@ -157,11 +171,14 @@ struct TRINITY_DLL_DECL npc_plaguehound_trackerAI : public npc_escortAI
             if(Unit* summoner = CAST_SUM(me)->GetSummoner())
                 if(summoner->GetTypeId() == TYPEID_PLAYER)
                     pPlayer = CAST_PLR(summoner);
+
         if (!pPlayer)
             return;
+
         me->SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE);
         Start(false, false, pPlayer->GetGUID());
     }
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = NULL;
@@ -169,8 +186,10 @@ struct TRINITY_DLL_DECL npc_plaguehound_trackerAI : public npc_escortAI
             if(Unit* summoner = CAST_SUM(me)->GetSummoner())
                 if(summoner->GetTypeId() == TYPEID_PLAYER)
                     pPlayer = CAST_PLR(summoner);
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
         case 26:
@@ -179,15 +198,19 @@ struct TRINITY_DLL_DECL npc_plaguehound_trackerAI : public npc_escortAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_plaguehound_tracker(Creature* pCreature)
 {
     return new npc_plaguehound_trackerAI(pCreature);
 }
+
 /*######
 ## npc_razael_and_lyana
 ######*/
+
 #define GOSSIP_RAZAEL_REPORT "High Executor Anselm wants a report on the situation."
 #define GOSSIP_LYANA_REPORT "High Executor Anselm requests your report."
+
 enum eRazael
 {
     QUEST_REPORTS_FROM_THE_FIELD = 11221,
@@ -198,6 +221,7 @@ enum eRazael
     GOSSIP_TEXTID_LYANA1 = 11586,
     GOSSIP_TEXTID_LYANA2 = 11588
 };
+
 bool GossipHello_npc_razael_and_lyana(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_REPORTS_FROM_THE_FIELD) == QUEST_STATUS_INCOMPLETE)
@@ -223,6 +247,7 @@ bool GossipHello_npc_razael_and_lyana(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_razael_and_lyana(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -238,18 +263,22 @@ bool GossipSelect_npc_razael_and_lyana(Player* pPlayer, Creature* pCreature, uin
     }
     return true;
 }
+
 void AddSC_howling_fjord()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_apothecary_hanes";
     newscript->GetAI = &GetAI_npc_apothecary_hanes;
     newscript->pQuestAccept = &QuestAccept_npc_apothecary_hanes;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_plaguehound_tracker";
     newscript->GetAI = &GetAI_npc_plaguehound_tracker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_razael_and_lyana";
     newscript->pGossipHello =  &GossipHello_npc_razael_and_lyana;
diff --git a/src/bindings/scripts/scripts/northrend/icecrown.cpp b/src/bindings/scripts/scripts/northrend/icecrown.cpp
index 99c251604c5..443b6603943 100644
--- a/src/bindings/scripts/scripts/northrend/icecrown.cpp
+++ b/src/bindings/scripts/scripts/northrend/icecrown.cpp
@@ -13,19 +13,24 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Icecrown
 SD%Complete: 100
 SDComment: Quest support: 12807
 SDCategory: Icecrown
 EndScriptData */
+
 /* ContentData
 npc_arete
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## npc_arete
 ######*/
+
 #define GOSSIP_ARETE_ITEM1 "Lord-Commander, I would hear your tale."
 #define GOSSIP_ARETE_ITEM2 ""
 #define GOSSIP_ARETE_ITEM3 "I thought that they now called themselves the Scarlet Onslaught?"
@@ -33,6 +38,7 @@ EndContentData */
 #define GOSSIP_ARETE_ITEM5 "That's fine. When do I start?"
 #define GOSSIP_ARETE_ITEM6 "Let's finish this!"
 #define GOSSIP_ARETE_ITEM7 "That's quite a tale, Lord-Commander."
+
 enum eArete
 {
     GOSSIP_TEXTID_ARETE1        = 13525,
@@ -42,21 +48,26 @@ enum eArete
     GOSSIP_TEXTID_ARETE5        = 13529,
     GOSSIP_TEXTID_ARETE6        = 13530,
     GOSSIP_TEXTID_ARETE7        = 13531,
+
     QUEST_THE_STORY_THUS_FAR    = 12807
 };
+
 bool GossipHello_npc_arete(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_THE_STORY_THUS_FAR) == QUEST_STATUS_INCOMPLETE)
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ARETE_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_ARETE1, pCreature->GetGUID());
         return true;
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_arete(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -90,11 +101,14 @@ bool GossipSelect_npc_arete(Player* pPlayer, Creature* pCreature, uint32 uiSende
             pPlayer->AreaExploredOrEventHappens(QUEST_THE_STORY_THUS_FAR);
             break;
     }
+
     return true;
 }
+
 void AddSC_icecrown()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_arete";
     newscript->pGossipHello = &GossipHello_npc_arete;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_anubrekhan.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_anubrekhan.cpp
index f14dd5d4daa..2de7abcf392 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_anubrekhan.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_anubrekhan.cpp
@@ -13,39 +13,53 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SAY_GREET           RAND(-1533000,-1533004,-1533005,-1533006,-1533007)
 #define SAY_AGGRO           RAND(-1533001,-1533002,-1533003)
 #define SAY_SLAY            -1533008
+
 #define SPELL_IMPALE        HEROIC(28783,56090)
 #define SPELL_LOCUSTSWARM   HEROIC(28785,54021)
+
 #define SPELL_SELF_SPAWN_5  29105                           //This spawns 5 corpse scarabs ontop of us (most likely the player casts this on death)
+
 #define EVENT_IMPALE        1
 #define EVENT_LOCUST        2
+
 #define MOB_CRYPT_GUARD     16573
+
 struct TRINITY_DLL_DECL boss_anubrekhanAI : public BossAI
 {
     boss_anubrekhanAI(Creature *c) : BossAI(c, BOSS_ANUBREKHAN) { Prepare(); }
+
     bool HasTaunted;
+
     void Prepare()
     {
         HasTaunted = false;
+
         if (HeroicMode)
         {
             DoSpawnCreature(MOB_CRYPT_GUARD, 0, -10, 0, me->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
             DoSpawnCreature(MOB_CRYPT_GUARD, 0, 10, 0, me->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
         }
     }
+
     void InitializeAI() { Prepare(); BossAI::InitializeAI(); }
     void JustReachedHome() { Prepare(); _JustReachedHome(); }
+
     void KilledUnit(Unit* victim)
     {
         //Force the player to spawn corpse scarabs via spell
         victim->CastSpell(victim, SPELL_SELF_SPAWN_5, true, NULL, NULL, me->GetGUID());
+
         if (!(rand()%5))
             DoScriptText(SAY_SLAY, me);
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -53,6 +67,7 @@ struct TRINITY_DLL_DECL boss_anubrekhanAI : public BossAI
         events.ScheduleEvent(EVENT_IMPALE, 15000, 1);
         events.ScheduleEvent(EVENT_LOCUST, 80000 + rand()%40000, 1);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!HasTaunted && me->IsWithinDistInMap(who, 60.0f))
@@ -62,11 +77,14 @@ struct TRINITY_DLL_DECL boss_anubrekhanAI : public BossAI
         }
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim() || !CheckInRoom())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -87,13 +105,16 @@ struct TRINITY_DLL_DECL boss_anubrekhanAI : public BossAI
                     return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_anubrekhan(Creature* pCreature)
 {
     return new boss_anubrekhanAI (pCreature);
 }
+
 void AddSC_boss_anubrekhan()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_faerlina.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_faerlina.cpp
index 8675a47ed87..e7cd19d3b26 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_faerlina.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_faerlina.cpp
@@ -15,27 +15,35 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SAY_GREET       -1533009
 #define SAY_AGGRO       RAND(-1533010,-1533011,-1533012,-1533013)
 #define SAY_SLAY        RAND(-1533014,-1533015)
 #define SAY_DEATH       -1533016
+
 //#define SOUND_RANDOM_AGGRO  8955                            //soundId containing the 4 aggro sounds, we not using this
+
 #define SPELL_POSION_BOLT_VOLLEY    HEROIC(28796,54098)
 #define SPELL_RAIN_OF_FIRE          HEROIC(28794,54099)
 #define SPELL_FRENZY                HEROIC(28798,54100)
 #define SPELL_WIDOWS_EMBRACE        HEROIC(28732,54097)
+
 enum Events
 {
     EVENT_POSION = 1,
     EVENT_FIRE,
     EVENT_FRENZY,
 };
+
 struct TRINITY_DLL_DECL boss_faerlinaAI : public BossAI
 {
     boss_faerlinaAI(Creature *c) : BossAI(c, BOSS_FAERLINA), greet(false) {}
+
     bool greet;
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -44,6 +52,7 @@ struct TRINITY_DLL_DECL boss_faerlinaAI : public BossAI
         events.ScheduleEvent(EVENT_FIRE, 5000 + rand()%15000);
         events.ScheduleEvent(EVENT_FRENZY, 60000 + rand()%20000);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!greet)
@@ -53,21 +62,26 @@ struct TRINITY_DLL_DECL boss_faerlinaAI : public BossAI
         }
         BossAI::MoveInLineOfSight(who);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (!(rand()%3))
             DoScriptText(SAY_SLAY, me);
     }
+
     void JustDied(Unit* Killer)
     {
         _JustDied();
         DoScriptText(SAY_DEATH, me);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -88,13 +102,16 @@ struct TRINITY_DLL_DECL boss_faerlinaAI : public BossAI
                     return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_faerlina(Creature* pCreature)
 {
     return new boss_faerlinaAI (pCreature);
 }
+
 void AddSC_boss_faerlina()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_four_horsemen.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_four_horsemen.cpp
index c841a6877a5..a39e76a24b6 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_four_horsemen.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_four_horsemen.cpp
@@ -13,8 +13,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 enum Horsemen
 {
     HORSEMEN_THANE,
@@ -22,12 +24,14 @@ enum Horsemen
     HORSEMEN_BARON,
     HORSEMEN_SIR,
 };
+
 enum Events
 {
     EVENT_MARK = 1,
     EVENT_CAST,
     EVENT_BERSERK,
 };
+
 const uint32 MOB_HORSEMEN[]     =   {16064, 16065, 30549, 16063};
 const uint32 SPELL_MARK[]       =   {28832, 28833, 28834, 28835};
 #define SPELL_PRIMARY(i)            HEROIC(SPELL_PRIMARY_N[i],SPELL_PRIMARY_H[i])
@@ -38,6 +42,7 @@ const uint32 SPELL_SECONDARY_N[]=   {0, 57374, 0, 57376};
 const uint32 SPELL_SECONDARY_H[]=   {0, 57464, 0, 57465};
 const uint32 SPELL_PUNISH[]     =   {0, 57381, 0, 57377};
 #define SPELL_BERSERK               26662
+
 // used by 16063,16064,16065,30549, but signed for 16063
 const int32 SAY_AGGRO[]     =   {-1533051, -1533044, -1533065, -1533058};
 const int32 SAY_TAUNT[3][4] ={  {-1533052, -1533045, -1533071, -1533059},
@@ -46,26 +51,31 @@ const int32 SAY_TAUNT[3][4] ={  {-1533052, -1533045, -1533071, -1533059},
 const int32 SAY_SPECIAL[]   =   {-1533055, -1533048, -1533070, -1533062};
 const int32 SAY_SLAY[]      =   {-1533056, -1533049, -1533068, -1533063};
 const int32 SAY_DEATH[]     =   {-1533057, -1533050, -1533074, -1533064};
+
 #define SAY_BARON_AGGRO     RAND(-1533065,-1533066,-1533067)
 #define SAY_BARON_SLAY      RAND(-1533068,-1533069)
+
 struct TRINITY_DLL_DECL boss_four_horsemenAI : public BossAI
 {
     boss_four_horsemenAI(Creature *c) : BossAI(c, BOSS_HORSEMEN)
     {
         id = Horsemen(0);
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
             if (me->GetEntry() == MOB_HORSEMEN[i])
                 id = Horsemen(i);
         caster = (id == HORSEMEN_LADY || id == HORSEMEN_SIR);
     }
+
     Horsemen id;
     bool caster;
+
     void MoveInLineOfSight(Unit *who)
     {
         BossAI::MoveInLineOfSight(who);
         if (caster)
             SelectNearestTarget(who);
     }
+
     void AttackStart(Unit *who)
     {
         if (caster)
@@ -73,6 +83,7 @@ struct TRINITY_DLL_DECL boss_four_horsemenAI : public BossAI
         else
             BossAI::AttackStart(who);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (!(rand()%5))
@@ -83,11 +94,13 @@ struct TRINITY_DLL_DECL boss_four_horsemenAI : public BossAI
                 DoScriptText(SAY_SLAY[id], me);
         }
     }
+
     void JustDied(Unit* killer)
     {
         _JustDied();
         DoScriptText(SAY_DEATH[id], me);
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -99,13 +112,17 @@ struct TRINITY_DLL_DECL boss_four_horsemenAI : public BossAI
             events.ScheduleEvent(EVENT_CAST, 20000+rand()%5000);
             events.ScheduleEvent(EVENT_BERSERK, 15*100*1000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim() || !CheckInRoom())
             return;
+
         events.Update(diff);
+
         if (me->hasUnitState(UNIT_STAT_CASTING))
             return;
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -128,16 +145,19 @@ struct TRINITY_DLL_DECL boss_four_horsemenAI : public BossAI
                     return;
             }
         }
+
         if (!caster)
             DoMeleeAttackIfReady();
         else if (!DoSpellAttackIfReady(SPELL_SECONDARY(id)))
             DoCastAOE(SPELL_PUNISH[id]);
     }
 };
+
 CreatureAI* GetAI_four_horsemen(Creature* pCreature)
 {
     return new boss_four_horsemenAI (pCreature);
 }
+
 void AddSC_boss_four_horsemen()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_gluth.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_gluth.cpp
index 05a551d76f2..ed38cbe62c4 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_gluth.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_gluth.cpp
@@ -13,20 +13,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SPELL_MORTAL_WOUND      25646
 #define SPELL_ENRAGE            HEROIC(28371,54427)
 #define SPELL_DECIMATE          HEROIC(28374,54426)
 #define SPELL_BERSERK           26662
 #define SPELL_INFECTED_WOUND    29306
+
 #define MOB_ZOMBIE  16360
+
 const Position PosSummon[3] =
 {
     {3267.9, -3172.1, 297.42, 0.94},
     {3253.2, -3132.3, 297.42, 0},
     {3308.3, -3185.8, 297.42, 1.58},
 };
+
 enum Events
 {
     EVENT_WOUND = 1,
@@ -35,7 +40,9 @@ enum Events
     EVENT_BERSERK,
     EVENT_SUMMON,
 };
+
 #define EMOTE_NEARBY    " spots a nearby zombie to devour!"
+
 struct TRINITY_DLL_DECL boss_gluthAI : public BossAI
 {
     boss_gluthAI(Creature *c) : BossAI(c, BOSS_GLUTH)
@@ -43,12 +50,15 @@ struct TRINITY_DLL_DECL boss_gluthAI : public BossAI
         // Do not let Gluth be affected by zombies' debuff
         me->ApplySpellImmune(0, IMMUNITY_ID, SPELL_INFECTED_WOUND, true);
     }
+
     std::vector triggers;
+
     void Reset()
     {
         triggers.clear();
         _Reset();
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (who->GetEntry() == MOB_ZOMBIE && me->IsWithinDistInMap(who, 15))
@@ -59,9 +69,10 @@ struct TRINITY_DLL_DECL boss_gluthAI : public BossAI
         else
             BossAI::MoveInLineOfSight(who);
     }
+
     void EnterCombat(Unit *who)
     {
-        for (uint32 i = 0; i < 3; ++i)
+        for(uint32 i = 0; i < 3; ++i)
             if (Creature *trigger = DoSummon(WORLD_TRIGGER, PosSummon[i]))
                 triggers.push_back(trigger);
         if (triggers.size() < 3)
@@ -70,6 +81,7 @@ struct TRINITY_DLL_DECL boss_gluthAI : public BossAI
             EnterEvadeMode();
             return;
         }
+
         _EnterCombat();
         events.ScheduleEvent(EVENT_WOUND, 10000);
         events.ScheduleEvent(EVENT_ENRAGE, 30000);
@@ -77,6 +89,7 @@ struct TRINITY_DLL_DECL boss_gluthAI : public BossAI
         events.ScheduleEvent(EVENT_BERSERK, 8*60000);
         events.ScheduleEvent(EVENT_SUMMON, 10000);
     }
+
     void JustSummoned(Creature *summon)
     {
         if (summon->GetEntry() == WORLD_TRIGGER)
@@ -85,11 +98,14 @@ struct TRINITY_DLL_DECL boss_gluthAI : public BossAI
             summon->AI()->AttackStart(me);
         summons.Summon(summon);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictimWithGaze() || !CheckInRoom())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -110,12 +126,13 @@ struct TRINITY_DLL_DECL boss_gluthAI : public BossAI
                     DoCast(me, SPELL_BERSERK);
                     return;
                 case EVENT_SUMMON:
-                    for (uint32 i = 0; i < HEROIC(1,2); ++i)
+                    for(uint32 i = 0; i < HEROIC(1,2); ++i)
                         DoSummon(MOB_ZOMBIE, triggers[rand()%3]);
                     events.ScheduleEvent(EVENT_SUMMON, 10000);
                     return;
             }
         }
+
         if (me->getVictim()->GetEntry() == MOB_ZOMBIE)
         {
             if (me->IsWithinMeleeRange(me->getVictim()))
@@ -128,10 +145,12 @@ struct TRINITY_DLL_DECL boss_gluthAI : public BossAI
             DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_gluth(Creature* pCreature)
 {
     return new boss_gluthAI (pCreature);
 }
+
 void AddSC_boss_gluth()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_gothik.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_gothik.cpp
index e9278b33223..647c62a32eb 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_gothik.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_gothik.cpp
@@ -13,21 +13,26 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SAY_SPEECH                  -1533040
 #define SAY_KILL                    -1533041
 #define SAY_DEATH                   -1533042
 #define SAY_TELEPORT                -1533043
+
 //Gothik
 #define SPELL_HARVEST_SOUL          28679
 #define SPELL_SHADOW_BOLT           HEROIC(29317,56405)
+
 #define SPELL_INFORM_LIVE_TRAINEE   27892
 #define SPELL_INFORM_LIVE_KNIGHT    27928
 #define SPELL_INFORM_LIVE_RIDER     27935
 #define SPELL_INFORM_DEAD_TRAINEE   27915
 #define SPELL_INFORM_DEAD_KNIGHT    27931
 #define SPELL_INFORM_DEAD_RIDER     27937
+
 #define MOB_LIVE_TRAINEE    16124
 #define MOB_LIVE_KNIGHT     16125
 #define MOB_LIVE_RIDER      16126
@@ -35,6 +40,7 @@
 #define MOB_DEAD_KNIGHT     16148
 #define MOB_DEAD_RIDER      16150
 #define MOB_DEAD_HORSE      16149
+
 const struct Waves { uint32 entry, number, time; }
 waves[] =
 {
@@ -63,21 +69,26 @@ waves[] =
     {MOB_LIVE_TRAINEE, 2, 29000},
     {0, 0, 0},
 };
+
 #define POS_Y_GATE  -3360.78f
+
 enum Events
 {
     EVENT_SUMMON = 1,
     EVENT_HARVEST,
     EVENT_BOLT,
 };
+
 #define POS_LIVE 3
 #define POS_DEAD 5
+
 const Position PosSummonLive[POS_LIVE] =
 {
     {2669.7, -3430.9, 268.56, 1.6},
     {2692.0, -3430.9, 268.56, 1.6},
     {2714.1, -3430.9, 268.56, 1.6},
 };
+
 const Position PosSummonDead[POS_DEAD] =
 {
     {2725.1, -3310.0, 268.85, 3.4},
@@ -86,14 +97,18 @@ const Position PosSummonDead[POS_DEAD] =
     {2682.8, -3304.2, 268.85, 3.9},
     {2664.8, -3340.7, 268.23, 3.7},
 };
+
 const float PosGround[4] = {2691.2, -3362.7, 267.68, 1.7};
 const float PosPlatform[4] = {2640.5, -3360.6, 285.26, 0};
+
 struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
 {
     boss_gothikAI(Creature *c) : BossAI(c, BOSS_GOTHIK) {}
+
     uint32 waveCount;
     typedef std::vector TriggerVct;
     TriggerVct liveTrigger, deadTrigger;
+
     void Reset()
     {
         liveTrigger.clear();
@@ -102,20 +117,23 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
         me->SetReactState(REACT_PASSIVE);
         _Reset();
     }
+
     void EnterCombat(Unit *who)
     {
-        for (uint32 i = 0; i < POS_LIVE; ++i)
+        for(uint32 i = 0; i < POS_LIVE; ++i)
             if (Creature *trigger = DoSummon(WORLD_TRIGGER, PosSummonLive[i]))
                 liveTrigger.push_back(trigger);
-        for (uint32 i = 0; i < POS_DEAD; ++i)
+        for(uint32 i = 0; i < POS_DEAD; ++i)
             if (Creature *trigger = DoSummon(WORLD_TRIGGER, PosSummonDead[i]))
                 deadTrigger.push_back(trigger);
+
         if (liveTrigger.size() < POS_LIVE || deadTrigger.size() < POS_DEAD)
         {
             error_log("Script Gothik: cannot summon triggers!");
             EnterEvadeMode();
             return;
         }
+
         _EnterCombat();
         me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
         waveCount = 0;
@@ -125,6 +143,7 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
         if (instance)
             instance->SetData(DATA_GOTHIK_GATE, 1);
     }
+
     void JustSummoned(Creature *summon)
     {
         if (summon->GetEntry() == WORLD_TRIGGER)
@@ -136,23 +155,27 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
         }
         summons.Summon(summon);
     }
+
     void SummonedCreatureDespawn(Creature *summon)
     {
         if (summon->GetEntry() == WORLD_TRIGGER)
         {
-            //for (TriggerVct::iterator itr = liveTrigger.begin(); itr != liveTrigger.end(); ++itr)
+            //for(TriggerVct::iterator itr = liveTrigger.begin(); itr != liveTrigger.end(); ++itr)
             //    if(*itr == summon)
             error_log("boss_gothikAI: trigger is despawned!");
             EnterEvadeMode();
             return;
         }
+
         summons.Despawn(summon);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (!(rand()%5))
             DoScriptText(SAY_KILL, me);
     }
+
     void JustDied(Unit* Killer)
     {
         liveTrigger.clear();
@@ -160,6 +183,7 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
         _JustDied();
         DoScriptText(SAY_DEATH, me);
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         uint32 spellId = 0;
@@ -175,10 +199,12 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
             me->CastSpell(deadTrigger[rand()%POS_DEAD], spellId, true);
         }
     }
+
     void SpellHitTarget(Unit *target, const SpellEntry *spell)
     {
         if (!me->isInCombat())
             return;
+
         switch(spell->Id)
         {
             case SPELL_INFORM_DEAD_TRAINEE: DoSummon(MOB_DEAD_TRAINEE, target, 0);  break;
@@ -187,13 +213,17 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
                 DoSummon(MOB_DEAD_HORSE, target, 1.0f); break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateCombatState() || !CheckInRoom())
             return;
+
         events.Update(diff);
+
         if (me->hasUnitState(UNIT_STAT_CASTING))
             return;
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -201,7 +231,7 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
                 case EVENT_SUMMON:
                     if (waves[waveCount].entry)
                     {
-                        for (uint32 i = 0; i < waves[waveCount].number; ++i)
+                        for(uint32 i = 0; i < waves[waveCount].number; ++i)
                             DoSummon(waves[waveCount].entry, liveTrigger[rand()%POS_LIVE], 1.0f);
                         events.ScheduleEvent(EVENT_SUMMON, waves[waveCount].time);
                         ++waveCount;
@@ -230,27 +260,34 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
                     return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_gothik_minionAI : public CombatAI
 {
     mob_gothik_minionAI(Creature *c) : CombatAI(c)
     {
         liveSide = me->GetPositionY() < POS_Y_GATE;
     }
+
     bool liveSide;
     bool gateClose;
+
 #define SIDE_CHECK(who) (liveSide == (who->GetPositionY() < POS_Y_GATE))
+
     void DoAction(const int32 param)
     {
         gateClose = param;
     }
+
     void DamageTaken(Unit *attacker, uint32 &damage)
     {
         if (gateClose && !SIDE_CHECK(attacker))
             damage = 0;
     }
+
     void JustDied(Unit *killer)
     {
         if (me->isSummon())
@@ -259,6 +296,7 @@ struct TRINITY_DLL_DECL mob_gothik_minionAI : public CombatAI
                 CombatAI::JustDied(owner);
         }
     }
+
     void EnterEvadeMode()
     {
         if (!gateClose)
@@ -266,13 +304,15 @@ struct TRINITY_DLL_DECL mob_gothik_minionAI : public CombatAI
             CombatAI::EnterEvadeMode();
             return;
         }
+
         if (!_EnterEvadeMode())
             return;
+
         Map* pMap = me->GetMap();
         if (pMap->IsDungeon())
         {
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
-            for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+            for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
             {
                 if (i->getSource()->isAlive() && SIDE_CHECK(i->getSource()))
                 {
@@ -281,9 +321,11 @@ struct TRINITY_DLL_DECL mob_gothik_minionAI : public CombatAI
                 }
             }
         }
+
         me->GetMotionMaster()->MoveIdle();
         Reset();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (gateClose && (!SIDE_CHECK(me) || me->getVictim() && !SIDE_CHECK(me->getVictim())))
@@ -291,17 +333,21 @@ struct TRINITY_DLL_DECL mob_gothik_minionAI : public CombatAI
             EnterEvadeMode();
             return;
         }
+
         CombatAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_boss_gothik(Creature* pCreature)
 {
     return new boss_gothikAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_gothik_minion(Creature* pCreature)
 {
     return new mob_gothik_minionAI (pCreature);
 }
+
 void AddSC_boss_gothik()
 {
     Script *newscript;
@@ -309,6 +355,7 @@ void AddSC_boss_gothik()
     newscript->Name = "boss_gothik";
     newscript->GetAI = &GetAI_boss_gothik;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_gothik_minion";
     newscript->GetAI = &GetAI_mob_gothik_minion;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_grobbulus.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_grobbulus.cpp
index 3a346798e9d..38edde2c327 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_grobbulus.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_grobbulus.cpp
@@ -13,25 +13,32 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SPELL_BOMBARD_SLIME         28280
+
 #define SPELL_POISON_CLOUD          28240
 #define SPELL_MUTATING_INJECTION    28169
 #define SPELL_SLIME_SPRAY           HEROIC(28157,54364)
 #define SPELL_BERSERK               26662
 #define SPELL_POISON_CLOUD_ADD      59116
+
 #define EVENT_BERSERK   1
 #define EVENT_CLOUD     2
 #define EVENT_INJECT    3
 #define EVENT_SPRAY     4
+
 #define MOB_FALLOUT_SLIME   16290
+
 struct TRINITY_DLL_DECL boss_grobbulusAI : public BossAI
 {
     boss_grobbulusAI(Creature *c) : BossAI(c, BOSS_GROBBULUS)
     {
         me->ApplySpellImmune(0, IMMUNITY_ID, SPELL_POISON_CLOUD_ADD, true);
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -40,6 +47,7 @@ struct TRINITY_DLL_DECL boss_grobbulusAI : public BossAI
         events.ScheduleEvent(EVENT_SPRAY, 15000+rand()%15000); //not sure
         events.ScheduleEvent(EVENT_BERSERK, 12*60000);
     }
+
     void SpellHitTarget(Unit *target, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_SLIME_SPRAY)
@@ -48,11 +56,14 @@ struct TRINITY_DLL_DECL boss_grobbulusAI : public BossAI
                 DoZoneInCombat(slime);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -76,21 +87,26 @@ struct TRINITY_DLL_DECL boss_grobbulusAI : public BossAI
                     return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL npc_grobbulus_poison_cloudAI : public Scripted_NoMovementAI
 {
     npc_grobbulus_poison_cloudAI(Creature* pCreature) : Scripted_NoMovementAI(pCreature)
     {
         Reset();
     }
+
     uint32 Cloud_Timer;
+
     void Reset()
     {
         Cloud_Timer = 1000;
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Cloud_Timer < diff)
@@ -100,14 +116,17 @@ struct TRINITY_DLL_DECL npc_grobbulus_poison_cloudAI : public Scripted_NoMovemen
         } else Cloud_Timer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_grobbulus(Creature* pCreature)
 {
     return new boss_grobbulusAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_grobbulus_poison_cloud(Creature* pCreature)
 {
     return new npc_grobbulus_poison_cloudAI(pCreature);
 }
+
 void AddSC_boss_grobbulus()
 {
     Script *newscript;
@@ -115,6 +134,7 @@ void AddSC_boss_grobbulus()
     newscript->Name = "boss_grobbulus";
     newscript->GetAI = &GetAI_boss_grobbulus;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_grobbulus_poison_cloud";
     newscript->GetAI = &GetAI_npc_grobbulus_poison_cloud;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_heigan.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_heigan.cpp
index 417dc61b5cf..4cf9eb0ffcb 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_heigan.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_heigan.cpp
@@ -13,15 +13,19 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SAY_AGGRO           RAND(-1533109,-1533110,-1533111)
 #define SAY_SLAY            -1533112
 #define SAY_TAUNT           RAND(-1533113,-1533114,-1533115,-1533116,-1533117)
 #define SAY_DEATH           -1533118
+
 #define SPELL_SPELL_DISRUPTION  29310
 #define SPELL_DECREPIT_FEVER    HEROIC(29998,55011)
 #define SPELL_PLAGUE_CLOUD      29350
+
 enum Events
 {
     EVENT_DISRUPT   = 1,
@@ -29,35 +33,43 @@ enum Events
     EVENT_ERUPT,
     EVENT_PHASE,
 };
+
 enum Phases
 {
     PHASE_FIGHT = 1,
     PHASE_DANCE,
 };
+
 //Spell by eye stalks
 #define SPELL_MIND_FLAY     26143
+
 struct TRINITY_DLL_DECL boss_heiganAI : public BossAI
 {
     boss_heiganAI(Creature *c) : BossAI(c, BOSS_HEIGAN) {}
+
     uint32 eruptSection;
     bool eruptDirection;
     Phases phase;
+
     void KilledUnit(Unit* Victim)
     {
         if (!(rand()%5))
             DoScriptText(SAY_SLAY, me);
     }
+
     void JustDied(Unit* Killer)
     {
         _JustDied();
         DoScriptText(SAY_DEATH, me);
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
         DoScriptText(SAY_AGGRO, me);
         EnterPhase(PHASE_FIGHT);
     }
+
     void EnterPhase(Phases newPhase)
     {
         phase = newPhase;
@@ -80,11 +92,14 @@ struct TRINITY_DLL_DECL boss_heiganAI : public BossAI
             events.ScheduleEvent(EVENT_ERUPT, 5000);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim() || !CheckInRoom())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -103,22 +118,28 @@ struct TRINITY_DLL_DECL boss_heiganAI : public BossAI
                 case EVENT_ERUPT:
                     instance->SetData(DATA_HEIGAN_ERUPT, eruptSection);
                     TeleportCheaters();
+
                     if (eruptSection == 0)
                         eruptDirection = true;
                     else if (eruptSection == 3)
                         eruptDirection = false;
+
                     eruptDirection ? ++eruptSection : --eruptSection;
+
                     events.ScheduleEvent(EVENT_ERUPT, phase == PHASE_FIGHT ? 10000 : 3000);
                     break;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_heigan(Creature* pCreature)
 {
     return new boss_heiganAI (pCreature);
 }
+
 void AddSC_boss_heigan()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_kelthuzad.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_kelthuzad.cpp
index a07c09ff748..2e395ecec03 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_kelthuzad.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_kelthuzad.cpp
@@ -13,36 +13,45 @@
  * along with 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"
 #include "def_naxxramas.h"
+
 //when shappiron dies. dialog between kel and lich king (in this order)
 #define SAY_SAPP_DIALOG1            -1533084 //not used
 #define SAY_SAPP_DIALOG2_LICH       -1533085 //not used
 #define SAY_SAPP_DIALOG3            -1533086 //not used
 #define SAY_SAPP_DIALOG4_LICH       -1533087 //not used
 #define SAY_SAPP_DIALOG5            -1533088 //not used
+
 //when cat dies
 #define SAY_CAT_DIED                -1533089 //not used
+
 //when each of the 4 wing bosses dies
 #define SAY_TAUNT1                  -1533090 //not used
 #define SAY_TAUNT2                  -1533091 //not used
 #define SAY_TAUNT3                  -1533092 //not used
 #define SAY_TAUNT4                  -1533093 //not used
+
 #define SAY_SUMMON_MINIONS          -1533105                //start of phase 1 not used
+
 #define SAY_AGGRO   RAND(-1533094,-1533095,-1533096)       //start of phase 2
 #define SAY_SLAY    RAND(-1533097,-1533098)
 #define SAY_DEATH   -1533099
 #define SAY_CHAIN   RAND(-1533100,-1533101)
 #define SAY_FROST_BLAST             -1533102
 #define SAY_SPECIAL RAND(-1533106,-1533107,-1533108)
+
 #define SAY_REQUEST_AID             -1533103                //start of phase 3
 #define SAY_ANSWER_REQUEST          -1533104                //lich king answer
+
 enum Event
 {
     EVENT_BOLT = 1,
@@ -51,12 +60,15 @@ enum Event
     EVENT_DETONATE,
     EVENT_FISSURE,
     EVENT_BLAST,
+
     EVENT_WASTE,
     EVENT_ABOMIN,
     EVENT_WEAVER,
     EVENT_ICECROWN,
+
     EVENT_PHASE,
 };
+
 #define SPELL_FROST_BOLT            HEROIC(28478,55802)
 #define SPELL_FROST_BOLT_AOE        HEROIC(28479,55807)
 #define SPELL_SHADOW_FISURE         27810
@@ -65,10 +77,12 @@ enum Event
 #define SPELL_FROST_BLAST           27808
 #define SPELL_CHAINS_OF_KELTHUZAD   28410 //28408 script effect
 #define SPELL_BERSERK               28498
+
 #define MOB_WASTE                   16427 // Soldiers of the Frozen Wastes
 #define MOB_ABOMINATION             16428 // Unstoppable Abominations
 #define MOB_WEAVER                  16429 // Soul Weavers
 #define MOB_ICECROWN                16441 // Guardians of Icecrown
+
 const Position Pos[12] =
 {
     {3783.272705, -5062.697266, 143.711203,3.617599},//LEFT_FAR
@@ -84,29 +98,38 @@ const Position Pos[12] =
     {3707.990733,-5151.450195,142.032562,1.376855},//RIGHT_MIDDLE
     {3739.500000,-5141.883989,142.0141130, 2.121412}//RIGHT_NEAR
 };
+
 struct TRINITY_DLL_DECL boss_kelthuzadAI : public BossAI
 {
     boss_kelthuzadAI(Creature* c) : BossAI(c, BOSS_KELTHUZAD) {}
+
     uint32 GuardiansOfIcecrown_Count;
+
     uint32 Phase;
     uint32 GuardiansOfIcecrown_Timer;
+
     void Reset()
     {
         _Reset();
         me->SetReactState(REACT_AGGRESSIVE);
         GuardiansOfIcecrown_Count = 0;
+
         GuardiansOfIcecrown_Timer = 5000;                   //5 seconds for summoning each Guardian of Icecrown in phase 3
+
         Phase=0;
     }
+
     void KilledUnit()
     {
         DoScriptText(SAY_SLAY, m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         _JustDied();
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void EnterCombat(Unit* who)
     {
         _EnterCombat();
@@ -119,11 +142,14 @@ struct TRINITY_DLL_DECL boss_kelthuzadAI : public BossAI
         events.ScheduleEvent(EVENT_WEAVER, 20000);
         events.ScheduleEvent(EVENT_PHASE, 228000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateCombatState())
             return;
+
         events.Update(diff);
+
         if (Phase == 1)
         {
             while(uint32 eventId = events.GetEvent())
@@ -184,8 +210,10 @@ struct TRINITY_DLL_DECL boss_kelthuzadAI : public BossAI
                 }
                 else GuardiansOfIcecrown_Timer -= diff;
             }
+
             if (me->hasUnitState(UNIT_STAT_CASTING))
                 return;
+
             if (uint32 eventId = events.GetEvent())
             {
                 switch(eventId)
@@ -208,13 +236,14 @@ struct TRINITY_DLL_DECL boss_kelthuzadAI : public BossAI
                     {
                         std::vector unitList;
                         std::list *threatList = &me->getThreatManager().getThreatList();
-                        for (std::list::const_iterator itr = threatList->begin(); itr != threatList->end(); ++itr)
+                        for(std::list::const_iterator itr = threatList->begin(); itr != threatList->end(); ++itr)
                         {
                             if ((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER
                                 && (*itr)->getTarget()->getPowerType() == POWER_MANA
                                 && (*itr)->getTarget()->GetPower(POWER_MANA))
                                 unitList.push_back((*itr)->getTarget());
                         }
+
                         if (!unitList.empty())
                         {
                             std::vector::iterator itr = unitList.begin();
@@ -222,6 +251,7 @@ struct TRINITY_DLL_DECL boss_kelthuzadAI : public BossAI
                             DoCast(*itr, SPELL_MANA_DETONATION);
                             DoScriptText(SAY_SPECIAL, me);
                         }
+
                         events.RepeatEvent(20000);
                         return;
                     }
@@ -242,14 +272,17 @@ struct TRINITY_DLL_DECL boss_kelthuzadAI : public BossAI
                         return;
                 }
             }
+
             DoMeleeAttackIfReady();
         }
     }
 };
+
 CreatureAI* GetAI_boss_kelthuzadAI(Creature* pCreature)
 {
     return new boss_kelthuzadAI (pCreature);
 }
+
 void AddSC_boss_kelthuzad()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_loatheb.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_loatheb.cpp
index 9790f40fda3..c87caf2beae 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_loatheb.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_loatheb.cpp
@@ -15,21 +15,26 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SPELL_NECROTIC_AURA         55593
 #define SPELL_SUMMON_SPORE          29234
 #define SPELL_DEATHBLOOM            HEROIC(29865,55053)
 #define SPELL_INEVITABLE_DOOM       HEROIC(29204,55052)
+
 enum Events
 {
     EVENT_AURA = 1,
     EVENT_BLOOM,
     EVENT_DOOM,
 };
+
 struct TRINITY_DLL_DECL boss_loathebAI : public BossAI
 {
     boss_loathebAI(Creature *c) : BossAI(c, BOSS_LOATHEB) {}
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -37,11 +42,14 @@ struct TRINITY_DLL_DECL boss_loathebAI : public BossAI
         events.ScheduleEvent(EVENT_BLOOM, 30000);
         events.ScheduleEvent(EVENT_DOOM, 120000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -61,13 +69,16 @@ struct TRINITY_DLL_DECL boss_loathebAI : public BossAI
                     return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_loatheb(Creature* pCreature)
 {
     return new boss_loathebAI (pCreature);
 }
+
 void AddSC_boss_loatheb()
 {
     Script *newscript;
@@ -75,6 +86,7 @@ void AddSC_boss_loatheb()
     newscript->Name = "boss_loatheb";
     newscript->GetAI = &GetAI_boss_loatheb;
     newscript->RegisterSelf();
+
     // Fungal Creep
     GetAISpellInfo(29232)->condition = AICOND_DIE;
 }
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_maexxna.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_maexxna.cpp
index b9b0085e230..ff84d1077e4 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_maexxna.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_maexxna.cpp
@@ -15,15 +15,19 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SPELL_WEB_WRAP          28622
 #define SPELL_WEB_SPRAY         HEROIC(29484,54125)
 #define SPELL_POISON_SHOCK      HEROIC(28741,54122)
 #define SPELL_NECROTIC_POISON   HEROIC(54121,28776)
 #define SPELL_FRENZY            HEROIC(54123,54124)
+
 #define MOB_WEB_WRAP            16486
 #define MOB_SPIDERLING          17055
+
 #define MAX_POS_WRAP            3
 const float PosWrap[MAX_POS_WRAP][3] =
 {
@@ -31,6 +35,7 @@ const float PosWrap[MAX_POS_WRAP][3] =
     {3531.271, -3847.424, 299.450+20},
     {3497.067, -3843.384, 302.384+20},
 };
+
 enum Events
 {
     EVENT_SPRAY = 1,
@@ -39,10 +44,13 @@ enum Events
     EVENT_WRAP,
     EVENT_SUMMON,
 };
+
 struct TRINITY_DLL_DECL boss_maexxnaAI : public BossAI
 {
     boss_maexxnaAI(Creature *c) : BossAI(c, BOSS_MAEXXNA) {}
+
     bool enraged;
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -53,17 +61,20 @@ struct TRINITY_DLL_DECL boss_maexxnaAI : public BossAI
         events.ScheduleEvent(EVENT_POISON, 5000);
         events.ScheduleEvent(EVENT_SUMMON, 40000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim() || !CheckInRoom())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
             {
                 case EVENT_WRAP:
-                    for (uint32 i = 0; i < HEROIC(1,2); ++i)
+                    for(uint32 i = 0; i < HEROIC(1,2); ++i)
                     {
                         if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0, true, -SPELL_WEB_WRAP))
                         {
@@ -94,13 +105,14 @@ struct TRINITY_DLL_DECL boss_maexxnaAI : public BossAI
                 case EVENT_SUMMON:
                 {
                     uint32 amount = 8+rand()%2;
-                    for (uint32 i = 0; i < amount; ++i)
+                    for(uint32 i = 0; i < amount; ++i)
                         DoSummon(MOB_SPIDERLING, me);
                     events.ScheduleEvent(EVENT_SUMMON, 40000);
                     break;
                 }
             }
         }
+
         if (!enraged && HealthBelowPct(30))
         {
             DoCast(me, SPELL_FRENZY);
@@ -110,13 +122,16 @@ struct TRINITY_DLL_DECL boss_maexxnaAI : public BossAI
             DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_maexxna(Creature* pCreature)
 {
     return new boss_maexxnaAI (pCreature);
 }
+
 void AddSC_boss_maexxna()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_maexxna";
     newscript->GetAI = &GetAI_boss_maexxna;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_noth.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_noth.cpp
index 594fe83620f..c4ba86a91d6 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_noth.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_noth.cpp
@@ -13,26 +13,34 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SAY_AGGRO               RAND(-1533075,-1533076,-1533077)
 #define SAY_SUMMON              -1533078
 #define SAY_SLAY                RAND(-1533079,-1533080)
 #define SAY_DEATH               -1533081
+
 #define SOUND_DEATH      8848
+
 #define SPELL_CURSE_PLAGUEBRINGER       HEROIC(29213,54835)
 #define SPELL_BLINK                     RAND(29208,29209,29210,29211)
 #define SPELL_CRIPPLE                   HEROIC(29212,54814)
 #define SPELL_TELEPORT                  29216
+
 #define MOB_WARRIOR         16984
 #define MOB_CHAMPION        16983
 #define MOB_GUARDIAN        16981
+
 // 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 MAX_SUMMON_POS 5
+
 const float SummonPos[MAX_SUMMON_POS][4] =
 {
     {2728.12, -3544.43, 261.91, 6.04},
@@ -41,6 +49,7 @@ const float SummonPos[MAX_SUMMON_POS][4] =
     {2704.11, -3456.81, 265.53, 4.51},
     {2663.56, -3464.43, 262.66, 5.20},
 };
+
 enum Events
 {
     EVENT_BERSERK   = 1,
@@ -51,16 +60,20 @@ enum Events
     EVENT_WAVE,
     EVENT_GROUND,
 };
+
 struct TRINITY_DLL_DECL boss_nothAI : public BossAI
 {
     boss_nothAI(Creature *c) : BossAI(c, BOSS_NOTH) {}
+
     uint32 waveCount, balconyCount;
+
     void Reset()
     {
         me->SetReactState(REACT_AGGRESSIVE);
         me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         _Reset();
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -68,6 +81,7 @@ struct TRINITY_DLL_DECL boss_nothAI : public BossAI
         balconyCount = 0;
         EnterPhaseGround();
     }
+
     void EnterPhaseGround()
     {
         me->SetReactState(REACT_AGGRESSIVE);
@@ -84,36 +98,43 @@ struct TRINITY_DLL_DECL boss_nothAI : public BossAI
                 events.ScheduleEvent(EVENT_BLINK, 20000+rand()%10000);
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         if (!(rand()%5))
             DoScriptText(SAY_SLAY, me);
     }
+
     void JustSummoned(Creature *summon)
     {
         summons.Summon(summon);
         summon->setActive(true);
         summon->AI()->DoZoneInCombat();
     }
+
     void JustDied(Unit* Killer)
     {
         _JustDied();
         DoScriptText(SAY_DEATH, me);
     }
+
     void SummonUndead(uint32 entry, uint32 num)
     {
-        for (uint32 i = 0; i < num; ++i)
+        for(uint32 i = 0; i < num; ++i)
         {
             uint32 pos = rand()%MAX_SUMMON_POS;
             me->SummonCreature(entry, SummonPos[pos][0], SummonPos[pos][1], SummonPos[pos][2],
                 SummonPos[pos][3], TEMPSUMMON_CORPSE_DESPAWN, 60000);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateCombatState() || !CheckInRoom())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -168,14 +189,17 @@ struct TRINITY_DLL_DECL boss_nothAI : public BossAI
                 }
             }
         }
+
         if (me->HasReactState(REACT_AGGRESSIVE))
             DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_noth(Creature* pCreature)
 {
     return new boss_nothAI (pCreature);
 }
+
 void AddSC_boss_noth()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_patchwerk.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_patchwerk.cpp
index 34ebdfe3e1c..5077f0267ed 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_patchwerk.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_patchwerk.cpp
@@ -13,36 +13,48 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define SAY_AGGRO               RAND(-1533017,-1533018)
 #define SAY_SLAY                -1533019
 #define SAY_DEATH               -1533020
+
 #define EMOTE_BERSERK           -1533021
 #define EMOTE_ENRAGE            -1533022
+
 #define SPELL_HATEFULSTRIKE     HEROIC(41926,59192)
 #define SPELL_FRENZY            28131
 #define SPELL_BERSERK           26662
 #define SPELL_SLIMEBOLT         32309
+
 #define EVENT_BERSERK   1
 #define EVENT_HATEFUL   2
 #define EVENT_SLIME     3
+
 #define ACHIEVEMENT_MAKE_QUICK_WERK_OF_HIM  HEROIC(1856, 1857)
 #define MAX_ENCOUNTER_TIME                    3 * 60 * 1000
+
 struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
 {
     boss_patchwerkAI(Creature *c) : BossAI(c, BOSS_PATCHWERK) {}
+
     bool Enraged;
+
     uint32 EncounterTime;
+
     void KilledUnit(Unit* Victim)
     {
         if (!(rand()%5))
             DoScriptText(SAY_SLAY, me);
     }
+
     void JustDied(Unit* Killer)
     {
         _JustDied();
         DoScriptText(SAY_DEATH, me);
+
         if(EncounterTime <= MAX_ENCOUNTER_TIME)
         {
             AchievementEntry const *AchievMakeQuickWerkOfHim = GetAchievementStore()->LookupEntry(ACHIEVEMENT_MAKE_QUICK_WERK_OF_HIM);
@@ -52,12 +64,13 @@ struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
                 if(pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievMakeQuickWerkOfHim);
                 }
             }
         }
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -67,12 +80,16 @@ struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
         events.ScheduleEvent(EVENT_HATEFUL, 1200);
         events.ScheduleEvent(EVENT_BERSERK, 360000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         EncounterTime += diff;
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -84,7 +101,7 @@ struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
                     uint32 MostHP = 0;
                     Unit* pMostHPTarget = NULL;
                     std::list::iterator i = me->getThreatManager().getThreatList().begin();
-                    for (; i != me->getThreatManager().getThreatList().end(); ++i)
+                    for(; i != me->getThreatManager().getThreatList().end(); ++i)
                     {
                         Unit* target = (*i)->getTarget();
                         if (target->isAlive() && target->GetHealth() > MostHP && me->IsWithinMeleeRange(target))
@@ -93,8 +110,10 @@ struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
                             pMostHPTarget = target;
                         }
                     }
+
                     if (pMostHPTarget)
                         DoCast(pMostHPTarget, SPELL_HATEFULSTRIKE, true);
+
                     events.ScheduleEvent(EVENT_HATEFUL, 1200);
                     return;
                 }
@@ -109,6 +128,7 @@ struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
                     return;
             }
         }
+
         if (!Enraged && HealthBelowPct(5))
         {
             DoCast(m_creature, SPELL_FRENZY);
@@ -116,13 +136,16 @@ struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
             Enraged = true;
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_patchwerk(Creature* pCreature)
 {
     return new boss_patchwerkAI (pCreature);
 }
+
 void AddSC_boss_patchwerk()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_razuvious.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_razuvious.cpp
index 71698e1c25c..7f92978e8b1 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_razuvious.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_razuvious.cpp
@@ -15,8 +15,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 //Razuvious - NO TEXT sound only
 //8852 aggro01 - Hah hah, I'm just getting warmed up!
 //8853 aggro02 Stand and fight!
@@ -30,15 +32,18 @@
 //8861 Sweep the leg! Do you have a problem with that?
 //8860 death - An honorable... death...
 //8947 - Aggro Mixed? - ?
+
 #define SOUND_AGGRO     RAND(8852,8853,8854)
 #define SOUND_SLAY      RAND(8861,8863)
 #define SOUND_COMMND    RAND(8855,8856,8858,8859,8861)
 #define SOUND_DEATH     8860
 #define SOUND_AGGROMIX  8847
+
 #define SPELL_UNBALANCING_STRIKE    26613
 #define SPELL_DISRUPTING_SHOUT      HEROIC(29107,55543)
 #define SPELL_JAGGED_KNIFE          55550
 #define SPELL_HOPELESS              29125
+
 enum Events
 {
     EVENT_STRIKE,
@@ -46,14 +51,17 @@ enum Events
     EVENT_KNIFE,
     EVENT_COMMAND,
 };
+
 struct TRINITY_DLL_DECL boss_razuviousAI : public BossAI
 {
     boss_razuviousAI(Creature *c) : BossAI(c, BOSS_RAZUVIOUS) {}
+
     void KilledUnit(Unit* victim)
     {
         if (!(rand()%3))
             DoPlaySoundToSet(me, SOUND_SLAY);
     }
+
     void DamageTaken(Unit* pDone_by, uint32& uiDamage)
     {
         // Damage done by the controlled Death Knight understudies should also count toward damage done by players
@@ -62,12 +70,14 @@ struct TRINITY_DLL_DECL boss_razuviousAI : public BossAI
             me->LowerPlayerDamageReq(uiDamage);
         }
     }
+
     void JustDied(Unit* killer)
     {
         _JustDied();
         DoPlaySoundToSet(me, SOUND_DEATH);
         me->CastSpell(me, SPELL_HOPELESS, true); // TODO: this may affect other creatures
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -76,11 +86,14 @@ struct TRINITY_DLL_DECL boss_razuviousAI : public BossAI
         events.ScheduleEvent(EVENT_SHOUT, 25000);
         events.ScheduleEvent(EVENT_COMMAND, 40000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -104,13 +117,16 @@ struct TRINITY_DLL_DECL boss_razuviousAI : public BossAI
                     return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_razuvious(Creature* pCreature)
 {
     return new boss_razuviousAI (pCreature);
 }
+
 void AddSC_boss_razuvious()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_sapphiron.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_sapphiron.cpp
index 4ec38e2a446..e5fb1c6463a 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_sapphiron.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_sapphiron.cpp
@@ -15,10 +15,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 #define EMOTE_BREATH            -1533082
 #define EMOTE_ENRAGE            -1533083
+
 #define SPELL_FROST_AURA        HEROIC(28531,55799)
 #define SPELL_CLEAVE            19983
 #define SPELL_TAIL_SWEEP        HEROIC(55697,55696)
@@ -30,11 +33,15 @@
 #define SPELL_FROST_MISSILE     30101
 #define SPELL_BERSERK           26662
 #define SPELL_DIES              29357
+
 #define SPELL_CHILL             HEROIC(28547,55699)
+
 #define MOB_BLIZZARD            16474
 #define GO_ICEBLOCK             181247
+
 #define ACHIEVEMENT_THE_HUNDRED_CLUB    HEROIC(2146, 2147)
 #define MAX_FROST_RESISTANCE            100
+
 enum Phases
 {
     PHASE_NULL = 0,
@@ -42,6 +49,7 @@ enum Phases
     PHASE_GROUND,
     PHASE_FLIGHT,
 };
+
 enum Events
 {
     EVENT_BERSERK   = 1,
@@ -58,7 +66,9 @@ enum Events
     EVENT_GROUND,
     EVENT_BIRTH,
 };
+
 typedef std::map IceBlockMap;
+
 struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
 {
     boss_sapphironAI(Creature* c) : BossAI(c, BOSS_SAPPHIRON)
@@ -66,12 +76,15 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
     {
         pMap = m_creature->GetMap();
     }
+
     Phases phase;
     uint32 iceboltCount;
     IceBlockMap iceblocks;
+
     bool CanTheHundredClub; // needed for achievement: The Hundred Club(2146, 2147)
     uint32 CheckFrostResistTimer;
     Map* pMap;
+
     void InitializeAI()
     {
         float x, y, z;
@@ -80,25 +93,35 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
         me->SetVisibility(VISIBILITY_OFF);
         me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         me->SetReactState(REACT_PASSIVE);
+
         ScriptedAI::InitializeAI();
     }
+
     void Reset()
     {
         _Reset();
+
         if (phase = PHASE_FLIGHT)
             ClearIceBlock();
+
         phase = PHASE_NULL;
+
         CanTheHundredClub = true;
         CheckFrostResistTimer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
+
         me->CastSpell(me, SPELL_FROST_AURA, true);
+
         events.ScheduleEvent(EVENT_BERSERK, 15*60000);
         EnterPhaseGround();
+
         CheckPlayersFrostResist();
     }
+
     void SpellHitTarget(Unit *target, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_ICEBOLT)
@@ -111,10 +134,12 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
             }
         }
     }
+
     void JustDied(Unit* who)
     {
         _JustDied();
         me->CastSpell(me, SPELL_DIES, true);
+
         CheckPlayersFrostResist();
         if(CanTheHundredClub)
         {
@@ -124,17 +149,19 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
                 if(pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievTheHundredClub);
                 }
             }
         }
     }
+
     void MovementInform(uint32, uint32 id)
     {
         if (id == 1)
             events.ScheduleEvent(EVENT_LIFTOFF, 0);
     }
+
     void DoAction(const int32 param)
     {
         if (param == DATA_SAPPHIRON_BIRTH)
@@ -143,12 +170,13 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
             events.ScheduleEvent(EVENT_BIRTH, 23000);
         }
     }
+
     void CheckPlayersFrostResist()
     {
         if(CanTheHundredClub && pMap && pMap->IsDungeon())
         {
             Map::PlayerList const &players = pMap->GetPlayers();
-            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+            for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
             {
                 if(itr->getSource()->GetResistance(SPELL_SCHOOL_FROST) > MAX_FROST_RESISTANCE)
                 {
@@ -158,6 +186,7 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
             }
         }
     }
+
     void EnterPhaseGround()
     {
         phase = PHASE_GROUND;
@@ -169,9 +198,10 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
         events.ScheduleEvent(EVENT_BLIZZARD, 5000+rand()%5000, 0, PHASE_GROUND);
         events.ScheduleEvent(EVENT_FLIGHT, 45000);
     }
+
     void ClearIceBlock()
     {
-        for (IceBlockMap::iterator itr = iceblocks.begin(); itr != iceblocks.end(); ++itr)
+        for(IceBlockMap::iterator itr = iceblocks.begin(); itr != iceblocks.end(); ++itr)
         {
             if (Player* pPlayer = Unit::GetPlayer(itr->first))
                 pPlayer->RemoveAura(SPELL_ICEBOLT);
@@ -180,13 +210,17 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
         }
         iceblocks.clear();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!phase)
             return;
+
         events.Update(diff);
+
         if (phase != PHASE_BIRTH && !UpdateCombatState() || !CheckInRoom())
             return;
+
         if(CanTheHundredClub)
         {
             if(CheckFrostResistTimer < diff)
@@ -195,6 +229,7 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
                 CheckFrostResistTimer = (rand() % 5 + 5) * 1000;
             }else CheckFrostResistTimer -= diff;
         }
+
         if (phase == PHASE_GROUND)
         {
             while(uint32 eventId = events.ExecuteEvent())
@@ -236,6 +271,7 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
                         return;
                 }
             }
+
             DoMeleeAttackIfReady();
         }
         else
@@ -255,9 +291,10 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
                     {
                         std::vector targets;
                         std::list::iterator i = me->getThreatManager().getThreatList().begin();
-                        for (; i != me->getThreatManager().getThreatList().end(); ++i)
+                        for(; i != me->getThreatManager().getThreatList().end(); ++i)
                             if ((*i)->getTarget()->GetTypeId() == TYPEID_PLAYER && !(*i)->getTarget()->HasAura(SPELL_ICEBOLT))
                                 targets.push_back((*i)->getTarget());
+
                         if (targets.empty())
                             iceboltCount = 0;
                         else
@@ -268,6 +305,7 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
                             DoCast(*itr, SPELL_ICEBOLT);
                             --iceboltCount;
                         }
+
                         if (iceboltCount)
                             events.ScheduleEvent(EVENT_ICEBOLT, 1000);
                         else
@@ -304,23 +342,26 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
             }//if (uint32 eventId = events.ExecuteEvent())
         }//if (phase == PHASE_GROUND)
     }
+
     void CastExplosion()
     {
         DoZoneInCombat(); // make sure everyone is in threatlist
         std::vector targets;
         std::list::iterator i = me->getThreatManager().getThreatList().begin();
-        for (; i != me->getThreatManager().getThreatList().end(); ++i)
+        for(; i != me->getThreatManager().getThreatList().end(); ++i)
         {
             Unit *target = (*i)->getTarget();
             if (target->GetTypeId() != TYPEID_PLAYER)
                 continue;
+
             if (target->HasAura(SPELL_ICEBOLT))
             {
                 target->ApplySpellImmune(0, IMMUNITY_ID, SPELL_FROST_EXPLOSION, true);
                 targets.push_back(target);
                 continue;
             }
-            for (IceBlockMap::iterator itr = iceblocks.begin(); itr != iceblocks.end(); ++itr)
+
+            for(IceBlockMap::iterator itr = iceblocks.begin(); itr != iceblocks.end(); ++itr)
             {
                 if (GameObject* pGo = GameObject::GetGameObject(*me, itr->second))
                 {
@@ -334,15 +375,19 @@ struct TRINITY_DLL_DECL boss_sapphironAI : public BossAI
                 }
             }
         }
+
         me->CastSpell(me, SPELL_FROST_EXPLOSION, true);
-        for (std::vector::iterator itr = targets.begin(); itr != targets.end(); ++itr)
+
+        for(std::vector::iterator itr = targets.begin(); itr != targets.end(); ++itr)
             (*itr)->ApplySpellImmune(0, IMMUNITY_ID, SPELL_FROST_EXPLOSION, false);
     }
 };
+
 CreatureAI* GetAI_boss_sapphiron(Creature* pCreature)
 {
     return new boss_sapphironAI (pCreature);
 }
+
 void AddSC_boss_sapphiron()
 {
     Script *newscript;
@@ -350,6 +395,7 @@ void AddSC_boss_sapphiron()
     newscript->Name = "boss_sapphiron";
     newscript->GetAI = &GetAI_boss_sapphiron;
     newscript->RegisterSelf();
+
     // Chill
     GetAISpellInfo(28547)->cooldown = 1000;
     GetAISpellInfo(55699)->cooldown = 1000;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_thaddius.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_thaddius.cpp
index 477ac69df87..173bb84dba7 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_thaddius.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_thaddius.cpp
@@ -15,24 +15,32 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 //Stalagg
 #define SAY_STAL_AGGRO          -1533023 //not used
 #define SAY_STAL_SLAY           -1533024 //not used
 #define SAY_STAL_DEATH          -1533025 //not used
+
 #define SPELL_POWERSURGE        28134
+
 //Feugen
 #define SAY_FEUG_AGGRO          -1533026 //not used
 #define SAY_FEUG_SLAY           -1533027 //not used
 #define SAY_FEUG_DEATH          -1533028 //not used
+
 #define SPELL_MANABURN          28135
+
 //both
 #define SPELL_WARSTOMP          28125
 
+
  //generic
 #define C_TESLA_COIL                        16218           //the coils (emotes "Tesla Coil overloads!")
 
+
 //Thaddus
 #define SAY_GREET               -1533029 //not used
 #define SAY_AGGRO               RAND(-1533030,-1533031,-1533032)
@@ -43,16 +51,19 @@
 #define SAY_SCREAM2             -1533037 //not used
 #define SAY_SCREAM3             -1533038 //not used
 #define SAY_SCREAM4             -1533039 //not used
+
 #define SPELL_POLARITY_SHIFT        28089
 #define SPELL_BALL_LIGHTNING        28299
 #define SPELL_CHAIN_LIGHTNING       HEROIC(28167,54531)
 #define SPELL_BERSERK               27680
+
 enum Events
 {
     EVENT_SHIFT = 1,
     EVENT_CHAIN,
     EVENT_BERSERK,
 };
+
 struct TRINITY_DLL_DECL boss_thaddiusAI : public BossAI
 {
     boss_thaddiusAI(Creature *c) : BossAI(c, BOSS_THADDIUS)
@@ -60,16 +71,19 @@ struct TRINITY_DLL_DECL boss_thaddiusAI : public BossAI
         // temp
         me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_STUNNED);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (!(rand()%5))
             DoScriptText(SAY_SLAY, me);
     }
+
     void JustDied(Unit* Killer)
     {
         _JustDied();
         DoScriptText(SAY_DEATH, me);
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -78,13 +92,17 @@ struct TRINITY_DLL_DECL boss_thaddiusAI : public BossAI
         events.ScheduleEvent(EVENT_CHAIN, 10000+rand()%10000);
         events.ScheduleEvent(EVENT_BERSERK, 6*60000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         if (me->hasUnitState(UNIT_STAT_CASTING))
             return;
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -102,16 +120,19 @@ struct TRINITY_DLL_DECL boss_thaddiusAI : public BossAI
                     return;
             }
         }
+
         if (events.GetTimer() > 15000 && !me->IsWithinMeleeRange(me->getVictim()))
             DoCast(me->getVictim(), SPELL_BALL_LIGHTNING);
         else
             DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_thaddius(Creature* pCreature)
 {
     return new boss_thaddiusAI (pCreature);
 }
+
 void AddSC_boss_thaddius()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/def_naxxramas.h b/src/bindings/scripts/scripts/northrend/naxxramas/def_naxxramas.h
index 06692a009d4..383200d4600 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/def_naxxramas.h
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/def_naxxramas.h
@@ -15,8 +15,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef DEF_NAXXRAMAS_H
 #define DEF_NAXXRAMAS_H
+
 enum Encounter
 {
     BOSS_ANUBREKHAN,
@@ -36,12 +38,15 @@ enum Encounter
     BOSS_KELTHUZAD,
     MAX_BOSS_NUMBER
 };
+
 enum Data
 {
     DATA_HEIGAN_ERUPT,
     DATA_GOTHIK_GATE,
     DATA_SAPPHIRON_BIRTH,
 };
+
 #define GO_BIRTH                181356
+
 #endif
 
diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/instance_naxxramas.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/instance_naxxramas.cpp
index f6ea3d6bca9..189eac62ca8 100644
--- a/src/bindings/scripts/scripts/northrend/naxxramas/instance_naxxramas.cpp
+++ b/src/bindings/scripts/scripts/northrend/naxxramas/instance_naxxramas.cpp
@@ -13,8 +13,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_naxxramas.h"
+
 const DoorData doorData[] =
 {
     {181126,    BOSS_ANUBREKHAN,DOOR_TYPE_ROOM,     BOUNDARY_S},
@@ -42,6 +44,7 @@ const DoorData doorData[] =
     {181225,    BOSS_SAPPHIRON, DOOR_TYPE_PASSAGE,  BOUNDARY_W},
     {0,         0,              DOOR_TYPE_ROOM,     0}, // EOF
 };
+
 const MinionData minionData[] =
 {
     //{16573,     BOSS_ANUBREKHAN},     there is no spawn point in db, so we do not add them here
@@ -53,13 +56,16 @@ const MinionData minionData[] =
     {30549,     BOSS_HORSEMEN},
     {0,         0,}
 };
+
 enum eEnums
 {
     GO_HORSEMEN_CHEST_HERO  = 193426,
     GO_HORSEMEN_CHEST       = 181366,                   //four horsemen event, DoRespawnGameObject() when event == DONE
     GO_GOTHIK_GATE          = 181170,
+
     SPELL_ERUPTION          = 29371
 };
+
 const float HeiganPos[2] = {2796, -3707};
 const float HeiganEruptionSlope[3] =
 {
@@ -67,6 +73,7 @@ const float HeiganEruptionSlope[3] =
     (-3647 - HeiganPos[1]) /(2749 - HeiganPos[0]),
     (-3637 - HeiganPos[1]) /(2771 - HeiganPos[0]),
 };
+
 // 0  H      x
 //  1        ^
 //   2       |
@@ -76,15 +83,18 @@ inline uint32 GetEruptionSection(float x, float y)
     y -= HeiganPos[1];
     if (y < 1.0f)
         return 0;
+
     x -= HeiganPos[0];
     if (x > -1.0f)
         return 3;
+
     float slope = y/x;
-    for (uint32 i = 0; i < 3; ++i)
+    for(uint32 i = 0; i < 3; ++i)
         if (slope > HeiganEruptionSlope[i])
             return i;
     return 3;
 }
+
 struct TRINITY_DLL_DECL instance_naxxramas : public InstanceData
 {
     instance_naxxramas(Map* pMap) : InstanceData(pMap)
@@ -94,18 +104,22 @@ struct TRINITY_DLL_DECL instance_naxxramas : public InstanceData
         LoadDoorData(doorData);
         LoadMinionData(minionData);
     }
+
     std::set HeiganEruption[4];
     GameObject* pGothikGate, *HorsemenChest;
     Creature* Sapphiron;
     uint32 HorsemenNum;
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
         {
             case 15989: Sapphiron = add ? pCreature : NULL; return;
         }
+
         AddMinion(pCreature, add);
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         if (pGo->GetGOInfo()->displayId == 6785 || pGo->GetGOInfo()->displayId == 1287)
@@ -117,6 +131,7 @@ struct TRINITY_DLL_DECL instance_naxxramas : public InstanceData
                 HeiganEruption[section].erase(pGo);
             return;
         }
+
         switch(pGo->GetEntry())
         {
             case GO_BIRTH: if (!add && Sapphiron) Sapphiron->AI()->DoAction(DATA_SAPPHIRON_BIRTH); return;
@@ -124,8 +139,10 @@ struct TRINITY_DLL_DECL instance_naxxramas : public InstanceData
             case GO_HORSEMEN_CHEST: HorsemenChest = add ? pGo : NULL; break;
             case GO_HORSEMEN_CHEST_HERO: HorsemenChest = add ? pGo : NULL; break;
         }
+
         AddDoor(pGo, add);
     }
+
     void SetData(uint32 id, uint32 value)
     {
         switch(id)
@@ -139,21 +156,26 @@ struct TRINITY_DLL_DECL instance_naxxramas : public InstanceData
                 break;
         }
     }
+
     bool SetBossState(uint32 id, EncounterState state)
     {
         if (!InstanceData::SetBossState(id, state))
             return false;
+
         if (id == BOSS_HORSEMEN && state == DONE && HorsemenChest)
             HorsemenChest->SetRespawnTime(HorsemenChest->GetRespawnDelay());
+
         return true;
     }
+
     void HeiganErupt(uint32 section)
     {
-        for (uint32 i = 0; i < 4; ++i)
+        for(uint32 i = 0; i < 4; ++i)
         {
             if (i == section)
                 continue;
-            for (std::set::iterator itr = HeiganEruption[i].begin(); itr != HeiganEruption[i].end(); ++itr)
+
+            for(std::set::iterator itr = HeiganEruption[i].begin(); itr != HeiganEruption[i].end(); ++itr)
             {
                 (*itr)->SendCustomAnim();
                 (*itr)->CastSpell(NULL, SPELL_ERUPTION);
@@ -161,21 +183,26 @@ struct TRINITY_DLL_DECL instance_naxxramas : public InstanceData
         }
     }
 };
+
 bool AreaTrigger_at_naxxramas_frostwyrm_wing(Player* pPlayer, AreaTriggerEntry *at)
 {
     if (pPlayer->isGameMaster())
         return false;
+
     InstanceData *data = pPlayer->GetInstanceData();
     if (data)
-        for (uint32 i = BOSS_ANUBREKHAN; i < BOSS_SAPPHIRON; ++i)
+        for(uint32 i = BOSS_ANUBREKHAN; i < BOSS_SAPPHIRON; ++i)
             if (data->GetBossState(i) != DONE)
                 return true;
+
     return false;
 }
+
 InstanceData* GetInstanceData_instance_naxxramas(Map* pMap)
 {
     return new instance_naxxramas(pMap);
 }
+
 void AddSC_instance_naxxramas()
 {
     Script *newscript;
@@ -183,6 +210,7 @@ void AddSC_instance_naxxramas()
     newscript->Name = "instance_naxxramas";
     newscript->GetInstanceData = &GetInstanceData_instance_naxxramas;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "at_naxxramas_frostwyrm_wing";
     newscript->pAreaTrigger = &AreaTrigger_at_naxxramas_frostwyrm_wing;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/boss_malygos.cpp b/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/boss_malygos.cpp
index a8e261a80a5..e96d6893380 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/boss_malygos.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/boss_malygos.cpp
@@ -5,10 +5,12 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Spells
 #define SPELL_ARCANE_BREATH_N                        56272
 #define SPELL_ARCANE_BREATH_H                        60072
@@ -21,6 +23,7 @@ update creature_template set scriptname = '' where entry = '';
 #define SPELL_SURGE_OF_POWER_2                       57407
 #define SPELL_SURGE_OF_POWER_3                       60936
 #define SPELL_VORTEX                                 56105
+
 //Dragon "mounts" spells in Phase3
 //they use Rugelike energy
 #define SPELL_DMOUNT_FLAME_SPIKE                     56091 //maybe not accurate
@@ -29,6 +32,7 @@ update creature_template set scriptname = '' where entry = '';
 #define SPELL_DMOUNT_LIFE_BURST                      57143
 #define SPELL_DMOUNT_FLAME_SHIELD                    57108
 //#define SPELL_DMOUNT_UNKNOWN                      XYZ //Increases your drake's flight speed by 500%.
+
 //not in db
 //Yell
 //-->Other
@@ -53,7 +57,9 @@ update creature_template set scriptname = '' where entry = '';
 #define SAY_PHASE1_SLAY_1                          -1616015
 #define SAY_PHASE1_SLAY_2                          -1616016
 #define SAY_PHASE1_SLAY_3                          -1616017
+
 //--> Phase2 at 50% HP,
+
 /*Malygos himself is not targetable during this phase, it will end when the adds he spawns are all killed. However, he does continue to play a part in the encounter.
 During this phase he drops anti-magic zones onto the ground the raid MUST stand inside of, it reduces magical damage taken by 50%. They shrink over time, so it's important that your raid moves to each new one he drops.
 Throughout the phase, he will deep breath doing ~4k damage per second, unless you are standing inside of the anti-magic zone.
@@ -62,6 +68,7 @@ The Lords will move down onto the group, and need to be tanked (They will one-sh
 It is recommended to let melee take the first disks, then ranged. As those mobs die, they also drop disks, which allows the rest of your dps to get onto them.
 The Scions will continually cast Arcane Blast on random targets on the floor, which is mitigated by the anti-magic zones. While mounted on a disk, you will not take damage.
 After all of the NPCs riding on the disks die, the players on the disks need to dismount as Phase 3 is about to begin.*/
+
 //not in db
 #define SAY_PHASE2_AGGRO                           -1616018
 #define SAY_PHASE2_END                             -1616019
@@ -75,11 +82,14 @@ After all of the NPCs riding on the disks die, the players on the disks need to
 #define SAY_PHASE3_SLAY_2                          -1616026
 #define SAY_PHASE3_SLAY_3                          -1616027
 #define SAY_PHASE3_BIG_ATTACK                      -1616028
+
 struct TRINITY_DLL_DECL boss_malygosAI : public ScriptedAI
 {
     boss_malygosAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 phase,
            enrage;
+
     void Reset()
     {
         //Source Deadly Boss Mod
@@ -102,12 +112,14 @@ struct TRINITY_DLL_DECL boss_malygosAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 50){
             phase = 2;
             //spawn adds
             //set malygos unatackable untill all adds spawned dead
             //start phase3
         }
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
@@ -118,6 +130,7 @@ struct TRINITY_DLL_DECL boss_malygosAI : public ScriptedAI
     {
         if (victim == m_creature)
             return;
+
         if (phase ==1)
             DoScriptText(RAND(SAY_PHASE1_SLAY_1,SAY_PHASE1_SLAY_2,SAY_PHASE1_SLAY_3), m_creature);
         if (phase ==2)
@@ -126,13 +139,16 @@ struct TRINITY_DLL_DECL boss_malygosAI : public ScriptedAI
             DoScriptText(RAND(SAY_PHASE3_SLAY_1,SAY_PHASE3_SLAY_2,SAY_PHASE3_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_malygos(Creature* pCreature)
 {
     return new boss_malygosAI (pCreature);
 }
+
 void AddSC_boss_malygos()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_malygos";
     newscript->GetAI = &GetAI_boss_malygos;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/def_eye_of_eternity.h b/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/def_eye_of_eternity.h
index b2624ea1796..caa82a92e95 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/def_eye_of_eternity.h
+++ b/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/def_eye_of_eternity.h
@@ -1,3 +1,4 @@
 #ifndef DEF_EYE_OF_ETERNITY_H
 #define DEF_EYE_OF_ETERNITY_H
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/instance_eye_of_eternity.cpp b/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/instance_eye_of_eternity.cpp
index aa2c7107ad4..7c89a117d92 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/instance_eye_of_eternity.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/eye_of_eternity/instance_eye_of_eternity.cpp
@@ -1,13 +1,16 @@
 #include "precompiled.h"
 #include "def_eye_of_eternity.h"
+
 struct TRINITY_DLL_DECL instance_eye_of_eternity : public ScriptedInstance
 {
     instance_eye_of_eternity(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
 };
+
 InstanceData* GetInstanceData_instance_eye_of_eternity(Map* pMap)
 {
     return new instance_eye_of_eternity(pMap);
 }
+
 void AddSC_instance_eye_of_eternity()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_anomalus.cpp b/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_anomalus.cpp
index 4a1dc380925..f0759804235 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_anomalus.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_anomalus.cpp
@@ -13,18 +13,23 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss_Anomalus
 SD%Complete:
 SDComment:
 SDCategory: The Nexus, The Nexus
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_nexus.h"
+
 bool DeadChaoticRift; // needed for achievement: Chaos Theory(2037)
+
 enum eEnums
 {
     ACHIEVEMENT_CHAOS_THEORY   = 2037,
+
     //Spells
     SPELL_SPARK_N              = 47751,
     SPELL_SPARK_H              = 57062,
@@ -32,17 +37,20 @@ enum eEnums
     SPELL_CHARGE_RIFT          = 47747, //Works wrong (affect players, not rifts)
     SPELL_CREATE_RIFT          = 47743, //Don't work, using WA
     SPELL_ARCANE_ATTRACTION    = 57063, //No idea, when it's used
+
     MOB_CRAZED_MANA_WRAITH              = 26746,
     MOB_CHAOTIC_RIFT                    = 26918,
     SPELL_CHAOTIC_ENERGY_BURST          = 47688,
     SPELL_CHARGED_CHAOTIC_ENERGY_BURST  = 47737,
     SPELL_ARCANEFORM                    = 48019, //Chaotic Rift visual
+
     //Yell
     SAY_AGGRO               = -1576010,
     SAY_DEATH               = -1576011,
     SAY_RIFT                = -1576012,
     SAY_SHIELD              = -1576013
 };
+
 float RiftLocation[6][3]=
 {
     {652.64, -273.70, -8.75},
@@ -52,6 +60,7 @@ float RiftLocation[6][3]=
     {639.87, -314.11, -9.49},
     {651.72, -297.44, -9.37}
 };
+
 struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
 {
     boss_anomalusAI(Creature *c) : ScriptedAI(c)
@@ -59,31 +68,40 @@ struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool HeroicMode;
+
     uint8 Phase;
     uint32 SPELL_SPARK_Timer;
     uint32 SPELL_CREATE_RIFT_Timer;
     uint64 ChaoticRiftGUID;
+
     void Reset()
     {
         Phase = 0;
         SPELL_SPARK_Timer = 5000;
         SPELL_CREATE_RIFT_Timer = 25000;
         ChaoticRiftGUID = 0;
+
         DeadChaoticRift = false;
+
         if (pInstance)
             pInstance->SetData(DATA_ANOMALUS_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_ANOMALUS_EVENT, IN_PROGRESS);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (HeroicMode && !DeadChaoticRift)
         {
             AchievementEntry const *AchievChaosTheory = GetAchievementStore()->LookupEntry(ACHIEVEMENT_CHAOS_THEORY);
@@ -93,18 +111,21 @@ struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievChaosTheory);
                 }
             }
         }
+
         if (pInstance)
             pInstance->SetData(DATA_ANOMALUS_EVENT, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (m_creature->HasAura(SPELL_RIFT_SHIELD))
         {
             if (ChaoticRiftGUID)
@@ -119,11 +140,13 @@ struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
             }
         } else
             ChaoticRiftGUID = 0;
+
         if ((Phase == 0) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.75))
         {
             Phase = 1;
             DoScriptText(SAY_SHIELD, m_creature);
             DoCast(m_creature, SPELL_RIFT_SHIELD);
+
             int tmp = rand()%(2);
             Creature* Rift = m_creature->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[tmp][0], RiftLocation[tmp][1], RiftLocation[tmp][2], 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
             if (Rift)
@@ -135,11 +158,13 @@ struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
                 DoScriptText(SAY_RIFT , m_creature);
             }
         }
+
         if ((Phase == 1) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.50))
         {
             Phase = 2;
             DoScriptText(SAY_SHIELD , m_creature);
             DoCast(m_creature,SPELL_RIFT_SHIELD);
+
             int tmp = rand()%(2);
             Creature* Rift = m_creature->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[tmp][0], RiftLocation[tmp][1], RiftLocation[tmp][2], 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
             if (Rift)
@@ -151,11 +176,13 @@ struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
                 DoScriptText(SAY_RIFT , m_creature);
             }
         }
+
         if ((Phase == 2) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.25))
         {
             Phase = 3;
             DoScriptText(SAY_SHIELD , m_creature);
             DoCast(m_creature,SPELL_RIFT_SHIELD);
+
             int tmp = rand()%(2);
             Creature* Rift = m_creature->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[tmp][0], RiftLocation[tmp][1], RiftLocation[tmp][2], 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
             if (Rift)
@@ -167,15 +194,18 @@ struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
                 DoScriptText(SAY_RIFT , m_creature);
             }
         }
+
         if (SPELL_SPARK_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(target, HEROIC(SPELL_SPARK_N, SPELL_SPARK_H));
             SPELL_SPARK_Timer = 5000;
         }else SPELL_SPARK_Timer -=diff;
+
         if (SPELL_CREATE_RIFT_Timer < diff)
         {
             DoScriptText(SAY_RIFT , m_creature);
+
             int tmp = rand()%(2);
             Creature* Rift = m_creature->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[tmp][0], RiftLocation[tmp][1], RiftLocation[tmp][2], 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
             if (Rift)
@@ -183,22 +213,28 @@ struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
                     Rift->AI()->AttackStart(target);
             SPELL_CREATE_RIFT_Timer = 25000;
         }else SPELL_CREATE_RIFT_Timer -=diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_anomalus(Creature* pCreature)
 {
     return new boss_anomalusAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_chaotic_riftAI : public Scripted_NoMovementAI
 {
     mob_chaotic_riftAI(Creature *c) : Scripted_NoMovementAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 SPELL_CHAOTIC_ENERGY_BURST_Timer;
     uint32 SUMMON_CRAZED_MANA_WRAITH_Timer;
+
     void Reset()
     {
         SPELL_CHAOTIC_ENERGY_BURST_Timer = 1000;
@@ -208,14 +244,17 @@ struct TRINITY_DLL_DECL mob_chaotic_riftAI : public Scripted_NoMovementAI
                                          //Set model to horde number
         DoCast(m_creature, SPELL_ARCANEFORM, false);
     }
+
     void JustDied(Unit *killer)
     {
         DeadChaoticRift = true;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (SPELL_CHAOTIC_ENERGY_BURST_Timer < diff)
         {
             Unit* Anomalus = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_ANOMALUS) : 0);
@@ -226,6 +265,7 @@ struct TRINITY_DLL_DECL mob_chaotic_riftAI : public Scripted_NoMovementAI
                     DoCast(target, SPELL_CHAOTIC_ENERGY_BURST);
             SPELL_CHAOTIC_ENERGY_BURST_Timer = 1000;
         }else SPELL_CHAOTIC_ENERGY_BURST_Timer -=diff;
+
         if (SUMMON_CRAZED_MANA_WRAITH_Timer < diff)
         {
             Creature* Wraith = m_creature->SummonCreature(MOB_CRAZED_MANA_WRAITH, m_creature->GetPositionX()+1, m_creature->GetPositionY()+1, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
@@ -240,17 +280,21 @@ struct TRINITY_DLL_DECL mob_chaotic_riftAI : public Scripted_NoMovementAI
         }else SUMMON_CRAZED_MANA_WRAITH_Timer -=diff;
     }
 };
+
 CreatureAI* GetAI_mob_chaotic_rift(Creature* pCreature)
 {
     return new mob_chaotic_riftAI (pCreature);
 }
+
 void AddSC_boss_anomalus()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_anomalus";
     newscript->GetAI = &GetAI_boss_anomalus;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_chaotic_rift";
     newscript->GetAI = &GetAI_mob_chaotic_rift;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_keristrasza.cpp b/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_keristrasza.cpp
index 6274bf3d1f8..4845119a89e 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_keristrasza.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_keristrasza.cpp
@@ -13,18 +13,23 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss_Keristrasza
 SD%Complete:
 SDComment:
 SDCategory: The Nexus, The Nexus
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_nexus.h"
+
 enum eEnums
 {
     CONTAINMENT_SPHERES                             = 3,
+
     ACHIEVEMENT_INTENSE_COLD                        = 2036,
+
     //Spells
     SPELL_FROZEN_PRISON                             = 47854,
     SPELL_TAIL_SWEEP                                = 50155,
@@ -35,6 +40,7 @@ enum eEnums
     SPELL_CRYSTALIZE                                = 48179,
     SPELL_INTENSE_COLD                              = 48094,
     SPELL_INTENSE_COLD_TRIGGERED                    = 48095,
+
     //Yell
     SAY_AGGRO                                       = -1576040,
     SAY_SLAY                                        = -1576041,
@@ -42,6 +48,7 @@ enum eEnums
     SAY_DEATH                                       = -1576043,
     SAY_CRYSTAL_NOVA                                = -1576044
 };
+
 struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI
 {
     boss_keristraszaAI(Creature *c) : ScriptedAI(c)
@@ -49,38 +56,51 @@ struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool HeroicMode;
+
     uint32 CRYSTALFIRE_BREATH_Timer;
     uint32 CRYSTAL_CHAINS_CRYSTALIZE_Timer;
     uint32 TAIL_SWEEP_Timer;
     bool Enrage;
+
     uint64 ContainmentSphereGUIDs[CONTAINMENT_SPHERES];
+
     uint32 CheckIntenseColdTimer;
     bool MoreThanTwoIntenseCold; // needed for achievement: Intense Cold(2036)
+
     void Reset()
     {
         CRYSTALFIRE_BREATH_Timer = 14000;
         CRYSTAL_CHAINS_CRYSTALIZE_Timer = HEROIC(30000,11000);
         TAIL_SWEEP_Timer = 5000;
         Enrage = false;
+
         CheckIntenseColdTimer = 2000;
         MoreThanTwoIntenseCold = false;
+
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+
         RemovePrison(CheckContainmentSpheres());
+
         if (pInstance)
             pInstance->SetData(DATA_KERISTRASZA_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoCastAOE(SPELL_INTENSE_COLD);
+
         if (pInstance)
             pInstance->SetData(DATA_KERISTRASZA_EVENT, IN_PROGRESS);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (HeroicMode && !MoreThanTwoIntenseCold)
         {
             AchievementEntry const *AchievIntenseCold = GetAchievementStore()->LookupEntry(ACHIEVEMENT_INTENSE_COLD);
@@ -90,27 +110,33 @@ struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievIntenseCold);
                 }
             }
         }
+
         if (pInstance)
             pInstance->SetData(DATA_KERISTRASZA_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_SLAY, m_creature);
     }
+
     bool CheckContainmentSpheres(bool remove_prison = false)
     {
         if(!pInstance)
             return false;
+
         ContainmentSphereGUIDs[0] = pInstance->GetData64(ANOMALUS_CONTAINMET_SPHERE);
         ContainmentSphereGUIDs[1] = pInstance->GetData64(ORMOROKS_CONTAINMET_SPHERE);
         ContainmentSphereGUIDs[2] = pInstance->GetData64(TELESTRAS_CONTAINMET_SPHERE);
+
         GameObject *ContainmentSpheres[CONTAINMENT_SPHERES];
-        for (uint8 i = 0; i < CONTAINMENT_SPHERES; ++i)
+
+        for(uint8 i = 0; i < CONTAINMENT_SPHERES; ++i)
         {
             ContainmentSpheres[i] = pInstance->instance->GetGameObject(ContainmentSphereGUIDs[i]);
             if (!ContainmentSpheres[i])
@@ -122,6 +148,7 @@ struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI
             RemovePrison(true);
         return true;
     }
+
     void RemovePrison(bool remove)
     {
         if (remove)
@@ -138,18 +165,21 @@ struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI
             m_creature->CastSpell(m_creature, SPELL_FROZEN_PRISON, false);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (CheckIntenseColdTimer < diff && !MoreThanTwoIntenseCold)
         {
             std::list ThreatList = m_creature->getThreatManager().getThreatList();
-            for (std::list::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); itr++)
+            for(std::list::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); itr++)
             {
                 Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                 if (!target || target->GetTypeId() != TYPEID_PLAYER)
                     continue;
+
                 Aura *AuraIntenseCold = target->GetAura(SPELL_INTENSE_COLD_TRIGGERED);
                 if (AuraIntenseCold && AuraIntenseCold->GetStackAmount() > 2)
                 {
@@ -159,22 +189,26 @@ struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI
             }
             CheckIntenseColdTimer = 2000;
         } else CheckIntenseColdTimer -= diff;
+
         if (!Enrage && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.25))
         {
             DoScriptText(SAY_ENRAGE, m_creature);
             DoCast(m_creature, SPELL_ENRAGE);
             Enrage = true;
         }
+
         if (CRYSTALFIRE_BREATH_Timer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_CRYSTALFIRE_BREATH_N, SPELL_CRYSTALFIRE_BREATH_H));
             CRYSTALFIRE_BREATH_Timer = 14000;
         } else CRYSTALFIRE_BREATH_Timer -=diff;
+
         if (TAIL_SWEEP_Timer < diff)
         {
             DoCast(m_creature, SPELL_TAIL_SWEEP);
             TAIL_SWEEP_Timer = 5000;
         } else TAIL_SWEEP_Timer -=diff;
+
         if (CRYSTAL_CHAINS_CRYSTALIZE_Timer < diff)
         {
             DoScriptText(SAY_CRYSTAL_NOVA, m_creature);
@@ -184,33 +218,41 @@ struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI
                 DoCast(target, SPELL_CRYSTAL_CHAINS);
             CRYSTAL_CHAINS_CRYSTALIZE_Timer = HEROIC(30000,11000);
         } else CRYSTAL_CHAINS_CRYSTALIZE_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_keristrasza(Creature* pCreature)
 {
     return new boss_keristraszaAI (pCreature);
 }
+
 bool GOHello_containment_sphere(Player *pPlayer, GameObject *pGO)
 {
     ScriptedInstance *pInstance = pGO->GetInstanceData();
+
     Creature *Keristrasza = Unit::GetCreature(*pGO, pInstance ? pInstance->GetData64(DATA_KERISTRASZA) : 0);
     if (Keristrasza && Keristrasza->isAlive())
     {
         // maybe these are hacks :(
         pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
         pGO->SetGoState(GO_STATE_ACTIVE);
+
         CAST_AI(boss_keristraszaAI, Keristrasza->AI())->CheckContainmentSpheres(true);
     }
     return true;
 }
+
 void AddSC_boss_keristrasza()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_keristrasza";
     newscript->GetAI = &GetAI_boss_keristrasza;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "containment_sphere";
     newscript->pGOHello = &GOHello_containment_sphere;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_magus_telestra.cpp b/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_magus_telestra.cpp
index 5b7d2000c6c..d043705ab54 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_magus_telestra.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_magus_telestra.cpp
@@ -13,14 +13,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss_Magus_Telestra
 SD%Complete:
 SDComment:
 SDCategory: The Nexus, The Nexus
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_nexus.h"
+
 enum eEnums
 {
 //Spells
@@ -30,13 +33,16 @@ enum eEnums
     SPELL_FIREBOMB_H          = 56934,
     SPELL_GRAVITY_WELL        = 47756,
     SPELL_TELESTRA_BACK       = 47714,
+
 //At 50% HP - 3 clones, Frost, Fire, Arcane (and in 10% HP in Heroic)
     MOB_FIRE_MAGUS            = 26928,
     MOB_FROST_MAGUS           = 26930,
     MOB_ARCANE_MAGUS          = 26929,
+
     SPELL_FIRE_MAGUS_VISUAL   = 47705,
     SPELL_FROST_MAGUS_VISUAL  = 47706,
     SPELL_ARCANE_MAGUS_VISUAL = 47704,
+
 //Yell
     SAY_AGGRO                 = -1576000,
     SAY_KILL                  = -1576001,
@@ -44,14 +50,17 @@ enum eEnums
     SAY_MERGE                 = -1576003,
     SAY_SPLIT_1               = -1576004,
     SAY_SPLIT_2               = -1576005,
+
 //Achievement
     ACHIEV_SPLIT_PERSONALITY  = 2150,
     ACHIEV_TIMER              = 5 * 1000
 };
+
 float CenterOfRoom[1][4] =
 {
     {504.80, 89.07, -16.12, 6.27}
 };
+
 struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
 {
     boss_magus_telestraAI(Creature* c) : ScriptedAI(c)
@@ -59,24 +68,31 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool HeroicMode;
+
     uint64 FireMagusGUID;
     uint64 FrostMagusGUID;
     uint64 ArcaneMagusGUID;
     bool FireMagusDead;
     bool FrostMagusDead;
     bool ArcaneMagusDead;
+
     uint32 AppearDelay_Timer;
     bool AppearDelay;
+
     uint8 Phase;
+
     uint32 SPELL_ICE_NOVA_Timer;
     uint32 SPELL_FIREBOMB_Timer;
     uint32 SPELL_GRAVITY_WELL_Timer;
     uint32 Cooldown;
+
     bool AchievementTimerRunning;
     uint8 AchievementProgress;
     uint32 AchievementTimer;
+
     void Reset()
     {
         Phase = 0;
@@ -85,27 +101,36 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
         SPELL_FIREBOMB_Timer =  0;
         SPELL_GRAVITY_WELL_Timer = 15000;
         Cooldown = 0;
+
         FireMagusGUID = 0;
         FrostMagusGUID = 0;
         ArcaneMagusGUID = 0;
+
         AchievementProgress = 0;
         AchievementTimer = 0;
         AchievementTimerRunning = false;
+
         AppearDelay = false;
+
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetVisibility(VISIBILITY_ON);
+
         if (pInstance)
             pInstance->SetData(DATA_MAGUS_TELESTRA_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_MAGUS_TELESTRA_EVENT, IN_PROGRESS);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (HeroicMode && AchievementProgress == 2)
         {
             AchievementEntry const *AchievSplitPersonality = GetAchievementStore()->LookupEntry(ACHIEV_SPLIT_PERSONALITY);
@@ -115,18 +140,21 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievSplitPersonality);
                 }
             }
         }
+
         if (pInstance)
             pInstance->SetData(DATA_MAGUS_TELESTRA_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_KILL, m_creature);
     }
+
     uint64 SplitPersonality(uint32 entry)
     {
         Creature* Summoned = m_creature->SummonCreature(entry, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
@@ -156,6 +184,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
         }
         return 0;
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
@@ -163,6 +192,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
         {
             return;
         }
+
         if (AppearDelay)
         {
             m_creature->StopMoving();
@@ -175,6 +205,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
             return;
         }
 
+
         if ((Phase == 1)||(Phase == 3))
         {
             Unit* FireMagus;
@@ -229,6 +260,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
             }else
                 return;
         }
+
         if ((Phase == 0) && (m_creature->GetHealth() <= (m_creature->GetMaxHealth() * 0.5)))
         {
             Phase = 1;
@@ -245,6 +277,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
             DoScriptText(RAND(SAY_SPLIT_1,SAY_SPLIT_2), m_creature);
             return;
         }
+
         if (HeroicMode && (Phase == 2) && (m_creature->GetHealth() <= (m_creature->GetMaxHealth() * 0.1)))
         {
             Phase = 3;
@@ -261,6 +294,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
             DoScriptText(RAND(SAY_SPLIT_1,SAY_SPLIT_2), m_creature);
             return;
         }
+
         if (Cooldown)
         {
             if (Cooldown < diff)
@@ -271,6 +305,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
                 return;
             }
         }
+
         if (SPELL_ICE_NOVA_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -280,6 +315,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
             }
             SPELL_ICE_NOVA_Timer = 15000;
         }else SPELL_ICE_NOVA_Timer -=diff;
+
         if (SPELL_GRAVITY_WELL_Timer < diff)
         {
             if (Unit* target = m_creature->getVictim())
@@ -289,6 +325,7 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
             }
             SPELL_GRAVITY_WELL_Timer = 15000;
         }else SPELL_GRAVITY_WELL_Timer -=diff;
+
         if (SPELL_FIREBOMB_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -298,16 +335,20 @@ struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI
             }
             SPELL_FIREBOMB_Timer = 2000;
         }else SPELL_FIREBOMB_Timer -=diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_magus_telestra(Creature* pCreature)
 {
     return new boss_magus_telestraAI (pCreature);
 }
+
 void AddSC_boss_magus_telestra()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_magus_telestra";
     newscript->GetAI = &GetAI_boss_magus_telestra;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_ormorok.cpp b/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_ormorok.cpp
index 62d4ae008b3..44c4a16401d 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_ormorok.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/nexus/boss_ormorok.cpp
@@ -13,14 +13,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss_Ormorok
 SD%Complete:
 SDComment:
 SDCategory: The Nexus, The Nexus
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_nexus.h"
+
 enum eEnums
 {
 //Spells
@@ -39,6 +42,7 @@ enum eEnums
     SPELL_SUMMON_CRYSTALLINE_TANGLER           = 61564, //summons npc 32665
     MOB_CRYSTALLINE_TANGLER                    = 32665,
     SPELL_ROOTS                                = 28858, //proper spell id is unknown
+
 //Yell
     SAY_AGGRO                               = -1576020,
     SAY_DEATH                               = -1576021,
@@ -46,7 +50,9 @@ enum eEnums
     SAY_CRYSTAL_SPIKES                      = -1576023,
     SAY_KILL                                = -1576024
 };
+
 #define SPIKE_DISTANCE                            5.0f
+
 struct TRINITY_DLL_DECL boss_ormorokAI : public ScriptedAI
 {
     boss_ormorokAI(Creature *c) : ScriptedAI(c)
@@ -54,6 +60,7 @@ struct TRINITY_DLL_DECL boss_ormorokAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool HeroicMode;
     bool Frenzy;
@@ -64,12 +71,14 @@ struct TRINITY_DLL_DECL boss_ormorokAI : public ScriptedAI
     float BaseZ;
     float BaseO;
     float SpikeXY[4][2];
+
     uint32 SPELL_CRYSTAL_SPIKES_Timer;
     uint32 CRYSTAL_SPIKES_Timer;
     uint32 SPELL_TRAMPLE_Timer;
     uint32 SPELL_FRENZY_Timer;
     uint32 SPELL_SPELL_REFLECTION_Timer;
     uint32 SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer;
+
     void Reset()
     {
         SPELL_CRYSTAL_SPIKES_Timer = 12000;
@@ -78,25 +87,32 @@ struct TRINITY_DLL_DECL boss_ormorokAI : public ScriptedAI
         SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer = 17000;
         Frenzy = false;
         CrystalSpikes = false;
+
         if (pInstance)
             pInstance->SetData(DATA_ORMOROK_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_ORMOROK_EVENT, IN_PROGRESS);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_ORMOROK_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -120,22 +136,26 @@ struct TRINITY_DLL_DECL boss_ormorokAI : public ScriptedAI
                     CrystalSpikes = false;
                 CRYSTAL_SPIKES_Timer = 200;
             }else CRYSTAL_SPIKES_Timer -= diff;
+
         if (!Frenzy && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.25))
         {
             DoCast(m_creature, SPELL_FRENZY);
             Frenzy = true;
         }
+
         if (SPELL_TRAMPLE_Timer < diff)
         {
             DoCast(m_creature, HEROIC(SPELL_TRAMPLE_N, SPELL_TRAMPLE_H));
             SPELL_TRAMPLE_Timer = 10000;
         }else SPELL_TRAMPLE_Timer -= diff;
+
         if (SPELL_SPELL_REFLECTION_Timer < diff)
         {
             DoScriptText(SAY_REFLECT, m_creature);
             DoCast(m_creature, SPELL_SPELL_REFLECTION);
             SPELL_SPELL_REFLECTION_Timer = 30000;
         }else SPELL_SPELL_REFLECTION_Timer -= diff;
+
         if (SPELL_CRYSTAL_SPIKES_Timer < diff)
         {
             DoScriptText(SAY_CRYSTAL_SPIKES, m_creature);
@@ -148,6 +168,7 @@ struct TRINITY_DLL_DECL boss_ormorokAI : public ScriptedAI
             BaseO = m_creature->GetOrientation();
             SPELL_CRYSTAL_SPIKES_Timer = 20000;
         }else SPELL_CRYSTAL_SPIKES_Timer -=diff;
+
         if (HeroicMode && (SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer < diff))
         {
             Creature* Crystalline_Tangler = m_creature->SummonCreature(MOB_CRYSTALLINE_TANGLER, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
@@ -187,18 +208,23 @@ struct TRINITY_DLL_DECL boss_ormorokAI : public ScriptedAI
             }
             SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer = 17000;
         }else SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer -=diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_crystal_spikeAI : public Scripted_NoMovementAI
 {
     mob_crystal_spikeAI(Creature *c) : Scripted_NoMovementAI(c)
     {
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
+
     uint32 SPELL_CRYSTALL_SPIKE_DAMAGE_Timer;
     uint32 SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer;
+
     void Reset()
     {
         SPELL_CRYSTALL_SPIKE_DAMAGE_Timer = 3700;
@@ -208,6 +234,7 @@ struct TRINITY_DLL_DECL mob_crystal_spikeAI : public Scripted_NoMovementAI
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); //
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); //
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer < diff)
@@ -215,6 +242,7 @@ struct TRINITY_DLL_DECL mob_crystal_spikeAI : public Scripted_NoMovementAI
             DoCast(m_creature, SPELL_CRYSTAL_SPIKE_PREVISUAL);
             SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer = 10000;
         }else SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer -=diff;
+
         if (SPELL_CRYSTALL_SPIKE_DAMAGE_Timer < diff)
         {
             DoCast(m_creature, HEROIC(SPELL_CRYSTALL_SPIKE_DAMAGE_N, SPELL_CRYSTALL_SPIKE_DAMAGE_H));
@@ -222,14 +250,18 @@ struct TRINITY_DLL_DECL mob_crystal_spikeAI : public Scripted_NoMovementAI
         }else SPELL_CRYSTALL_SPIKE_DAMAGE_Timer -=diff;
     }
 };
+
 struct TRINITY_DLL_DECL mob_crystalline_tanglerAI : public ScriptedAI
 {
     mob_crystalline_tanglerAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 SPELL_ROOTS_Timer;
+
     void Reset()
     {
         SPELL_ROOTS_Timer = 1000;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (SPELL_ROOTS_Timer < diff)
@@ -242,29 +274,36 @@ struct TRINITY_DLL_DECL mob_crystalline_tanglerAI : public ScriptedAI
         }else SPELL_ROOTS_Timer -=diff;
     }
 };
+
 CreatureAI* GetAI_mob_crystal_spike(Creature* pCreature)
 {
     return new mob_crystal_spikeAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_crystalline_tangler(Creature* pCreature)
 {
     return new mob_crystalline_tanglerAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_ormorok(Creature* pCreature)
 {
     return new boss_ormorokAI (pCreature);
 }
+
 void AddSC_boss_ormorok()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_ormorok";
     newscript->GetAI = &GetAI_boss_ormorok;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_crystal_spike";
     newscript->GetAI = &GetAI_mob_crystal_spike;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_crystalline_tangler";
     newscript->GetAI = &GetAI_mob_crystalline_tangler;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/nexus/commander_kolurg.cpp b/src/bindings/scripts/scripts/northrend/nexus/nexus/commander_kolurg.cpp
index aaee8e8bd55..6fd8a7d4fe2 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/nexus/commander_kolurg.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/nexus/commander_kolurg.cpp
@@ -5,23 +5,28 @@ SD%Complete:
 SDComment:  Only Alliance Heroic
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_commander_kolurg' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 #define SPELL_BATTLE_SHOUT                                    31403
 #define SPELL_CHARGE                                          60067
 #define SPELL_FRIGHTENING_SHOUT                               19134
 #define SPELL_WHIRLWIND_1                                     38619
 #define SPELL_WHIRLWIND_2                                     38618
+
 //not used
 //Yell
 #define SAY_AGGRO                                          -1576024
 #define SAY_KILL                                           -1576025
 #define SAY_DEATH                                          -1576026
+
 struct TRINITY_DLL_DECL boss_commander_kolurgAI : public ScriptedAI
 {
     boss_commander_kolurgAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit* who) {}
     void AttackStart(Unit* who) {}
@@ -31,17 +36,21 @@ struct TRINITY_DLL_DECL boss_commander_kolurgAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)  {}
 };
+
 CreatureAI* GetAI_boss_commander_kolurg(Creature* pCreature)
 {
     return new boss_commander_kolurgAI (pCreature);
 }
+
 void AddSC_boss_commander_kolurg()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_commander_kolurg";
     newscript->GetAI = &GetAI_boss_commander_kolurg;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/nexus/commander_stoutbeard.cpp b/src/bindings/scripts/scripts/northrend/nexus/nexus/commander_stoutbeard.cpp
index 2a64bc3915b..def5fc92999 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/nexus/commander_stoutbeard.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/nexus/commander_stoutbeard.cpp
@@ -5,23 +5,28 @@ SD%Complete:
 SDComment:  Only Horde Heroic
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_commander_stoutbeard' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 #define SPELL_BATTLE_SHOUT                                       31403
 #define SPELL_CHARGE                                             60067
 #define SPELL_FRIGHTENING_SHOUT                                  19134
 #define SPELL_WHIRLWIND_1                                        38619
 #define SPELL_WHIRLWIND_2                                        38618
+
 //not used
 //Yell
 #define SAY_AGGRO                                              -1576021
 #define SAY_KILL                                               -1576022
 #define SAY_DEATH                                              -1576023
+
 struct TRINITY_DLL_DECL boss_commander_stoutbeardAI : public ScriptedAI
 {
     boss_commander_stoutbeardAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit* who)
     {
@@ -34,6 +39,7 @@ struct TRINITY_DLL_DECL boss_commander_stoutbeardAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
@@ -41,13 +47,16 @@ struct TRINITY_DLL_DECL boss_commander_stoutbeardAI : public ScriptedAI
         DoScriptText(SAY_DEATH, m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_commander_stoutbeard(Creature* pCreature)
 {
     return new boss_commander_stoutbeardAI (pCreature);
 }
+
 void AddSC_boss_commander_stoutbeard()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_commander_stoutbeard";
     newscript->GetAI = &GetAI_boss_commander_stoutbeard;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/nexus/def_nexus.h b/src/bindings/scripts/scripts/northrend/nexus/nexus/def_nexus.h
index 2fd3a37bb16..de36fea4b93 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/nexus/def_nexus.h
+++ b/src/bindings/scripts/scripts/northrend/nexus/nexus/def_nexus.h
@@ -1,15 +1,19 @@
 #ifndef DEF_NEXUS_H
 #define DEF_NEXUS_H
+
 enum eTypes
 {
     DATA_MAGUS_TELESTRA_EVENT,
     DATA_ANOMALUS_EVENT,
     DATA_ORMOROK_EVENT,
     DATA_KERISTRASZA_EVENT,
+
     DATA_ANOMALUS,
     DATA_KERISTRASZA,
+
     ANOMALUS_CONTAINMET_SPHERE,
     ORMOROKS_CONTAINMET_SPHERE,
     TELESTRAS_CONTAINMET_SPHERE
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/nexus/nexus/instance_nexus.cpp b/src/bindings/scripts/scripts/northrend/nexus/nexus/instance_nexus.cpp
index 6249d035c49..c420cb1920d 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/nexus/instance_nexus.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/nexus/instance_nexus.cpp
@@ -13,34 +13,46 @@
  * along 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_Nexus
 SD%Complete:
 SDComment:
 SDCategory: The Nexus, The Nexus
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_nexus.h"
+
 #define NUMBER_OF_ENCOUNTERS      4
+
 struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance
 {
     instance_nexus(Map* pMap) : ScriptedInstance(pMap) { Initialize(); }
+
     uint32 m_auiEncounter[NUMBER_OF_ENCOUNTERS];
+
     uint64 Anomalus;
     uint64 Keristrasza;
+
     uint64 AnomalusContainmentSphere;
     uint64 OrmoroksContainmentSphere;
     uint64 TelestrasContainmentSphere;
+
     std::string strInstData;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         Anomalus = 0;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         Map::PlayerList const& players = instance->GetPlayers();
         uint32 TeamInInstance = 0;
+
         if (!players.isEmpty())
         {
             if (Player* pPlayer = players.begin()->getSource())
@@ -94,6 +106,7 @@ struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance
                 }
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -121,6 +134,7 @@ struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance
             }
         }
     }
+
     uint32 GetData(uint32 identifier)
     {
         switch(identifier)
@@ -132,6 +146,7 @@ struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 identifier, uint32 data)
     {
         switch(identifier)
@@ -171,17 +186,22 @@ struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance
             }
             case DATA_KERISTRASZA_EVENT:    m_auiEncounter[3] = data; break;
         }
+
         if (data == DONE)
         {
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
             saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                 << m_auiEncounter[3];
+
             strInstData = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
     }
+
     uint64 GetData64(uint32 uiIdentifier)
     {
         switch(uiIdentifier)
@@ -194,10 +214,12 @@ struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance
         }
         return 0;
     }
+
     std::string GetSaveData()
     {
         return strInstData;
     }
+
     void Load(const char* chrIn)
     {
         if (!chrIn)
@@ -205,21 +227,27 @@ struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(chrIn);
+
         std::istringstream loadStream(chrIn);
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3];
-        for (uint8 i = 0; i < NUMBER_OF_ENCOUNTERS; ++i)
+
+        for(uint8 i = 0; i < NUMBER_OF_ENCOUNTERS; ++i)
         {
             if (m_auiEncounter[i] == IN_PROGRESS)
                 m_auiEncounter[i] = NOT_STARTED;
         }
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_nexus(Map* pMap)
 {
     return new instance_nexus(pMap);
 }
+
 void AddSC_instance_nexus()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_drakos.cpp b/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_drakos.cpp
index 107753764e4..3ef2fa93fa3 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_drakos.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_drakos.cpp
@@ -5,14 +5,17 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Spells
 #define SPELL_MAGIC_PULL                           51336
 #define SPELL_THUNDERING_STOMP                     50774
 #define SPELL_THUNDERING_STOMP_2                   59370
+
 //not in db
 //Yell
 #define SAY_AGGRO                               -1578000
@@ -27,9 +30,11 @@ update creature_template set scriptname = '' where entry = '';
 #define SAY_STOMP_1                             -1578009
 #define SAY_STOMP_2                             -1578010
 #define SAY_STOMP_3                             -1578011
+
 struct TRINITY_DLL_DECL boss_drakosAI : public ScriptedAI
 {
     boss_drakosAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit* who)
     {
@@ -42,6 +47,7 @@ struct TRINITY_DLL_DECL boss_drakosAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
@@ -55,13 +61,16 @@ struct TRINITY_DLL_DECL boss_drakosAI : public ScriptedAI
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2,SAY_KILL_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_drakos(Creature* pCreature)
 {
     return new boss_drakosAI (pCreature);
 }
+
 void AddSC_boss_drakos()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_drakos";
     newscript->GetAI = &GetAI_boss_drakos;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_eregos.cpp b/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_eregos.cpp
index e1640628cae..a0837ac0634 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_eregos.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_eregos.cpp
@@ -5,21 +5,26 @@ SD%Complete:
 SDComment:  Encounter is done entirely on drake vehicles
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Types of drake mounts: Ruby(Tank),  Amber(DPS),  Emerald(Healer)
 //Two Repeating phases
+
 //Spells
 #define SPELL_ARCANE_BARRAGE                       50804
 #define SPELL_ARCANE_VOLLEY                        51153
 #define SPELL_ENRAGED_ASSAULT                      51170
 #define SPELL_PLANAR_ANOMALIES                     57959
 #define SPELL_PLANAR_SHIFT                         51162
+
 //Heroic
 #define SPELL_ARCANE_BARRAGE_H                     59381
 #define SPELL_ARCANE_VOLLEY_H                      59382
+
 /*Ruby Drake ,
 (npc 27756) (item 37860)
 (summoned by spell Ruby Essence = 37860 ---> Call Amber Drake == 49462 ---> Summon 27756)
@@ -27,11 +32,13 @@ update creature_template set scriptname = '' where entry = '';
 #define NPC_RUBY_DRAKE_VEHICLE                     27756
 #define SPELL_RIDE_RUBY_DRAKE_QUE                  49463          //Apply Aura: Periodic Trigger, Interval: 3 seconds ---> 49464
 #define SPELL_RUBY_DRAKE_SADDLE                    49464          //Allows you to ride on the back of an Amber Drake. ---> Dummy
+
 #define SPELL_RUBY_SEARING_WRATH                   50232          //(60 yds) - Instant - Breathes a stream of fire at an enemy dragon, dealing 6800 to 9200 Fire damage and then jumping to additional dragons within 30 yards. Each jump increases the damage by 50%. Affects up to 5 total targets
 #define SPELL_RUBY_EVASIVE_AURA                    50248          //Instant - Allows the Ruby Drake to generate Evasive Charges when hit by hostile attacks and spells.
 #define SPELL_RUBY_EVASIVE_MANEUVERS               50240          //Instant - 5 sec. cooldown - Allows your drake to dodge all incoming attacks and spells. Requires Evasive Charges to use. Each attack or spell dodged while this ability is active burns one Evasive Charge. Lasts 30 sec. or until all charges are exhausted.
 //you do not have acces to until you kill Mage-Lord Urom
 #define SPELL_RUBY_MARTYR                          50253          //Instant - 10 sec. cooldown - Redirect all harmful spells cast at friendly drakes to yourself for 10 sec.
+
 /*Amber Drake,
 (npc 27755)  (item 37859)
 (summoned by spell Amber Essence = 37859 ---> Call Amber Drake == 49461 ---> Summon 27755)
@@ -39,10 +46,12 @@ update creature_template set scriptname = '' where entry = '';
 #define NPC_AMBER_DRAKE_VEHICLE                    27755
 #define SPELL_RIDE_AMBER_DRAKE_QUE                 49459          //Apply Aura: Periodic Trigger, Interval: 3 seconds ---> 49460
 #define SPELL_AMBER_DRAKE_SADDLE                   49460          //Allows you to ride on the back of an Amber Drake. ---> Dummy
+
 #define SPELL_AMBER_SHOCK_LANCE                    49840         //(60 yds) - Instant - Deals 4822 to 5602 Arcane damage and detonates all Shock Charges on an enemy dragon. Damage is increased by 6525 for each detonated.
 #define SPELL_AMBER_STOP_TIME                                    //Instant - 1 min cooldown - Halts the passage of time, freezing all enemy dragons in place for 10 sec. This attack applies 5 Shock Charges to each affected target.
 //you do not have access to until you kill the  Mage-Lord Urom.
 #define SPELL_AMBER_TEMPORAL_RIFT                  49592         //(60 yds) - Channeled - Channels a temporal rift on an enemy dragon for 10 sec. While trapped in the rift, all damage done to the target is increased by 100%. In addition, for every 15,000 damage done to a target affected by Temporal Rift, 1 Shock Charge is generated.
+
 /*Emerald Drake,
 (npc 27692)  (item 37815),
  (summoned by spell Emerald Essence = 37815 ---> Call Emerald Drake == 49345 ---> Summon 27692)
@@ -50,14 +59,18 @@ update creature_template set scriptname = '' where entry = '';
 #define NPC_EMERALD_DRAKE_VEHICLE                  27692
 #define SPELL_RIDE_EMERALD_DRAKE_QUE               49427         //Apply Aura: Periodic Trigger, Interval: 3 seconds ---> 49346
 #define SPELL_EMERALD_DRAKE_SADDLE                 49346         //Allows you to ride on the back of an Amber Drake. ---> Dummy
+
 #define SPELL_EMERALD_LEECHING_POISON              50328         //(60 yds) - Instant - Poisons the enemy dragon, leeching 1300 to the caster every 2 sec. for 12 sec. Stacks up to 3 times.
 #define SPELL_EMERALD_TOUCH_THE_NIGHTMARE          50341         //(60 yds) - Instant - Consumes 30% of the caster's max health to inflict 25,000 nature damage to an enemy dragon and reduce the damage it deals by 25% for 30 sec.
 // you do not have access to until you kill the Mage-Lord Urom
 #define SPELL_EMERALD_DREAM_FUNNEL                 50344         //(60 yds) - Channeled - Transfers 5% of the caster's max health to a friendly drake every second for 10 seconds as long as the caster channels.
+
 struct TRINITY_DLL_DECL boss_eregosAI : public ScriptedAI
 {
     boss_eregosAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 phase;
+
     void Reset() {}
     void EnterCombat(Unit* who) {}
     void AttackStart(Unit* who) {}
@@ -67,18 +80,23 @@ struct TRINITY_DLL_DECL boss_eregosAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         phase =1;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)  {}
 };
+
 CreatureAI* GetAI_boss_eregos(Creature* pCreature)
 {
     return new boss_eregosAI (pCreature);
 }
+
 void AddSC_boss_eregos()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_eregos";
     newscript->GetAI = &GetAI_boss_eregos;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_urom.cpp b/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_urom.cpp
index 52670dc9bc9..0693b74b9f1 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_urom.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_urom.cpp
@@ -5,10 +5,12 @@ SD%Complete:  1%
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Spells
 #define SPELL_ARCANE_SHIELD                      53813 //Dummy --> Channeled, shields the caster from damage.
 #define SPELL_EMPOWERED_ARCANE_EXPLOSION         51110
@@ -20,6 +22,7 @@ update creature_template set scriptname = '' where entry = '';
 #define SPELL_TELEPORT                           51112 //Teleports to the center of Oculus
 #define SPELL_TIME_BOMB                          51121 //Deals arcane damage to a random player, and after 6 seconds, deals zone damage to nearby equal to the health missing of the target afflicted by the debuff.
 #define SPELL_TIME_BOMB_2                        59376
+
 //not in db
 //Yell
 #define SAY_AGGRO                             -1578012
@@ -32,9 +35,11 @@ update creature_template set scriptname = '' where entry = '';
 #define SAY_SUMMON_1                          -1578019
 #define SAY_SUMMON_2                          -1578020
 #define SAY_SUMMON_3                          -1578021
+
 struct TRINITY_DLL_DECL boss_uromAI : public ScriptedAI
 {
     boss_uromAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit* who)
     {
@@ -47,6 +52,7 @@ struct TRINITY_DLL_DECL boss_uromAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
@@ -60,13 +66,16 @@ struct TRINITY_DLL_DECL boss_uromAI : public ScriptedAI
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2,SAY_KILL_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_urom(Creature* pCreature)
 {
     return new boss_uromAI (pCreature);
 }
+
 void AddSC_boss_urom()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_urom";
     newscript->GetAI = &GetAI_boss_urom;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_varos.cpp b/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_varos.cpp
index b2d4c201eba..0ccd453e4d2 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_varos.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/oculus/boss_varos.cpp
@@ -5,10 +5,12 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
+
 //Spells
 #define SPELL_ENERGIZE_CORES                      50785 //Damage 5938 to 6562, effec2 Triggers 54069, effect3 Triggers 56251
 #define SPELL_ENERGIZE_CORES_TRIGGER_1            54069
@@ -20,6 +22,7 @@ update creature_template set scriptname = '' where entry = '';
 #define SPELL_CALL_AZURE_RING_CAPTAIN_4           51008 //Effect    Send Event (18455)
 #define SPELL_CALL_AMPLIFY_MAGIC                  51054
 #define SPELL_CALL_AMPLIFY_MAGIC_2                59371
+
 //not in db
 //Yell
 #define SAY_AGGRO                              -1578022
@@ -31,9 +34,11 @@ update creature_template set scriptname = '' where entry = '';
 #define SAY_STRIKE_3                           -1578028
 #define SAY_SPAWN                              -1578029
 
+
 struct TRINITY_DLL_DECL boss_varosAI : public ScriptedAI
 {
     boss_varosAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit* who)
     {
@@ -46,6 +51,7 @@ struct TRINITY_DLL_DECL boss_varosAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
@@ -59,13 +65,16 @@ struct TRINITY_DLL_DECL boss_varosAI : public ScriptedAI
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_varos(Creature* pCreature)
 {
     return new boss_varosAI (pCreature);
 }
+
 void AddSC_boss_varos()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_varos";
     newscript->GetAI = &GetAI_boss_varos;
diff --git a/src/bindings/scripts/scripts/northrend/nexus/oculus/def_oculus.h b/src/bindings/scripts/scripts/northrend/nexus/oculus/def_oculus.h
index d1924db70bc..0b63a52d866 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/oculus/def_oculus.h
+++ b/src/bindings/scripts/scripts/northrend/nexus/oculus/def_oculus.h
@@ -1,3 +1,4 @@
 #ifndef DEF_OCULUS_H
 #define DEF_OCULUS_H
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/nexus/oculus/instance_oculus.cpp b/src/bindings/scripts/scripts/northrend/nexus/oculus/instance_oculus.cpp
index 834c222c895..b5ceee9e5ed 100644
--- a/src/bindings/scripts/scripts/northrend/nexus/oculus/instance_oculus.cpp
+++ b/src/bindings/scripts/scripts/northrend/nexus/oculus/instance_oculus.cpp
@@ -1,13 +1,16 @@
 #include "precompiled.h"
 #include "def_oculus.h"
+
 struct TRINITY_DLL_DECL instance_oculus : public ScriptedInstance
 {
     instance_oculus(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
 };
+
 InstanceData* GetInstanceData_instance_oculus(Map* pMap)
 {
     return new instance_oculus(pMap);
 }
+
 void AddSC_instance_oculus()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp b/src/bindings/scripts/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp
index b32ca88b337..f13372af22d 100644
--- a/src/bindings/scripts/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp
+++ b/src/bindings/scripts/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp
@@ -13,14 +13,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss Sartharion
 SD%Complete: 70%
 SDComment: Flame wave, achievement and portal events need to be implemented
 SDCategory: Obsidian Sanctum
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_obsidian_sanctum.h"
+
 enum eEnums
 {
     //Sartharion Yell
@@ -38,11 +41,14 @@ enum eEnums
     SAY_SARTHARION_SLAY_1                       = -1615029,
     SAY_SARTHARION_SLAY_2                       = -1615030,
     SAY_SARTHARION_SLAY_3                       = -1615031,
+
     WHISPER_LAVA_CHURN                          = -1615032,
+
     WHISPER_SHADRON_DICIPLE                     = -1615008,
     WHISPER_VESPERON_DICIPLE                    = -1615041,
     WHISPER_HATCH_EGGS                          = -1615017,
     WHISPER_OPEN_PORTAL                         = -1615042, // whisper, shared by two dragons
+
     //Sartharion Spells
     SPELL_BERSERK                               = 61632,    // Increases the caster's attack speed by 150% and all damage it deals by 500% for 5 min.
     SPELL_CLEAVE                                = 56909,    // Inflicts 35% weapon damage to an enemy and its nearest allies, affecting up to 10 targets.
@@ -53,74 +59,92 @@ enum eEnums
     SPELL_WILL_OF_SARTHARION                    = 61254,    // Sartharion's presence bolsters the resolve of the Twilight Drakes, increasing their total health by 25%. This effect also increases Sartharion's health by 25%.
     SPELL_LAVA_STRIKE                           = 57571,    // (Real spell casted should be 57578) 57571 then trigger visual missile, then summon Lava Blaze on impact(spell 57572)
     SPELL_TWILIGHT_REVENGE                      = 60639,
+
     SPELL_PYROBUFFET                            = 56916,    // currently used for hard enrage after 15 minutes
     SPELL_PYROBUFFET_RANGE                      = 58907,    // possibly used when player get too far away from dummy creatures (2x Creature entry 30494)
+
     SPELL_TWILIGHT_SHIFT_ENTER                  = 57620,    // enter phase. Player get this when click GO
     SPELL_TWILIGHT_SHIFT_REMOVAL                = 61187,    // leave phase
     SPELL_TWILIGHT_SHIFT_REMOVAL_ALL            = 61190,    // leave phase (probably version to make all leave)
+
     //Mini bosses common spells
     SPELL_TWILIGHT_RESIDUE                      = 61885,    // makes immune to shadow damage, applied when leave phase
+
     //Miniboses (Vesperon, Shadron, Tenebron)
     SPELL_SHADOW_BREATH_H                       = 59126,    // Inflicts 8788 to 10212 Fire damage to enemies in a cone in front of the caster.
     SPELL_SHADOW_BREATH                         = 57570,    // Inflicts 6938 to 8062 Fire damage to enemies in a cone in front of the caster.
+
     SPELL_SHADOW_FISSURE_H                      = 59127,    // Deals 9488 to 13512 Shadow damage to any enemy within the Shadow fissure after 5 sec.
     SPELL_SHADOW_FISSURE                        = 57579,    // Deals 6188 to 8812 Shadow damage to any enemy within the Shadow fissure after 5 sec.
+
     //Vesperon
     //In portal is a disciple, when disciple killed remove Power_of_vesperon, portal open multiple times
     NPC_ACOLYTE_OF_VESPERON                     = 31219,    // Acolyte of Vesperon
     SPELL_POWER_OF_VESPERON                     = 61251,    // Vesperon's presence decreases the maximum health of all enemies by 25%.
     SPELL_TWILIGHT_TORMENT_VESP                 = 57948,    // (Shadow only) trigger 57935 then 57988
     SPELL_TWILIGHT_TORMENT_VESP_ACO             = 58853,    // (Fire and Shadow) trigger 58835 then 57988
+
     //Shadron
     //In portal is a disciple, when disciple killed remove Power_of_vesperon, portal open multiple times
     NPC_ACOLYTE_OF_SHADRON                      = 31218,    // Acolyte of Shadron
     SPELL_POWER_OF_SHADRON                      = 58105,    // Shadron's presence increases Fire damage taken by all enemies by 100%.
     SPELL_GIFT_OF_TWILIGTH_SHA                  = 57835,    // TARGET_SCRIPT shadron
     SPELL_GIFT_OF_TWILIGTH_SAR                  = 58766,    // TARGET_SCRIPT sartharion
+
     //Tenebron
     //in the portal spawns 6 eggs, if not killed in time (approx. 20s)  they will hatch,  whelps can cast 60708
     SPELL_POWER_OF_TENEBRON                     = 61248,    // Tenebron's presence increases Shadow damage taken by all enemies by 100%.
     //Tenebron, dummy spell
     SPELL_SUMMON_TWILIGHT_WHELP                 = 58035,    // doesn't work, will spawn NPC_TWILIGHT_WHELP
     SPELL_SUMMON_SARTHARION_TWILIGHT_WHELP      = 58826,    // doesn't work, will spawn NPC_SHARTHARION_TWILIGHT_WHELP
+
     SPELL_HATCH_EGGS_H                          = 59189,
     SPELL_HATCH_EGGS                            = 58542,
     SPELL_HATCH_EGGS_EFFECT_H                   = 59190,
     SPELL_HATCH_EGGS_EFFECT                     = 58685,
+
     //Whelps
     NPC_TWILIGHT_WHELP                          = 30890,
     NPC_SHARTHARION_TWILIGHT_WHELP              = 31214,
     SPELL_FADE_ARMOR                            = 60708,    // Reduces the armor of an enemy by 1500 for 15s
+
     //flame tsunami
     SPELL_FLAME_TSUNAMI                         = 57494,    // the visual dummy
     SPELL_FLAME_TSUNAMI_LEAP                    = 60241,    // SPELL_EFFECT_138 some leap effect, causing caster to move in direction
     SPELL_FLAME_TSUNAMI_DMG_AURA                = 57492,    // periodic damage, npc has this aura
+
     NPC_FLAME_TSUNAMI                           = 30616,    // for the flame waves
     NPC_LAVA_BLAZE                              = 30643,    // adds spawning from flame strike
+
     //using these custom points for dragons start and end
     POINT_ID_INIT                               = 100,
     POINT_ID_LAND                               = 200
 };
+
 struct Waypoint
 {
     float m_fX, m_fY, m_fZ;
 };
+
 //each dragons special points. First where fly to before connect to connon, second where land point is.
 Waypoint m_aTene[]=
 {
     {3212.854, 575.597, 109.856},                           //init
     {3246.425, 565.367, 61.249}                             //end
 };
+
 Waypoint m_aShad[]=
 {
     {3293.238, 472.223, 106.968},
     {3271.669, 526.907, 61.931}
 };
+
 Waypoint m_aVesp[]=
 {
     {3193.310, 472.861, 102.697},
     {3227.268, 533.238, 59.995}
 };
+
 #define MAX_WAYPOINT 6
 //points around raid "isle", counter clockwise. should probably be adjusted to be more alike
 Waypoint m_aDragonCommon[MAX_WAYPOINT]=
@@ -132,9 +156,11 @@ Waypoint m_aDragonCommon[MAX_WAYPOINT]=
     {3250.479, 585.827, 98.652},
     {3209.969, 566.523, 98.652}
 };
+
 /*######
 ## Boss Sartharion
 ######*/
+
 struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
 {
     boss_sartharionAI(Creature* pCreature) : ScriptedAI(pCreature)
@@ -142,111 +168,143 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         m_pInstance = pCreature->GetInstanceData();
         m_bIsHeroic = pCreature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* m_pInstance;
     bool m_bIsHeroic;
+
     bool m_bIsBerserk;
     bool m_bIsSoftEnraged;
+
     uint32 m_uiEnrageTimer;
     bool m_bIsHardEnraged;
+
     uint32 m_uiTenebronTimer;
     uint32 m_uiShadronTimer;
     uint32 m_uiVesperonTimer;
+
     uint32 m_uiFlameTsunamiTimer;
     uint32 m_uiFlameBreathTimer;
     uint32 m_uiTailSweepTimer;
     uint32 m_uiCleaveTimer;
     uint32 m_uiLavaStrikeTimer;
+
     bool m_bHasCalledTenebron;
     bool m_bHasCalledShadron;
     bool m_bHasCalledVesperon;
+
     void Reset()
     {
         m_bIsBerserk = false;
         m_bIsSoftEnraged = false;
+
         m_uiEnrageTimer = 15*MINUTE*IN_MILISECONDS;
         m_bIsHardEnraged = false;
+
         m_uiTenebronTimer = 30000;
         m_uiShadronTimer = 75000;
         m_uiVesperonTimer = 120000;
+
         m_uiFlameTsunamiTimer = 30000;
         m_uiFlameBreathTimer = 20000;
         m_uiTailSweepTimer = 20000;
         m_uiCleaveTimer = 7000;
         m_uiLavaStrikeTimer = 5000;
+
         m_bHasCalledTenebron = false;
         m_bHasCalledShadron = false;
         m_bHasCalledVesperon = false;
+
         if (m_creature->HasAura(SPELL_TWILIGHT_REVENGE))
             m_creature->RemoveAurasDueToSpell(SPELL_TWILIGHT_REVENGE);
     }
+
     void JustReachedHome()
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_SARTHARION_EVENT, NOT_STARTED);
     }
+
     void Aggro(Unit* pWho)
     {
         DoScriptText(SAY_SARTHARION_AGGRO,m_creature);
         DoZoneInCombat();
+
         if (m_pInstance)
         {
             m_pInstance->SetData(TYPE_SARTHARION_EVENT, IN_PROGRESS);
             FetchDragons();
         }
     }
+
     void JustDied(Unit* pKiller)
     {
         DoScriptText(SAY_SARTHARION_DEATH,m_creature);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_SARTHARION_EVENT, DONE);
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(RAND(SAY_SARTHARION_SLAY_1,SAY_SARTHARION_SLAY_2,SAY_SARTHARION_SLAY_3), m_creature);
     }
+
     void FetchDragons()
     {
         Unit* pTene = Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_TENEBRON));
         Unit* pShad = Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_SHADRON));
         Unit* pVesp = Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_VESPERON));
+
         //if at least one of the dragons are alive and are being called
         bool bCanUseWill = false;
+
         if (pTene && pTene->isAlive() && !pTene->getVictim())
         {
             bCanUseWill = true;
             pTene->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aTene[0].m_fX, m_aTene[0].m_fY, m_aTene[0].m_fZ);
+
             if (!pTene->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
                 pTene->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         }
+
         if (pShad && pShad->isAlive() && !pShad->getVictim())
         {
             bCanUseWill = true;
             pShad->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aShad[0].m_fX, m_aShad[0].m_fY, m_aShad[0].m_fZ);
+
             if (!pShad->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
                 pShad->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         }
+
         if (pVesp && pVesp->isAlive() && !pVesp->getVictim())
         {
             bCanUseWill = true;
             pVesp->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aVesp[0].m_fX, m_aVesp[0].m_fY, m_aVesp[0].m_fZ);
+
             if (!pVesp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
                 pVesp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         }
+
         if (bCanUseWill)
             DoCast(m_creature, SPELL_WILL_OF_SARTHARION);
     }
+
     void CallDragon(uint32 uiDataId)
     {
         if (m_pInstance)
         {
             Creature* pTemp = Unit::GetCreature((*m_creature),m_pInstance->GetData64(uiDataId));
+
             if (pTemp && pTemp->isAlive() && !pTemp->getVictim())
             {
                 if (pTemp->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
                     pTemp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+
                 if (pTemp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
                     pTemp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
                 int32 iTextId = 0;
+
                 switch(pTemp->GetEntry())
                 {
                     case NPC_TENEBRON:
@@ -262,16 +320,20 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
                         pTemp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aVesp[1].m_fX, m_aVesp[1].m_fY, m_aVesp[1].m_fZ);
                         break;
                 }
+
                 DoScriptText(iTextId, m_creature);
             }
         }
     }
+
     void SendFlameTsunami()
     {
         Map* pMap = m_creature->GetMap();
+
         if (pMap && pMap->IsDungeon())
         {
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
+
             if (!PlayerList.isEmpty())
             {
                 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
@@ -282,14 +344,17 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         Unit* pTene = Unit::GetUnit(*m_creature, m_pInstance ? m_pInstance->GetData64(DATA_TENEBRON) : 0);
         Unit* pShad = Unit::GetUnit(*m_creature, m_pInstance ? m_pInstance->GetData64(DATA_SHADRON) : 0);
         Unit* pVesp = Unit::GetUnit(*m_creature, m_pInstance ? m_pInstance->GetData64(DATA_VESPERON) : 0);
+
         //spell will target dragons, if they are still alive at 35%
         if (!m_bIsBerserk && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 35
             && ((pTene && pTene->isAlive()) || (pShad && pShad->isAlive()) || (pVesp && pVesp->isAlive())))
@@ -298,12 +363,14 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
             DoCast(m_creature, SPELL_BERSERK);
             m_bIsBerserk = true;
         }
+
         //soft enrage
         if (!m_bIsSoftEnraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 10)
         {
             // TODO
             m_bIsSoftEnraged = true;
         }
+
         // hard enrage
         if (!m_bIsHardEnraged)
         {
@@ -315,6 +382,7 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
             else
                 m_uiEnrageTimer -= uiDiff;
         }
+
         // flame tsunami
         if (m_uiFlameTsunamiTimer < uiDiff)
         {
@@ -323,6 +391,7 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         }
         else
             m_uiFlameTsunamiTimer -= uiDiff;
+
         // flame breath
         if (m_uiFlameBreathTimer < uiDiff)
         {
@@ -332,6 +401,7 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         }
         else
             m_uiFlameBreathTimer -= uiDiff;
+
         // Tail Sweep
         if (m_uiTailSweepTimer < uiDiff)
         {
@@ -340,6 +410,7 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         }
         else
             m_uiTailSweepTimer -= uiDiff;
+
         // Cleave
         if (m_uiCleaveTimer < uiDiff)
         {
@@ -348,12 +419,14 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         }
         else
             m_uiCleaveTimer -= uiDiff;
+
         // Lavas Strike
         if (m_uiLavaStrikeTimer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
             {
                 DoCast(pTarget, SPELL_LAVA_STRIKE);
+
                 if(urand(0,4) == 4)
                     DoScriptText(RAND(SAY_SARTHARION_SPECIAL_1,SAY_SARTHARION_SPECIAL_2,SAY_SARTHARION_SPECIAL_3), m_creature);
             }
@@ -361,6 +434,7 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         }
         else
             m_uiLavaStrikeTimer -= uiDiff;
+
         // call tenebron
         if (!m_bHasCalledTenebron && m_uiTenebronTimer < uiDiff)
         {
@@ -369,6 +443,7 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         }
         else
             m_uiTenebronTimer -= uiDiff;
+
         // call shadron
         if (!m_bHasCalledShadron && m_uiShadronTimer < uiDiff)
         {
@@ -377,6 +452,7 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         }
         else
             m_uiShadronTimer -= uiDiff;
+
         // call vesperon
         if (!m_bHasCalledVesperon && m_uiVesperonTimer < uiDiff)
         {
@@ -385,14 +461,18 @@ struct TRINITY_DLL_DECL boss_sartharionAI : public ScriptedAI
         }
         else
             m_uiVesperonTimer -= uiDiff;
+
         DoMeleeAttackIfReady();
+
         EnterEvadeIfOutOfCombatArea(uiDiff);
     }
 };
+
 CreatureAI* GetAI_boss_sartharion(Creature* pCreature)
 {
     return new boss_sartharionAI(pCreature);
 }
+
 enum TeneText
 {
     SAY_TENEBRON_AGGRO                      = -1615009,
@@ -404,6 +484,7 @@ enum TeneText
     SAY_TENEBRON_SPECIAL_1                  = -1615015,
     SAY_TENEBRON_SPECIAL_2                  = -1615016
 };
+
 enum ShadText
 {
     SAY_SHADRON_AGGRO                       = -1615000,
@@ -415,6 +496,7 @@ enum ShadText
     SAY_SHADRON_SPECIAL_1                   = -1615006,
     SAY_SHADRON_SPECIAL_2                   = -1615007
 };
+
 enum VespText
 {
     SAY_VESPERON_AGGRO                      = -1615033,
@@ -426,6 +508,7 @@ enum VespText
     SAY_VESPERON_SPECIAL_1                  = -1615039,
     SAY_VESPERON_SPECIAL_2                  = -1615040
 };
+
 //to control each dragons common abilities
 struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
 {
@@ -434,32 +517,40 @@ struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
         m_pInstance = pCreature->GetInstanceData();
         m_bIsHeroic = pCreature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* m_pInstance;
     bool m_bIsHeroic;
+
     uint32 m_uiWaypointId;
     uint32 m_uiMoveNextTimer;
     int32 m_iPortalRespawnTime;
     bool m_bCanMoveFree;
+
     void Reset()
     {
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
         m_uiWaypointId = 0;
         m_uiMoveNextTimer = 500;
         m_iPortalRespawnTime = 30000;
         m_bCanMoveFree = false;
     }
+
     void MovementInform(uint32 uiType, uint32 uiPointId)
     {
         if (!m_pInstance || uiType != POINT_MOTION_TYPE)
             return;
+
         debug_log("dummy_dragonAI: %s reached point %u", m_creature->GetName(), uiPointId);
+
         //if healers messed up the raid and we was already initialized
         if (m_pInstance->GetData(TYPE_SARTHARION_EVENT) != IN_PROGRESS)
         {
             EnterEvadeMode();
             return;
         }
+
         //this is end, if we reach this, don't do much
         if (uiPointId == POINT_ID_LAND)
         {
@@ -467,26 +558,34 @@ struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
             m_bCanMoveFree = false;
             return;
         }
+
         //get amount of common points
         uint32 uiCommonWPCount = sizeof(m_aDragonCommon)/sizeof(Waypoint);
+
         //increase
         m_uiWaypointId = uiPointId+1;
+
         //if we have reached a point bigger or equal to count, it mean we must reset to point 0
         if (m_uiWaypointId >= uiCommonWPCount)
         {
             if (!m_bCanMoveFree)
                 m_bCanMoveFree = true;
+
             m_uiWaypointId = 0;
         }
+
         m_uiMoveNextTimer = 500;
     }
+
     //used when open portal and spawn mobs in phase
     void DoRaidWhisper(int32 iTextId)
     {
         Map* pMap = m_creature->GetMap();
+
         if (pMap && pMap->IsDungeon())
         {
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
+
             if (!PlayerList.isEmpty())
             {
                 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
@@ -494,14 +593,18 @@ struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
             }
         }
     }
+
     //"opens" the portal and does the "opening" whisper
     void OpenPortal()
     {
         int32 iTextId = 0;
+
         //there are 4 portal spawn locations, each are expected to be spawned with negative spawntimesecs in database
+
         //using a grid search here seem to be more efficient than caching all four guids
         //in instance script and calculate range to each.
         GameObject* pPortal = m_creature->FindNearestGameObject(GO_TWILIGHT_PORTAL,50.0f);
+
         switch(m_creature->GetEntry())
         {
             case NPC_TENEBRON:
@@ -512,23 +615,30 @@ struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
                 iTextId = WHISPER_OPEN_PORTAL;
                 break;
         }
+
         DoRaidWhisper(iTextId);
+
         //By using SetRespawnTime() we will actually "spawn" the object with our defined time.
         //Once time is up, portal will disappear again.
         if (pPortal && !pPortal->isSpawned())
             pPortal->SetRespawnTime(m_iPortalRespawnTime);
+
         //Unclear what are expected to happen if one drake has a portal open already
         //Refresh respawnTime so time again are set to 30secs?
     }
+
     //Removes each drakes unique debuff from players
     void RemoveDebuff(uint32 uiSpellId)
     {
         Map* pMap = m_creature->GetMap();
+
         if (pMap && pMap->IsDungeon())
         {
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
+
             if (PlayerList.isEmpty())
                 return;
+
             for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
             {
                 if (i->getSource()->isAlive() && i->getSource()->HasAura(uiSpellId))
@@ -536,10 +646,12 @@ struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
             }
         }
     }
+
     void JustDied(Unit* pKiller)
     {
         int32 iTextId = 0;
         uint32 uiSpellId = 0;
+
         switch(m_creature->GetEntry())
         {
             case NPC_TENEBRON:
@@ -555,19 +667,24 @@ struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
                 uiSpellId = SPELL_POWER_OF_VESPERON;
                 break;
         }
+
         DoScriptText(iTextId, m_creature);
+
         RemoveDebuff(uiSpellId);
+
         if (m_pInstance)
         {
             // not if solo mini-boss fight
             if (m_pInstance->GetData(TYPE_SARTHARION_EVENT) != IN_PROGRESS)
                 return;
+
             // Twilight Revenge to main boss
             if (Unit* pSartharion = Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_SARTHARION)))
                 if (pSartharion->isAlive())
                     m_creature->CastSpell(pSartharion,SPELL_TWILIGHT_REVENGE,true);
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (m_bCanMoveFree && m_uiMoveNextTimer)
@@ -577,6 +694,7 @@ struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
                 if(m_uiWaypointId < MAX_WAYPOINT)
                     m_creature->GetMotionMaster()->MovePoint(m_uiWaypointId,
                         m_aDragonCommon[m_uiWaypointId].m_fX, m_aDragonCommon[m_uiWaypointId].m_fY, m_aDragonCommon[m_uiWaypointId].m_fZ);
+
                 debug_log("dummy_dragonAI: %s moving to point %u", m_creature->GetName(), m_uiWaypointId);
                 m_uiMoveNextTimer = 0;
             }
@@ -585,31 +703,38 @@ struct TRINITY_DLL_DECL dummy_dragonAI : public ScriptedAI
         }
     }
 };
+
 /*######
 ## Mob Tenebron
 ######*/
+
 struct TRINITY_DLL_DECL mob_tenebronAI : public dummy_dragonAI
 {
     mob_tenebronAI(Creature* pCreature) : dummy_dragonAI(pCreature) { }
+
     uint32 m_uiShadowBreathTimer;
     uint32 m_uiShadowFissureTimer;
     uint32 m_uiHatchEggTimer;
+
     void Reset()
     {
         m_uiShadowBreathTimer = 20000;
         m_uiShadowFissureTimer = 5000;
         m_uiHatchEggTimer = 30000;
     }
+
     void Aggro(Unit* pWho)
     {
         DoScriptText(SAY_TENEBRON_AGGRO, m_creature);
         DoZoneInCombat();
         DoCast(m_creature, SPELL_POWER_OF_TENEBRON);
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(RAND(SAY_TENEBRON_SLAY_1,SAY_TENEBRON_SLAY_2), m_creature);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //if no target, update dummy and return
@@ -618,15 +743,18 @@ struct TRINITY_DLL_DECL mob_tenebronAI : public dummy_dragonAI
             dummy_dragonAI::UpdateAI(uiDiff);
             return;
         }
+
         // shadow fissure
         if (m_uiShadowFissureTimer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, m_bIsHeroic ? SPELL_SHADOW_FISSURE_H : SPELL_SHADOW_FISSURE);
+
             m_uiShadowFissureTimer = urand(15000,20000);
         }
         else
             m_uiShadowFissureTimer -= uiDiff;
+
         // shadow breath
         if (m_uiShadowBreathTimer < uiDiff)
         {
@@ -636,42 +764,53 @@ struct TRINITY_DLL_DECL mob_tenebronAI : public dummy_dragonAI
         }
         else
             m_uiShadowBreathTimer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_tenebron(Creature* pCreature)
 {
     return new mob_tenebronAI(pCreature);
 }
+
 /*######
 ## Mob Shadron
 ######*/
+
 struct TRINITY_DLL_DECL mob_shadronAI : public dummy_dragonAI
 {
     mob_shadronAI(Creature* pCreature) : dummy_dragonAI(pCreature) { }
+
     uint32 m_uiShadowBreathTimer;
     uint32 m_uiShadowFissureTimer;
     uint32 m_uiAcolyteShadronTimer;
+
     void Reset()
     {
         m_uiShadowBreathTimer = 20000;
         m_uiShadowFissureTimer = 5000;
         m_uiAcolyteShadronTimer = 60000;
+
         if (m_creature->HasAura(SPELL_TWILIGHT_TORMENT_VESP))
             m_creature->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP);
+
         if (m_creature->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA))
             m_creature->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SHA);
     }
+
     void Aggro(Unit* pWho)
     {
         DoScriptText(SAY_SHADRON_AGGRO,m_creature);
         DoZoneInCombat();
         DoCast(m_creature, SPELL_POWER_OF_SHADRON);
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(RAND(SAY_SHADRON_SLAY_1,SAY_SHADRON_SLAY_2), m_creature);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //if no target, update dummy and return
@@ -680,15 +819,18 @@ struct TRINITY_DLL_DECL mob_shadronAI : public dummy_dragonAI
             dummy_dragonAI::UpdateAI(uiDiff);
             return;
         }
+
         // shadow fissure
         if (m_uiShadowFissureTimer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, m_bIsHeroic ? SPELL_SHADOW_FISSURE_H : SPELL_SHADOW_FISSURE);
+
             m_uiShadowFissureTimer = urand(15000,20000);
         }
         else
             m_uiShadowFissureTimer -= uiDiff;
+
         // shadow breath
         if (m_uiShadowBreathTimer < uiDiff)
         {
@@ -698,38 +840,47 @@ struct TRINITY_DLL_DECL mob_shadronAI : public dummy_dragonAI
         }
         else
             m_uiShadowBreathTimer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_shadron(Creature* pCreature)
 {
     return new mob_shadronAI(pCreature);
 }
+
 /*######
 ## Mob Vesperon
 ######*/
+
 struct TRINITY_DLL_DECL mob_vesperonAI : public dummy_dragonAI
 {
     mob_vesperonAI(Creature* pCreature) : dummy_dragonAI(pCreature) { }
+
     uint32 m_uiShadowBreathTimer;
     uint32 m_uiShadowFissureTimer;
     uint32 m_uiAcolyteVesperonTimer;
+
     void Reset()
     {
         m_uiShadowBreathTimer = 20000;
         m_uiShadowFissureTimer = 5000;
         m_uiAcolyteVesperonTimer = 60000;
     }
+
     void Aggro(Unit* pWho)
     {
         DoScriptText(SAY_VESPERON_AGGRO,m_creature);
         DoZoneInCombat();
         DoCast(m_creature, SPELL_POWER_OF_VESPERON);
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(RAND(SAY_VESPERON_SLAY_1,SAY_VESPERON_SLAY_2), m_creature);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //if no target, update dummy and return
@@ -738,15 +889,18 @@ struct TRINITY_DLL_DECL mob_vesperonAI : public dummy_dragonAI
             dummy_dragonAI::UpdateAI(uiDiff);
             return;
         }
+
         // shadow fissure
         if (m_uiShadowFissureTimer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, m_bIsHeroic ? SPELL_SHADOW_FISSURE_H : SPELL_SHADOW_FISSURE);
+
             m_uiShadowFissureTimer = urand(15000,20000);
         }
         else
             m_uiShadowFissureTimer -= uiDiff;
+
         // shadow breath
         if (m_uiShadowBreathTimer < uiDiff)
         {
@@ -756,23 +910,29 @@ struct TRINITY_DLL_DECL mob_vesperonAI : public dummy_dragonAI
         }
         else
             m_uiShadowBreathTimer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_vesperon(Creature* pCreature)
 {
     return new mob_vesperonAI(pCreature);
 }
+
 /*######
 ## Mob Acolyte of Shadron
 ######*/
+
 struct TRINITY_DLL_DECL mob_acolyte_of_shadronAI : public ScriptedAI
 {
     mob_acolyte_of_shadronAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     void Reset()
     {
         if (m_pInstance)
@@ -784,15 +944,18 @@ struct TRINITY_DLL_DECL mob_acolyte_of_shadronAI : public ScriptedAI
                 DoCast(m_creature, SPELL_GIFT_OF_TWILIGTH_SHA);
         }
     }
+
     void JustDied(Unit* killer)
     {
         if (m_pInstance)
         {
             Creature* pDebuffTarget = NULL;
+
             if (m_pInstance->GetData(TYPE_SARTHARION_EVENT) == IN_PROGRESS)
             {
                 //not solo fight, so main boss has deduff
                 pDebuffTarget = m_pInstance->instance->GetCreature(m_pInstance->GetData64(DATA_SARTHARION));
+
                 if (pDebuffTarget && pDebuffTarget->isAlive() && pDebuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SAR))
                     pDebuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SAR);
             }
@@ -800,91 +963,116 @@ struct TRINITY_DLL_DECL mob_acolyte_of_shadronAI : public ScriptedAI
             {
                 //event not in progress, then solo fight and must remove debuff mini-boss
                 pDebuffTarget = m_pInstance->instance->GetCreature(m_pInstance->GetData64(DATA_SHADRON));
+
                 if (pDebuffTarget && pDebuffTarget->isAlive() && pDebuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA))
                     pDebuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SHA);
             }
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_acolyte_of_shadron(Creature* pCreature)
 {
     return new mob_acolyte_of_shadronAI(pCreature);
 }
+
 /*######
 ## Mob Acolyte of Vesperon
 ######*/
+
 struct TRINITY_DLL_DECL mob_acolyte_of_vesperonAI : public ScriptedAI
 {
     mob_acolyte_of_vesperonAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     void Reset()
     {
         DoCast(m_creature, SPELL_TWILIGHT_TORMENT_VESP_ACO);
     }
+
     void JustDied(Unit* pKiller)
     {
         // remove twilight torment on Vesperon
         if (m_pInstance)
         {
             Creature* pVesperon = m_pInstance->instance->GetCreature(m_pInstance->GetData64(DATA_VESPERON));
+
             if (pVesperon && pVesperon->isAlive() && pVesperon->HasAura(SPELL_TWILIGHT_TORMENT_VESP))
                 pVesperon->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP);
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_acolyte_of_vesperon(Creature* pCreature)
 {
     return new mob_acolyte_of_vesperonAI(pCreature);
 }
+
 /*######
 ## Mob Twilight Eggs
 ######*/
+
 struct TRINITY_DLL_DECL mob_twilight_eggsAI : public ScriptedAI
 {
     mob_twilight_eggsAI(Creature* pCreature) : ScriptedAI(pCreature) { }
+
     uint32 m_uiFadeArmorTimer;
+
     void Reset()
     {
         m_uiFadeArmorTimer = 1000;
     }
+
     void AttackStart(Unit* pWho) { }
     void MoveInLineOfSight(Unit* pWho) { }
 };
+
 CreatureAI* GetAI_mob_twilight_eggs(Creature* pCreature)
 {
     return new mob_twilight_eggsAI(pCreature);
 }
+
 /*######
 ## Mob Twilight Whelps
 ######*/
+
 struct TRINITY_DLL_DECL mob_twilight_whelpAI : public ScriptedAI
 {
     mob_twilight_whelpAI(Creature* pCreature) : ScriptedAI(pCreature) { }
+
     uint32 m_uiFadeArmorTimer;
+
     void Reset()
     {
         m_uiFadeArmorTimer = 1000;
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         // twilight torment
         if (m_uiFadeArmorTimer < uiDiff)
         {
@@ -893,44 +1081,55 @@ struct TRINITY_DLL_DECL mob_twilight_whelpAI : public ScriptedAI
         }
         else
             m_uiFadeArmorTimer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_twilight_whelp(Creature* pCreature)
 {
     return new mob_twilight_whelpAI(pCreature);
 }
+
 void AddSC_boss_sartharion()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_sartharion";
     newscript->GetAI = &GetAI_boss_sartharion;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_vesperon";
     newscript->GetAI = &GetAI_mob_vesperon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_shadron";
     newscript->GetAI = &GetAI_mob_shadron;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_tenebron";
     newscript->GetAI = &GetAI_mob_tenebron;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_acolyte_of_shadron";
     newscript->GetAI = &GetAI_mob_acolyte_of_shadron;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_acolyte_of_vesperon";
     newscript->GetAI = &GetAI_mob_acolyte_of_vesperon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_twilight_eggs";
     newscript->GetAI = &GetAI_mob_twilight_eggs;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_twilight_whelp";
     newscript->GetAI = &GetAI_mob_twilight_whelp;
diff --git a/src/bindings/scripts/scripts/northrend/obsidian_sanctum/def_obsidian_sanctum.h b/src/bindings/scripts/scripts/northrend/obsidian_sanctum/def_obsidian_sanctum.h
index 053ca56c8cb..59013174795 100644
--- a/src/bindings/scripts/scripts/northrend/obsidian_sanctum/def_obsidian_sanctum.h
+++ b/src/bindings/scripts/scripts/northrend/obsidian_sanctum/def_obsidian_sanctum.h
@@ -1,16 +1,20 @@
 #ifndef DEF_OBSIDIAN_SANCTUM_H
 #define DEF_OBSIDIAN_SANCTUM_H
+
 enum eTypes
 {
     TYPE_SARTHARION_EVENT       = 1,
+
     DATA_SARTHARION             = 10,
     DATA_TENEBRON               = 11,
     DATA_SHADRON                = 12,
     DATA_VESPERON               = 13,
+
     NPC_SARTHARION              = 28860,
     NPC_TENEBRON                = 30452,
     NPC_SHADRON                 = 30451,
     NPC_VESPERON                = 30449,
     GO_TWILIGHT_PORTAL          = 193988
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/obsidian_sanctum/instance_obsidian_sanctum.cpp b/src/bindings/scripts/scripts/northrend/obsidian_sanctum/instance_obsidian_sanctum.cpp
index 95ec22db002..5dd3e06e585 100644
--- a/src/bindings/scripts/scripts/northrend/obsidian_sanctum/instance_obsidian_sanctum.cpp
+++ b/src/bindings/scripts/scripts/northrend/obsidian_sanctum/instance_obsidian_sanctum.cpp
@@ -1,25 +1,32 @@
 #include "precompiled.h"
 #include "def_obsidian_sanctum.h"
+
 #define MAX_ENCOUNTER     1
+
 /* Obsidian Sanctum encounters:
 0 - Sartharion
 */
+
 struct TRINITY_DLL_DECL instance_obsidian_sanctum : public ScriptedInstance
 {
     instance_obsidian_sanctum(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     uint64 m_uiSartharionGUID;
     uint64 m_uiTenebronGUID;
     uint64 m_uiShadronGUID;
     uint64 m_uiVesperonGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         m_uiSartharionGUID = 0;
         m_uiTenebronGUID   = 0;
         m_uiShadronGUID    = 0;
         m_uiVesperonGUID   = 0;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -43,17 +50,21 @@ struct TRINITY_DLL_DECL instance_obsidian_sanctum : public ScriptedInstance
                 break;
         }
     }
+
     void SetData(uint32 uiType, uint32 uiData)
     {
         if (uiType == TYPE_SARTHARION_EVENT)
             m_auiEncounter[0] = uiData;
     }
+
     uint32 GetData(uint32 uiType)
     {
         if (uiType == TYPE_SARTHARION_EVENT)
             return m_auiEncounter[0];
+
         return 0;
     }
+
     uint64 GetData64(uint32 uiData)
     {
         switch(uiData)
@@ -70,10 +81,12 @@ struct TRINITY_DLL_DECL instance_obsidian_sanctum : public ScriptedInstance
         return 0;
     }
 };
+
 InstanceData* GetInstanceData_instance_obsidian_sanctum(Map* pMap)
 {
     return new instance_obsidian_sanctum(pMap);
 }
+
 void AddSC_instance_obsidian_sanctum()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/sholazar_basin.cpp b/src/bindings/scripts/scripts/northrend/sholazar_basin.cpp
index c715f2e4a11..0a4421683a3 100644
--- a/src/bindings/scripts/scripts/northrend/sholazar_basin.cpp
+++ b/src/bindings/scripts/scripts/northrend/sholazar_basin.cpp
@@ -14,36 +14,46 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Sholazar_Basin
 SD%Complete: 100
 SDComment: Quest support: 12570, 12573, 12621.
 SDCategory: Sholazar_Basin
 EndScriptData */
+
 /* ContentData
 npc_injured_rainspeaker_oracle
 npc_vekjik
 avatar_of_freya
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_injured_rainspeaker_oracle
 ######*/
+
 #define GOSSIP_ITEM1 "I am ready to travel to your village now."
+
 enum eRainspeaker
 {
     SAY_START_IRO                       = -1571000,
     SAY_QUEST_ACCEPT_IRO                = -1571001,
     SAY_END_IRO                         = -1571002,
+
     QUEST_FORTUNATE_MISUNDERSTANDINGS   = 12570,
     FACTION_ESCORTEE_A                  = 774,
     FACTION_ESCORTEE_H                  = 775
 };
+
 struct TRINITY_DLL_DECL npc_injured_rainspeaker_oracleAI : public npc_escortAI
 {
     npc_injured_rainspeaker_oracleAI(Creature* c) : npc_escortAI(c) { c_guid = c->GetGUID(); }
+
     uint64 c_guid;
+
     void Reset()
     {
         me->RestoreFaction();
@@ -54,11 +64,14 @@ struct TRINITY_DLL_DECL npc_injured_rainspeaker_oracleAI : public npc_escortAI
             me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
         }
     }
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
         case 1: SetRun(); break;
@@ -88,10 +101,12 @@ struct TRINITY_DLL_DECL npc_injured_rainspeaker_oracleAI : public npc_escortAI
             break;
         }
     }
+
     void JustDied(Unit* killer)
     {
         if (!HasEscortState(STATE_ESCORT_ESCORTING))
             return;
+
         if (Player* pPlayer = GetPlayerForEscort())
         {
           if (pPlayer->GetQuestStatus(QUEST_FORTUNATE_MISUNDERSTANDINGS) != QUEST_STATUS_COMPLETE)
@@ -100,15 +115,20 @@ struct TRINITY_DLL_DECL npc_injured_rainspeaker_oracleAI : public npc_escortAI
     }
 };
 
+
 bool GossipHello_npc_injured_rainspeaker_oracle(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_FORTUNATE_MISUNDERSTANDINGS) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_injured_rainspeaker_oracle(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -117,6 +137,7 @@ bool GossipSelect_npc_injured_rainspeaker_oracle(Player* pPlayer, Creature* pCre
         CAST_AI(npc_escortAI, (pCreature->AI()))->SetMaxPlayerDistance(35.0f);
         pCreature->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING);
         DoScriptText(SAY_START_IRO, pCreature);
+
         switch (pPlayer->GetTeam()){
         case ALLIANCE:
             pCreature->setFaction(FACTION_ESCORTEE_A);
@@ -128,41 +149,53 @@ bool GossipSelect_npc_injured_rainspeaker_oracle(Player* pPlayer, Creature* pCre
     }
     return true;
 }
+
 bool QuestAccept_npc_injured_rainspeaker_oracle(Player* pPlayer, Creature* pCreature, Quest const *_Quest)
 {
     DoScriptText(SAY_QUEST_ACCEPT_IRO, pCreature);
     return false;
 }
+
 CreatureAI* GetAI_npc_injured_rainspeaker_oracle(Creature* pCreature)
 {
     return new npc_injured_rainspeaker_oracleAI(pCreature);
 }
+
 /*######
 ## npc_vekjik
 ######*/
+
 #define GOSSIP_VEKJIK_ITEM1 "Shaman Vekjik, I have spoken with the big-tongues and they desire peace. I have brought this offering on their behalf."
 #define GOSSIP_VEKJIK_ITEM2 "No no... I had no intentions of betraying your people. I was only defending myself. it was all a misunderstanding."
+
 enum eVekjik
 {
     GOSSIP_TEXTID_VEKJIK1       = 13137,
     GOSSIP_TEXTID_VEKJIK2       = 13138,
+
     SAY_TEXTID_VEKJIK1          = -1000208,
+
     SPELL_FREANZYHEARTS_FURY    = 51469,
+
     QUEST_MAKING_PEACE          = 12573
 };
+
 bool GossipHello_npc_vekjik(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_MAKING_PEACE) == QUEST_STATUS_INCOMPLETE)
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_VEKJIK_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_VEKJIK1, pCreature->GetGUID());
         return true;
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_vekjik(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -178,33 +211,43 @@ bool GossipSelect_npc_vekjik(Player* pPlayer, Creature* pCreature, uint32 uiSend
             pCreature->CastSpell(pPlayer, SPELL_FREANZYHEARTS_FURY, false);
             break;
     }
+
     return true;
 }
 
+
 /*######
 ## avatar_of_freya
 ######*/
+
 #define GOSSIP_ITEM_AOF1 "I want to stop the Scourge as much as you do. How can I help?"
 #define GOSSIP_ITEM_AOF2 "You can trust me. I am no friend of the Lich King."
 #define GOSSIP_ITEM_AOF3 "I will not fail."
+
 enum eFreya
 {
     QUEST_FREYA_PACT         = 12621,
+
     SPELL_FREYA_CONVERSATION = 52045,
+
     GOSSIP_TEXTID_AVATAR1    = 13303,
     GOSSIP_TEXTID_AVATAR2    = 13304,
     GOSSIP_TEXTID_AVATAR3    = 13305
 };
 
+
 bool GossipHello_npc_avatar_of_freya(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_FREYA_PACT) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_AOF1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->PlayerTalkClass->SendGossipMenu(GOSSIP_TEXTID_AVATAR1, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_avatar_of_freya(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -224,6 +267,7 @@ bool GossipSelect_npc_avatar_of_freya(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 void AddSC_sholazar_basin()
 {
     Script *newscript;
@@ -234,11 +278,13 @@ void AddSC_sholazar_basin()
     newscript->pGossipSelect = &GossipSelect_npc_injured_rainspeaker_oracle;
     newscript->pQuestAccept = &QuestAccept_npc_injured_rainspeaker_oracle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_vekjik";
     newscript->pGossipHello = &GossipHello_npc_vekjik;
     newscript->pGossipSelect = &GossipSelect_npc_vekjik;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_avatar_of_freya";
     newscript->pGossipHello = &GossipHello_npc_avatar_of_freya;
diff --git a/src/bindings/scripts/scripts/northrend/storm_peaks.cpp b/src/bindings/scripts/scripts/northrend/storm_peaks.cpp
index 39b9a599d83..473fca5aa71 100644
--- a/src/bindings/scripts/scripts/northrend/storm_peaks.cpp
+++ b/src/bindings/scripts/scripts/northrend/storm_peaks.cpp
@@ -14,37 +14,47 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
+
 /*######
 ## npc_agnetta_tyrsdottar
 ######*/
+
 #define SAY_AGGRO                  -1571003
 #define GOSSIP_AGNETTA             "Skip the warmup, sister... or are you too scared to face soemeone your own size?"
+
 enum eAgnetta
 {
     QUEST_ITS_THAT_YOUR_GOBLIN      = 12969,
     FACTION_HOSTILE_AT1             = 45
 };
 
+
 struct TRINITY_DLL_DECL npc_agnetta_tyrsdottarAI : public ScriptedAI
 {
     npc_agnetta_tyrsdottarAI(Creature* pCreature) : ScriptedAI(pCreature) { }
+
     void Reset()
     {
         me->RestoreFaction();
     }
 };
+
 CreatureAI* GetAI_npc_agnetta_tyrsdottar(Creature* pCreature)
 {
     return new npc_agnetta_tyrsdottarAI(pCreature);
 }
+
 bool GossipHello_npc_agnetta_tyrsdottar(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_ITS_THAT_YOUR_GOBLIN) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_AGNETTA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(13691, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_agnetta_tyrsdottar(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction )
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -54,28 +64,36 @@ bool GossipSelect_npc_agnetta_tyrsdottar(Player* pPlayer, Creature* pCreature, u
         pCreature->setFaction(FACTION_HOSTILE_AT1);
         pCreature->AI()->AttackStart(pPlayer);
     }
+
     return true;
 }
+
 /*######
 ## npc_frostborn_scout
 ######*/
+
 #define GOSSIP_ITEM1    "Are you okay? I've come to take you back to Frosthold if you can stand."
 #define GOSSIP_ITEM2    "I'm sorry that I didn't get here sooner. What happened?"
 #define GOSSIP_ITEM3    "I'll go get some help. Hang in there."
+
 enum eFrostbornScout
 {
     QUEST_MISSING_SCOUTS  =  12864
 };
 
+
 bool GossipHello_npc_frostborn_scout(Player* pPlayer, Creature* pCreature)
 {
+
     if (pPlayer->GetQuestStatus(QUEST_MISSING_SCOUTS) == QUEST_STATUS_INCOMPLETE)
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->PlayerTalkClass->SendGossipMenu(13611, pCreature->GetGUID());
     }
+
     return true;
 }
+
 bool GossipSelect_npc_frostborn_scout(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -93,15 +111,19 @@ bool GossipSelect_npc_frostborn_scout(Player* pPlayer, Creature* pCreature, uint
         pPlayer->AreaExploredOrEventHappens(QUEST_MISSING_SCOUTS);
         break;
     }
+
     return true;
 }
+
 /*######
 ## npc_thorim
 ######*/
+
 #define GOSSIP_HN "Thorim?"
 #define GOSSIP_SN1 "Can you tell me what became of Sif?"
 #define GOSSIP_SN2 "He did more than that, Thorim. He controls Ulduar now."
 #define GOSSIP_SN3 "It needn't end this way."
+
 enum eThorim
 {
     QUEST_SIBLING_RIVALRY = 13064,
@@ -111,10 +133,12 @@ enum eThorim
     GOSSIP_TEXTID_THORIM3 = 13802,
     GOSSIP_TEXTID_THORIM4 = 13803
 };
+
 bool GossipHello_npc_thorim(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_SIBLING_RIVALRY) == QUEST_STATUS_INCOMPLETE) {
         pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_HN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM1, pCreature->GetGUID());
@@ -122,6 +146,7 @@ bool GossipHello_npc_thorim(Player* pPlayer, Creature* pCreature)
     }
     return false;
 }
+
 bool GossipSelect_npc_thorim(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -145,20 +170,24 @@ bool GossipSelect_npc_thorim(Player* pPlayer, Creature* pCreature, uint32 uiSend
     }
     return true;
 }
+
 void AddSC_storm_peaks()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "npc_agnetta_tyrsdottar";
     newscript->GetAI = &GetAI_npc_agnetta_tyrsdottar;
     newscript->pGossipHello = &GossipHello_npc_agnetta_tyrsdottar;
     newscript->pGossipSelect = &GossipSelect_npc_agnetta_tyrsdottar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_frostborn_scout";
     newscript->pGossipHello = &GossipHello_npc_frostborn_scout;
     newscript->pGossipSelect = &GossipSelect_npc_frostborn_scout;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_thorim";
     newscript->pGossipHello = &GossipHello_npc_thorim;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_bjarngrim.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_bjarngrim.cpp
index 10c636d62ea..d2630dc2175 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_bjarngrim.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_bjarngrim.cpp
@@ -13,14 +13,17 @@
  * along with 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 Bjarngrim
 SD%Complete: 70%
 SDComment: Waypoint needed, we expect boss to always have 2x Stormforged Lieutenant following
 SDCategory: Halls of Lightning
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_halls_of_lightning.h"
+
 enum eEnums
 {
     //Yell
@@ -35,38 +38,47 @@ enum eEnums
     EMOTE_BERSEKER_STANCE                   = -1602008,
     SAY_DEFENSIVE_STANCE                    = -1602009,
     EMOTE_DEFENSIVE_STANCE                  = -1602010,
+
     SPELL_DEFENSIVE_STANCE                  = 53790,
     //SPELL_DEFENSIVE_AURA                    = 41105,
     SPELL_SPELL_REFLECTION                  = 36096,
     SPELL_PUMMEL                            = 12555,
     SPELL_KNOCK_AWAY                        = 52029,
     SPELL_IRONFORM                          = 52022,
+
     SPELL_BERSEKER_STANCE                   = 53791,
     //SPELL_BERSEKER_AURA                     = 41107,
     SPELL_INTERCEPT                         = 58769,
     SPELL_WHIRLWIND                         = 52027,
     SPELL_CLEAVE                            = 15284,
+
     SPELL_BATTLE_STANCE                     = 53792,
     //SPELL_BATTLE_AURA                       = 41106,
     SPELL_MORTAL_STRIKE                     = 16856,
     SPELL_SLAM                              = 52026,
+
     //OTHER SPELLS
     //SPELL_CHARGE_UP                         = 52098,      // only used when starting walk from one platform to the other
     //SPELL_TEMPORARY_ELECTRICAL_CHARGE       = 52092,      // triggered part of above
+
     NPC_STORMFORGED_LIEUTENANT              = 29240,
     SPELL_ARC_WELD                          = 59085,
     SPELL_RENEW_STEEL_N                     = 52774,
     SPELL_RENEW_STEEL_H                     = 59160,
+
     EQUIP_SWORD                             = 37871,
     EQUIP_SHIELD                            = 35642,
     EQUIP_MACE                              = 43623,
+
     STANCE_DEFENSIVE                        = 0,
     STANCE_BERSERKER                        = 1,
     STANCE_BATTLE                           = 2
 };
+
 /*######
 ## boss_bjarngrim
 ######*/
+
 struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
 {
     boss_bjarngrimAI(Creature *pCreature) : ScriptedAI(pCreature)
@@ -76,39 +88,54 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
         m_uiStance = STANCE_DEFENSIVE;
         memset(&m_auiStormforgedLieutenantGUID, 0, sizeof(m_auiStormforgedLieutenantGUID));
     }
+
     ScriptedInstance* m_pInstance;
+
     bool m_bIsHeroic;
     bool m_bIsChangingStance;
+
     uint8 m_uiChargingStatus;
     uint8 m_uiStance;
+
     uint32 m_uiCharge_Timer;
     uint32 m_uiChangeStance_Timer;
+
     uint32 m_uiReflection_Timer;
     uint32 m_uiKnockAway_Timer;
     uint32 m_uiPummel_Timer;
     uint32 m_uiIronform_Timer;
+
     uint32 m_uiIntercept_Timer;
     uint32 m_uiWhirlwind_Timer;
     uint32 m_uiCleave_Timer;
+
     uint32 m_uiMortalStrike_Timer;
     uint32 m_uiSlam_Timer;
+
     uint64 m_auiStormforgedLieutenantGUID[2];
+
     void Reset()
     {
         m_bIsChangingStance = false;
+
         m_uiChargingStatus = 0;
         m_uiCharge_Timer = 1000;
+
         m_uiChangeStance_Timer = 20000 + rand()%5000;
+
         m_uiReflection_Timer = 8000;
         m_uiKnockAway_Timer = 20000;
         m_uiPummel_Timer = 10000;
         m_uiIronform_Timer = 25000;
+
         m_uiIntercept_Timer = 5000;
         m_uiWhirlwind_Timer = 10000;
         m_uiCleave_Timer = 8000;
+
         m_uiMortalStrike_Timer = 8000;
         m_uiSlam_Timer = 10000;
-        for (uint8 i = 0; i < 2; ++i)
+
+        for(uint8 i = 0; i < 2; ++i)
         {
             if (Creature* pStormforgedLieutenant = (Unit::GetCreature((*m_creature), m_auiStormforgedLieutenantGUID[i])))
             {
@@ -116,34 +143,44 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                     pStormforgedLieutenant->Respawn();
             }
         }
+
         if (m_uiStance != STANCE_DEFENSIVE)
         {
             DoRemoveStanceAura(m_uiStance);
             DoCast(m_creature, SPELL_DEFENSIVE_STANCE);
             m_uiStance = STANCE_DEFENSIVE;
         }
+
         SetEquipmentSlots(false, EQUIP_SWORD, EQUIP_SHIELD, EQUIP_NO_CHANGE);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_BJARNGRIM, NOT_STARTED);
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         //must get both lieutenants here and make sure they are with him
         m_creature->CallForHelp(30.0f);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_BJARNGRIM, IN_PROGRESS);
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void JustDied(Unit* pKiller)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_BJARNGRIM, DONE);
     }
+
     //TODO: remove when removal is done by mangos
     void DoRemoveStanceAura(uint8 uiStance)
     {
@@ -160,22 +197,29 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 break;
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target
      if (!UpdateVictim())
             return;
+
         // Change stance
         if (m_uiChangeStance_Timer < uiDiff)
         {
             //wait for current spell to finish before change stance
             if (m_creature->IsNonMeleeSpellCasted(false))
                 return;
+
             DoRemoveStanceAura(m_uiStance);
+
             int uiTempStance = rand()%(3-1);
+
             if (uiTempStance >= m_uiStance)
                 ++uiTempStance;
+
             m_uiStance = uiTempStance;
+
             switch(m_uiStance)
             {
                 case STANCE_DEFENSIVE:
@@ -197,11 +241,13 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                     SetEquipmentSlots(false, EQUIP_MACE, EQUIP_UNEQUIP, EQUIP_NO_CHANGE);
                     break;
             }
+
             m_uiChangeStance_Timer = 20000 + rand()%5000;
             return;
         }
         else
             m_uiChangeStance_Timer -= uiDiff;
+
         switch(m_uiStance)
         {
             case STANCE_DEFENSIVE:
@@ -213,6 +259,7 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiReflection_Timer -= uiDiff;
+
                 if (m_uiKnockAway_Timer < uiDiff)
                 {
                     DoCast(m_creature, SPELL_KNOCK_AWAY);
@@ -220,6 +267,7 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiKnockAway_Timer -= uiDiff;
+
                 if (m_uiPummel_Timer < uiDiff)
                 {
                     DoCast(m_creature->getVictim(), SPELL_PUMMEL);
@@ -227,6 +275,7 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiPummel_Timer -= uiDiff;
+
                 if (m_uiIronform_Timer < uiDiff)
                 {
                     DoCast(m_creature, SPELL_IRONFORM);
@@ -234,6 +283,7 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiIronform_Timer -= uiDiff;
+
                 break;
             }
             case STANCE_BERSERKER:
@@ -246,6 +296,7 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiIntercept_Timer -= uiDiff;
+
                 if (m_uiWhirlwind_Timer < uiDiff)
                 {
                     DoCast(m_creature, SPELL_WHIRLWIND);
@@ -253,6 +304,7 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiWhirlwind_Timer -= uiDiff;
+
                 if (m_uiCleave_Timer < uiDiff)
                 {
                     DoCast(m_creature->getVictim(), SPELL_CLEAVE);
@@ -260,6 +312,7 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiCleave_Timer -= uiDiff;
+
                 break;
             }
             case STANCE_BATTLE:
@@ -271,6 +324,7 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiMortalStrike_Timer -= uiDiff;
+
                 if (m_uiSlam_Timer < uiDiff)
                 {
                     DoCast(m_creature->getVictim(), SPELL_SLAM);
@@ -278,15 +332,19 @@ struct TRINITY_DLL_DECL boss_bjarngrimAI : public ScriptedAI
                 }
                 else
                     m_uiSlam_Timer -= uiDiff;
+
                 break;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 /*######
 ## mob_stormforged_lieutenant
 ######*/
+
 struct TRINITY_DLL_DECL mob_stormforged_lieutenantAI : public ScriptedAI
 {
     mob_stormforged_lieutenantAI(Creature *pCreature) : ScriptedAI(pCreature)
@@ -294,15 +352,19 @@ struct TRINITY_DLL_DECL mob_stormforged_lieutenantAI : public ScriptedAI
         m_pInstance = pCreature->GetInstanceData();
         m_bIsHeroic = pCreature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* m_pInstance;
     bool m_bIsHeroic;
+
     uint32 m_uiArcWeld_Timer;
     uint32 m_uiRenewSteel_Timer;
+
     void Reset()
     {
         m_uiArcWeld_Timer = 20000 + rand()%1000;
         m_uiRenewSteel_Timer = 10000 + rand()%1000;
     }
+
     void EnterCombat(Unit* pWho)
     {
         if (m_pInstance)
@@ -314,11 +376,13 @@ struct TRINITY_DLL_DECL mob_stormforged_lieutenantAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (m_uiArcWeld_Timer < uiDiff)
         {
             DoCast(m_creature->getVictim(), SPELL_ARC_WELD);
@@ -326,6 +390,7 @@ struct TRINITY_DLL_DECL mob_stormforged_lieutenantAI : public ScriptedAI
         }
         else
             m_uiArcWeld_Timer -= uiDiff;
+
         if (m_uiRenewSteel_Timer < uiDiff)
         {
             if (m_pInstance)
@@ -340,24 +405,30 @@ struct TRINITY_DLL_DECL mob_stormforged_lieutenantAI : public ScriptedAI
         }
         else
             m_uiRenewSteel_Timer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_bjarngrim(Creature* pCreature)
 {
     return new boss_bjarngrimAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_stormforged_lieutenant(Creature* pCreature)
 {
     return new mob_stormforged_lieutenantAI(pCreature);
 }
+
 void AddSC_boss_bjarngrim()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_bjarngrim";
     newscript->GetAI = &GetAI_boss_bjarngrim;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_stormforged_lieutenant";
     newscript->GetAI = &GetAI_mob_stormforged_lieutenant;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_ionar.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_ionar.cpp
index ccaf46303c7..96e49343b39 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_ionar.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_ionar.cpp
@@ -13,14 +13,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss Ionar
 SD%Complete: 80%
 SDComment: Timer check
 SDCategory: Halls of Lightning
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_halls_of_lightning.h"
+
 enum eEnums
 {
     SAY_AGGRO                               = -1602011,
@@ -30,23 +33,30 @@ enum eEnums
     SAY_DEATH                               = -1602015,
     SAY_SPLIT_1                             = -1602016,
     SAY_SPLIT_2                             = -1602017,
+
     SPELL_BALL_LIGHTNING_N                  = 52780,
     SPELL_BALL_LIGHTNING_H                  = 59800,
     SPELL_STATIC_OVERLOAD_N                 = 52658,
     SPELL_STATIC_OVERLOAD_H                 = 59795,
+
     SPELL_DISPERSE                          = 52770,
     SPELL_SUMMON_SPARK                      = 52746,
     SPELL_SPARK_DESPAWN                     = 52776,
+
     //Spark of Ionar
     SPELL_SPARK_VISUAL_TRIGGER_N            = 52667,
     SPELL_SPARK_VISUAL_TRIGGER_H            = 59833,
+
     NPC_SPARK_OF_IONAR                      = 28926,
+
     MAX_SPARKS                              = 5,
     POINT_CALLBACK                          = 0
 };
+
 /*######
 ## Boss Ionar
 ######*/
+
 struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
 {
     boss_ionarAI(Creature *pCreature) : ScriptedAI(pCreature)
@@ -54,46 +64,64 @@ struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
         m_pInstance = pCreature->GetInstanceData();
         m_bIsHeroic = pCreature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* m_pInstance;
+
     std::list m_lSparkGUIDList;
+
     bool m_bIsHeroic;
+
     bool m_bIsSplitPhase;
     uint32 m_uiSplit_Timer;
     uint32 m_uiSparkAtHomeCount;
+
     uint32 m_uiStaticOverload_Timer;
     uint32 m_uiBallLightning_Timer;
+
     uint32 m_uiHealthAmountModifier;
+
     void Reset()
     {
         m_lSparkGUIDList.clear();
+
         m_bIsSplitPhase = true;
         m_uiSplit_Timer = 25000;
         m_uiSparkAtHomeCount = 0;
+
         m_uiStaticOverload_Timer = 5000 + rand()%1000;
         m_uiBallLightning_Timer = 10000 + rand()%1000;
+
         m_uiHealthAmountModifier = 1;
+
         if (m_creature->GetVisibility() == VISIBILITY_OFF)
             m_creature->SetVisibility(VISIBILITY_ON);
     }
+
     void AttackedBy(Unit* pAttacker)
     {
         if (m_creature->getVictim())
             return;
+
         if (m_creature->GetVisibility() == VISIBILITY_OFF)
             return;
+
         AttackStart(pAttacker);
     }
+
     void Aggro(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_IONAR, IN_PROGRESS);
     }
+
     void JustReachedHome()
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_IONAR, NOT_STARTED);
     }
+
     void AttackStart(Unit* pWho)
     {
         if (m_creature->Attack(pWho, true))
@@ -101,26 +129,32 @@ struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
             m_creature->AddThreat(pWho, 0.0f);
             m_creature->SetInCombatWith(pWho);
             pWho->SetInCombatWith(m_creature);
+
             if (m_creature->GetVisibility() != VISIBILITY_OFF)
                 m_creature->GetMotionMaster()->MoveChase(pWho);
         }
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
         DespawnSpark();
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_IONAR, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void DespawnSpark()
     {
         if (m_lSparkGUIDList.empty())
             return;
-        for (std::list::iterator itr = m_lSparkGUIDList.begin(); itr != m_lSparkGUIDList.end(); ++itr)
+
+        for(std::list::iterator itr = m_lSparkGUIDList.begin(); itr != m_lSparkGUIDList.end(); ++itr)
         {
             if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
             {
@@ -128,15 +162,18 @@ struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
                     pTemp->ForcedDespawn();
             }
         }
+
         m_lSparkGUIDList.clear();
     }
+
     //make sparks come back
     void CallBackSparks()
     {
         //should never be empty here, but check
         if (m_lSparkGUIDList.empty())
             return;
-        for (std::list::iterator itr = m_lSparkGUIDList.begin(); itr != m_lSparkGUIDList.end(); ++itr)
+
+        for(std::list::iterator itr = m_lSparkGUIDList.begin(); itr != m_lSparkGUIDList.end(); ++itr)
         {
             if (Creature* pSpark = Unit::GetCreature(*m_creature, *itr))
             {
@@ -144,27 +181,34 @@ struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
                 {
                     if (pSpark->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
                         pSpark->GetMotionMaster()->MovementExpired();
+
                     pSpark->SetSpeed(MOVE_RUN, pSpark->GetCreatureInfo()->speed * 2);
                     pSpark->GetMotionMaster()->MovePoint(POINT_CALLBACK, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
                 }
             }
         }
     }
+
     void RegisterSparkAtHome()
     {
         ++m_uiSparkAtHomeCount;
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (pSummoned->GetEntry() == NPC_SPARK_OF_IONAR)
         {
             pSummoned->CastSpell(pSummoned, m_bIsHeroic ? SPELL_SPARK_VISUAL_TRIGGER_H : SPELL_SPARK_VISUAL_TRIGGER_N, true);
+
             Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
+
             if (m_creature->getVictim())
                 pSummoned->AI()->AttackStart(pTarget ? pTarget : m_creature->getVictim());
+
             m_lSparkGUIDList.push_back(pSummoned->GetGUID());
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         // Splitted
@@ -175,9 +219,11 @@ struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
                 Reset();
                 return;
             }*/
+
             if (m_uiSplit_Timer < uiDiff)
             {
                 m_uiSplit_Timer = 2500;
+
                 // Return sparks to where Ionar splitted
                 if (m_bIsSplitPhase)
                 {
@@ -189,10 +235,13 @@ struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
                 {
                     m_creature->SetVisibility(VISIBILITY_ON);
                     m_creature->CastSpell(m_creature, SPELL_SPARK_DESPAWN, false);
+
                     DespawnSpark();
+
                     m_uiSparkAtHomeCount = 0;
                     m_uiSplit_Timer = 25000;
                     m_bIsSplitPhase = true;
+
                     if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE)
                     {
                         if (m_creature->getVictim())
@@ -202,19 +251,24 @@ struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
             }
             else
                 m_uiSplit_Timer -= uiDiff;
+
             return;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (m_uiStaticOverload_Timer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, m_bIsHeroic ? SPELL_STATIC_OVERLOAD_H : SPELL_STATIC_OVERLOAD_N);
+
             m_uiStaticOverload_Timer = 5000 + rand()%1000;
         }
         else
             m_uiStaticOverload_Timer -= uiDiff;
+
         if (m_uiBallLightning_Timer < uiDiff)
         {
             DoCast(m_creature->getVictim(), m_bIsHeroic ? SPELL_BALL_LIGHTNING_H : SPELL_BALL_LIGHTNING_N);
@@ -222,22 +276,29 @@ struct TRINITY_DLL_DECL boss_ionarAI : public ScriptedAI
         }
         else
             m_uiBallLightning_Timer -= uiDiff;
+
         // Health check
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < (100-(20*m_uiHealthAmountModifier)))
         {
             ++m_uiHealthAmountModifier;
+
             DoScriptText(RAND(SAY_SPLIT_1,SAY_SPLIT_2), m_creature);
+
             if (m_creature->IsNonMeleeSpellCasted(false))
                 m_creature->InterruptNonMeleeSpells(false);
+
             DoCast(m_creature, SPELL_DISPERSE);
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_ionar(Creature* pCreature)
 {
     return new boss_ionarAI(pCreature);
 }
+
 bool EffectDummyCreature_boss_ionar(Unit* pCaster, uint32 uiSpellId, uint32 uiEffIndex, Creature* pCreatureTarget)
 {
     //always check spellid and effectindex
@@ -245,32 +306,42 @@ bool EffectDummyCreature_boss_ionar(Unit* pCaster, uint32 uiSpellId, uint32 uiEf
     {
         if (pCreatureTarget->GetEntry() != NPC_IONAR)
             return true;
+
         for (uint8 i = 0; i < MAX_SPARKS; ++i)
             pCreatureTarget->CastSpell(pCreatureTarget, SPELL_SUMMON_SPARK, true);
+
         pCreatureTarget->AttackStop();
         pCreatureTarget->SetVisibility(VISIBILITY_OFF);
+
         if (pCreatureTarget->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
             pCreatureTarget->GetMotionMaster()->MovementExpired();
+
         //always return true when we are handling this spell and effect
         return true;
     }
     return false;
 }
+
 /*######
 ## mob_spark_of_ionar
 ######*/
+
 struct TRINITY_DLL_DECL mob_spark_of_ionarAI : public ScriptedAI
 {
     mob_spark_of_ionarAI(Creature *pCreature) : ScriptedAI(pCreature)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     void Reset() { }
+
     void MovementInform(uint32 uiType, uint32 uiPointId)
     {
         if (uiType != POINT_MOTION_TYPE || !m_pInstance)
             return;
+
         if (uiPointId == POINT_CALLBACK)
         {
             if (Creature* pIonar = m_pInstance->instance->GetCreature(m_pInstance->GetData64(DATA_IONAR)))
@@ -280,6 +351,7 @@ struct TRINITY_DLL_DECL mob_spark_of_ionarAI : public ScriptedAI
                     m_creature->ForcedDespawn();
                     return;
                 }
+
                 if (boss_ionarAI* pIonarAI = dynamic_cast(pIonar->AI()))
                     pIonarAI->RegisterSparkAtHome();
             }
@@ -288,18 +360,22 @@ struct TRINITY_DLL_DECL mob_spark_of_ionarAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_mob_spark_of_ionar(Creature* pCreature)
 {
     return new mob_spark_of_ionarAI(pCreature);
 }
+
 void AddSC_boss_ionar()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_ionar";
     newscript->GetAI = &GetAI_boss_ionar;
     newscript->pEffectDummyCreature = &EffectDummyCreature_boss_ionar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_spark_of_ionar";
     newscript->GetAI = &GetAI_mob_spark_of_ionar;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_loken.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_loken.cpp
index 227b297e087..19d34eb383c 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_loken.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_loken.cpp
@@ -13,18 +13,23 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss Loken
 SD%Complete: 60%
 SDComment: Missing intro. Remove hack of Pulsing Shockwave when core supports. Aura is not working (59414)
 SDCategory: Halls of Lightning
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_halls_of_lightning.h"
+
 #define MAX_ENCOUNTER_TIME  2 * 60 * 1000
+
 enum eEnums
 {
     ACHIEVEMENT_TIMELY_DEATH            = 1867,
+
     SAY_AGGRO                           = -1602018,
     SAY_INTRO_1                         = -1602019,
     SAY_INTRO_2                         = -1602020,
@@ -39,16 +44,20 @@ enum eEnums
     SAY_50HEALTH                        = -1602029,
     SAY_25HEALTH                        = -1602030,
     EMOTE_NOVA                          = -1602031,
+
     SPELL_ARC_LIGHTNING                 = 52921,
     SPELL_LIGHTNING_NOVA_N              = 52960,
     SPELL_LIGHTNING_NOVA_H              = 59835,
+
     SPELL_PULSING_SHOCKWAVE_N           = 52961,
     SPELL_PULSING_SHOCKWAVE_H           = 59836,
     SPELL_PULSING_SHOCKWAVE_AURA        = 59414
 };
+
 /*######
 ## Boss Loken
 ######*/
+
 struct TRINITY_DLL_DECL boss_lokenAI : public ScriptedAI
 {
     boss_lokenAI(Creature* pCreature) : ScriptedAI(pCreature)
@@ -56,36 +65,50 @@ struct TRINITY_DLL_DECL boss_lokenAI : public ScriptedAI
         m_pInstance = pCreature->GetInstanceData();
         m_bIsHeroic = pCreature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* m_pInstance;
+
     bool m_bIsHeroic;
     bool m_bIsAura;
+
     uint32 m_uiArcLightning_Timer;
     uint32 m_uiLightningNova_Timer;
     uint32 m_uiPulsingShockwave_Timer;
     uint32 m_uiResumePulsingShockwave_Timer;
+
     uint32 m_uiHealthAmountModifier;
+
     uint32 EncounterTime;
+
     void Reset()
     {
         m_bIsAura = false;
+
         m_uiArcLightning_Timer = 15000;
         m_uiLightningNova_Timer = 20000;
         m_uiPulsingShockwave_Timer = 2000;
         m_uiResumePulsingShockwave_Timer = 15000;
+
         m_uiHealthAmountModifier = 1;
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_LOKEN, NOT_STARTED);
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         EncounterTime = 0;
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_LOKEN, IN_PROGRESS);
     }
+
     void JustDied(Unit* pKiller)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (m_bIsHeroic && EncounterTime <= MAX_ENCOUNTER_TIME)
         {
             AchievementEntry const *AchievTimelyDeath = GetAchievementStore()->LookupEntry(ACHIEVEMENT_TIMELY_DEATH);
@@ -95,24 +118,29 @@ struct TRINITY_DLL_DECL boss_lokenAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievTimelyDeath);
                 }
             }
         }
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_LOKEN, DONE);
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         EncounterTime += uiDiff;
+
         if (m_bIsAura)
         {
             // workaround for PULSING_SHOCKWAVE
@@ -122,17 +150,21 @@ struct TRINITY_DLL_DECL boss_lokenAI : public ScriptedAI
                 if (pMap->IsDungeon())
                 {
                     Map::PlayerList const &PlayerList = pMap->GetPlayers();
+
                     if (PlayerList.isEmpty())
                         return;
+
                     for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                         if (i->getSource()->isAlive() && i->getSource()->isTargetableForAttack())
                         {
                             int32 dmg;
                             float m_fDist = (m_creature->GetDistance(i->getSource()) - 7.8f);
+
                             if (m_fDist <= 1.0f) // Less than 1 yard
                                 dmg = (m_bIsHeroic ? 150 : 100); // need to correct damage
                             else // Further from 1 yard
                                 dmg = ((m_bIsHeroic ? 150 : 100) * m_fDist) + (m_bIsHeroic ? 150 : 100); // need to correct damage
+
                             m_creature->CastCustomSpell(i->getSource(), (m_bIsHeroic ? 59837 : 52942), &dmg, 0, 0, false);
                         }
                 }
@@ -145,6 +177,7 @@ struct TRINITY_DLL_DECL boss_lokenAI : public ScriptedAI
             {
                 //breaks at movement, can we assume when it's time, this spell is casted and also must stop movement?
                 m_creature->CastSpell(m_creature, SPELL_PULSING_SHOCKWAVE_AURA, true);
+
                   DoCast(m_creature, m_bIsHeroic ? SPELL_PULSING_SHOCKWAVE_H : SPELL_PULSING_SHOCKWAVE_N); // need core support
                 m_bIsAura = true;
                 m_uiResumePulsingShockwave_Timer = 0;
@@ -152,25 +185,30 @@ struct TRINITY_DLL_DECL boss_lokenAI : public ScriptedAI
             else
                 m_uiResumePulsingShockwave_Timer -= uiDiff;
         }
+
         if (m_uiArcLightning_Timer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, SPELL_ARC_LIGHTNING);
+
             m_uiArcLightning_Timer = 15000 + rand()%1000;
         }
         else
             m_uiArcLightning_Timer -= uiDiff;
+
         if (m_uiLightningNova_Timer < uiDiff)
         {
             DoScriptText(RAND(SAY_NOVA_1,SAY_NOVA_2,SAY_NOVA_3), m_creature);
             DoScriptText(EMOTE_NOVA, m_creature);
             DoCast(m_creature, m_bIsHeroic ? SPELL_LIGHTNING_NOVA_H : SPELL_LIGHTNING_NOVA_N);
+
             m_bIsAura = false;
             m_uiResumePulsingShockwave_Timer = (m_bIsHeroic ? 4000 : 5000); // Pause Pulsing Shockwave aura
             m_uiLightningNova_Timer = 20000 + rand()%1000;
         }
         else
             m_uiLightningNova_Timer -= uiDiff;
+
         // Health check
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < (100-(25*m_uiHealthAmountModifier)))
         {
@@ -180,18 +218,23 @@ struct TRINITY_DLL_DECL boss_lokenAI : public ScriptedAI
                 case 2: DoScriptText(SAY_50HEALTH, m_creature); break;
                 case 3: DoScriptText(SAY_25HEALTH, m_creature); break;
             }
+
             ++m_uiHealthAmountModifier;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_loken(Creature* pCreature)
 {
     return new boss_lokenAI(pCreature);
 }
+
 void AddSC_boss_loken()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_loken";
     newscript->GetAI = &GetAI_boss_loken;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_volkhan.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_volkhan.cpp
index 0446e653b2d..1804d316f92 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_volkhan.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/boss_volkhan.cpp
@@ -13,14 +13,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss Volkhan
 SD%Complete: 60%
 SDComment: Not considered complete. Some events may fail and need further development
 SDCategory: Halls of Lightning
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_halls_of_lightning.h"
+
 enum eEnums
 {
     SAY_AGGRO                               = -1602032,
@@ -34,31 +37,41 @@ enum eEnums
     SAY_FORGE_2                             = -1602040,
     EMOTE_TO_ANVIL                          = -1602041,
     EMOTE_SHATTER                           = -1602042,
+
     SPELL_HEAT_N                            = 52387,
     SPELL_HEAT_H                            = 59528,
     SPELL_SHATTERING_STOMP_N                = 52237,
     SPELL_SHATTERING_STOMP_H                = 59529,
+
     //unclear how "directions" of spells must be. Last, summoning GO, what is it for? Script depend on:
     SPELL_TEMPER                            = 52238,        //TARGET_SCRIPT boss->anvil
     SPELL_TEMPER_DUMMY                      = 52654,        //TARGET_SCRIPT anvil->boss
+
     //SPELL_TEMPER_VISUAL                     = 52661,        //summons GO
+
     SPELL_SUMMON_MOLTEN_GOLEM               = 52405,
+
     //Molten Golem
     SPELL_BLAST_WAVE                        = 23113,
     SPELL_IMMOLATION_STRIKE_N               = 52433,
     SPELL_IMMOLATION_STRIKE_H               = 59530,
     SPELL_SHATTER_N                         = 52429,
     SPELL_SHATTER_H                         = 59527,
+
     NPC_VOLKHAN_ANVIL                       = 28823,
     NPC_MOLTEN_GOLEM                        = 28695,
     NPC_BRITTLE_GOLEM                       = 28681,
+
     POINT_ID_ANVIL                          = 0,
     MAX_GOLEM                               = 2,
+
     ACHIEVEMENT_SHATTER_RESISTANT            = 2042
 };
+
 /*######
 ## Boss Volkhan
 ######*/
+
 struct TRINITY_DLL_DECL boss_volkhanAI : public ScriptedAI
 {
     boss_volkhanAI(Creature *pCreature) : ScriptedAI(pCreature)
@@ -66,38 +79,51 @@ struct TRINITY_DLL_DECL boss_volkhanAI : public ScriptedAI
         m_pInstance = pCreature->GetInstanceData();
         m_bIsHeroic = pCreature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* m_pInstance;
+
     std::list m_lGolemGUIDList;
+
     bool m_bIsHeroic;
     bool m_bHasTemper;
     bool m_bIsStriking;
     bool m_bCanShatterGolem;
+
     uint8 GolemsShattered;
     uint32 m_uiPause_Timer;
     uint32 m_uiShatteringStomp_Timer;
     uint32 m_uiShatter_Timer;
+
     uint32 m_uiHealthAmountModifier;
+
     void Reset()
     {
         m_bIsStriking = false;
         m_bHasTemper = false;
         m_bCanShatterGolem = false;
+
         m_uiPause_Timer = 3500;
         m_uiShatteringStomp_Timer = 0;
         m_uiShatter_Timer = 5000;
         GolemsShattered = 0;
+
         m_uiHealthAmountModifier = 1;
+
         DespawnGolem();
         m_lGolemGUIDList.clear();
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_VOLKHAN, NOT_STARTED);
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_VOLKHAN, IN_PROGRESS);
     }
+
     void AttackStart(Unit* pWho)
     {
         if (m_creature->Attack(pWho, true))
@@ -105,16 +131,20 @@ struct TRINITY_DLL_DECL boss_volkhanAI : public ScriptedAI
             m_creature->AddThreat(pWho, 0.0f);
             m_creature->SetInCombatWith(pWho);
             pWho->SetInCombatWith(m_creature);
+
             if (!m_bHasTemper)
                 m_creature->GetMotionMaster()->MoveChase(pWho);
         }
     }
+
     void JustDied(Unit* pKiller)
     {
         DoScriptText(SAY_DEATH, m_creature);
         DespawnGolem();
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_VOLKHAN, DONE);
+
         if (HeroicMode && GolemsShattered < 5)
         {
             AchievementEntry const *AchievShatterResistant = GetAchievementStore()->LookupEntry(ACHIEVEMENT_SHATTER_RESISTANT);
@@ -124,21 +154,24 @@ struct TRINITY_DLL_DECL boss_volkhanAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievShatterResistant);
                 }
             }
         }
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void DespawnGolem()
     {
         if (m_lGolemGUIDList.empty())
             return;
-        for (std::list::iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
+
+        for(std::list::iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
         {
             if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
             {
@@ -146,13 +179,16 @@ struct TRINITY_DLL_DECL boss_volkhanAI : public ScriptedAI
                     pTemp->ForcedDespawn();
             }
         }
+
         m_lGolemGUIDList.clear();
     }
+
     void ShatterGolem()
     {
         if (m_lGolemGUIDList.empty())
             return;
-        for (std::list::iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
+
+        for(std::list::iterator itr = m_lGolemGUIDList.begin(); itr != m_lGolemGUIDList.end(); ++itr)
         {
             if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
             {
@@ -165,27 +201,33 @@ struct TRINITY_DLL_DECL boss_volkhanAI : public ScriptedAI
             }
         }
     }
+
     void SpellHit(Unit* pCaster, const SpellEntry* pSpell)
     {
         if (pSpell->Id == SPELL_TEMPER_DUMMY)
             m_bIsStriking = true;
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (pSummoned->GetEntry() == NPC_MOLTEN_GOLEM)
         {
             m_lGolemGUIDList.push_back(pSummoned->GetGUID());
+
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 pSummoned->AI()->AttackStart(pTarget);
+
             //why healing when just summoned?
             pSummoned->CastSpell(pSummoned, m_bIsHeroic ? SPELL_HEAT_H : SPELL_HEAT_N, false, NULL, NULL, m_creature->GetGUID());
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (m_bIsStriking)
         {
             if (m_uiPause_Timer < uiDiff)
@@ -195,29 +237,37 @@ struct TRINITY_DLL_DECL boss_volkhanAI : public ScriptedAI
                     if (m_creature->getVictim())
                         m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                 }
+
                 m_bHasTemper = false;
                 m_bIsStriking = false;
                 m_uiPause_Timer = 3500;
             }
             else
                 m_uiPause_Timer -= uiDiff;
+
             return;
         }
+
         // When to start shatter? After 60, 40 or 20% hp?
         if (!m_bHasTemper && m_uiHealthAmountModifier >= 3)
         {
             if (m_uiShatteringStomp_Timer < uiDiff)
             {
                 //should he stomp even if he has no brittle golem to shatter?
+
                 DoScriptText(RAND(SAY_STOMP_1,SAY_STOMP_2), m_creature);
+
                 DoCast(m_creature, m_bIsHeroic ? SPELL_SHATTERING_STOMP_H : SPELL_SHATTERING_STOMP_N);
+
                 DoScriptText(EMOTE_SHATTER, m_creature);
+
                 m_uiShatteringStomp_Timer = 30000;
                 m_bCanShatterGolem = true;
             }
             else
                 m_uiShatteringStomp_Timer -= uiDiff;
         }
+
         // Shatter Golems 3 seconds after Shattering Stomp
         if (m_bCanShatterGolem)
         {
@@ -230,23 +280,31 @@ struct TRINITY_DLL_DECL boss_volkhanAI : public ScriptedAI
             else
                 m_uiShatter_Timer -= uiDiff;
         }
+
         // Health check
         if (!m_bCanShatterGolem && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < (100-(20*m_uiHealthAmountModifier)))
         {
             ++m_uiHealthAmountModifier;
+
             if (m_creature->IsNonMeleeSpellCasted(false))
                 m_creature->InterruptNonMeleeSpells(false);
+
             DoScriptText(RAND(SAY_FORGE_1,SAY_FORGE_2), m_creature);
+
             m_bHasTemper = true;
+
             m_creature->CastSpell(m_creature, SPELL_TEMPER, false);
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_volkhan(Creature* pCreature)
 {
     return new boss_volkhanAI(pCreature);
 }
+
 bool EffectDummyCreature_boss_volkhan(Unit* pCaster, uint32 uiSpellId, uint32 uiEffIndex, Creature* pCreatureTarget)
 {
     //always check spellid and effectindex
@@ -254,18 +312,23 @@ bool EffectDummyCreature_boss_volkhan(Unit* pCaster, uint32 uiSpellId, uint32 ui
     {
         if (pCaster->GetEntry() != NPC_VOLKHAN_ANVIL || pCreatureTarget->GetEntry() != NPC_VOLKHAN)
             return true;
-        for (uint8 i = 0; i < MAX_GOLEM; ++i)
+
+        for(uint8 i = 0; i < MAX_GOLEM; ++i)
         {
             pCreatureTarget->CastSpell(pCaster, SPELL_SUMMON_MOLTEN_GOLEM, true);
         }
+
         //always return true when we are handling this spell and effect
         return true;
     }
+
     return false;
 }
+
 /*######
 ## npc_volkhan_anvil
 ######*/
+
 bool EffectDummyCreature_npc_volkhan_anvil(Unit* pCaster, uint32 uiSpellId, uint32 uiEffIndex, Creature* pCreatureTarget)
 {
     //always check spellid and effectindex
@@ -273,42 +336,58 @@ bool EffectDummyCreature_npc_volkhan_anvil(Unit* pCaster, uint32 uiSpellId, uint
     {
         if (pCaster->GetEntry() != NPC_VOLKHAN || pCreatureTarget->GetEntry() != NPC_VOLKHAN_ANVIL)
             return true;
+
         Creature *cre = CAST_CRE(pCaster);
+
         DoScriptText(EMOTE_TO_ANVIL, pCaster);
+
         float fX, fY, fZ;
         pCreatureTarget->GetContactPoint(pCaster, fX, fY, fZ, INTERACTION_DISTANCE);
+
         pCaster->AttackStop();
+
         if (pCaster->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
             pCaster->GetMotionMaster()->MovementExpired();
+
         cre->GetMap()->CreatureRelocation(cre, fX, fY, fZ, pCreatureTarget->GetOrientation());
         cre->SendMonsterMove(fX, fY, fZ, 0, cre->GetUnitMovementFlags(), 1);
+
         pCreatureTarget->CastSpell(pCaster, SPELL_TEMPER_DUMMY, false);
+
         //always return true when we are handling this spell and effect
         return true;
     }
+
     return false;
 }
+
 /*######
 ## mob_molten_golem
 ######*/
+
 struct TRINITY_DLL_DECL mob_molten_golemAI : public ScriptedAI
 {
     mob_molten_golemAI(Creature *pCreature) : ScriptedAI(pCreature)
     {
         m_bIsHeroic = pCreature->GetMap()->IsHeroic();
     }
+
     bool m_bIsHeroic;
     bool m_bIsFrozen;
+
     uint32 m_uiBlast_Timer;
     uint32 m_uiDeathDelay_Timer;
     uint32 m_uiImmolation_Timer;
+
     void Reset()
     {
         m_bIsFrozen = false;
+
         m_uiBlast_Timer = 20000;
         m_uiDeathDelay_Timer = 0;
         m_uiImmolation_Timer = 5000;
     }
+
     void AttackStart(Unit* pWho)
     {
         if (m_creature->Attack(pWho, true))
@@ -316,10 +395,12 @@ struct TRINITY_DLL_DECL mob_molten_golemAI : public ScriptedAI
             m_creature->AddThreat(pWho, 0.0f);
             m_creature->SetInCombatWith(pWho);
             pWho->SetInCombatWith(m_creature);
+
             if (!m_bIsFrozen)
                 m_creature->GetMotionMaster()->MoveChase(pWho);
         }
     }
+
     void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
     {
         if (uiDamage > m_creature->GetHealth())
@@ -337,6 +418,7 @@ struct TRINITY_DLL_DECL mob_molten_golemAI : public ScriptedAI
             m_bIsFrozen = true;
         }
     }
+
     void SpellHit(Unit* pCaster, const SpellEntry* pSpell)
     {
         //this is the dummy effect of the spells
@@ -346,11 +428,13 @@ struct TRINITY_DLL_DECL mob_molten_golemAI : public ScriptedAI
                 m_creature->ForcedDespawn();
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target or if we are frozen
         if (!UpdateVictim() || m_bIsFrozen)
             return;
+
         if (m_uiBlast_Timer < uiDiff)
         {
             DoCast(m_creature, SPELL_BLAST_WAVE);
@@ -358,6 +442,7 @@ struct TRINITY_DLL_DECL mob_molten_golemAI : public ScriptedAI
         }
         else
             m_uiBlast_Timer -= uiDiff;
+
         if (m_uiImmolation_Timer < uiDiff)
         {
             DoCast(m_creature->getVictim(), m_bIsHeroic ? SPELL_IMMOLATION_STRIKE_H : SPELL_IMMOLATION_STRIKE_N);
@@ -365,25 +450,31 @@ struct TRINITY_DLL_DECL mob_molten_golemAI : public ScriptedAI
         }
         else
             m_uiImmolation_Timer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_molten_golem(Creature* pCreature)
 {
     return new mob_molten_golemAI(pCreature);
 }
+
 void AddSC_boss_volkhan()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_volkhan";
     newscript->GetAI = &GetAI_boss_volkhan;
     newscript->pEffectDummyCreature = &EffectDummyCreature_boss_volkhan;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_volkhan_anvil";
     newscript->pEffectDummyCreature = &EffectDummyCreature_npc_volkhan_anvil;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_molten_golem";
     newscript->GetAI = &GetAI_mob_molten_golem;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/def_halls_of_lightning.h b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/def_halls_of_lightning.h
index 0eba059d387..d9739fdf888 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/def_halls_of_lightning.h
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/def_halls_of_lightning.h
@@ -1,27 +1,34 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_HALLS_OF_LIGHTNING_H
 #define DEF_HALLS_OF_LIGHTNING_H
+
 enum eTypes
 {
     MAX_ENCOUNTER           = 4,
+
     DATA_BJARNGRIM          = 1,
     DATA_IONAR              = 2,
     DATA_LOKEN              = 3,
     DATA_VOLKHAN            = 4,
+
     TYPE_BJARNGRIM          = 10,
     TYPE_IONAR              = 11,
     TYPE_LOKEN              = 12,
     TYPE_VOLKHAN            = 13,
+
     NPC_BJARNGRIM           = 28586,
     NPC_VOLKHAN             = 28587,
     NPC_IONAR               = 28546,
     NPC_LOKEN               = 28923,
+
     GO_BJARNGRIM_DOOR       = 191416,                       //_doors10
     GO_VOLKHAN_DOOR         = 191325,                       //_doors07
     GO_IONAR_DOOR           = 191326,                       //_doors05
     GO_LOKEN_DOOR           = 191324,                       //_doors02
     GO_LOKEN_THRONE         = 192654
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/instance_halls_of_lightning.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/instance_halls_of_lightning.cpp
index b22aa409f43..e9d75fb8b6f 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/instance_halls_of_lightning.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_lightning/instance_halls_of_lightning.cpp
@@ -13,46 +13,57 @@
  * along 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_Halls_of_Lightning
 SD%Complete: 90%
 SDComment: All ready.
 SDCategory: Halls of Lightning
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_halls_of_lightning.h"
+
 /* Halls of Lightning encounters:
 0 - General Bjarngrim
 1 - Volkhan
 2 - Ionar
 3 - Loken
 */
+
 struct TRINITY_DLL_DECL instance_halls_of_lightning : public ScriptedInstance
 {
     instance_halls_of_lightning(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     uint64 m_uiGeneralBjarngrimGUID;
     uint64 m_uiIonarGUID;
     uint64 m_uiLokenGUID;
     uint64 m_uiVolkhanGUID;
+
     uint64 m_uiBjarngrimDoorGUID;
     uint64 m_uiVolkhanDoorGUID;
     uint64 m_uiIonarDoorGUID;
     uint64 m_uiLokenDoorGUID;
     uint64 m_uiLokenGlobeGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         m_uiGeneralBjarngrimGUID = 0;
         m_uiVolkhanGUID          = 0;
         m_uiIonarGUID            = 0;
         m_uiLokenGUID            = 0;
+
         m_uiBjarngrimDoorGUID    = 0;
         m_uiVolkhanDoorGUID      = 0;
         m_uiIonarDoorGUID        = 0;
         m_uiLokenDoorGUID        = 0;
         m_uiLokenGlobeGUID       = 0;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -71,6 +82,7 @@ struct TRINITY_DLL_DECL instance_halls_of_lightning : public ScriptedInstance
                 break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -100,6 +112,7 @@ struct TRINITY_DLL_DECL instance_halls_of_lightning : public ScriptedInstance
                 break;
         }
     }
+
     void SetData(uint32 uiType, uint32 uiData)
     {
         switch(uiType)
@@ -123,6 +136,7 @@ struct TRINITY_DLL_DECL instance_halls_of_lightning : public ScriptedInstance
                 if (uiData == DONE)
                 {
                     DoUseDoorOrButton(m_uiLokenDoorGUID);
+
                     //Appears to be type 5 GO with animation. Need to figure out how this work, code below only placeholder
                     if (GameObject* pGlobe = instance->GetGameObject(m_uiLokenGlobeGUID))
                         pGlobe->SetGoState(GO_STATE_ACTIVE);
@@ -131,6 +145,7 @@ struct TRINITY_DLL_DECL instance_halls_of_lightning : public ScriptedInstance
                 break;
         }
     }
+
     uint32 GetData(uint32 uiType)
     {
         switch(uiType)
@@ -146,6 +161,7 @@ struct TRINITY_DLL_DECL instance_halls_of_lightning : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 uiData)
     {
         switch(uiData)
@@ -162,10 +178,12 @@ struct TRINITY_DLL_DECL instance_halls_of_lightning : public ScriptedInstance
         return 0;
     }
 };
+
 InstanceData* GetInstanceData_instance_halls_of_lightning(Map* pMap)
 {
     return new instance_halls_of_lightning(pMap);
 }
+
 void AddSC_instance_halls_of_lightning()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_krystallus.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_krystallus.cpp
index 4d6aef7c122..ed5291a6887 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_krystallus.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_krystallus.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_krystallus' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_halls_of_stone.h"
+
 enum Spells
 {
     SPELL_BOULDER_TOSS                             = 50843,
@@ -21,6 +23,7 @@ enum Spells
     SPELL_STOMP                                    = 48131,
     H_SPELL_STOMP                                  = 59744
 };
+
 enum Yells
 {
     SAY_AGGRO                                   = -1603007,
@@ -28,58 +31,71 @@ enum Yells
     SAY_DEATH                                   = -1603009,
     SAY_SHATTER                                 = -1603010
 };
+
 struct TRINITY_DLL_DECL boss_krystallusAI : public ScriptedAI
 {
     boss_krystallusAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiBoulderTossTimer;
     uint32 uiGroundSpikeTimer;
     uint32 uiGroundSlamTimer;
     uint32 uiShatterTimer;
     uint32 uiStompTimer;
+
     bool bIsSlam;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         bIsSlam = false;
+
         uiBoulderTossTimer = 3000 + rand()%6000;
         uiGroundSpikeTimer = 9000 + rand()%5000;
         uiGroundSlamTimer = 15000 + rand()%3000;
         uiStompTimer = 20000 + rand()%9000;
         uiShatterTimer = 0;
+
         if (pInstance)
             pInstance->SetData(DATA_KRYSTALLUS_EVENT, NOT_STARTED);
     }
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_KRYSTALLUS_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiBoulderTossTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 DoCast(pTarget, HEROIC(SPELL_BOULDER_TOSS, H_SPELL_BOULDER_TOSS));
             uiBoulderTossTimer = 9000 + rand()%6000;
         } else uiBoulderTossTimer -= diff;
+
         if (uiGroundSpikeTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 DoCast(pTarget, SPELL_GROUND_SPIKE);
             uiGroundSpikeTimer = 12000 + rand()%5000;
         } else uiGroundSpikeTimer -= diff;
+
         if (uiStompTimer < diff)
         {
             DoCast(m_creature, HEROIC(SPELL_STOMP, H_SPELL_STOMP));
             uiStompTimer = 20000 + rand()%9000;
         } else uiStompTimer -= diff;
+
         if (uiGroundSlamTimer < diff)
         {
             DoCast(m_creature, SPELL_GROUND_SLAM);
@@ -87,6 +103,7 @@ struct TRINITY_DLL_DECL boss_krystallusAI : public ScriptedAI
             uiShatterTimer = 10000;
             uiGroundSlamTimer = 15000 + rand()%3000;
         } else uiGroundSlamTimer -= diff;
+
         if (bIsSlam)
         {
             if(uiShatterTimer < diff)
@@ -95,14 +112,18 @@ struct TRINITY_DLL_DECL boss_krystallusAI : public ScriptedAI
                 bIsSlam = false;
             } else uiShatterTimer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_KRYSTALLUS_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
@@ -110,13 +131,16 @@ struct TRINITY_DLL_DECL boss_krystallusAI : public ScriptedAI
         DoScriptText(SAY_KILL, m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_krystallus(Creature* pCreature)
 {
     return new boss_krystallusAI (pCreature);
 }
+
 void AddSC_boss_krystallus()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_krystallus";
     newscript->GetAI = &GetAI_boss_krystallus;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_maiden_of_grief.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_maiden_of_grief.cpp
index 2b8cceb14e8..f8fcd720dfa 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_maiden_of_grief.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_maiden_of_grief.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_maiden_of_grief' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_halls_of_stone.h"
+
 enum Spells
 {
     SPELL_PARTING_SORROW                                = 59723,
@@ -20,6 +22,7 @@ enum Spells
     SPELL_PILLAR_OF_WOE_N                               = 50761,
     SPELL_PILLAR_OF_WOE_H                               = 59727
 };
+
 enum Yells
 {
     SAY_AGGRO                                        = -1603000,
@@ -30,10 +33,12 @@ enum Yells
     SAY_DEATH                                        = -1603005,
     SAY_STUN                                         = -1603006
 };
+
 enum Achievements
 {
     ACHIEVEMENT_GOOD_GRIEF                           = 1866
 };
+
 struct TRINITY_DLL_DECL boss_maiden_of_griefAI : public ScriptedAI
 {
     boss_maiden_of_griefAI(Creature *c) : ScriptedAI(c)
@@ -41,13 +46,16 @@ struct TRINITY_DLL_DECL boss_maiden_of_griefAI : public ScriptedAI
         pInstance = m_creature->GetInstanceData();
         IsHeroic = m_creature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool IsHeroic;
+
     uint32 PartingSorrowTimer;
     uint32 StormOfGriefTimer;
     uint32 ShockOfSorrowTimer;
     uint32 PillarOfWoeTimer;
     uint32 AchievTimer;
+
     void Reset()
     {
         PartingSorrowTimer = 25000 + rand()%5000;
@@ -55,39 +63,49 @@ struct TRINITY_DLL_DECL boss_maiden_of_griefAI : public ScriptedAI
         ShockOfSorrowTimer = 20000+rand()%5000;
         PillarOfWoeTimer = 5000 + rand()%10000;
         AchievTimer = 0;
+
         if (pInstance)
             pInstance->SetData(DATA_MAIDEN_OF_GRIEF_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_MAIDEN_OF_GRIEF_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Achievement counter
         if (pInstance)
             if (pInstance->GetData(DATA_MAIDEN_OF_GRIEF_EVENT) == IN_PROGRESS)
                 AchievTimer += diff;
+
         if(IsHeroic)
         {
             if (PartingSorrowTimer < diff)
             {
                 Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
+
                 if(target)
                     DoCast(target,SPELL_PARTING_SORROW);
+
                 PartingSorrowTimer = 30000 + rand()%10000;
             }else PartingSorrowTimer -= diff;
         }
+
         if (StormOfGriefTimer < diff)
         {
             DoCast(m_creature->getVictim(),IsHeroic ? SPELL_STORM_OF_GRIEF_H : SPELL_STORM_OF_GRIEF_N, true);
             StormOfGriefTimer = 15000 + rand()%5000;
         }else StormOfGriefTimer -= diff;
+
         if (ShockOfSorrowTimer < diff)
         {
             DoResetThreat();
@@ -95,28 +113,35 @@ struct TRINITY_DLL_DECL boss_maiden_of_griefAI : public ScriptedAI
             DoCast(m_creature,IsHeroic ? SPELL_SHOCK_OF_SORROW_H : SPELL_SHOCK_OF_SORROW_N);
             ShockOfSorrowTimer = 20000 + rand()%10000;
         }else ShockOfSorrowTimer -= diff;
+
         if (PillarOfWoeTimer < diff)
         {
             Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1);
+
             if(target)
                 DoCast(target,IsHeroic ? SPELL_PILLAR_OF_WOE_H : SPELL_PILLAR_OF_WOE_N);
             else
                 DoCast(m_creature->getVictim(),IsHeroic ? SPELL_PILLAR_OF_WOE_H : SPELL_PILLAR_OF_WOE_N);
+
             PillarOfWoeTimer = 5000 + rand()%20000;
         }else PillarOfWoeTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_MAIDEN_OF_GRIEF_EVENT, DONE);
+
         AchievementEntry const *AchievGoodGrief = GetAchievementStore()->LookupEntry(ACHIEVEMENT_GOOD_GRIEF);
         Map* pMap = m_creature->GetMap();
+
         if (HeroicMode && AchievTimer < 60000 && pMap && pMap->IsDungeon() && AchievGoodGrief)
         {
             Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievGoodGrief);
         }
     }
@@ -124,16 +149,20 @@ struct TRINITY_DLL_DECL boss_maiden_of_griefAI : public ScriptedAI
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3,SAY_SLAY_4), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_maiden_of_grief(Creature* pCreature)
 {
     return new boss_maiden_of_griefAI (pCreature);
 }
+
 void AddSC_boss_maiden_of_grief()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_maiden_of_grief";
     newscript->GetAI = &GetAI_boss_maiden_of_grief;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_sjonnir.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_sjonnir.cpp
index c093da581c6..69061ad1d1f 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_sjonnir.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/boss_sjonnir.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_sjonnir' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_halls_of_stone.h"
+
 enum Spells
 {
     SPELL_LIGHTING_RING                        = 51849, //Periodic Trigger (interval 2s) spell = 50841
@@ -24,6 +26,7 @@ enum Spells
     H_SPELL_LIGHTING_SHIELD                    = 59845,
     SPELL_FRENZY                               = 28747
 };
+
 enum Yells
 {
     SAY_AGGRO                               = -1603011,
@@ -32,7 +35,9 @@ enum Yells
     SAY_SLAY_3                              = -1603014,
     SAY_DEATH                               = -1603015
 };
+
 #define EMOTE_GENERIC_FRENZY                  -1000002
+
 enum Creatures
 {
     CREATURE_FORGED_IRON_TROGG              = 27979,
@@ -40,28 +45,35 @@ enum Creatures
     CREATURE_FORGED_IRON_DWARF              = 27982,
     CREATURE_IRON_SLUDGE                    = 28165
 };
+
 enum Misc
 {
     DATA_TIME_BEFORE_OOZE                   = 150000, //2min 30 secs
     ACHIEVEMENT_ABUSE_THE_OOZE              = 2155
 };
+
 struct Locations
 {
     float x, y, z;
 };
+
 static Locations PipeLocations[] =
 {
   {1295.44, 734.07, 200.3}, //left
   {1297.7,  595.6,  199.9} //right
 };
+
 static Locations CenterPoint = {1295.21, 667.157, 189.691};
+
 struct TRINITY_DLL_DECL boss_sjonnirAI : public ScriptedAI
 {
     boss_sjonnirAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     bool bIsFrenzy;
+
     uint32 uiChainLightningTimer;
     uint32 uiLightningShieldTimer;
     uint32 uiStaticChargeTimer;
@@ -70,10 +82,13 @@ struct TRINITY_DLL_DECL boss_sjonnirAI : public ScriptedAI
     uint32 uiFrenzyTimer;
     uint32 uiEncounterTimer;
     uint32 uiKilledIronSludges;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         bIsFrenzy = false;
+
         uiEncounterTimer = 0;
         uiChainLightningTimer = 3000 + rand()%5000;
         uiLightningShieldTimer = 20000 + rand()%5000;
@@ -82,37 +97,46 @@ struct TRINITY_DLL_DECL boss_sjonnirAI : public ScriptedAI
         uiSummonTimer = 5000;
         uiFrenzyTimer = 300000; //5 minutes
         uiKilledIronSludges = 0;
+
         if (pInstance)
             pInstance->SetData(DATA_SJONNIR_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         uiEncounterTimer = 0;
+
         if (pInstance)
             pInstance->SetData(DATA_SJONNIR_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiChainLightningTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 DoCast(pTarget, HEROIC(SPELL_CHAIN_LIGHTING, H_SPELL_CHAIN_LIGHTING));
             uiChainLightningTimer = 10000 + rand()%5000;
         } else uiChainLightningTimer -= diff;
+
         if (uiLightningShieldTimer < diff)
         {
             DoCast(m_creature, HEROIC(SPELL_LIGHTING_SHIELD, H_SPELL_LIGHTING_SHIELD));
             uiLightningShieldTimer -= diff;
         }
+
         if (uiStaticChargeTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_STATIC_CHARGE, H_SPELL_STATIC_CHARGE));
             uiStaticChargeTimer = 20000 + rand()%5000;
         } uiStaticChargeTimer -= diff;
+
         if (uiLightningRingTimer < diff)
         {
             if (m_creature->IsNonMeleeSpellCasted(false))
@@ -120,6 +144,7 @@ struct TRINITY_DLL_DECL boss_sjonnirAI : public ScriptedAI
             DoCast(m_creature, HEROIC(SPELL_LIGHTING_RING, H_SPELL_LIGHTING_RING));
             uiLightningRingTimer = 30000 + rand()%5000;
         } else uiLightningRingTimer -= diff;
+
         if (uiSummonTimer < diff)
         {
             uint32 uiSummonPipe = rand()%2;
@@ -129,6 +154,7 @@ struct TRINITY_DLL_DECL boss_sjonnirAI : public ScriptedAI
                                        TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
             uiSummonTimer = 20000;
         } else uiSummonTimer -= diff;
+
         if (!bIsFrenzy)
         {
           if (uiFrenzyTimer < diff)
@@ -138,18 +164,23 @@ struct TRINITY_DLL_DECL boss_sjonnirAI : public ScriptedAI
           }
           else uiFrenzyTimer -= diff;
         }
+
         uiEncounterTimer +=diff;
+
         DoMeleeAttackIfReady();
     }
+
     void JustSummoned(Creature* summon)
     {
         summon->GetMotionMaster()->MovePoint(0, CenterPoint.x, CenterPoint.y, CenterPoint.z);
         /*if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
             summon->AI()->AttackStart(pTarget);*/
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (HeroicMode && uiKilledIronSludges > 4)
         {
             AchievementEntry const *AchievAbuseTheOoze = GetAchievementStore()->LookupEntry(ACHIEVEMENT_ABUSE_THE_OOZE);
@@ -159,11 +190,12 @@ struct TRINITY_DLL_DECL boss_sjonnirAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievAbuseTheOoze);
                 }
             }
         }
+
         if (pInstance)
             pInstance->SetData(DATA_SJONNIR_EVENT, DONE);
     }
@@ -173,25 +205,31 @@ struct TRINITY_DLL_DECL boss_sjonnirAI : public ScriptedAI
             return;
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void KilledIronSludge()
     {
         ++uiKilledIronSludges;
     }
 };
+
 CreatureAI* GetAI_boss_sjonnir(Creature* pCreature)
 {
     return new boss_sjonnirAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_malformed_oozeAI : public ScriptedAI
 {
     mob_malformed_oozeAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 uiMergeTimer;
     bool bIsMerging;
+
     void Reset()
     {
         uiMergeTimer = 5000;
         bIsMerging = false;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (bIsMerging)
@@ -206,10 +244,13 @@ struct TRINITY_DLL_DECL mob_malformed_oozeAI : public ScriptedAI
                 } else bIsMerging = false;
             } else uiMergeTimer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if(type != POINT_MOTION_TYPE)
@@ -217,17 +258,21 @@ struct TRINITY_DLL_DECL mob_malformed_oozeAI : public ScriptedAI
         bIsMerging = true;
     }
 };
+
 CreatureAI* GetAI_mob_malformed_ooze(Creature* pCreature)
 {
     return new mob_malformed_oozeAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_iron_sludgeAI : public ScriptedAI
 {
     mob_iron_sludgeAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     void JustDied(Unit* pKiller)
     {
         if (pInstance)
@@ -235,21 +280,26 @@ struct TRINITY_DLL_DECL mob_iron_sludgeAI : public ScriptedAI
                 CAST_AI(boss_sjonnirAI, pSjonnir->AI())->KilledIronSludge();
     }
 };
+
 CreatureAI* GetAI_mob_iron_sludge(Creature* pCreature)
 {
     return new mob_iron_sludgeAI(pCreature);
 }
+
 void AddSC_boss_sjonnir()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_sjonnir";
     newscript->GetAI = &GetAI_boss_sjonnir;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_malformed_ooze";
     newscript->GetAI = &GetAI_mob_malformed_ooze;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_iron_sludge";
     newscript->GetAI = &GetAI_mob_iron_sludge;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/halls_of_stone.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/halls_of_stone.cpp
index 3501bc56e3b..0681b376f4e 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/halls_of_stone.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/halls_of_stone.cpp
@@ -1,6 +1,7 @@
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "def_halls_of_stone.h"
+
 enum Texts
 {
     SAY_KILL_1                          = -1603016,
@@ -12,26 +13,33 @@ enum Texts
     SAY_PLAYER_DEATH_2                  = -1603022,
     SAY_PLAYER_DEATH_3                  = -1603023,
     SAY_ESCORT_START                    = -1603024,
+
     SAY_SPAWN_DWARF                     = -1603025,
     SAY_SPAWN_TROGG                     = -1603026,
     SAY_SPAWN_OOZE                      = -1603027,
     SAY_SPAWN_EARTHEN                   = -1603028,
+
     SAY_EVENT_INTRO_1                   = -1603029,
     SAY_EVENT_INTRO_2                   = -1603030,
     SAY_EVENT_INTRO_3_ABED              = -1603031,
+
     SAY_EVENT_A_1                       = -1603032,
     SAY_EVENT_A_2_KADD                  = -1603033,
     SAY_EVENT_A_3                       = -1603034,
+
     SAY_EVENT_B_1                       = -1603035,
     SAY_EVENT_B_2_MARN                  = -1603036,
     SAY_EVENT_B_3                       = -1603037,
+
     SAY_EVENT_C_1                       = -1603038,
     SAY_EVENT_C_2_ABED                  = -1603039,
     SAY_EVENT_C_3                       = -1603040,
+
     SAY_EVENT_D_1                       = -1603041,
     SAY_EVENT_D_2_ABED                  = -1603042,
     SAY_EVENT_D_3                       = -1603043,
     SAY_EVENT_D_4_ABED                  = -1603044,
+
     SAY_EVENT_END_01                    = -1603045,
     SAY_EVENT_END_02                    = -1603046,
     SAY_EVENT_END_03_ABED               = -1603047,
@@ -53,12 +61,16 @@ enum Texts
     SAY_EVENT_END_19_MARN               = -1603063,
     SAY_EVENT_END_20                    = -1603064,
     SAY_EVENT_END_21_ABED               = -1603065,
+
     SAY_VICTORY_SJONNIR_1               = -1603066,
     SAY_VICTORY_SJONNIR_2               = -1603067,
+
     SAY_ENTRANCE_MEET                   = -1603068,
+
     TEXT_ID_START                       = 13100,
     TEXT_ID_PROGRESS                    = 13101
 };
+
 enum Creatures
 {
     CREATURE_TRIBUNAL_OF_THE_AGES       = 28234,
@@ -70,6 +82,7 @@ enum Creatures
     CREATURE_IRON_GOLEM_CUSTODIAN       = 27985,
     CREATURE_KADDRAK                    = 30898
 };
+
 enum Spells
 {
     SPELL_STEALTH                       = 58506,
@@ -83,21 +96,26 @@ enum Spells
     SPELL_SEARING_GAZE                  = 51136,
     H_SPELL_SEARING_GAZE                = 59867
 };
+
 enum Quests
 {
     QUEST_HALLS_OF_STONE                = 13207
 };
+
 #define GOSSIP_ITEM_START               "Brann, it would be our honor!"
 #define GOSSIP_ITEM_PROGRESS            "Let's move Brann, enough of the history lessons!"
+
 struct Locations
 {
     float x, y, z;
 };
+
 static Locations SpawnLocations[]=
 {
     {946.992, 397.016, 208.374},
     {960.748, 382.944, 208.374},
 };
+
 struct TRINITY_DLL_DECL mob_tribuna_controllerAI : public ScriptedAI
 {
     mob_tribuna_controllerAI(Creature *c) : ScriptedAI(c)
@@ -105,31 +123,39 @@ struct TRINITY_DLL_DECL mob_tribuna_controllerAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         SetCombatMovement(false);
     }
+
     ScriptedInstance* pInstance;
+
     uint32 uiKaddrakEncounterTimer;
     uint32 uiMarnakEncounterTimer;
     uint32 uiAbedneumEncounterTimer;
+
     bool bKaddrakActivated;
     bool bMarnakActivated;
     bool bAbedneumActivated;
+
     std::list lKaddrakGUIDList;
+
     void Reset()
     {
         uiKaddrakEncounterTimer = 1500;
         uiMarnakEncounterTimer = 10000;
         uiAbedneumEncounterTimer = 10000;
+
         bKaddrakActivated = false;
         bMarnakActivated = false;
         bAbedneumActivated = false;
+
         lKaddrakGUIDList.clear();
     }
+
     void UpdateFacesList()
    {
         /*GetCreatureListWithEntryInGrid(lKaddrakGUIDList, m_creature, CREATURE_KADDRAK, 50.0f);
         if (!lKaddrakGUIDList.empty())
         {
             uint32 uiPositionCounter = 0;
-            for (std::list::iterator itr = lKaddrakGUIDList.begin(); itr != lKaddrakGUIDList.end(); ++itr)
+            for(std::list::iterator itr = lKaddrakGUIDList.begin(); itr != lKaddrakGUIDList.end(); ++itr)
             {
                 if ((*itr)->isAlive())
                 {
@@ -148,6 +174,7 @@ struct TRINITY_DLL_DECL mob_tribuna_controllerAI : public ScriptedAI
             }
         }*/
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(bKaddrakActivated)
@@ -196,19 +223,25 @@ struct TRINITY_DLL_DECL mob_tribuna_controllerAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI
 {
     npc_brann_hosAI(Creature *c) : npc_escortAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiStep;
     uint32 uiPhaseTimer;
+
     uint64 uiControllerGUID;
     std::list lDwarfGUIDList;
+
     ScriptedInstance* pInstance;
+
     bool bIsBattle;
     bool bIsLowHP;
+
     void Reset()
     {
         if (!HasEscortState(STATE_ESCORT_ESCORTING))
@@ -218,11 +251,14 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI
             uiStep = 0;
             uiPhaseTimer = 0;
             uiControllerGUID = 0;
+
             DespawnDwarf();
+
             if (pInstance)
                 pInstance->SetData(DATA_BRANN_EVENT, NOT_STARTED);
         }
     }
+
     void DespawnDwarf()
     {
         if (lDwarfGUIDList.empty())
@@ -235,6 +271,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI
         }
         lDwarfGUIDList.clear();
     }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
@@ -267,6 +304,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI
                 break;
         }
      }
+
      void SpawnDwarf(uint32 uiType)
      {
        switch(uiType)
@@ -288,17 +326,20 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI
                break;
        }
      }
+
     void JustSummoned(Creature* pSummoned)
     {
         lDwarfGUIDList.push_back(pSummoned->GetGUID());
         pSummoned->AddThreat(m_creature, 0.0f);
         pSummoned->AI()->AttackStart(m_creature);
     }
+
     void JumpToNextStep(uint32 uiTimer)
     {
       uiPhaseTimer = uiTimer;
       uiStep++;
     }
+
     void StartWP()
     {
         m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
@@ -306,6 +347,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI
         uiStep = 1;
         Start();
     }
+
     void UpdateEscortAI(const uint32 uiDiff)
     {
         if (uiPhaseTimer < uiDiff)
@@ -584,6 +626,7 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI
                     break;
             }
         } else uiPhaseTimer -= uiDiff;
+
         if (!bIsLowHP && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 30)
         {
             DoScriptText(SAY_LOW_HEALTH, m_creature);
@@ -592,14 +635,18 @@ struct TRINITY_DLL_DECL npc_brann_hosAI : public npc_escortAI
             bIsLowHP = false;
     }
 };
+
 bool GossipHello_npc_brann_hos(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_START, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     pPlayer->SEND_GOSSIP_MENU(TEXT_ID_START, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_brann_hos(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1 || uiAction == GOSSIP_ACTION_INFO_DEF+2)
@@ -607,25 +654,31 @@ bool GossipSelect_npc_brann_hos(Player* pPlayer, Creature* pCreature, uint32 uiS
         pPlayer->CLOSE_GOSSIP_MENU();
         ((npc_brann_hosAI*)pCreature->AI())->StartWP();
     }
+
     return true;
 }
+
 CreatureAI* GetAI_mob_tribuna_controller(Creature* pCreature)
 {
     return new mob_tribuna_controllerAI(pCreature);
 }
+
 CreatureAI* GetAI_npc_brann_hos(Creature* pCreature)
 {
     return new npc_brann_hosAI(pCreature);
 }
+
 void AddSC_halls_of_stone()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_brann_hos";
     newscript->GetAI = &GetAI_npc_brann_hos;
     newscript->pGossipHello = &GossipHello_npc_brann_hos;
     newscript->pGossipSelect = &GossipSelect_npc_brann_hos;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_tribuna_controller";
     newscript->GetAI = &GetAI_mob_tribuna_controller;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/instance_halls_of_stone.cpp b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/instance_halls_of_stone.cpp
index 8e7bf896803..85d9367ae1d 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/instance_halls_of_stone.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/halls_of_stone/instance_halls_of_stone.cpp
@@ -1,22 +1,28 @@
 #include "precompiled.h"
 #include "def_halls_of_stone.h"
+
 #define MAX_ENCOUNTER 4
+
 /* Halls of Stone encounters:
 0- Krystallus
 1- Maiden of Grief
 2- Escort Event
 3- Sjonnir The Ironshaper
 */
+
 struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
 {
     instance_halls_of_stone(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 uiMaidenOfGrief;
     uint64 uiKrystallus;
     uint64 uiSjonnir;
+
     uint64 uiKaddrak;
     uint64 uiAbedneum;
     uint64 uiMarnak;
     uint64 uiBrann;
+
     uint64 uiMaidenOfGriefDoor;
     uint64 uiSjonnirDoor;
     uint64 uiBrannDoor;
@@ -26,17 +32,22 @@ struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
     uint64 uiKaddrakGo;
     uint64 uiAbedneumGo;
     uint64 uiMarnakGo;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     std::string str_data;
+
     void Initialize()
     {
         uiMaidenOfGrief = 0;
         uiKrystallus = 0;
         uiSjonnir = 0;
+
         uiKaddrak = 0;
         uiMarnak = 0;
         uiAbedneum = 0;
         uiBrann = 0;
+
         uiMaidenOfGriefDoor = 0;
         uiSjonnirDoor = 0;
         uiBrannDoor = 0;
@@ -46,9 +57,11 @@ struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
         uiTribunalConsole = 0;
         uiTribunalChest = 0;
         uiTribunalSkyFloor = 0;
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             m_auiEncounter[i] = NOT_STARTED;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -62,6 +75,7 @@ struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
             case 28070: uiBrann = pCreature->GetGUID(); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -107,6 +121,7 @@ struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
                 break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -130,9 +145,11 @@ struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
                     HandleGameObject(uiSjonnirDoor,true);
                 break;
         }
+
         if (data == DONE)
             SaveToDB();
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -142,8 +159,10 @@ struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
             case DATA_SJONNIR_EVENT:                   return m_auiEncounter[2];
             case DATA_BRANN_EVENT:                     return m_auiEncounter[3];
         }
+
         return 0;
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -160,17 +179,23 @@ struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
             case DATA_GO_MARNAK:                       return uiMarnakGo;
             case DATA_GO_SKY_FLOOR:                    return uiTribunalSkyFloor;
         }
+
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::ostringstream saveStream;
         saveStream << "H S " << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " << m_auiEncounter[3];
+
         str_data = saveStream.str();
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -178,28 +203,37 @@ struct TRINITY_DLL_DECL instance_halls_of_stone : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         char dataHead1, dataHead2;
         uint16 data0, data1, data2, data3;
+
         std::istringstream loadStream(in);
         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3;
+
         if (dataHead1 == 'H' && dataHead2 == 'S')
         {
             m_auiEncounter[0] = data0;
             m_auiEncounter[1] = data1;
             m_auiEncounter[2] = data2;
             m_auiEncounter[3] = data3;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 if (m_auiEncounter[i] == IN_PROGRESS)
                     m_auiEncounter[i] = NOT_STARTED;
+
         } else OUT_LOAD_INST_DATA_FAIL;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_halls_of_stone(Map* pMap)
 {
     return new instance_halls_of_stone(pMap);
 }
+
 void AddSC_instance_halls_of_stone()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_algalon.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_algalon.cpp
index b28c71f645d..a736b2db12a 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_algalon.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_algalon.cpp
@@ -15,5 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_assembly_of_iron.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_assembly_of_iron.cpp
index 9f529b04ebb..df03ff9eff7 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_assembly_of_iron.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_assembly_of_iron.cpp
@@ -15,17 +15,21 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Assembly of Iron encounter
 SD%Complete: 60%
 SDComment: Runes need DB support, chain lightning won't cast, supercharge won't cast (target error?) - it worked before during debugging.
 SDCategory: Ulduar - Ulduar
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 // Any boss
 #define SPELL_SUPERCHARGE   61920
 #define SPELL_BERSERK       47008   // Hard enrage, don't know the correct ID.
+
 // Steelbreaker
 #define SPELL_HIGH_VOLTAGE           61890
 #define SPELL_HIGH_VOLTAGE_H         63498
@@ -36,6 +40,7 @@ EndScriptData */
 #define SPELL_OVERWHELMING_POWER_H   61888
 #define SPELL_OVERWHELMING_POWER     64637
 #define SPELL_ELECTRICAL_CHARGE      61902
+
 // Runemaster Molgeim
 #define SPELL_SHIELD_OF_RUNES        62274
 #define SPELL_SHIELD_OF_RUNES_H      63489
@@ -45,6 +50,7 @@ EndScriptData */
 #define SPELL_LIGHTNING_BLAST        62054
 #define SPELL_LIGHTNING_BLAST_H      63491
 #define CREATURE_RUNE_OF_SUMMONING   33051
+
 // Stormcaller Brundir
 #define SPELL_CHAIN_LIGHTNING_N      61879
 #define SPELL_CHAIN_LIGHTNING_H      63479
@@ -56,6 +62,8 @@ EndScriptData */
 #define SPELL_LIGHTNING_TENDRILS_H   63486
 #define SPELL_STORMSHIELD            64187
 
+
+
 enum eEnums
 {
     EVENT_ENRAGE,
@@ -76,21 +84,27 @@ enum eEnums
     EVENT_LIGHTNING_TENDRILS,
     EVENT_STORMSHIELD,
     MAX_EVENT
+
 };
 
+
+
 bool IsEncounterComplete(ScriptedInstance* pInstance, Creature* m_creature)
 {
    if (!pInstance || !m_creature)
         return false;
-    for (uint8 i = 0; i < 3; ++i)
+
+    for(uint8 i = 0; i < 3; ++i)
     {
         uint64 guid = pInstance->GetData64(DATA_STEELBREAKER+i);
         if(!guid)
             return false;
+
         if(Creature *boss = (Unit::GetCreature((*m_creature), guid)))
         {
             if(boss->isAlive())
                 return false;
+
             continue;
         }
         else
@@ -98,12 +112,14 @@ bool IsEncounterComplete(ScriptedInstance* pInstance, Creature* m_creature)
     }
     return true;
 }
+
 struct TRINITY_DLL_DECL boss_steelbreakerAI : public ScriptedAI
 {
     boss_steelbreakerAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     void Reset()
     {
         events.Reset();
@@ -112,9 +128,11 @@ struct TRINITY_DLL_DECL boss_steelbreakerAI : public ScriptedAI
         if(pInstance)
             pInstance->SetData(TYPE_ASSEMBLY, NOT_STARTED);
     }
+
     EventMap events;
     ScriptedInstance* pInstance;
     uint32 phase;
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
@@ -122,6 +140,7 @@ struct TRINITY_DLL_DECL boss_steelbreakerAI : public ScriptedAI
         events.ScheduleEvent(EVENT_ENRAGE, 900000);
         UpdatePhase();
     }
+
     void UpdatePhase()
     {
         ++phase;
@@ -132,6 +151,7 @@ struct TRINITY_DLL_DECL boss_steelbreakerAI : public ScriptedAI
         if(phase >= 3)
             events.RescheduleEvent(EVENT_OVERWHELMING_POWER, rand()%5000);
     }
+
     void DamageTaken(Unit* pKiller, uint32 &damage)
     {
         if(damage >= m_creature->GetHealth())
@@ -141,6 +161,7 @@ struct TRINITY_DLL_DECL boss_steelbreakerAI : public ScriptedAI
                 {
                     Brundir->SetHealth(Brundir->GetMaxHealth());
                 }
+
             if(Creature* Molgeim = Unit::GetCreature(*m_creature, pInstance ? pInstance->GetData64(DATA_RUNEMASTER_MOLGEIM) : 0))
                 if(Molgeim->isAlive())
                 {
@@ -149,26 +170,32 @@ struct TRINITY_DLL_DECL boss_steelbreakerAI : public ScriptedAI
              DoCast(SPELL_SUPERCHARGE);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if(IsEncounterComplete(pInstance, m_creature) && pInstance)
             pInstance->SetData(TYPE_ASSEMBLY, DONE);
     }
+
     void KilledUnit(Unit *who)
     {
         if(phase == 3)
             DoCast(m_creature, SPELL_ELECTRICAL_CHARGE);
     }
+
     void SpellHit(Unit *from, const SpellEntry *spell)
     {
         if(spell->Id == SPELL_SUPERCHARGE)
             UpdatePhase();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -193,15 +220,18 @@ struct TRINITY_DLL_DECL boss_steelbreakerAI : public ScriptedAI
                 break;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_runemaster_molgeimAI : public ScriptedAI
 {
     boss_runemaster_molgeimAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     void Reset()
     {
         if(pInstance)
@@ -210,15 +240,18 @@ struct TRINITY_DLL_DECL boss_runemaster_molgeimAI : public ScriptedAI
         m_creature->RemoveAllAuras();
         phase = 0;
     }
+
     ScriptedInstance* pInstance;
     EventMap events;
     uint32 phase;
+
     void EnterCombat(Unit* who)
     {
         DoZoneInCombat();
         events.ScheduleEvent(EVENT_ENRAGE, 900000);
         UpdatePhase();
     }
+
     void UpdatePhase()
     {
         ++phase;
@@ -230,6 +263,7 @@ struct TRINITY_DLL_DECL boss_runemaster_molgeimAI : public ScriptedAI
         if(phase >= 3)
             events.RescheduleEvent(EVENT_RUNE_OF_SUMMONING, 20000+(rand()%10)*1000);
     }
+
     void DamageTaken(Unit* pKiller, uint32 &damage)
     {
         if(damage >= m_creature->GetHealth())
@@ -239,6 +273,7 @@ struct TRINITY_DLL_DECL boss_runemaster_molgeimAI : public ScriptedAI
                 {
                     Steelbreaker->SetHealth(Steelbreaker->GetMaxHealth());
                 }
+
             if(Creature* Brundir = Unit::GetCreature((*m_creature), pInstance ? pInstance->GetData64(DATA_STORMCALLER_BRUNDIR) : 0))
                 if(Brundir->isAlive())
                 {
@@ -247,21 +282,26 @@ struct TRINITY_DLL_DECL boss_runemaster_molgeimAI : public ScriptedAI
             DoCast(m_creature, SPELL_SUPERCHARGE);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if(IsEncounterComplete(pInstance, m_creature) && pInstance)
             pInstance->SetData(TYPE_ASSEMBLY, DONE);
     }
+
     void SpellHit(Unit *from, const SpellEntry *spell)
     {
         if(spell->Id == SPELL_SUPERCHARGE)
             UpdatePhase();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -298,52 +338,64 @@ struct TRINITY_DLL_DECL boss_runemaster_molgeimAI : public ScriptedAI
                 break;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_lightning_elementalAI : public ScriptedAI
 {
     mob_lightning_elementalAI(Creature *c) : ScriptedAI(c)
     {
         Charge();
     }
+
     Unit* Target;
+
     void Charge()
     {
         Target = m_creature->SelectNearestTarget();
         m_creature->AddThreat(Target, 5000000.0f);
         AttackStart(Target);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(!m_creature->isInCombat())
             return;
+
         if(m_creature->IsWithinMeleeRange(Target))
         {
             DoCast(Target, HEROIC(SPELL_LIGHTNING_BLAST, SPELL_LIGHTNING_BLAST_H));
             m_creature->Kill(m_creature); // hack until spell works
         }
+
         m_creature->GetMotionMaster()->MoveChase(Target); // needed at every update?
     }
+
 };
+
 struct TRINITY_DLL_DECL mob_rune_of_summoningAI : public ScriptedAI
 {
     mob_rune_of_summoningAI(Creature *c) : ScriptedAI(c)
     {
         SummonLightningElemental();
     }
+
     void SummonLightningElemental()
     {
         m_creature->SummonCreature(CREATURE_RUNE_OF_SUMMONING, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN );
         m_creature->DealDamage(m_creature, m_creature->GetHealth());
     }
 };
+
 struct TRINITY_DLL_DECL boss_stormcaller_brundirAI : public ScriptedAI
 {
     boss_stormcaller_brundirAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     void Reset()
     {
         if(pInstance)
@@ -352,15 +404,18 @@ struct TRINITY_DLL_DECL boss_stormcaller_brundirAI : public ScriptedAI
         events.Reset();
         phase = 0;
     }
+
     EventMap events;
     ScriptedInstance* pInstance;
     uint32 phase;
+
     void EnterCombat(Unit* who)
     {
         DoZoneInCombat();
         events.ScheduleEvent(EVENT_ENRAGE, 900000);
         UpdatePhase();
     }
+
     void UpdatePhase()
     {
         ++phase;
@@ -374,7 +429,9 @@ struct TRINITY_DLL_DECL boss_stormcaller_brundirAI : public ScriptedAI
             DoCast(m_creature, SPELL_STORMSHIELD);
             events.RescheduleEvent(EVENT_LIGHTNING_TENDRILS, 40000+ (rand()%40)*1000);
         }
+
     }
+
     void DamageTaken(Unit* pKiller, uint32 &damage)
     {
         if(damage >= m_creature->GetHealth())
@@ -384,19 +441,23 @@ struct TRINITY_DLL_DECL boss_stormcaller_brundirAI : public ScriptedAI
                 {
                     Steelbreaker->SetHealth(Steelbreaker->GetMaxHealth());
                 }
+
             if(Creature* Molgeim = Unit::GetCreature(*m_creature, pInstance ? pInstance->GetData64(DATA_RUNEMASTER_MOLGEIM) : 0))
                 if(Molgeim->isAlive())
                 {
                     Molgeim->SetHealth(Molgeim->GetMaxHealth());
                 }
+
             DoCast(SPELL_SUPERCHARGE);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if(IsEncounterComplete(pInstance, m_creature) && pInstance)
             pInstance->SetData(TYPE_ASSEMBLY, DONE);
     }
+
     void SpellHit(Unit *from, const SpellEntry *spell)
     {
         if(spell->Id == SPELL_SUPERCHARGE)
@@ -404,11 +465,14 @@ struct TRINITY_DLL_DECL boss_stormcaller_brundirAI : public ScriptedAI
             UpdatePhase();
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -438,50 +502,63 @@ struct TRINITY_DLL_DECL boss_stormcaller_brundirAI : public ScriptedAI
                 break;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_steelbreaker(Creature* pCreature)
 {
     return new boss_steelbreakerAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_runemaster_molgeim(Creature* pCreature)
 {
     return new boss_runemaster_molgeimAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_stormcaller_brundir(Creature* pCreature)
 {
     return new boss_stormcaller_brundirAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_lightning_elemental(Creature* pCreature)
 {
     return new mob_lightning_elementalAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_rune_of_summoning(Creature* pCreature)
 {
     return new mob_rune_of_summoningAI (pCreature);
 }
+
 void AddSC_boss_assembly_of_iron()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_steelbreaker";
     newscript->GetAI = &GetAI_boss_steelbreaker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_runemaster_molgeim";
     newscript->GetAI = &GetAI_boss_runemaster_molgeim;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_stormcaller_brundir";
     newscript->GetAI = &GetAI_boss_stormcaller_brundir;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_lightning_elemental";
     newscript->GetAI = &GetAI_mob_lightning_elemental;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_rune_of_summoning";
     newscript->GetAI = &GetAI_mob_rune_of_summoning;
     newscript->RegisterSelf();
-}
+
+}
\ No newline at end of file
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_auriaya.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_auriaya.cpp
index 8199a914e2f..e4dedac54ac 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_auriaya.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_auriaya.cpp
@@ -15,8 +15,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 //boss_auriaya
 #define SPELL_TERRIFYING_SCREECH    64386
 #define SPELL_SONIC_BOOM            38897
@@ -24,20 +26,25 @@
 //beetwen -2000000 and -2999999 are custom texts so wtf?
 #define SAY_AGGRO                   -2615016
 #define SAY_SLAY_1                  -2615017
+
 struct TRINITY_DLL_DECL boss_auriaya_AI : public BossAI
 {
     boss_auriaya_AI(Creature *pCreature) : BossAI(pCreature, TYPE_AURIAYA)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     uint32 TERRIFYING_SCREECH_Timer;
     uint32 SONIC_BOOM_Timer;
+
     void Reset()
     {
         TERRIFYING_SCREECH_Timer = 0;
         SONIC_BOOM_Timer = 2000;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO,m_creature);
@@ -46,31 +53,39 @@ struct TRINITY_DLL_DECL boss_auriaya_AI : public BossAI
     {
         DoScriptText(SAY_SLAY_1, m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_SLAY_1, m_creature);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_AURIAYA, DONE);
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (TERRIFYING_SCREECH_Timer < diff)
         {
             DoCast(m_creature,SPELL_TERRIFYING_SCREECH);
             DoScriptText(SAY_SLAY_1, m_creature);
             TERRIFYING_SCREECH_Timer = 360000;
         } else TERRIFYING_SCREECH_Timer -= diff;
+
         if (SONIC_BOOM_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_SONIC_BOOM);
             SONIC_BOOM_Timer = 20000;
         } else SONIC_BOOM_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_auriaya(Creature* pCreature)
 {
     return new boss_auriaya_AI (pCreature);
@@ -78,6 +93,7 @@ CreatureAI* GetAI_boss_auriaya(Creature* pCreature)
 void AddSC_boss_auriaya()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_auriaya";
     newscript->GetAI = &GetAI_boss_auriaya;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp
index e16045c1877..1aa70290b69 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp
@@ -15,31 +15,43 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
 #include "Vehicle.h"
 
+
 #define SPELL_PURSUED           62374
 #define SPELL_GATHERING_SPEED   62375
 #define SPELL_BATTERING_RAM     62376
 #define SPELL_FLAME_VENTS       62396
 #define SPELL_MISSILE_BARRAGE   62400
 #define SPELL_SYSTEMS_SHUTDOWN  62475
+
 #define SPELL_FLAME_CANNON      62395
 //#define SPELL_FLAME_CANNON      64692 trigger the same spell
+
 #define SPELL_OVERLOAD_CIRCUIT  62399
+
 #define SPELL_SEARING_FLAME     62402
+
 #define SPELL_BLAZE             62292
+
 #define SPELL_SMOKE_TRAIL       63575
+
 #define SPELL_MIMIRON_INFERNO   62910
+
 #define SPELL_HODIR_FURY        62297
+
 #define SPELL_ELECTROSHOCK      62522
+
 enum Mobs
 {
     MOB_MECHANOLIFT = 33214,
     MOB_LIQUID      = 33189,
     MOB_CONTAINER   = 33218,
 };
+
 enum Events
 {
     EVENT_PURSUE = 1,
@@ -50,12 +62,14 @@ enum Events
     EVENT_MIMIRON_INFERNO, // Not Blizzlike
     EVENT_HODIR_FURY,      // Not Blizzlike
 };
+
 enum Seats
 {
     SEAT_PLAYER = 0,
     SEAT_TURRET = 1,
     SEAT_DEVICE = 2,
 };
+
 struct TRINITY_DLL_DECL boss_flame_leviathanAI : public BossAI
 {
     boss_flame_leviathanAI(Creature *pCreature) : BossAI(pCreature, TYPE_LEVIATHAN), vehicle(me->GetVehicleKit())
@@ -63,13 +77,17 @@ struct TRINITY_DLL_DECL boss_flame_leviathanAI : public BossAI
         m_pInstance = pCreature->GetInstanceData();
         assert(vehicle);
     }
+
     ScriptedInstance* m_pInstance;
+
     Vehicle *vehicle;
+
     void Reset()
     {
         _Reset();
         me->SetReactState(REACT_AGGRESSIVE);
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -84,17 +102,20 @@ struct TRINITY_DLL_DECL boss_flame_leviathanAI : public BossAI
         if (Creature *turret = CAST_CRE(vehicle->GetPassenger(7)))
             turret->AI()->DoZoneInCombat();
     }
+
     // TODO: effect 0 and effect 1 may be on different target
     void SpellHitTarget(Unit *target, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_PURSUED)
             AttackStart(target);
     }
+
     void JustDied(Unit *victim)
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_LEVIATHAN, DONE);
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if(spell->Id == 62472)
@@ -102,21 +123,27 @@ struct TRINITY_DLL_DECL boss_flame_leviathanAI : public BossAI
         else if(spell->Id == SPELL_ELECTROSHOCK)
             me->InterruptSpell(CURRENT_CHANNELED_SPELL);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!me->isInCombat())
             return;
+
         if (me->getThreatManager().isThreatListEmpty())
         {
             EnterEvadeMode();
             return;
         }
+
         events.Update(diff);
+
         if (me->hasUnitState(UNIT_STAT_CASTING))
             return;
+
         uint32 eventId = events.GetEvent();
         if (!me->getVictim())
             eventId = EVENT_PURSUE;
+
         switch(eventId)
         {
             case 0: break; // this is a must
@@ -158,10 +185,13 @@ struct TRINITY_DLL_DECL boss_flame_leviathanAI : public BossAI
                 events.PopEvent();
                 break;
         }
+
         DoSpellAttackIfReady(SPELL_BATTERING_RAM);
     }
 };
+
 //#define BOSS_DEBUG
+
 struct TRINITY_DLL_DECL boss_flame_leviathan_seatAI : public PassiveAI
 {
     boss_flame_leviathan_seatAI(Creature *c) : PassiveAI(c), vehicle(c->GetVehicleKit())
@@ -171,7 +201,9 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_seatAI : public PassiveAI
         me->SetReactState(REACT_AGGRESSIVE);
 #endif
     }
+
     Vehicle *vehicle;
+
 #ifdef BOSS_DEBUG
     void MoveInLineOfSight(Unit *who)
     {
@@ -180,14 +212,17 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_seatAI : public PassiveAI
             who->EnterVehicle(vehicle, SEAT_PLAYER);
     }
 #endif
+
     void PassengerBoarded(Unit *who, int8 seatId, bool apply)
     {
         if(!me->GetVehicle())
             return;
+
         if(seatId == SEAT_PLAYER)
         {
             if(!apply)
                 return;
+
             if(Creature *turret = CAST_CRE(vehicle->GetPassenger(SEAT_TURRET)))
             {
                 turret->setFaction(me->GetVehicleBase()->getFaction());
@@ -204,6 +239,7 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_seatAI : public PassiveAI
         {
             if(apply)
                 return;
+
             if(Unit *device = vehicle->GetPassenger(SEAT_DEVICE))
             {
                 device->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
@@ -212,14 +248,17 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_seatAI : public PassiveAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL boss_flame_leviathan_defense_turretAI : public TurretAI
 {
     boss_flame_leviathan_defense_turretAI(Creature *c) : TurretAI(c) {}
+
     void DamageTaken(Unit *who, uint32 &damage)
     {
         if(!CanAIAttack(who))
             damage = 0;
     }
+
     bool CanAIAttack(const Unit *who) const
     {
         if (who->GetTypeId() != TYPEID_PLAYER || !who->GetVehicle() || who->GetVehicleBase()->GetEntry() != 33114)
@@ -227,9 +266,11 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_defense_turretAI : public TurretAI
         return true;
     }
 };
+
 struct TRINITY_DLL_DECL boss_flame_leviathan_overload_deviceAI : public PassiveAI
 {
     boss_flame_leviathan_overload_deviceAI(Creature *c) : PassiveAI(c) {}
+
     void DoAction(const int32 param)
     {
         if(param == EVENT_SPELLCLICK)
@@ -249,9 +290,11 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_overload_deviceAI : public PassiveA
         }
     }
 };
+
 struct TRINITY_DLL_DECL boss_flame_leviathan_safety_containerAI : public PassiveAI
 {
     boss_flame_leviathan_safety_containerAI(Creature *c) : PassiveAI(c) {}
+
     void MovementInform(uint32 type, uint32 id)
     {
         if(id == me->GetEntry())
@@ -261,52 +304,63 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_safety_containerAI : public Passive
             me->DisappearAndDie(); // this will relocate creature to sky
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(!me->GetVehicle() && me->isSummon() && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)
             me->GetMotionMaster()->MoveFall(409.8f, me->GetEntry());
     }
 };
+
 struct TRINITY_DLL_DECL spell_pool_of_tarAI : public TriggerAI
 {
     spell_pool_of_tarAI(Creature *c) : TriggerAI(c)
     {
         me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void DamageTaken(Unit *who, uint32 &damage)
     {
         damage = 0;
     }
+
     void SpellHit(Unit* caster, const SpellEntry *spell)
     {
         if(spell->SchoolMask & SPELL_SCHOOL_MASK_FIRE && !me->HasAura(SPELL_BLAZE))
             me->CastSpell(me, SPELL_BLAZE, true);
     }
 };
+
 CreatureAI* GetAI_boss_flame_leviathan(Creature* pCreature)
 {
     return new boss_flame_leviathanAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_flame_leviathan_seat(Creature* pCreature)
 {
     return new boss_flame_leviathan_seatAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_flame_leviathan_defense_turret(Creature* pCreature)
 {
     return new boss_flame_leviathan_defense_turretAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_flame_leviathan_overload_device(Creature* pCreature)
 {
     return new boss_flame_leviathan_overload_deviceAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_flame_leviathan_safety_containerAI(Creature* pCreature)
 {
     return new boss_flame_leviathan_safety_containerAI(pCreature);
 }
+
 CreatureAI* GetAI_spell_pool_of_tar(Creature* pCreature)
 {
     return new spell_pool_of_tarAI (pCreature);
 }
+
 void AddSC_boss_flame_leviathan()
 {
     Script *newscript;
@@ -314,22 +368,27 @@ void AddSC_boss_flame_leviathan()
     newscript->Name = "boss_flame_leviathan";
     newscript->GetAI = &GetAI_boss_flame_leviathan;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_flame_leviathan_seat";
     newscript->GetAI = &GetAI_boss_flame_leviathan_seat;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_flame_leviathan_defense_turret";
     newscript->GetAI = &GetAI_boss_flame_leviathan_defense_turret;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_flame_leviathan_overload_device";
     newscript->GetAI = &GetAI_boss_flame_leviathan_overload_device;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_flame_leviathan_safety_container";
     newscript->GetAI = &GetAI_boss_flame_leviathan_safety_containerAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "spell_pool_of_tar";
     newscript->GetAI = &GetAI_spell_pool_of_tar;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_freya.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_freya.cpp
index 447a26ae7b3..ac0b23c1b7a 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_freya.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_freya.cpp
@@ -15,12 +15,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 /*
 #define SAY_AGGRO -1
 #define SAY_SLAY -1
 */
+
 struct TRINITY_DLL_DECL boss_freyaAI : public BossAI
 {
     boss_freyaAI(Creature* pCreature) : BossAI(pCreature, TYPE_FREYA)
@@ -28,39 +31,52 @@ struct TRINITY_DLL_DECL boss_freyaAI : public BossAI
         m_pInstance = pCreature->GetInstanceData();
         Reset();
     }
+
     ScriptedInstance* m_pInstance;
+
     void Reset()
     {
     }
+
     void KilledUnit(Unit *victim)
     {
     }
+
     void JustDied(Unit *victim)
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_FREYA, DONE);
     }
+
     void Aggro(Unit* pWho)
     {
 //        DoScriptText(SAY_AGGRO, m_creature);
         m_creature->SetInCombatWithZone();
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_FREYA, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
 //SPELLS TODO:
+
 //
         DoMeleeAttackIfReady();
+
         EnterEvadeIfOutOfCombatArea(diff);
+
     }
+
 };
+
 CreatureAI* GetAI_boss_freya(Creature* pCreature)
 {
     return new boss_freyaAI(pCreature);
 }
+
 void AddSC_boss_freya()
 {
     Script *newscript;
@@ -68,4 +84,5 @@ void AddSC_boss_freya()
     newscript->Name = "boss_freya";
     newscript->GetAI = &GetAI_boss_freya;
     newscript->RegisterSelf();
+
 }
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_general_vezax.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_general_vezax.cpp
index b28c71f645d..a736b2db12a 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_general_vezax.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_general_vezax.cpp
@@ -15,5 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_hodir.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_hodir.cpp
index 1b84b927184..c05d30d83ba 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_hodir.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_hodir.cpp
@@ -15,12 +15,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 /*
 #define SAY_AGGRO -1
 #define SAY_SLAY -1
 */
+
 struct TRINITY_DLL_DECL boss_hodirAI : public BossAI
 {
     boss_hodirAI(Creature *pCreature) : BossAI(pCreature, TYPE_HODIR)
@@ -28,39 +31,52 @@ struct TRINITY_DLL_DECL boss_hodirAI : public BossAI
         m_pInstance = pCreature->GetInstanceData();
         Reset();
     }
+
     ScriptedInstance* m_pInstance;
+
     void Reset()
     {
     }
+
     void KilledUnit(Unit *victim)
     {
     }
+
     void JustDied(Unit *victim)
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_HODIR, DONE);
     }
+
     void Aggro(Unit* pWho)
     {
 //        DoScriptText(SAY_AGGRO, m_creature);
         m_creature->SetInCombatWithZone();
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_HODIR, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
 //SPELLS TODO:
+
 //
         DoMeleeAttackIfReady();
+
         EnterEvadeIfOutOfCombatArea(diff);
+
     }
+
 };
+
 CreatureAI* GetAI_boss_hodir(Creature* pCreature)
 {
     return new boss_hodirAI(pCreature);
 }
+
 void AddSC_boss_hodir()
 {
     Script *newscript;
@@ -68,5 +84,6 @@ void AddSC_boss_hodir()
     newscript->Name = "boss_hodir";
     newscript->GetAI = &GetAI_boss_hodir;
     newscript->RegisterSelf();
+
 }
 
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_ignis.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_ignis.cpp
index e4697b60412..8dfda95a987 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_ignis.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_ignis.cpp
@@ -15,26 +15,33 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 #define SPELL_FLAME_JETS            62680
 #define SPELL_SCORCH                62546
 #define SPELL_SLAG_POT              62717
+
 //wrong ids. not in db
 #define SAY_AGGRO                   -10000002
 #define SAY_SLAY                    -1000003
+
 struct TRINITY_DLL_DECL boss_ignis_AI : public BossAI
 {
     boss_ignis_AI(Creature *pCreature) : BossAI(pCreature, TYPE_IGNIS) {}
+
     uint32 FLAME_JETS_Timer;
     uint32 SCORCH_Timer;
     uint32 SLAG_POT_Timer;
+
     void Reset()
     {
         FLAME_JETS_Timer = 32000;
         SCORCH_Timer = 100;
         SLAG_POT_Timer = 100;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO,m_creature);
@@ -43,15 +50,19 @@ struct TRINITY_DLL_DECL boss_ignis_AI : public BossAI
     {
         DoScriptText(SAY_SLAY, m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_SLAY, m_creature);
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(m_creature->GetPositionY() < 150 || m_creature->GetPositionX() < 450) // Not Blizzlike, anti-exploit to prevent players from pulling bosses to vehicles.
         {
             m_creature->RemoveAllAuras();
@@ -59,17 +70,20 @@ struct TRINITY_DLL_DECL boss_ignis_AI : public BossAI
             m_creature->CombatStop(false);
             m_creature->GetMotionMaster()->MoveTargetedHome();
         }
+
         if (FLAME_JETS_Timer < diff)
         {
             DoCast(m_creature,SPELL_FLAME_JETS);
             DoScriptText(SAY_SLAY, m_creature);
             FLAME_JETS_Timer = 25000;
         } else FLAME_JETS_Timer -= diff;
+
         if (SCORCH_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_SCORCH);
             SCORCH_Timer = 20000;
         } else SCORCH_Timer -= diff;
+
         if (SLAG_POT_Timer < diff)
         {
             DoCast(m_creature,SPELL_SLAG_POT);
@@ -77,9 +91,11 @@ struct TRINITY_DLL_DECL boss_ignis_AI : public BossAI
             SLAG_POT_Timer = 30000;
         } else SLAG_POT_Timer -= diff;
 
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_ignis(Creature* pCreature)
 {
     return new boss_ignis_AI (pCreature);
@@ -87,6 +103,7 @@ CreatureAI* GetAI_boss_ignis(Creature* pCreature)
 void AddSC_boss_ignis()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_ignis";
     newscript->GetAI = &GetAI_boss_ignis;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp
index 6e47e787ab1..b2dfbc08263 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp
@@ -15,16 +15,20 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
 #include "Vehicle.h"
+
 #define SPELL_ARM_DEAD_DAMAGE   HEROIC(63629,63979)
 #define SPELL_TWO_ARM_SMASH     HEROIC(63356,64003)
 #define SPELL_ONE_ARM_SMASH     HEROIC(63573,64006)
 #define SPELL_STONE_SHOUT       HEROIC(63716,64005)
 #define SPELL_PETRIFY_BREATH    HEROIC(62030,63980)
+
 #define SPELL_STONE_GRIP        HEROIC(62166,63981)
 #define SPELL_ARM_SWEEP         HEROIC(63766,63983)
+
 enum Events
 {
     EVENT_NONE = 0,
@@ -32,6 +36,7 @@ enum Events
     EVENT_GRIP,
     EVENT_SWEEP,
 };
+
 struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI
 {
     boss_kologarnAI(Creature *pCreature) : BossAI(pCreature, TYPE_KOLOGARN), vehicle(me->GetVehicleKit()),
@@ -42,18 +47,23 @@ struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI
         me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); // i think this is a hack, but there is no other way to disable his rotation
     }
+
     ScriptedInstance* m_pInstance;
+
     Vehicle *vehicle;
     bool left, right;
+
     void AttackStart(Unit *who)
     {
         me->Attack(who, true);
     }
+
     void JustDied(Unit *victim)
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_KOLOGARN, DONE);
     }
+
     void PassengerBoarded(Unit *who, int8 seatId, bool apply)
     {
         if(who->GetTypeId() == TYPEID_UNIT)
@@ -66,6 +76,7 @@ struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI
             CAST_CRE(who)->SetReactState(REACT_PASSIVE);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         _EnterCombat();
@@ -73,13 +84,17 @@ struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI
         events.ScheduleEvent(EVENT_SWEEP, 10000);
         events.ScheduleEvent(EVENT_GRIP, 15000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(!UpdateVictim())
             return;
+
         events.Update(diff);
+
         if(me->hasUnitState(UNIT_STAT_CASTING))
             return;
+
         // TODO: because we are using hack, he is stunned and cannot cast, so we use triggered for every spell
         switch(events.GetEvent())
         {
@@ -105,13 +120,16 @@ struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI
                 events.PopEvent();
                 break;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_kologarn(Creature* pCreature)
 {
     return new boss_kologarnAI (pCreature);
 }
+
 void AddSC_boss_kologarn()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_mimiron.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_mimiron.cpp
index b28c71f645d..a736b2db12a 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_mimiron.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_mimiron.cpp
@@ -15,5 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_razorscale.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_razorscale.cpp
index 87df084972a..92dd6ecacab 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_razorscale.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_razorscale.cpp
@@ -15,14 +15,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 Name: razorscale
 %Complete: 90
 Comment: Made by Epsik from WoW Arthas wow.dsl.net.pk
 Category:
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 //wrong text ids. correct are beetwen -1000000 AND -1999999
 //beetwen -2000000 and -2999999 are custom texts so wtf?
 #define SAY_AGGRO                   -2000000
@@ -30,17 +33,23 @@ EndScriptData */
 #define SAY_PHASE_2_TRANS           -2000002
 #define SAY_PHASE_3_TRANS           -2000003
 #define EMOTE_BREATH                -2000004
+
 #define SPELL_FLAMEBUFFET           64016
 #define SPELL_FIREBALL              62796
+
 #define SPELL_WINGBUFFET            62666
 #define SPELL_FLAMEBREATH           63317
 #define SPELL_FUSEARMOR             64771
 #define SPELL_DEVOURINGFLAME        63014
 #define SPELL_KNOCK_AWAY            19633
+
 #define SPELL_BELLOWINGROAR         18431
 #define SPELL_HEATED_GROUND         22191
+
 #define SPELL_SUMMONADDS            17646
+
 #define CREATURE_ADDS               33846
+
 static float MovementLocations[4][3]=
 {
     {607.7, -281.9, 408.6},
@@ -48,6 +57,7 @@ static float MovementLocations[4][3]=
     {612.3, -230.8, 409.1},
     {624.1, -251.8, 426.1}
 };
+
 static float SpawnLocations[4][3]=
 {
     {602.0, -248.1, 391.2},
@@ -55,10 +65,13 @@ static float SpawnLocations[4][3]=
     {643.3, -256.4, 391.4},
     {626.6, -271.5, 391.4},
 };
+
 struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
 {
     boss_razorscaleAI(Creature *pCreature) : BossAI(pCreature, TYPE_RAZORSCALE) {}
+
     uint32 Phase;
+
     uint32 FlameBreathTimer;
     uint32 FUSEARMORTimer;
     uint32 DEVOURINGFLAMETimer;
@@ -68,10 +81,13 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
     uint32 WingBuffetTimer;
     uint32 KnockAwayTimer;
     uint32 FireballTimer;
+
     bool InitialSpawn;
+
     void Reset()
     {
         Phase = 1;
+
         FlameBreathTimer = 20000;
         DEVOURINGFLAMETimer = 2000;
         FUSEARMORTimer = 15000;
@@ -81,26 +97,33 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
         WingBuffetTimer = 17000;
         KnockAwayTimer = 15000;
         FireballTimer = 18000;
+
         InitialSpawn = true;
+
         m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
         m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoZoneInCombat();
     }
+
     void JustDied(Unit* Killer)
     {
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(m_creature->GetPositionY() > -60 || m_creature->GetPositionX() < 450) // Not Blizzlike, anti-exploit to prevent players from pulling bosses to vehicles.
         {
             m_creature->RemoveAllAuras();
@@ -108,6 +131,7 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
             m_creature->CombatStop(false);
             m_creature->GetMotionMaster()->MoveTargetedHome();
         }
+
         if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 99) && (Phase == 1))
         {
             Phase = 2;
@@ -117,6 +141,7 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
             m_creature->GetMotionMaster()->MoveIdle();
             DoScriptText(SAY_PHASE_2_TRANS, m_creature);
         }
+
         if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) && (Phase == 2))
         {
             Phase = 3;
@@ -128,6 +153,7 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
             DoScriptText(SAY_PHASE_3_TRANS, m_creature);
             m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
         }
+
         if (Phase == 1 || Phase == 3)
         {
             if (FlameBreathTimer < diff)
@@ -135,23 +161,28 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
                 DoCast(m_creature->getVictim(), SPELL_FLAMEBREATH);
                 FlameBreathTimer = 15000;
             } else FlameBreathTimer -= diff;
+
             if (DEVOURINGFLAMETimer < diff)
             {
                 Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
                 if (target && !m_creature->HasInArc(M_PI, target))
                     DoCast(target, SPELL_DEVOURINGFLAME);
+
                 DEVOURINGFLAMETimer = 10000;
             } else DEVOURINGFLAMETimer -= diff;
+
             if (FUSEARMORTimer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_FUSEARMOR);
                 FUSEARMORTimer = 10000;
             } else FUSEARMORTimer -= diff;
+
             if (WingBuffetTimer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_WINGBUFFET);
                 WingBuffetTimer = 7000 + ((rand()%8)*1000);
             } else WingBuffetTimer -= diff;
+
             if (KnockAwayTimer < diff)
             {
                 if (rand()%100 <= 30)
@@ -160,27 +191,34 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
                 }
                 KnockAwayTimer = 15000;
             } else KnockAwayTimer -= diff;
+
             if (Phase == 3)
             {
                 if (BellowingRoarTimer < diff)
                 {
                     DoCast(m_creature->getVictim(), SPELL_BELLOWINGROAR);
+
                     BellowingRoarTimer = 30000;
                 } else BellowingRoarTimer -= diff;
+
                 if (SummonAddsTimer < diff)
                 {
                     SummonAdds(Phase);
+
                     SummonAddsTimer = 45000;
                 } else SummonAddsTimer -= diff;
             }
+
             DoMeleeAttackIfReady();
         }
+
         if (Phase == 2)
         {
             if (InitialSpawn)
             {
                 InitialSpawn = false;
-                for (uint32 i = 0; i < 4; ++i)
+
+                for(uint32 i = 0; i < 4; ++i)
                 {
                     uint32 random = rand()%4;
                     Creature* Add = m_creature->SummonCreature(CREATURE_ADDS, SpawnLocations[random][0], SpawnLocations[random][1], SpawnLocations[random][2], 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
@@ -189,11 +227,14 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
                 }
             }
 
+
             if (FireballTimer < diff)
             {
                 DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FIREBALL);
+
                 FireballTimer = 18000;
             } else FireballTimer -= diff;
+
             if (MovementTimer < diff)
             {
                 if (rand()%100 <= 30)
@@ -202,15 +243,19 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
                     DoCast(m_creature->getVictim(), SPELL_FLAMEBUFFET);
                 }
                 else ChangePosition();
+
                 MovementTimer = 25000;
             } else MovementTimer -= diff;
+
             if (SummonAddsTimer < diff)
             {
                 SummonAdds(Phase);
+
                 SummonAddsTimer = 45000;
             } else SummonAddsTimer -= diff;
         }
     }
+
     void ChangePosition()
     {
         /* Malfunctioning, Razorscale is flying around randomly, attacking players from hundreds of yards away.
@@ -218,12 +263,13 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
         if (random<4){
             m_creature->GetMotionMaster()->MovePoint(0, MovementLocations[random][0], MovementLocations[random][1], MovementLocations[random][2]);} */
     }
+
     void SummonAdds(uint32 Phase)
     {
         if (Phase == 2)
         {
             uint32 max = rand()%10;
-            for (uint32 i = 0; i < 4; ++i)
+            for(uint32 i = 0; i < 4; ++i)
             {
                 uint32 random = rand()%3;
                 Creature* Add = m_creature->SummonCreature(CREATURE_ADDS, SpawnLocations[random][0], SpawnLocations[random][1], SpawnLocations[random][2], 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
@@ -231,12 +277,13 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
                     Add->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0));
             }
         }
+
         if (Phase == 3)
         {
             uint32 max = rand() % 10 +1;
             if (max < 1)
             {
-                for (uint32 i = 0; i < max; ++i)
+                for(uint32 i = 0; i < max; ++i)
                 {
                     uint32 random = rand()%4;
                     Creature* Add = m_creature->SummonCreature(CREATURE_ADDS, SpawnLocations[random][0], SpawnLocations[random][1], SpawnLocations[random][2], 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
@@ -247,10 +294,12 @@ struct TRINITY_DLL_DECL boss_razorscaleAI : public BossAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_razorscale(Creature* pCreature)
 {
     return new boss_razorscaleAI (pCreature);
 }
+
 void AddSC_boss_razorscale()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_thorim.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_thorim.cpp
index 66cb95be254..d0bd4c87c04 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_thorim.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_thorim.cpp
@@ -15,12 +15,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 /*
 #define SAY_AGGRO -1
 #define SAY_SLAY -1
 */
+
 struct TRINITY_DLL_DECL boss_thorimAI : public BossAI
 {
     boss_thorimAI(Creature* pCreature) : BossAI(pCreature, TYPE_THORIM)
@@ -28,39 +31,52 @@ struct TRINITY_DLL_DECL boss_thorimAI : public BossAI
         m_pInstance = pCreature->GetInstanceData();
         Reset();
     }
+
     ScriptedInstance* m_pInstance;
+
     void Reset()
     {
     }
+
     void KilledUnit(Unit *victim)
     {
     }
+
     void JustDied(Unit *victim)
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_THORIM, DONE);
     }
+
     void Aggro(Unit* pWho)
     {
 //        DoScriptText(SAY_AGGRO, m_creature);
         m_creature->SetInCombatWithZone();
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_THORIM, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
 //SPELLS TODO:
+
 //
         DoMeleeAttackIfReady();
+
         EnterEvadeIfOutOfCombatArea(diff);
+
     }
+
 };
+
 CreatureAI* GetAI_boss_thorim(Creature* pCreature)
 {
     return new boss_thorimAI(pCreature);
 }
+
 void AddSC_boss_thorim()
 {
     Script *newscript;
@@ -68,4 +84,5 @@ void AddSC_boss_thorim()
     newscript->Name = "boss_thorim";
     newscript->GetAI = &GetAI_boss_thorim;
     newscript->RegisterSelf();
+
 }
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_xt002.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_xt002.cpp
index 9b497333e6d..e5889969716 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_xt002.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_xt002.cpp
@@ -15,26 +15,34 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 #define SPELL_SEARING_LIGHT         63018
 #define SPELL_SONIC_BOOM            38897
+
 #define SAY_AGGRO                   -1000000
 #define SAY_SLAY                    -1000001
+
 struct TRINITY_DLL_DECL boss_xt002_AI : public BossAI
 {
     boss_xt002_AI(Creature *pCreature) : BossAI(pCreature, TYPE_XT002)
     {
         m_pInstance = pCreature->GetInstanceData();
     }
+
     ScriptedInstance* m_pInstance;
+
     uint32 SEARING_LIGHT_Timer;
     uint32 SONIC_BOOM_Timer;
+
     void Reset()
     {
         SEARING_LIGHT_Timer = 100;
         SONIC_BOOM_Timer = 20;
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO,m_creature);
@@ -43,17 +51,22 @@ struct TRINITY_DLL_DECL boss_xt002_AI : public BossAI
     {
         DoScriptText(SAY_SLAY, m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_SLAY, m_creature);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_XT002, DONE);
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if(m_creature->GetPositionX() < 700) // Not Blizzlike, anti-exploit to prevent players from pulling bosses to vehicles.
         {
             m_creature->RemoveAllAuras();
@@ -61,20 +74,24 @@ struct TRINITY_DLL_DECL boss_xt002_AI : public BossAI
             m_creature->CombatStop(false);
             m_creature->GetMotionMaster()->MoveTargetedHome();
         }
+
         if (SEARING_LIGHT_Timer < diff)
         {
             DoCast(m_creature,SPELL_SEARING_LIGHT);
             DoScriptText(SAY_SLAY, m_creature);
             SEARING_LIGHT_Timer = 50000;
         } else SEARING_LIGHT_Timer -= diff;
+
         if (SONIC_BOOM_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_SONIC_BOOM);
             SONIC_BOOM_Timer = 20000;
         } else SONIC_BOOM_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_xt002(Creature* pCreature)
 {
     return new boss_xt002_AI (pCreature);
@@ -82,6 +99,7 @@ CreatureAI* GetAI_boss_xt002(Creature* pCreature)
 void AddSC_boss_xt002()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_xt002";
     newscript->GetAI = &GetAI_boss_xt002;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_yoggsaron.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_yoggsaron.cpp
index b28c71f645d..a736b2db12a 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_yoggsaron.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_yoggsaron.cpp
@@ -15,5 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/def_ulduar.h b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/def_ulduar.h
index 5f1667dbfee..ed7686343fb 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/def_ulduar.h
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/def_ulduar.h
@@ -15,11 +15,14 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef DEF_ULDUAR_H
 #define DEF_ULDUAR_H
+
 enum eTypes
 {
     MAX_ENCOUNTER               = 14,
+
     TYPE_LEVIATHAN              = 0,
     TYPE_IGNIS                  = 1,
     TYPE_RAZORSCALE             = 2,
@@ -34,11 +37,13 @@ enum eTypes
     TYPE_VEZAX                  = 11,
     TYPE_YOGGSARON              = 12,
     TYPE_ALGALON                = 13,
+
     DATA_STEELBREAKER           = 20,
     DATA_MOLGEIM                = 21,
     DATA_BRUNDIR                = 22,
     DATA_RUNEMASTER_MOLGEIM     = 23,
     DATA_STORMCALLER_BRUNDIR    = 24,
+
     NPC_LEVIATHAN               = 33113,
     NPC_IGNIS                   = 33118,
     NPC_RAZORSCALE              = 33186,
@@ -56,4 +61,5 @@ enum eTypes
     NPC_YOGGSARON               = 33288,
     NPC_ALGALON                 = 32871
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/instance_ulduar.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/instance_ulduar.cpp
index 23a1eba2d16..4a4c441fffc 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/instance_ulduar.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/instance_ulduar.cpp
@@ -15,8 +15,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 enum eGameObjects
 {
     GO_Kologarn_CHEST_HERO  = 195047,
@@ -28,11 +30,14 @@ enum eGameObjects
     GO_Freya_CHEST_HERO     = 194325,
     GO_Freya_CHEST          = 194324,
 };
+
 struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
 {
     instance_ulduar(Map* pMap) : ScriptedInstance(pMap), KologarnChest(NULL), ThorimChest(NULL), HodirChest(NULL), FreyaChest(NULL) { Initialize(); };
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     std::string m_strInstData;
+
     uint64 m_uiLeviathanGUID;
     uint64 m_uiIgnisGUID;
     uint64 m_uiRazorscaleGUID;
@@ -47,7 +52,9 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
     uint64 m_uiVezaxGUID;
     uint64 m_uiYoggSaronGUID;
     uint64 m_uiAlgalonGUID;
+
     GameObject* KologarnChest, *ThorimChest, *HodirChest, *FreyaChest;
+
     void Initialize()
     {
         m_uiLeviathanGUID       = 0;
@@ -67,18 +74,22 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
         ThorimChest             = 0;
         HodirChest              = 0;
         FreyaChest              = 0;
+
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
         memset(&m_auiAssemblyGUIDs, 0, sizeof(m_auiAssemblyGUIDs));
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
         {
             if (m_auiEncounter[i] == IN_PROGRESS)
                 return true;
         }
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -95,6 +106,7 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
             case NPC_XT002:
                 m_uiXT002GUID = pCreature->GetGUID();
                 break;
+
             // Assembly of Iron
             case NPC_STEELBREAKER:
                 m_auiAssemblyGUIDs[0] = pCreature->GetGUID();
@@ -105,6 +117,7 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
             case NPC_BRUNDIR:
                 m_auiAssemblyGUIDs[2] = pCreature->GetGUID();
                 break;
+
             case NPC_KOLOGARN:
                 m_uiKologarnGUID = pCreature->GetGUID();
                 break;
@@ -133,7 +146,9 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
                 m_uiAlgalonGUID = pCreature->GetGUID();
                 break;
         }
+
      }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -148,6 +163,7 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
             case GO_Freya_CHEST: FreyaChest = add ? pGo : NULL; break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -181,17 +197,23 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
                 m_auiEncounter[type] = data;
                 break;
         }
+
         if (data == DONE)
         {
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 saveStream << m_auiEncounter[i] << " ";
+
             m_strInstData = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
     }
+
     uint64 GetData64(uint32 data)
     {
         switch(data)
@@ -222,6 +244,7 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
                 return m_uiYoggSaronGUID;
             case TYPE_ALGALON:
                 return m_uiAlgalonGUID;
+
             // Assembly of Iron
             case DATA_STEELBREAKER:
                 return m_auiAssemblyGUIDs[0];
@@ -230,8 +253,10 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
             case DATA_BRUNDIR:
                 return m_auiAssemblyGUIDs[2];
         }
+
         return 0;
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -252,12 +277,15 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
             case TYPE_ALGALON:
                 return m_auiEncounter[type];
         }
+
         return 0;
     }
+
     const char* Save()
     {
         return m_strInstData.c_str();
     }
+
     void Load(const char* strIn)
     {
         if (!strIn)
@@ -265,21 +293,28 @@ struct TRINITY_DLL_DECL instance_ulduar : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(strIn);
+
         std::istringstream loadStream(strIn);
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
         {
             loadStream >> m_auiEncounter[i];
+
             if (m_auiEncounter[i] == IN_PROGRESS)
                 m_auiEncounter[i] = NOT_STARTED;
         }
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_ulduar(Map* pMap)
 {
     return new instance_ulduar(pMap);
 }
+
 void AddSC_instance_ulduar()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/ulduar_teleporter.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/ulduar_teleporter.cpp
index fb0d149eb09..3ea183059da 100644
--- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/ulduar_teleporter.cpp
+++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/ulduar_teleporter.cpp
@@ -1,7 +1,9 @@
 #include "precompiled.h"
 #include "def_ulduar.h"
+
 /*
 The teleporter appears to be active and stable.
+
 - Expedition Base Camp
 - Formation Grounds
 - Colossal Forge
@@ -10,6 +12,7 @@ The teleporter appears to be active and stable.
 - Shattered Walkway
 - Conservatory of Life
 */
+
 #define BASE_CAMP    200
 #define GROUNDS      201
 #define FORGE        202
@@ -17,10 +20,12 @@ The teleporter appears to be active and stable.
 #define ANTECHAMBER  204
 #define WALKWAY      205
 #define CONSERVATORY 206
+
 bool GoHello_ulduar_teleporter( Player *pPlayer, GameObject *pGO )
 {
     ScriptedInstance *pInstance = (ScriptedInstance *) pGO->GetInstanceData();
     if(!pInstance) return true;
+
     pPlayer->ADD_GOSSIP_ITEM(0, "Teleport to the Expedition Base Camp", GOSSIP_SENDER_MAIN, BASE_CAMP);
     pPlayer->ADD_GOSSIP_ITEM(0, "Teleport to the Formation Grounds", GOSSIP_SENDER_MAIN, GROUNDS);
     if(pInstance->GetData(TYPE_LEVIATHAN) == DONE)
@@ -39,12 +44,15 @@ bool GoHello_ulduar_teleporter( Player *pPlayer, GameObject *pGO )
         }
     }
     pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pGO->GetGUID());
+
     return true;
 }
+
 bool GOSelect_ulduar_teleporter( Player *pPlayer, GameObject *pGO, uint32 sender, uint32 action )
 {
     if(sender != GOSSIP_SENDER_MAIN) return true;
     if(!pPlayer->getAttackers().empty()) return true;
+
     switch(action)
     {
     case BASE_CAMP:
@@ -69,8 +77,10 @@ bool GOSelect_ulduar_teleporter( Player *pPlayer, GameObject *pGO, uint32 sender
         pPlayer->TeleportTo(603, 2086.27, -24.3134, 421.239, 0);
         pPlayer->CLOSE_GOSSIP_MENU(); break;
     }
+
     return true;
 }
+
 void AddSC_ulduar_teleporter()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp
index 4cc6163c83b..86523ef0bf6 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp
@@ -15,23 +15,29 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Boss_Ingvar_The_Plunderer
 SD%Complete: 95
 SDComment: Some Problems with Annhylde Movement, Blizzlike Timers
 SDCategory: Udgarde Keep
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_utgarde_keep.h"
+
 enum eEnums
 {
     //Yells Ingvar
     YELL_AGGRO_1                        = -1574005,
     YELL_AGGRO_2                        = -1574006,
+
     YELL_DEAD_1                         = -1574007,
     YELL_DEAD_2                         = -1574008,
+
     YELL_KILL_1                         = -1574009,
     YELL_KILL_2                         = -1574010,
+
 //Ingvar Spells human form
     MOB_INGVAR_HUMAN                            = 23954,
     SPELL_CLEAVE                                = 42724,
@@ -41,12 +47,15 @@ enum eEnums
     H_SPELL_STAGGERING_ROAR                     = 59708,
     SPELL_ENRAGE                                = 42705,
     H_SPELL_ENRAGE                              = 59707,
+
     MOB_ANNHYLDE_THE_CALLER                     = 24068,
     SPELL_INGVAR_FEIGN_DEATH                    = 42795,
     SPELL_SUMMON_BANSHEE                        = 42912,
     SPELL_SCOURG_RESURRECTION_EFFEKTSPAWN       = 42863, //Spawn resurrecteffekt around Ingvar
+
     MODEL_INGVAR_UNDEAD                         = 26351,
     MODEL_INGVAR_HUMAN                          = 21953,
+
 //Ingvar Spells undead form
     MOB_INGVAR_UNDEAD                           = 23980,
     SPELL_DARK_SMASH                            = 42723,
@@ -54,9 +63,11 @@ enum eEnums
     H_SPELL_DREADFUL_ROAR                       = 59734,
     SPELL_WOE_STRIKE                            = 42730,
     H_SPELL_WOE_STRIKE                          = 59735,
+
     ENTRY_THROW_TARGET                          = 23996,
     SPELL_SHADOW_AXE_SUMMON                     = 42749
 };
+
 struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
 {
     boss_ingvar_the_plundererAI(Creature *c) : ScriptedAI(c)
@@ -64,33 +75,44 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
+
     bool HeroicMode;
     bool undead;
     bool event_inProgress;
+
     uint32 Cleave_Timer;
     uint32 Smash_Timer;
     uint32 Enrage_Timer;
     uint32 Roar_Timer;
     uint32 SpawnResTimer;
     uint32 wait_Timer;
+
     void Reset()
     {
         if (undead) // Visual Hack
             m_creature->SetDisplayId(MODEL_INGVAR_HUMAN);
+
         undead = false;
         event_inProgress = false;
+
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
+
         Cleave_Timer = 2000;
         Smash_Timer = 5000;
         Enrage_Timer = 10000;
         Roar_Timer = 15000;
+
         SpawnResTimer = 3000;
+
         wait_Timer = 0;
+
         if (pInstance)
             pInstance->SetData(DATA_INGVAR_EVENT, NOT_STARTED);
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth() && !undead)
@@ -106,15 +128,19 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
             m_creature->GetMotionMaster()->MoveIdle();
             m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
             // visuel hack end
+
             event_inProgress = true;
             undead = true;
+
             DoScriptText(YELL_DEAD_1,m_creature);
         }
+
         if (event_inProgress)
         {
             damage = 0;
         }
     }
+
     void StartZombiePhase()
     {
         undead = true;
@@ -122,29 +148,37 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
         m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
         m_creature->AI()->AttackStart(m_creature->getVictim());
+
         DoScriptText(YELL_AGGRO_2,m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(YELL_AGGRO_1,m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_INGVAR_EVENT, IN_PROGRESS);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(YELL_DEAD_2,m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_INGVAR_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (undead) { DoScriptText(YELL_KILL_1,m_creature); }
         else { DoScriptText(YELL_KILL_2,m_creature); }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (event_inProgress)
         {
             if (SpawnResTimer)
@@ -154,14 +188,17 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
                     //DoCast(m_creature,SPELL_SCOURG_RESURRECTION_EFFEKTSPAWN); // Dont needet ?
                     SpawnResTimer = 0;
                 }else SpawnResTimer -= diff;
+
             return;
         }
+
         // This is used for a spell queue ... the spells should not castet if one spell is already casting
         if (wait_Timer)
             if (wait_Timer < diff)
             {
                 wait_Timer = 0;
             }else wait_Timer -= diff;
+
         if (Cleave_Timer < diff)
         {
             if (!wait_Timer)
@@ -171,9 +208,11 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
                 else
                     DoCast(m_creature->getVictim(),SPELL_CLEAVE);
                 Cleave_Timer = rand()%5000 + 2000;
+
                 wait_Timer = 1000;
             }
         }else Cleave_Timer -= diff;
+
         if (Smash_Timer < diff)
         {
             if (!wait_Timer)
@@ -183,9 +222,11 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
                 else
                     DoCast(m_creature->getVictim(),HEROIC(SPELL_SMASH, H_SPELL_SMASH));
                 Smash_Timer = 10000;
+
                 wait_Timer = 5000;
             }
         }else Smash_Timer -= diff;
+
         if (!undead)
         {
             if (Enrage_Timer < diff)
@@ -204,6 +245,7 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
                     if (target)
                     {
                         Creature* temp = m_creature->SummonCreature(ENTRY_THROW_TARGET,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN,2000);
+
                         DoCast(m_creature,SPELL_SHADOW_AXE_SUMMON);
                     }
                     Enrage_Timer = 30000;
@@ -211,6 +253,7 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
             }else Enrage_Timer -= diff;
         }
 
+
         if (Roar_Timer < diff)
         {
             if (!wait_Timer)
@@ -220,36 +263,44 @@ struct TRINITY_DLL_DECL boss_ingvar_the_plundererAI : public ScriptedAI
                 else
                     DoCast(m_creature,HEROIC(SPELL_STAGGERING_ROAR, H_SPELL_STAGGERING_ROAR));
                 Roar_Timer = 10000;
+
                 wait_Timer = 5000;
             }
         }else Roar_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_ingvar_the_plunderer(Creature* pCreature)
 {
     return new boss_ingvar_the_plundererAI (pCreature);
 }
+
 enum eSpells
 {
 //we don't have that text in db so comment it until we get this text
 //    YELL_RESSURECT                      = -1574025,
+
 //Spells for Annhylde
     SPELL_SCOURG_RESURRECTION_HEAL              = 42704, //Heal Max + DummyAura
     SPELL_SCOURG_RESURRECTION_BEAM              = 42857, //Channeling Beam of Annhylde
     SPELL_SCOURG_RESURRECTION_DUMMY             = 42862, //Some Emote Dummy?
     SPELL_INGVAR_TRANSFORM                      = 42796
 };
+
 struct TRINITY_DLL_DECL mob_annhylde_the_callerAI : public ScriptedAI
 {
     mob_annhylde_the_callerAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     float x,y,z;
     ScriptedInstance* pInstance;
     uint32 Resurect_Timer;
     uint32 Resurect_Phase;
+
     void Reset()
     {
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_FLYING + MOVEMENTFLAG_HOVER);
@@ -257,15 +308,19 @@ struct TRINITY_DLL_DECL mob_annhylde_the_callerAI : public ScriptedAI
         m_creature->SetSpeed(MOVE_RUN , 1.0f);
         m_creature->SetSpeed(MOVE_WALK , 1.0f);
         //m_creature->SetSpeed(MOVE_FLIGHT , 1.0f);
+
         m_creature->GetPosition(x,y,z);
         DoTeleportTo(x+1,y,z+30);
+
         Unit* ingvar = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_INGVAR) : 0);
         if (ingvar)
         {
             m_creature->GetMotionMaster()->MovePoint(1,x,y,z+15);
+
 //            DoScriptText(YELL_RESSURECT,m_creature);
         }
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
@@ -289,6 +344,7 @@ struct TRINITY_DLL_DECL mob_annhylde_the_callerAI : public ScriptedAI
             }
         }
     }
+
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
     void EnterCombat(Unit *who) {}
@@ -316,31 +372,39 @@ struct TRINITY_DLL_DECL mob_annhylde_the_callerAI : public ScriptedAI
                         //ingvar->CastSpell(ingvar,SPELL_INGVAR_TRANSFORM,false);
                         //ingvar->SetDisplayId(MODEL_INGVAR_UNDEAD); // Visual Hack - when he dies he becomes human model -> wrong
                         Creature* c_ingvar = ingvar;
+
                         CAST_AI(boss_ingvar_the_plundererAI, (c_ingvar->AI()))->StartZombiePhase();
+
                         m_creature->GetMotionMaster()->MovePoint(2,x+1,y,z+30);
                         Resurect_Phase++;
                     }
                 }
+
             }else Resurect_Timer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_annhylde_the_caller(Creature* pCreature)
 {
     return new mob_annhylde_the_callerAI (pCreature);
 }
+
 enum eShadowAxe
 {
     SPELL_SHADOW_AXE_DAMAGE                     = 42750,
     H_SPELL_SHADOW_AXE_DAMAGE                   = 59719
 };
+
 struct TRINITY_DLL_DECL mob_ingvar_throw_dummyAI : public ScriptedAI
 {
     mob_ingvar_throw_dummyAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
     uint32 Despawn_Timer;
+
     void Reset()
     {
         Unit* target = m_creature->FindNearestCreature(ENTRY_THROW_TARGET,50);
@@ -366,21 +430,26 @@ struct TRINITY_DLL_DECL mob_ingvar_throw_dummyAI : public ScriptedAI
         }else Despawn_Timer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_ingvar_throw_dummy(Creature* pCreature)
 {
     return new mob_ingvar_throw_dummyAI (pCreature);
 }
+
 void AddSC_boss_ingvar_the_plunderer()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_ingvar_the_plunderer";
     newscript->GetAI = &GetAI_boss_ingvar_the_plunderer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_annhylde_the_caller";
     newscript->GetAI = &GetAI_mob_annhylde_the_caller;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ingvar_throw_dummy";
     newscript->GetAI = &GetAI_mob_ingvar_throw_dummy;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp
index b3075e26688..bff13c8b4cc 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp
@@ -15,17 +15,21 @@
  * along with 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_Keleseth
 SD%Complete: 90
 SDComment:  Needs Prince Movements, Needs adjustments to blizzlike timers, Needs Shadowbolt castbar, Needs right Ressurect Visual, Needs Some Heroic Spells
 SDCategory: Utgarde Keep
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_utgarde_keep.h"
+
 enum eEnums
 {
     ACHIEVEMENT_ON_THE_ROCKS                 = 1919,
+
     SPELL_SHADOWBOLT                         = 43667,
     SPELL_SHADOWBOLT_HEROIC                  = 59389,
     SPELL_FROST_TOMB                         = 48400,
@@ -34,13 +38,16 @@ enum eEnums
     SPELL_SCOURGE_RESSURRECTION              = 42704,
     CREATURE_FROSTTOMB                       = 23965,
     CREATURE_SKELETON                        = 23970,
+
     SAY_AGGRO                                = -1574000,
     SAY_FROST_TOMB                           = -1574001,
     SAY_SKELETONS                            = -1574002,
     SAY_KILL                                 = -1574003,
     SAY_DEATH                                = -1574004
 };
+
 #define SKELETONSPAWN_Z                          42.8668
+
 float SkeletonSpawnPoint[5][5]=
 {
     {156.2559, 259.2093},
@@ -49,27 +56,35 @@ float SkeletonSpawnPoint[5][5]=
     {156.2559, 259.2093},
     {156.2559, 259.2093},
 };
+
 float AttackLoc[3]={197.636, 194.046, 40.8164};
+
 bool ShatterFrostTomb; // needed for achievement: On The Rocks(1919)
+
 struct TRINITY_DLL_DECL mob_frost_tombAI : public ScriptedAI
 {
     mob_frost_tombAI(Creature *c) : ScriptedAI(c)
     {
         FrostTombGUID = 0;
     }
+
     uint64 FrostTombGUID;
+
     void SetPrisoner(Unit* uPrisoner)
     {
         FrostTombGUID = uPrisoner->GetGUID();
     }
+
     void Reset(){ FrostTombGUID = 0; }
     void EnterCombat(Unit* who) {}
     void AttackStart(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
+
     void JustDied(Unit *killer)
     {
         if (killer->GetGUID() != m_creature->GetGUID())
             ShatterFrostTomb = true;
+
         if (FrostTombGUID)
         {
             Unit* FrostTomb = Unit::GetUnit((*m_creature),FrostTombGUID);
@@ -77,6 +92,7 @@ struct TRINITY_DLL_DECL mob_frost_tombAI : public ScriptedAI
                 FrostTomb->RemoveAurasDueToSpell(SPELL_FROST_TOMB);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         Unit* temp = Unit::GetUnit((*m_creature),FrostTombGUID);
@@ -84,6 +100,7 @@ struct TRINITY_DLL_DECL mob_frost_tombAI : public ScriptedAI
             m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
     }
 };
+
 struct TRINITY_DLL_DECL boss_kelesethAI : public ScriptedAI
 {
     boss_kelesethAI(Creature *c) : ScriptedAI(c)
@@ -91,7 +108,9 @@ struct TRINITY_DLL_DECL boss_kelesethAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         Heroic = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 FrostTombTimer;
     uint32 SummonSkeletonsTimer;
     uint32 RespawnSkeletonsTimer;
@@ -100,24 +119,32 @@ struct TRINITY_DLL_DECL boss_kelesethAI : public ScriptedAI
     bool Skeletons;
     bool Heroic;
     bool RespawnSkeletons;
+
     void Reset()
     {
         ShadowboltTimer = 0;
         Skeletons = false;
+
         ShatterFrostTomb = false;
+
         ResetTimer();
+
         if (pInstance)
             pInstance->SetData(DATA_PRINCEKELESETH_EVENT, NOT_STARTED);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(SAY_KILL, m_creature);
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (Heroic && !ShatterFrostTomb)
         {
             AchievementEntry const *AchievOnTheRocks = GetAchievementStore()->LookupEntry(ACHIEVEMENT_ON_THE_ROCKS);
@@ -127,30 +154,36 @@ struct TRINITY_DLL_DECL boss_kelesethAI : public ScriptedAI
                 if (pMap && pMap->IsDungeon())
                 {
                     Map::PlayerList const &players = pMap->GetPlayers();
-                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+                    for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                         itr->getSource()->CompletedAchievement(AchievOnTheRocks);
                 }
             }
         }
+
         if (pInstance)
             pInstance->SetData(DATA_PRINCEKELESETH_EVENT, DONE);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoZoneInCombat();
+
         if (pInstance)
             pInstance->SetData(DATA_PRINCEKELESETH_EVENT, IN_PROGRESS);
     }
+
     void ResetTimer(uint32 inc = 0)
     {
         SummonSkeletonsTimer = 5000 + inc;
         FrostTombTimer = 28000 + inc;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (ShadowboltTimer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0);
@@ -158,12 +191,13 @@ struct TRINITY_DLL_DECL boss_kelesethAI : public ScriptedAI
                 m_creature->CastSpell(target, Heroic ? SPELL_SHADOWBOLT_HEROIC : SPELL_SHADOWBOLT, true);
             ShadowboltTimer = 10000;
         }else ShadowboltTimer -= diff;
+
         if (!Skeletons)
             if ((SummonSkeletonsTimer < diff))
             {
                 Creature* Skeleton;
                 DoScriptText(SAY_SKELETONS, m_creature);
-                for (uint8 i = 0; i < 5; ++i)
+                for(uint8 i = 0; i < 5; ++i)
                 {
                     Skeleton = m_creature->SummonCreature(CREATURE_SKELETON, SkeletonSpawnPoint[i][0], SkeletonSpawnPoint[i][1] , SKELETONSPAWN_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN,20000);
                     if (Skeleton)
@@ -176,6 +210,7 @@ struct TRINITY_DLL_DECL boss_kelesethAI : public ScriptedAI
                 }
                 Skeletons = true;
             }else SummonSkeletonsTimer -= diff;
+
         if (FrostTombTimer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
@@ -187,36 +222,44 @@ struct TRINITY_DLL_DECL boss_kelesethAI : public ScriptedAI
                 {
                     CAST_AI(mob_frost_tombAI, Chains->AI())->SetPrisoner(target);
                     Chains->CastSpell(target, SPELL_FROST_TOMB, true);
+
                     DoScriptText(SAY_FROST_TOMB, m_creature);
                 }
             }
             FrostTombTimer = 15000;
         }else FrostTombTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_vrykul_skeletonAI : public ScriptedAI
 {
     mob_vrykul_skeletonAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
     uint32 Respawn_Time;
     uint64 Target_Guid;
     uint32 Decrepify_Timer;
+
     bool isDead;
+
     void Reset()
     {
         Respawn_Time = 12000;
         Decrepify_Timer = 10000 + rand()%20000;
         isDead = false;
     }
+
     void EnterCombat(Unit *who){}
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by->GetGUID() == m_creature->GetGUID())
             return;
+
         if (damage >= m_creature->GetHealth())
         {
             PretendToDie();
@@ -224,6 +267,7 @@ struct TRINITY_DLL_DECL mob_vrykul_skeletonAI : public ScriptedAI
         }
     }
 
+
     void PretendToDie()
     {
         isDead = true;
@@ -234,12 +278,14 @@ struct TRINITY_DLL_DECL mob_vrykul_skeletonAI : public ScriptedAI
         m_creature->GetMotionMaster()->MoveIdle();
         m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
     };
+
     void Resurrect()
     {
         isDead = false;
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
         m_creature->CastSpell(m_creature,SPELL_SCOURGE_RESSURRECTION,true);
+
         if (m_creature->getVictim())
         {
             m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
@@ -248,6 +294,7 @@ struct TRINITY_DLL_DECL mob_vrykul_skeletonAI : public ScriptedAI
         else
             m_creature->GetMotionMaster()->Initialize();
     };
+
     void UpdateAI(const uint32 diff)
     {
         if (pInstance && pInstance->GetData(DATA_PRINCEKELESETH_EVENT) == IN_PROGRESS)
@@ -264,11 +311,13 @@ struct TRINITY_DLL_DECL mob_vrykul_skeletonAI : public ScriptedAI
             {
                 if (!UpdateVictim())
                     return;
+
                 if (Decrepify_Timer < diff)
                 {
                     DoCast(m_creature->getVictim(),SPELL_DECREPIFY);
                     Decrepify_Timer = 30000;
                 }else Decrepify_Timer -= diff;
+
                 DoMeleeAttackIfReady();
             }
         }else
@@ -276,31 +325,39 @@ struct TRINITY_DLL_DECL mob_vrykul_skeletonAI : public ScriptedAI
             if (m_creature->isAlive())
                 m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         }
+
     }
 };
+
 CreatureAI* GetAI_mob_frost_tomb(Creature* pCreature)
 {
     return new mob_frost_tombAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_keleseth(Creature* pCreature)
 {
     return new boss_kelesethAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_vrykul_skeleton(Creature* pCreature)
 {
     return new mob_vrykul_skeletonAI (pCreature);
 }
+
 void AddSC_boss_keleseth()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_keleseth";
     newscript->GetAI = &GetAI_boss_keleseth;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_frost_tomb";
     newscript->GetAI = &GetAI_mob_frost_tomb;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_vrykul_skeleton";
     newscript->GetAI = &GetAI_mob_vrykul_skeleton;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_skarvald_dalronn.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_skarvald_dalronn.cpp
index 0102efe51af..0770f9209e9 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_skarvald_dalronn.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/boss_skarvald_dalronn.cpp
@@ -15,14 +15,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 SDName: Boss_Skarvald_Dalronn
 SD%Complete: 95
 SDComment: Needs adjustments to blizzlike timers, Yell Text + Sound to DB
 SDCategory: Utgarde Keep
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_utgarde_keep.h"
+
 enum eEnums
 {
     //signed for 24200, but used by 24200,27390
@@ -31,12 +34,14 @@ enum eEnums
     YELL_SKARVALD_SKA_DIEDFIRST                 = -1574013,
     YELL_SKARVALD_KILL                          = -1574014,
     YELL_SKARVALD_DAL_DIEDFIRST                 = -1574015,
+
     //signed for 24201, but used by 24201,27389
     YELL_DALRONN_AGGRO                          = -1574016,
     YELL_DALRONN_SKA_DIED                       = -1574017,
     YELL_DALRONN_DAL_DIEDFIRST                  = -1574018,
     YELL_DALRONN_KILL                           = -1574019,
     YELL_DALRONN_SKA_DIEDFIRST                  = -1574020,
+
 //Spells of Skarvald and his Ghost
     MOB_SKARVALD_THE_CONSTRUCTOR                = 24200,
     SPELL_CHARGE                                = 43651,
@@ -52,6 +57,7 @@ enum eEnums
     SPELL_SUMMON_DALRONN_GHOST                  = 48612,
     MOB_DALRONN_GHOST                           = 27389
 };
+
 struct TRINITY_DLL_DECL boss_skarvald_the_constructorAI : public ScriptedAI
 {
     boss_skarvald_the_constructorAI(Creature *c) : ScriptedAI(c)
@@ -59,7 +65,9 @@ struct TRINITY_DLL_DECL boss_skarvald_the_constructorAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
+
     bool ghost;
     bool HeroicMode;
     uint32 Charge_Timer;
@@ -67,32 +75,39 @@ struct TRINITY_DLL_DECL boss_skarvald_the_constructorAI : public ScriptedAI
     uint32 Response_Timer;
     uint32 Check_Timer;
     bool Dalronn_isDead;
+
     void Reset()
     {
         Charge_Timer = 5000;
         StoneStrike_Timer = 10000;
         Dalronn_isDead = false;
         Check_Timer = 5000;
+
         ghost = (m_creature->GetEntry() == MOB_SKARVALD_GHOST);
         if (!ghost && pInstance)
         {
             Unit* dalronn = Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_DALRONN));
             if (dalronn && dalronn->isDead())
                 CAST_CRE(dalronn)->Respawn();
+
             pInstance->SetData(DATA_SKARVALD_DALRONN_EVENT, NOT_STARTED);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (!ghost && pInstance)
         {
             DoScriptText(YELL_SKARVALD_AGGRO,m_creature);
+
             Unit* dalronn = Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_DALRONN));
             if (dalronn && dalronn->isAlive() && !dalronn->getVictim())
                 dalronn->getThreatManager().addThreat(who,0.0f);
+
             pInstance->SetData(DATA_SKARVALD_DALRONN_EVENT, IN_PROGRESS);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (!ghost && pInstance)
@@ -103,11 +118,13 @@ struct TRINITY_DLL_DECL boss_skarvald_the_constructorAI : public ScriptedAI
                 if (dalronn->isDead())
                 {
                     DoScriptText(YELL_SKARVALD_DAL_DIED,m_creature);
+
                     pInstance->SetData(DATA_SKARVALD_DALRONN_EVENT, DONE);
                 }
                 else
                 {
                     DoScriptText(YELL_SKARVALD_SKA_DIEDFIRST,m_creature);
+
                     m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                     //DoCast(m_creature,SPELL_SUMMON_SKARVALD_GHOST,true);
                     Creature* temp = m_creature->SummonCreature(MOB_SKARVALD_GHOST,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),0,TEMPSUMMON_CORPSE_DESPAWN,5000);
@@ -120,6 +137,7 @@ struct TRINITY_DLL_DECL boss_skarvald_the_constructorAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (!ghost)
@@ -127,6 +145,7 @@ struct TRINITY_DLL_DECL boss_skarvald_the_constructorAI : public ScriptedAI
             DoScriptText(YELL_SKARVALD_KILL,m_creature);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (ghost)
@@ -134,8 +153,10 @@ struct TRINITY_DLL_DECL boss_skarvald_the_constructorAI : public ScriptedAI
             if (pInstance && pInstance->GetData(DATA_SKARVALD_DALRONN_EVENT) != IN_PROGRESS)
                 m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         }
+
         if (!UpdateVictim())
             return;
+
         if (!ghost)
         {
             if (Check_Timer)
@@ -150,31 +171,38 @@ struct TRINITY_DLL_DECL boss_skarvald_the_constructorAI : public ScriptedAI
                         Check_Timer = 0;
                     }
                 }else Check_Timer -= diff;
+
             if (Response_Timer)
                 if (Dalronn_isDead)
                     if (Response_Timer < diff)
                     {
                         DoScriptText(YELL_SKARVALD_DAL_DIEDFIRST,m_creature);
+
                         Response_Timer = 0;
                     }else Response_Timer -= diff;
         }
+
         if (Charge_Timer < diff)
         {
             DoCast(SelectUnit(SELECT_TARGET_RANDOM, 1), SPELL_CHARGE);
             Charge_Timer = 5000+rand()%5000;
         }else Charge_Timer -= diff;
+
         if (StoneStrike_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_STONE_STRIKE);
             StoneStrike_Timer = 5000+rand()%5000;
         }else StoneStrike_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_skarvald_the_constructor(Creature* pCreature)
 {
     return new boss_skarvald_the_constructorAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
 {
     boss_dalronn_the_controllerAI(Creature *c) : ScriptedAI(c)
@@ -182,17 +210,21 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
+
     bool ghost;
     bool HeroicMode;
     uint32 ShadowBolt_Timer;
     uint32 Debilitate_Timer;
     uint32 Summon_Timer;
+
     uint32 Response_Timer;
     uint32 Check_Timer;
     uint32 AggroYell_Timer;
     bool Skarvald_isDead;
 
+
     void Reset()
     {
         ShadowBolt_Timer = 1000;
@@ -201,15 +233,18 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
         Check_Timer = 5000;
         Skarvald_isDead = false;
         AggroYell_Timer = 0;
+
         ghost = m_creature->GetEntry() == MOB_DALRONN_GHOST;
         if (!ghost && pInstance)
         {
             Unit* skarvald = Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_SKARVALD));
             if (skarvald && skarvald->isDead())
                 CAST_CRE(skarvald)->Respawn();
+
             pInstance->SetData(DATA_SKARVALD_DALRONN_EVENT, NOT_STARTED);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (!ghost)
@@ -217,11 +252,14 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
             Unit* skarvald = Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_SKARVALD));
             if (skarvald && skarvald->isAlive() && !skarvald->getVictim())
                 skarvald->getThreatManager().addThreat(who,0.0f);
+
             AggroYell_Timer = 5000;
+
             if (pInstance)
                 pInstance->SetData(DATA_SKARVALD_DALRONN_EVENT, IN_PROGRESS);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (!ghost)
@@ -231,12 +269,14 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
                 if (skarvald->isDead())
                 {
                     DoScriptText(YELL_DALRONN_SKA_DIED,m_creature);
+
                     if (pInstance)
                         pInstance->SetData(DATA_SKARVALD_DALRONN_EVENT, DONE);
                 }
                 else
                 {
                     DoScriptText(YELL_DALRONN_DAL_DIEDFIRST,m_creature);
+
                     m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                     //DoCast(m_creature,SPELL_SUMMON_DALRONN_GHOST,true);
                     Creature* temp = m_creature->SummonCreature(MOB_DALRONN_GHOST,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),0,TEMPSUMMON_CORPSE_DESPAWN,5000);
@@ -248,6 +288,7 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
                 }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (!ghost)
@@ -255,6 +296,7 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
             DoScriptText(YELL_DALRONN_KILL,m_creature);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (ghost)
@@ -262,14 +304,18 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
             if (pInstance && pInstance->GetData(DATA_SKARVALD_DALRONN_EVENT) != IN_PROGRESS)
                 m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         }
+
         if (!UpdateVictim())
             return;
+
         if (AggroYell_Timer)
             if (AggroYell_Timer < diff)
             {
                 DoScriptText(YELL_DALRONN_AGGRO,m_creature);
+
                 AggroYell_Timer = 0;
             }else AggroYell_Timer -= diff;
+
         if (!ghost)
         {
             if (Check_Timer)
@@ -284,14 +330,17 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
                         Check_Timer = 0;
                     }
                 }else Check_Timer -= diff;
+
             if (Response_Timer)
                 if (Skarvald_isDead)
                     if (Response_Timer < diff)
                     {
                         DoScriptText(YELL_DALRONN_SKA_DIEDFIRST,m_creature);
+
                         Response_Timer = 0;
                     }else Response_Timer -= diff;
         }
+
         if (ShadowBolt_Timer < diff)
         {
             if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -300,6 +349,7 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
                 ShadowBolt_Timer = 1000;
             }
         }else ShadowBolt_Timer -= diff;
+
         if (Debilitate_Timer < diff)
         {
             if (!m_creature->IsNonMeleeSpellCasted(false))
@@ -308,26 +358,32 @@ struct TRINITY_DLL_DECL boss_dalronn_the_controllerAI : public ScriptedAI
                 Debilitate_Timer = 5000+rand()%5000;
             }
         }else Debilitate_Timer -= diff;
+
         if (HeroicMode)
             if (Summon_Timer < diff)
             {
                 DoCast(m_creature,H_SPELL_SUMMON_SKELETONS);
                 Summon_Timer = (rand()%10000) + 20000;
             }else Summon_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_dalronn_the_controller(Creature* pCreature)
 {
     return new boss_dalronn_the_controllerAI (pCreature);
 }
+
 void AddSC_boss_skarvald_dalronn()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_skarvald_the_constructor";
     newscript->GetAI = &GetAI_boss_skarvald_the_constructor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_dalronn_the_controller";
     newscript->GetAI = &GetAI_boss_dalronn_the_controller;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/def_utgarde_keep.h b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/def_utgarde_keep.h
index 0f4beff5d44..b630e156564 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/def_utgarde_keep.h
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/def_utgarde_keep.h
@@ -15,16 +15,21 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef DEF_UTGARDE_KEEP_H
 #define DEF_UTGARDE_KEEP_H
+
 #define DATA_PRINCEKELESETH             1
 #define DATA_SKARVALD                   3
 #define DATA_DALRONN                    4
 #define DATA_INGVAR                     6
+
 #define DATA_PRINCEKELESETH_EVENT       2
 #define DATA_SKARVALD_DALRONN_EVENT     5
 #define DATA_INGVAR_EVENT               7
+
 #define EVENT_FORGE_1                   8
 #define EVENT_FORGE_2                   9
 #define EVENT_FORGE_3                   10
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp
index 4b15767090a..744891371a9 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp
@@ -15,82 +15,104 @@
  * along 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_Utgarde_Keep
 SD%Complete: 90
 SDComment: Instance Data Scripts and functions to acquire mobs and set encounter status for use in various Utgarde Keep Scripts
 SDCategory: Utgarde Keep
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_utgarde_keep.h"
+
 #define MAX_ENCOUNTER     3
+
 #define ENTRY_BELLOW_1          186688
 #define ENTRY_BELLOW_2          186689
 #define ENTRY_BELLOW_3          186690
+
 #define ENTRY_FORGEFIRE_1       186692
 #define ENTRY_FORGEFIRE_2       186693
 #define ENTRY_FORGEFIRE_3       186691
+
 #define ENTRY_GLOWING_ANVIL_1   186609
 #define ENTRY_GLOWING_ANVIL_2   186610
 #define ENTRY_GLOWING_ANVIL_3   186611
+
 #define ENTRY_GIANT_PORTCULLIS_1    186756
 #define ENTRY_GIANT_PORTCULLIS_2    186694
+
 /* Utgarde Keep encounters:
 0 - Prince Keleseth
 1 - Skarvald Dalronn
 2 - Ingvar the Plunderer
 */
+
 struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance
 {
     instance_utgarde_keep(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 Keleseth;
     uint64 Skarvald;
     uint64 Dalronn;
     uint64 Ingvar;
+
     uint64 forge_bellow[3];
     uint64 forge_fire[3];
     uint64 forge_anvil[3];
     uint64 portcullis[2];
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     uint32 forge_event[3];
     std::string str_data;
+
    void Initialize()
    {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         Keleseth = 0;
         Skarvald = 0;
         Dalronn = 0;
         Ingvar = 0;
-        for (uint8 i = 0; i < 3; ++i)
+
+        for(uint8 i = 0; i < 3; ++i)
         {
             forge_bellow[i] = 0;
             forge_fire[i] = 0;
             forge_anvil[i] = 0;
             forge_event[i] = NOT_STARTED;
         }
+
         portcullis[0] = 0;
         portcullis[1] = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     Player* GetPlayerInMap()
     {
         Map::PlayerList const& players = instance->GetPlayers();
+
         if (!players.isEmpty())
         {
-            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+            for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
             {
                 if (Player* plr = itr->getSource())
                 return plr;
             }
         }
+
         debug_log("TSCR: Instance Utgarde Keep: GetPlayerInMap, but PlayerList is empty!");
         return NULL;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -101,6 +123,7 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance
             case 23954:    Ingvar = pCreature->GetGUID();               break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -130,6 +153,7 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance
         if (m_auiEncounter[2] == DONE)HandleGameObject(NULL,true,pGo);break;
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -139,8 +163,10 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance
             case DATA_SKARVALD:               return Skarvald;
             case DATA_INGVAR:                 return Ingvar;
         }
+
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -203,11 +229,13 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance
             break;
         }
 
+
         if (data == DONE)
         {
             SaveToDB();
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -216,18 +244,24 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance
             case DATA_SKARVALD_DALRONN_EVENT:   return m_auiEncounter[1];
             case DATA_INGVAR_EVENT:             return m_auiEncounter[2];
         }
+
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::ostringstream saveStream;
         saveStream << "U K " << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
             << m_auiEncounter[2] << " " << forge_event[0] << " " << forge_event[1] << " " << forge_event[2];
+
         str_data = saveStream.str();
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -235,30 +269,40 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         char dataHead1, dataHead2;
         uint16 data0,data1,data2, data3, data4, data5;
+
         std::istringstream loadStream(in);
         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3 >> data4 >> data5;
+
         if (dataHead1 == 'U' && dataHead2 == 'K')
         {
             m_auiEncounter[0] = data0;
             m_auiEncounter[1] = data1;
             m_auiEncounter[2] = data2;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 if (m_auiEncounter[i] == IN_PROGRESS)
                     m_auiEncounter[i] = NOT_STARTED;
+
             forge_event[0] = data3;
             forge_event[1] = data4;
             forge_event[2] = data5;
+
         }else OUT_LOAD_INST_DATA_FAIL;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_utgarde_keep(Map* pMap)
 {
    return new instance_utgarde_keep(pMap);
 }
+
 void AddSC_instance_utgarde_keep()
 {
    Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/utgarde_keep.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/utgarde_keep.cpp
index 0faf485eb98..6dd5b242517 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/utgarde_keep.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_keep/utgarde_keep.cpp
@@ -15,14 +15,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "def_utgarde_keep.h"
+
 uint32 entry_search[3] =
 {
     186609,
     186610,
     186611
 };
+
 struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
 {
     npc_dragonflayer_forge_masterAI(Creature *c) : ScriptedAI(c)
@@ -30,13 +33,16 @@ struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         fm_Type = 0;
     }
+
     ScriptedInstance* pInstance;
     uint8 fm_Type;
+
     void Reset()
     {
         if (fm_Type == 0) fm_Type = GetForgeMasterType();
         CheckForge();
     }
+
     void CheckForge()
     {
        if (pInstance)
@@ -55,6 +61,7 @@ struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
             }
         }
     }
+
     void JustDied(Unit *killer)
     {
         if (fm_Type == 0) fm_Type = GetForgeMasterType();
@@ -74,6 +81,7 @@ struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
             }
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (fm_Type == 0) fm_Type = GetForgeMasterType();
@@ -94,11 +102,13 @@ struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
         }
         m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE ,EMOTE_ONESHOT_NONE);
     }
+
     uint8 GetForgeMasterType()
     {
         float diff = 30.0f;
         int near_f = 0;
-        for (uint8 i = 0; i < 3 ; ++i)
+
+        for(uint8 i = 0; i < 3 ; ++i)
         {
             GameObject* temp;
             temp = m_creature->FindNearestGameObject(entry_search[i],30);
@@ -108,9 +118,11 @@ struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
                 {
                     near_f = i + 1;
                     diff = m_creature->GetDistance2d(temp);
+
                 }
             }
         }
+
         switch (near_f)
         {
         case 1:  return 1;
@@ -119,22 +131,28 @@ struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
         default: return 0;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (fm_Type == 0)
             fm_Type = GetForgeMasterType();
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_dragonflayer_forge_master(Creature* pCreature)
 {
     return new npc_dragonflayer_forge_masterAI(pCreature);
 }
+
 void AddSC_utgarde_keep()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_dragonflayer_forge_master";
     newscript->GetAI = &GetAI_npc_dragonflayer_forge_master;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp
index cec37e66377..db5394de8c3 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp
@@ -5,73 +5,92 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_palehoof' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_pinnacle.h"
+
 //Spells
 #define SPELL_ARCING_SMASH                          48260
 #define SPELL_IMPALE                                48261
 #define H_SPELL_IMPALE                              59268
 #define SPELL_WITHERING_ROAR                        48256
 #define H_SPELL_WITHERING_ROAR                      59267
+
 #define SPELL_FREEZE                                16245
+
 //ravenous furbolg's spells
 #define SPELL_CHAIN_LIGHTING                        48140
 #define H_SPELL_CHAIN_LIGHTING                      59273
 #define SPELL_CRAZED                                48139
 #define SPELL_TERRIFYING_ROAR                       48144
+
 //frenzied worgen's spells
 #define SPELL_MORTAL_WOUND                          48137
 #define H_SPELL_MORTAL_WOUND                        59265
 #define SPELL_ENRAGE_1                              48138
 #define SPELL_ENRAGE_2                              48142
+
 //ferocious rhino's spells
 #define SPELL_GORE                                  48130
 #define H_SPELL_GORE                                59264
 #define SPELL_GRIEVOUS_WOUND                        48105
 #define H_SPELL_GRIEVOUS_WOUND                      59263
 #define SPELL_STOMP                                 48131
+
 //massive jormungar's spells
 #define SPELL_ACID_SPIT                             48132
 #define SPELL_ACID_SPLATTER                         48136
 #define H_SPELL_ACID_SPLATTER                       59272
 #define SPELL_POISON_BREATH                         48133
 #define H_SPELL_POISON_BREATH                       59271
+
 #define CREATURE_JORMUNGAR_WORM                     27228
+
 //not in db
 //Yell
 #define SAY_AGGRO                                -1575000
 #define SAY_SLAY_1                               -1575001
 #define SAY_SLAY_2                               -1575002
 #define SAY_DEATH                                -1575003
+
 struct TRINITY_DLL_DECL boss_palehoofAI : public ScriptedAI
 {
     boss_palehoofAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiArcingSmashTimer;
     uint32 uiImpaleTimer;
     uint32 uiWhiteringRoarTimer;
     uint32 uiWaitingTimer;
+
     uint8 Phase;
+
     bool bWaiting;
+
     ScriptedInstance *pInstance;
+
     void Reset()
     {
         uiArcingSmashTimer = 15000;
         uiImpaleTimer = 12000;
         uiWhiteringRoarTimer = 10000;
+
         Phase = 0;
         bWaiting = false;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         DoCast(m_creature, SPELL_FREEZE);
+
         if (pInstance)
         {
             pInstance->SetData(DATA_GORTOK_PALEHOOF_EVENT, NOT_STARTED);
+
             Creature* pTemp;
             if ((pTemp = Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_MOB_FRENZIED_WORGEN))) && !pTemp->isAlive())
                 pTemp->Respawn();
@@ -81,6 +100,7 @@ struct TRINITY_DLL_DECL boss_palehoofAI : public ScriptedAI
                 pTemp->Respawn();
             if ((pTemp = Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_MOB_RAVENOUS_FURBOLG))) && !pTemp->isAlive())
                 pTemp->Respawn();
+
             if (GameObject* pGo = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GORTOK_PALEHOOF_SPHERE)))
             {
                 pGo->SetGoState(GO_STATE_READY);
@@ -88,10 +108,12 @@ struct TRINITY_DLL_DECL boss_palehoofAI : public ScriptedAI
             }
         }
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Phase == 6)
@@ -99,22 +121,26 @@ struct TRINITY_DLL_DECL boss_palehoofAI : public ScriptedAI
             //Return since we have no target
             if (!UpdateVictim())
                 return;
+
             if (uiArcingSmashTimer < diff)
             {
                 DoCast(m_creature,SPELL_ARCING_SMASH);
                 uiArcingSmashTimer = 13000 + rand()%4000;
             } else uiArcingSmashTimer -= diff;
+
             if (uiImpaleTimer < diff)
             {
                 if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                     DoCast(pTarget, HEROIC(SPELL_IMPALE, H_SPELL_IMPALE));
                 uiImpaleTimer = 8000 + rand()%4000;
             } else uiImpaleTimer -= diff;
+
             if (uiWhiteringRoarTimer < diff)
             {
                 DoCast(m_creature, HEROIC(SPELL_WITHERING_ROAR, H_SPELL_WITHERING_ROAR));
                 uiWhiteringRoarTimer = 8000 + rand()%4000;
             } else uiWhiteringRoarTimer -= diff;
+
             DoMeleeAttackIfReady();
         }
         else if (Phase != 0 && bWaiting)
@@ -130,6 +156,7 @@ struct TRINITY_DLL_DECL boss_palehoofAI : public ScriptedAI
                   case 4: pNext = Unit::GetCreature((*m_creature), pInstance ? pInstance->GetData64(DATA_MOB_FEROCIOUS_RHINO) : 0); break;
                   case 5: pNext = m_creature; ++Phase; break;
               }
+
               if (pNext)
               {
                   pNext->RemoveAurasDueToSpell(SPELL_FREEZE);
@@ -138,20 +165,24 @@ struct TRINITY_DLL_DECL boss_palehoofAI : public ScriptedAI
                   ((Unit*)pNext)->SetStandState(UNIT_STAND_STATE_STAND);
                   pNext->SetInCombatWithZone();
               }
+
               bWaiting = false;
           } else uiWaitingTimer -= diff;
         }
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
         if (pInstance)
             pInstance->SetData(DATA_GORTOK_PALEHOOF_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void NextPhase()
     {
         ++Phase;
@@ -159,53 +190,66 @@ struct TRINITY_DLL_DECL boss_palehoofAI : public ScriptedAI
         uiWaitingTimer = 1000;
     }
 };
+
 struct TRINITY_DLL_DECL mob_ravenous_furbolgAI : public ScriptedAI
 {
     mob_ravenous_furbolgAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiChainLightingTimer;
     uint32 uiCrazedTimer;
     uint32 uiTerrifyingRoarTimer;
+
     ScriptedInstance *pInstance;
+
     void Reset()
     {
         uiChainLightingTimer = 5000;
         uiCrazedTimer = 10000;
         uiTerrifyingRoarTimer = 15000;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         DoCast(m_creature, SPELL_FREEZE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiChainLightingTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_CHAIN_LIGHTING, H_SPELL_CHAIN_LIGHTING));
             uiChainLightingTimer = 5000 + rand()%5000;
         } else uiChainLightingTimer -=  diff;
+
         if (uiCrazedTimer < diff)
         {
             DoCast(m_creature, SPELL_CRAZED);
             uiCrazedTimer = 8000 + rand()%4000;
         } else uiCrazedTimer -=  diff;
+
         if (uiTerrifyingRoarTimer < diff)
         {
             DoCast(m_creature, SPELL_TERRIFYING_ROAR);
             uiTerrifyingRoarTimer = 10000 + rand()%10000;
         } else uiTerrifyingRoarTimer -=  diff;
+
         DoMeleeAttackIfReady();
     }
+
     void AttackStart(Unit* who)
     {
         if (!who)
             return;
+
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         if (m_creature->Attack(who, true))
         {
             m_creature->AddThreat(who, 0.0f);
@@ -214,6 +258,7 @@ struct TRINITY_DLL_DECL mob_ravenous_furbolgAI : public ScriptedAI
             DoStartMovement(who);
         }
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
@@ -224,53 +269,66 @@ struct TRINITY_DLL_DECL mob_ravenous_furbolgAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_frenzied_worgenAI : public ScriptedAI
 {
     mob_frenzied_worgenAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiMortalWoundTimer;
     uint32 uiEnrage1Timer;
     uint32 uiEnrage2Timer;
+
     ScriptedInstance *pInstance;
+
     void Reset()
     {
         uint32 uiMortalWoundTimer = 5000;
         uint32 uiEnrage1Timer = 15000;
         uint32 uiEnrage2Timer = 10000;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         DoCast(m_creature, SPELL_FREEZE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiMortalWoundTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_MORTAL_WOUND, H_SPELL_MORTAL_WOUND));
             uiMortalWoundTimer = 3000 + rand()%4000;
         } else uiMortalWoundTimer -= diff;
+
         if (uiEnrage1Timer < diff)
         {
             DoCast(m_creature, SPELL_ENRAGE_1);
             uiEnrage1Timer = 15000;
         } else uiEnrage1Timer -= diff;
+
         if (uiEnrage2Timer < diff)
         {
             DoCast(m_creature, SPELL_ENRAGE_2);
             uiEnrage2Timer = 10000;
         } else uiEnrage2Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void AttackStart(Unit* who)
     {
         if (!who)
             return;
+
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         if (m_creature->Attack(who, true))
         {
             m_creature->AddThreat(who, 0.0f);
@@ -281,6 +339,7 @@ struct TRINITY_DLL_DECL mob_frenzied_worgenAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(DATA_GORTOK_PALEHOOF_EVENT, IN_PROGRESS);
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
@@ -291,54 +350,67 @@ struct TRINITY_DLL_DECL mob_frenzied_worgenAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_ferocious_rhinoAI : public ScriptedAI
 {
     mob_ferocious_rhinoAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiStompTimer;
     uint32 uiGoreTimer;
     uint32 uiGrievousWoundTimer;
+
     ScriptedInstance *pInstance;
+
     void Reset()
     {
         uiStompTimer = 10000;
         uiGoreTimer = 15000;
         uiGrievousWoundTimer = 20000;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         DoCast(m_creature, SPELL_FREEZE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiStompTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_STOMP);
             uiStompTimer = 8000 + rand()%4000;
         } else uiStompTimer -= diff;
+
         if (uiGoreTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_GORE, H_SPELL_GORE));
             uiGoreTimer = 13000 + rand()%4000;
         } else uiGoreTimer -= diff;
+
         if (uiGrievousWoundTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 DoCast(pTarget, HEROIC(SPELL_GRIEVOUS_WOUND, H_SPELL_GRIEVOUS_WOUND));
             uiGrievousWoundTimer = 18000 + rand()%4000;
         } else uiGrievousWoundTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void AttackStart(Unit* who)
     {
         if (!who)
             return;
+
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         if (m_creature->Attack(who, true))
         {
             m_creature->AddThreat(who, 0.0f);
@@ -347,6 +419,7 @@ struct TRINITY_DLL_DECL mob_ferocious_rhinoAI : public ScriptedAI
             DoStartMovement(who);
         }
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
@@ -357,55 +430,68 @@ struct TRINITY_DLL_DECL mob_ferocious_rhinoAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_massive_jormungarAI : public ScriptedAI
 {
     mob_massive_jormungarAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiAcidSpitTimer;
     uint32 uiAcidSplatterTimer;
     uint32 uiPoisonBreathTimer;
+
     ScriptedInstance *pInstance;
+
     void Reset()
     {
         uiAcidSpitTimer = 3000;
         uiAcidSplatterTimer = 12000;
         uiPoisonBreathTimer = 10000;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         DoCast(m_creature, SPELL_FREEZE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiAcidSpitTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 DoCast(pTarget, SPELL_ACID_SPIT);
             uiAcidSpitTimer = 2000 + rand()%2000;
         } else uiAcidSpitTimer -= diff;
+
         if (uiAcidSplatterTimer < diff)
         {
             DoCast(m_creature, HEROIC(SPELL_POISON_BREATH, H_SPELL_POISON_BREATH));
             uiAcidSplatterTimer = 10000 + rand()%4000;
         } else uiAcidSplatterTimer -= diff;
+
         if (uiPoisonBreathTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 DoCast(pTarget, HEROIC(SPELL_POISON_BREATH, H_SPELL_POISON_BREATH));
             uiPoisonBreathTimer = 8000 + rand()%4000;
         } else uiPoisonBreathTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void AttackStart(Unit* who)
     {
         if (!who)
             return;
+
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         if (m_creature->Attack(who, true))
         {
             m_creature->AddThreat(who, 0.0f);
@@ -414,6 +500,7 @@ struct TRINITY_DLL_DECL mob_massive_jormungarAI : public ScriptedAI
             DoStartMovement(who);
         }
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
@@ -424,62 +511,77 @@ struct TRINITY_DLL_DECL mob_massive_jormungarAI : public ScriptedAI
         }
     }
 };
+
 bool GOHello_palehoof_sphere(Player *pPlayer, GameObject *pGO)
 {
     ScriptedInstance *pInstance = pGO->GetInstanceData();
+
     Creature *pPalehoof = Unit::GetCreature(*pGO, pInstance ? pInstance->GetData64(DATA_GORTOK_PALEHOOF) : 0);
     if (pPalehoof && pPalehoof->isAlive())
     {
         // maybe these are hacks :(
         pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
         pGO->SetGoState(GO_STATE_ACTIVE);
+
         CAST_AI(boss_palehoofAI, pPalehoof->AI())->NextPhase();
     }
     return true;
 }
+
 CreatureAI* GetAI_boss_palehoof(Creature* pCreature)
 {
     return new boss_palehoofAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_ravenous_furbolg(Creature* pCreature)
 {
     return new mob_ravenous_furbolgAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_frenzied_worgen(Creature* pCreature)
 {
     return new mob_frenzied_worgenAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_ferocious_rhino(Creature* pCreature)
 {
     return new mob_ferocious_rhinoAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_massive_jormungar(Creature* pCreature)
 {
     return new mob_massive_jormungarAI (pCreature);
 }
+
 void AddSC_boss_palehoof()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_palehoof";
     newscript->GetAI = &GetAI_boss_palehoof;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ravenous_furbolg";
     newscript->GetAI = &GetAI_mob_ravenous_furbolg;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_frenzied_worgen";
     newscript->GetAI = &GetAI_mob_frenzied_worgen;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ferocious_rhino";
     newscript->GetAI = &GetAI_mob_ferocious_rhino;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_massive_jormungar";
     newscript->GetAI = &GetAI_mob_massive_jormungar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_palehoof_sphere";
     newscript->pGOHello=&GOHello_palehoof_sphere;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_skadi.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_skadi.cpp
index 1b1fa225049..4710d8dec82 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_skadi.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_skadi.cpp
@@ -5,14 +5,17 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_skadi' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_pinnacle.h"
+
 //Phase 0 "gauntlet even" Skadi on a flying mount, waves of adds charging to the group periodicaly carrying harpoons
 //Phase 1 Kill the Skadi drake mount with harppons launcher
 //Phase 2 Kill the Skadi
+
 //Skadi Spells
 #define SPELL_CRUSH                              50234
 #define H_SPELL_CRUSH                            59330
@@ -20,11 +23,14 @@ update creature_template set scriptname = 'boss_skadi' where entry = '';
 #define H_SPELL_POISONED_SPEAR                   59331
 #define SPELL_WHIRLWIND                          50228 //random target,  but not the tank approx. every 20s
 #define H_SPELL_WHIRLWIND                        59332
+
 //Spawned creatures
 #define CREATURE_YMIRJAR_WARRIOR                 26690
 #define CREATURE_YMIRJAR_WITCH_DOCTOR            26691
 #define CREATURE_YMIRJAR_HARPOONER               26692
+
 #define DATA_MOUNT                               27043
+
 //not in db
 //Yell
 #define SAY_AGGRO                             -1575004
@@ -38,12 +44,14 @@ update creature_template set scriptname = 'boss_skadi' where entry = '';
 #define SAY_DRAKE_BREATH_1                    -1575012
 #define SAY_DRAKE_BREATH_2                    -1575013
 #define SAY_DRAKE_BREATH_3                    -1575014
+
 //Spawn locations
 struct Locations
 {
     float x, y, z;
     uint32 id;
 };
+
 static Locations SpawnLoc[]=
 {
     {340.556, -511.493, 104.352},
@@ -52,50 +60,65 @@ static Locations SpawnLoc[]=
     {430.551, -514.320, 105.055},
     {468.931, -513.555, 104.723}
 };
+
 enum CombatPhase
 {
     FLYING,
     SKADI
 };
+
 struct TRINITY_DLL_DECL boss_skadiAI : public ScriptedAI
 {
     boss_skadiAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiCrushTimer;
     uint32 uiPoisonedSpearTimer;
     uint32 uiWhirlwindTimer;
     uint32 uiMovementTimer;
     uint32 uiWaypointId;
     uint32 uiSpawnCounter;
+
     CombatPhase Phase;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiCrushTimer = 8000;
         uiPoisonedSpearTimer = 10000;
         uiWhirlwindTimer = 20000;
         uiSpawnCounter = 0;
+
         uiWaypointId = 0;
+
         Phase = SKADI;
+
         m_creature->Unmount();
         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_SKADI_THE_RUTHLESS_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         m_creature->Mount(DATA_MOUNT);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->GetMotionMaster()->MovePoint(uiWaypointId, 340.259, -510.541, 120.869);
+
         Phase = FLYING;
+
         if (pInstance)
             pInstance->SetData(DATA_SKADI_THE_RUTHLESS_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         switch(Phase)
@@ -123,40 +146,49 @@ struct TRINITY_DLL_DECL boss_skadiAI : public ScriptedAI
                 //Return since we have no target
                 if (!UpdateVictim())
                     return;
+
                 if (uiCrushTimer < diff)
                 {
                     DoCast(m_creature->getVictim(), HEROIC(SPELL_CRUSH, H_SPELL_CRUSH));
                     uiCrushTimer = 8000;
                 } else uiCrushTimer -= diff;
+
                 if (uiPoisonedSpearTimer < diff)
                 {
                     if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM,0,100,true))
                         DoCast(pTarget, HEROIC(SPELL_POISONED_SPEAR, H_SPELL_POISONED_SPEAR));
                     uiPoisonedSpearTimer = 10000;
                 } else uiPoisonedSpearTimer -= diff;
+
                 if (uiWhirlwindTimer < diff)
                 {
                     if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM,0,100,true))
                         m_creature->CastSpell(pTarget, HEROIC(SPELL_WHIRLWIND, H_SPELL_WHIRLWIND), false);
                 } else uiWhirlwindTimer = 20000;
+
                 DoMeleeAttackIfReady();
                 break;
         }
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_SKADI_THE_RUTHLESS_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2,SAY_KILL_3), m_creature);
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if(type != POINT_MOTION_TYPE)
                 return;
+
         if (HeroicMode ? (uiSpawnCounter >= 4) : (uiSpawnCounter >= 5))
         {
             uiWaypointId = 200;
@@ -181,10 +213,11 @@ struct TRINITY_DLL_DECL boss_skadiAI : public ScriptedAI
             }
         }
     }
+
     void SpawnMobs(uint32 spot)
     {
         uint8 uiMaxSpawn = (HeroicMode ? 6 : 5);
-        for (uint8 i = 0; i < uiMaxSpawn; ++i)
+        for(uint8 i = 0; i < uiMaxSpawn; ++i)
         {
             Creature* pTemp;
             switch (rand()%3)
@@ -202,13 +235,16 @@ struct TRINITY_DLL_DECL boss_skadiAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_skadi(Creature* pCreature)
 {
     return new boss_skadiAI (pCreature);
 }
+
 void AddSC_boss_skadi()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_skadi";
     newscript->GetAI = &GetAI_boss_skadi;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp
index ef2fc77b4c7..137b445e93a 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_svala' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_pinnacle.h"
+
 enum Spells
 {
     SPELL_CALL_FLAMES                        = 48258,
@@ -73,26 +75,35 @@ static Locations RitualChannelerLocations[]=
     {302.36, -352.01, 90.54},
     {291.39, -350.89, 90.54}
 };
+
 struct TRINITY_DLL_DECL boss_svalaAI : public ScriptedAI
 {
     boss_svalaAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiIntroTimer;
+
     uint8 uiIntroPhase;
+
     IntroPhase Phase;
+
     Creature* pArthas;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         Phase = IDLE;
         uiIntroTimer = 1000;
         uiIntroPhase = 0;
         pArthas = NULL;
+
         if (pInstance)
             pInstance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, NOT_STARTED);
     }
+
     void MoveInLineOfSight(Unit* pWho)
     {
         if (!pWho)
@@ -101,6 +112,7 @@ struct TRINITY_DLL_DECL boss_svalaAI : public ScriptedAI
         {
             Phase = INTRO;
             m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
             if (pArthas = m_creature->SummonCreature(CREATURE_ARTHAS, 295.81, -366.16, 92.57, 1.58, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 20000))
             {
                 pArthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -109,15 +121,19 @@ struct TRINITY_DLL_DECL boss_svalaAI : public ScriptedAI
             }
         }
     }
+
     void AttackStart(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (Phase != INTRO)
             return;
+
         if (uiIntroTimer < diff)
         {
             if(!pArthas)
                 return;
+
             switch (uiIntroPhase)
             {
                 case 0:
@@ -166,17 +182,21 @@ struct TRINITY_DLL_DECL boss_svalaAI : public ScriptedAI
         } else uiIntroTimer -= diff;
     }
 };
+
 struct TRINITY_DLL_DECL mob_ritual_channelerAI : public ScriptedAI
 {
     mob_ritual_channelerAI(Creature *c) :ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         DoCast(m_creature, SPELL_SHADOWS_IN_THE_DARK);
     }
+
     void EnterCombat(Unit* who)
     {
         if (who && who->HasAura(SPELL_PARALYZE,0))
@@ -184,40 +204,53 @@ struct TRINITY_DLL_DECL mob_ritual_channelerAI : public ScriptedAI
         return;
     }
 };
+
 struct TRINITY_DLL_DECL boss_svala_sorrowgraveAI : public ScriptedAI
 {
     boss_svala_sorrowgraveAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiSinsterStrikeTimer;
     uint32 uiCallFlamesTimer;
     uint32 uiRitualOfSwordTimer;
     uint32 uiSacrificeTimer;
+
     CombatPhase Phase;
+
     Creature* pRitualChanneler[3];
     Unit* pSacrificeTarget;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiSinsterStrikeTimer = 7000;
         uiCallFlamesTimer = 10000;
         uiRitualOfSwordTimer = 20000;
         uiSacrificeTimer = 8000;
+
         Phase = NORMAL;
+
         DoTeleportTo(296.632, -346.075, 90.6307);
+
         for (uint8 i = 0; i < 3; ++i)
              pRitualChanneler[i] = NULL;
         pSacrificeTarget = NULL;
+
         if (pInstance)
             pInstance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Phase == NORMAL)
@@ -225,11 +258,13 @@ struct TRINITY_DLL_DECL boss_svala_sorrowgraveAI : public ScriptedAI
             //Return since we have no target
             if (!UpdateVictim())
                 return;
+
             if (uiSinsterStrikeTimer < diff)
             {
                 DoCast(m_creature->getVictim(), HEROIC(SPELL_SINSTER_STRIKE, H_SPELL_SINSTER_STRIKE));
                 uiSinsterStrikeTimer = 5000 + rand()%4000;
             } else uiSinsterStrikeTimer -= diff;
+
             if (uiCallFlamesTimer < diff)
             {
                 Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
@@ -239,6 +274,7 @@ struct TRINITY_DLL_DECL boss_svala_sorrowgraveAI : public ScriptedAI
                     uiCallFlamesTimer = 8000 + rand()%4000;
                 }
             } else uiCallFlamesTimer -= diff;
+
             if (uiRitualOfSwordTimer < diff)
             {
                 pSacrificeTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
@@ -251,13 +287,16 @@ struct TRINITY_DLL_DECL boss_svala_sorrowgraveAI : public ScriptedAI
                     m_creature->SetUnitMovementFlags(MOVEMENTFLAG_FLY_MODE);
                     DoTeleportTo(296.632, -346.075, 120.85);
                     Phase = SACRIFICING;
+
                     for (uint8 i = 0; i < 3; ++i)
                         if (pRitualChanneler[i] = m_creature->SummonCreature(CREATURE_RITUAL_CHANNELER, RitualChannelerLocations[i].x, RitualChannelerLocations[i].y, RitualChannelerLocations[i].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000))
                             if (mob_ritual_channelerAI *pChannelerAI = CAST_AI(mob_ritual_channelerAI,pRitualChanneler[i]->AI()))
                                 pChannelerAI->AttackStartNoMove(pSacrificeTarget);
+
                     uiRitualOfSwordTimer = urand(18000,22000);
                 }
             } else uiRitualOfSwordTimer -= diff;
+
             DoMeleeAttackIfReady();
         }
         else  //SACRIFICING
@@ -275,21 +314,25 @@ struct TRINITY_DLL_DECL boss_svala_sorrowgraveAI : public ScriptedAI
                 }
                 if (bSacrificed && pSacrificeTarget && pSacrificeTarget->isAlive())
                     m_creature->Kill(pSacrificeTarget, false); // durability damage?
+
                 //go down
                 Phase = NORMAL;
                 pSacrificeTarget = NULL;
                 m_creature->SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE);
                 if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                     m_creature->GetMotionMaster()->MoveChase(pTarget);
+
                 uiSacrificeTimer = 8000;
             }
             else uiSacrificeTimer -= diff;
         }
     }
+
     void KilledUnit(Unit* pVictim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void JustDied(Unit* pKiller)
     {
         if (pInstance)
@@ -297,34 +340,42 @@ struct TRINITY_DLL_DECL boss_svala_sorrowgraveAI : public ScriptedAI
             Creature* pSvala = Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_SVALA));
             if (pSvala && pSvala->isAlive())
                 pKiller->Kill(pSvala);
+
             pInstance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, IN_PROGRESS);
         }
         DoScriptText(SAY_DEATH, m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_svala(Creature* pCreature)
 {
     return new boss_svalaAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_ritual_channeler(Creature* pCreature)
 {
     return new mob_ritual_channelerAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_svala_sorrowgrave(Creature* pCreature)
 {
     return new boss_svala_sorrowgraveAI(pCreature);
 }
+
 void AddSC_boss_svala()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_svala";
     newscript->GetAI = &GetAI_boss_svala;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ritual_channeler";
     newscript->GetAI = &GetAI_mob_ritual_channeler;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_svala_sorrowgrave";
     newscript->GetAI = &GetAI_boss_svala_sorrowgrave;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_ymiron.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_ymiron.cpp
index 0ac94a7f4f5..df72278c684 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_ymiron.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_ymiron.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = 'boss_ymiron' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_pinnacle.h"
+
 enum Spells
 {
     SPELL_BANE                                = 48294,
@@ -23,13 +25,17 @@ enum Spells
     SPELL_SPIRIT_STRIKE                       = 48423,
     H_SPELL_SPIRIT_STRIKE                     = 59304,
     SPELL_ANCESTORS_VENGEANCE                 = 16939,
+
     SPELL_SUMMON_AVENGING_SPIRIT              = 48592,
     SPELL_SUMMON_SPIRIT_FOUNT                 = 48386,
+
     SPELL_CHANNEL_SPIRIT_TO_YMIRON            = 48316,
     SPELL_CHANNEL_YMIRON_TO_SPIRIT            = 48307,
+
     SPELL_SPIRIT_FOUNT                        = 48380,
     H_SPELL_SPIRIT_FOUNT                      = 59320
 };
+
 //not in db
 enum Yells
 {
@@ -44,6 +50,7 @@ enum Yells
     SAY_SUMMON_RANULF                       = -1575036,
     SAY_SUMMON_TORGYN                       = -1575037
 };
+
 enum Creatures
 {
     CREATURE_BJORN                          = 27303,
@@ -57,12 +64,14 @@ enum Creatures
     CREATURE_SPIRIT_FOUNT                   = 27339,
     CREATURE_AVENGING_SPIRIT                = 27386
 };
+
 struct ActiveBoatStruct
 {
     uint32 npc;
     uint32 say;
     float MoveX,MoveY,MoveZ,SpawnX,SpawnY,SpawnZ,SpawnO;
 };
+
 static ActiveBoatStruct ActiveBot[4] =
 {
     {CREATURE_BJORN_VISUAL,  SAY_SUMMON_BJORN,  404.379, -335.335, 104.756, 413.594, -335.408, 107.995, 3.157},
@@ -70,6 +79,7 @@ static ActiveBoatStruct ActiveBot[4] =
     {CREATURE_RANULF_VISUAL, SAY_SUMMON_RANULF, 381.546, -314.362, 104.756, 370.841, -314.426, 107.995, 6.232},
     {CREATURE_TORGYN_VISUAL, SAY_SUMMON_TORGYN, 404.310, -314.761, 104.756, 413.992, -314.703, 107.995, 3.157}
 };
+
 struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
 {
     boss_ymironAI(Creature *c) : ScriptedAI(c)
@@ -86,28 +96,36 @@ struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
             m_uiActiveOrder[r] = temp;
         }
     }
+
     bool m_bIsWalking;
     bool m_bIsPause;
     bool m_bIsActiveWithBJORN;
     bool m_bIsActiveWithHALDOR;
     bool m_bIsActiveWithRANULF;
     bool m_bIsActiveWithTORGYN;
+
     uint8 m_uiActiveOrder[4];
     uint8 m_uiActivedNumber;
+
     uint32 m_uiFetidRot_Timer;
     uint32 m_uiBane_Timer;
     uint32 m_uiDarkSlash_Timer;
     uint32 m_uiAncestors_Vengeance_Timer;
+
     uint32 m_uiAbility_BJORN_Timer;
     uint32 m_uiAbility_HALDOR_Timer;
     uint32 m_uiAbility_RANULF_Timer;
     uint32 m_uiAbility_TORGYN_Timer;
+
     uint32 m_uiPause_Timer;
     uint32 m_uiHealthAmountModifier;
     uint32 m_uiHealthAmountMultipler;
+
     uint64 m_uiActivedCreatureGUID;
     uint64 m_uiOrbGUID;
+
     ScriptedInstance *pInstance;
+
     void Reset()
     {
         m_bIsPause = false;
@@ -115,29 +133,37 @@ struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
         m_bIsActiveWithHALDOR = false;
         m_bIsActiveWithRANULF = false;
         m_bIsActiveWithTORGYN = false;
+
         m_uiFetidRot_Timer            = urand(8000,13000);
         m_uiBane_Timer                = urand(18000,23000);
         m_uiDarkSlash_Timer           = urand(28000,33000);
         m_uiAncestors_Vengeance_Timer = HEROIC(60000,45000);
         m_uiPause_Timer               = 0;
+
         m_uiAbility_BJORN_Timer  = 0;
         m_uiAbility_HALDOR_Timer = 0;
         m_uiAbility_RANULF_Timer = 0;
         m_uiAbility_TORGYN_Timer = 0;
+
         m_uiActivedNumber        = 0;
         m_uiHealthAmountModifier = 1;
         m_uiHealthAmountMultipler = HEROIC(20,25);
+
         DespawnBoatGhosts(m_uiActivedCreatureGUID);
         DespawnBoatGhosts(m_uiOrbGUID);
+
         if (pInstance)
             pInstance->SetData(DATA_KING_YMIRON_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_KING_YMIRON_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (m_bIsWalking)
@@ -161,6 +187,7 @@ struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
                         case 3: m_bIsActiveWithTORGYN = true; break;
                     }
                 }
+
                 m_bIsPause = true;
                 m_bIsWalking = false;
                 m_uiPause_Timer = 3000;
@@ -175,14 +202,17 @@ struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
                 m_uiAbility_HALDOR_Timer = 5000;
                 m_uiAbility_RANULF_Timer = 5000;
                 m_uiAbility_TORGYN_Timer = 5000;
+
                 m_bIsPause = false;
                 m_uiPause_Timer = 0;
             } else m_uiPause_Timer -= diff;
             return;
         }
+
         //Return since we have no target
          if (!UpdateVictim())
              return;
+
         if (!m_bIsPause)
         {
             // Normal spells ------------------------------------------------------------------------
@@ -191,21 +221,25 @@ struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
                 DoCast(m_creature, HEROIC(SPELL_BANE, H_SPELL_BANE));
                 m_uiBane_Timer = urand(20000,25000);
             } else m_uiBane_Timer -= diff;
+
             if (m_uiFetidRot_Timer < diff)
             {
                 DoCast(m_creature->getVictim(), HEROIC(SPELL_FETID_ROT, H_SPELL_FETID_ROT));
                 m_uiFetidRot_Timer = urand(10000,15000);
             } else m_uiFetidRot_Timer -= diff;
+
             if (m_uiDarkSlash_Timer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_DARK_SLASH);
                 m_uiDarkSlash_Timer = urand(30000,35000);
             } else m_uiDarkSlash_Timer -= diff;
+
             if (m_uiAncestors_Vengeance_Timer < diff)
             {
                 DoCast(m_creature, SPELL_ANCESTORS_VENGEANCE);
                 m_uiAncestors_Vengeance_Timer = HEROIC(urand(60000,65000),urand(45000,50000));
             } else m_uiAncestors_Vengeance_Timer -= diff;
+
             // Abilities ------------------------------------------------------------------------------
             if (m_bIsActiveWithBJORN && m_uiAbility_BJORN_Timer < diff)
             {
@@ -222,23 +256,26 @@ struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
                 }
                 m_bIsActiveWithBJORN = false; // only one orb
             } else m_uiAbility_BJORN_Timer -= diff;
+
             if (m_bIsActiveWithHALDOR && m_uiAbility_HALDOR_Timer < diff)
             {
                 DoCast(m_creature->getVictim(), HEROIC(SPELL_SPIRIT_STRIKE, H_SPELL_SPIRIT_STRIKE));
                 m_uiAbility_HALDOR_Timer = 5000; // overtime
             } else m_uiAbility_HALDOR_Timer -= diff;
+
             if (m_bIsActiveWithRANULF && m_uiAbility_RANULF_Timer < diff)
             {
                 DoCast(m_creature, HEROIC(SPELL_SPIRIT_BURST, H_SPELL_SPIRIT_BURST));
                 m_uiAbility_RANULF_Timer = 10000; // overtime
             } else m_uiAbility_RANULF_Timer -= diff;
+
             if (m_bIsActiveWithTORGYN && m_uiAbility_TORGYN_Timer < diff)
             {
                 float x,y,z;
                 x = m_creature->GetPositionX()-5;
                 y = m_creature->GetPositionY()-5;
                 z = m_creature->GetPositionZ();
-                for (uint8 i = 0; i < 4; ++i)
+                for(uint8 i = 0; i < 4; ++i)
                 {
                     //DoCast(m_creature, SPELL_SUMMON_AVENGING_SPIRIT); // works fine, but using summon has better control
                     if (Creature* pTemp = m_creature->SummonCreature(CREATURE_AVENGING_SPIRIT, x+rand()%10, y+rand()%10, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000))
@@ -252,27 +289,33 @@ struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
                 }
                 m_uiAbility_TORGYN_Timer = 15000; // overtime
             } else m_uiAbility_TORGYN_Timer -= diff;
+
             // Health check -----------------------------------------------------------------------------
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < (100-(m_uiHealthAmountMultipler * m_uiHealthAmountModifier)))
             {
                uint8 m_uiOrder = m_uiHealthAmountModifier - 1;
                ++m_uiHealthAmountModifier;
+
                 m_creature->InterruptNonMeleeSpells(true);
                 DoCast(m_creature, SPELL_SCREAMS_OF_THE_DEAD);
                 m_creature->GetMotionMaster()->Clear();
                 m_creature->StopMoving();
                 m_creature->AttackStop();
                 m_creature->GetMotionMaster()->MovePoint(0, ActiveBot[m_uiActiveOrder[m_uiOrder]].MoveX, ActiveBot[m_uiActiveOrder[m_uiOrder]].MoveY, ActiveBot[m_uiActiveOrder[m_uiOrder]].MoveZ);
+
                 DespawnBoatGhosts(m_uiActivedCreatureGUID);
                 DespawnBoatGhosts(m_uiOrbGUID);
+
                 m_bIsActiveWithBJORN  = false;
                 m_bIsActiveWithHALDOR = false;
                 m_bIsActiveWithRANULF = false;
                 m_bIsActiveWithTORGYN = false;
+
                 m_uiBane_Timer                += 8000;
                 m_uiFetidRot_Timer            += 8000;
                 m_uiDarkSlash_Timer           += 8000;
                 m_uiAncestors_Vengeance_Timer += 8000;
+
                 m_uiActivedNumber = m_uiOrder;
                 m_bIsWalking = true;
                 m_uiPause_Timer = 2000;
@@ -281,33 +324,42 @@ struct TRINITY_DLL_DECL boss_ymironAI : public ScriptedAI
             DoMeleeAttackIfReady();
         }
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         DespawnBoatGhosts(m_uiActivedCreatureGUID);
         DespawnBoatGhosts(m_uiOrbGUID);
+
         if (pInstance)
             pInstance->SetData(DATA_KING_YMIRON_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3,SAY_SLAY_4), m_creature);
     }
+
     void DespawnBoatGhosts(uint64& m_uiCreatureGUID)
     {
         if (m_uiCreatureGUID)
             if (Creature* pTemp = (Creature*)Unit::GetUnit(*m_creature, m_uiCreatureGUID))
                 pTemp->DisappearAndDie();
+
         m_uiCreatureGUID = 0;
     }
 };
+
 CreatureAI* GetAI_boss_ymiron(Creature* pCreature)
 {
     return new boss_ymironAI(pCreature);
 }
+
 void AddSC_boss_ymiron()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_ymiron";
     newscript->GetAI = &GetAI_boss_ymiron;
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/def_pinnacle.h b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/def_pinnacle.h
index fd1e0efa312..b446b441c17 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/def_pinnacle.h
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/def_pinnacle.h
@@ -1,17 +1,21 @@
 #ifndef DEF_PINNACLE_H
 #define DEF_PINNACLE_H
+
 #define DATA_SVALA                        1
 #define DATA_SVALA_SORROWGRAVE            2
 #define DATA_GORTOK_PALEHOOF              3
 #define DATA_SKADI_THE_RUTHLESS           4
 #define DATA_KING_YMIRON                  5
+
 #define DATA_SVALA_SORROWGRAVE_EVENT      6
 #define DATA_GORTOK_PALEHOOF_EVENT        7
 #define DATA_SKADI_THE_RUTHLESS_EVENT     8
 #define DATA_KING_YMIRON_EVENT            9
+
 #define DATA_MOB_FRENZIED_WORGEN         10
 #define DATA_MOB_RAVENOUS_FURBOLG        11
 #define DATA_MOB_MASSIVE_JORMUNGAR       12
 #define DATA_MOB_FEROCIOUS_RHINO         13
+
 #define DATA_GORTOK_PALEHOOF_SPHERE      14
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/instance_pinnacle.cpp b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/instance_pinnacle.cpp
index 0aaa243e229..7eb661668df 100644
--- a/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/instance_pinnacle.cpp
+++ b/src/bindings/scripts/scripts/northrend/utgarde_keep/utgarde_pinnacle/instance_pinnacle.cpp
@@ -1,43 +1,57 @@
 #include "precompiled.h"
 #include "def_pinnacle.h"
+
 #define MAX_ENCOUNTER     4
+
 /* Utgarde Pinnacle encounters:
 0 - Svala Sorrowgrave
 1 - Gortok Palehoof
 2 - Skadi the Ruthless
 3 - King Ymiron
 */
+
 #define ENTRY_SKADI_THE_RUTHLESS_DOOR      192173
 #define ENTRY_KING_YMIRON_DOOR             192174
 #define ENTRY_GORK_PALEHOOF_SPHERE         188593
+
 struct TRINITY_DLL_DECL instance_pinnacle : public ScriptedInstance
 {
     instance_pinnacle(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 uiSvalaSorrowgrave;
     uint64 uiGortokPalehoof;
     uint64 uiSkadiTheRuthless;
     uint64 uiKingYmiron;
+
     uint64 uiSkadiTheRuthlessDoor;
     uint64 uiKingYmironDoor;
     uint64 uiGortokPalehoofSphere;
+
     uint64 uiFrenziedWorgen;
     uint64 uiRavenousFurbolg;
     uint64 uiFerociousRhino;
     uint64 uiMassiveJormungar;
+
     uint64 uiSvala;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     std::string str_data;
+
     void Initialize()
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
            m_auiEncounter[i] = NOT_STARTED;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -53,6 +67,7 @@ struct TRINITY_DLL_DECL instance_pinnacle : public ScriptedInstance
             case 29281:    uiSvala = pCreature->GetGUID();                          break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -75,6 +90,7 @@ struct TRINITY_DLL_DECL instance_pinnacle : public ScriptedInstance
                 break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -96,9 +112,11 @@ struct TRINITY_DLL_DECL instance_pinnacle : public ScriptedInstance
                 m_auiEncounter[3] = data;
                 break;
         }
+
         if (data == DONE)
             SaveToDB();
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -110,6 +128,7 @@ struct TRINITY_DLL_DECL instance_pinnacle : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -125,18 +144,24 @@ struct TRINITY_DLL_DECL instance_pinnacle : public ScriptedInstance
             case DATA_SVALA:                  return uiSvala;
             case DATA_GORTOK_PALEHOOF_SPHERE: return uiGortokPalehoofSphere;
         }
+
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::ostringstream saveStream;
         saveStream << "U P " << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
             << m_auiEncounter[2] << " " << m_auiEncounter[3];
+
         str_data = saveStream.str();
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -144,28 +169,37 @@ struct TRINITY_DLL_DECL instance_pinnacle : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         char dataHead1, dataHead2;
         uint16 data0, data1, data2, data3;
+
         std::istringstream loadStream(in);
         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3;
+
         if (dataHead1 == 'U' && dataHead2 == 'K')
         {
             m_auiEncounter[0] = data0;
             m_auiEncounter[1] = data1;
             m_auiEncounter[2] = data2;
             m_auiEncounter[3] = data3;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 if (m_auiEncounter[i] == IN_PROGRESS)
                     m_auiEncounter[i] = NOT_STARTED;
+
         } else OUT_LOAD_INST_DATA_FAIL;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_utgarde_pinnacle(Map* pMap)
 {
     return new instance_pinnacle(pMap);
 }
+
 void AddSC_instance_utgarde_pinnacle()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/vault_of_archavon/boss_archavon.cpp b/src/bindings/scripts/scripts/northrend/vault_of_archavon/boss_archavon.cpp
index 2c81d20a46d..34e0cdc61b2 100644
--- a/src/bindings/scripts/scripts/northrend/vault_of_archavon/boss_archavon.cpp
+++ b/src/bindings/scripts/scripts/northrend/vault_of_archavon/boss_archavon.cpp
@@ -4,10 +4,12 @@ UPDATE `creature_template` SET `ScriptName`='mob_archavon_warder' WHERE `entry`=
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_vault_of_archavon.h"
+
 #define EMOTE_BERSERK           -1590002
+
 //Spells Archavon
 #define SPELL_ROCK_SHARDS        58678
-#define SPELL_CRUSHING_LEAP      HEROIC(58960,60894) //Instant (10-80yr range) -- Leaps at an enemy, inflicting 8000 Physical damage, knocking all nearby enemies away, and creating a cloud of choking debris.
+#define SPELL_CRUSHING_LEAP      HEROIC(58960,60894)//Instant (10-80yr range) -- Leaps at an enemy, inflicting 8000 Physical damage, knocking all nearby enemies away, and creating a cloud of choking debris.
 #define SPELL_STOMP              HEROIC(58663,60880)
 #define SPELL_IMPALE             HEROIC(58666,60882) //Lifts an enemy off the ground with a spiked fist, inflicting 47125 to 52875 Physical damage and 9425 to 10575 additional damage each second for 8 sec.
 #define SPELL_BERSERK            47008
@@ -15,39 +17,50 @@ UPDATE `creature_template` SET `ScriptName`='mob_archavon_warder' WHERE `entry`=
 #define SPELL_ROCK_SHOWER        HEROIC(60919,60923)
 #define SPELL_SHIELD_CRUSH       HEROIC(60897,60899)
 #define SPELL_WHIRL              HEROIC(60902,60916)
+
 //4 Warders spawned
 #define ARCHAVON_WARDER          32353 //npc 32353
+
 //Yell
 #define SAY_LEAP "Archavon the Stone Watcher lunges for $N!" //$N should be the target
+
 #define EVENT_ROCK_SHARDS        1  //15s cd
 #define EVENT_CHOKING_CLOUD      2  //30s cd
 #define EVENT_STOMP              3  //45s cd
 #define EVENT_IMPALE             4
 #define EVENT_BERSERK            5  //300s cd
+
 //mob
 #define EVENT_ROCK_SHOWER        5  //set = 20s cd,unkown cd
 #define EVENT_SHIELD_CRUSH       6  //set = 30s cd
 #define EVENT_WHIRL              8  //set= 10s cd
+
 struct TRINITY_DLL_DECL boss_archavonAI : public ScriptedAI
 {
     boss_archavonAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     EventMap events;
+
     void Reset()
     {
         events.Reset();
+
         if (pInstance)
             pInstance->SetData(DATA_ARCHAVON_EVENT, NOT_STARTED);
     }
+
     void KilledUnit(Unit* Victim){}
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_ARCHAVON_EVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
@@ -55,18 +68,23 @@ struct TRINITY_DLL_DECL boss_archavonAI : public ScriptedAI
         events.ScheduleEvent(EVENT_CHOKING_CLOUD, 30000);
         events.ScheduleEvent(EVENT_STOMP, 45000);
         events.ScheduleEvent(EVENT_BERSERK, 300000);
+
         if (pInstance)
             pInstance->SetData(DATA_ARCHAVON_EVENT, IN_PROGRESS);
     }
+
     // Below UpdateAI may need review/debug.
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         if (me->hasUnitState(UNIT_STAT_CASTING))
             return;
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -95,20 +113,25 @@ struct TRINITY_DLL_DECL boss_archavonAI : public ScriptedAI
                     return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 /*######
 ##  Mob Archavon Warder
 ######*/
 struct TRINITY_DLL_DECL mob_warderAI : public ScriptedAI //npc 32353
 {
     mob_warderAI(Creature *c) : ScriptedAI(c) {}
+
     EventMap events;
+
     void Reset()
     {
         events.Reset();
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
@@ -116,12 +139,15 @@ struct TRINITY_DLL_DECL mob_warderAI : public ScriptedAI //npc 32353
         events.ScheduleEvent(EVENT_SHIELD_CRUSH, 20000);
         events.ScheduleEvent(EVENT_WHIRL, 7500);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -146,21 +172,26 @@ struct TRINITY_DLL_DECL mob_warderAI : public ScriptedAI //npc 32353
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_warder(Creature* pCreature)
 {
     return new mob_warderAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_archavon(Creature* pCreature)
 {
     return new boss_archavonAI (pCreature);
 }
+
 void AddSC_boss_archavon()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_archavon";
     newscript->GetAI = &GetAI_boss_archavon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_archavon_warder";
     newscript->GetAI = &GetAI_mob_warder;
diff --git a/src/bindings/scripts/scripts/northrend/vault_of_archavon/boss_emalon.cpp b/src/bindings/scripts/scripts/northrend/vault_of_archavon/boss_emalon.cpp
index d7564ea7a6b..0f240bd8692 100644
--- a/src/bindings/scripts/scripts/northrend/vault_of_archavon/boss_emalon.cpp
+++ b/src/bindings/scripts/scripts/northrend/vault_of_archavon/boss_emalon.cpp
@@ -1,27 +1,34 @@
 #include "precompiled.h"
 #include "def_vault_of_archavon.h"
+
 //Emalon spells
 #define SPELL_CHAIN_LIGHTNING           HEROIC(64213, 64215)
 #define SPELL_LIGHTNING_NOVA            HEROIC(64216, 65279)
 #define SPELL_OVERCHARGE                64218                   //Casted every 45 sec on a random Tempest Minion
 #define SPELL_BERSERK                   26662
+
 //Tempest Minion spells
 #define SPELL_SHOCK                     64363
 #define SPELL_OVERCHARGED               64217
 #define SPELL_OVERCHARGED_BLAST         64219                   //Casted when Overcharged reaches 10 stacks. Mob dies after that
+
 //Emotes
 #define EMOTE_OVERCHARGE        -1590000
 #define EMOTE_MINION_RESPAWN    -1590001
 #define EMOTE_BERSERK           -1590002
+
 //Events
 #define EVENT_CHAIN_LIGHTNING       1
 #define EVENT_LIGHTNING_NOVA        2
 #define EVENT_OVERCHARGE            3
 #define EVENT_BERSERK               4
 #define EVENT_SHOCK                 5
+
 //Creatures
 #define MOB_TEMPEST_MINION          33998
+
 #define MAX_TEMPEST_MINIONS         4
+
 float TempestMinions[4][4] =
 {
     {-203.980103, -281.287720, 91.650223, 1.598807},
@@ -29,6 +36,7 @@ float TempestMinions[4][4] =
     {-233.267578, -297.104645, 91.681915, 1.598807},
     {-203.842529, -297.097015, 91.745163, 1.598807}
 };
+
 /*######
 ##  Emalon the Storm Watcher
 ######*/
@@ -38,23 +46,31 @@ struct TRINITY_DLL_DECL boss_emalonAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     EventMap events;
+
     std::list MinionList;
+
     void Reset()
     {
         events.Reset();
+
         DespawnAllMinions();
+
         for (uint8 i = 0; i < MAX_TEMPEST_MINIONS; ++i)
             m_creature->SummonCreature(MOB_TEMPEST_MINION, TempestMinions[i][0], TempestMinions[i][1], TempestMinions[i][2], TempestMinions[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
+
         if (pInstance)
             pInstance->SetData(DATA_EMALON_EVENT, NOT_STARTED);
     }
+
     void DespawnAllMinions()
     {
         if(!MinionList.empty())
         {
-            for (std::list::const_iterator itr = MinionList.begin(); itr != MinionList.end(); itr++)
+            for(std::list::const_iterator itr = MinionList.begin(); itr != MinionList.end(); itr++)
             {
                 Creature *Minion = Unit::GetCreature(*m_creature, *itr);
                 if(Minion && Minion->isAlive())
@@ -63,45 +79,56 @@ struct TRINITY_DLL_DECL boss_emalonAI : public ScriptedAI
         }
         MinionList.clear();
     }
+
     void JustSummoned(Creature *summoned)
     {
         MinionList.push_back(summoned->GetGUID());
+
         if(m_creature->getVictim())
             summoned->AI()->AttackStart(m_creature->getVictim());
     }
+
     void JustDied(Unit* Killer)
     {
         DespawnAllMinions();
+
         if (pInstance)
             pInstance->SetData(DATA_EMALON_EVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         if(!MinionList.empty())
         {
-            for (std::list::const_iterator itr = MinionList.begin(); itr != MinionList.end(); ++itr)
+            for(std::list::const_iterator itr = MinionList.begin(); itr != MinionList.end(); ++itr)
             {
                 Creature *Minion = Unit::GetCreature(*m_creature, *itr);
                 if(Minion && Minion->isAlive() && !Minion->getVictim())
                     Minion->AI()->AttackStart(who);
             }
         }
+
         DoZoneInCombat();
         events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 5000);
         events.ScheduleEvent(EVENT_LIGHTNING_NOVA, 40000);
         events.ScheduleEvent(EVENT_BERSERK, 360000);
         events.ScheduleEvent(EVENT_OVERCHARGE, 45000);
+
         if (pInstance)
             pInstance->SetData(DATA_EMALON_EVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if(!UpdateVictim())
             return;
+
         events.Update(diff);
+
         if(me->hasUnitState(UNIT_STAT_CASTING))
             return;
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -136,9 +163,11 @@ struct TRINITY_DLL_DECL boss_emalonAI : public ScriptedAI
                 return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 /*######
 ##  Tempest Minion
 ######*/
@@ -150,16 +179,23 @@ struct TRINITY_DLL_DECL mob_tempest_minionAI : public ScriptedAI
         EmalonGUID = pInstance ? pInstance->GetData64(DATA_EMALON) : 0;
         Emalon = Unit::GetCreature(*m_creature, EmalonGUID);
     }
+
     ScriptedInstance* pInstance;
+
     EventMap events;
+
     uint64 EmalonGUID;
     Creature* Emalon;
+
     uint32 OverchargedTimer;
+
     void Reset()
     {
         events.Reset();
+
         OverchargedTimer = 0;
     }
+
     void JustDied(Unit* Killer)
     {
         if(Emalon && Emalon->isAlive())
@@ -168,21 +204,27 @@ struct TRINITY_DLL_DECL mob_tempest_minionAI : public ScriptedAI
             DoScriptText(EMOTE_MINION_RESPAWN, m_creature);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
         events.ScheduleEvent(EVENT_SHOCK, 20000);
+
         if(Emalon && !Emalon->getVictim())
             Emalon->AI()->AttackStart(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if(!UpdateVictim())
             return;
+
         events.Update(diff);
+
         if(me->hasUnitState(UNIT_STAT_CASTING))
             return;
+
         if(Aura *OverchargedAura = m_creature->GetAura(SPELL_OVERCHARGED))
         {
             if(OverchargedAura->GetStackAmount() < 10)
@@ -203,6 +245,7 @@ struct TRINITY_DLL_DECL mob_tempest_minionAI : public ScriptedAI
                 }
             }
         }
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -213,24 +256,30 @@ struct TRINITY_DLL_DECL mob_tempest_minionAI : public ScriptedAI
                 return;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_tempest_minion(Creature *_Creature)
 {
     return new mob_tempest_minionAI (_Creature);
 }
+
 CreatureAI* GetAI_boss_emalon(Creature *_Creature)
 {
     return new boss_emalonAI (_Creature);
 }
+
 void AddSC_boss_emalon()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_emalon";
     newscript->GetAI = &GetAI_boss_emalon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_tempest_minion";
     newscript->GetAI = &GetAI_mob_tempest_minion;
diff --git a/src/bindings/scripts/scripts/northrend/vault_of_archavon/def_vault_of_archavon.h b/src/bindings/scripts/scripts/northrend/vault_of_archavon/def_vault_of_archavon.h
index e61edf6776a..95c44035184 100644
--- a/src/bindings/scripts/scripts/northrend/vault_of_archavon/def_vault_of_archavon.h
+++ b/src/bindings/scripts/scripts/northrend/vault_of_archavon/def_vault_of_archavon.h
@@ -1,5 +1,6 @@
 #ifndef DEF_ARCHAVON_H
 #define DEF_ARCHAVON_H
+
 #define DATA_ARCHAVON_EVENT         1
 #define DATA_EMALON_EVENT           2
 #define DATA_EMALON                 3
diff --git a/src/bindings/scripts/scripts/northrend/vault_of_archavon/instance_vault_of_archavon.cpp b/src/bindings/scripts/scripts/northrend/vault_of_archavon/instance_vault_of_archavon.cpp
index f2dc5b19a66..45d0a4be7ae 100644
--- a/src/bindings/scripts/scripts/northrend/vault_of_archavon/instance_vault_of_archavon.cpp
+++ b/src/bindings/scripts/scripts/northrend/vault_of_archavon/instance_vault_of_archavon.cpp
@@ -1,29 +1,39 @@
 #include "precompiled.h"
 #include "def_vault_of_archavon.h"
+
 #define ENCOUNTERS 2
+
 /* Vault of Archavon encounters:
 1 - Archavon the Stone Watcher event
 2 - Emalon the Storm Watcher event
 */
+
 struct TRINITY_DLL_DECL instance_archavon : public ScriptedInstance
 {
     instance_archavon(Map *Map) : ScriptedInstance(Map) {Initialize();};
+
     uint32 Encounters[ENCOUNTERS];
+
     uint64 Archavon;
     uint64 Emalon;
+
     void Initialize()
     {
         Archavon = 0;
         Emalon = 0;
-        for (uint8 i = 0; i < ENCOUNTERS; i++)
+
+        for(uint8 i = 0; i < ENCOUNTERS; i++)
             Encounters[i] = NOT_STARTED;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < ENCOUNTERS; i++)
+        for(uint8 i = 0; i < ENCOUNTERS; i++)
             if(Encounters[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature *creature, bool add)
     {
         switch(creature->GetEntry())
@@ -32,6 +42,7 @@ struct TRINITY_DLL_DECL instance_archavon : public ScriptedInstance
         case 33993: Emalon = creature->GetGUID(); break;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -41,6 +52,7 @@ struct TRINITY_DLL_DECL instance_archavon : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -50,6 +62,7 @@ struct TRINITY_DLL_DECL instance_archavon : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -57,9 +70,11 @@ struct TRINITY_DLL_DECL instance_archavon : public ScriptedInstance
             case DATA_ARCHAVON_EVENT: Encounters[0] = data; break;
             case DATA_EMALON_EVENT: Encounters[1] = data; break;
         }
+
         if(data == DONE)
             SaveToDB();
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
@@ -72,8 +87,10 @@ struct TRINITY_DLL_DECL instance_archavon : public ScriptedInstance
             OUT_SAVE_INST_DATA_COMPLETE;
             return out;
         }
+
         return NULL;
     }
+
     void Load(const char* in)
     {
         if(!in)
@@ -81,19 +98,22 @@ struct TRINITY_DLL_DECL instance_archavon : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
         std::istringstream stream(in);
         stream >> Encounters[0] >> Encounters[1];
-        for (uint8 i = 0; i < ENCOUNTERS; ++i)
+        for(uint8 i = 0; i < ENCOUNTERS; ++i)
             if(Encounters[i] == IN_PROGRESS)
                 Encounters[i] = NOT_STARTED;
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_archavon(Map* map)
 {
     return new instance_archavon(map);
 }
+
 void AddSC_instance_archavon()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/boss_cyanigosa.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/boss_cyanigosa.cpp
index 50f2e0c7462..6d4822a01d9 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/boss_cyanigosa.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/boss_cyanigosa.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_violet_hold.h"
+
 enum Spells
 {
     SPELL_ARCANE_VACUM                             = 58694,
@@ -21,6 +23,7 @@ enum Spells
     SPELL_UNCONTROLLABLE_ENERGY                    = 58688,
     H_SPELL_UNCONTROLLABLE_ENERGY                  = 59281
 };
+
 enum Yells
 {
     SAY_AGGRO                                   = -1608000,
@@ -34,39 +37,49 @@ enum Yells
     SAY_SPECIAL_ATTACK_1                        = -1608008,
     SAY_SPECIAL_ATTACK_2                        = -1608009
 };
+
 struct TRINITY_DLL_DECL boss_cyanigosaAI : public ScriptedAI
 {
     boss_cyanigosaAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiArcaneVacumTimer;
     uint32 uiBlizzardTimer;
     uint32 uiManaDestructionTimer;
     uint32 uiTailSweepTimer;
     uint32 uiUncontrollableEnergyTimer;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_CYANIGOSA_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_CYANIGOSA_EVENT, IN_PROGRESS);
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiArcaneVacumTimer < diff)
         {
             DoCast(m_creature, SPELL_ARCANE_VACUM);
         } else uiArcaneVacumTimer -= diff;
+
         if (uiBlizzardTimer < diff)
         {
             Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
@@ -75,14 +88,17 @@ struct TRINITY_DLL_DECL boss_cyanigosaAI : public ScriptedAI
             if (pTarget)
                 DoCast(pTarget, HeroicMode ? H_SPELL_BLIZZARD : SPELL_BLIZZARD);
         } else uiBlizzardTimer -= diff;
+
         if (uiTailSweepTimer < diff)
         {
             DoCast(m_creature, HeroicMode ? H_SPELL_TAIL_SWEEP : SPELL_TAIL_SWEEP);
         } else uiTailSweepTimer -= diff;
+
         if (uiUncontrollableEnergyTimer < diff)
         {
             DoCast(m_creature->getVictim(), HeroicMode ? H_SPELL_UNCONTROLLABLE_ENERGY : SPELL_UNCONTROLLABLE_ENERGY);
         } else uiUncontrollableEnergyTimer -= diff;
+
         if (HeroicMode)
             if (uiManaDestructionTimer < diff)
             {
@@ -92,14 +108,18 @@ struct TRINITY_DLL_DECL boss_cyanigosaAI : public ScriptedAI
                 if (pTarget)
                     DoCast(pTarget, SPELL_MANA_DESTRUCTION);
             } else uiManaDestructionTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_CYANIGOSA_EVENT, DONE);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
@@ -107,13 +127,16 @@ struct TRINITY_DLL_DECL boss_cyanigosaAI : public ScriptedAI
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_cyanigosa(Creature* pCreature)
 {
     return new boss_cyanigosaAI (pCreature);
 }
+
 void AddSC_boss_cyanigosa()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_cyanigosa";
     newscript->GetAI = &GetAI_boss_cyanigosa;
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/boss_erekem.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/boss_erekem.cpp
index 4855079fc06..cf6686421d1 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/boss_erekem.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/boss_erekem.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_violet_hold.h"
+
 enum Spells
 {
     SPELL_BLOODLUST                                = 54516,
@@ -22,6 +24,7 @@ enum Spells
     SPELL_LIGHTNING_BOLT                           = 53044,
     SPELL_STORMSTRIKE                              = 51876
 };
+
 //not in db
 enum Yells
 {
@@ -34,20 +37,25 @@ enum Yells
     SAY_ADD_KILLED                              = -1608016,
     SAY_BOTH_ADDS_KILLED                        = -1608017
 };
+
 struct TRINITY_DLL_DECL boss_erekemAI : public ScriptedAI
 {
     boss_erekemAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiBloodlustTimer;
     uint32 uiChainHealTimer;
     uint32 uiEarthShockTimer;
     uint32 uiLightningBoltTimer;
     uint32 uiEarthShieldTimer;
+
     Creature* pGuard1;
     Creature* pGuard2;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiBloodlustTimer = 15000;
@@ -63,10 +71,12 @@ struct TRINITY_DLL_DECL boss_erekemAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
         }
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoCast(m_creature, HEROIC(SPELL_EARTH_SHIELD, H_SPELL_EARTH_SHIELD));
+
         if (pInstance)
         {
             if (pInstance->GetData(DATA_WAVE_COUNT) == 6)
@@ -75,12 +85,15 @@ struct TRINITY_DLL_DECL boss_erekemAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
         }
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //spam stormstrike in hc mode if spawns are dead
         if (HeroicMode)
         {
@@ -89,11 +102,13 @@ struct TRINITY_DLL_DECL boss_erekemAI : public ScriptedAI
                 DoCast(m_creature->getVictim(), SPELL_STORMSTRIKE);
             }
         }
+
         if (uiEarthShieldTimer < diff)
         {
             DoCast(m_creature, HEROIC(SPELL_EARTH_SHIELD, H_SPELL_EARTH_SHIELD));
             uiEarthShieldTimer = 20000;
         } else uiEarthShieldTimer -= diff;
+
         if (uiChainHealTimer < diff)
         {
             if (Creature *pTarget = GetChainHealTarget())
@@ -103,17 +118,20 @@ struct TRINITY_DLL_DECL boss_erekemAI : public ScriptedAI
                 uiChainHealTimer = ((pGuard1 && !pGuard1->isAlive()) || (pGuard2 && !pGuard2->isAlive()) ? 3000 : 8000) + rand()%3000;
             }
         } else uiChainHealTimer -= diff;
+
         if (uiBloodlustTimer < diff)
         {
             DoCast(m_creature,SPELL_BLOODLUST);
             uiBloodlustTimer = urand(35000,45000);
         } else uiBloodlustTimer -= diff;
 
+
         if (uiEarthShockTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_EARTH_SHOCK);
             uiEarthShockTimer = urand(8000,13000);
         } else uiEarthShockTimer -= diff;
+
         if (uiLightningBoltTimer < diff)
         {
             Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
@@ -123,11 +141,14 @@ struct TRINITY_DLL_DECL boss_erekemAI : public ScriptedAI
                 DoCast(pTarget, SPELL_LIGHTNING_BOLT);
             uiLightningBoltTimer = urand(18000,24000);
         } else uiLightningBoltTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
         {
             if (pInstance->GetData(DATA_WAVE_COUNT) == 6)
@@ -142,43 +163,53 @@ struct TRINITY_DLL_DECL boss_erekemAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     Creature* GetChainHealTarget()
     {
         Creature* pTarget = NULL;
         return pTarget;
     }
 };
+
 CreatureAI* GetAI_boss_erekem(Creature* pCreature)
 {
     return new boss_erekemAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_erekem_guardAI : public ScriptedAI
 {
     mob_erekem_guardAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiEarthShieldTimer;
     uint32 uiLightningBoltTimer;
     uint32 uiBloodlustTimer;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiEarthShieldTimer = 20000;
         uiLightningBoltTimer = urand(0,5000);
         uiBloodlustTimer = urand(8000,18000);
     }
+
     void EnterCombat(Unit* who)
     {
         DoCast(m_creature, H_SPELL_EARTH_SHIELD);
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (uiEarthShieldTimer < diff)
@@ -186,12 +217,14 @@ struct TRINITY_DLL_DECL mob_erekem_guardAI : public ScriptedAI
             DoCast(m_creature, H_SPELL_EARTH_SHIELD);
             uiEarthShieldTimer = 20000;
         } else uiEarthShieldTimer -= diff;
+
         if (uiLightningBoltTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 DoCast(pTarget, SPELL_LIGHTNING_BOLT);
             uiLightningBoltTimer = urand(18000,24000);
         } else uiLightningBoltTimer -= diff;
+
         if (uiBloodlustTimer < diff)
         {
             DoCast(m_creature,SPELL_BLOODLUST);
@@ -199,18 +232,22 @@ struct TRINITY_DLL_DECL mob_erekem_guardAI : public ScriptedAI
         } else uiBloodlustTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_erekem_guard(Creature* pCreature)
 {
     return new mob_erekem_guardAI (pCreature);
 }
 
+
 void AddSC_boss_erekem()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_erekem";
     newscript->GetAI = &GetAI_boss_erekem;
     newscript->RegisterSelf();
+
     newscript->Name = "mob_erekem_guard";
     newscript->GetAI = &GetAI_mob_erekem_guard;
     newscript->RegisterSelf();
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/boss_ichoron.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/boss_ichoron.cpp
index 3b859c596df..3d9f5bc659c 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/boss_ichoron.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/boss_ichoron.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_violet_hold.h"
+
 enum Spells
 {
     SPELL_DRAINED                                  = 59820,
@@ -21,6 +23,7 @@ enum Spells
     SPELL_WATER_BOLT_VOLLEY                        = 54241,
     H_SPELL_WATER_BOLT_VOLLEY                      = 59521
 };
+
 //not in db
 enum Yells
 {
@@ -34,24 +37,31 @@ enum Yells
     SAY_SHATTER                                 = -1608025,
     SAY_BUBBLE                                  = -1608026
 };
+
 enum CombatPhase
 {
     BUBBLED,
     SUMMONS,
     DPS
 };
+
 struct TRINITY_DLL_DECL boss_ichoronAI : public ScriptedAI
 {
     boss_ichoronAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     CombatPhase Phase;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         Phase = BUBBLED;
+
         DoCast(m_creature, SPELL_PROTECTIVE_BUBBLE);
+
         if (pInstance)
         {
             if (pInstance->GetData(DATA_WAVE_COUNT) == 6)
@@ -63,6 +73,7 @@ struct TRINITY_DLL_DECL boss_ichoronAI : public ScriptedAI
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
         {
             if (pInstance->GetData(DATA_WAVE_COUNT) == 6)
@@ -71,16 +82,20 @@ struct TRINITY_DLL_DECL boss_ichoronAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
         {
             if (pInstance->GetData(DATA_WAVE_COUNT) == 6)
@@ -95,6 +110,7 @@ struct TRINITY_DLL_DECL boss_ichoronAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
@@ -102,13 +118,16 @@ struct TRINITY_DLL_DECL boss_ichoronAI : public ScriptedAI
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_ichoron(Creature* pCreature)
 {
     return new boss_ichoronAI (pCreature);
 }
+
 void AddSC_boss_ichoron()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_ichoron";
     newscript->GetAI = &GetAI_boss_ichoron;
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/boss_lavanthor.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/boss_lavanthor.cpp
index 7316c004219..fc493735a72 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/boss_lavanthor.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/boss_lavanthor.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_violet_hold.h"
+
 enum Spells
 {
   SPELL_CAUTERIZING_FLAMES                      = 59466, //Only in heroic
@@ -20,17 +22,21 @@ enum Spells
   SPELL_LAVA_BURN                               = 54249,
   H_SPELL_LAVA_BURN                             = 59594
 };
+
 struct TRINITY_DLL_DECL boss_lavanthorAI : public ScriptedAI
 {
     boss_lavanthorAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiFireboltTimer;
     uint32 uiFlameBreathTimer;
     uint32 uiLavaBurnTimer;
     uint32 uiCauterizingFlamesTimer;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiFireboltTimer = 1000;
@@ -45,6 +51,7 @@ struct TRINITY_DLL_DECL boss_lavanthorAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
         }
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
@@ -55,27 +62,33 @@ struct TRINITY_DLL_DECL boss_lavanthorAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
         }
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiFireboltTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_FIREBOLT, H_SPELL_FIREBOLT));
             uiFireboltTimer = urand(5000,13000);
         } else uiFireboltTimer -= diff;
+
         if (uiFlameBreathTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_FLAME_BREATH, H_SPELL_FLAME_BREATH));
             uiFlameBreathTimer = urand(10000,15000);
         } else uiFlameBreathTimer -= diff;
+
         if (uiLavaBurnTimer < diff)
         {
             DoCast(m_creature->getVictim(), HEROIC(SPELL_LAVA_BURN, H_SPELL_LAVA_BURN));
             uiLavaBurnTimer = urand(15000,23000);
         }
+
         if (HeroicMode)
         {
             if (uiCauterizingFlamesTimer < diff)
@@ -84,8 +97,10 @@ struct TRINITY_DLL_DECL boss_lavanthorAI : public ScriptedAI
                 uiCauterizingFlamesTimer = urand(10000,16000);
             } else uiCauterizingFlamesTimer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
@@ -103,13 +118,16 @@ struct TRINITY_DLL_DECL boss_lavanthorAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_lavanthor(Creature* pCreature)
 {
     return new boss_lavanthorAI (pCreature);
 }
+
 void AddSC_boss_lavanthor()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_lavanthor";
     newscript->GetAI = &GetAI_boss_lavanthor;
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/boss_moragg.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/boss_moragg.cpp
index 00e136139fb..53501a6425a 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/boss_moragg.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/boss_moragg.cpp
@@ -5,31 +5,38 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_violet_hold.h"
 
+
 //Spells
 enum Spells
 {
     SPELL_CORROSIVE_SALIVA                     = 54527,
     SPELL_OPTIC_LINK                           = 54396
 };
+
 struct TRINITY_DLL_DECL boss_moraggAI : public ScriptedAI
 {
     boss_moraggAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiOpticLinkTimer;
     uint32 uiCorrosiveSalivaTimer;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         uiOpticLinkTimer = 10000;
         uiCorrosiveSalivaTimer = 5000;
+
         if (pInstance)
         {
             if (pInstance->GetData(DATA_WAVE_COUNT) == 6)
@@ -38,6 +45,7 @@ struct TRINITY_DLL_DECL boss_moraggAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
         }
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
@@ -48,23 +56,28 @@ struct TRINITY_DLL_DECL boss_moraggAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
         }
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (uiOpticLinkTimer < diff)
         {
             if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                 DoCast(pTarget,SPELL_OPTIC_LINK);
             uiOpticLinkTimer = 15000;
         } else uiOpticLinkTimer -= diff;
+
         if (uiCorrosiveSalivaTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_CORROSIVE_SALIVA);
             uiCorrosiveSalivaTimer = 10000;
         } else uiCorrosiveSalivaTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
@@ -84,13 +97,16 @@ struct TRINITY_DLL_DECL boss_moraggAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_moragg(Creature* pCreature)
 {
     return new boss_moraggAI (pCreature);
 }
+
 void AddSC_boss_moragg()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_moragg";
     newscript->GetAI = &GetAI_boss_moragg;
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/boss_xevozz.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/boss_xevozz.cpp
index 9ad67768fcf..3f607bcd3f3 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/boss_xevozz.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/boss_xevozz.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_violet_hold.h"
+
 enum Spells
 {
     SPELL_ARCANE_BARRAGE_VOLLEY                    = 54202,
@@ -23,17 +25,20 @@ enum Spells
     SPELL_SUMMON_ETHEREAL_SPHERE_3                 = 54138,
     H_SPELL_SUMMON_ETHEREAL_SPHERE_3               = 61339
 };
+
 enum Creatures
 {
     CREATURE_ETHEREAL_SPHERE                       = 29271,
     H_CREATURE_ETHEREAL_SPHERE                     = 32582
 };
+
 enum CreatureSpells
 {
     SPELL_ARCANE_POWER                             = 54160,
     H_SPELL_ARCANE_POWER                           = 59474,
     SPELL_SUMMON_PLAYERS                           = 54164
 };
+
 //not in db
 enum Yells
 {
@@ -48,13 +53,16 @@ enum Yells
     SAY_REPEAT_SUMMON_2                         = -1608035,
     SAY_SUMMON_ENERGY                           = -1608036
 };
+
 struct TRINITY_DLL_DECL boss_xevozzAI : public ScriptedAI
 {
     boss_xevozzAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         if (pInstance)
@@ -65,6 +73,7 @@ struct TRINITY_DLL_DECL boss_xevozzAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
         }
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
@@ -76,14 +85,18 @@ struct TRINITY_DLL_DECL boss_xevozzAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
         }
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
@@ -108,13 +121,16 @@ struct TRINITY_DLL_DECL boss_xevozzAI : public ScriptedAI
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_xevozz(Creature* pCreature)
 {
     return new boss_xevozzAI (pCreature);
 }
+
 void AddSC_boss_xevozz()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_xevozz";
     newscript->GetAI = &GetAI_boss_xevozz;
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/boss_zuramat.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/boss_zuramat.cpp
index e9a7d5aef20..d573060f50e 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/boss_zuramat.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/boss_zuramat.cpp
@@ -5,11 +5,13 @@ SD%Complete:
 SDComment:
 SDCategory:
 Script Data End */
+
 /*** SQL START ***
 update creature_template set scriptname = '' where entry = '';
 *** SQL END ***/
 #include "precompiled.h"
 #include "def_violet_hold.h"
+
 enum Spells
 {
     SPELL_SHROUD_OF_DARKNESS                       = 54524,
@@ -18,10 +20,12 @@ enum Spells
     SPELL_VOID_SHIFT                               = 54361,
     H_SPELL_VOID_SHIFT                             = 59743
 };
+
 enum Creatures
 {
     CREATURE_VOID_SENTRY                           = 29364
 };
+
 //not in db
 enum Yells
 {
@@ -34,14 +38,18 @@ enum Yells
     SAY_SHIELD                                  = -1608043,
     SAY_WHISPER                                 = -1608044
 };
+
 struct TRINITY_DLL_DECL boss_zuramatAI : public ScriptedAI
 {
     boss_zuramatAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 void_shift;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         if (pInstance)
@@ -52,6 +60,7 @@ struct TRINITY_DLL_DECL boss_zuramatAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
         }
     }
+
     void EnterCombat(Unit* who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
@@ -63,17 +72,21 @@ struct TRINITY_DLL_DECL boss_zuramatAI : public ScriptedAI
                 pInstance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
         }
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
         {
             if (pInstance->GetData(DATA_WAVE_COUNT) == 6)
@@ -88,20 +101,25 @@ struct TRINITY_DLL_DECL boss_zuramatAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
 };
+
 CreatureAI* GetAI_boss_zuramat(Creature* pCreature)
 {
     return new boss_zuramatAI (pCreature);
 }
+
 void AddSC_boss_zuramat()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_zuramat";
     newscript->GetAI = &GetAI_boss_zuramat;
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/def_violet_hold.h b/src/bindings/scripts/scripts/northrend/violet_hold/def_violet_hold.h
index 02ce2e251ae..4e989ffb7bb 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/def_violet_hold.h
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/def_violet_hold.h
@@ -1,5 +1,6 @@
 #ifndef DEF_VIOLET_HOLD_H
 #define DEF_VIOLET_HOLD_H
+
 enum Data
 {
     DATA_1ST_BOSS_EVENT,
@@ -7,6 +8,7 @@ enum Data
     DATA_CYANIGOSA_EVENT,
     DATA_WAVE_COUNT
 };
+
 enum Data64
 {
     DATA_MORAGG,
@@ -27,4 +29,5 @@ enum Data64
     DATA_MAIN_DOOR,
     DATA_SINCLARI
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/instance_violet_hold.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/instance_violet_hold.cpp
index 7a3f462d896..60128f1b931 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/instance_violet_hold.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/instance_violet_hold.cpp
@@ -1,10 +1,13 @@
 #include "precompiled.h"
 #include "def_violet_hold.h"
+
 #define MAX_ENCOUNTER          3
+
 /* Violet Hold encounters:
 0 - First boss
 1 - Second boss
 2 - Cyanigosa*/
+
 /* Violet hold bosses:
 0 - Moragg
 1 - Erekem
@@ -38,6 +41,7 @@ const Location PortalLocation[] =
 struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
 {
     instance_violet_hold(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 uiMoragg;
     uint64 uiErekem;
     uint64 uiIchoron;
@@ -46,6 +50,7 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
     uint64 uiZuramat;
     uint64 uiCyanigosa;
     uint64 uiSinclari;
+
     uint64 uiMoraggCell;
     uint64 uiErekemCell;
     uint64 uiErekemRightGuardCell;
@@ -55,13 +60,18 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
     uint64 uiXevozzCell;
     uint64 uiZuramatCell;
     uint64 uiMainDoor;
+
     uint8 uiWaveCount;
     uint8 uiLocation;
     uint8 uiFirstBoss;
     uint8 uiSecondBoss;
+
     uint8 m_auiEncounter[MAX_ENCOUNTER];
+
     bool HeroicMode;
+
     std::string str_data;
+
     void Initialize()
     {
         uiMoragg = 0;
@@ -72,6 +82,7 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
         uiZuramat = 0;
         uiCyanigosa = 0;
         uiSinclari = 0;
+
         uiMoraggCell = 0;
         uiErekemCell = 0;
         uiErekemRightGuardCell = 0;
@@ -81,18 +92,23 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
         uiXevozzCell = 0;
         uiZuramatCell = 0;
         uiMainDoor = 0;
+
         uiWaveCount = 0;
         uiLocation = 0;
         uiFirstBoss = 0;
         uiSecondBoss = 0;
+
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -123,6 +139,7 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
                 break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -165,6 +182,7 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
                 break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -230,6 +248,7 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
                 break;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -239,8 +258,10 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
             case DATA_CYANIGOSA_EVENT:          return m_auiEncounter[2];
             case DATA_WAVE_COUNT:               return uiWaveCount;
         }
+
         return 0;
     }
+
     void StartBossEncounter(uint8 uiBoss)
     {
         Creature* pBoss = NULL;
@@ -301,6 +322,7 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
                 break;
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -323,18 +345,24 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
             case DATA_MAIN_DOOR:                return uiMainDoor;
             case DATA_SINCLARI:                 return uiSinclari;
         }
+
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
+
         std::ostringstream saveStream;
         saveStream << "V H " << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
             << m_auiEncounter[2] << " " << uiFirstBoss << " " << uiSecondBoss;
+
         str_data = saveStream.str();
+
         OUT_SAVE_INST_DATA_COMPLETE;
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -342,29 +370,38 @@ struct TRINITY_DLL_DECL instance_violet_hold : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         char dataHead1, dataHead2;
         uint16 data0, data1, data2, data3, data4;
+
         std::istringstream loadStream(in);
         loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3 >> data4;
+
         if (dataHead1 == 'V' && dataHead2 == 'H')
         {
             m_auiEncounter[0] = data0;
             m_auiEncounter[1] = data1;
             m_auiEncounter[2] = data2;
-            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                 if (m_auiEncounter[i] == IN_PROGRESS)
                     m_auiEncounter[i] = NOT_STARTED;
+
             uiFirstBoss = data3;
             uiSecondBoss = data4;
         }else OUT_LOAD_INST_DATA_FAIL;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_violet_hold(Map* pMap)
 {
     return new instance_violet_hold(pMap);
 }
+
 void AddSC_instance_violet_hold()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/violet_hold.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/violet_hold.cpp
index 1d11a31767d..900b0021336 100644
--- a/src/bindings/scripts/scripts/northrend/violet_hold/violet_hold.cpp
+++ b/src/bindings/scripts/scripts/northrend/violet_hold/violet_hold.cpp
@@ -1,8 +1,10 @@
 #include "precompiled.h"
 #include "def_violet_hold.h"
+
 #define GOSSIP_START_EVENT "[PH]: Start Event"
 #define NEXT_WAVE_TIME        90000
 #define SPAWN_TIME             9000
+
 enum Creatures
 {
     CREATURE_AZURE_INVADER            = 30661,
@@ -11,6 +13,7 @@ enum Creatures
     CREATURE_AZURE_MAGE_SLAYER        = 30664,
     CREATURE_AZURE_CAPTAIN            = 30666
 };
+
 bool GossipHello_npc_sinclari(Player* pPlayer, Creature* pCreature)
 {
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
@@ -19,6 +22,7 @@ bool GossipHello_npc_sinclari(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(1, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_sinclari(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     pPlayer->CLOSE_GOSSIP_MENU();
@@ -27,22 +31,28 @@ bool GossipSelect_npc_sinclari(Player* pPlayer, Creature* pCreature, uint32 uiSe
         pInstance->SetData(DATA_WAVE_COUNT,1);
     return true;
 }
+
 struct TRINITY_DLL_DECL npc_teleportation_portalAI : public ScriptedAI
 {
     npc_teleportation_portalAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 uiDespawnTimer;
     uint32 uiSpawnTimer;
+
     ScriptedInstance *pInstance;
+
     void reset()
     {
         uiDespawnTimer = NEXT_WAVE_TIME;
         uiSpawnTimer = 500;
     }
+
     void EnterCombat(Unit *who) {}
     void MoveInLineOfSight(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (uiSpawnTimer < diff)
@@ -61,24 +71,29 @@ struct TRINITY_DLL_DECL npc_teleportation_portalAI : public ScriptedAI
             m_creature->DisappearAndDie();
         } else uiDespawnTimer -= diff;
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_WAVE_COUNT,pInstance->GetData(DATA_WAVE_COUNT)+1);
     }
 };
+
 CreatureAI* GetAI_npc_teleportation_portal(Creature *pCreature)
 {
     return new npc_teleportation_portalAI(pCreature);
 }
+
 void AddSC_violet_hold()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_sinclari_vh";
     newscript->pGossipHello = &GossipHello_npc_sinclari;
     newscript->pGossipSelect = &GossipSelect_npc_sinclari;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_teleportation_portal_vh";
     newscript->GetAI = &GetAI_npc_teleportation_portal;
diff --git a/src/bindings/scripts/scripts/northrend/wintergrasp.cpp b/src/bindings/scripts/scripts/northrend/wintergrasp.cpp
index 241d9202e9a..53e6fca2af7 100644
--- a/src/bindings/scripts/scripts/northrend/wintergrasp.cpp
+++ b/src/bindings/scripts/scripts/northrend/wintergrasp.cpp
@@ -13,18 +13,22 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "Wintergrasp.h"
+
 #define GOSSIP_HELLO_DEMO1  "Build catapult."
 #define GOSSIP_HELLO_DEMO2  "Build demolisher."
 #define GOSSIP_HELLO_DEMO3  "Build siege engine."
 #define GOSSIP_HELLO_DEMO4  "I cannot build more!"
+
 struct TRINITY_DLL_DECL npc_demolisher_engineererAI : public ScriptedAI
 {
     npc_demolisher_engineererAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         me->SetReactState(REACT_PASSIVE);
     }
+
     /*
     void JustDied(Unit *killer)
     {
@@ -33,14 +37,17 @@ struct TRINITY_DLL_DECL npc_demolisher_engineererAI : public ScriptedAI
     }
     */
 };
+
 CreatureAI* GetAI_npc_demolisher_engineerer(Creature* pCreature)
 {
     return new npc_demolisher_engineererAI (pCreature);
 }
+
 bool GossipHello_npc_demolisher_engineerer(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if(pPlayer->isGameMaster() || pCreature->GetZoneScript() && pCreature->GetZoneScript()->GetData(pCreature->GetDBTableGUIDLow()))
     {
         if (pPlayer->HasAura(SPELL_CORPORAL))
@@ -54,9 +61,11 @@ bool GossipHello_npc_demolisher_engineerer(Player* pPlayer, Creature* pCreature)
     }
     else
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_DEMO4, GOSSIP_SENDER_MAIN,   GOSSIP_ACTION_INFO_DEF+9);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_demolisher_engineerer(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     pPlayer->CLOSE_GOSSIP_MENU();
@@ -69,11 +78,14 @@ bool GossipSelect_npc_demolisher_engineerer(Player* pPlayer, Creature* pCreature
             case 2: pPlayer->CastSpell(pPlayer, pPlayer->GetTeamId() ? 61408 : 56661, false, NULL, NULL, pCreature->GetGUID()); break;
         }
     }
+
     return true;
 }
+
 void AddSC_wintergrasp()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_demolisher_engineerer";
     newscript->GetAI = &GetAI_npc_demolisher_engineerer;
diff --git a/src/bindings/scripts/scripts/northrend/zuldrak.cpp b/src/bindings/scripts/scripts/northrend/zuldrak.cpp
index 6e187e0335b..90a047b4c44 100644
--- a/src/bindings/scripts/scripts/northrend/zuldrak.cpp
+++ b/src/bindings/scripts/scripts/northrend/zuldrak.cpp
@@ -15,22 +15,29 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
+
 /*####
 ## npc_drakuru_shackles
 ####*/
+
 enum eDrakuruShackles
 {
     SPELL_LEFT_CHAIN           = 59951,
     SPELL_RIGHT_CHAIN          = 59952,
     SPELL_UNLOCK_SHACKLE       = 55083,
     SPELL_FREE_RAGECLAW        = 55223,
+
     NPC_RAGECLAW               = 29686
 };
+
 struct TRINITY_DLL_DECL npc_drakuru_shacklesAI : public ScriptedAI
 {
     npc_drakuru_shacklesAI(Creature *c) : ScriptedAI(c) {}
+
     Unit* Rageclaw;
+
     void Reset()
     {
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -40,17 +47,21 @@ struct TRINITY_DLL_DECL npc_drakuru_shacklesAI : public ScriptedAI
         if (Unit* summon = m_creature->SummonCreature(NPC_RAGECLAW,x,y,z,0,TEMPSUMMON_DEAD_DESPAWN,1000))
             DoActionOnRageclaw(true,summon);
     }
+
     void DoActionOnRageclaw(bool locking, Unit *who)
     {
         if (!who)
             return;
+
         if (locking)
         {
             if (who)
             {
                 Rageclaw = who;
+
                 m_creature->SetInFront(Rageclaw);
                 Rageclaw->SetInFront(m_creature);
+
                 m_creature->CastSpell(Rageclaw, SPELL_LEFT_CHAIN, true);
                 m_creature->CastSpell(Rageclaw, SPELL_RIGHT_CHAIN, true);
             }
@@ -62,6 +73,7 @@ struct TRINITY_DLL_DECL npc_drakuru_shacklesAI : public ScriptedAI
             m_creature->setDeathState(DEAD);
         }
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_UNLOCK_SHACKLE)
@@ -70,31 +82,39 @@ struct TRINITY_DLL_DECL npc_drakuru_shacklesAI : public ScriptedAI
                 DoActionOnRageclaw(false,caster);
             else
                 m_creature->setDeathState(JUST_DIED);
+
         }
     }
 };
+
 CreatureAI* GetAI_npc_drakuru_shackles(Creature* pCreature)
 {
     return new npc_drakuru_shacklesAI (pCreature);
 }
 
+
 /*####
 ## npc_captured_rageclaw
 ####*/
+
 enum eRageclaw
 {
     SPELL_UNSHACKLED           = 55085,
     SPELL_KNEEL                = 39656
 };
+
 const char * SAY_RAGECLAW_1 =      "I poop on you, trollses!";
 const char * SAY_RAGECLAW_2 =      "ARRRROOOOGGGGAAAA!";
 const char * SAY_RAGECLAW_3 =      "No more mister nice wolvar!";
 #define SAY_RAGECLAW RAND(SAY_RAGECLAW_1,SAY_RAGECLAW_2,SAY_RAGECLAW_3)
+
 struct TRINITY_DLL_DECL npc_captured_rageclawAI : public ScriptedAI
 {
     npc_captured_rageclawAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 DespawnTimer;
     bool Despawn;
+
     void Reset()
     {
         Despawn = false;
@@ -102,22 +122,30 @@ struct TRINITY_DLL_DECL npc_captured_rageclawAI : public ScriptedAI
         m_creature->setFaction(35);
         m_creature->CastSpell(m_creature, SPELL_KNEEL, true); // Little Hack for kneel - Thanks Illy :P
     }
+
     void MoveInLineOfSight(Unit *who){}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_FREE_RAGECLAW)
         {
             m_creature->RemoveAurasDueToSpell(SPELL_LEFT_CHAIN);
+
             m_creature->RemoveAurasDueToSpell(SPELL_RIGHT_CHAIN);
+
             m_creature->RemoveAurasDueToSpell(SPELL_KNEEL);
+
             m_creature->setFaction(m_creature->GetCreatureInfo()->faction_H);
+
             DoCast(m_creature, SPELL_UNSHACKLED, true);
             m_creature->MonsterSay(SAY_RAGECLAW, LANG_UNIVERSAL, NULL);
             m_creature->GetMotionMaster()->MoveRandom(10);
+
             DespawnTimer = 10000;
             Despawn = true;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (m_creature->getVictim())
@@ -125,38 +153,48 @@ struct TRINITY_DLL_DECL npc_captured_rageclawAI : public ScriptedAI
             DoMeleeAttackIfReady();
             return;
         }
+
         if (!Despawn)
             return;
+
         if (DespawnTimer < diff)
             m_creature->setDeathState(JUST_DIED);
         else DespawnTimer-=diff;
    }
 };
+
 CreatureAI* GetAI_npc_captured_rageclaw(Creature* pCreature)
 {
     return new npc_captured_rageclawAI (pCreature);
 }
+
 /*####
 ## npc_gymer
 ####*/
+
 #define    GOSSIP_ITEM_G "I'm ready, Gymer. Let's go!"
+
 enum eGymer
 {
     QUEST_STORM_KING_VENGEANCE    = 12919,
     SPELL_GYMER                   = 55568
 };
+
     bool GossipHello_npc_gymer(Player *pPlayer, Creature *pCreature)
     {
         if (pCreature->isQuestGiver())
             pPlayer->PrepareQuestMenu(pCreature->GetGUID());
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
         if (pPlayer->GetQuestStatus(QUEST_STORM_KING_VENGEANCE) == QUEST_STATUS_INCOMPLETE)
         {
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_G, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
             pPlayer->SEND_GOSSIP_MENU(13640, pCreature->GetGUID());
         }
+
         return true;
     }
+
     bool GossipSelect_npc_gymer(Player *pPlayer, Creature *pCreature, uint32 uiSender, uint32 uiAction)
     {
         if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -164,19 +202,24 @@ enum eGymer
             pPlayer->CLOSE_GOSSIP_MENU();
             pPlayer->CastSpell(pPlayer, SPELL_GYMER, true);
         }
+
         return true;
     }
+
 void AddSC_zuldrak()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_drakuru_shackles";
     newscript->GetAI = &GetAI_npc_drakuru_shackles;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_captured_rageclaw";
     newscript->GetAI = &GetAI_npc_captured_rageclaw;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_gymer";
     newscript->pGossipHello = &GossipHello_npc_gymer;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/auchenai_crypts/boss_exarch_maladaar.cpp b/src/bindings/scripts/scripts/outland/auchindoun/auchenai_crypts/boss_exarch_maladaar.cpp
index 84a5179b7a3..8b1c610e065 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/auchenai_crypts/boss_exarch_maladaar.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/auchenai_crypts/boss_exarch_maladaar.cpp
@@ -13,18 +13,22 @@
  * along with 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
@@ -34,25 +38,32 @@ EndContentData */
 #define SPELL_MORTAL_STRIKE     37335
 #define SPELL_FREEZING_TRAP     37368
 #define SPELL_HAMMER_OF_JUSTICE 37369
+
 struct TRINITY_DLL_DECL mob_stolen_soulAI : public ScriptedAI
 {
     mob_stolen_soulAI(Creature *c) : ScriptedAI(c) {}
+
     uint8 myClass;
     uint32 Class_Timer;
+
     void Reset()
     {
         Class_Timer = 1000;
     }
+
     void EnterCombat(Unit *who)
     { }
+
     void SetMyClass(uint8 myclass)
     {
         myClass = myclass;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Class_Timer < diff)
         {
             switch (myClass)
@@ -95,53 +106,72 @@ struct TRINITY_DLL_DECL mob_stolen_soulAI : public ScriptedAI
                     break;
             }
         } else Class_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_stolen_soul(Creature* pCreature)
 {
     return new mob_stolen_soulAI (pCreature);
 }
+
 #define SAY_INTRO                   -1558000
 #define SAY_SUMMON                  -1558001
+
 #define SAY_AGGRO_1                 -1558002
 #define SAY_AGGRO_2                 -1558003
 #define SAY_AGGRO_3                 -1558004
+
 #define SAY_ROAR                    -1558005
 #define SAY_SOUL_CLEAVE             -1558006
+
 #define SAY_SLAY_1                  -1558007
 #define SAY_SLAY_2                  -1558008
+
 #define SAY_DEATH                   -1558009
+
 #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 TRINITY_DLL_DECL boss_exarch_maladaarAI : public ScriptedAI
 {
     boss_exarch_maladaarAI(Creature *c) : ScriptedAI(c)
     {
         HasTaunted = false;
     }
+
     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 = 15000 + rand()% 5000;
         Ribbon_of_Souls_timer = 5000;
         StolenSoul_Timer = 25000 + rand()% 10000;
+
         Avatar_summoned = false;
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!HasTaunted && m_creature->IsWithinDistInMap(who, 150.0))
@@ -149,13 +179,16 @@ struct TRINITY_DLL_DECL boss_exarch_maladaarAI : public ScriptedAI
             DoScriptText(SAY_INTRO, m_creature);
             HasTaunted = true;
         }
+
         ScriptedAI::MoveInLineOfSight(who);
     }
 
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned->GetEntry() == ENTRY_STOLEN_SOUL)
@@ -164,38 +197,48 @@ struct TRINITY_DLL_DECL boss_exarch_maladaarAI : public ScriptedAI
             summoned->CastSpell(summoned,SPELL_STOLEN_SOUL_VISUAL,false);
             summoned->SetDisplayId(soulmodel);
             summoned->setFaction(m_creature->getFaction());
+
             if (Unit *target = Unit::GetUnit(*m_creature,soulholder))
             {
+
             CAST_AI(mob_stolen_soulAI, summoned->AI())->SetMyClass(soulclass);
              summoned->AI()->AttackStart(target);
             }
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         if (rand()%2)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
         //When Exarch Maladar is defeated D'ore appear.
         m_creature->SummonCreature(19412, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 600000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (!Avatar_summoned && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 25))
         {
             if (m_creature->IsNonMeleeSpellCasted(false))
                 m_creature->InterruptNonMeleeSpells(true);
+
             DoScriptText(SAY_SUMMON, m_creature);
+
             DoCast(m_creature, SPELL_SUMMON_AVATAR);
             Avatar_summoned = true;
             StolenSoul_Timer = 15000 + rand()% 15000;
         }
+
         if (StolenSoul_Timer < diff)
         {
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0))
@@ -204,78 +247,100 @@ struct TRINITY_DLL_DECL boss_exarch_maladaarAI : public ScriptedAI
                 {
                     if (m_creature->IsNonMeleeSpellCasted(false))
                         m_creature->InterruptNonMeleeSpells(true);
+
                     uint32 i = urand(1,2);
                     if (i == 1)
                         DoScriptText(SAY_ROAR, m_creature);
                     else
                         DoScriptText(SAY_SOUL_CLEAVE, m_creature);
+
                     soulmodel = target->GetDisplayId();
                     soulholder = target->GetGUID();
                     soulclass = target->getClass();
+
                     DoCast(target,SPELL_STOLEN_SOUL);
                     m_creature->SummonCreature(ENTRY_STOLEN_SOUL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
+
                     StolenSoul_Timer = 20000 + rand()% 10000;
                 } 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 = 15000 + rand()% 15000;
         }else Fear_timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_exarch_maladaar(Creature* pCreature)
 {
     return new boss_exarch_maladaarAI (pCreature);
 }
+
 #define SPELL_AV_MORTAL_STRIKE          16856
 #define SPELL_AV_SUNDER_ARMOR           16145
+
 struct TRINITY_DLL_DECL mob_avatar_of_martyredAI : public ScriptedAI
 {
     mob_avatar_of_martyredAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Mortal_Strike_timer;
+
     void Reset()
     {
         Mortal_Strike_timer = 10000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Mortal_Strike_timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_AV_MORTAL_STRIKE);
             Mortal_Strike_timer = 10000 + rand()%20 * 1000;
         } else Mortal_Strike_timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_avatar_of_martyred(Creature* pCreature)
 {
     return new mob_avatar_of_martyredAI (pCreature);
 }
+
 void AddSC_boss_exarch_maladaar()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_exarch_maladaar";
     newscript->GetAI = &GetAI_boss_exarch_maladaar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_avatar_of_martyred";
     newscript->GetAI = &GetAI_mob_avatar_of_martyred;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_stolen_soul";
     newscript->GetAI = &GetAI_mob_stolen_soul;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp b/src/bindings/scripts/scripts/outland/auchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp
index 19e3664f62b..c8dabff9650 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp
@@ -13,36 +13,45 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 Name: Boss_Shirrak_the_dead_watcher
 %Complete: 80
 Comment: InhibitMagic should stack slower far from the boss, proper Visual for Focus Fire, heroic implemented
 Category: Auchindoun, Auchenai Crypts
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SPELL_INHIBITMAGIC          32264
 #define SPELL_ATTRACTMAGIC          32265
 #define N_SPELL_CARNIVOROUSBITE     36383
 #define H_SPELL_CARNIVOROUSBITE     39382
 #define SPELL_CARNIVOROUSBITE       (HeroicMode?H_SPELL_CARNIVOROUSBITE:N_SPELL_CARNIVOROUSBITE)
+
 #define ENTRY_FOCUS_FIRE            18374
+
 #define N_SPELL_FIERY_BLAST         32302
 #define H_SPELL_FIERY_BLAST         38382
 #define SPELL_FIERY_BLAST           (HeroicMode?H_SPELL_FIERY_BLAST:N_SPELL_FIERY_BLAST)
 #define SPELL_FOCUS_FIRE_VISUAL     42075 //need to find better visual
+
 #define EMOTE_FOCUSES_ON            "focuses on "
+
 struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
 {
     boss_shirrak_the_dead_watcherAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 Inhibitmagic_Timer;
     uint32 Attractmagic_Timer;
     uint32 Carnivorousbite_Timer;
     uint32 FocusFire_Timer;
     bool HeroicMode;
     Unit *focusedTarget;
+
     void Reset()
     {
         Inhibitmagic_Timer = 0;
@@ -51,8 +60,10 @@ struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
         FocusFire_Timer = 17000;
         focusedTarget = NULL;
     }
+
     void EnterCombat(Unit *who)
     { }
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned && summoned->GetEntry() == ENTRY_FOCUS_FIRE)
@@ -61,10 +72,12 @@ struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
             summoned->setFaction(m_creature->getFaction());
             summoned->SetLevel(m_creature->getLevel());
             summoned->addUnitState(UNIT_STAT_ROOT);
+
             if (focusedTarget)
                 summoned->AI()->AttackStart(focusedTarget);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Inhibitmagic_Timer
@@ -73,7 +86,7 @@ struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
             float dist;
             Map* pMap = m_creature->GetMap();
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
-            for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+            for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                 if (Player* i_pl = i->getSource())
                     if (i_pl->isAlive() && (dist = i_pl->IsWithinDist(m_creature, 45)))
                     {
@@ -88,9 +101,11 @@ struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
                     }
             Inhibitmagic_Timer = 3000+(rand()%1000);
         }else Inhibitmagic_Timer -= diff;
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Attractmagic_Timer
         if (Attractmagic_Timer < diff)
         {
@@ -98,12 +113,14 @@ struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
             Attractmagic_Timer = 30000;
             Carnivorousbite_Timer = 1500;
         }else Attractmagic_Timer -= diff;
+
         //Carnivorousbite_Timer
         if (Carnivorousbite_Timer < diff)
         {
             DoCast(m_creature,SPELL_CARNIVOROUSBITE);
             Carnivorousbite_Timer = 10000;
         }else Carnivorousbite_Timer -= diff;
+
         //FocusFire_Timer
         if (FocusFire_Timer < diff)
         {
@@ -113,6 +130,7 @@ struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
             {
                 focusedTarget = target;
                 m_creature->SummonCreature(ENTRY_FOCUS_FIRE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN,5500);
+
                 // TODO: Find better way to handle emote
                 // Emote
                 std::string *emote = new std::string(EMOTE_FOCUSES_ON);
@@ -124,49 +142,62 @@ struct TRINITY_DLL_DECL boss_shirrak_the_dead_watcherAI : public ScriptedAI
             }
             FocusFire_Timer = 15000+(rand()%5000);
         }else FocusFire_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_shirrak_the_dead_watcher(Creature* pCreature)
 {
     return new boss_shirrak_the_dead_watcherAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_focus_fireAI : public ScriptedAI
 {
     mob_focus_fireAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
     uint32 FieryBlast_Timer;
     bool fiery1, fiery2;
+
     void Reset()
     {
         FieryBlast_Timer = 3000+(rand()%1000);
         fiery1 = fiery2 = true;
     }
+
     void EnterCombat(Unit *who)
     { }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //FieryBlast_Timer
         if (fiery2 && FieryBlast_Timer < diff)
         {
             DoCast(m_creature,SPELL_FIERY_BLAST);
+
             if (fiery1) fiery1 = false;
             else if (fiery2) fiery2 = false;
+
             FieryBlast_Timer = 1000;
         }else FieryBlast_Timer -= diff;
+
         //DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_focus_fire(Creature* pCreature)
 {
     return new mob_focus_fireAI (pCreature);
 }
+
 void AddSC_boss_shirrak_the_dead_watcher()
 {
     Script *newscript;
@@ -174,6 +205,7 @@ void AddSC_boss_shirrak_the_dead_watcher()
     newscript->Name = "boss_shirrak_the_dead_watcher";
     newscript->GetAI = &GetAI_boss_shirrak_the_dead_watcher;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_focus_fire";
     newscript->GetAI = &GetAI_mob_focus_fire;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/mana_tombs/boss_nexusprince_shaffar.cpp b/src/bindings/scripts/scripts/outland/auchindoun/mana_tombs/boss_nexusprince_shaffar.cpp
index c17a021cc27..9d19da0916f 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/mana_tombs/boss_nexusprince_shaffar.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/mana_tombs/boss_nexusprince_shaffar.cpp
@@ -13,17 +13,21 @@
  * along with 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"
+
 enum ePrince
 {
     SAY_INTRO                       = -1557000,
@@ -34,27 +38,36 @@ enum ePrince
     SAY_SLAY_2                      = -1557005,
     SAY_SUMMON                      = -1557006,
     SAY_DEAD                        = -1557007,
+
     SPELL_BLINK                     = 34605,
     SPELL_FROSTBOLT                 = 32364,
     SPELL_FIREBALL                  = 32363,
     SPELL_FROSTNOVA                 = 32365,
+
     SPELL_ETHEREAL_BEACON           = 32371,                // Summons NPC_BEACON
     SPELL_ETHEREAL_BEACON_VISUAL    = 32368,
+
     NPC_BEACON                      = 18431,
     NPC_SHAFFAR                     = 18344,
+
     NR_INITIAL_BEACONS              = 3
 };
+
 struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
 {
     boss_nexusprince_shaffarAI(Creature *c) : ScriptedAI(c), summons(me) { HasTaunted = false; }
+
     uint32 Blink_Timer;
     uint32 Beacon_Timer;
     uint32 FireBall_Timer;
     uint32 Frostbolt_Timer;
     uint32 FrostNova_Timer;
+
     SummonList summons;
+
     bool HasTaunted;
     bool CanBlink;
+
     void Reset()
     {
         Blink_Timer = 1500;
@@ -62,19 +75,24 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
         FireBall_Timer = 8000;
         Frostbolt_Timer = 4000;
         FrostNova_Timer = 15000;
+
         CanBlink = false;
+
         float dist = 8.0f;
         float posX, posY, posZ, angle;
         m_creature->GetHomePosition(posX, posY, posZ, angle);
+
         m_creature->SummonCreature(NPC_BEACON, posX - dist, posY - dist, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000);
         m_creature->SummonCreature(NPC_BEACON, posX - dist, posY + dist, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000);
         m_creature->SummonCreature(NPC_BEACON, posX + dist, posY, posZ, angle, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 7200000);
     }
+
     void EnterEvadeMode()
     {
         summons.DespawnAll();
         ScriptedAI::EnterEvadeMode();
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!HasTaunted && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 100.0f))
@@ -83,113 +101,141 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
             HasTaunted = true;
         }
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
+
         DoZoneInCombat();
         summons.DoZoneInCombat();
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned->GetEntry() == NPC_BEACON)
         {
             summoned->CastSpell(summoned,SPELL_ETHEREAL_BEACON_VISUAL,false);
+
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 summoned->AI()->AttackStart(target);
         }
+
         summons.Summon(summoned);
     }
+
     void SummonedCreatureDespawn(Creature *summon)
     {
         summons.Despawn(summon);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEAD, m_creature);
         summons.DespawnAll();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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);
+
                 //expire movement, will prevent from running right back to victim after cast
                 //(but should MoveChase be used again at a certain time or should he not move?)
                 if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
                     m_creature->GetMotionMaster()->MovementExpired();
+
                 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))
                 DoScriptText(SAY_SUMMON, m_creature);
+
             DoCast(m_creature,SPELL_ETHEREAL_BEACON, true);
+
             Beacon_Timer = 10000;
         }else Beacon_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_nexusprince_shaffar(Creature* pCreature)
 {
     return new boss_nexusprince_shaffarAI (pCreature);
 }
+
 enum eEnums
 {
     SPELL_ARCANE_BOLT               = 15254,
     SPELL_ETHEREAL_APPRENTICE       = 32372                 // Summon 18430
 };
+
 struct TRINITY_DLL_DECL mob_ethereal_beaconAI : public ScriptedAI
 {
     mob_ethereal_beaconAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
     uint32 Apprentice_Timer;
     uint32 ArcaneBolt_Timer;
     uint32 Check_Timer;
+
     void KillSelf()
     {
         m_creature->Kill(m_creature);
     }
+
     void Reset()
     {
         Apprentice_Timer = (HeroicMode ? 10000 : 20000);
         ArcaneBolt_Timer = 1000;
         Check_Timer = 1000;
     }
+
     void EnterCombat(Unit *who)
     {
         // Send Shaffar to fight
@@ -202,14 +248,17 @@ struct TRINITY_DLL_DECL mob_ethereal_beaconAI : public ScriptedAI
         if (!Shaffar->isInCombat())
             Shaffar->AI()->AttackStart(who);
     }
+
     void JustSummoned(Creature *summoned)
     {
         summoned->AI()->AttackStart(m_creature->getVictim());
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Check_Timer < diff)
         {
             Creature *Shaffar = me->FindNearestCreature(NPC_SHAFFAR, 100);
@@ -220,53 +269,62 @@ struct TRINITY_DLL_DECL mob_ethereal_beaconAI : public ScriptedAI
             }
             Check_Timer = 1000;
         }else Check_Timer -= diff;
+
         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);
             m_creature->ForcedDespawn();
             return;
         }else Apprentice_Timer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_ethereal_beacon(Creature* pCreature)
 {
     return new mob_ethereal_beaconAI (pCreature);
 }
+
 enum eEthereal
 {
     SPELL_ETHEREAL_APPRENTICE_FIREBOLT          = 32369,
     SPELL_ETHEREAL_APPRENTICE_FROSTBOLT         = 32370
 };
+
 struct TRINITY_DLL_DECL mob_ethereal_apprenticeAI : public ScriptedAI
 {
     mob_ethereal_apprenticeAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Cast_Timer;
+
     bool isFireboltTurn;
+
     void Reset()
     {
         Cast_Timer = 3000;
         isFireboltTurn = true;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Cast_Timer < diff)
         {
             if (isFireboltTurn)
             {
                 m_creature->CastSpell(m_creature->getVictim(), SPELL_ETHEREAL_APPRENTICE_FIREBOLT, true);
                 isFireboltTurn = false;
-            }
-            else
-            {
+            }else{
                 m_creature->CastSpell(m_creature->getVictim(), SPELL_ETHEREAL_APPRENTICE_FROSTBOLT, true);
                 isFireboltTurn = true;
             }
@@ -274,21 +332,26 @@ struct TRINITY_DLL_DECL mob_ethereal_apprenticeAI : public ScriptedAI
         }else Cast_Timer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_ethereal_apprentice(Creature* pCreature)
 {
     return new mob_ethereal_apprenticeAI (pCreature);
 }
+
 void AddSC_boss_nexusprince_shaffar()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_nexusprince_shaffar";
     newscript->GetAI = &GetAI_boss_nexusprince_shaffar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ethereal_beacon";
     newscript->GetAI = &GetAI_mob_ethereal_beacon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ethereal_apprentice";
     newscript->GetAI = &GetAI_mob_ethereal_apprentice;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/mana_tombs/boss_pandemonius.cpp b/src/bindings/scripts/scripts/outland/auchindoun/mana_tombs/boss_pandemonius.cpp
index c30109335d0..4f91a8a08df 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/mana_tombs/boss_pandemonius.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/mana_tombs/boss_pandemonius.cpp
@@ -13,56 +13,71 @@
  * along with 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                     -1557008
 #define SAY_AGGRO_2                     -1557009
 #define SAY_AGGRO_3                     -1557010
+
 #define SAY_KILL_1                      -1557011
 #define SAY_KILL_2                      -1557012
+
 #define SAY_DEATH                       -1557013
+
 #define EMOTE_DARK_SHELL                -1557014
+
 #define SPELL_VOID_BLAST                32325
 #define H_SPELL_VOID_BLAST              38760
 #define SPELL_DARK_SHELL                32358
 #define H_SPELL_DARK_SHELL              38759
+
 struct TRINITY_DLL_DECL boss_pandemoniusAI : public ScriptedAI
 {
     boss_pandemoniusAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
     uint32 VoidBlast_Timer;
     uint32 DarkShell_Timer;
     uint32 VoidBlast_Counter;
+
     void Reset()
     {
         VoidBlast_Timer = 8000+rand()%15000;
         DarkShell_Timer = 20000;
         VoidBlast_Counter = 0;
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (VoidBlast_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -71,30 +86,37 @@ struct TRINITY_DLL_DECL boss_pandemoniusAI : public ScriptedAI
                 VoidBlast_Timer = 500;
                 ++VoidBlast_Counter;
             }
+
             if (VoidBlast_Counter == 5)
             {
                 VoidBlast_Timer = 15000+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);
+
                 DoScriptText(EMOTE_DARK_SHELL, m_creature);
+
                 DoCast(m_creature,HEROIC(SPELL_DARK_SHELL, H_SPELL_DARK_SHELL));
                 DarkShell_Timer = 20000;
             }else DarkShell_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_pandemonius(Creature* pCreature)
 {
     return new boss_pandemoniusAI (pCreature);
 }
+
 void AddSC_boss_pandemonius()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/boss_darkweaver_syth.cpp b/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/boss_darkweaver_syth.cpp
index 2d2e60e1e3c..1d0092c2dfc 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/boss_darkweaver_syth.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/boss_darkweaver_syth.cpp
@@ -13,48 +13,63 @@
  * along with 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 partly implemented.
 SDCategory: Auchindoun, Sethekk Halls
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SAY_SUMMON                  -1556000
+
 #define SAY_AGGRO_1                 -1556001
 #define SAY_AGGRO_2                 -1556002
 #define SAY_AGGRO_3                 -1556003
+
 #define SAY_SLAY_1                  -1556004
 #define SAY_SLAY_2                  -1556005
+
 #define SAY_DEATH                   -1556006
+
 #define SPELL_FROST_SHOCK           21401 //37865
 #define SPELL_FLAME_SHOCK           34354
 #define SPELL_SHADOW_SHOCK          30138
 #define SPELL_ARCANE_SHOCK          37132
+
 #define SPELL_CHAIN_LIGHTNING       15659 //15305
+
 #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          (HeroicMode?38141:33526)
 #define SPELL_ARCANE_BUFFET         (HeroicMode?38138:33527)
 #define SPELL_FROST_BUFFET          (HeroicMode?38142:33528)
 #define SPELL_SHADOW_BUFFET         (HeroicMode?38143:33529)
+
 struct TRINITY_DLL_DECL boss_darkweaver_sythAI : public ScriptedAI
 {
     boss_darkweaver_sythAI(Creature *c) : ScriptedAI(c)
+
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 flameshock_timer;
     uint32 arcaneshock_timer;
     uint32 frostshock_timer;
     uint32 shadowshock_timer;
     uint32 chainlightning_timer;
+
     bool summon90;
     bool summon50;
     bool summon10;
     bool HeroicMode;
+
     void Reset()
     {
         flameshock_timer = 2000;
@@ -62,252 +77,327 @@ struct TRINITY_DLL_DECL boss_darkweaver_sythAI : public ScriptedAI
         frostshock_timer = 6000;
         shadowshock_timer = 8000;
         chainlightning_timer = 15000;
+
         summon90 = false;
         summon50 = false;
         summon10 = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (rand()%2)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0))
             summoned->AI()->AttackStart(target);
     }
+
     void SythSummoning()
     {
         DoScriptText(SAY_SUMMON, m_creature);
+
         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 (!UpdateVictim())
             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* pCreature)
 {
     return new boss_darkweaver_sythAI (pCreature);
 }
+
 /* ELEMENTALS */
+
 struct TRINITY_DLL_DECL mob_syth_fireAI : public ScriptedAI
 {
     mob_syth_fireAI(Creature *c) : ScriptedAI(c)
+
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 flameshock_timer;
     uint32 flamebuffet_timer;
     bool HeroicMode;
+
     void Reset()
     {
         m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true);
         flameshock_timer = 2500;
         flamebuffet_timer = 5000;
     }
+
     void EnterCombat(Unit *who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new mob_syth_fireAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_syth_arcaneAI : public ScriptedAI
 {
     mob_syth_arcaneAI(Creature *c) : ScriptedAI(c)
+
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 arcaneshock_timer;
     uint32 arcanebuffet_timer;
     bool HeroicMode;
+
     void Reset()
     {
         m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, true);
         arcaneshock_timer = 2500;
         arcanebuffet_timer = 5000;
     }
+
     void EnterCombat(Unit *who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new mob_syth_arcaneAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_syth_frostAI : public ScriptedAI
 {
     mob_syth_frostAI(Creature *c) : ScriptedAI(c)
+
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 frostshock_timer;
     uint32 frostbuffet_timer;
     bool HeroicMode;
+
     void Reset()
     {
         m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true);
         frostshock_timer = 2500;
         frostbuffet_timer = 5000;
     }
+
     void EnterCombat(Unit *who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new mob_syth_frostAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_syth_shadowAI : public ScriptedAI
 {
     mob_syth_shadowAI(Creature *c) : ScriptedAI(c)
+
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 shadowshock_timer;
     uint32 shadowbuffet_timer;
     bool HeroicMode;
+
     void Reset()
     {
         m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, true);
         shadowshock_timer = 2500;
         shadowbuffet_timer = 5000;
     }
+
     void EnterCombat(Unit *who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new mob_syth_shadowAI (pCreature);
 }
+
 void AddSC_boss_darkweaver_syth()
 {
     Script *newscript;
@@ -315,18 +405,22 @@ void AddSC_boss_darkweaver_syth()
     newscript->Name = "boss_darkweaver_syth";
     newscript->GetAI = &GetAI_boss_darkweaver_syth;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_syth_fire";
     newscript->GetAI = &GetAI_mob_syth_arcane;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_syth_arcane";
     newscript->GetAI = &GetAI_mob_syth_arcane;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_syth_frost";
     newscript->GetAI = &GetAI_mob_syth_frost;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_syth_shadow";
     newscript->GetAI = &GetAI_mob_syth_shadow;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/boss_tailonking_ikiss.cpp b/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/boss_tailonking_ikiss.cpp
index 672fe5fec58..eafd0b2d0fd 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/boss_tailonking_ikiss.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/boss_tailonking_ikiss.cpp
@@ -13,51 +13,67 @@
  * along with 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                   -1556007
+
 #define SAY_AGGRO_1                 -1556008
 #define SAY_AGGRO_2                 -1556009
 #define SAY_AGGRO_3                 -1556010
+
 #define SAY_SLAY_1                  -1556011
 #define SAY_SLAY_2                  -1556012
 #define SAY_DEATH                   -1556013
 #define EMOTE_ARCANE_EXP            -1556015
+
 #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 TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI
 {
     boss_talon_king_ikissAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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;
@@ -66,6 +82,7 @@ struct TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI
         Intro = false;
         ManaShield = false;
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!m_creature->getVictim() && who->isTargetableForAttack() && (m_creature->IsHostileTo(who)) && who->isInAccessiblePlaceFor(m_creature))
@@ -75,8 +92,10 @@ struct TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI
                 Intro = true;
                 DoScriptText(SAY_INTRO, 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))
             {
@@ -85,35 +104,43 @@ struct TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI
             }
         }
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_IKISSDOOREVENT, DONE);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Blink)
         {
             DoCast(m_creature,HEROIC(SPELL_ARCANE_EXPLOSION, H_SPELL_ARCANE_EXPLOSION));
             m_creature->CastSpell(m_creature,SPELL_ARCANE_BUBBLE,true);
             Blink = false;
         }
+
         if (ArcaneVolley_Timer < diff)
         {
             DoCast(m_creature,HEROIC(SPELL_ARCANE_VOLLEY, H_SPELL_ARCANE_VOLLEY));
             ArcaneVolley_Timer = 7000+rand()%5000;
         }else ArcaneVolley_Timer -= diff;
+
         if (Sheep_Timer < diff)
         {
             //second top aggro target in normal, random target in heroic correct?
@@ -123,12 +150,14 @@ struct TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI
                 DoCast(target,HEROIC(SPELL_POLYMORPH, H_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)
@@ -137,32 +166,41 @@ struct TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI
                 Slow_Timer = 15000+rand()%25000;
             }else Slow_Timer -= diff;
         }
+
         if (Blink_Timer < diff)
         {
             DoScriptText(EMOTE_ARCANE_EXP, m_creature);
+
             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();
+
                 DoTeleportTo(X,Y,Z);
+
                 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* pCreature)
 {
     return new boss_talon_king_ikissAI (pCreature);
 }
+
 void AddSC_boss_talon_king_ikiss()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/def_sethekk_halls.h b/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/def_sethekk_halls.h
index e3e4f0c6656..79a6cd4952d 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/def_sethekk_halls.h
+++ b/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/def_sethekk_halls.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
+
 enum eTypes
 {
     DATA_IKISSDOOREVENT = 1,
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/instance_sethekk_halls.cpp b/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/instance_sethekk_halls.cpp
index 44fab706f58..942325bd315 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/instance_sethekk_halls.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/sethekk_halls/instance_sethekk_halls.cpp
@@ -13,29 +13,36 @@
  * along 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"
+
 enum eEnums
 {
     NPC_ANZU   = 23035,
     IKISS_DOOR = 177203,
 };
+
 struct TRINITY_DLL_DECL instance_sethekk_halls : public ScriptedInstance
 {
     instance_sethekk_halls(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 AnzuEncounter;
     uint64 m_uiIkissDoorGUID;
+
     void Initialize()
     {
         AnzuEncounter = NOT_STARTED;
         m_uiIkissDoorGUID = 0;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         if (pCreature->GetEntry() == NPC_ANZU)
@@ -46,11 +53,13 @@ struct TRINITY_DLL_DECL instance_sethekk_halls : public ScriptedInstance
                 AnzuEncounter = IN_PROGRESS;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
          if (pGo->GetEntry() == IKISS_DOOR)
             m_uiIkissDoorGUID = pGo->GetGUID();
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -65,10 +74,12 @@ struct TRINITY_DLL_DECL instance_sethekk_halls : public ScriptedInstance
         }
     }
 };
+
 InstanceData* GetInstanceData_instance_sethekk_halls(Map* pMap)
 {
     return new instance_sethekk_halls(pMap);
 }
+
 void AddSC_instance_sethekk_halls()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp
index d6d92da05b6..aeb9f15b8ba 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp
@@ -13,15 +13,18 @@
  * along with 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: 80
 SDComment: Enrage spell missing/not known
 SDCategory: Auchindoun, Shadow Labyrinth
 EndScriptData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "def_shadow_labyrinth.h"
+
 enum eEnums
 {
     SAY_INTRO       = -1555000,
@@ -32,11 +35,13 @@ enum eEnums
     SAY_SLAY1       = -1555005,
     SAY_SLAY2       = -1555006,
     SAY_DEATH       = -1555007,
+
     SPELL_BANISH            = 30231,
     SPELL_CORROSIVE_ACID    = 33551,
     SPELL_FEAR              = 33547,
     SPELL_ENRAGE            = 34970
 };
+
 struct TRINITY_DLL_DECL boss_ambassador_hellmawAI : public npc_escortAI
 {
     boss_ambassador_hellmawAI(Creature* pCreature) : npc_escortAI(pCreature)
@@ -44,8 +49,10 @@ struct TRINITY_DLL_DECL boss_ambassador_hellmawAI : public npc_escortAI
         m_pInstance = pCreature->GetInstanceData();
         HeroicMode = pCreature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* m_pInstance;
     bool HeroicMode;
+
     uint32 EventCheck_Timer;
     uint32 CorrosiveAcid_Timer;
     uint32 Fear_Timer;
@@ -53,6 +60,7 @@ struct TRINITY_DLL_DECL boss_ambassador_hellmawAI : public npc_escortAI
     bool Intro;
     bool IsBanished;
     bool Enraged;
+
     void Reset()
     {
         EventCheck_Timer = 5000;
@@ -62,32 +70,40 @@ struct TRINITY_DLL_DECL boss_ambassador_hellmawAI : public npc_escortAI
         Intro = false;
         IsBanished = true;
         Enraged = false;
+
         if (m_pInstance && m_creature->isAlive())
         {
             if (m_pInstance->GetData(TYPE_OVERSEER) != DONE)
                 m_creature->CastSpell(m_creature, SPELL_BANISH, true);
         }
     }
+
     void JustReachedHome()
     {
         if (m_pInstance)
             m_pInstance->SetData(TYPE_HELLMAW, FAIL);
     }
+
     void MoveInLineOfSight(Unit* pWho)
     {
         if (m_creature->HasAura(SPELL_BANISH))
             return;
+
         npc_escortAI::MoveInLineOfSight(pWho);
     }
+
     void WaypointReached(uint32 i)
     {
     }
+
     void DoIntro()
     {
         if (m_creature->HasAura(SPELL_BANISH))
             m_creature->RemoveAurasDueToSpell(SPELL_BANISH);
+
         IsBanished = false;
         Intro = true;
+
         if (m_pInstance)
         {
             if (m_pInstance->GetData(TYPE_HELLMAW) != FAIL)
@@ -95,23 +111,29 @@ struct TRINITY_DLL_DECL boss_ambassador_hellmawAI : public npc_escortAI
                 DoScriptText(SAY_INTRO, m_creature);
                 Start(true, false, 0, NULL, false, true);
             }
+
             m_pInstance->SetData(TYPE_HELLMAW, IN_PROGRESS);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (m_pInstance)
             m_pInstance->SetData(TYPE_HELLMAW, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Intro && !HasEscortState(STATE_ESCORT_ESCORTING))
@@ -135,24 +157,30 @@ struct TRINITY_DLL_DECL boss_ambassador_hellmawAI : public npc_escortAI
                 return;
             }
         }
+
         npc_escortAI::UpdateAI(diff);
+
         if (!UpdateVictim())
             return;
+
         if (m_creature->HasAura(SPELL_BANISH, 0))
         {
             EnterEvadeMode();
             return;
         }
+
         if (CorrosiveAcid_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_CORROSIVE_ACID);
             CorrosiveAcid_Timer = 15000 + rand()%10000;
         }else CorrosiveAcid_Timer -= diff;
+
         if (Fear_Timer < diff)
         {
             DoCast(m_creature,SPELL_FEAR);
             Fear_Timer = 20000 + rand()%15000;
         }else Fear_Timer -= diff;
+
         if (HeroicMode)
         {
             if (!Enraged && Enrage_Timer < diff)
@@ -163,10 +191,12 @@ struct TRINITY_DLL_DECL boss_ambassador_hellmawAI : public npc_escortAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_ambassador_hellmaw(Creature* pCreature)
 {
     return new boss_ambassador_hellmawAI(pCreature);
 }
+
 void AddSC_boss_ambassador_hellmaw()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp
index c400cc1de95..1eca5a36734 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp
@@ -13,18 +13,22 @@
  * along with 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_INTRO1          -1555008 //not used
 #define SAY_INTRO2          -1555009 //not used
 #define SAY_INTRO3          -1555010 //not used
@@ -35,6 +39,7 @@ EndScriptData */
 #define SAY_SLAY2           -1555015
 #define SAY_HELP            -1555016 //not used
 #define SAY_DEATH           -1555017
+
 //below, not used
 #define SAY2_INTRO1         -1555018
 #define SAY2_INTRO2         -1555019
@@ -46,18 +51,22 @@ EndScriptData */
 #define SAY2_SLAY2          -1555025
 #define SAY2_HELP           -1555026
 #define SAY2_DEATH          -1555027
+
 struct TRINITY_DLL_DECL boss_blackheart_the_inciterAI : public ScriptedAI
 {
     boss_blackheart_the_inciterAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     bool InciteChaos;
     uint32 InciteChaos_Timer;
     uint32 InciteChaosWait_Timer;
     uint32 Charge_Timer;
     uint32 Knockback_Timer;
+
     void Reset()
     {
         InciteChaos = false;
@@ -65,30 +74,38 @@ struct TRINITY_DLL_DECL boss_blackheart_the_inciterAI : public ScriptedAI
         InciteChaosWait_Timer = 15000;
         Charge_Timer = 5000;
         Knockback_Timer = 15000;
+
         if (pInstance)
             pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, NOT_STARTED);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (InciteChaos)
         {
             if (InciteChaosWait_Timer < diff)
@@ -96,23 +113,28 @@ struct TRINITY_DLL_DECL boss_blackheart_the_inciterAI : public ScriptedAI
                 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)
+            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)
         {
@@ -120,12 +142,14 @@ struct TRINITY_DLL_DECL boss_blackheart_the_inciterAI : public ScriptedAI
                 DoCast(target, SPELL_CHARGE);
             Charge_Timer = 15000 + rand()%10000;
         }else Charge_Timer -= diff;
+
         //Knockback_Timer
         if (Knockback_Timer < diff)
         {
             DoCast(m_creature, SPELL_WAR_STOMP);
             Knockback_Timer = 18000 + rand()%6000;
         }else Knockback_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -133,6 +157,7 @@ CreatureAI* GetAI_boss_blackheart_the_inciter(Creature* pCreature)
 {
     return new boss_blackheart_the_inciterAI (pCreature);
 }
+
 void AddSC_boss_blackheart_the_inciter()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
index 6fe4eada5e6..34bcdd86175 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
@@ -13,14 +13,17 @@
  * along with 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: 100
 SDComment:
 SDCategory: Auchindoun, Shadow Labyrinth
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_shadow_labyrinth.h"
+
 #define SAY_INTRO                       -1555028
 #define SAY_AGGRO1                      -1555029
 #define SAY_AGGRO2                      -1555030
@@ -29,19 +32,25 @@ EndScriptData */
 #define SAY_SLAY1                       -1555033
 #define SAY_SLAY2                       -1555034
 #define SAY_DEATH                       -1555035
+
 #define SPELL_RAIN_OF_FIRE          33617
 #define H_SPELL_RAIN_OF_FIRE        39363
+
 #define SPELL_DRAW_SHADOWS          33563
 #define SPELL_SHADOWBOLT_VOLLEY     33841
 #define SPELL_BANISH                38791
+
 #define MOB_VOID_TRAVELER           19226
 #define SPELL_SACRIFICE             33587
 #define SPELL_SHADOW_NOVA           33846
 #define SPELL_EMPOWERING_SHADOWS    33783
 #define H_SPELL_EMPOWERING_SHADOWS  39364
+
 #define MOB_VOID_PORTAL             19224
 #define SPELL_VOID_PORTAL_VISUAL    33569
+
 float VorpilPosition[3] = {-252.8820,-264.3030,17.1};
+
 float VoidPortalCoords[5][3] =
 {
     {-283.5894, -239.5718, 12.7},
@@ -50,23 +59,28 @@ float VoidPortalCoords[5][3] =
     {-209.3401, -262.7564, 17.1},
     {-261.4533, -297.3298, 17.1}
 };
+
 struct TRINITY_DLL_DECL mob_voidtravelerAI : public ScriptedAI
 {
     mob_voidtravelerAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
     Unit *Vorpil;
     uint32 move;
     bool sacrificed;
+
     void Reset()
     {
         Vorpil = NULL;
         move = 0;
         sacrificed = false;
     }
+
     void EnterCombat(Unit *who){}
+
     void UpdateAI(const uint32 diff)
     {
         if (!Vorpil)
@@ -107,6 +121,7 @@ CreatureAI* GetAI_mob_voidtraveler(Creature* pCreature)
 {
     return new mob_voidtravelerAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
 {
     boss_grandmaster_vorpilAI(Creature *c) : ScriptedAI(c)
@@ -115,15 +130,18 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
         HeroicMode = c->GetMap()->IsHeroic();
         Intro = false;
     }
+
     ScriptedInstance *pInstance;
     bool Intro, HelpYell;
     bool sumportals;
     bool HeroicMode;
+
     uint32 ShadowBoltVolley_Timer;
     uint32 DrawShadows_Timer;
     uint32 summonTraveler_Timer;
     uint32 banish_Timer;
     uint64 PortalsGuid[5];
+
     void Reset()
     {
         ShadowBoltVolley_Timer = 7000 + rand()%7000;
@@ -132,9 +150,11 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
         banish_Timer = 17000;
         HelpYell = false;
         destroyPortals();
+
         if (pInstance)
             pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, NOT_STARTED);
     }
+
     void summonPortals()
     {
         if (!sumportals)
@@ -153,6 +173,7 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
             summonTraveler_Timer = 5000;
         }
     }
+
     void destroyPortals()
     {
         if (sumportals)
@@ -167,6 +188,7 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
             sumportals = false;
         }
     }
+
     void spawnVoidTraveler()
     {
         int pos = urand(0,4);
@@ -177,47 +199,58 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
             HelpYell = true;
         }
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned && summoned->GetEntry() == MOB_VOID_TRAVELER)
             CAST_AI(mob_voidtravelerAI, summoned->AI())->Vorpil = m_creature;
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
         destroyPortals();
+
         if (pInstance)
             pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), m_creature);
         summonPortals();
+
         if (pInstance)
             pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, IN_PROGRESS);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         ScriptedAI::MoveInLineOfSight(who);
+
         if (!Intro && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who))
         {
             DoScriptText(SAY_INTRO, m_creature);
             Intro = true;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (ShadowBoltVolley_Timer < diff)
         {
             DoCast(m_creature,SPELL_SHADOWBOLT_VOLLEY);
             ShadowBoltVolley_Timer = 15000 + rand()%15000;;
         } else ShadowBoltVolley_Timer -= diff;
+
         if (HeroicMode && banish_Timer < diff)
         {
             Unit *target = SelectTarget(SELECT_TARGET_RANDOM,0,30,false);
@@ -227,20 +260,25 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
                 banish_Timer = 16000;
             }
         } else banish_Timer -= diff;
+
         if (DrawShadows_Timer < diff)
         {
             Map* pMap = m_creature->GetMap();
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
-            for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+            for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                 if (Player* i_pl = i->getSource())
                     if (i_pl->isAlive() && !i_pl->HasAura(SPELL_BANISH))
                         i_pl->TeleportTo(m_creature->GetMapId(), VorpilPosition[0],VorpilPosition[1],VorpilPosition[2], 0, TELE_TO_NOT_LEAVE_COMBAT);
+
             m_creature->GetMap()->CreatureRelocation(m_creature, VorpilPosition[0],VorpilPosition[1],VorpilPosition[2],0.0f);
             DoCast(m_creature,SPELL_DRAW_SHADOWS,true);
+
             DoCast(m_creature,HeroicMode?H_SPELL_RAIN_OF_FIRE:SPELL_RAIN_OF_FIRE);
+
             ShadowBoltVolley_Timer = 6000;
             DrawShadows_Timer = 30000;
         } else DrawShadows_Timer -= diff;
+
         if (summonTraveler_Timer < diff)
         {
             spawnVoidTraveler();
@@ -249,6 +287,7 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
             if ((m_creature->GetHealth()*5) < m_creature->GetMaxHealth())
                 summonTraveler_Timer = 5000;
         } else summonTraveler_Timer -=diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -256,6 +295,7 @@ CreatureAI* GetAI_boss_grandmaster_vorpil(Creature* pCreature)
 {
     return new boss_grandmaster_vorpilAI (pCreature);
 }
+
 void AddSC_boss_grandmaster_vorpil()
 {
     Script *newscript;
@@ -263,6 +303,7 @@ void AddSC_boss_grandmaster_vorpil()
     newscript->Name = "boss_grandmaster_vorpil";
     newscript->GetAI = &GetAI_boss_grandmaster_vorpil;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_voidtraveler";
     newscript->GetAI = &GetAI_mob_voidtraveler;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp
index 6ab5baaf56c..7782b5fed62 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp
@@ -13,15 +13,19 @@
  * along with 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: 90
 SDComment: Timers may be incorrect
 SDCategory: Auchindoun, Shadow Labyrinth
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_shadow_labyrinth.h"
+
 #define EMOTE_SONIC_BOOM            -1555036
+
 #define SPELL_SONIC_BOOM_CAST       (HeroicMode?38796:33923)
 #define SPELL_SONIC_BOOM_EFFECT     (HeroicMode?38795:33666)
 #define SPELL_RESONANCE             33657
@@ -29,6 +33,7 @@ EndScriptData */
 #define SPELL_MAGNETIC_PULL         33689
 #define SPELL_SONIC_SHOCK           38797
 #define SPELL_THUNDERING_STORM      39365
+
 struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
 {
     boss_murmurAI(Creature *c) : ScriptedAI(c)
@@ -36,6 +41,7 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
         SetCombatMovement(false);
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 SonicBoom_Timer;
     uint32 MurmursTouch_Timer;
     uint32 Resonance_Timer;
@@ -44,6 +50,7 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
     uint32 ThunderingStorm_Timer;
     bool HeroicMode;
     bool SonicBoom;
+
     void Reset()
     {
         SonicBoom_Timer = 30000;
@@ -53,15 +60,17 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
         ThunderingStorm_Timer = 15000;
         SonicShock_Timer = 10000;
         SonicBoom = false;
+
         //database should have `RegenHealth`=0 to prevent regen
         uint32 hp = (m_creature->GetMaxHealth()*40)/100;
         if (hp) m_creature->SetHealth(hp);
         m_creature->ResetPlayerDamageReq();
     }
+
     void SonicBoomEffect()
     {
         std::list t_list = m_creature->getThreatManager().getThreatList();
-        for (std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
+        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)
@@ -75,23 +84,28 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
            }
         }
     }
+
     void EnterCombat(Unit *who) { }
+
     // Sonic Boom instant damage (needs core fix instead of this)
     void SpellHitTarget(Unit *target, const SpellEntry *spell)
     {
         if (target && target->isAlive() && spell && spell->Id == SPELL_SONIC_BOOM_EFFECT)
             m_creature->DealDamage(target,(target->GetHealth()*90)/100,NULL,SPELL_DIRECT_DAMAGE,SPELL_SCHOOL_MASK_NATURE,spell);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target or casting
         if (!UpdateVictim() || m_creature->IsNonMeleeSpellCasted(false))
             return;
+
         // Sonic Boom
         if (SonicBoom)
         {
             DoCast(m_creature, SPELL_SONIC_BOOM_EFFECT, true);
             SonicBoomEffect();
+
             SonicBoom = false;
             Resonance_Timer = 1500;
         }
@@ -103,6 +117,7 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
             SonicBoom = true;
             return;
         }else SonicBoom_Timer -= diff;
+
         // Murmur's Touch
         if (MurmursTouch_Timer < diff)
         {
@@ -110,6 +125,7 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
                 DoCast(target, SPELL_MURMURS_TOUCH);
             MurmursTouch_Timer = 25000 + rand()%10000;
         }else MurmursTouch_Timer -= diff;
+
         // Resonance
         if (!SonicBoom && !(m_creature->IsWithinMeleeRange(m_creature->getVictim())))
         {
@@ -119,6 +135,7 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
                 Resonance_Timer = 5000;
             }else Resonance_Timer -= diff;
         }
+
         // Magnetic Pull
         if (MagneticPull_Timer < diff)
         {
@@ -131,18 +148,20 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
                 }
             MagneticPull_Timer = 500;
         }else MagneticPull_Timer -= diff;
+
         if (HeroicMode)
         {
             // Thundering Storm
             if (ThunderingStorm_Timer < diff)
             {
                 std::list& m_threatlist = m_creature->getThreatManager().getThreatList();
-                for (std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i)
+                for(std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i)
                     if (Unit* target = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()))
                         if (target->isAlive() && !m_creature->IsWithinDist(target, 35, false))
                             DoCast(target, SPELL_THUNDERING_STORM, true);
                 ThunderingStorm_Timer = 15000;
             }else ThunderingStorm_Timer -= diff;
+
             // Sonic Shock
             if (SonicShock_Timer < diff)
             {
@@ -152,13 +171,14 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
                 SonicShock_Timer = 10000+rand()%10000;
             }else SonicShock_Timer -= diff;
         }
+
         // Select nearest most aggro target if top aggro too far
         if (!m_creature->isAttackReady())
             return;
         if (!m_creature->IsWithinMeleeRange(m_creature->getVictim()))
         {
             std::list& m_threatlist = m_creature->getThreatManager().getThreatList();
-            for (std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i)
+            for(std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i)
                 if (Unit* target = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()))
                     if (target->isAlive() && m_creature->IsWithinMeleeRange(target))
                     {
@@ -166,13 +186,16 @@ struct TRINITY_DLL_DECL boss_murmurAI : public ScriptedAI
                         break;
                     }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_murmur(Creature* pCreature)
 {
     return new boss_murmurAI (pCreature);
 }
+
 void AddSC_boss_murmur()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/def_shadow_labyrinth.h b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/def_shadow_labyrinth.h
index a5f233dbbca..a78955368bf 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/def_shadow_labyrinth.h
+++ b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/def_shadow_labyrinth.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
diff --git a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp
index 1897f405415..f8f3b73bffa 100644
--- a/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp
+++ b/src/bindings/scripts/scripts/outland/auchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp
@@ -13,46 +13,61 @@
  * along 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 MAX_ENCOUNTER 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 TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
 {
     instance_shadow_labyrinth(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     std::string str_data;
+
     uint64 m_uiRefectoryDoorGUID;
     uint64 m_uiScreamingHallDoorGUID;
+
     uint64 m_uiGrandmasterVorpil;
     uint32 m_uiFelOverseerCount;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         m_uiRefectoryDoorGUID = 0;
         m_uiScreamingHallDoorGUID = 0;
+
         m_uiGrandmasterVorpil = 0;
         m_uiFelOverseerCount = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -69,6 +84,7 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
                 break;
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -85,6 +101,7 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
                 break;
         }
     }
+
     void SetData(uint32 type, uint32 uiData)
     {
         switch(type)
@@ -92,6 +109,7 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
             case TYPE_HELLMAW:
                 m_auiEncounter[0] = uiData;
                 break;
+
             case TYPE_OVERSEER:
                 if (uiData != DONE)
                 {
@@ -101,6 +119,7 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
                 if (m_uiFelOverseerCount)
                 {
                     --m_uiFelOverseerCount;
+
                     if (m_uiFelOverseerCount)
                         debug_log("TSCR: Shadow Labyrinth: %u Fel Overseers left to kill.",m_uiFelOverseerCount);
                     else
@@ -110,33 +129,42 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
                     }
                 }
                 break;
+
             case DATA_BLACKHEARTTHEINCITEREVENT:
                 if (uiData == DONE)
                     DoUseDoorOrButton(m_uiRefectoryDoorGUID);
                 m_auiEncounter[2] = uiData;
                 break;
+
             case DATA_GRANDMASTERVORPILEVENT:
                 if (uiData == DONE)
                     DoUseDoorOrButton(m_uiScreamingHallDoorGUID);
                 m_auiEncounter[3] = uiData;
                 break;
+
             case DATA_MURMUREVENT:
                 m_auiEncounter[4] = uiData;
                 break;
         }
+
         if (uiData == DONE)
         {
             if (type == TYPE_OVERSEER && m_uiFelOverseerCount != 0)
                 return;
+
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
             saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
                 << m_auiEncounter[2] << " " << m_auiEncounter[3] << " " << m_auiEncounter[4];
+
             str_data = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -148,16 +176,20 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
         }
         return false;
     }
+
     uint64 GetData64(uint32 identifier)
     {
         if (identifier == DATA_GRANDMASTERVORPIL)
             return m_uiGrandmasterVorpil;
+
         return 0;
     }
+
     std::string GetSaveData()
     {
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -165,19 +197,25 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         std::istringstream loadStream(in);
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3] >> m_auiEncounter[4];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)
                 m_auiEncounter[i] = NOT_STARTED;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_shadow_labyrinth(Map* pMap)
 {
     return new instance_shadow_labyrinth(pMap);
 }
+
 void AddSC_instance_shadow_labyrinth()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/black_temple.cpp b/src/bindings/scripts/scripts/outland/black_temple/black_temple.cpp
index 3e8714217cd..270dafabe54 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/black_temple.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/black_temple.cpp
@@ -13,41 +13,53 @@
  * along 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* pPlayer, Creature* pCreature)
 {
     ScriptedInstance* pInstance = pCreature->GetInstanceData();
+
     if (pInstance && (pInstance->GetData(DATA_SUPREMUSEVENT) >= DONE) && (pInstance->GetData(DATA_HIGHWARLORDNAJENTUSEVENT) >= DONE))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_OLUM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_spirit_of_olum(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
         pPlayer->CLOSE_GOSSIP_MENU();
+
     pPlayer->InterruptNonMeleeSpells(false);
     pPlayer->CastSpell(pPlayer, 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;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_bloodboil.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_bloodboil.cpp
index c1f7f51e9b3..be303f85980 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/boss_bloodboil.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/boss_bloodboil.cpp
@@ -13,14 +13,17 @@
  * along with 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"
+
 //Speech'n'Sound
 #define SAY_AGGRO               -1564029
 #define SAY_SLAY1               -1564030
@@ -30,6 +33,7 @@ EndScriptData */
 #define SAY_ENRAGE1             -1564034
 #define SAY_ENRAGE2             -1564035
 #define SAY_DEATH               -1564036
+
 //Spells
 #define SPELL_ACID_GEYSER        40630
 #define SPELL_ACIDIC_WOUND       40481
@@ -46,16 +50,22 @@ EndScriptData */
 #define SPELL_TAUNT_GURTOGG      40603
 #define SPELL_INSIGNIFIGANCE     40618
 #define SPELL_BERSERK            45078
+
 //This is used to sort the players by distance in preparation for the Bloodboil cast.
+
 struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
 {
     boss_gurtogg_bloodboilAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint64 TargetGUID;
+
     float TargetThreat;
+
     uint32 BloodboilTimer;
     uint32 BloodboilCount;
     uint32 AcidGeyserTimer;
@@ -66,13 +76,18 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
     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;
@@ -83,10 +98,13 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
         EjectTimer = 10000;
         BewilderingStrikeTimer = 15000;
         PhaseChangeTimer = 60000;
+
         Phase1 = true;
+
         m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
         m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, false);
     }
+
     void EnterCombat(Unit *who)
     {
         DoZoneInCombat();
@@ -94,55 +112,65 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(DATA_GURTOGGBLOODBOILEVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
             pInstance->SetData(DATA_GURTOGGBLOODBOILEVENT, DONE);
+
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     // 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()) // He doesn't have anyone in his threatlist, useless to continue
             return;
+
         std::list targets;
         std::list::iterator itr = m_threatlist.begin();
-        for (; itr!= m_threatlist.end(); ++itr)             //store the threat list in a different container
+        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(ObjectDistanceOrderReversed(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)
+            for(std::list::iterator itr = targets.begin(); itr != targets.end(); ++itr)
             {
                 Unit* target = *itr;
                 if (!target) return;
-                for (uint32 i = 0; i<3; ++i)
+                for(uint32 i = 0;i<3; ++i)
                 {
                     uint8 eff = spellInfo->Effect[i];
                     if (eff>=TOTAL_SPELL_EFFECTS)
                         continue;
+
                     Aura *Aur = new Aura(spellInfo, i, target, target, target);
                     target->AddAura(Aur);
                 }
             }
         }*/
     }
+
     void RevertThreatOnTarget(uint64 guid)
     {
         Unit* pUnit = NULL;
@@ -155,20 +183,24 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
                 m_creature->AddThreat(pUnit, TargetThreat);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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))
         {
             if (EnrageTimer < diff)
@@ -177,6 +209,7 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
                 DoScriptText(RAND(SAY_ENRAGE1,SAY_ENRAGE2), m_creature);
             }else EnrageTimer -= diff;
         }
+
         if (Phase1)
         {
             if (BewilderingStrikeTimer < diff)
@@ -187,17 +220,20 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
                     m_creature->AddThreat(target, mt_threat);
                 BewilderingStrikeTimer = 20000;
             }else BewilderingStrikeTimer -= diff;
+
             if (EjectTimer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_EJECT1);
                 DoModifyThreatPercent(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.
@@ -209,6 +245,7 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
                 }
             }else BloodboilTimer -= diff;
         }
+
         if (!Phase1)
         {
             if (AcidGeyserTimer < diff)
@@ -216,12 +253,14 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
                 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)
@@ -230,6 +269,7 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
                 if (target && target->isAlive())
                 {
                     Phase1 = false;
+
                     TargetThreat = DoGetThreat(target);
                     TargetGUID = target->GetGUID();
                     target->CastSpell(m_creature, SPELL_TAUNT_GURTOGG, true);
@@ -245,9 +285,12 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
                     /* 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);
+
                     DoScriptText(RAND(SAY_SPECIAL1,SAY_SPECIAL2), m_creature);
+
                     AcidGeyserTimer = 1000;
                     PhaseChangeTimer = 30000;
                 }
@@ -268,13 +311,16 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
                 m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, false);
             }
         }else PhaseChangeTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_gurtogg_bloodboil(Creature* pCreature)
 {
     return new boss_gurtogg_bloodboilAI (pCreature);
 }
+
 void AddSC_boss_gurtogg_bloodboil()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_illidan.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_illidan.cpp
index 9928ca54fd0..e081e33eb06 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/boss_illidan.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/boss_illidan.cpp
@@ -13,21 +13,26 @@
 * along with 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: Somewhat of a workaround for Parasitic Shadowfiend, unable to summon GOs for Cage Trap.
 SDCategory: Black Temple
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_black_temple.h"
+
 #define GETGO(obj, guid)      GameObject* obj = pInstance->instance->GetGameObject(guid)
 #define GETUNIT(unit, guid)   Unit* unit = Unit::GetUnit(*m_creature, guid)
 #define GETCRE(cre, guid)     Creature* cre = Unit::GetCreature(*m_creature, guid)
 #define HPPCT(unit)           unit->GetHealth()*100 / unit->GetMaxHealth()
+
 /************* 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
@@ -35,25 +40,31 @@ EndScriptData */
 #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
 const char*  SAY_KILL1        = "Who shall be next to taste my blades?!";
 #define SOUND_KILL1           11473
 const char*  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                     37335 // 41032 is bugged, cannot be block/dodge/parry// Reduces Max. Health by 60% for 7 seconds. Can stack 19 times. 1.5 second cast
@@ -117,14 +128,18 @@ const char*  SAY_KILL2        = "This is too easy!";
 #define SPELL_SHADOW_STRIKE             40685 // 4375 to 5625 every 3 seconds for 12 seconds
 #define SPELL_THROW_DAGGER              41152 // 5400 to 6600 damage, need dagger
 #define SPELL_FAN_BLADES                39954 // bugged visual
+
 // Other defines
 #define CENTER_X            676.740
 #define CENTER_Y            305.297
 #define CENTER_Z            353.192
+
 #define FLAME_ENRAGE_DISTANCE   30
 #define FLAME_CHARGE_DISTANCE   50
+
 #define EQUIP_ID_MAIN_HAND  32837
 #define EQUIP_ID_OFF_HAND   32838
+
 /**** Creature Summon and Recognition IDs ****/
 enum CreatureEntry
 {
@@ -144,6 +159,7 @@ enum CreatureEntry
     PARASITIC_SHADOWFIEND   =   23498,
     CAGE_TRAP_TRIGGER       =   23292,
 };
+
 /*** Phase Names ***/
 enum PhaseIllidan
 {
@@ -158,6 +174,7 @@ enum PhaseIllidan
     PHASE_TRANSFORM_SEQUENCE    =   8,
     PHASE_ILLIDAN_MAX           =   9,
 };//Maiev uses the same phase
+
 enum PhaseAkama
 {
     PHASE_AKAMA_NULL        =   0,
@@ -168,6 +185,7 @@ enum PhaseAkama
     PHASE_FIGHT_MINIONS     =   5,
     PHASE_RETURN            =   6,
 };
+
 enum EventIllidan
 {
     EVENT_NULL                  =   0,
@@ -197,6 +215,7 @@ enum EventIllidan
     EVENT_FLIGHT_SEQUENCE       =   2,
     EVENT_TRANSFORM_SEQUENCE    =   2,
 };
+
 enum EventMaiev
 {
     EVENT_MAIEV_NULL            =   0,
@@ -206,6 +225,7 @@ enum EventMaiev
     EVENT_MAIEV_THROW_DAGGER    =   4,
     EVENT_MAIEV_TRAP            =   4,
 };
+
 static EventIllidan MaxTimer[]=
 {
     EVENT_NULL,
@@ -218,6 +238,7 @@ static EventIllidan MaxTimer[]=
     EVENT_FLIGHT_SEQUENCE,
     EVENT_TRANSFORM_SEQUENCE
 };
+
 struct Yells
 {
     uint32 sound;
@@ -225,6 +246,7 @@ struct Yells
     uint32 pCreature, 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},
@@ -250,6 +272,7 @@ static Yells Conversation[]=
     {11387, "The Light will fill these dismal halls once again. I swear it.", AKAMA, 8000, 0, true},
     {0, NULL, EMPTY, 1000, 0, false}//21
 };
+
 static Yells RandomTaunts[]=
 {
     {11467, "I can feel your hatred.", ILLIDAN_STORMRAGE, 0, 0, false},
@@ -257,6 +280,7 @@ static Yells RandomTaunts[]=
     {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},
@@ -264,10 +288,12 @@ static Yells MaievTaunts[]=
     {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;
 };
+
 static Locations HoverPosition[]=
 {
     {657, 340, 355},
@@ -275,6 +301,7 @@ static Locations HoverPosition[]=
     {705, 275, 355},
     {705, 340, 355}
 };
+
 static Locations GlaivePosition[]=
 {
     {695.105, 305.303, 354.256},
@@ -282,11 +309,13 @@ static Locations GlaivePosition[]=
     {700.105, 305.303, 354.256},
     {664.338, 305.303, 354.256}
 };
+
 static Locations EyeBlast[]=
 {
     {677, 350, 354},//start point, pass through glaive point
     {677, 260, 354}
 };
+
 static Locations AkamaWP[]=
 {
     {770.01, 304.50, 312.29}, // Bottom of the first stairs, at the doors
@@ -309,11 +338,13 @@ static Locations SpiritSpawns[]=
     {755.5426, 309.9156, 312.2129},
     {755.5426, 298.7923, 312.0834}
 };
+
 struct Animation // For the demon transformation
 {
     uint32 aura, unaura, timer, size, displayid, phase;
     bool equip;
 };
+
 static Animation DemonTransformation[]=
 {
     {SPELL_DEMON_TRANSFORM_1, 0, 1000, 0, 0, 6, true},
@@ -327,9 +358,12 @@ static Animation DemonTransformation[]=
     {SPELL_DEMON_TRANSFORM_3, SPELL_DEMON_TRANSFORM_2, 3500, 0, 0, 6, true},
     {0, SPELL_DEMON_TRANSFORM_3, 0, 0, 0, 8, true}
 };
+
 #define EMOTE_SETS_GAZE_ON     "sets its gaze on $N!"
 #define EMOTE_UNABLE_TO_SUMMON "is unable to summon Maiev Shadowsong and enter Phase 4. Resetting Encounter."
 
+
+
 /************************************** Illidan's AI ***************************************/
 struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
 {
@@ -337,32 +371,43 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
         m_creature->CastSpell(m_creature, SPELL_DUAL_WIELD, true);
+
         SpellEntry *TempSpell = GET_SPELL(SPELL_SHADOWFIEND_PASSIVE);
         if (TempSpell)
             TempSpell->EffectApplyAuraName[0] = 4; // proc debuff, and summon infinite fiends
     }
+
     ScriptedInstance* pInstance;
+
     PhaseIllidan Phase;
     EventIllidan Event;
     uint32 Timer[EVENT_ENRAGE + 1];
+
     uint32 TalkCount;
     uint32 TransformCount;
     uint32 FlightCount;
+
     uint32 HoverPoint;
+
     uint64 AkamaGUID;
     uint64 MaievGUID;
     uint64 FlameGUID[2];
     uint64 GlaiveGUID[2];
+
     SummonList Summons;
+
     void Reset();
+
     void JustSummoned(Creature* summon);
+
     void SummonedCreatureDespawn(Creature* summon)
     {
         if (summon->GetCreatureInfo()->Entry == FLAME_OF_AZZINOTH)
         {
-            for (uint8 i = 0; i < 2; ++i)
+            for(uint8 i = 0; i < 2; ++i)
                 if (summon->GetGUID() == FlameGUID[i])
                     FlameGUID[i] = 0;
+
             if (!FlameGUID[0] && !FlameGUID[1] && Phase != PHASE_ILLIDAN_NULL)
             {
                 m_creature->InterruptNonMeleeSpells(true);
@@ -371,6 +416,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
         }
         Summons.Despawn(summon);
     }
+
     void MovementInform(uint32 MovementType, uint32 Data)
     {
         if (FlightCount == 7) //change hover point
@@ -385,30 +431,39 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
         else // handle flight sequence
             Timer[EVENT_FLIGHT_SEQUENCE] = 1000;
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->setActive(true);
         DoZoneInCombat();
     }
+
     void AttackStart(Unit *who)
     {
         if (!who || Phase >= PHASE_TALK_SEQUENCE)
             return;
+
         if (Phase == PHASE_FLIGHT || Phase == PHASE_DEMON)
             AttackStartNoMove(who);
         else
             ScriptedAI::AttackStart(who);
     }
+
     void MoveInLineOfSight(Unit *who) {}
+
     void JustDied(Unit *killer)
     {
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
         if (!pInstance)
             return;
+
         pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, DONE); // Completed
-        for (uint8 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L + 1; ++i)
+
+        for(uint8 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L + 1; ++i)
             pInstance->HandleGameObject(pInstance->GetData64(i), true);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim == m_creature) return;
@@ -425,6 +480,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
             break;
         }
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth() && done_by != m_creature)
@@ -432,6 +488,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
         if (done_by->GetGUID() == MaievGUID)
             done_by->AddThreat(m_creature, -(3*(float)damage)/4); // do not let maiev tank him
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_GLAIVE_RETURNS) // Re-equip our warblades!
@@ -443,9 +500,10 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
             m_creature->SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE);
         }
     }
+
     void DeleteFromThreatList(uint64 TargetGUID)
     {
-        for (std::list::iterator itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++itr)
+        for(std::list::iterator itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++itr)
         {
             if ((*itr)->getUnitGuid() == TargetGUID)
             {
@@ -454,9 +512,11 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
             }
         }
     }
+
     void Talk(uint32 count)
     {
         Timer[EVENT_TALK_SEQUENCE] = Conversation[count].timer;
+
         Creature* pCreature = NULL;
         if (Conversation[count].pCreature == ILLIDAN_STORMRAGE)
             pCreature = m_creature;
@@ -464,6 +524,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
             pCreature = (Unit::GetCreature((*m_creature), AkamaGUID));
         else if (Conversation[count].pCreature == MAIEV_SHADOWSONG)
             pCreature = (Unit::GetCreature((*m_creature), MaievGUID));
+
         if (pCreature)
         {
             if (Conversation[count].emote)
@@ -474,6 +535,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
                 DoPlaySoundToSet(pCreature, Conversation[count].sound); // Play some sound on the creature
         }
     }
+
     void EnterPhase(PhaseIllidan NextPhase);
     void CastEyeBlast();
     void SummonFlamesOfAzzinoth();
@@ -539,7 +601,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
             Timer[EVENT_FLIGHT_SEQUENCE] = 0;
             break;
         case 8://glaive return
-            for (uint8 i = 0; i < 2; ++i)
+            for(uint8 i = 0; i < 2; ++i)
             {
                 if (GlaiveGUID[i])
                 {
@@ -557,7 +619,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
             m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
             m_creature->StopMoving();
             m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
-            for (uint8 i = 0; i < 2; ++i)
+            for(uint8 i = 0; i < 2; ++i)
             {
                 if (GlaiveGUID[i])
                 {
@@ -582,14 +644,18 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
         }
         FlightCount++;
     }
+
     void HandleTransformSequence()
     {
         if (DemonTransformation[TransformCount].unaura)
             m_creature->RemoveAurasDueToSpell(DemonTransformation[TransformCount].unaura);
+
         if (DemonTransformation[TransformCount].aura)
             DoCast(m_creature, DemonTransformation[TransformCount].aura, true);
+
         if (DemonTransformation[TransformCount].displayid)
             m_creature->SetDisplayId(DemonTransformation[TransformCount].displayid); // It's morphin time!
+
         if (DemonTransformation[TransformCount].equip)
         {
             // Requip warglaives if needed
@@ -601,6 +667,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
             // Unequip warglaives if needed
             SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_UNEQUIP, EQUIP_NO_CHANGE);
         }
+
         switch(TransformCount)
         {
         case 2:
@@ -625,12 +692,14 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
             Timer[EVENT_TRANSFORM_SEQUENCE] = DemonTransformation[TransformCount].timer;
         TransformCount++;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if ((!UpdateVictim()) && Phase < PHASE_TALK_SEQUENCE)
             return;
+
         Event = EVENT_NULL;
-        for (uint32 i = 1; i <= MaxTimer[Phase]; ++i)
+        for(uint32 i = 1; i <= MaxTimer[Phase]; ++i)
         {
             if (Timer[i]) // Event is enabled
                 if (Timer[i] <= diff)
@@ -640,35 +709,43 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
                 }
                 else Timer[i] -= diff;
         }
+
         switch(Phase)
         {
         case PHASE_NORMAL:
             if (HPPCT(m_creature) < 65)
                 EnterPhase(PHASE_FLIGHT_SEQUENCE);
             break;
+
         case PHASE_NORMAL_2:
             if (HPPCT(m_creature) < 30)
                 EnterPhase(PHASE_TALK_SEQUENCE);
             break;
+
         case PHASE_NORMAL_MAIEV:
             if (HPPCT(m_creature) < 1)
                 EnterPhase(PHASE_TALK_SEQUENCE);
             break;
+
         case PHASE_TALK_SEQUENCE:
             if (Event == EVENT_TALK_SEQUENCE)
                 HandleTalkSequence();
             break;
+
         case PHASE_FLIGHT_SEQUENCE:
             if (Event == EVENT_FLIGHT_SEQUENCE)
                 HandleFlightSequence();
             break;
+
         case PHASE_TRANSFORM_SEQUENCE:
             if (Event == EVENT_TRANSFORM_SEQUENCE)
                 HandleTransformSequence();
             break;
         }
+
         if (m_creature->IsNonMeleeSpellCasted(false))
             return;
+
         if (Phase == PHASE_NORMAL || Phase == PHASE_NORMAL_2 || Phase == PHASE_NORMAL_MAIEV && !m_creature->HasAura(SPELL_CAGED))
         {
             switch(Event)
@@ -680,6 +757,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
                 DoCast(m_creature, SPELL_BERSERK, true);
                 Timer[EVENT_BERSERK] = 5000;//The buff actually lasts forever.
                 break;
+
             case EVENT_TAUNT:
                 {
                     uint32 random = rand()%4;
@@ -692,46 +770,56 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
                 }
                 Timer[EVENT_TAUNT] = 25000 + rand()%10000;
                 break;
+
             case EVENT_SHEAR:
                 // no longer exists in 3.0.2
                 //DoCast(m_creature->getVictim(), SPELL_SHEAR);
                 Timer[EVENT_SHEAR] = 25000 + (rand()%16 * 1000);
                 break;
+
             case EVENT_FLAME_CRASH:
                 DoCast(m_creature->getVictim(), SPELL_FLAME_CRASH);
                 Timer[EVENT_FLAME_CRASH] = 30000 + rand()%10000;
                 break;
+
             case EVENT_PARASITIC_SHADOWFIEND:
                 {
                     if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 200, true))
                         m_creature->CastSpell(target, SPELL_PARASITIC_SHADOWFIEND, true);
                     Timer[EVENT_PARASITIC_SHADOWFIEND] = 35000 + rand()%10000;
                 }break;
+
             case EVENT_PARASITE_CHECK:
                 Timer[EVENT_PARASITE_CHECK] = 0;
                 break;
+
             case EVENT_DRAW_SOUL:
                 DoCast(m_creature->getVictim(), SPELL_DRAW_SOUL);
                 Timer[EVENT_DRAW_SOUL] = 50000 + rand()%10000;
                 break;
+
                 //PHASE_NORMAL_2
             case EVENT_AGONIZING_FLAMES:
                 DoCast(SelectUnit(SELECT_TARGET_RANDOM,0), SPELL_AGONIZING_FLAMES);
                 Timer[EVENT_AGONIZING_FLAMES] = 0;
                 break;
+
             case EVENT_TRANSFORM_NORMAL:
                 EnterPhase(PHASE_TRANSFORM_SEQUENCE);
                 break;
+
                 //PHASE_NORMAL_MAIEV
             case EVENT_ENRAGE:
                 DoCast(m_creature, SPELL_ENRAGE);
                 Timer[EVENT_ENRAGE] = 0;
                 break;
+
             default:
                 break;
             }
             DoMeleeAttackIfReady();
         }
+
         if (Phase == PHASE_FLIGHT)
         {
             switch(Event)
@@ -740,14 +828,17 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
                 DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FIREBALL);
                 Timer[EVENT_FIREBALL] = 3000;
                 break;
+
             case EVENT_DARK_BARRAGE:
                 DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DARK_BARRAGE);
                 Timer[EVENT_DARK_BARRAGE] = 0;
                 break;
+
             case EVENT_EYE_BLAST:
                 CastEyeBlast();
                 Timer[EVENT_EYE_BLAST] = 0;
                 break;
+
             case EVENT_MOVE_POINT:
                 Phase = PHASE_FLIGHT_SEQUENCE;
                 Timer[EVENT_FLIGHT_SEQUENCE] = 0;//do not start Event when changing hover point
@@ -756,10 +847,12 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
                     HoverPoint -= 4;
                 m_creature->GetMotionMaster()->MovePoint(0, HoverPosition[HoverPoint].x, HoverPosition[HoverPoint].y, HoverPosition[HoverPoint].z);
                 break;
+
             default:
                 break;
             }
         }
+
         if (Phase == PHASE_DEMON)
         {
             switch(Event)
@@ -791,20 +884,26 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public ScriptedAI
         }
     }
 };
+
 /********************************** End of Illidan AI ******************************************/
+
 struct TRINITY_DLL_DECL flame_of_azzinothAI : public ScriptedAI
 {
     flame_of_azzinothAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 FlameBlastTimer;
     uint32 CheckTimer;
     uint64 GlaiveGUID;
+
     void Reset()
     {
         FlameBlastTimer = 15000;
         CheckTimer = 5000;
         GlaiveGUID = 0;
     }
+
     void EnterCombat(Unit *who) {DoZoneInCombat();}
+
     void ChargeCheck()
     {
         Unit* target = SelectTarget(SELECT_TARGET_FARTHEST, 0, 200, false);
@@ -816,6 +915,7 @@ struct TRINITY_DLL_DECL flame_of_azzinothAI : public ScriptedAI
             m_creature->MonsterTextEmote(EMOTE_SETS_GAZE_ON, target->GetGUID());
         }
     }
+
     void EnrageCheck()
     {
         if (GETUNIT(Glaive, GlaiveGUID))
@@ -839,11 +939,14 @@ struct TRINITY_DLL_DECL flame_of_azzinothAI : public ScriptedAI
             }
         }
     }
+
     void SetGlaiveGUID(uint64 guid){ GlaiveGUID = guid; }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (FlameBlastTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_BLAZE_SUMMON, true); //appear at victim
@@ -851,16 +954,20 @@ struct TRINITY_DLL_DECL flame_of_azzinothAI : public ScriptedAI
             FlameBlastTimer = 15000; //10000 is official-like?
             DoZoneInCombat(); //in case someone is revived
         }else FlameBlastTimer -= diff;
+
         if (CheckTimer < diff)
         {
             ChargeCheck();
             EnrageCheck();
             CheckTimer = 1000;
         }else CheckTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
 
+
+
 /******* Functions and vars for Akama's AI ******/
 struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
 {
@@ -871,39 +978,46 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
     }
     bool JustCreated;
     ScriptedInstance* pInstance;
+
     PhaseAkama Phase;
     bool Event;
     uint32 Timer;
+
     uint64 IllidanGUID;
     uint64 ChannelGUID;
     uint64 SpiritGUID[2];
     uint64 GateGUID;
     uint64 DoorGUID[2];
+
     uint32 ChannelCount;
     uint32 WalkCount;
     uint32 TalkCount;
     uint32 Check_Timer;
+
     void Reset()
     {
         WalkCount = 0;
         if (pInstance)
         {
             pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, NOT_STARTED);
+
             IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE);
             GateGUID = pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_GATE);
             DoorGUID[0] = pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_DOOR_R);
             DoorGUID[1] = pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_DOOR_L);
-            if(JustCreated) //close all doors at create
+
+            if(JustCreated)//close all doors at create
             {
                 pInstance->HandleGameObject(GateGUID, false);
-                for (uint8 i = 0; i < 2; ++i)
+
+                for(uint8 i = 0; i < 2; ++i)
                     pInstance->HandleGameObject(DoorGUID[i], false);
                 //JustCreated = false;
             }else
             {//open all doors, raid wiped
                 pInstance->HandleGameObject(GateGUID, true);
                 WalkCount = 1;//skip first wp
-                for (uint8 i = 0; i < 2; ++i)
+                for(uint8 i = 0; i < 2; ++i)
                     pInstance->HandleGameObject(DoorGUID[i], true);
             }
         }
@@ -914,20 +1028,26 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
             DoorGUID[0] = 0;
             DoorGUID[1] = 0;
         }
+
         ChannelGUID = 0;
         SpiritGUID[0] = 0;
         SpiritGUID[1] = 0;
+
         Phase = PHASE_AKAMA_NULL;
         Timer = 0;
+
         ChannelCount = 0;
         TalkCount = 0;
         Check_Timer = 5000;
+
         KillAllElites();
+
         m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 0); // Database sometimes has strange values..
         m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
         m_creature->setActive(false);
         m_creature->SetVisibility(VISIBILITY_OFF);
     }
+
     // 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()
     {
@@ -935,38 +1055,44 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
         m_creature->DeleteThreatList();
         m_creature->CombatStop(true);
     }
+
     void EnterCombat(Unit *who) {}
     void MoveInLineOfSight(Unit* who) {}
+
     void MovementInform(uint32 MovementType, uint32 Data)
     {
         if(MovementType == POINT_MOTION_TYPE)
             Timer = 1;
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage > m_creature->GetHealth() || done_by->GetGUID() != IllidanGUID)
             damage = 0;
     }
+
     void KillAllElites()
     {
         std::list& threatList = m_creature->getThreatManager().getThreatList();
         std::vector eliteList;
-        for (std::list::iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
+        for(std::list::iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
         {
             Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
             if (pUnit && pUnit->GetEntry() == ILLIDARI_ELITE)
                 eliteList.push_back(pUnit);
         }
-        for (std::vector::iterator itr = eliteList.begin(); itr != eliteList.end(); ++itr)
+        for(std::vector::iterator itr = eliteList.begin(); itr != eliteList.end(); ++itr)
             (*itr)->setDeathState(JUST_DIED);
         EnterEvadeMode();
     }
+
     void BeginTalk()
     {
         if (!pInstance)
             return;
+
         pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, IN_PROGRESS);
-        for (uint8 i = 0; i < 2; ++i)
+        for(uint8 i = 0; i < 2; ++i)
             pInstance->HandleGameObject(DoorGUID[i], false);
         if (GETCRE(Illidan, IllidanGUID))
         {
@@ -979,6 +1105,7 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
             CAST_AI(boss_illidan_stormrageAI, Illidan->AI())->EnterPhase(PHASE_TALK_SEQUENCE);
         }
     }
+
     void BeginChannel()
     {
         m_creature->setActive(true);
@@ -990,25 +1117,29 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
             Gate->GetPosition(x, y, z);
         else
             return;//if door not spawned, don't crash server
+
         if (Creature* Channel = m_creature->SummonCreature(ILLIDAN_DOOR_TRIGGER, x, y, z+5, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000))
         {
             ChannelGUID = Channel->GetGUID();
             Channel->SetDisplayId(11686); // Invisible but spell visuals can still be seen.
             DoCast(Channel, SPELL_AKAMA_DOOR_FAIL);
         }
-        for (uint8 i = 0; i < 2; ++i)
+
+        for(uint8 i = 0; i < 2; ++i)
             if (Creature* Spirit = m_creature->SummonCreature(i ? SPIRIT_OF_OLUM : SPIRIT_OF_UDALO, SpiritSpawns[i].x, SpiritSpawns[i].y, SpiritSpawns[i].z, 0, TEMPSUMMON_TIMED_DESPAWN, 20000))
             {
                 Spirit->SetVisibility(VISIBILITY_OFF);
                 SpiritGUID[i] = Spirit->GetGUID();
             }
     }
+
     void BeginWalk()
     {
         m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
         m_creature->SetSpeed(MOVE_RUN, 1.0f);
         m_creature->GetMotionMaster()->MovePoint(0, AkamaWP[WalkCount].x, AkamaWP[WalkCount].y, AkamaWP[WalkCount].z);
     }
+
     void EnterPhase(PhaseAkama NextPhase)
     {
         if (!pInstance)
@@ -1072,6 +1203,7 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
         Phase = NextPhase;
         Event = false;
     }
+
     void HandleTalkSequence()
     {
         switch(TalkCount)
@@ -1096,6 +1228,7 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
         }
         TalkCount++;
     }
+
     void HandleChannelSequence()
     {
         Unit* Channel, *Spirit[2];
@@ -1107,6 +1240,7 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
             if (!Channel || !Spirit[0] || !Spirit[1])
                 return;
         }
+
         switch(ChannelCount)
         {
         case 0: // channel failed
@@ -1152,12 +1286,13 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
         }
         ChannelCount++;
     }
+
     void HandleWalkSequence()
     {
         switch(WalkCount)
         {
         case 6:
-            for (uint8 i = 0; i < 2; ++i)
+            for(uint8 i = 0; i < 2; ++i)
                 if(pInstance)
                     pInstance->HandleGameObject(DoorGUID[i], true);
             break;
@@ -1171,6 +1306,7 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
             EnterPhase(PHASE_FIGHT_MINIONS);
             break;
         }
+
         if (Phase == PHASE_WALK)
         {
             Timer = 0;
@@ -1178,6 +1314,7 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
             m_creature->GetMotionMaster()->MovePoint(WalkCount, AkamaWP[WalkCount].x, AkamaWP[WalkCount].y, AkamaWP[WalkCount].z);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if(m_creature->GetVisibility() == VISIBILITY_OFF)
@@ -1186,6 +1323,7 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
             {
                 if(pInstance && pInstance->GetData(DATA_ILLIDARICOUNCILEVENT) == DONE)
                     m_creature->SetVisibility(VISIBILITY_ON);
+
                 Check_Timer = 5000;
             }else Check_Timer -= diff;
         }
@@ -1196,6 +1334,7 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
                 Event = true;
             else Timer -= diff;
         }
+
         if (Event)
         {
             switch(Phase)
@@ -1248,22 +1387,29 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
                 break;
             }
         }
+
         if (!UpdateVictim())
             return;
+
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 20)
             DoCast(m_creature, SPELL_HEALING_POTION);
+
         DoMeleeAttackIfReady();
     }
 };
 
+
 struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
 {
     boss_maievAI(Creature *c) : ScriptedAI(c) {};
+
     uint64 IllidanGUID;
+
     PhaseIllidan Phase;
     EventMaiev Event;
     uint32 Timer[5];
     uint32 MaxTimer;
+
     void Reset()
     {
         MaxTimer = 0;
@@ -1275,10 +1421,12 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
         SetEquipmentSlots(false, 44850, EQUIP_UNEQUIP, EQUIP_NO_CHANGE);
         m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, 45738);
     }
+
     void EnterCombat(Unit *who) {}
     void MoveInLineOfSight(Unit *who) {}
     void EnterEvadeMode() {}
     void GetIllidanGUID(uint64 guid) { IllidanGUID = guid; }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by->GetGUID() != IllidanGUID)
@@ -1292,10 +1440,12 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
                 damage = 0;
         }
     }
+
     void AttackStart(Unit *who)
     {
         if (!who || Timer[EVENT_MAIEV_STEALTH])
             return;
+
         if (Phase == PHASE_TALK_SEQUENCE)
             AttackStartNoMove(who);
         else if (Phase == PHASE_DEMON || Phase == PHASE_TRANSFORM_SEQUENCE)
@@ -1308,12 +1458,14 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
         else
             ScriptedAI::AttackStart(who);
     }
+
     void DoAction(const int32 param)
     {
         if (param > PHASE_ILLIDAN_NULL && param < PHASE_ILLIDAN_MAX)
             EnterPhase(PhaseIllidan(param));
     }
-    void EnterPhase(PhaseIllidan NextPhase) //This is in fact Illidan's phase.
+
+    void EnterPhase(PhaseIllidan NextPhase)//This is in fact Illidan's phase.
     {
         switch(NextPhase)
         {
@@ -1349,6 +1501,7 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
             MaxTimer = 1;
         Phase = NextPhase;
     }
+
     void BlinkTo(float x, float y, float z)
     {
         m_creature->AttackStop();
@@ -1357,11 +1510,13 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
         DoTeleportTo(x, y, z);
         DoCast(m_creature, SPELL_TELEPORT_VISUAL, true);
     }
+
     void BlinkToPlayer()
     {
         if (GETCRE(Illidan, IllidanGUID))
         {
             Unit* target = CAST_AI(boss_illidan_stormrageAI, Illidan->AI())->SelectUnit(SELECT_TARGET_RANDOM, 0);
+
             if (!target || !m_creature->IsWithinDistInMap(target, 80) || Illidan->IsWithinDistInMap(target, 20))
             {
                 uint8 pos = rand()%4;
@@ -1375,19 +1530,22 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if ((!UpdateVictim())
             && !Timer[EVENT_MAIEV_STEALTH])
             return;
+
         Event = EVENT_MAIEV_NULL;
-        for (uint8 i = 1; i <= MaxTimer; ++i)
+        for(uint8 i = 1; i <= MaxTimer; ++i)
             if (Timer[i])
             {
                 if (Timer[i] <= diff)
                     Event = (EventMaiev)i;
                 else Timer[i] -= diff;
             }
+
             switch(Event)
             {
             case EVENT_MAIEV_STEALTH:
@@ -1430,6 +1588,7 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
             default:
                 break;
             }
+
             if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50)
             {
                 m_creature->SetVisibility(VISIBILITY_OFF);
@@ -1440,11 +1599,13 @@ struct TRINITY_DLL_DECL boss_maievAI : public ScriptedAI
                 Timer[EVENT_MAIEV_STEALTH] = 60000; //reappear after 1 minute
                 MaxTimer = 1;
             }
+
             if (Phase == PHASE_NORMAL_MAIEV)
                 DoMeleeAttackIfReady();
     }
 };
 
+
 bool GossipSelect_npc_akama_at_illidan(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF) // Time to begin the Event
@@ -1454,32 +1615,44 @@ bool GossipSelect_npc_akama_at_illidan(Player* pPlayer, Creature* pCreature, uin
     }
     return true;
 }
+
 bool GossipHello_npc_akama_at_illidan(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
     pPlayer->SEND_GOSSIP_MENU(10465, pCreature->GetGUID());
+
     return true;
 }
+
 struct TRINITY_DLL_DECL cage_trap_triggerAI : public ScriptedAI
 {
     cage_trap_triggerAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 IllidanGUID;
     uint32 DespawnTimer;
+
     bool Active;
     bool SummonedBeams;
+
     void Reset()
     {
         IllidanGUID = 0;
+
         Active = false;
         SummonedBeams = false;
+
         DespawnTimer = 0;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void EnterCombat(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
@@ -1497,12 +1670,14 @@ struct TRINITY_DLL_DECL cage_trap_triggerAI : public ScriptedAI
             }
         }
     }
+
     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)
@@ -1512,35 +1687,45 @@ struct TRINITY_DLL_DECL cage_trap_triggerAI : public ScriptedAI
             //}
     }
 };
+
 bool GOHello_cage_trap(Player* pPlayer, GameObject* pGo)
 {
     float x, y, z;
     pPlayer->GetPosition(x, y, z);
+
     // Grid search for nearest live Creature of entry 23304 within 10 yards
     if (Creature* pTrigger = pGo->FindNearestCreature(23304, 10.0f))
         CAST_AI(cage_trap_triggerAI, pTrigger->AI())->Active = true;
     pGo->SetGoState(GO_STATE_ACTIVE);
     return true;
 }
+
 struct TRINITY_DLL_DECL shadow_demonAI : public ScriptedAI
 {
     shadow_demonAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 TargetGUID;
+
     void EnterCombat(Unit *who) {DoZoneInCombat();}
+
     void Reset()
     {
         TargetGUID = 0;
         m_creature->CastSpell(m_creature, SPELL_SHADOW_DEMON_PASSIVE, true);
     }
+
     void JustDied(Unit *killer)
     {
         if (Unit* target = Unit::GetUnit((*m_creature), TargetGUID))
             target->RemoveAurasDueToSpell(SPELL_PARALYZE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim()) return;
+
         if (m_creature->getVictim()->GetTypeId() != TYPEID_PLAYER) return; // Only cast the below on players.
+
         if (!m_creature->getVictim()->HasAura(SPELL_PARALYZE))
         {
             TargetGUID = m_creature->getVictim()->GetGUID();
@@ -1553,6 +1738,7 @@ struct TRINITY_DLL_DECL shadow_demonAI : public ScriptedAI
             DoCast(m_creature->getVictim(), SPELL_CONSUME_SOUL);
     }
 };
+
 // Shadowfiends interact with Illidan, setting more targets in Illidan's hashmap
 struct TRINITY_DLL_DECL mob_parasitic_shadowfiendAI : public ScriptedAI
 {
@@ -1560,19 +1746,24 @@ struct TRINITY_DLL_DECL mob_parasitic_shadowfiendAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     uint64 IllidanGUID;
     uint32 CheckTimer;
+
     void Reset()
     {
         if (pInstance)
             IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE);
         else
             IllidanGUID = 0;
+
         CheckTimer = 5000;
         DoCast(m_creature, SPELL_SHADOWFIEND_PASSIVE, true);
     }
+
     void EnterCombat(Unit* who) { DoZoneInCombat(); }
+
     void DoMeleeAttackIfReady()
     {
         if (m_creature->isAttackReady() && m_creature->IsWithinMeleeRange(m_creature->getVictim()))
@@ -1580,7 +1771,7 @@ struct TRINITY_DLL_DECL mob_parasitic_shadowfiendAI : public ScriptedAI
             if (!m_creature->getVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND)
                 && !m_creature->getVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND2))
             {
-                if (Creature* illidan = Unit::GetCreature((*m_creature),IllidanGUID)) //summon only in 1. phase
+                if (Creature* illidan = Unit::GetCreature((*m_creature),IllidanGUID))//summon only in 1. phase
                     if (CAST_AI(boss_illidan_stormrageAI, illidan->AI())->Phase == PHASE_NORMAL)
                         m_creature->CastSpell(m_creature->getVictim(), SPELL_PARASITIC_SHADOWFIEND2, true, 0, 0, IllidanGUID); //do not stack
             }
@@ -1588,6 +1779,7 @@ struct TRINITY_DLL_DECL mob_parasitic_shadowfiendAI : public ScriptedAI
             m_creature->resetAttackTimer();
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->getVictim())
@@ -1601,6 +1793,7 @@ struct TRINITY_DLL_DECL mob_parasitic_shadowfiendAI : public ScriptedAI
                 return;
             }
         }
+
         if (CheckTimer < diff)
         {
             GETUNIT(Illidan, IllidanGUID);
@@ -1611,22 +1804,27 @@ struct TRINITY_DLL_DECL mob_parasitic_shadowfiendAI : public ScriptedAI
                 return;
             }else CheckTimer = 5000;
         }else CheckTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL blade_of_azzinothAI : public NullCreatureAI
 {
     blade_of_azzinothAI(Creature* c) : NullCreatureAI(c) {}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_THROW_GLAIVE2 || spell->Id == SPELL_THROW_GLAIVE)
             me->SetDisplayId(21431);//appear when hit by Illidan's glaive
     }
 };
+
 void boss_illidan_stormrageAI::Reset()
 {
     if (pInstance)
         pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, NOT_STARTED);
+
     if (AkamaGUID)
     {
         if (GETCRE(Akama, AkamaGUID))
@@ -1642,19 +1840,23 @@ void boss_illidan_stormrageAI::Reset()
         }
         AkamaGUID = 0;
     }
+
     MaievGUID = 0;
-    for (uint8 i = 0; i < 2; ++i)
+    for(uint8 i = 0; i < 2; ++i)
     {
         FlameGUID[i] = 0;
         GlaiveGUID[i] = 0;
     }
+
     Phase = PHASE_ILLIDAN_NULL;
     Event = EVENT_NULL;
     Timer[EVENT_BERSERK] = 1500000;
+
     HoverPoint = 0;
     TalkCount = 0;
     FlightCount = 0;
     TransformCount = 0;
+
     m_creature->SetDisplayId(21135);
     m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
     m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -1664,6 +1866,7 @@ void boss_illidan_stormrageAI::Reset()
     m_creature->setActive(false);
     Summons.DespawnAll();
 }
+
 void boss_illidan_stormrageAI::JustSummoned(Creature* summon)
 {
     Summons.Summon(summon);
@@ -1706,6 +1909,7 @@ void boss_illidan_stormrageAI::JustSummoned(Creature* summon)
         break;
     }
 }
+
 void boss_illidan_stormrageAI::HandleTalkSequence()
 {
     switch(TalkCount)
@@ -1789,42 +1993,51 @@ void boss_illidan_stormrageAI::HandleTalkSequence()
     TalkCount++;
 }
 
+
 void boss_illidan_stormrageAI::CastEyeBlast()
 {
     m_creature->InterruptNonMeleeSpells(false);
+
     m_creature->MonsterYell(SAY_EYE_BLAST, LANG_UNIVERSAL, 0);
     DoPlaySoundToSet(m_creature, SOUND_EYE_BLAST);
+
     float distx, disty, dist[2];
-    for (uint8 i = 0; i < 2; ++i)
+    for(uint8 i = 0; i < 2; ++i)
     {
         distx = EyeBlast[i].x - HoverPosition[HoverPoint].x;
         disty = EyeBlast[i].y - HoverPosition[HoverPoint].y;
         dist[i] = distx * distx + disty * disty;
     }
     Locations initial = EyeBlast[dist[0] < dist[1] ? 0 : 1];
-    for (uint8 i = 0; i < 2; ++i)
+    for(uint8 i = 0; i < 2; ++i)
     {
         distx = GlaivePosition[i].x - HoverPosition[HoverPoint].x;
         disty = GlaivePosition[i].y - HoverPosition[HoverPoint].y;
         dist[i] = distx * distx + disty * disty;
     }
     Locations final = GlaivePosition[dist[0] < dist[1] ? 0 : 1];
+
     final.x = 2 * final.x - initial.x;
     final.y = 2 * final.y - initial.y;
+
     Creature* Trigger = m_creature->SummonTrigger(initial.x, initial.y, initial.z, 0, 13000);
     if (!Trigger) return;
+
     Trigger->SetSpeed(MOVE_WALK, 3);
     Trigger->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
     Trigger->GetMotionMaster()->MovePoint(0, final.x, final.y, final.z);
+
     //Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Trigger->GetGUID());
     DoCast(Trigger, SPELL_EYE_BLAST);
 }
+
 void boss_illidan_stormrageAI::SummonFlamesOfAzzinoth()
 {
     m_creature->MonsterYell(SAY_SUMMONFLAMES, LANG_UNIVERSAL, 0);
     DoPlaySoundToSet(m_creature, SOUND_SUMMONFLAMES);
-    for (uint8 i = 0; i < 2; ++i)
+
+    for(uint8 i = 0; i < 2; ++i)
     {
         if (GETUNIT(Glaive, GlaiveGUID[i]))
         {
@@ -1840,6 +2053,7 @@ void boss_illidan_stormrageAI::SummonFlamesOfAzzinoth()
         }
     }
 }
+
 void boss_illidan_stormrageAI::SummonMaiev()
 {
     m_creature->CastSpell(m_creature, SPELL_SHADOW_PRISON, true);
@@ -1852,6 +2066,7 @@ void boss_illidan_stormrageAI::SummonMaiev()
     }
 }
 
+
 void boss_illidan_stormrageAI::EnterPhase(PhaseIllidan NextPhase)
 {
     DoZoneInCombat();
@@ -1936,75 +2151,93 @@ void boss_illidan_stormrageAI::EnterPhase(PhaseIllidan NextPhase)
     Phase = NextPhase;
     Event = EVENT_NULL;
 }
+
 CreatureAI* GetAI_boss_illidan_stormrage(Creature* pCreature)
 {
     return new boss_illidan_stormrageAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_akama_at_illidan(Creature* pCreature)
 {
     return new npc_akama_illidanAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_maiev(Creature* pCreature)
 {
     return new boss_maievAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_flame_of_azzinoth(Creature* pCreature)
 {
     return new flame_of_azzinothAI (pCreature);
 }
+
 CreatureAI* GetAI_cage_trap_trigger(Creature* pCreature)
 {
     return new cage_trap_triggerAI (pCreature);
 }
+
 CreatureAI* GetAI_shadow_demon(Creature* pCreature)
 {
     return new shadow_demonAI (pCreature);
 }
+
 CreatureAI* GetAI_blade_of_azzinoth(Creature* pCreature)
 {
     return new blade_of_azzinothAI (pCreature);
 }
+
 CreatureAI* GetAI_parasitic_shadowfiend(Creature* pCreature)
 {
     return new mob_parasitic_shadowfiendAI (pCreature);
 }
+
 void AddSC_boss_illidan()
 {
     Script* newscript;
+
     newscript = new Script;
     newscript->Name = "boss_illidan_stormrage";
     newscript->GetAI = &GetAI_boss_illidan_stormrage;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_maiev_shadowsong";
     newscript->GetAI = &GetAI_boss_maiev;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_flame_of_azzinoth";
     newscript->GetAI = &GetAI_mob_flame_of_azzinoth;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_blade_of_azzinoth";
     newscript->GetAI = &GetAI_blade_of_azzinoth;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "gameobject_cage_trap";
     newscript->pGOHello = &GOHello_cage_trap;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_cage_trap_trigger";
     newscript->GetAI = &GetAI_cage_trap_trigger;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_shadow_demon";
     newscript->GetAI = &GetAI_shadow_demon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_parasitic_shadowfiend";
     newscript->GetAI = &GetAI_parasitic_shadowfiend;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_mother_shahraz.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_mother_shahraz.cpp
index 3b3fc3d6da6..524ab213d73 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/boss_mother_shahraz.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/boss_mother_shahraz.cpp
@@ -13,14 +13,17 @@
  * along with 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"
+
 //Speech'n'Sounds
 #define SAY_TAUNT1              -1564018
 #define SAY_TAUNT2              -1564019
@@ -33,6 +36,7 @@ EndScriptData */
 #define SAY_SLAY2               -1564026
 #define SAY_ENRAGE              -1564027
 #define SAY_DEATH               -1564028
+
 //Spells
 #define SPELL_BEAM_SINISTER     40859
 #define SPELL_BEAM_VILE         40860
@@ -45,6 +49,7 @@ EndScriptData */
 #define SPELL_SABER_LASH_IMM    43690
 #define SPELL_TELEPORT_VISUAL   40869
 #define SPELL_BERSERK           45078
+
 uint32 PrismaticAuras[]=
 {
     40880,                                                  // Shadow
@@ -54,10 +59,12 @@ uint32 PrismaticAuras[]=
     40896,                                                  // Frost
     40897,                                                  // Holy
 };
+
 struct Locations
 {
     float x,y,z;
 };
+
 static Locations TeleportPoint[]=
 {
     {959.996, 212.576, 193.843},
@@ -68,13 +75,16 @@ static Locations TeleportPoint[]=
     {930.548, 284.888, 193.367},
     {965.997, 278.398, 195.777}
 };
+
 struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
 {
     boss_shahrazAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint64 TargetGUID[3];
     uint32 BeamTimer;
     uint32 BeamCount;
@@ -87,13 +97,17 @@ struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
     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)
+
+        for(uint8 i = 0; i<3; ++i)
             TargetGUID[i] = 0;
+
         BeamTimer = 20000; // Timers may be incorrect
         BeamCount = 0;
         CurrentBeam = 0;                                    // 0 - Sinister, 1 - Vile, 2 - Wicked, 3 - Sinful
@@ -105,32 +119,39 @@ struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
         RandomYellTimer = 70000 + rand()%41 * 1000;
         EnrageTimer = 600000;
         ExplosionCount = 0;
+
         Enraged = false;
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_MOTHERSHAHRAZEVENT, IN_PROGRESS);
+
         DoZoneInCombat();
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
             pInstance->SetData(DATA_MOTHERSHAHRAZEVENT, DONE);
+
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     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)
+        for(uint8 i = 0; i < 3; ++i)
         {
             Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 1);
             if (pUnit && pUnit->isAlive() && (pUnit->GetTypeId() == TYPEID_PLAYER))
@@ -141,23 +162,28 @@ struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged)
         {
             Enraged = true;
             DoCast(m_creature, SPELL_ENRAGE, true);
             DoScriptText(SAY_ENRAGE, m_creature);
         }
+
         //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:
@@ -178,7 +204,9 @@ struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
             if (BeamCount > 3)
                 while(CurrentBeam == Beam)
                     CurrentBeam = rand()%3;
+
         }else BeamTimer -= diff;
+
         // Random Prismatic Shield every 15 seconds.
         if (PrismaticShieldTimer < diff)
         {
@@ -187,21 +215,25 @@ struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
                 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();
+
             DoScriptText(RAND(SAY_SPELL2,SAY_SPELL3), m_creature);
             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 < 3; ++i)
+                for(uint8 i = 0; i < 3; ++i)
                 {
                     Unit* pUnit = NULL;
                     if (TargetGUID[i])
@@ -212,6 +244,7 @@ struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
                         TargetGUID[i] = 0;
                     }
                 }
+
                 ExplosionCount++;
                 FatalAttractionExplodeTimer = 1000;
             }
@@ -221,16 +254,19 @@ struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
                 ExplosionCount = 0;
             }
         }else FatalAttractionExplodeTimer -= diff;
+
         if (ShriekTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SILENCING_SHRIEK);
             ShriekTimer = 25000+rand()%10 * 1000;
         }else ShriekTimer -= diff;
+
         if (SaberTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SABER_LASH);
             SaberTimer = 25000+rand()%10 * 1000;
         }else SaberTimer -= diff;
+
         //Enrage
         if (!m_creature->HasAura(SPELL_BERSERK))
             if (EnrageTimer < diff)
@@ -238,19 +274,23 @@ struct TRINITY_DLL_DECL boss_shahrazAI : public ScriptedAI
             DoCast(m_creature, SPELL_BERSERK);
             DoScriptText(SAY_ENRAGE, m_creature);
         }else EnrageTimer -= diff;
+
         //Random taunts
         if (RandomYellTimer < diff)
         {
             DoScriptText(RAND(SAY_TAUNT1,SAY_TAUNT2,SAY_TAUNT3), m_creature);
             RandomYellTimer = 60000 + rand()%91 * 1000;
         }else RandomYellTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_shahraz(Creature* pCreature)
 {
     return new boss_shahrazAI (pCreature);
 }
+
 void AddSC_boss_mother_shahraz()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_reliquary_of_souls.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_reliquary_of_souls.cpp
index 04921585793..f1e0873dd95 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/boss_reliquary_of_souls.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/boss_reliquary_of_souls.cpp
@@ -13,15 +13,18 @@
 * along with 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:
 SDCategory: Black Temple
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_black_temple.h"
 #include "Spell.h"
+
 //Sound'n'speech
 //Suffering
 #define SUFF_SAY_FREED              -1564047
@@ -32,6 +35,7 @@ EndScriptData */
 #define SUFF_SAY_RECAP              -1564052
 #define SUFF_SAY_AFTER              -1564053
 #define SUFF_EMOTE_ENRAGE           -1564054
+
 //Desire
 #define DESI_SAY_FREED              -1564055
 #define DESI_SAY_SLAY1              -1564056
@@ -40,6 +44,7 @@ EndScriptData */
 #define DESI_SAY_SPEC               -1564059
 #define DESI_SAY_RECAP              -1564060
 #define DESI_SAY_AFTER              -1564061
+
 //Anger
 #define ANGER_SAY_FREED             -1564062
 #define ANGER_SAY_FREED2            -1564063
@@ -48,6 +53,7 @@ EndScriptData */
 #define ANGER_SAY_SPEC              -1564066
 #define ANGER_SAY_BEFORE            -1564067
 #define ANGER_SAY_DEATH             -1564068
+
 //Spells
 #define AURA_OF_SUFFERING               41292
 #define AURA_OF_SUFFERING_ARMOR         42017 // linked aura, need core support
@@ -57,26 +63,32 @@ EndScriptData */
 #define SPELL_FIXATE_TAUNT              41295 // force taunt
 #define SPELL_ENRAGE                    41305
 #define SPELL_SOUL_DRAIN                41303
+
 #define AURA_OF_DESIRE                  41350
 #define AURA_OF_DESIRE_DAMAGE           41352
 #define SPELL_RUNE_SHIELD               41431
 #define SPELL_DEADEN                    41410
 #define SPELL_SOUL_SHOCK                41426
+
 #define AURA_OF_ANGER                   41337
 #define SPELL_SELF_SEETHE               41364 // force cast 41520
 #define SPELL_ENEMY_SEETHE              41520
 #define SPELL_SOUL_SCREAM               41545
 #define SPELL_SPITE_TARGET              41376 // cast 41377 after 6 sec
 #define SPELL_SPITE_DAMAGE              41377
+
 #define ENSLAVED_SOUL_PASSIVE           41535
 #define SPELL_SOUL_RELEASE              41542
 #define SPELL_SUBMERGE                  37550 //dropout 'head'
+
 #define CREATURE_ENSLAVED_SOUL          23469
 #define NUMBER_ENSLAVED_SOUL            8
+
 struct Position2d
 {
     float x,y;
 };
+
 static Position2d Coords[]=
 {
     {450.4, 212.3},
@@ -86,18 +98,24 @@ static Position2d Coords[]=
     {450.4, 137.4},
     {450.4, 168.3}
 };
+
 struct TRINITY_DLL_DECL npc_enslaved_soulAI : public ScriptedAI
 {
     npc_enslaved_soulAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 ReliquaryGUID;
+
     void Reset() {ReliquaryGUID = 0;}
+
     void EnterCombat(Unit* who)
     {
         m_creature->CastSpell(m_creature, ENSLAVED_SOUL_PASSIVE, true);
         DoZoneInCombat();
     }
+
     void JustDied(Unit *killer);
 };
+
 struct TRINITY_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI
 {
     boss_reliquary_of_soulsAI(Creature *c) : ScriptedAI(c)
@@ -105,17 +123,23 @@ struct TRINITY_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         EssenceGUID = 0;
     }
+
     ScriptedInstance* pInstance;
+
     uint64 EssenceGUID;
+
     uint32 Phase;
     uint32 Counter;
     uint32 Timer;
+
     uint32 SoulCount;
     uint32 SoulDeathCount;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, NOT_STARTED);
+
         if (EssenceGUID)
         {
             if (Creature* Essence = Unit::GetCreature(*m_creature, EssenceGUID))
@@ -124,21 +148,26 @@ struct TRINITY_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI
             }
             EssenceGUID = 0;
         }
+
         Phase = 0;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
         m_creature->RemoveAurasDueToSpell(SPELL_SUBMERGE);
     }
+
     void EnterCombat(Unit* who)
     {
         m_creature->AddThreat(who, 10000.0f);
         DoZoneInCombat();
         if (pInstance)
             pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, IN_PROGRESS);
+
         Phase = 1;
         Counter = 0;
         Timer = 0;
     }
+
     bool SummonSoul()
     {
         uint32 random = rand()%6;
@@ -153,13 +182,15 @@ struct TRINITY_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI
         }else EnterEvadeMode();
         return true;
     }
+
     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++)
+        for(; itr != m_threatlist.end(); itr++)
         {
             Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
             if (pUnit)
@@ -170,20 +201,24 @@ struct TRINITY_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI
             }
         }
     }
+
     void JustDied(Unit* killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Phase)
             return;
+
         if (m_creature->getThreatManager().getThreatList().empty()) // Reset if event is begun and we don't have a threatlist
         {
             EnterEvadeMode();
             return;
         }
+
         Creature* Essence;
         if (EssenceGUID)
         {
@@ -194,6 +229,7 @@ struct TRINITY_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI
                 return;
             }
         }
+
         if (Timer < diff)
         {
             switch(Counter)
@@ -294,24 +330,30 @@ struct TRINITY_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI
         }else Timer -= diff;
     }
 };
+
 struct TRINITY_DLL_DECL boss_essence_of_sufferingAI : public ScriptedAI
 {
     boss_essence_of_sufferingAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 StatAuraGUID;
+
     uint32 AggroYellTimer;
     uint32 FixateTimer;
     uint32 EnrageTimer;
     uint32 SoulDrainTimer;
     uint32 AuraTimer;
+
     void Reset()
     {
         StatAuraGUID = 0;
+
         AggroYellTimer = 5000;
         FixateTimer = 8000;
         EnrageTimer = 30000;
         SoulDrainTimer = 45000;
         AuraTimer = 5000;
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth())
@@ -322,6 +364,7 @@ struct TRINITY_DLL_DECL boss_essence_of_sufferingAI : public ScriptedAI
             DoScriptText(SUFF_SAY_RECAP, m_creature);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (!m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
@@ -334,10 +377,12 @@ struct TRINITY_DLL_DECL boss_essence_of_sufferingAI : public ScriptedAI
             }
         else return;
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SUFF_SAY_SLAY1,SUFF_SAY_SLAY2,SUFF_SAY_SLAY3), m_creature);
     }
+
     void CastFixate()
     {
         std::list& m_threatlist = m_creature->getThreatManager().getThreatList();
@@ -345,7 +390,7 @@ struct TRINITY_DLL_DECL boss_essence_of_sufferingAI : public ScriptedAI
             return; // No point continuing if empty threatlist.
         std::list targets;
         std::list::iterator itr = m_threatlist.begin();
-        for (; itr != m_threatlist.end(); ++itr)
+        for(; itr != m_threatlist.end(); ++itr)
         {
             Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
             if (pUnit && pUnit->isAlive() && (pUnit->GetTypeId() == TYPEID_PLAYER)) // Only alive players
@@ -361,6 +406,7 @@ struct TRINITY_DLL_DECL boss_essence_of_sufferingAI : public ScriptedAI
         DoResetThreat();
         m_creature->AddThreat(target,1000000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (m_creature->isInCombat())
@@ -376,29 +422,36 @@ struct TRINITY_DLL_DECL boss_essence_of_sufferingAI : public ScriptedAI
                 }
             }else FixateTimer -= diff;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (EnrageTimer < diff)
         {
             DoCast(m_creature, SPELL_ENRAGE);
             EnrageTimer = 60000;
             DoScriptText(SUFF_EMOTE_ENRAGE, m_creature);
         }else EnrageTimer -= diff;
+
         if (SoulDrainTimer < diff)
         {
             DoCast(SelectUnit(SELECT_TARGET_RANDOM,0), SPELL_SOUL_DRAIN);
             SoulDrainTimer = 60000;
         }else SoulDrainTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_essence_of_desireAI : public ScriptedAI
 {
     boss_essence_of_desireAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 RuneShieldTimer;
     uint32 DeadenTimer;
     uint32 SoulShockTimer;
+
     void Reset()
     {
         RuneShieldTimer = 60000;
@@ -406,10 +459,12 @@ struct TRINITY_DLL_DECL boss_essence_of_desireAI : public ScriptedAI
         SoulShockTimer = 5000;
         m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_CONFUSE, true);
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by == m_creature)
             return;
+
         if (damage >= m_creature->GetHealth())
         {
             damage = 0;
@@ -422,29 +477,34 @@ struct TRINITY_DLL_DECL boss_essence_of_desireAI : public ScriptedAI
             m_creature->CastCustomSpell(done_by, AURA_OF_DESIRE_DAMAGE, &bp0, NULL, NULL, true);
         }
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (m_creature->GetCurrentSpell(CURRENT_GENERIC_SPELL))
-            for (uint8 i = 0; i < 3; ++i)
+            for(uint8 i = 0; i < 3; ++i)
                 if (spell->Effect[i] == SPELL_EFFECT_INTERRUPT_CAST)
                     if (m_creature->GetCurrentSpell(CURRENT_GENERIC_SPELL)->m_spellInfo->Id == SPELL_SOUL_SHOCK
                         || m_creature->GetCurrentSpell(CURRENT_GENERIC_SPELL)->m_spellInfo->Id == SPELL_DEADEN)
                         m_creature->InterruptSpell(CURRENT_GENERIC_SPELL, false);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(DESI_SAY_FREED, m_creature);
         DoZoneInCombat();
         DoCast(m_creature, AURA_OF_DESIRE, true);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(DESI_SAY_SLAY1,DESI_SAY_SLAY2,DESI_SAY_SLAY3), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (RuneShieldTimer < diff)
         {
             m_creature->InterruptNonMeleeSpells(false);
@@ -453,11 +513,13 @@ struct TRINITY_DLL_DECL boss_essence_of_desireAI : public ScriptedAI
             DeadenTimer += 2000;
             RuneShieldTimer = 60000;
         }else RuneShieldTimer -= diff;
+
         if (SoulShockTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SOUL_SHOCK);
             SoulShockTimer = 5000;
         }else SoulShockTimer -= diff;
+
         if (DeadenTimer < diff)
         {
             m_creature->InterruptNonMeleeSpells(false);
@@ -468,51 +530,68 @@ struct TRINITY_DLL_DECL boss_essence_of_desireAI : public ScriptedAI
                 DoScriptText(DESI_SAY_SPEC, m_creature);
             }
         }else DeadenTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_essence_of_angerAI : public ScriptedAI
 {
     boss_essence_of_angerAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 AggroTargetGUID;
+
     uint32 CheckTankTimer;
     uint32 SoulScreamTimer;
     uint32 SpiteTimer;
+
     std::list SpiteTargetGUID;
+
     bool CheckedAggro;
+
     void Reset()
     {
         AggroTargetGUID = 0;
+
         CheckTankTimer = 5000;
         SoulScreamTimer = 10000;
         SpiteTimer = 30000;
+
         SpiteTargetGUID.clear();
+
         CheckedAggro = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(ANGER_SAY_FREED,ANGER_SAY_FREED2), m_creature);
+
         DoZoneInCombat();
         DoCast(m_creature, AURA_OF_ANGER, true);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(ANGER_SAY_DEATH, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(ANGER_SAY_SLAY1,ANGER_SAY_SLAY2), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (!CheckedAggro)
         {
             AggroTargetGUID = m_creature->getVictim()->GetGUID();
             CheckedAggro = true;
         }
+
         if (CheckTankTimer < diff)
         {
             if (m_creature->getVictim()->GetGUID() != AggroTargetGUID)
@@ -523,6 +602,7 @@ struct TRINITY_DLL_DECL boss_essence_of_angerAI : public ScriptedAI
             }
             CheckTankTimer = 2000;
         }else CheckTankTimer -= diff;
+
         if (SoulScreamTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SOUL_SCREAM);
@@ -532,15 +612,18 @@ struct TRINITY_DLL_DECL boss_essence_of_angerAI : public ScriptedAI
                 DoScriptText(ANGER_SAY_SPEC, m_creature);
             }
         }else SoulScreamTimer -= diff;
+
         if (SpiteTimer < diff)
         {
             DoCast(m_creature, SPELL_SPITE_TARGET);
             SpiteTimer = 30000;
             DoScriptText(ANGER_SAY_SPEC, m_creature);
         }else SpiteTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 void npc_enslaved_soulAI::JustDied(Unit *killer)
 {
     if (ReliquaryGUID)
@@ -551,26 +634,32 @@ void npc_enslaved_soulAI::JustDied(Unit *killer)
     }
     DoCast(m_creature, SPELL_SOUL_RELEASE, true);
 }
+
 CreatureAI* GetAI_boss_reliquary_of_souls(Creature* pCreature)
 {
     return new boss_reliquary_of_soulsAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_essence_of_suffering(Creature* pCreature)
 {
     return new boss_essence_of_sufferingAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_essence_of_desire(Creature* pCreature)
 {
     return new boss_essence_of_desireAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_essence_of_anger(Creature* pCreature)
 {
     return new boss_essence_of_angerAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_enslaved_soul(Creature* pCreature)
 {
     return new npc_enslaved_soulAI (pCreature);
 }
+
 void AddSC_boss_reliquary_of_souls()
 {
     Script *newscript;
@@ -578,18 +667,22 @@ void AddSC_boss_reliquary_of_souls()
     newscript->Name = "boss_reliquary_of_souls";
     newscript->GetAI = &GetAI_boss_reliquary_of_souls;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_essence_of_suffering";
     newscript->GetAI = &GetAI_boss_essence_of_suffering;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_essence_of_desire";
     newscript->GetAI = &GetAI_boss_essence_of_desire;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_essence_of_anger";
     newscript->GetAI = &GetAI_boss_essence_of_anger;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_enslaved_soul";
     newscript->GetAI = &GetAI_npc_enslaved_soul;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_shade_of_akama.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_shade_of_akama.cpp
index c4365bc8168..ada3230a6f6 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/boss_shade_of_akama.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/boss_shade_of_akama.cpp
@@ -13,25 +13,31 @@
  * along with 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: 90
 SDComment: Seems to be complete.
 SDCategory: Black Temple
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_black_temple.h"
+
 #define SAY_DEATH                   -1564013
 #define SAY_LOW_HEALTH              -1564014
 // Ending cinematic text
 #define SAY_FREE                    -1564015
 #define SAY_BROKEN_FREE_01          -1564016
 #define SAY_BROKEN_FREE_02          -1564017
+
 #define GOSSIP_ITEM                 "We are ready to fight alongside you, Akama"
+
 struct Location
 {
     float x, y, o, z;
 };
+
 static Location ChannelerLocations[]=
 {
     {463.161285, 401.219757, 3.141592},
@@ -41,16 +47,19 @@ static Location ChannelerLocations[]=
     {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
@@ -58,6 +67,7 @@ static Location BrokenCoords[]=
     {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},
@@ -65,6 +75,7 @@ static Location BrokenWP[]=
     {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
@@ -75,6 +86,7 @@ static Location BrokenWP[]=
 #define AKAMA_X         514.583984
 #define AKAMA_Y         400.601013
 #define AKAMA_Z         112.783997
+
 // Spells
 #define SPELL_VERTEX_SHADE_BLACK    39833
 #define SPELL_SHADE_SOUL_CHANNEL    40401
@@ -84,16 +96,21 @@ static Location BrokenWP[]=
 #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 TRINITY_DLL_DECL mob_ashtongue_channelerAI : public ScriptedAI
 {
     mob_ashtongue_channelerAI(Creature* c) : ScriptedAI(c) {ShadeGUID = 0;}
+
     uint64 ShadeGUID;
+
     void Reset() {}
     void JustDied(Unit* killer);
     void EnterCombat(Unit* who) {}
@@ -101,17 +118,21 @@ struct TRINITY_DLL_DECL mob_ashtongue_channelerAI : public ScriptedAI
     void MoveInLineOfSight(Unit* who) {}
     void UpdateAI(const uint32 diff) {}
 };
+
 struct TRINITY_DLL_DECL mob_ashtongue_sorcererAI : public ScriptedAI
 {
     mob_ashtongue_sorcererAI(Creature* c) : ScriptedAI(c) {ShadeGUID = 0;}
+
     uint64 ShadeGUID;
     uint32 CheckTimer;
     bool StartBanishing;
+
     void Reset()
     {
         StartBanishing = false;
         CheckTimer = 5000;
     }
+
     void JustDied(Unit* killer);
     void EnterCombat(Unit* who) {}
     void AttackStart(Unit* who) {}
@@ -120,6 +141,7 @@ struct TRINITY_DLL_DECL mob_ashtongue_sorcererAI : public ScriptedAI
     {
         if (StartBanishing)
             return;
+
         if (CheckTimer < diff)
         {
             Creature* Shade = Unit::GetCreature((*m_creature), ShadeGUID);
@@ -131,6 +153,7 @@ struct TRINITY_DLL_DECL mob_ashtongue_sorcererAI : public ScriptedAI
                     m_creature->GetMotionMaster()->MoveIdle();
                     DoCast(Shade, SPELL_SHADE_SOUL_CHANNEL, true);
                     DoCast(Shade, SPELL_SHADE_SOUL_CHANNEL_2, true);
+
                     StartBanishing = true;
                 }
             }
@@ -138,6 +161,7 @@ struct TRINITY_DLL_DECL mob_ashtongue_sorcererAI : public ScriptedAI
         }else CheckTimer -= diff;
     }
 };
+
 struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
 {
     boss_shade_of_akamaAI(Creature* c) : ScriptedAI(c), summons(m_creature)
@@ -148,29 +172,38 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
         m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
         m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true);
     }
+
     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;
     bool reseting;
     bool GridSearcherSucceeded;
     bool HasKilledAkamaAndReseting;
     SummonList summons;
+
     void Reset()
     {
         reseting = true;
         HasKilledAkamaAndReseting = false;
+
         GridSearcherSucceeded = false;
+
         Sorcerers.clear();
         summons.DespawnAll();//despawn all adds
+
         if (Creature* Akama = Unit::GetCreature(*m_creature, AkamaGUID))
         {
             Akama->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);//turn gossip on so players can restart the event
@@ -182,20 +215,25 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
         }
         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)
             pInstance->SetData(DATA_SHADEOFAKAMAEVENT, NOT_STARTED);
+
         reseting = false;
     }
     void JustDied(Unit* killer)
@@ -212,14 +250,16 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
         if (summon->GetEntry() == CREATURE_DEFENDER || summon->GetEntry() == 23523 || summon->GetEntry() == 23318 || summon->GetEntry() == 23524)
             summons.Despawn(summon);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!GridSearcherSucceeded)
         {
             FindChannelers();
+
             if (!Channelers.empty())
             {
-                for (std::list::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr)
+                for(std::list::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr)
                 {
                     Creature* Channeler = (Unit::GetCreature(*m_creature, *itr));
                     if (Channeler)
@@ -229,6 +269,7 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
                             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);
@@ -238,16 +279,20 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
             }else error_log("SD2 ERROR: No Channelers are stored in the list. This encounter will not work properly");
         }
     }
+
     void AttackStart(Unit* who)
     {
         if (!who || IsBanished) return;
+
         if (who->isTargetableForAttack() && who != m_creature)
             DoStartMovement(who);
     }
+
     void IncrementDeathCount(uint64 guid = 0)               // If guid is set, will remove it from list of sorcerer
     {
         if (reseting)
             return;
+
         debug_log("TSCR: Increasing Death Count for Shade of Akama encounter");
         ++DeathCount;
         m_creature->RemoveAuraFromStack(SPELL_SHADE_SOUL_CHANNEL_2);
@@ -258,6 +303,7 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
             else  Sorcerers.remove(guid);
         }
     }
+
     void SummonCreature()
     {
         uint32 random = rand()%2;
@@ -280,7 +326,7 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
         }
         else
         {
-            for (uint8 i = 0; i < 3; ++i)
+            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)
@@ -293,13 +339,15 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
             }
         }
     }
+
     void FindChannelers()
     {
         std::list ChannelerList;
         m_creature->GetCreatureListWithEntryInGrid(ChannelerList,CREATURE_CHANNELER,50.0f);
+
         if (!ChannelerList.empty())
         {
-            for (std::list::iterator itr = ChannelerList.begin(); itr != ChannelerList.end(); ++itr)
+            for(std::list::iterator itr = ChannelerList.begin(); itr != ChannelerList.end(); ++itr)
             {
                 CAST_AI(mob_ashtongue_channelerAI, (*itr)->AI())->ShadeGUID = m_creature->GetGUID();
                 Channelers.push_back((*itr)->GetGUID());
@@ -308,6 +356,7 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
         }
         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())
@@ -315,15 +364,19 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
             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)
+
+        for(std::list::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr)
             if (Creature* Channeler = (Unit::GetCreature(*m_creature, *itr)))
                 Channeler->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void SetAkamaGUID(uint64 guid) { AkamaGUID = guid; }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->isInCombat())
             return;
+
         if (IsBanished)
         {
             // Akama is set in the threatlist so when we reset, we make sure that he is not included in our check
@@ -332,6 +385,7 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
                 EnterEvadeMode();
                 return;
             }
+
             if (DefenderTimer < diff)
             {
                 uint32 ran = rand()%2;
@@ -356,11 +410,13 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
                 }
                 DefenderTimer = 15000;
             }else DefenderTimer -= diff;
+
             if (SummonTimer < diff)
             {
                 SummonCreature();
                 SummonTimer = 35000;
             }else SummonTimer -= diff;
+
             if (DeathCount >= 6)
             {
                 if (AkamaGUID)
@@ -399,9 +455,10 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
                     }
                 }
             }else ReduceHealthTimer -= diff;
+
             if (HasKilledAkama)
             {
-                if (!HasKilledAkamaAndReseting) //do not let players kill Shade if Akama is dead and Shade is waiting for ResetTimer!! event would bug
+                if (!HasKilledAkamaAndReseting)//do not let players kill Shade if Akama is dead and Shade is waiting for ResetTimer!! event would bug
                 {
                     HasKilledAkamaAndReseting = true;
                     m_creature->RemoveAllAuras();
@@ -417,10 +474,12 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
                     return;
                 } else ResetTimer -= diff;
             }
+
             DoMeleeAttackIfReady();
         }
     }
 };
+
 void mob_ashtongue_channelerAI::JustDied(Unit* killer)
 {
     Creature* Shade = (Unit::GetCreature((*m_creature), ShadeGUID));
@@ -428,6 +487,7 @@ void mob_ashtongue_channelerAI::JustDied(Unit* killer)
         CAST_AI(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 = (Unit::GetCreature((*m_creature), ShadeGUID));
@@ -435,6 +495,7 @@ void mob_ashtongue_sorcererAI::JustDied(Unit* killer)
         CAST_AI(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 TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
 {
     npc_akamaAI(Creature* c) : ScriptedAI(c), summons(m_creature)
@@ -454,8 +515,11 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
         BrokenList.clear();
         HasYelledOnce = false;
     }
+
     ScriptedInstance* pInstance;
+
     uint64 ShadeGUID;
+
     uint32 DestructivePoisonTimer;
     uint32 LightningBoltTimer;
     uint32 CheckTimer;
@@ -465,17 +529,21 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
     uint32 EndingTalkCount;
     uint32 WayPointId;
     uint32 BrokenSummonIndex;
+
     std::list BrokenList;
+
     bool EventBegun;
     bool ShadeHasDied;
     bool StartCombat;
     bool HasYelledOnce;
     SummonList summons;
+
     void Reset()
     {
         DestructivePoisonTimer = 15000;
         LightningBoltTimer = 10000;
         CheckTimer = 2000;
+
         if (!EventBegun)
         {
             m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 0);      // Database sometimes has very very strange values
@@ -483,6 +551,7 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
         }
         summons.DespawnAll();
     }
+
     void JustSummoned(Creature *summon)
     {
         if (summon->GetEntry() == CREATURE_BROKEN)
@@ -493,14 +562,18 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
         if (summon->GetEntry() == CREATURE_BROKEN)
             summons.Despawn(summon);
     }
+
     void EnterCombat(Unit* who) {}
+
     void BeginEvent(Player* pl)
     {
         if (!pInstance)
             return;
+
         ShadeGUID = pInstance->GetData64(DATA_SHADEOFAKAMA);
         if (!ShadeGUID)
             return;
+
         Creature* Shade = (Unit::GetCreature((*m_creature), ShadeGUID));
         if (Shade)
         {
@@ -518,13 +591,16 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
             EventBegun = true;
         }
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
             return;
+
         switch(id)
         {
         case 0: ++WayPointId; break;
+
         case 1:
             if (Creature* Shade = Unit::GetCreature(*m_creature, ShadeGUID))
             {
@@ -536,6 +612,7 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
             break;
         }
     }
+
     void JustDied(Unit* killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
@@ -555,15 +632,18 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
             CAST_AI(boss_shade_of_akamaAI, Shade->AI())->HasKilledAkama = true;
         summons.DespawnAll();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!EventBegun)
             return;
+
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 15 && !HasYelledOnce)
         {
             DoScriptText(SAY_LOW_HEALTH, m_creature);
             HasYelledOnce = true;
         }
+
         if (ShadeGUID && !StartCombat)
         {
             Creature* Shade = (Unit::GetCreature((*m_creature), ShadeGUID));
@@ -584,6 +664,7 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
                 }
             }
         }
+
         if (ShadeHasDied && (WayPointId == 1))
         {
             if (pInstance)
@@ -591,6 +672,7 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
             m_creature->GetMotionMaster()->MovePoint(WayPointId, AkamaWP[1].x, AkamaWP[1].y, AkamaWP[1].z);
             ++WayPointId;
         }
+
         if (!ShadeHasDied && StartCombat)
         {
             if (CheckTimer < diff)
@@ -614,11 +696,12 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
                 CheckTimer = 5000;
             }else CheckTimer -= diff;
         }
+
         if (SummonBrokenTimer && BrokenSummonIndex < 4)
         {
             if (SummonBrokenTimer <= diff)
             {
-                for (uint8 i = 0; i < 4; ++i)
+                for(uint8 i = 0; i < 4; ++i)
                 {
                     float x = BrokenCoords[BrokenSummonIndex].x + (i*5);
                     float y = BrokenCoords[BrokenSummonIndex].y + (1*5);
@@ -639,6 +722,7 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
                 SummonBrokenTimer = 1000;
             }else SummonBrokenTimer -= diff;
         }
+
         if (SoulRetrieveTimer)
             if (SoulRetrieveTimer <= diff)
             {
@@ -659,7 +743,7 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
                     if (!BrokenList.empty())
                     {
                         bool Yelled = false;
-                        for (std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
+                        for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
                             if (Creature* pUnit = Unit::GetCreature(*m_creature, *itr))
                             {
                                 if (!Yelled)
@@ -676,7 +760,7 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
                 case 3:
                     if (!BrokenList.empty())
                     {
-                        for (std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
+                        for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
                             if (Creature* pUnit = Unit::GetCreature(*m_creature, *itr))
                                 // This is the incorrect spell, but can't seem to find the right one.
                                 pUnit->CastSpell(pUnit, 39656, true);
@@ -687,7 +771,7 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
                 case 4:
                     if (!BrokenList.empty())
                     {
-                        for (std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
+                        for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
                             if (Creature* pUnit = Unit::GetCreature((*m_creature), *itr))
                                 pUnit->MonsterYell(SAY_BROKEN_FREE_02, LANG_UNIVERSAL, 0);
                     }
@@ -695,8 +779,10 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
                     break;
                 }
             }else SoulRetrieveTimer -= diff;
+
         if (!UpdateVictim())
             return;
+
         if (DestructivePoisonTimer < diff)
         {
             Creature* Shade = Unit::GetCreature((*m_creature), ShadeGUID);
@@ -704,30 +790,37 @@ struct TRINITY_DLL_DECL npc_akamaAI : public ScriptedAI
                 DoCast(Shade, SPELL_DESTRUCTIVE_POISON);
             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* pCreature)
 {
     return new boss_shade_of_akamaAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_ashtongue_channeler(Creature* pCreature)
 {
     return new mob_ashtongue_channelerAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_ashtongue_sorcerer(Creature* pCreature)
 {
     return new mob_ashtongue_sorcererAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_akama_shade(Creature* pCreature)
 {
     return new npc_akamaAI (pCreature);
 }
+
 bool GossipSelect_npc_akama(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)               //Fight time
@@ -735,8 +828,10 @@ bool GossipSelect_npc_akama(Player* pPlayer, Creature* pCreature, uint32 uiSende
         pPlayer->CLOSE_GOSSIP_MENU();
         CAST_AI(npc_akamaAI, pCreature->AI())->BeginEvent(pPlayer);
     }
+
     return true;
 }
+
 bool GossipHello_npc_akama(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->isAlive())
@@ -744,8 +839,10 @@ bool GossipHello_npc_akama(Player* pPlayer, Creature* pCreature)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
         pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID());
     }
+
     return true;
 }
+
 void AddSC_boss_shade_of_akama()
 {
     Script *newscript;
@@ -753,14 +850,17 @@ void AddSC_boss_shade_of_akama()
     newscript->Name = "boss_shade_of_akama";
     newscript->GetAI = &GetAI_boss_shade_of_akama;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ashtongue_channeler";
     newscript->GetAI = &GetAI_mob_ashtongue_channeler;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ashtongue_sorcerer";
     newscript->GetAI = &GetAI_mob_ashtongue_sorcerer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_akama_shade";
     newscript->GetAI = &GetAI_npc_akama_shade;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_supremus.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_supremus.cpp
index aedfdd97ccc..a4e1b2d5428 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/boss_supremus.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/boss_supremus.cpp
@@ -13,17 +13,21 @@
  * along with 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 molten punch
 SDCategory: Black Temple
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_black_temple.h"
+
 #define EMOTE_NEW_TARGET            -1564010
 #define EMOTE_PUNCH_GROUND          -1564011                //DoScriptText(EMOTE_PUNCH_GROUND, m_creature);
 #define EMOTE_GROUND_CRACK          -1564012
+
 //Spells
 #define SPELL_MOLTEN_PUNCH          40126
 #define SPELL_HATEFUL_STRIKE        41926
@@ -31,20 +35,26 @@ EndScriptData */
 #define SPELL_VOLCANIC_ERUPTION     40117
 #define SPELL_VOLCANIC_SUMMON       40276
 #define SPELL_BERSERK               45078
+
 #define CREATURE_VOLCANO            23085
 #define CREATURE_STALKER            23095
+
 #define PHASE_STRIKE    1
 #define PHASE_CHASE     2
+
 #define EVENT_BERSERK           1
 #define EVENT_SWITCH_PHASE      2
 #define EVENT_FLAME             3
 #define EVENT_VOLCANO           4
 #define EVENT_SWITCH_TARGET     5
 #define EVENT_HATEFUL_STRIKE    6
+
 #define GCD_CAST    1
+
 struct TRINITY_DLL_DECL molten_flameAI : public NullCreatureAI
 {
     molten_flameAI(Creature *c) : NullCreatureAI(c) {}
+
     void InitializeAI()
     {
         float x, y, z;
@@ -54,16 +64,19 @@ struct TRINITY_DLL_DECL molten_flameAI : public NullCreatureAI
         me->CastSpell(me,SPELL_MOLTEN_FLAME,true);
     }
 };
+
 struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI
 {
     boss_supremusAI(Creature *c) : ScriptedAI(c), summons(m_creature)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     EventMap events;
     SummonList summons;
     uint32 phase;
+
     void Reset()
     {
         if (pInstance)
@@ -75,18 +88,23 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI
             }
             //else ToggleDoors(false);
         }
+
         phase = 0;
+
         events.Reset();
         summons.DespawnAll();
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_SUPREMUSEVENT, IN_PROGRESS);
+
         ChangePhase();
         events.ScheduleEvent(EVENT_BERSERK, 900000, GCD_CAST);
         events.ScheduleEvent(EVENT_FLAME, 20000, GCD_CAST);
     }
+
     void ChangePhase()
     {
         if (!phase || phase == PHASE_CHASE)
@@ -112,6 +130,7 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI
         events.SetPhase(phase);
         events.ScheduleEvent(EVENT_SWITCH_PHASE, 60000, GCD_CAST);
     }
+
     void JustDied(Unit *killer)
     {
         if (pInstance)
@@ -121,12 +140,15 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI
         }
         summons.DespawnAll();
     }
+
     void JustSummoned(Creature *summon) {summons.Summon(summon);}
     void SummonedCreatureDespawn(Creature *summon) {summons.Despawn(summon);}
+
     Unit* CalculateHatefulStrikeTarget()
     {
         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)
@@ -141,13 +163,17 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI
                 }
             }
         }
+
         return target;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -194,12 +220,15 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI
                     break;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL npc_volcanoAI : public Scripted_NoMovementAI
 {
     npc_volcanoAI(Creature *c) : Scripted_NoMovementAI(c) {}
+
     void Reset()
     {
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -209,34 +238,43 @@ struct TRINITY_DLL_DECL npc_volcanoAI : public Scripted_NoMovementAI
         wait = 3000;
     }
     uint32 wait;
+
     void EnterCombat(Unit *who) {}
+
     void MoveInLineOfSight(Unit *who) {}
+
     void DoAction(const uint32 info)
     {
         m_creature->RemoveAura(SPELL_VOLCANIC_ERUPTION);
     }
+
     void UpdateAI(const uint32 diff)
     {
-        if (wait<=diff) //wait 3secs before casting
+        if (wait<=diff)//wait 3secs before casting
         {
             DoCast(m_creature, SPELL_VOLCANIC_ERUPTION);
             wait = 60000;
         }
         else wait -= diff;
     }
+
 };
+
 CreatureAI* GetAI_boss_supremus(Creature* pCreature)
 {
     return new boss_supremusAI (pCreature);
 }
+
 CreatureAI* GetAI_molten_flame(Creature* pCreature)
 {
     return new molten_flameAI (pCreature);
 }
+
 CreatureAI* GetAI_npc_volcano(Creature* pCreature)
 {
     return new npc_volcanoAI (pCreature);
 }
+
 void AddSC_boss_supremus()
 {
     Script *newscript;
@@ -244,10 +282,12 @@ void AddSC_boss_supremus()
     newscript->Name = "boss_supremus";
     newscript->GetAI = &GetAI_boss_supremus;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "molten_flame";
     newscript->GetAI = &GetAI_molten_flame;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_volcano";
     newscript->GetAI = &GetAI_npc_volcano;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp
index 70fad658bb9..d4f06f13274 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp
@@ -13,14 +13,17 @@
  * along with 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"
+
  //Speech'n'sound
 #define SAY_INTRO                       -1564037
 #define SAY_AGGRO                       -1564038
@@ -32,6 +35,7 @@ EndScriptData */
 #define SAY_SPECIAL2                    -1564044
 #define SAY_ENRAGE                      -1564045
 #define SAY_DEATH                       -1564046
+
 //Spells
 #define SPELL_INCINERATE                40239
 #define SPELL_CRUSHING_SHADOWS          40243
@@ -39,29 +43,37 @@ EndScriptData */
 #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
+
 #define CREATURE_DOOM_BLOSSOM       23123
 #define CREATURE_SHADOWY_CONSTRUCT  23111
+
 struct TRINITY_DLL_DECL mob_doom_blossomAI : public ScriptedAI
 {
     mob_doom_blossomAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 CheckTeronTimer;
     uint32 ShadowBoltTimer;
     uint64 TeronGUID;
+
     void Reset()
     {
         CheckTeronTimer = 5000;
         ShadowBoltTimer = 12000;
         TeronGUID = 0;
     }
+
     void EnterCombat(Unit *who) { }
     void AttackStart(Unit* who) { }
     void MoveInLineOfSight(Unit* who) { }
+
     void Despawn()
     {
         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 (CheckTeronTimer < diff)
@@ -69,14 +81,17 @@ struct TRINITY_DLL_DECL mob_doom_blossomAI : public ScriptedAI
             if (TeronGUID)
             {
                 DoZoneInCombat();
+
                 Creature* Teron = (Unit::GetCreature((*m_creature), TeronGUID));
                 if ((Teron) && (!Teron->isAlive() || Teron->IsInEvadeMode()))
                     Despawn();
             }
             else
                 Despawn();
+
             CheckTeronTimer = 5000;
         }else CheckTeronTimer -= diff;
+
         if (ShadowBoltTimer < diff && m_creature->isInCombat())
         {
             DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_SHADOWBOLT);
@@ -84,29 +99,39 @@ struct TRINITY_DLL_DECL mob_doom_blossomAI : public ScriptedAI
         }else ShadowBoltTimer -= diff;
         return;
     }
+
     void SetTeronGUID(uint64 guid){ TeronGUID = guid; }
 };
+
 struct TRINITY_DLL_DECL mob_shadowy_constructAI : public ScriptedAI
 {
     mob_shadowy_constructAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 GhostGUID;
     uint64 TeronGUID;
+
     uint32 CheckPlayerTimer;
     uint32 CheckTeronTimer;
+
     void Reset()
     {
         GhostGUID = 0;
         TeronGUID = 0;
+
         CheckPlayerTimer = 2000;
         CheckTeronTimer = 5000;
     }
+
     void EnterCombat(Unit* who) { }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || (!who->isAlive()) || (who->GetGUID() == GhostGUID))
             return;
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
 /* 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)
     {
@@ -114,6 +139,7 @@ struct TRINITY_DLL_DECL mob_shadowy_constructAI : public ScriptedAI
         damage = 0;                                         // Only the ghost can deal damage.
     }
  */
+
     void CheckPlayers()
     {
         std::list& m_threatlist = m_creature->getThreatManager().getThreatList();
@@ -121,7 +147,7 @@ struct TRINITY_DLL_DECL mob_shadowy_constructAI : public ScriptedAI
             return;                                         // No threat list. Don't continue.
         std::list::iterator itr = m_threatlist.begin();
         std::list targets;
-        for (; itr != m_threatlist.end(); ++itr)
+        for(; itr != m_threatlist.end(); ++itr)
         {
             Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
             if (pUnit && pUnit->isAlive())
@@ -135,6 +161,7 @@ struct TRINITY_DLL_DECL mob_shadowy_constructAI : public ScriptedAI
             m_creature->AI()->AttackStart(target);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (CheckPlayerTimer < diff)
@@ -142,22 +169,27 @@ struct TRINITY_DLL_DECL mob_shadowy_constructAI : public ScriptedAI
             CheckPlayers();
             CheckPlayerTimer = 3000;
         }else CheckPlayerTimer -= diff;
+
         if (CheckTeronTimer < diff)
         {
             Creature* Teron = (Unit::GetCreature((*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 TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
 {
     boss_teron_gorefiendAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 IncinerateTimer;
     uint32 SummonDoomBlossomTimer;
     uint32 EnrageTimer;
@@ -166,29 +198,37 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
     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;
     bool Done;
+
     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;
         Done = false;
     }
+
     void EnterCombat(Unit *who) {}
+
     void MoveInLineOfSight(Unit* pWho)
     {
         if (!Intro && pWho->GetTypeId() == TYPEID_PLAYER && pWho->isTargetableForAttack() && m_creature->IsHostileTo(pWho) && pWho->isInAccessiblePlaceFor(m_creature))
@@ -197,6 +237,7 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
             {
                 if (pInstance)
                     pInstance->SetData(DATA_TERONGOREFIENDEVENT, IN_PROGRESS);
+
                 m_creature->GetMotionMaster()->Clear(false);
                 m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                 DoScriptText(SAY_INTRO, m_creature);
@@ -208,16 +249,20 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
         if (Done)
             ScriptedAI::MoveInLineOfSight(pWho);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
             pInstance->SetData(DATA_TERONGOREFIENDEVENT, DONE);
+
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     float CalculateRandomLocation(float Loc, uint32 radius)
     {
         float coord = Loc;
@@ -232,12 +277,14 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
         }
         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)
+        for(i = m_threatlist.begin(); i != m_threatlist.end(); ++i)
         {
             Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid());
             if (pUnit && pUnit->isAlive())
@@ -247,6 +294,7 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
             }
         }
     }
+
     void MindControlGhost()
     {
         /************************************************************************/
@@ -255,6 +303,7 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
         /**   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);
@@ -269,7 +318,7 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                 Ghost->DealDamage(Ghost, Ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL,
             false);
             }*/
-            for (uint8 i = 0; i < 4; ++i)
+            for(uint8 i = 0; i < 4; ++i)
             {
                 Creature* Construct = NULL;
                 float X = CalculateRandomLocation(Ghost->GetPositionX(), 10);
@@ -283,12 +332,14 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                     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 && !Done)
@@ -305,6 +356,7 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                     Unit* pUnit = Unit::GetUnit((*m_creature), AggroTargetGUID);
                     if (pUnit)
                         AttackStart(pUnit);
+
                     DoZoneInCombat();
                 }
                 else
@@ -314,12 +366,15 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                 }
             }else AggroTimer -= diff;
         }
+
         if (!UpdateVictim() || !Done)
             return;
+
         if (SummonShadowsTimer < diff)
         {
             //MindControlGhost();
-            for (uint8 i = 0; i < 2; ++i)
+
+            for(uint8 i = 0; i < 2; ++i)
             {
                 Creature* Shadow = NULL;
                 float X = CalculateRandomLocation(m_creature->GetPositionX(), 10);
@@ -329,12 +384,14 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                     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)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -356,11 +413,13 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                 }
             }
         }else SummonDoomBlossomTimer -= diff;
+
         if (IncinerateTimer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
             if (!target)
                 target = m_creature->getVictim();
+
             if (target)
             {
                 DoScriptText(RAND(SAY_SPECIAL1,SAY_SPECIAL2), m_creature);
@@ -368,6 +427,7 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                 IncinerateTimer = 20000 + rand()%31 * 1000;
             }
         }else IncinerateTimer -= diff;
+
         if (CrushingShadowsTimer < diff)
         {
             Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
@@ -375,12 +435,15 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                 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);
@@ -389,11 +452,13 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
                 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)
         {
             DoScriptText(RAND(SAY_SPELL1,SAY_SPELL2), m_creature);
             RandomYellTimer = 50000 + rand()%51 * 1000;
         }else RandomYellTimer -= diff;
+
         if (!m_creature->HasAura(SPELL_BERSERK))
         {
             if (EnrageTimer < diff)
@@ -402,21 +467,26 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
             DoScriptText(SAY_ENRAGE, m_creature);
         }else EnrageTimer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_doom_blossom(Creature* pCreature)
 {
     return new mob_doom_blossomAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_shadowy_construct(Creature* pCreature)
 {
     return new mob_shadowy_constructAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_teron_gorefiend(Creature* pCreature)
 {
     return new boss_teron_gorefiendAI (pCreature);
 }
+
 void AddSC_boss_teron_gorefiend()
 {
     Script *newscript;
@@ -424,10 +494,12 @@ void AddSC_boss_teron_gorefiend()
     newscript->Name = "mob_doom_blossom";
     newscript->GetAI = &GetAI_mob_doom_blossom;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_shadowy_construct";
     newscript->GetAI = &GetAI_mob_shadowy_construct;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_teron_gorefiend";
     newscript->GetAI = &GetAI_boss_teron_gorefiend;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_warlord_najentus.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_warlord_najentus.cpp
index 928e0903d9c..0d7e2a7e61d 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/boss_warlord_najentus.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/boss_warlord_najentus.cpp
@@ -13,14 +13,17 @@
  * along with 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: 95
 SDComment:
 SDCategory: Black Temple
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_black_temple.h"
+
 enum eEnums
 {
     SAY_AGGRO                       = -1564000,
@@ -33,6 +36,7 @@ enum eEnums
     SAY_ENRAGE1                     = -1564007,           //is this text actually in use?
     SAY_ENRAGE2                     = -1564008,
     SAY_DEATH                       = -1564009,
+
     //Spells
     SPELL_NEEDLE_SPINE              = 39992,
     SPELL_TIDAL_BURST               = 39878,
@@ -41,42 +45,55 @@ enum eEnums
     SPELL_CREATE_NAJENTUS_SPINE     = 39956,
     SPELL_HURL_SPINE                = 39948,
     SPELL_BERSERK                   = 26662,
+
     GOBJECT_SPINE                   = 185584,
+
     EVENT_BERSERK                   = 1,
     EVENT_YELL                      = 2,
     EVENT_NEEDLE                    = 3,
     EVENT_SPINE                     = 4,
     EVENT_SHIELD                    = 5,
+
     GCD_CAST                        = 1,
     GCD_YELL                        = 2
 };
+
 struct TRINITY_DLL_DECL boss_najentusAI : public ScriptedAI
 {
     boss_najentusAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     EventMap events;
+
     uint64 SpineTargetGUID;
+
     void Reset()
     {
         events.Reset();
+
         SpineTargetGUID = 0;
+
         if (pInstance)
             pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, NOT_STARTED);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(rand()%2 ? SAY_SLAY1 : SAY_SLAY2, m_creature);
         events.DelayEvents(5000, GCD_YELL);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
             pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, DONE);
+
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_HURL_SPINE && m_creature->HasAura(SPELL_TIDAL_SHIELD))
@@ -86,16 +103,19 @@ struct TRINITY_DLL_DECL boss_najentusAI : public ScriptedAI
             ResetTimer();
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, IN_PROGRESS);
+
         DoScriptText(SAY_AGGRO, m_creature);
         DoZoneInCombat();
         events.ScheduleEvent(EVENT_BERSERK, 480000, GCD_CAST);
         events.ScheduleEvent(EVENT_YELL, 45000 + (rand()%76)*1000, GCD_YELL);
         ResetTimer();
     }
+
     bool RemoveImpalingSpine()
     {
         if (!SpineTargetGUID) return false;
@@ -105,17 +125,21 @@ struct TRINITY_DLL_DECL boss_najentusAI : public ScriptedAI
         SpineTargetGUID=0;
         return true;
     }
+
     void ResetTimer(uint32 inc = 0)
     {
         events.RescheduleEvent(EVENT_NEEDLE, 10000 + inc, GCD_CAST);
         events.RescheduleEvent(EVENT_SPINE, 20000 + inc, GCD_CAST);
         events.RescheduleEvent(EVENT_SHIELD, 60000 + inc);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         events.Update(diff);
+
         while(uint32 eventId = events.ExecuteEvent())
         {
             switch(eventId)
@@ -151,7 +175,7 @@ struct TRINITY_DLL_DECL boss_najentusAI : public ScriptedAI
                     //m_creature->CastSpell(m_creature, SPELL_NEEDLE_SPINE, true);
                     std::list target;
                     SelectTargetList(target, 3, SELECT_TARGET_RANDOM, 80, true);
-                    for (std::list::iterator i = target.begin(); i != target.end(); ++i)
+                    for(std::list::iterator i = target.begin(); i != target.end(); ++i)
                         m_creature->CastSpell(*i, 39835, true);
                     events.ScheduleEvent(EVENT_NEEDLE, 15000+rand()%10000, GCD_CAST);
                     events.DelayEvents(1500, GCD_CAST);
@@ -164,9 +188,11 @@ struct TRINITY_DLL_DECL boss_najentusAI : public ScriptedAI
                     break;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 bool GOHello_go_najentus_spine(Player* pPlayer, GameObject* pGo)
 {
     if (ScriptedInstance* pInstance = pGo->GetInstanceData())
@@ -178,10 +204,12 @@ bool GOHello_go_najentus_spine(Player* pPlayer, GameObject* pGo)
             }
     return true;
 }
+
 CreatureAI* GetAI_boss_najentus(Creature* pCreature)
 {
     return new boss_najentusAI (pCreature);
 }
+
 void AddSC_boss_najentus()
 {
     Script *newscript;
@@ -189,6 +217,7 @@ void AddSC_boss_najentus()
     newscript->Name = "boss_najentus";
     newscript->GetAI = &GetAI_boss_najentus;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_najentus_spine";
     newscript->pGOHello = &GOHello_go_najentus_spine;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/def_black_temple.h b/src/bindings/scripts/scripts/outland/black_temple/def_black_temple.h
index 9b22ff1c0e9..b7432cd5b20 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/def_black_temple.h
+++ b/src/bindings/scripts/scripts/outland/black_temple/def_black_temple.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
+
 enum eTypes
 {
     DATA_AKAMA                      = 1,
@@ -32,5 +34,6 @@ enum eTypes
     DATA_GAMEOBJECT_SUPREMUS_DOORS  = 25,
     DATA_BLOOD_ELF_COUNCIL_VOICE    = 26
 };
+
 #endif
 
diff --git a/src/bindings/scripts/scripts/outland/black_temple/illidari_council.cpp b/src/bindings/scripts/scripts/outland/black_temple/illidari_council.cpp
index ec486675595..7530909cb11 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/illidari_council.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/illidari_council.cpp
@@ -13,42 +13,52 @@
  * along 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"
+
 //Speech'n'Sounds
 #define SAY_GATH_SLAY           -1564085
 #define SAY_GATH_SLAY_COMNT     -1564089
 #define SAY_GATH_DEATH          -1564093
 #define SAY_GATH_SPECIAL1       -1564077
 #define SAY_GATH_SPECIAL2       -1564081
+
 #define SAY_VERA_SLAY           -1564086
 #define SAY_VERA_COMNT          -1564089 //signed for 22949
 #define SAY_VERA_DEATH          -1564094
 #define SAY_VERA_SPECIAL1       -1564078
 #define SAY_VERA_SPECIAL2       -1564082
+
 #define SAY_MALA_SLAY           -1564087
 #define SAY_MALA_COMNT          -1564090
 #define SAY_MALA_DEATH          -1564095
 #define SAY_MALA_SPECIAL1       -1564079
 #define SAY_MALA_SPECIAL2       -1564083
+
 #define SAY_ZERE_SLAY           -1564088
 #define SAY_ZERE_COMNT          -1564091
 #define SAY_ZERE_DEATH          -1564096
 #define SAY_ZERE_SPECIAL1       -1564080
 #define SAY_ZERE_SPECIAL2       -1564084
+
 #define ERROR_INST_DATA           "SD2 ERROR: Instance Data for Black Temple not set properly; Illidari Council event will not function properly."
+
 #define AKAMAID                 23089
+
 struct CouncilYells
 {
     int32 entry;
     uint32 timer;
 };
+
 static CouncilYells CouncilAggro[]=
 {
     {-1564069, 5000},                                       // Gathios
@@ -56,6 +66,7 @@ static CouncilYells CouncilAggro[]=
     {-1564071, 5000},                                       // Malande
     {-1564072, 0},                                          // Zerevor
 };
+
 // Need to get proper timers for this later
 static CouncilYells CouncilEnrage[]=
 {
@@ -64,18 +75,21 @@ static CouncilYells CouncilEnrage[]=
     {-1564075, 5000},                                       // Malande
     {-1564076, 0},                                          // Zerevor
 };
+
 // 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
@@ -85,30 +99,41 @@ static CouncilYells CouncilEnrage[]=
 #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
+
 struct TRINITY_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)
+        for(uint8 i = 0; i < 4; ++i)
             Council[i] = 0;
     }
+
     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()
     {
@@ -120,15 +145,20 @@ struct TRINITY_DLL_DECL mob_blood_elf_council_voice_triggerAI : public ScriptedA
             Council[3] = pInstance->GetData64(DATA_HIGHNETHERMANCERZEREVOR);
         }else error_log(ERROR_INST_DATA);
     }
+
     void EnterCombat(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)
@@ -143,6 +173,7 @@ struct TRINITY_DLL_DECL mob_blood_elf_council_voice_triggerAI : public ScriptedA
                 YellCounter = 0;                            // Reuse for Enrage Yells
         }else AggroYellTimer -= diff;
         }
+
         if (EnrageTimer)
         {
             if (EnrageTimer <= diff)
@@ -158,27 +189,36 @@ struct TRINITY_DLL_DECL mob_blood_elf_council_voice_triggerAI : public ScriptedA
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_illidari_councilAI : public ScriptedAI
 {
     mob_illidari_councilAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
             Council[i] = 0;
     }
+
     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)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (pMember = (Unit::GetCreature((*m_creature), Council[i])))
             {
@@ -190,37 +230,45 @@ struct TRINITY_DLL_DECL mob_illidari_councilAI : public ScriptedAI
                 pMember->AI()->EnterEvadeMode();
             }
         }
+
         if (pInstance)
         {
             pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, NOT_STARTED);
             if (Creature* VoiceTrigger = (Unit::GetCreature(*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->SetDisplayId(11686);
     }
+
     void EnterCombat(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 = (Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE))))
             {
                 CAST_AI(mob_blood_elf_council_voice_triggerAI, VoiceTrigger->AI())->LoadCouncilGUIDs();
                 CAST_AI(mob_blood_elf_council_voice_triggerAI, VoiceTrigger->AI())->EventStarted = true;
             }
-            for (uint8 i = 0; i < 4; ++i)
+
+            for(uint8 i = 0; i < 4; ++i)
             {
                 Unit* Member = NULL;
                 if (Council[i])
@@ -230,13 +278,17 @@ struct TRINITY_DLL_DECL mob_illidari_councilAI : public ScriptedAI
                         CAST_CRE(Member)->AI()->AttackStart(target);
                 }
             }
+
             pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, IN_PROGRESS);
+
             EventBegun = true;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!EventBegun) return;
+
         if (EndEventTimer)
         {
             if (EndEventTimer <= diff)
@@ -253,6 +305,7 @@ struct TRINITY_DLL_DECL mob_illidari_councilAI : public ScriptedAI
                     m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                     return;
                 }
+
                 Creature* pMember = (Unit::GetCreature(*m_creature, Council[DeathCount]));
                 if (pMember && pMember->isAlive())
                     pMember->DealDamage(pMember, pMember->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
@@ -260,12 +313,13 @@ struct TRINITY_DLL_DECL mob_illidari_councilAI : public ScriptedAI
                 EndEventTimer = 1500;
             }else EndEventTimer -= diff;
         }
+
         if (CheckTimer)
         {
             if (CheckTimer <= diff)
             {
                 uint8 EvadeCheck = 0;
-                for (uint8 i = 0; i < 4; ++i)
+                for(uint8 i = 0; i < 4; ++i)
                 {
                     if (Council[i])
                     {
@@ -283,25 +337,33 @@ struct TRINITY_DLL_DECL mob_illidari_councilAI : public ScriptedAI
                         }
                     }
                 }
+
                 if (EvadeCheck > 3)
                     Reset();
+
                 CheckTimer = 2000;
             }else CheckTimer -= diff;
         }
+
     }
 };
+
 struct TRINITY_DLL_DECL boss_illidari_councilAI : public ScriptedAI
 {
     boss_illidari_councilAI(Creature* c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
             Council[i] = 0;
         LoadedGUIDs = false;
     }
+
     uint64 Council[4];
+
     ScriptedInstance* pInstance;
+
     bool LoadedGUIDs;
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
@@ -324,9 +386,10 @@ struct TRINITY_DLL_DECL boss_illidari_councilAI : public ScriptedAI
         if (!LoadedGUIDs)
             LoadGUIDs();
     }
+
     void EnterEvadeMode()
     {
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (Unit* pUnit = Unit::GetUnit(*m_creature, Council[i]))
                 if (pUnit != m_creature && pUnit->getVictim())
@@ -337,12 +400,14 @@ struct TRINITY_DLL_DECL boss_illidari_councilAI : public ScriptedAI
         }
         ScriptedAI::EnterEvadeMode();
     }
+
     void DamageTaken(Unit* done_by, uint32 &damage)
     {
         if (done_by == m_creature)
             return;
+
         damage /= 4;
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (Creature* pUnit = Unit::GetCreature(*m_creature, Council[i]))
                 if (pUnit != m_creature && damage < pUnit->GetHealth())
@@ -352,6 +417,7 @@ struct TRINITY_DLL_DECL boss_illidari_councilAI : public ScriptedAI
                 }
         }
     }
+
     void LoadGUIDs()
     {
         if (!pInstance)
@@ -359,21 +425,26 @@ struct TRINITY_DLL_DECL boss_illidari_councilAI : public ScriptedAI
             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 TRINITY_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_councilAI
 {
     boss_gathios_the_shattererAI(Creature *c) : boss_illidari_councilAI(c) {}
+
     uint32 ConsecrationTimer;
     uint32 HammerOfJusticeTimer;
     uint32 SealTimer;
     uint32 AuraTimer;
     uint32 BlessingTimer;
+
     void Reset()
     {
         ConsecrationTimer = 40000;
@@ -382,24 +453,30 @@ struct TRINITY_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_coun
         AuraTimer = 90000;
         BlessingTimer = 60000;
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_GATH_SLAY, m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_GATH_DEATH, m_creature);
     }
+
     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;
@@ -408,17 +485,19 @@ struct TRINITY_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_coun
             case 0: spellid = SPELL_DEVOTION_AURA;   break;
             case 1: spellid = SPELL_CHROMATIC_AURA;  break;
         }
-        for (uint8 i = 0; i < 4; ++i)
+        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 (!UpdateVictim())
             return;
+
         if (BlessingTimer < diff)
         {
             if (Unit* pUnit = SelectCouncilMember())
@@ -431,11 +510,13 @@ struct TRINITY_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_coun
             }
             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))
@@ -448,6 +529,7 @@ struct TRINITY_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_coun
                 }
             }
         }else HammerOfJusticeTimer -= diff;
+
         if (SealTimer < diff)
         {
             switch(rand()%2)
@@ -457,23 +539,28 @@ struct TRINITY_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_coun
             }
             SealTimer = 40000;
         }else SealTimer -= diff;
+
         if (AuraTimer < diff)
         {
             CastAuraOnCouncil();
             AuraTimer = 90000;
         }else AuraTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_high_nethermancer_zerevorAI : public boss_illidari_councilAI
 {
     boss_high_nethermancer_zerevorAI(Creature *c) : boss_illidari_councilAI(c) {}
+
     uint32 BlizzardTimer;
     uint32 FlamestrikeTimer;
     uint32 ArcaneBoltTimer;
     uint32 DampenMagicTimer;
     uint32 Cooldown;
     uint32 ArcaneExplosionTimer;
+
     void Reset()
     {
         BlizzardTimer = 30000 + rand()%61 * 1000;
@@ -483,18 +570,22 @@ struct TRINITY_DLL_DECL boss_high_nethermancer_zerevorAI : public boss_illidari_
         ArcaneExplosionTimer = 14000;
         Cooldown = 0;
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_ZERE_SLAY, m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_ZERE_DEATH, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Cooldown)
         {
             if (Cooldown < diff) Cooldown = 0;
@@ -504,6 +595,7 @@ struct TRINITY_DLL_DECL boss_high_nethermancer_zerevorAI : public boss_illidari_
                 return;                                     // Don't cast any other spells if global cooldown is still ticking
             }
         }
+
         if (DampenMagicTimer < diff)
         {
             DoCast(m_creature, SPELL_DAMPEN_MAGIC);
@@ -511,18 +603,21 @@ struct TRINITY_DLL_DECL boss_high_nethermancer_zerevorAI : public boss_illidari_
             DampenMagicTimer = 67200;                      // almost 1,12 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))
@@ -533,6 +628,7 @@ struct TRINITY_DLL_DECL boss_high_nethermancer_zerevorAI : public boss_illidari_
                 Cooldown = 1000;
             }
         }else BlizzardTimer -= diff;
+
         if (FlamestrikeTimer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -545,13 +641,16 @@ struct TRINITY_DLL_DECL boss_high_nethermancer_zerevorAI : public boss_illidari_
         }else FlamestrikeTimer -= diff;
     }
 };
+
 struct TRINITY_DLL_DECL boss_lady_malandeAI : public boss_illidari_councilAI
 {
     boss_lady_malandeAI(Creature *c) : boss_illidari_councilAI(c) {}
+
     uint32 EmpoweredSmiteTimer;
     uint32 CircleOfHealingTimer;
     uint32 DivineWrathTimer;
     uint32 ReflectiveShieldTimer;
+
     void Reset()
     {
         EmpoweredSmiteTimer = 38000;
@@ -559,18 +658,22 @@ struct TRINITY_DLL_DECL boss_lady_malandeAI : public boss_illidari_councilAI
         DivineWrathTimer = 40000;
         ReflectiveShieldTimer = 0;
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(SAY_MALA_SLAY, m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_MALA_DEATH, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (EmpoweredSmiteTimer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -579,11 +682,13 @@ struct TRINITY_DLL_DECL boss_lady_malandeAI : public boss_illidari_councilAI
                 EmpoweredSmiteTimer = 38000;
             }
         }else EmpoweredSmiteTimer -= diff;
+
         if (CircleOfHealingTimer < diff)
         {
             DoCast(m_creature, SPELL_CIRCLE_OF_HEALING);
             CircleOfHealingTimer = 60000;
         }else CircleOfHealingTimer -= diff;
+
         if (DivineWrathTimer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -592,44 +697,57 @@ struct TRINITY_DLL_DECL boss_lady_malandeAI : public boss_illidari_councilAI
                 DivineWrathTimer = 40000 + rand()%41 * 1000;
             }
         }else DivineWrathTimer -= diff;
+
         if (ReflectiveShieldTimer < diff)
         {
             DoCast(m_creature, SPELL_REFLECTIVE_SHIELD);
             ReflectiveShieldTimer = 65000;
         }else ReflectiveShieldTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_veras_darkshadowAI : public boss_illidari_councilAI
 {
     boss_veras_darkshadowAI(Creature *c) : boss_illidari_councilAI(c) {}
+
     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)
     {
         DoScriptText(SAY_VERA_SLAY, m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_VERA_DEATH, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (!HasVanished)
         {
             if (DeadlyPoisonTimer < diff)
@@ -637,11 +755,13 @@ struct TRINITY_DLL_DECL boss_veras_darkshadowAI : public boss_illidari_councilAI
                 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))
@@ -657,6 +777,7 @@ struct TRINITY_DLL_DECL boss_veras_darkshadowAI : public boss_illidari_councilAI
                     m_creature->GetMotionMaster()->MoveChase(target);
                 }
             }else VanishTimer -= diff;
+
             DoMeleeAttackIfReady();
         }
         else
@@ -673,6 +794,7 @@ struct TRINITY_DLL_DECL boss_veras_darkshadowAI : public boss_illidari_councilAI
                 AppearEnvenomTimer = 4000;
                 HasVanished = false;
             }else VanishTimer -= diff;
+
             if (AppearEnvenomTimer < diff)                   // Appear 2 seconds before becoming attackable (Shifting out of vanish)
             {
                 m_creature->GetMotionMaster()->Clear();
@@ -683,53 +805,66 @@ struct TRINITY_DLL_DECL boss_veras_darkshadowAI : public boss_illidari_councilAI
         }
     }
 };
+
 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* pCreature)
 {
     return new mob_illidari_councilAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_gathios_the_shatterer(Creature* pCreature)
 {
     return new boss_gathios_the_shattererAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_lady_malande(Creature* pCreature)
 {
     return new boss_lady_malandeAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_veras_darkshadow(Creature* pCreature)
 {
     return new boss_veras_darkshadowAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_high_nethermancer_zerevor(Creature* pCreature)
 {
     return new boss_high_nethermancer_zerevorAI (pCreature);
 }
+
 void AddSC_boss_illidari_council()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_illidari_council";
     newscript->GetAI = &GetAI_mob_illidari_council;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_blood_elf_council_voice_trigger";
     newscript->GetAI = &GetAI_mob_blood_elf_council_voice_trigger;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_gathios_the_shatterer";
     newscript->GetAI = &GetAI_boss_gathios_the_shatterer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_lady_malande";
     newscript->GetAI = &GetAI_boss_lady_malande;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_veras_darkshadow";
     newscript->GetAI = &GetAI_boss_veras_darkshadow;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_high_nethermancer_zerevor";
     newscript->GetAI = &GetAI_boss_high_nethermancer_zerevor;
diff --git a/src/bindings/scripts/scripts/outland/black_temple/instance_black_temple.cpp b/src/bindings/scripts/scripts/outland/black_temple/instance_black_temple.cpp
index 0d49c7970a7..cd67af9a8f3 100644
--- a/src/bindings/scripts/scripts/outland/black_temple/instance_black_temple.cpp
+++ b/src/bindings/scripts/scripts/outland/black_temple/instance_black_temple.cpp
@@ -13,15 +13,19 @@
 * along 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 MAX_ENCOUNTER      9
+
 /* Black Temple encounters:
 0 - High Warlord Naj'entus event
 1 - Supremus Event
@@ -33,11 +37,14 @@ EndScriptData */
 7 - Illidari Council Event
 8 - Illidan Stormrage Event
 */
+
 struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
 {
     instance_black_temple(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     std::string str_data;
+
     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.
@@ -50,6 +57,7 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
     uint64 IllidariCouncil;
     uint64 BloodElfCouncilVoice;
     uint64 IllidanStormrage;
+
     uint64 NajentusGate;
     uint64 MainTempleDoors;
     uint64 ShadeOfAkamaDoor;
@@ -62,9 +70,11 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
     uint64 SimpleDoor;//council
     uint64 IllidanGate;
     uint64 IllidanDoor[2];
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         Najentus = 0;
         Akama = 0;
         Akama_Shade = 0;
@@ -77,6 +87,7 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
         IllidariCouncil = 0;
         BloodElfCouncilVoice = 0;
         IllidanStormrage = 0;
+
         NajentusGate    = 0;
         MainTempleDoors = 0;
         ShadeOfAkamaDoor= 0;
@@ -91,26 +102,32 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
         IllidanDoor[0]  = 0;
         IllidanDoor[1]  = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     Player* GetPlayerInMap()
     {
         Map::PlayerList const& players = instance->GetPlayers();
+
         if (!players.isEmpty())
         {
-            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+            for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
             {
                 if (Player* plr = itr->getSource())
                     return plr;
             }
         }
+
         debug_log("TSCR: Instance Black Temple: GetPlayerInMap, but PlayerList is empty!");
         return NULL;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -129,6 +146,7 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
         case 23499:    BloodElfCouncilVoice = pCreature->GetGUID();      break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -157,6 +175,7 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
         case 186262: IllidanDoor[1] = pGo->GetGUID(); break; // Left door at Temple Summit
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -179,8 +198,10 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
         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)
@@ -245,19 +266,24 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
             m_auiEncounter[7] = data; break;
         case DATA_ILLIDANSTORMRAGEEVENT:      m_auiEncounter[8] = data;         break;
         }
+
         if (data == DONE)
         {
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
             saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " "
                 << m_auiEncounter[2] << " " << m_auiEncounter[3] << " " << m_auiEncounter[4]
             << " " << m_auiEncounter[5] << " " << m_auiEncounter[6] << " " << m_auiEncounter[7]
             << " " << m_auiEncounter[8];
+
             str_data = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -272,12 +298,15 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
         case DATA_ILLIDARICOUNCILEVENT:             return m_auiEncounter[7];
         case DATA_ILLIDANSTORMRAGEEVENT:            return m_auiEncounter[8];
         }
+
         return 0;
     }
+
    std::string GetSaveData()
     {
         return str_data;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -285,21 +314,27 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         std::istringstream loadStream(in);
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2]
         >> m_auiEncounter[3] >> m_auiEncounter[4] >> m_auiEncounter[5] >> m_auiEncounter[6]
         >> m_auiEncounter[7] >> m_auiEncounter[8];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)
                 m_auiEncounter[i] = NOT_STARTED;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_black_temple(Map* pMap)
 {
     return new instance_black_temple(pMap);
 }
+
 void AddSC_instance_black_temple()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/blades_edge_mountains.cpp b/src/bindings/scripts/scripts/outland/blades_edge_mountains.cpp
index 4ee593cf194..4c8d148d565 100644
--- a/src/bindings/scripts/scripts/outland/blades_edge_mountains.cpp
+++ b/src/bindings/scripts/scripts/outland/blades_edge_mountains.cpp
@@ -13,12 +13,14 @@
  * along 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, 10821, 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
@@ -27,26 +29,34 @@ npc_overseer_nuaar
 npc_saikkal_the_elder
 go_legion_obelisk
 EndContentData */
+
 #include "precompiled.h"
+
 //Support for quest: You're Fired! (10821)
 bool     obelisk_one, obelisk_two, obelisk_three, obelisk_four, obelisk_five;
+
 #define LEGION_OBELISK_ONE           185193
 #define LEGION_OBELISK_TWO           185195
 #define LEGION_OBELISK_THREE         185196
 #define LEGION_OBELISK_FOUR          185197
 #define LEGION_OBELISK_FIVE          185198
+
 /*######
 ## mobs_bladespire_ogre
 ######*/
+
 //TODO: add support for quest 10512 + Creature abilities
 struct TRINITY_DLL_DECL mobs_bladespire_ogreAI : public ScriptedAI
 {
     mobs_bladespire_ogreAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() { }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -54,9 +64,11 @@ CreatureAI* GetAI_mobs_bladespire_ogre(Creature* pCreature)
 {
     return new mobs_bladespire_ogreAI (pCreature);
 }
+
 /*######
 ## mobs_nether_drake
 ######*/
+
 enum eNetherdrake
 {
     SAY_NIHIL_1                 = -1000396, //signed for 5955
@@ -64,46 +76,59 @@ enum eNetherdrake
     SAY_NIHIL_3                 = -1000398, //signed for 5955
     SAY_NIHIL_4                 = -1000399, //signed for 20021, used by 20021,21817,21820,21821,21823
     SAY_NIHIL_INTERRUPT         = -1000400, //signed for 20021, used by 20021,21817,21820,21821,21823
+
     ENTRY_WHELP                 = 20021,
     ENTRY_PROTO                 = 21821,
     ENTRY_ADOLE                 = 21817,
     ENTRY_MATUR                 = 21820,
     ENTRY_NIHIL                 = 21823,
+
     SPELL_T_PHASE_MODULATOR     = 37573,
+
     SPELL_ARCANE_BLAST          = 38881,
     SPELL_MANA_BURN             = 38884,
     SPELL_INTANGIBLE_PRESENCE   = 36513
 };
+
 struct TRINITY_DLL_DECL mobs_nether_drakeAI : public ScriptedAI
 {
     mobs_nether_drakeAI(Creature *c) : ScriptedAI(c) {}
+
     bool IsNihil;
     uint32 NihilSpeech_Timer;
     uint32 NihilSpeech_Phase;
+
     uint32 ArcaneBlast_Timer;
     uint32 ManaBurn_Timer;
     uint32 IntangiblePresence_Timer;
+
     void Reset()
     {
         IsNihil = false;
         NihilSpeech_Timer = 3000;
         NihilSpeech_Phase = 0;
+
         ArcaneBlast_Timer = 7500;
         ManaBurn_Timer = 10000;
         IntangiblePresence_Timer = 15000;
     }
+
     void EnterCombat(Unit* who) { }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     //in case Creature was not summoned (not expected)
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
             return;
+
         if (id == 0)
         {
             m_creature->setDeathState(JUST_DIED);
@@ -111,14 +136,17 @@ struct TRINITY_DLL_DECL mobs_nether_drakeAI : public ScriptedAI
             m_creature->SetHealth(0);
         }
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_T_PHASE_MODULATOR && caster->GetTypeId() == TYPEID_PLAYER)
         {
             const uint32 entry_list[4] = {ENTRY_PROTO, ENTRY_ADOLE, ENTRY_MATUR, ENTRY_NIHIL};
             int cid = rand()%(4-1);
+
             if (entry_list[cid] == m_creature->GetEntry())
                 ++cid;
+
             //we are nihil, so say before transform
             if (m_creature->GetEntry() == ENTRY_NIHIL)
             {
@@ -126,6 +154,7 @@ struct TRINITY_DLL_DECL mobs_nether_drakeAI : public ScriptedAI
                 m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                 IsNihil = false;
             }
+
             if (m_creature->UpdateEntry(entry_list[cid]))
             {
                 if (entry_list[cid] == ENTRY_NIHIL)
@@ -138,6 +167,7 @@ struct TRINITY_DLL_DECL mobs_nether_drakeAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IsNihil)
@@ -171,16 +201,20 @@ struct TRINITY_DLL_DECL mobs_nether_drakeAI : public ScriptedAI
                 }
                 NihilSpeech_Timer = 5000;
             }else NihilSpeech_Timer -=diff;
+
             //anything below here is not interesting for Nihil, so skip it
             return;
         }
+
         if (!UpdateVictim())
             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();
@@ -188,31 +222,40 @@ struct TRINITY_DLL_DECL mobs_nether_drakeAI : public ScriptedAI
                 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* pCreature)
 {
     return new mobs_nether_drakeAI (pCreature);
 }
+
 /*######
 ## npc_daranelle
 ######*/
+
 enum eDaranelle
 {
     SAY_SPELL_INFLUENCE     = -1000174,
     SPELL_LASHHAN_CHANNEL   = 36904
 };
+
 struct TRINITY_DLL_DECL npc_daranelleAI : public ScriptedAI
 {
     npc_daranelleAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() { }
+
     void EnterCombat(Unit* who) { }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (who->GetTypeId() == TYPEID_PLAYER)
@@ -224,24 +267,32 @@ struct TRINITY_DLL_DECL npc_daranelleAI : public ScriptedAI
                 m_creature->CastSpell(who,37028,true);
             }
         }
+
         ScriptedAI::MoveInLineOfSight(who);
     }
 };
+
 CreatureAI* GetAI_npc_daranelle(Creature* pCreature)
 {
     return new npc_daranelleAI (pCreature);
 }
+
 /*######
 ## npc_overseer_nuaar
 ######*/
+
 #define GOSSIP_HELLO_ON "Overseer, I am here to negotiate on behalf of the Cenarion Expedition."
+
 bool GossipHello_npc_overseer_nuaar(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(10682) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_ON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(10532, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_overseer_nuaar(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -251,18 +302,24 @@ bool GossipSelect_npc_overseer_nuaar(Player* pPlayer, Creature* pCreature, uint3
     }
     return true;
 }
+
 /*######
 ## npc_saikkal_the_elder
 ######*/
+
 #define GOSSIP_HELLO_STE    "Yes... yes, it's me."
 #define GOSSIP_SELECT_STE   "Yes elder. Tell me more of the book."
+
 bool GossipHello_npc_saikkal_the_elder(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(10980) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_STE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(10794, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_saikkal_the_elder(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -278,9 +335,11 @@ bool GossipSelect_npc_saikkal_the_elder(Player* pPlayer, Creature* pCreature, ui
     }
     return true;
 }
+
 /*######
 ## go_legion_obelisk
 ######*/
+
 bool GOHello_go_legion_obelisk(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->GetQuestStatus(10821) == QUEST_STATUS_INCOMPLETE)
@@ -303,6 +362,7 @@ bool GOHello_go_legion_obelisk(Player* pPlayer, GameObject* pGo)
                   obelisk_five = true;
                  break;
         }
+
         if (obelisk_one == true && obelisk_two == true && obelisk_three == true && obelisk_four == true && obelisk_five == true)
         {
             pGo->SummonCreature(19963,2943.40f,4778.20f,284.49f,0.94f,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000);
@@ -314,36 +374,45 @@ bool GOHello_go_legion_obelisk(Player* pPlayer, GameObject* pGo)
             obelisk_five = false;
         }
     }
+
     return true;
 }
+
 /*######
 ## AddSC
 ######*/
+
 void AddSC_blades_edge_mountains()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mobs_bladespire_ogre";
     newscript->GetAI = &GetAI_mobs_bladespire_ogre;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mobs_nether_drake";
     newscript->GetAI = &GetAI_mobs_nether_drake;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_daranelle";
     newscript->GetAI = &GetAI_npc_daranelle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_overseer_nuaar";
     newscript->pGossipHello = &GossipHello_npc_overseer_nuaar;
     newscript->pGossipSelect = &GossipSelect_npc_overseer_nuaar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_saikkal_the_elder";
     newscript->pGossipHello = &GossipHello_npc_saikkal_the_elder;
     newscript->pGossipSelect = &GossipSelect_npc_saikkal_the_elder;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_legion_obelisk";
     newscript->pGOHello =           &GOHello_go_legion_obelisk;
diff --git a/src/bindings/scripts/scripts/outland/boss_doomlord_kazzak.cpp b/src/bindings/scripts/scripts/outland/boss_doomlord_kazzak.cpp
index e9edad38db4..902c3e347b5 100644
--- a/src/bindings/scripts/scripts/outland/boss_doomlord_kazzak.cpp
+++ b/src/bindings/scripts/scripts/outland/boss_doomlord_kazzak.cpp
@@ -13,13 +13,16 @@
  * along with 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 SAY_INTRO                       -1000375 //signed for 3465
 #define SAY_AGGRO1                      -1000376 //signed for 3465
 #define SAY_AGGRO2                      -1000377 //signed for 3465
@@ -32,6 +35,7 @@ EndScriptData */
 #define EMOTE_FRENZY                    -1000384 //signed for 21027
 #define SAY_RAND1                       -1000385 //signed for 21027
 #define SAY_RAND2                       -1000386 //signed for 21027
+
 #define SPELL_SHADOWVOLLEY              32963
 #define SPELL_CLEAVE                    31779
 #define SPELL_THUNDERCLAP               36706
@@ -40,9 +44,11 @@ EndScriptData */
 #define SPELL_ENRAGE                    32964
 #define SPELL_CAPTURESOUL               32966
 #define SPELL_TWISTEDREFLECTION         21063
+
 struct TRINITY_DLL_DECL boss_doomlordkazzakAI : public ScriptedAI
 {
     boss_doomlordkazzakAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ShadowVolley_Timer;
     uint32 Cleave_Timer;
     uint32 ThunderClap_Timer;
@@ -50,6 +56,7 @@ struct TRINITY_DLL_DECL boss_doomlordkazzakAI : public ScriptedAI
     uint32 MarkOfKazzak_Timer;
     uint32 Enrage_Timer;
     uint32 Twisted_Reflection_Timer;
+
     void Reset()
     {
         ShadowVolley_Timer = 6000 + rand()%4000;
@@ -60,55 +67,67 @@ struct TRINITY_DLL_DECL boss_doomlordkazzakAI : public ScriptedAI
         Enrage_Timer = 60000;
         Twisted_Reflection_Timer = 33000;                   // Timer may be incorrect
     }
+
     void JustRespawned()
     {
         DoScriptText(SAY_INTRO, m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2), m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         // When Kazzak kills a player (not pets/totems), he regens some health
          if (victim->GetTypeId() != TYPEID_PLAYER)
              return;
+
             DoCast(m_creature,SPELL_CAPTURESOUL);
+
             DoScriptText(RAND(SAY_KILL1,SAY_KILL2,SAY_KILL3), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
@@ -119,6 +138,7 @@ struct TRINITY_DLL_DECL boss_doomlordkazzakAI : public ScriptedAI
                 MarkOfKazzak_Timer = 20000;
             }
         }else MarkOfKazzak_Timer -= diff;
+
         //Enrage_Timer
         if (Enrage_Timer < diff)
         {
@@ -126,18 +146,23 @@ struct TRINITY_DLL_DECL boss_doomlordkazzakAI : public ScriptedAI
             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* pCreature)
 {
     return new boss_doomlordkazzakAI (pCreature);
 }
+
 void AddSC_boss_doomlordkazzak()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/boss_doomwalker.cpp b/src/bindings/scripts/scripts/outland/boss_doomwalker.cpp
index af01d09454a..4eba3e1e38d 100644
--- a/src/bindings/scripts/scripts/outland/boss_doomwalker.cpp
+++ b/src/bindings/scripts/scripts/outland/boss_doomwalker.cpp
@@ -13,13 +13,16 @@
 * along with 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"
+
 #define SAY_AGGRO                   -1000387 //signed for 21027
 #define SAY_EARTHQUAKE_1            -1000388 //signed for 21027
 #define SAY_EARTHQUAKE_2            -1000389 //signed for 21027
@@ -29,6 +32,7 @@ EndScriptData */
 #define SAY_SLAY_2                  -1000393 //signed for 5955
 #define SAY_SLAY_3                  -1000394 //signed for 5955
 #define SAY_DEATH                   -1000395 //signed for 5955
+
 #define SPELL_EARTHQUAKE            32686
 #define SPELL_SUNDER_ARMOR          33661
 #define SPELL_CHAIN_LIGHTNING       33665
@@ -36,15 +40,19 @@ EndScriptData */
 #define SPELL_ENRAGE                33653
 #define SPELL_MARK_DEATH            37128
 #define SPELL_AURA_DEATH            37131
+
 struct TRINITY_DLL_DECL boss_doomwalkerAI : public ScriptedAI
 {
     boss_doomwalkerAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Chain_Timer;
     uint32 Enrage_Timer;
     uint32 Overrun_Timer;
     uint32 Quake_Timer;
     uint32 Armor_Timer;
+
     bool InEnrage;
+
     void Reset()
     {
         Enrage_Timer    = 0;
@@ -52,23 +60,30 @@ struct TRINITY_DLL_DECL boss_doomwalkerAI : public ScriptedAI
         Chain_Timer     = 10000 + rand()%20000;
         Quake_Timer     = 25000 + rand()%10000;
         Overrun_Timer   = 30000 + rand()%15000;
+
         InEnrage = false;
     }
+
     void KilledUnit(Unit* Victim)
     {
         Victim->CastSpell(Victim,SPELL_MARK_DEATH,0);
+
         if (rand()%5)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (who && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsHostileTo(who))
@@ -79,10 +94,12 @@ struct TRINITY_DLL_DECL boss_doomwalkerAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //Spell Enrage, when hp <= 20% gain enrage
         if (((m_creature->GetHealth()*100)/ m_creature->GetMaxHealth()) <= 20)
         {
@@ -93,49 +110,63 @@ struct TRINITY_DLL_DECL boss_doomwalkerAI : public ScriptedAI
                 InEnrage = true;
             }else Enrage_Timer -= diff;
         }
+
         //Spell Overrun
         if (Overrun_Timer < diff)
         {
             DoScriptText(RAND(SAY_OVERRUN_1,SAY_OVERRUN_2), m_creature);
+
             DoCast(m_creature->getVictim(),SPELL_OVERRUN);
             Overrun_Timer = 25000 + rand()%15000;
         }else Overrun_Timer -= diff;
+
         //Spell Earthquake
         if (Quake_Timer < diff)
         {
             if (rand()%2)
                 return;
+
             DoScriptText(RAND(SAY_EARTHQUAKE_1,SAY_EARTHQUAKE_2), m_creature);
+
             //remove enrage before casting earthquake because enrage + earthquake = 16000dmg over 8sec and all dead
             if (InEnrage)
                 m_creature->RemoveAura(SPELL_ENRAGE);
+
             DoCast(m_creature,SPELL_EARTHQUAKE);
             Quake_Timer = 30000 + rand()%25000;
         }else Quake_Timer -= diff;
+
         //Spell Chain Lightning
         if (Chain_Timer < diff)
         {
             Unit* target = NULL;
             target = SelectUnit(SELECT_TARGET_RANDOM,1);
+
             if (!target)
                 target = m_creature->getVictim();
+
             if (target)
                 DoCast(target,SPELL_CHAIN_LIGHTNING);
+
             Chain_Timer = 7000 + rand()%20000;
         }else Chain_Timer -= diff;
+
         //Spell Sunder Armor
         if (Armor_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_SUNDER_ARMOR);
             Armor_Timer = 10000 + rand()%15000;
         }else Armor_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_doomwalker(Creature* pCreature)
 {
     return new boss_doomwalkerAI (pCreature);
 }
+
 void AddSC_boss_doomwalker()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp
index fa9e079f8e4..7b25584cf64 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp
@@ -13,15 +13,18 @@
  * along with 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: 70
 SDComment: Cyclone workaround
 SDCategory: Coilfang Resevoir, Serpent Shrine Cavern
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_serpent_shrine.h"
 #include "escort_ai.h"
+
 #define SAY_AGGRO                   -1548021
 #define SAY_GAIN_BLESSING           -1548022
 #define SAY_GAIN_ABILITY1           -1548023
@@ -31,6 +34,7 @@ EndScriptData */
 #define SAY_SLAY2                   -1548027
 #define SAY_SLAY3                   -1548028
 #define SAY_DEATH                   -1548029
+
 //Karathress spells
 #define SPELL_CATACLYSMIC_BOLT          38441
 #define SPELL_POWER_OF_SHARKKIS         38455
@@ -39,6 +43,7 @@ EndScriptData */
 #define SPELL_ENRAGE                    24318
 #define SPELL_SEAR_NOVA                 38445
 #define SPELL_BLESSING_OF_THE_TIDES     38449
+
 //Sharkkis spells
 #define SPELL_LEECHING_THROW            29436
 #define SPELL_THE_BEAST_WITHIN          38373
@@ -46,6 +51,7 @@ EndScriptData */
 #define SPELL_SUMMON_FATHOM_LURKER      38433
 #define SPELL_SUMMON_FATHOM_SPOREBAT    38431
 #define SPELL_PET_ENRAGE                19574
+
 //Tidalvess spells
 #define SPELL_FROST_SHOCK               38234
 #define SPELL_SPITFIRE_TOTEM            38236
@@ -55,6 +61,7 @@ EndScriptData */
 #define SPELL_EARTHBIND_TOTEM           38304
 #define SPELL_EARTHBIND_TOTEM_EFFECT    6474
 #define SPELL_WINDFURY_WEAPON           38184
+
 //Caribdis Spells
 #define SPELL_WATER_BOLT_VOLLEY         38335
 #define SPELL_TIDAL_SURGE               38358
@@ -62,11 +69,13 @@ EndScriptData */
 #define SPELL_HEAL                      38330
 #define SPELL_SUMMON_CYCLONE            38337
 #define SPELL_CYCLONE_CYCLONE           29538
+
 //Yells and Quotes
 #define SAY_GAIN_BLESSING_OF_TIDES      "Your overconfidence will be your undoing! Guards, lend me your strength!"
 #define SOUND_GAIN_BLESSING_OF_TIDES    11278
 #define SAY_MISC                        "Alana be'lendor!" //don't know what use this
 #define SOUND_MISC                      11283
+
 //Summoned Unit GUIDs
 #define CREATURE_CYCLONE                22104
 #define CREATURE_FATHOM_SPOREBAT        22120
@@ -74,12 +83,14 @@ EndScriptData */
 #define CREATURE_SPITFIRE_TOTEM         22091
 #define CREATURE_EARTHBIND_TOTEM        22486
 #define CREATURE_POISON_CLEANSING_TOTEM 22487
+
 //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 TRINITY_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI
 {
@@ -90,19 +101,27 @@ struct TRINITY_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI
         Advisors[1] = 0;
         Advisors[2] = 0;
     }
+
     ScriptedInstance* pInstance;
+
     uint32 CataclysmicBolt_Timer;
     uint32 Enrage_Timer;
     uint32 SearNova_Timer;
+
     bool BlessingOfTides;
+
     uint64 Advisors[3];
+
     void Reset()
     {
         CataclysmicBolt_Timer = 10000;
         Enrage_Timer = 600000;                              //10 minutes
         SearNova_Timer = 20000+rand()%40000; // 20 - 60 seconds
+
         BlessingOfTides = false;
 
+
+
         if (pInstance)
         {
             uint64 RAdvisors[3];
@@ -111,7 +130,8 @@ struct TRINITY_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI
             RAdvisors[2] = pInstance->GetData64(DATA_CARIBDIS);
             //Respawn of the 3 Advisors
             Creature* pAdvisor = NULL;
-            for (int i=0; i<3; ++i)
+            for(int i=0; i<3; ++i)
+
             if (RAdvisors[i])
             {
                 pAdvisor = (Unit::GetCreature((*m_creature), RAdvisors[i]));
@@ -125,108 +145,133 @@ struct TRINITY_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI
             pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
         }
 
+
     }
+
     void EventSharkkisDeath()
     {
         DoScriptText(SAY_GAIN_ABILITY1, m_creature);
         DoCast(m_creature, SPELL_POWER_OF_SHARKKIS);
     }
+
     void EventTidalvessDeath()
     {
         DoScriptText(SAY_GAIN_ABILITY2, m_creature);
         DoCast(m_creature, SPELL_POWER_OF_TIDALVESS);
     }
+
     void EventCaribdisDeath()
     {
         DoScriptText(SAY_GAIN_ABILITY3, m_creature);
         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();
+
         DoScriptText(SAY_AGGRO, m_creature);
         DoZoneInCombat();
+
         pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID());
         pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit *killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_FATHOMLORDKARATHRESSEVENT, DONE);
+
         //support for quest 10944
         m_creature->SummonCreature(SEER_OLUM, OLUM_X, OLUM_Y, OLUM_Z, OLUM_O, TEMPSUMMON_TIMED_DESPAWN, 3600000);
     }
+
     void EnterCombat(Unit *who)
     {
         StartEvent(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER));
+
             if (target)
             {
                 AttackStart(target);
                 GetAdvisors();
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         //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();
+
             if (target)
                 DoCast(target, SPELL_CATACLYSMIC_BOLT);
             CataclysmicBolt_Timer = 10000;
         }else CataclysmicBolt_Timer -= diff;
+
         //SearNova_Timer
         if (SearNova_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SEAR_NOVA);
             SearNova_Timer = 20000+rand()%40000;
         }else SearNova_Timer -= diff;
+
         //Enrage_Timer
         if (Enrage_Timer < diff)
         {
             DoCast(m_creature, SPELL_ENRAGE);
             Enrage_Timer = 90000;
         }else Enrage_Timer -= diff;
+
         //Blessing of Tides Trigger
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 75 && !BlessingOfTides)
         {
             BlessingOfTides = true;
             bool continueTriggering;
             Creature* Advisor;
-            for (uint8 i = 0; i < 4; ++i)
+            for(uint8 i = 0; i < 4; ++i)
                 if (Advisors[i])
                 {
                     Advisor = (Unit::GetCreature(*m_creature, Advisors[i]));
@@ -246,9 +291,11 @@ struct TRINITY_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI
                     DoPlaySoundToSet(m_creature, SOUND_GAIN_BLESSING_OF_TIDES);
                 }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Fathom-Guard Sharkkis AI
 struct TRINITY_DLL_DECL boss_fathomguard_sharkkisAI : public ScriptedAI
 {
@@ -256,41 +303,53 @@ struct TRINITY_DLL_DECL boss_fathomguard_sharkkisAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 LeechingThrow_Timer;
     uint32 TheBeastWithin_Timer;
     uint32 Multishot_Timer;
     uint32 Pet_Timer;
+
     bool pet;
+
     uint64 SummonedPet;
 
+
     void Reset()
     {
         LeechingThrow_Timer = 20000;
         TheBeastWithin_Timer = 30000;
         Multishot_Timer = 15000;
         Pet_Timer = 10000;
+
         pet = false;
+
         Creature *Pet = Unit::GetCreature(*m_creature, SummonedPet);
         if (Pet && Pet->isAlive())
         {
             Pet->DealDamage(Pet, Pet->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         }
+
         SummonedPet = 0;
+
         if (pInstance)
             pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
         {
             Creature *Karathress = NULL;
             Karathress = (Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_KARATHRESS)));
+
             if (Karathress)
                 CAST_AI(boss_fathomlord_karathressAI, Karathress->AI())->EventSharkkisDeath();
                     CAST_AI(boss_fathomlord_karathressAI, Karathress->AI())->EventSharkkisDeath();
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -299,38 +358,45 @@ struct TRINITY_DLL_DECL boss_fathomguard_sharkkisAI : public ScriptedAI
             pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER));
+
             if (target)
             {
                 AttackStart(target);
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         //LeechingThrow_Timer
         if (LeechingThrow_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_LEECHING_THROW);
             LeechingThrow_Timer = 20000;
         }else LeechingThrow_Timer -= diff;
+
         //Multishot_Timer
         if (Multishot_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_MULTISHOT);
             Multishot_Timer = 20000;
         }else Multishot_Timer -= diff;
+
         //TheBeastWithin_Timer
         if (TheBeastWithin_Timer < diff)
         {
@@ -342,6 +408,7 @@ struct TRINITY_DLL_DECL boss_fathomguard_sharkkisAI : public ScriptedAI
             }
             TheBeastWithin_Timer = 30000;
         }else TheBeastWithin_Timer -= diff;
+
         //Pet_Timer
         if (Pet_Timer < diff && pet == false)
         {
@@ -368,9 +435,11 @@ struct TRINITY_DLL_DECL boss_fathomguard_sharkkisAI : public ScriptedAI
                 SummonedPet = Pet->GetGUID();
             }
         }else Pet_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Fathom-Guard Tidalvess AI
 struct TRINITY_DLL_DECL boss_fathomguard_tidalvessAI : public ScriptedAI
 {
@@ -378,31 +447,38 @@ struct TRINITY_DLL_DECL boss_fathomguard_tidalvessAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 FrostShock_Timer;
     uint32 Spitfire_Timer;
     uint32 PoisonCleansing_Timer;
     uint32 Earthbind_Timer;
+
     void Reset()
     {
         FrostShock_Timer = 25000;
         Spitfire_Timer = 60000;
         PoisonCleansing_Timer = 30000;
         Earthbind_Timer = 45000;
+
         if (pInstance)
             pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
         {
             Creature *Karathress = NULL;
             Karathress = (Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_KARATHRESS)));
+
             if (Karathress)
                 if (!m_creature->isAlive() && Karathress)
                     CAST_AI(boss_fathomlord_karathressAI, Karathress->AI())->EventTidalvessDeath();
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -412,36 +488,43 @@ struct TRINITY_DLL_DECL boss_fathomguard_tidalvessAI : public ScriptedAI
         }
         DoCast(m_creature, SPELL_WINDFURY_WEAPON);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER));
+
             if (target)
             {
                 AttackStart(target);
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         if (!m_creature->HasAura(SPELL_WINDFURY_WEAPON))
         {
             DoCast(m_creature, SPELL_WINDFURY_WEAPON);
         }
+
         //FrostShock_Timer
         if (FrostShock_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_FROST_SHOCK);
             FrostShock_Timer = 25000+rand()%5000;
         }else FrostShock_Timer -= diff;
+
         //Spitfire_Timer
         if (Spitfire_Timer < diff)
         {
@@ -453,21 +536,25 @@ struct TRINITY_DLL_DECL boss_fathomguard_tidalvessAI : public ScriptedAI
             }
             Spitfire_Timer = 60000;
         }else Spitfire_Timer -= diff;
+
         //PoisonCleansing_Timer
         if (PoisonCleansing_Timer < diff)
         {
             DoCast(m_creature, SPELL_POISON_CLEANSING_TOTEM);
             PoisonCleansing_Timer = 30000;
         }else PoisonCleansing_Timer -= diff;
+
         //Earthbind_Timer
         if (Earthbind_Timer < diff)
         {
             DoCast(m_creature, SPELL_EARTHBIND_TOTEM);
             Earthbind_Timer = 45000;
         }else Earthbind_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Fathom-Guard Caribdis AI
 struct TRINITY_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI
 {
@@ -475,31 +562,38 @@ struct TRINITY_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 WaterBoltVolley_Timer;
     uint32 TidalSurge_Timer;
     uint32 Heal_Timer;
     uint32 Cyclone_Timer;
+
     void Reset()
     {
         WaterBoltVolley_Timer = 35000;
         TidalSurge_Timer = 15000+rand()%5000;
         Heal_Timer = 55000;
         Cyclone_Timer = 30000+rand()%10000;
+
         if (pInstance)
             pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
         {
             Creature *Karathress = NULL;
             Karathress = (Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_KARATHRESS)));
+
             if (Karathress)
                 if (!m_creature->isAlive() && Karathress)
                     CAST_AI(boss_fathomlord_karathressAI, Karathress->AI())->EventCaribdisDeath();
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -508,32 +602,38 @@ struct TRINITY_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI
             pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER));
+
             if (target)
             {
                 AttackStart(target);
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         //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)
         {
@@ -542,6 +642,7 @@ struct TRINITY_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI
             m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_TIDAL_SURGE_FREEZE, true);
             TidalSurge_Timer = 15000+rand()%5000;
         }else TidalSurge_Timer -= diff;
+
         //Cyclone_Timer
         if (Cyclone_Timer < diff)
         {
@@ -561,21 +662,26 @@ struct TRINITY_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI
                 }
             }
         }else Cyclone_Timer -= diff;
+
         //Heal_Timer
         if (Heal_Timer < diff)
         {
             // It can be cast on any of the mobs
             Unit *pUnit = NULL;
+
             while(pUnit == NULL || !pUnit->isAlive())
             {
                 pUnit = selectAdvisorUnit();
             }
+
             if (pUnit && pUnit->isAlive())
                 DoCast(pUnit, SPELL_HEAL);
             Heal_Timer = 60000;
         }else Heal_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
+
     Unit* selectAdvisorUnit()
     {
         Unit* pUnit = NULL;
@@ -597,25 +703,31 @@ struct TRINITY_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI
                 break;
             }
         }else pUnit = m_creature;
+
                 return pUnit;
         }
 };
+
 CreatureAI* GetAI_boss_fathomlord_karathress(Creature* pCreature)
 {
     return new boss_fathomlord_karathressAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_fathomguard_sharkkis(Creature* pCreature)
 {
     return new boss_fathomguard_sharkkisAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_fathomguard_tidalvess(Creature* pCreature)
 {
     return new boss_fathomguard_tidalvessAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_fathomguard_caribdis(Creature* pCreature)
 {
     return new boss_fathomguard_caribdisAI (pCreature);
 }
+
 void AddSC_boss_fathomlord_karathress()
 {
     Script *newscript;
@@ -623,14 +735,17 @@ void AddSC_boss_fathomlord_karathress()
     newscript->Name = "boss_fathomlord_karathress";
     newscript->GetAI = &GetAI_boss_fathomlord_karathress;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_fathomguard_sharkkis";
     newscript->GetAI = &GetAI_boss_fathomguard_sharkkis;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_fathomguard_tidalvess";
     newscript->GetAI = &GetAI_boss_fathomguard_tidalvess;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_fathomguard_caribdis";
     newscript->GetAI = &GetAI_boss_fathomguard_caribdis;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp
index ba02cd9805d..288b8cf917e 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp
@@ -13,14 +13,17 @@
  * along with 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 SAY_AGGRO                   -1548000
 #define SAY_SWITCH_TO_CLEAN         -1548001
 #define SAY_CLEAN_SLAY1             -1548002
@@ -30,9 +33,12 @@ EndScriptData */
 #define SAY_CORRUPT_SLAY1           -1548006
 #define SAY_CORRUPT_SLAY2           -1548007
 #define SAY_CORRUPT_DEATH           -1548008
+
 #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
@@ -51,11 +57,14 @@ EndScriptData */
 #define SPELL_SUMMON_WATER_ELEMENT  36459                   //not in use yet(in use ever?)
 #define SPELL_ELEMENTAL_SPAWNIN     25035
 #define SPELL_BLUE_BEAM             40227                   //channeled Hydross Beam Helper (not in use yet)
+
 #define ENTRY_PURE_SPAWN            22035
 #define ENTRY_TAINTED_SPAWN         22036
 #define ENTRY_BEAM_DUMMY            21934
+
 #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
@@ -64,13 +73,16 @@ EndScriptData */
 #define SPAWN_Y_DIFF3               -4.72702
 #define SPAWN_X_DIFF4               12.577011
 #define SPAWN_Y_DIFF4               4.72702
+
 struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
 {
     boss_hydross_the_unstableAI(Creature *c) : ScriptedAI(c), Summons(m_creature)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint64 beams[2];
     uint32 PosCheck_Timer;
     uint32 MarkOfHydross_Timer;
@@ -83,6 +95,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
     bool CorruptedForm;
     bool beam;
     SummonList Summons;
+
     void Reset()
     {
         DeSummonBeams();
@@ -96,16 +109,20 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
         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->SetDisplayId(MODEL_CLEAN);
+
         if (pInstance)
             pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, NOT_STARTED);
         beam = false;
         Summons.DespawnAll();
     }
+
     void SummonBeams()
     {
         Creature* beamer = m_creature->SummonCreature(ENTRY_BEAM_DUMMY,-258.333,-356.34,22.0499,5.90835,TEMPSUMMON_CORPSE_DESPAWN,0);
@@ -127,7 +144,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
     }
     void DeSummonBeams()
     {
-        for (uint8 i=0; i<2; ++i)
+        for(uint8 i=0;i<2; ++i)
         {
             Creature* mob = Unit::GetCreature(*m_creature,beams[i]);
             if (mob)
@@ -140,9 +157,11 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (CorruptedForm)
@@ -154,6 +173,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
             DoScriptText(RAND(SAY_CLEAN_SLAY1,SAY_CLEAN_SLAY2), m_creature);
         }
     }
+
     void JustSummoned(Creature* summoned)
     {
         if (summoned->GetEntry() == ENTRY_PURE_SPAWN)
@@ -169,20 +189,24 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
             Summons.Summon(summoned);
         }
     }
+
     void SummonedCreatureDespawn(Creature *summon)
     {
         Summons.Despawn(summon);
     }
+
     void JustDied(Unit *victim)
     {
         if (CorruptedForm)
             DoScriptText(SAY_CORRUPT_DEATH, m_creature);
         else
             DoScriptText(SAY_CLEAN_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, DONE);
         Summons.DespawnAll();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!beam)
@@ -193,6 +217,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         // corrupted form
         if (CorruptedForm)
         {
@@ -202,6 +227,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
                 if (MarkOfCorruption_Count <= 5)
                 {
                     uint32 mark_spell;
+
                     switch(MarkOfCorruption_Count)
                     {
                         case 0: mark_spell = SPELL_MARK_OF_CORRUPTION1; break;
@@ -211,20 +237,26 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
                         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)
             {
@@ -234,18 +266,22 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
                     m_creature->SetDisplayId(MODEL_CLEAN);
                     CorruptedForm = false;
                     MarkOfHydross_Count = 0;
+
                     DoScriptText(SAY_SWITCH_TO_CLEAN, m_creature);
                     DoResetThreat();
                     SummonBeams();
+
                     // spawn 4 adds
                     DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF1, SPAWN_Y_DIFF1, 3, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                     DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF2, SPAWN_Y_DIFF2, 3, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                     DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF3, SPAWN_Y_DIFF3, 3, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                     DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF4, SPAWN_Y_DIFF4, 3, 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;
         }
@@ -258,6 +294,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
                 if (MarkOfHydross_Count <= 5)
                 {
                     uint32 mark_spell;
+
                     switch(MarkOfHydross_Count)
                     {
                         case 0:  mark_spell = SPELL_MARK_OF_HYDROSS1; break;
@@ -267,20 +304,26 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
                         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 = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                 if (target)
                     DoCast(target, SPELL_WATER_TOMB);
+
                 WaterTomb_Timer = 7000;
             }else WaterTomb_Timer -= diff;
+
             //PosCheck_Timer
             if (PosCheck_Timer < diff)
             {
@@ -290,27 +333,33 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
                     m_creature->SetDisplayId(MODEL_CORRUPT);
                     MarkOfCorruption_Count = 0;
                     CorruptedForm = true;
+
                     DoScriptText(SAY_SWITCH_TO_CORRUPT, m_creature);
                     DoResetThreat();
                     DeSummonBeams();
+
                     // spawn 4 adds
                     DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF1, SPAWN_Y_DIFF1, 3, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                     DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF2, SPAWN_Y_DIFF2, 3, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                     DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF3, SPAWN_Y_DIFF3, 3, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                     DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF4, SPAWN_Y_DIFF4, 3, 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();
     }
 };
@@ -318,6 +367,7 @@ CreatureAI* GetAI_boss_hydross_the_unstable(Creature* pCreature)
 {
     return new boss_hydross_the_unstableAI (pCreature);
 }
+
 void AddSC_boss_hydross_the_unstable()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp
index efdc19d1cc5..0ee1a68ee0e 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp
@@ -13,16 +13,19 @@
  * 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 "simple_ai.h"
 #include "Spell.h"
+
 #define SAY_INTRO                   -1548042
 #define SAY_AGGRO1                  -1548043
 #define SAY_AGGRO2                  -1548044
@@ -37,6 +40,7 @@ EndScriptData */
 #define SAY_SLAY2                   -1548053
 #define SAY_SLAY3                   -1548054
 #define SAY_DEATH                   -1548055
+
 #define SPELL_SURGE                 38044
 #define SPELL_MULTI_SHOT            38310
 #define SPELL_SHOCK_BLAST           38509
@@ -47,13 +51,16 @@ EndScriptData */
 #define SPELL_POISON_BOLT           40095
 #define SPELL_TOXIC_SPORES          38575
 #define SPELL_MAGIC_BARRIER         38112
+
 #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
@@ -61,8 +68,10 @@ EndScriptData */
 #define COILFANG_ELITE                22055
 #define TOXIC_SPOREBAT                22140
 #define TOXIC_SPORES_TRIGGER          22207
+
 #define TEXT_NOT_INITIALIZED          "Instance script not initialized"
 #define TEXT_ALREADY_DEACTIVATED      "Already deactivated"
+
 float ElementPos[8][4] =
 {
     {8.3, -835.3, 21.9, 5},
@@ -74,6 +83,7 @@ float ElementPos[8][4] =
     {-35, -987.6, 21.5, 0.8},
     {-58.9, -901.6, 21.5, 6}
 };
+
 float ElementWPPos[8][3] =
 {
     {71.700752, -883.905884, 41.097168},
@@ -85,6 +95,7 @@ float ElementWPPos[8][3] =
     {43.466549, -979.406677, 41.097027},
     {69.945908, -964.663940, 41.097054}
 };
+
 float SporebatWPPos[8][3] =
 {
     {31.6,-896.3,59.1},
@@ -96,18 +107,21 @@ float SporebatWPPos[8][3] =
     {42.2, -912.4, 51.7},
     {27, -905.9, 50}
 };
+
 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},
@@ -115,6 +129,7 @@ float ShieldGeneratorChannelPos[4][4] =
     {10.3859, -944.036, 42.5446, 0.779888},
     {49.3126, -943.398, 42.5501, 2.40174}
 };
+
 //Lady Vashj AI
 struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
 {
@@ -125,8 +140,11 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
         JustCreated = true;
         c->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); //set it only once on Creature create (no need do intro if wiped)
     }
+
     ScriptedInstance *pInstance;
+
     uint64 ShieldGeneratorChannel[4];
+
     uint32 AggroTimer;
     uint32 ShockBlast_Timer;
     uint32 Entangle_Timer;
@@ -141,10 +159,12 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
     uint32 SummonSporebat_StaticTimer;
     uint8 EnchantedElemental_Pos;
     uint8 Phase;
+
     bool Entangle;
     bool Intro;
     bool CanAttack;
     bool JustCreated;
+
     void Reset()
     {
         AggroTimer = 19000;
@@ -161,27 +181,32 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
         SummonSporebat_StaticTimer = 30000;
         EnchantedElemental_Pos = 0;
         Phase = 0;
+
         Entangle = false;
         if (JustCreated)
         {
             CanAttack = false;
             JustCreated = false;
         }else CanAttack = true;
+
         Unit *remo;
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             remo = Unit::GetUnit(*m_creature, ShieldGeneratorChannel[i]);
             if (remo)
                 remo->setDeathState(JUST_DIED);
         }
+
         if (pInstance)
             pInstance->SetData(DATA_LADYVASHJEVENT, NOT_STARTED);
         ShieldGeneratorChannel[0] = 0;
         ShieldGeneratorChannel[1] = 0;
         ShieldGeneratorChannel[2] = 0;
         ShieldGeneratorChannel[3] = 0;
+
         m_creature->SetCorpseDelay(1000*60*60);
     }
+
     //Called when a tainted elemental dies
     void EventTaintedElementalDeath()
     {
@@ -193,19 +218,25 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_LADYVASHJEVENT, DONE);
     }
+
     void StartEvent()
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3,SAY_AGGRO4), m_creature);
+
         Phase = 1;
+
         if (pInstance)
             pInstance->SetData(DATA_LADYVASHJEVENT, IN_PROGRESS);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -213,7 +244,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
             //remove old tainted cores to prevent cheating in phase 2
             Map* pMap = m_creature->GetMap();
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
-            for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+            for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
             {
                 if (Player* i_pl = i->getSource())
                 {
@@ -222,9 +253,11 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
             }
         }
         StartEvent();//this is EnterCombat(), so were are 100% in combat, start the event
+
         if (Phase != 2)
             AttackStart(who);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!Intro)
@@ -236,6 +269,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
             return;
         if (!who || m_creature->getVictim())
             return;
+
         if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(m_creature) && m_creature->IsHostileTo(who))
         {
             float attackRadius = m_creature->GetAttackDistance(who);
@@ -243,13 +277,16 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
             {
                 //if (who->HasStealthAura())
                 //    who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
-                if (!m_creature->isInCombat()) //AttackStart() sets UNIT_FLAG_IN_COMBAT, so this msut be before attacking
+
+                if (!m_creature->isInCombat())//AttackStart() sets UNIT_FLAG_IN_COMBAT, so this msut be before attacking
                     StartEvent();
+
                 if (Phase != 2)
                     AttackStart(who);
             }
         }
     }
+
     void CastShootOrMultishot()
     {
         switch(rand()%2)
@@ -270,6 +307,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
             DoScriptText(RAND(SAY_BOWSHOT1,SAY_BOWSHOT2), m_creature);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!CanAttack && Intro)
@@ -294,6 +332,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (Phase == 1 || Phase == 3)
         {
             //ShockBlast_Timer
@@ -303,8 +342,10 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                 //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)
             {
@@ -312,11 +353,14 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                 //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 = SelectTarget(SELECT_TARGET_RANDOM, 0, 200, true);
+
                 if (target && !target->HasAura(SPELL_STATIC_CHARGE_TRIGGER))
                                                             //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)
             {
@@ -335,6 +379,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                     Entangle_Timer = 20000+rand()%5000;
                 }
             }else Entangle_Timer -= diff;
+
             //Phase 1
             if (Phase == 1)
             {
@@ -343,10 +388,12 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                 {
                     //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->GetMotionMaster()->Clear();
                     DoTeleportTo(MIDDLE_X, MIDDLE_Y, MIDDLE_Z);
+
                     Creature *pCreature;
-                    for (uint8 i = 0; i < 4; ++i)
+                    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)
@@ -363,6 +410,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                 {
                     Creature *Sporebat = NULL;
                     Sporebat = m_creature->SummonCreature(TOXIC_SPOREBAT, SPOREBAT_X, SPOREBAT_Y, SPOREBAT_Z, SPOREBAT_O, TEMPSUMMON_CORPSE_DESPAWN, 0);
+
                     if (Sporebat)
                     {
                         Unit *target = NULL;
@@ -370,23 +418,29 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                         if (target)
                             Sporebat->AI()->AttackStart(target);
                     }
+
                     //summon sporebats faster and faster
                     if (SummonSporebat_StaticTimer > 1000)
                         SummonSporebat_StaticTimer -= 1000;
+
                     SummonSporebat_Timer = SummonSporebat_StaticTimer;
+
                     if (SummonSporebat_Timer < 5000)
                         SummonSporebat_Timer = 5000;
+
                 }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)
+                for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                 {
                     target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                                                             //if in melee range
@@ -396,9 +450,11 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                         break;
                     }
                 }
+
                 //if nobody is in melee range
                 if (!InMeleeRange)
                     CastShootOrMultishot();
+
                 Check_Timer = 5000;
             }else Check_Timer -= diff;
         }
@@ -412,30 +468,39 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                 //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_CORPSE_DESPAWN, 0);
+
                 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_DEAD_DESPAWN, 0);
+
                 TaintedElemental_Timer = 120000;
             }else TaintedElemental_Timer -= diff;
+
             //CoilfangElite_Timer
             if (CoilfangElite_Timer < diff)
             {
@@ -453,6 +518,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                 }
                 CoilfangElite_Timer = 45000+rand()%5000;
             }else CoilfangElite_Timer -= diff;
+
             //CoilfangStrider_Timer
             if (CoilfangStrider_Timer < diff)
             {
@@ -470,6 +536,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                 }
                 CoilfangStrider_Timer = 60000+rand()%10000;
             }else CoilfangStrider_Timer -= diff;
+
             //Check_Timer
             if (Check_Timer < diff)
             {
@@ -478,9 +545,13 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
                 {
                     //set life 50%
                     m_creature->SetHealth(m_creature->GetMaxHealth()/2);
+
                     m_creature->RemoveAurasDueToSpell(SPELL_MAGIC_BARRIER);
+
                     DoScriptText(SAY_PHASE3, m_creature);
+
                     Phase = 3;
+
                     //return to the tank
                     m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                 }
@@ -489,6 +560,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
         }
     }
 };
+
 //Enchanted Elemental
 //If one of them reaches Vashj he will increase her damage done by 5%.
 struct TRINITY_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI
@@ -497,11 +569,13 @@ struct TRINITY_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
     uint32 move;
     uint32 phase;
     float x, y, z;
     Creature *Vashj;
+
     void Reset()
     {
         m_creature->SetSpeed(MOVE_WALK,0.6);//walk
@@ -509,7 +583,8 @@ struct TRINITY_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI
         move = 0;
         phase = 1;
         Vashj = NULL;
-        for (int i = 0; i<8; ++i) //search for nearest waypoint (up on stairs)
+
+        for (int i = 0;i<8; ++i)//search for nearest waypoint (up on stairs)
         {
             if (!x || !y || !z)
             {
@@ -530,16 +605,21 @@ struct TRINITY_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI
         if (pInstance)
             Vashj = Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_LADYVASHJ));
     }
+
     void EnterCombat(Unit *who) { return; }
+
     void MoveInLineOfSight(Unit *who){return;}
+
     void UpdateAI(const uint32 diff)
     {
         if (!pInstance)
             return;
+
         if (!Vashj)
         {
             return;
         }
+
         if (move < diff)
         {
             m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
@@ -581,6 +661,7 @@ struct TRINITY_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI
         } else move -= 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 TRINITY_DLL_DECL mob_tainted_elementalAI : public ScriptedAI
@@ -589,28 +670,35 @@ struct TRINITY_DLL_DECL mob_tainted_elementalAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 PoisonBolt_Timer;
     uint32 Despawn_Timer;
+
     void Reset()
     {
         PoisonBolt_Timer = 5000+rand()%5000;
         Despawn_Timer = 30000;
     }
+
     void JustDied(Unit *killer)
     {
         if (pInstance)
         {
             Creature *Vashj = NULL;
             Vashj = (Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_LADYVASHJ)));
+
             if (Vashj)
                 CAST_AI(boss_lady_vashjAI, Vashj->AI())->EventTaintedElementalDeath();
         }
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->AddThreat(who, 0.1f);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //PoisonBolt_Timer
@@ -618,20 +706,25 @@ struct TRINITY_DLL_DECL mob_tainted_elementalAI : public ScriptedAI
         {
             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;
+
         //Despawn_Timer
         if (Despawn_Timer < diff)
         {
             //call Unsummon()
             m_creature->setDeathState(DEAD);
+
             //to prevent crashes
             Despawn_Timer = 1000;
         }else Despawn_Timer -= diff;
     }
 };
+
 //Toxic 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 TRINITY_DLL_DECL mob_toxic_sporebatAI : public ScriptedAI
@@ -641,11 +734,14 @@ struct TRINITY_DLL_DECL mob_toxic_sporebatAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         EnterEvadeMode();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 movement_timer;
     uint32 ToxicSpore_Timer;
     uint32 bolt_timer;
     uint32 Check_Timer;
+
     void Reset()
     {
         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
@@ -655,19 +751,26 @@ struct TRINITY_DLL_DECL mob_toxic_sporebatAI : public ScriptedAI
         bolt_timer = 5500;
         Check_Timer = 1000;
     }
+
     void EnterCombat(Unit *who)
     {
+
     }
+
     void MoveInLineOfSight(Unit *who)
     {
+
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
             return;
+
         if (id == 1)
             movement_timer = 0;
     }
+
     void UpdateAI (const uint32 diff)
     {
         //Random movement
@@ -677,6 +780,7 @@ struct TRINITY_DLL_DECL mob_toxic_sporebatAI : public ScriptedAI
             m_creature->GetMotionMaster()->MovePoint(1,SporebatWPPos[rndpos][0], SporebatWPPos[rndpos][1], SporebatWPPos[rndpos][2]);
             movement_timer = 6000;
         }else movement_timer -= diff;
+
         //toxic spores
         if (bolt_timer < diff)
         {
@@ -694,6 +798,7 @@ struct TRINITY_DLL_DECL mob_toxic_sporebatAI : public ScriptedAI
             bolt_timer = 10000+rand()%5000;
         }
         else bolt_timer -= diff;
+
         //Check_Timer
         if (Check_Timer < diff)
         {
@@ -710,45 +815,57 @@ struct TRINITY_DLL_DECL mob_toxic_sporebatAI : public ScriptedAI
                     m_creature->setFaction(35);
                 }
             }
+
             Check_Timer = 1000;
         }else Check_Timer -= diff;
     }
 };
+
 //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* pCreature)
 {
     SimpleAI* ai = new SimpleAI (pCreature);
+
     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 Strider
 //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* pCreature)
 {
     SimpleAI* ai = new SimpleAI (pCreature);
+
     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 TRINITY_DLL_DECL mob_shield_generator_channelAI : public ScriptedAI
 {
     mob_shield_generator_channelAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
     uint32 Check_Timer;
     bool Casted;
@@ -757,18 +874,24 @@ struct TRINITY_DLL_DECL mob_shield_generator_channelAI : public ScriptedAI
         Check_Timer = 0;
         Casted = false;
         m_creature->SetDisplayId(11686);  //invisible
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void EnterCombat(Unit *who) { return; }
+
     void MoveInLineOfSight(Unit *who) { return; }
+
     void UpdateAI (const uint32 diff)
     {
         if (!pInstance)
             return;
+
         if (Check_Timer < diff)
         {
             Unit *Vashj = NULL;
             Vashj = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ));
+
             if (Vashj && Vashj->isAlive())
             {
                 //start visual channel
@@ -782,14 +905,17 @@ struct TRINITY_DLL_DECL mob_shield_generator_channelAI : public ScriptedAI
         }else Check_Timer -= diff;
     }
 };
+
 bool ItemUse_item_tainted_core(Player* pPlayer, Item* _Item, SpellCastTargets const& targets)
 {
     ScriptedInstance *pInstance = pPlayer->GetInstanceData();
+
     if (!pInstance)
     {
         pPlayer->GetSession()->SendNotification(TEXT_NOT_INITIALIZED);
         return true;
     }
+
     Creature *Vashj = NULL;
     Vashj = (Unit::GetCreature((*pPlayer), pInstance->GetData64(DATA_LADYVASHJ)));
     if (Vashj && CAST_AI(boss_lady_vashjAI, Vashj->AI())->Phase == 2)
@@ -819,11 +945,13 @@ bool ItemUse_item_tainted_core(Player* pPlayer, Item* _Item, SpellCastTargets co
                 default:
                     return true;
             }
+
             if (pInstance->GetData(identifier))
             {
                 pPlayer->GetSession()->SendNotification(TEXT_ALREADY_DEACTIVATED);
                 return true;
             }
+
             //get and remove channel
             Unit *Channel = NULL;
             Channel = Unit::GetCreature(*Vashj, CAST_AI(boss_lady_vashjAI, Vashj->AI())->ShieldGeneratorChannel[channel_identifier]);
@@ -832,7 +960,9 @@ bool ItemUse_item_tainted_core(Player* pPlayer, Item* _Item, SpellCastTargets co
                 //call Unsummon()
                 Channel->setDeathState(JUST_DIED);
             }
+
             pInstance->SetData(identifier, 1);
+
             //remove this item
             pPlayer->DestroyItemCount(31088, 1, true);
             return true;
@@ -848,26 +978,32 @@ bool ItemUse_item_tainted_core(Player* pPlayer, Item* _Item, SpellCastTargets co
     }
     return true;
 }
+
 CreatureAI* GetAI_boss_lady_vashj(Creature* pCreature)
 {
     return new boss_lady_vashjAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_enchanted_elemental(Creature* pCreature)
 {
     return new mob_enchanted_elementalAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_tainted_elemental(Creature* pCreature)
 {
     return new mob_tainted_elementalAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_toxic_sporebat(Creature* pCreature)
 {
     return new mob_toxic_sporebatAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_shield_generator_channel(Creature* pCreature)
 {
     return new mob_shield_generator_channelAI (pCreature);
 }
+
 void AddSC_boss_lady_vashj()
 {
     Script *newscript;
@@ -875,30 +1011,37 @@ void AddSC_boss_lady_vashj()
     newscript->Name = "boss_lady_vashj";
     newscript->GetAI = &GetAI_boss_lady_vashj;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_enchanted_elemental";
     newscript->GetAI = &GetAI_mob_enchanted_elemental;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_tainted_elemental";
     newscript->GetAI = &GetAI_mob_tainted_elemental;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_toxic_sporebat";
     newscript->GetAI = &GetAI_mob_toxic_sporebat;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_coilfang_elite";
     newscript->GetAI = &GetAI_mob_coilfang_elite;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_coilfang_strider";
     newscript->GetAI = &GetAI_mob_coilfang_strider;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_shield_generator_channel";
     newscript->GetAI = &GetAI_mob_shield_generator_channel;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_tainted_core";
     newscript->pItemUse = &ItemUse_item_tainted_core;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp
index cf3657439c4..f57f0542bdf 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp
@@ -13,37 +13,45 @@
  * along with 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: 80
 SDComment: Possesion Support
 SDCategory: Coilfang Resevoir, Serpent Shrine Cavern
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_serpent_shrine.h"
+
 // --- Spells used by Leotheras The Blind
 #define SPELL_WHIRLWIND         37640
 #define SPELL_CHAOS_BLAST       37674
 #define SPELL_BERSERK           26662
 #define SPELL_INSIDIOUS_WHISPER 37676
 #define SPELL_DUAL_WIELD        42459
+
 // --- Spells used in banish phase ---
 #define BANISH_BEAM             38909
 #define AURA_BANISH             37833
+
 // --- Spells used by Greyheart Spellbinders
 #define SPELL_EARTHSHOCK        39076
 #define SPELL_MINDBLAST         37531
+
 // --- Spells used by Inner Demons and Creature ID
 #define INNER_DEMON_ID          21857
 #define AURA_DEMONIC_ALIGNMENT  37713
 #define SPELL_SHADOWBOLT        39309
 #define SPELL_SOUL_LINK         38007
 #define SPELL_CONSUMING_MADNESS 37749 //not supported by core yet
+
 //Misc.
 #define MODEL_DEMON             20125
 #define MODEL_NIGHTELF          20514
 #define DEMON_FORM              21875
 #define MOB_SPELLBINDER         21806
+
 #define SAY_AGGRO               -1548009
 #define SAY_SWITCH_TO_DEMON     -1548010
 #define SAY_INNER_DEMONS        -1548011
@@ -56,15 +64,19 @@ EndScriptData */
 #define SAY_FINAL_FORM          -1548018
 #define SAY_FREE                -1548019
 #define SAY_DEATH               -1548020
+
 struct TRINITY_DLL_DECL mob_inner_demonAI : public ScriptedAI
 {
     mob_inner_demonAI(Creature *c) : ScriptedAI(c)
     {
         victimGUID = 0;
     }
+
     uint32 ShadowBolt_Timer;
+
     uint32 Link_Timer;
     uint64 victimGUID;
+
     void Reset()
     {
         ShadowBolt_Timer = 10000;
@@ -76,6 +88,7 @@ struct TRINITY_DLL_DECL mob_inner_demonAI : public ScriptedAI
         if (pUnit && pUnit->HasAura(SPELL_INSIDIOUS_WHISPER))
             pUnit->RemoveAurasDueToSpell(SPELL_INSIDIOUS_WHISPER);
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by->GetGUID() != victimGUID && done_by->GetGUID() != m_creature->GetGUID())
@@ -84,15 +97,18 @@ struct TRINITY_DLL_DECL mob_inner_demonAI : public ScriptedAI
             DoModifyThreatPercent(done_by, -100);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (!victimGUID) return;
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (m_creature->getVictim()->GetGUID() != victimGUID)
         {
             DoModifyThreatPercent(m_creature->getVictim(), -100);
@@ -107,19 +123,23 @@ struct TRINITY_DLL_DECL mob_inner_demonAI : public ScriptedAI
                 return;
             }
         }
+
         if (Link_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SOUL_LINK, true);
             Link_Timer = 1000;
         }else Link_Timer -= diff;
 
+
         if (!m_creature->HasAura(AURA_DEMONIC_ALIGNMENT))
             DoCast(m_creature, AURA_DEMONIC_ALIGNMENT,true);
+
         if (ShadowBolt_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SHADOWBOLT, false);
             ShadowBolt_Timer = 10000;
         }else ShadowBolt_Timer -= diff;
+
        DoMeleeAttackIfReady();
     }
 };
@@ -131,10 +151,13 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
         c->GetPosition(x,y,z);
         pInstance = c->GetInstanceData();
         Demon = 0;
-        for (uint8 i = 0; i < 3; ++i) //clear guids
+
+        for(uint8 i = 0; i < 3; ++i)//clear guids
             SpellBinderGUID[i] = 0;
     }
+
     ScriptedInstance *pInstance;
+
     uint32 Whirlwind_Timer;
     uint32 ChaosBlast_Timer;
     uint32 SwitchToDemon_Timer;
@@ -142,16 +165,19 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
     uint32 Berserk_Timer;
     uint32 InnerDemons_Timer;
     uint32 BanishTimer;
+
     bool DealDamage;
     bool NeedThreatReset;
     bool DemonForm;
     bool IsFinalForm;
     bool EnrageUsed;
     float x,y,z;
+
     uint64 InnderDemon[5];
     uint32 InnderDemon_Count;
     uint64 Demon;
     uint64 SpellBinderGUID[3];
+
     void Reset()
     {
         CheckChannelers();
@@ -178,12 +204,14 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, NOT_STARTED);
     }
+
     void CheckChannelers(bool DoEvade = true)
     {
-        for (uint8 i = 0; i < 3; ++i)
+        for(uint8 i = 0; i < 3; ++i)
         {
             if (Creature *add = Unit::GetCreature(*m_creature,SpellBinderGUID[i]))
                 add->DisappearAndDie();
+
             float nx = x;
             float ny = y;
             float o = 2.4f;
@@ -193,16 +221,19 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
             Creature* binder = m_creature->SummonCreature(MOB_SPELLBINDER,nx,ny,z,o,TEMPSUMMON_DEAD_DESPAWN,0);
             if (binder)
                 SpellBinderGUID[i] = binder->GetGUID();
+
         }
     }
     void MoveInLineOfSight(Unit *who)
     {
         if (m_creature->HasAura(AURA_BANISH))
             return;
+
         if (!m_creature->getVictim() && who->isTargetableForAttack() && (m_creature->IsHostileTo(who)) && who->isInAccessiblePlaceFor(m_creature))
         {
             if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
                 return;
+
             float attackRadius = m_creature->GetAttackDistance(who);
             if (m_creature->IsWithinDistInMap(who, attackRadius))
             {
@@ -214,32 +245,39 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
             }
         }
     }
+
     void StartEvent()
     {
         DoScriptText(SAY_AGGRO, m_creature);
         if (pInstance)
             pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, IN_PROGRESS);
     }
+
     void CheckBanish()
     {
         uint8 AliveChannelers = 0;
-        for (uint8 i = 0; i < 3; ++i)
+        for(uint8 i = 0; i < 3; ++i)
         {
             Unit *add = Unit::GetUnit(*m_creature,SpellBinderGUID[i]);
             if (add && add->isAlive())
                 AliveChannelers++;
         }
+
         // channelers == 0 remove banish aura
         if (AliveChannelers == 0 && m_creature->HasAura(AURA_BANISH))
         {
             // removing banish aura
             m_creature->RemoveAurasDueToSpell(AURA_BANISH);
+
             // Leotheras is getting immune again
             m_creature->ApplySpellImmune(AURA_BANISH, IMMUNITY_MECHANIC, MECHANIC_BANISH, true);
+
             // changing model to bloodelf
             m_creature->SetDisplayId(MODEL_NIGHTELF);
+
             // and reseting equipment
             m_creature->LoadEquipment(m_creature->GetEquipmentId());
+
             if (pInstance && pInstance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
             {
                 Unit *victim = NULL;
@@ -255,17 +293,20 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
             // removing Leotheras banish immune to apply AURA_BANISH
             m_creature->ApplySpellImmune(AURA_BANISH, IMMUNITY_MECHANIC, MECHANIC_BANISH, false);
             DoCast(m_creature, AURA_BANISH);
+
             // changing model
             m_creature->SetDisplayId(MODEL_DEMON);
+
             // and removing weapons
             m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID  , 0);
             m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0);
         }
     }
+
     //Despawn all Inner Demon summoned
     void DespawnDemon()
     {
-        for (uint8 i=0; i<5; ++i)
+        for(uint8 i=0; i<5; ++i)
         {
             if (InnderDemon[i])
             {
@@ -278,11 +319,13 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
                     InnderDemon[i] = 0;
             }
         }
+
         InnderDemon_Count = 0;
     }
+
     void CastConsumingMadness() //remove this once SPELL_INSIDIOUS_WHISPER is supported by core
     {
-        for (uint8 i=0; i<5; ++i)
+        for(uint8 i=0; i<5; ++i)
         {
             if (InnderDemon[i] > 0)
             {
@@ -299,10 +342,12 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim->GetTypeId() != TYPEID_PLAYER)
             return;
+
         if (DemonForm)
         {
             DoScriptText(RAND(SAY_DEMON_SLAY1,SAY_DEMON_SLAY2,SAY_DEMON_SLAY3), m_creature);
@@ -312,9 +357,11 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
             DoScriptText(RAND(SAY_NIGHTELF_SLAY1,SAY_NIGHTELF_SLAY2,SAY_NIGHTELF_SLAY3), m_creature);
         }
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         //despawn copy
         if (Demon)
         {
@@ -324,12 +371,15 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         if (m_creature->HasAura(AURA_BANISH))
         return;
+
         m_creature->LoadEquipment(m_creature->GetEquipmentId());
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
@@ -354,6 +404,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
                 }
                 Whirlwind_Timer = 2000;
             }else Whirlwind_Timer -= diff;
+
         // reseting after changing forms and after ending whirlwind
         if (NeedThreatReset && !m_creature->HasAura(SPELL_WHIRLWIND))
         {
@@ -362,11 +413,13 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
                 InnerDemons_Timer = 30000;
             else
                 Whirlwind_Timer =  15000;
+
             NeedThreatReset = false;
             DoResetThreat();
             m_creature->GetMotionMaster()->Clear();
             m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
         }
+
         //Enrage_Timer (10 min)
         if (Berserk_Timer < diff && !EnrageUsed)
         {
@@ -374,6 +427,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
             DoCast(m_creature, SPELL_BERSERK);
             EnrageUsed = true;
         }else Berserk_Timer -= diff;
+
         if (!DemonForm)
         {
             //Whirldind Timer
@@ -388,6 +442,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
                 }else Whirlwind_Timer -= diff;
             }
             //Switch_Timer
+
             if (!IsFinalForm)
                 if (SwitchToDemon_Timer < diff)
                 {
@@ -426,14 +481,14 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
             {
                 std::list& ThreatList = m_creature->getThreatManager().getThreatList();
                 std::vector TargetList;
-                for (std::list::iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr)
+                for(std::list::iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr)
                 {
                     Unit *tempTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                     if (tempTarget && tempTarget->GetTypeId() == TYPEID_PLAYER && tempTarget->GetGUID() != m_creature->getVictim()->GetGUID() && TargetList.size()<5)
                         TargetList.push_back(tempTarget);
                 }
                 SpellEntry *spell = GET_SPELL(SPELL_INSIDIOUS_WHISPER);
-                for (std::vector::iterator itr = TargetList.begin(); itr != TargetList.end(); ++itr)
+                for(std::vector::iterator itr = TargetList.begin(); itr != TargetList.end(); ++itr)
                 {
                     if ((*itr) && (*itr)->isAlive())
                     {
@@ -442,6 +497,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
                         {
                             demon->AI()->AttackStart((*itr));
                             CAST_AI(mob_inner_demonAI, demon->AI())->victimGUID = (*itr)->GetGUID();
+
                             uint8 eff_mask=0;
                             for (int i=0; i<3; ++i)
                             {
@@ -451,29 +507,37 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
                             }
                             (*itr)->AddAura(new Aura(spell, eff_mask, *itr, *itr, *itr));
                             if (InnderDemon_Count > 4) InnderDemon_Count = 0;
+
                             //Safe storing of creatures
                             InnderDemon[InnderDemon_Count] = demon->GetGUID();
+
                             //Update demon count
                             InnderDemon_Count++;
                         }
                     }
                 }
                 DoScriptText(SAY_INNER_DEMONS, m_creature);
+
                 InnerDemons_Timer = 999999;
             }else InnerDemons_Timer -= diff;
+
             //Switch_Timer
             if (SwitchToHuman_Timer < diff)
             {
                 //switch to nightelf form
                 m_creature->SetDisplayId(MODEL_NIGHTELF);
                 m_creature->LoadEquipment(m_creature->GetEquipmentId());
+
                 CastConsumingMadness();
                 DespawnDemon();
+
                 DemonForm = false;
                 NeedThreatReset = true;
+
                 SwitchToHuman_Timer = 60000;
             }else SwitchToHuman_Timer -= diff;
         }
+
         if (!IsFinalForm && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 15)
         {
             //at this point he divides himself in two parts
@@ -490,42 +554,52 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
             //set nightelf final form
             IsFinalForm = true;
             DemonForm = false;
+
             DoScriptText(SAY_FINAL_FORM, m_creature);
             m_creature->SetDisplayId(MODEL_NIGHTELF);
             m_creature->LoadEquipment(m_creature->GetEquipmentId());
         }
     }
 };
+
 //Leotheras the Blind Demon Form AI
 struct TRINITY_DLL_DECL boss_leotheras_the_blind_demonformAI : public ScriptedAI
 {
     boss_leotheras_the_blind_demonformAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ChaosBlast_Timer;
     bool DealDamage;
+
     void Reset()
     {
         ChaosBlast_Timer = 1000;
         DealDamage = true;
     }
+
     void StartEvent()
     {
         DoScriptText(SAY_FREE, m_creature);
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim->GetTypeId() != TYPEID_PLAYER)
             return;
+
         DoScriptText(RAND(SAY_DEMON_SLAY1,SAY_DEMON_SLAY2,SAY_DEMON_SLAY3), m_creature);
     }
+
     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 EnterCombat(Unit *who)
     {
         StartEvent();
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
@@ -534,6 +608,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blind_demonformAI : public ScriptedAI
         //ChaosBlast_Timer
         if (m_creature->IsWithinDist(m_creature->getVictim(), 30))
             m_creature->StopMoving();
+
         if (ChaosBlast_Timer < diff)
          {
             // will cast only when in range od spell
@@ -545,6 +620,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blind_demonformAI : public ScriptedAI
                 ChaosBlast_Timer = 3000;
             }
          }else ChaosBlast_Timer -= diff;
+
         //Do NOT deal any melee damage to the target.
     }
 };
@@ -556,15 +632,21 @@ struct TRINITY_DLL_DECL mob_greyheart_spellbinderAI : public ScriptedAI
         leotherasGUID = 0;
         AddedBanish = false;
     }
+
     ScriptedInstance *pInstance;
+
     uint64 leotherasGUID;
+
     uint32 Mindblast_Timer;
     uint32 Earthshock_Timer;
+
     bool AddedBanish;
+
     void Reset()
     {
         Mindblast_Timer  = 3000 + rand()%5000;
         Earthshock_Timer = 5000 + rand()%5000;
+
         if (pInstance)
         {
             pInstance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, 0);
@@ -573,17 +655,20 @@ struct TRINITY_DLL_DECL mob_greyheart_spellbinderAI : public ScriptedAI
                 CAST_AI(boss_leotheras_the_blindAI, leotheras->AI())->CheckChannelers(false);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->InterruptNonMeleeSpells(false);
         if (pInstance)
             pInstance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, who->GetGUID());
     }
+
     void JustRespawned()
     {
         AddedBanish = false;
         Reset();
     }
+
     void CastChanneling()
     {
         if (!m_creature->isInCombat() && !m_creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
@@ -596,12 +681,14 @@ struct TRINITY_DLL_DECL mob_greyheart_spellbinderAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (pInstance)
         {
             if (!leotherasGUID)
                 leotherasGUID = pInstance->GetData64(DATA_LEOTHERAS);
+
             if (!m_creature->isInCombat() && pInstance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
             {
                 Unit *victim = NULL;
@@ -610,35 +697,42 @@ struct TRINITY_DLL_DECL mob_greyheart_spellbinderAI : public ScriptedAI
                     AttackStart(victim);
             }
         }
+
         if (!UpdateVictim())
         {
             CastChanneling();
             return;
         }
+
         if (pInstance && !pInstance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
         {
             EnterEvadeMode();
             return;
         }
+
         if (Mindblast_Timer < diff)
         {
             Unit* target = NULL;
             target = SelectUnit(SELECT_TARGET_RANDOM,0);
+
             if (target)DoCast(target, SPELL_MINDBLAST);
+
             Mindblast_Timer = 10000 + rand()%5000;
         }else Mindblast_Timer -= diff;
+
         if (Earthshock_Timer < diff)
         {
             Map* pMap = m_creature->GetMap();
             Map::PlayerList const &PlayerList = pMap->GetPlayers();
-            for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
+            for(Map::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr)
             {
                 if (Player* i_pl = itr->getSource())
                 {
                     bool isCasting = false;
-                    for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
+                    for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
                         if (i_pl->GetCurrentSpell(i))
                             isCasting = true;
+
                     if (isCasting)
                     {
                         DoCast(i_pl, SPELL_EARTHSHOCK);
@@ -650,20 +744,24 @@ struct TRINITY_DLL_DECL mob_greyheart_spellbinderAI : public ScriptedAI
         }else Earthshock_Timer -= diff;
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit *killer) {}
 };
 CreatureAI* GetAI_boss_leotheras_the_blind(Creature* pCreature)
 {
     return new boss_leotheras_the_blindAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_leotheras_the_blind_demonform(Creature* pCreature)
 {
     return new boss_leotheras_the_blind_demonformAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_greyheart_spellbinder(Creature* pCreature)
 {
     return new mob_greyheart_spellbinderAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_inner_demon(Creature* pCreature)
 {
     return new mob_inner_demonAI (pCreature);
@@ -671,18 +769,22 @@ CreatureAI* GetAI_mob_inner_demon(Creature* pCreature)
 void AddSC_boss_leotheras_the_blind()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_leotheras_the_blind";
     newscript->GetAI = &GetAI_boss_leotheras_the_blind;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_leotheras_the_blind_demonform";
     newscript->GetAI = &GetAI_boss_leotheras_the_blind_demonform;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_greyheart_spellbinder";
     newscript->GetAI = &GetAI_mob_greyheart_spellbinder;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_inner_demon";
     newscript->GetAI = &GetAI_mob_inner_demon;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp
index a9fbf6a2506..1146cf96b24 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp
@@ -13,16 +13,19 @@
  * along with 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_lurker_below
 SD%Complete: 80
 SDComment: Coilfang Frenzy, find out how could we fishing in the strangepool
 SDCategory: The Lurker Below
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_serpent_shrine.h"
 #include "simple_ai.h"
 #include "Spell.h"
+
 #define SPELL_SPOUT         37433
 #define SPELL_SPOUT_ANIM    42835
 #define SPELL_SPOUT_BREATH  37431
@@ -32,16 +35,22 @@ EndScriptData */
 #define SPELL_WATERBOLT     37138
 #define SPELL_SUBMERGE      37550
 #define SPELL_EMERGE        20568
+
 #define EMOTE_SPOUT "The Lurker Below takes a deep breath."
+
 #define SPOUT_DIST  100
+
 #define MOB_COILFANG_GUARDIAN 21873
 #define MOB_COILFANG_AMBUSHER 21865
+
 //Ambusher spells
 #define SPELL_SPREAD_SHOT   37790
 #define SPELL_SHOOT         37770
+
 //Guardian spells
 #define SPELL_ARCINGSMASH   38761 // Wrong SpellId. Can't find the right one.
 #define SPELL_HAMSTRING     26211
+
 float AddPos[9][3] =
 {
     {2.8553810, -459.823914, -19.182686},   //MOVE_AMBUSHER_1 X, Y, Z
@@ -54,6 +63,7 @@ float AddPos[9][3] =
     {14.388216, -423.468018, -19.625271},   //MOVE_GUARDIAN_2 X, Y, Z
     {42.471519, -445.115295, -19.769423}    //MOVE_GUARDIAN_3 X, Y, Z
 };
+
 struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
 {
     boss_the_lurker_belowAI(Creature *c) : Scripted_NoMovementAI(c), Summons(m_creature)
@@ -67,8 +77,10 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
             TempSpell->Effect[2] = 0;
         }
     }
+
     ScriptedInstance* pInstance;
     SummonList Summons;
+
     bool Spawned;
     bool Submerged;
     bool InRange;
@@ -83,7 +95,8 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
     uint32 CheckTimer;
     uint32 WaitTimer;
     uint32 WaitTimer2;
-    bool CheckCanStart() //check if players fished
+
+    bool CheckCanStart()//check if players fished
     {
         if(pInstance && pInstance->GetData(DATA_STRANGE_POOL) == NOT_STARTED)
             return false;
@@ -102,11 +115,14 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
         CheckTimer = 15000;//give time to get in range when fight starts
         WaitTimer = 60000;//never reached
         WaitTimer2 = 60000;//never reached
+
         Submerged = true;//will be false at combat start
         Spawned = false;
         InRange = false;
         CanStartEvent = false;
+
         Summons.DespawnAll();
+
         if (pInstance)
         {
             pInstance->SetData(DATA_THELURKERBELOWEVENT, NOT_STARTED);
@@ -117,21 +133,25 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_THELURKERBELOWEVENT, DONE);
+
         Summons.DespawnAll();
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_THELURKERBELOWEVENT, IN_PROGRESS);
         Scripted_NoMovementAI::EnterCombat(who);
     }
+
     void MoveInLineOfSight(Unit *who)
     {
-        if(!CanStartEvent) //boss is invisible, don't attack
+        if(!CanStartEvent)//boss is invisible, don't attack
             return;
         if (!m_creature->getVictim() && who->isTargetableForAttack() && (m_creature->IsHostileTo(who)))
         {
@@ -142,14 +162,16 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
             }
         }
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if(type == ROTATE_MOTION_TYPE)
             me->SetReactState(REACT_AGGRESSIVE);
     }
+
     void UpdateAI(const uint32 diff)
     {
-        if(!CanStartEvent) //boss is invisible, don't attack
+        if(!CanStartEvent)//boss is invisible, don't attack
         {
             if(CheckCanStart())
             {
@@ -159,7 +181,7 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                     Submerged = false;
                     WaitTimer2 = 500;
                 }
-                if(!Submerged && WaitTimer2 < diff) //wait 500ms before emerge anim
+                if(!Submerged && WaitTimer2 < diff)//wait 500ms before emerge anim
                 {
                     m_creature->RemoveAllAuras();
                     m_creature->RemoveFlag(UNIT_NPC_EMOTESTATE,EMOTE_STATE_SUBMERGED);
@@ -167,7 +189,8 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                     WaitTimer2 = 60000;//never reached
                     WaitTimer = 3000;
                 }else WaitTimer2 -= diff;
-                if(WaitTimer < diff) //wait 3secs for emerge anim, then attack
+
+                if(WaitTimer < diff)//wait 3secs for emerge anim, then attack
                 {
                     WaitTimer = 3000;
                     CanStartEvent=true;//fresh fished from pool
@@ -178,7 +201,9 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
             return;
         }
 
-        if(m_creature->getThreatManager().getThreatList().empty()) //check if should evade
+
+
+        if(m_creature->getThreatManager().getThreatList().empty())//check if should evade
         {
             if(m_creature->isInCombat())
                 EnterEvadeMode();
@@ -193,6 +218,7 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                 PhaseTimer = 60000;//60secs submerged
                 Submerged = true;
             }else PhaseTimer-=diff;
+
             if (SpoutTimer < diff)
             {
                 m_creature->MonsterTextEmote(EMOTE_SPOUT,0,true);
@@ -203,13 +229,15 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                 RotTimer = 20000;
                 return;
             }else SpoutTimer -= diff;
+
             //Whirl directly after a Spout and at random times
             if (WhirlTimer < diff)
             {
                 WhirlTimer = 18000;
                 DoCast(m_creature,SPELL_WHIRL);
             }else WhirlTimer -= diff;
-            if(CheckTimer < diff) //check if there are players in melee range
+
+            if(CheckTimer < diff)//check if there are players in melee range
             {
                 InRange = false;
                 Map* pMap = m_creature->GetMap();
@@ -224,6 +252,7 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                 }
                 CheckTimer = 2000;
             }else CheckTimer -= diff;
+
             if(RotTimer)
             {
                 Map* pMap = m_creature->GetMap();
@@ -236,17 +265,20 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                             DoCast(i->getSource(),SPELL_SPOUT,true);//only knock back palyers in arc, in 100yards, not in water
                     }
                 }
+
                 if(SpoutAnimTimer < diff)
                 {
                     DoCast(m_creature,SPELL_SPOUT_ANIM,true);
                     SpoutAnimTimer = 1000;
                 }else SpoutAnimTimer -= diff;
+
                 if(RotTimer < diff)
                 {
                     RotTimer = 0;
                 }else RotTimer -= diff;
                 return;
             }
+
             if (GeyserTimer < diff)
             {
                 Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1);
@@ -256,7 +288,8 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                     DoCast(target,SPELL_GEYSER,true);
                 GeyserTimer = rand()%5000 + 15000;
             }else GeyserTimer -= diff;
-            if(!InRange) //if on players in melee range cast Waterbolt
+
+            if(!InRange)//if on players in melee range cast Waterbolt
             {
                 if (WaterboltTimer < diff)
                 {
@@ -268,9 +301,12 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                     WaterboltTimer = 3000;
                 }else WaterboltTimer -= diff;
             }
+
             if (!UpdateCombatState())
                 return;
+
             DoMeleeAttackIfReady();
+
         }else//submerged
         {
             if (PhaseTimer < diff)
@@ -286,13 +322,15 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                 PhaseTimer = 120000;
                 return;
             }else PhaseTimer-=diff;
-            if(m_creature->getThreatManager().getThreatList().empty()) //check if should evade
+
+            if(m_creature->getThreatManager().getThreatList().empty())//check if should evade
             {
                 EnterEvadeMode();
                 return;
             }
             if (!m_creature->isInCombat())
                 DoZoneInCombat();
+
             if (!Spawned)
             {
                 m_creature->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
@@ -303,6 +341,7 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
                     if (i < 6)
                         Summoned = m_creature->SummonCreature(MOB_COILFANG_AMBUSHER,AddPos[i][0],AddPos[i][1],AddPos[i][2], 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                     else Summoned = m_creature->SummonCreature(MOB_COILFANG_GUARDIAN,AddPos[i][0],AddPos[i][1],AddPos[i][2], 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
+
                     if (Summoned)
                         Summons.Summon(Summoned);
                 }
@@ -311,21 +350,26 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
         }
     }
  };
+
 CreatureAI* GetAI_mob_coilfang_guardian(Creature* pCreature)
 {
     SimpleAI* ai = new SimpleAI (pCreature);
+
     ai->Spell[0].Enabled = true;
     ai->Spell[0].Spell_Id = SPELL_ARCINGSMASH;
     ai->Spell[0].Cooldown = 15000;
     ai->Spell[0].First_Cast = 5000;
     ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET;
+
     ai->Spell[1].Enabled = true;
     ai->Spell[1].Spell_Id = SPELL_HAMSTRING;
     ai->Spell[1].Cooldown = 10000;
     ai->Spell[1].First_Cast = 2000;
     ai->Spell[1].Cast_Target_Type = CAST_HOSTILE_TARGET;
+
     return ai;
 }
+
 struct TRINITY_DLL_DECL mob_coilfang_ambusherAI : public Scripted_NoMovementAI
 {
     mob_coilfang_ambusherAI(Creature *c) : Scripted_NoMovementAI(c)
@@ -334,33 +378,43 @@ struct TRINITY_DLL_DECL mob_coilfang_ambusherAI : public Scripted_NoMovementAI
         if (TempSpell)
             TempSpell->Effect[0] = 2;//change spell effect from weapon % dmg to simple phisical dmg
     }
+
     uint32 MultiShotTimer;
     uint32 ShootBowTimer;
+
     void Reset()
     {
         MultiShotTimer = 10000;
         ShootBowTimer = 4000;
+
     }
+
     void EnterCombat(Unit *who)
     {
+
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || m_creature->getVictim()) return;
+
         if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(m_creature) && m_creature->IsHostileTo(who) && m_creature->IsWithinDistInMap(who, 45))
         {
             AttackStart(who);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (MultiShotTimer < diff)
         {
             if (m_creature->getVictim())
                 DoCast(m_creature->getVictim(), SPELL_SPREAD_SHOT, true);
+
             MultiShotTimer = 10000+rand()%10000;
             ShootBowTimer += 1500;//add global cooldown
         }else MultiShotTimer -= diff;
+
         if (ShootBowTimer < diff)
         {
             Unit* target = NULL;
@@ -373,14 +427,17 @@ struct TRINITY_DLL_DECL mob_coilfang_ambusherAI : public Scripted_NoMovementAI
         }else ShootBowTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_coilfang_ambusher(Creature* pCreature)
 {
     return new mob_coilfang_ambusherAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_the_lurker_below(Creature* pCreature)
 {
     return new boss_the_lurker_belowAI (pCreature);
 }
+
 void AddSC_boss_the_lurker_below()
 {
     Script *newscript;
@@ -388,13 +445,16 @@ void AddSC_boss_the_lurker_below()
     newscript->Name = "boss_the_lurker_below";
     newscript->GetAI = &GetAI_boss_the_lurker_below;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_coilfang_guardian";
     newscript->GetAI = &GetAI_mob_coilfang_guardian;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_coilfang_ambusher";
     newscript->GetAI = &GetAI_mob_coilfang_ambusher;
     newscript->RegisterSelf();
 }
 
+
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp
index 5715ef78e6c..b624f5ba827 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp
@@ -13,14 +13,17 @@
 * along with 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, remove hacks
 SDCategory: Coilfang Resevoir, Serpent Shrine Cavern
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_serpent_shrine.h"
+
 #define SAY_AGGRO                   -1548030
 #define SAY_SUMMON1                 -1548031
 #define SAY_SUMMON2                 -1548032
@@ -33,10 +36,12 @@ EndScriptData */
 #define EMOTE_WATERY_GRAVE          -1548039
 #define EMOTE_EARTHQUAKE            -1548040
 #define EMOTE_WATERY_GLOBULES       -1548041
+
 #define SPELL_TIDAL_WAVE            37730
 #define SPELL_WATERY_GRAVE          38049
 #define SPELL_EARTHQUAKE            37764
 #define SPELL_WATERY_GRAVE_EXPLOSION 37852
+
 #define WATERY_GRAVE_X1             334.64
 #define WATERY_GRAVE_Y1             -728.89
 #define WATERY_GRAVE_Z1             -14.42
@@ -49,24 +54,29 @@ EndScriptData */
 #define WATERY_GRAVE_X4             372.93
 #define WATERY_GRAVE_Y4             -690.96
 #define WATERY_GRAVE_Z4             -14.44
+
 #define SPELL_WATERY_GRAVE_1    38023
 #define SPELL_WATERY_GRAVE_2    38024
 #define SPELL_WATERY_GRAVE_3    38025
 #define SPELL_WATERY_GRAVE_4    37850
+
 #define SPELL_SUMMON_WATER_GLOBULE_1    37854
 #define SPELL_SUMMON_WATER_GLOBULE_2    37858
 #define SPELL_SUMMON_WATER_GLOBULE_3    37860
 #define SPELL_SUMMON_WATER_GLOBULE_4    37861
+
 /*#define SPELL_SUMMON_MURLOC_A6    39813
 #define SPELL_SUMMON_MURLOC_A7  39814
 #define SPELL_SUMMON_MURLOC_A8  39815
 #define SPELL_SUMMON_MURLOC_A9  39816
 #define SPELL_SUMMON_MURLOC_A10 39817
+
 #define SPELL_SUMMON_MURLOC_B6  39818
 #define SPELL_SUMMON_MURLOC_B7  39819
 #define SPELL_SUMMON_MURLOC_B8  39820
 #define SPELL_SUMMON_MURLOC_B9  39821
 #define SPELL_SUMMON_MURLOC_B10 39822*/
+
 float MurlocCords[10][5] =
 {
       {21920, 424.36, -715.4, -7.14, 0.124},
@@ -80,9 +90,11 @@ float MurlocCords[10][5] =
       {21920, 321.05, -718.73, -13.15, 0.124},
        {21920, 321.05, -714.24, -13.15, 0.124}
 };
+
 //Creatures
 #define WATER_GLOBULE               21913
 #define TIDEWALKER_LURKER           21920
+
 //Morogrim Tidewalker AI
 struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
 {
@@ -90,8 +102,11 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     Map::PlayerList const *PlayerList;
+
     uint32 TidalWave_Timer;
     uint32 WateryGrave_Timer;
     uint32 Earthquake_Timer;
@@ -99,8 +114,10 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
     uint32 globulespell[4];
     int8 Playercount;
     int8 counter;
+
     bool Earthquake;
     bool Phase2;
+
     void Reset()
     {
         TidalWave_Timer = 10000;
@@ -111,33 +128,42 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
         globulespell[1] = SPELL_SUMMON_WATER_GLOBULE_2;
         globulespell[2] = SPELL_SUMMON_WATER_GLOBULE_3;
         globulespell[3] = SPELL_SUMMON_WATER_GLOBULE_4;
+
         Earthquake = false;
         Phase2 = false;
+
         if (pInstance)
             pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, NOT_STARTED);
     }
+
     void StartEvent()
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         PlayerList = &m_creature->GetMap()->GetPlayers();
         Playercount = PlayerList->getSize();
         StartEvent();
     }
+
     void ApplyWateryGrave(Unit* pPlayer, uint8 i)
     {
         switch(i)
@@ -148,11 +174,13 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
         case 3: pPlayer->CastSpell(pPlayer, SPELL_WATERY_GRAVE_4, true); break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Earthquake_Timer
         if (Earthquake_Timer < diff)
         {
@@ -165,7 +193,8 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
             else
             {
                 DoScriptText(RAND(SAY_SUMMON1,SAY_SUMMON2), m_creature);
-                for (uint8 i = 0; i < 10; ++i)
+
+                for(uint8 i = 0; i < 10; ++i)
                 {
                     Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
                     Creature* Murloc = m_creature->SummonCreature(MurlocCords[i][0],MurlocCords[i][1],MurlocCords[i][2],MurlocCords[i][3],MurlocCords[i][4], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
@@ -177,12 +206,14 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
                 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
@@ -193,7 +224,7 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
                 using std::set;
                 setlist;
                 set::iterator itr;
-                for (uint8 i = 0; i < 4; ++i)
+                for(uint8 i = 0; i < 4; ++i)
                 {
                     counter = 0;
                     do{target = SelectTarget(SELECT_TARGET_RANDOM, 1, 50, true);    //target players only
@@ -206,10 +237,13 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
                     ApplyWateryGrave(target, i);
                     }
                 }
+
                 DoScriptText(RAND(SAY_SUMMON_BUBL1,SAY_SUMMON_BUBL2), m_creature);
+
                 DoScriptText(EMOTE_WATERY_GRAVE, m_creature);
                 WateryGrave_Timer = 30000;
             }else WateryGrave_Timer -= diff;
+
             //Start Phase2
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25)
                 Phase2 = true;
@@ -239,27 +273,36 @@ struct TRINITY_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI
                 WateryGlobules_Timer = 25000;
             }else WateryGlobules_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Water Globule AI
 #define SPELL_GLOBULE_EXPLOSION 37871
+
 struct TRINITY_DLL_DECL mob_water_globuleAI : public ScriptedAI
 {
     mob_water_globuleAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who) {}
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || m_creature->getVictim())
             return;
+
         if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(m_creature) && m_creature->IsHostileTo(who))
         {
             //no attack radius check - it attacks the first target that moves in his los
@@ -267,25 +310,30 @@ struct TRINITY_DLL_DECL mob_water_globuleAI : public ScriptedAI
             AttackStart(who);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (Check_Timer < diff)
         {
             if (m_creature->IsWithinDistInMap(m_creature->getVictim(), 5))
             {
                 DoCast(m_creature->getVictim(), SPELL_GLOBULE_EXPLOSION);
+
                 //despawn
                 m_creature->ForcedDespawn();
                 return;
             }
             Check_Timer = 500;
         }else Check_Timer -= diff;
+
         //do NOT deal any melee damage to the target.
     }
 };
+
 CreatureAI* GetAI_boss_morogrim_tidewalker(Creature* pCreature)
 {
     return new boss_morogrim_tidewalkerAI (pCreature);
@@ -294,13 +342,16 @@ CreatureAI* GetAI_mob_water_globule(Creature* pCreature)
 {
     return new mob_water_globuleAI (pCreature);
 }
+
 void AddSC_boss_morogrim_tidewalker()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_morogrim_tidewalker";
     newscript->GetAI = &GetAI_boss_morogrim_tidewalker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_water_globule";
     newscript->GetAI = &GetAI_mob_water_globule;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h
index 64ea603c15b..adfa39dc7e0 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h
@@ -1,6 +1,7 @@
 /* Copyright (C) 2006 - 2009 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
 enum LurkerEventState
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp
index f3a89b1a185..bd917a6e5c7 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp
@@ -13,23 +13,29 @@
  * along 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: 100
 SDComment: Instance Data Scripts and functions to acquire mobs and set encounter status for use in various Serpent Shrine Scripts
 SDCategory: Coilfang Resevoir, Serpent Shrine Cavern
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_serpent_shrine.h"
+
 #define MAX_ENCOUNTER 6
 #define SPELL_SCALDINGWATER 37284
 #define MOB_COILFANG_FRENZY 21508
 #define TRASHMOB_COILFANG_PRIESTESS 21220  //6*2
 #define TRASHMOB_COILFANG_SHATTERER 21301  //6*3
+
 #define MIN_KILLS 30
+
 //NOTE: there are 6 platforms
 //there should be 3 shatterers and 2 priestess on all platforms, total of 30 elites, else it won't work!
 //delete all other elites not on platforms! these mobs should only be on those platforms nowhere else.
+
 /* Serpentshrine cavern encounters:
 0 - Hydross The Unstable event
 1 - Leotheras The Blind Event
@@ -38,18 +44,24 @@ EndScriptData */
 4 - Morogrim Tidewalker Event
 5 - Lady Vashj Event
 */
+
 bool GOHello_go_bridge_console(Player* pPlayer, GameObject* pGo)
 {
     ScriptedInstance* pInstance = pGo->GetInstanceData();
+
     if (!pInstance)
         return false;
+
     if (pInstance)
         pInstance->SetData(DATA_CONTROL_CONSOLE, DONE);
+
     return true;
 }
+
 struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
 {
     instance_serpentshrine_cavern(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 LurkerBelow;
     uint64 Sharkkis;
     uint64 Tidalvess;
@@ -59,6 +71,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
     uint64 KarathressEvent_Starter;
     uint64 LeotherasTheBlind;
     uint64 LeotherasEventStarter;
+
     uint64 ControlConsole;
     uint64 BridgePart[3];
     uint32 StrangePool;
@@ -68,12 +81,15 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
     uint32 FrenzySpawnTimer;
     uint32 Water;
     uint32 TrashCount;
+
     bool ShieldGeneratorDeactivated[4];
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     bool DoSpawnFrenzy;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         LurkerBelow = 0;
         Sharkkis = 0;
         Tidalvess = 0;
@@ -83,12 +99,14 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
         KarathressEvent_Starter = 0;
         LeotherasTheBlind = 0;
         LeotherasEventStarter = 0;
+
         ControlConsole = 0;
         BridgePart[0] = 0;
         BridgePart[1] = 0;
         BridgePart[2] = 0;
         StrangePool = 0;
         Water = WATERSTATE_FRENZY;
+
         ShieldGeneratorDeactivated[0] = false;
         ShieldGeneratorDeactivated[1] = false;
         ShieldGeneratorDeactivated[2] = false;
@@ -99,13 +117,17 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
         FrenzySpawnTimer = 2000;
         DoSpawnFrenzy = false;
         TrashCount = 0;
+
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void Update (uint32 diff)
     {
         //Lurker Fishing event
@@ -124,6 +146,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
                 Water = WATERSTATE_SCALDING;
             else
                 Water = WATERSTATE_FRENZY;
+
             Map::PlayerList const &PlayerList = instance->GetPlayers();
             if (PlayerList.isEmpty())
                 return;
@@ -135,6 +158,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
                     {
                         if(Water == WATERSTATE_SCALDING)
                         {
+
                             if(!pPlayer->HasAura(SPELL_SCALDINGWATER))
                             {
                                 pPlayer->CastSpell(pPlayer, SPELL_SCALDINGWATER,true);
@@ -156,6 +180,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
                     if(!pPlayer->IsInWater())
                         pPlayer->RemoveAurasDueToSpell(SPELL_SCALDINGWATER);
                 }
+
             }
             WaterCheckTimer = 500;//remove stress from core
         }else WaterCheckTimer -= diff;
@@ -165,6 +190,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
             FrenzySpawnTimer = 2000;
         }else FrenzySpawnTimer -= diff;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -173,14 +199,17 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
                 ControlConsole = pGo->GetGUID();
                 pGo->setActive(true);
             break;
+
             case 184203:
                 BridgePart[0] = pGo->GetGUID();
                 pGo->setActive(true);
             break;
+
             case 184204:
                 BridgePart[1] = pGo->GetGUID();
                 pGo->setActive(true);
             break;
+
             case 184205:
                 BridgePart[2] = pGo->GetGUID();
                 pGo->setActive(true);
@@ -194,6 +223,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
                 break;
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -212,6 +242,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
                 break;*/
         }
     }
+
     void SetData64(uint32 type, uint64 data)
     {
         if (type == DATA_KARATHRESSEVENT_STARTER)
@@ -219,6 +250,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
         if (type == DATA_LEOTHERAS_EVENT_STARTER)
             LeotherasEventStarter = data;
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -235,6 +267,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -282,9 +315,11 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
         case DATA_SHIELDGENERATOR3:ShieldGeneratorDeactivated[2] = (data) ? true : false;   break;
         case DATA_SHIELDGENERATOR4:ShieldGeneratorDeactivated[3] = (data) ? true : false;   break;
         }
+
         if (data == DONE)
             SaveToDB();
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -322,6 +357,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
         }
         return NULL;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -333,23 +369,27 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
         std::istringstream stream(in);
         stream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3]
         >> m_auiEncounter[4] >> m_auiEncounter[5] >> TrashCount;
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)                // Do not load an encounter as "In Progress" - reset it instead.
                 m_auiEncounter[i] = NOT_STARTED;
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_serpentshrine_cavern(Map* pMap)
 {
     return new instance_serpentshrine_cavern(pMap);
 }
+
 void AddSC_instance_serpentshrine_cavern()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "instance_serpent_shrine";
     newscript->GetInstanceData = &GetInstanceData_instance_serpentshrine_cavern;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_bridge_console";
     newscript->pGOHello = &GOHello_go_bridge_console;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp
index eaba84be358..fc23f175931 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp
@@ -13,18 +13,22 @@
  * along with 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: 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                  -1545000
 #define SAY_AGGRO_1                 -1545001
 #define SAY_AGGRO_2                 -1545002
@@ -32,9 +36,11 @@ EndContentData */
 #define SAY_SLAY_1                  -1545004
 #define SAY_SLAY_2                  -1545005
 #define SAY_DEAD                    -1545006
+
 #define SPELL_LIGHTNING_CLOUD       25033
 #define SPELL_LUNG_BURST            31481
 #define SPELL_ENVELOPING_WINDS      31718
+
 struct TRINITY_DLL_DECL boss_thespiaAI : public ScriptedAI
 {
     boss_thespiaAI(Creature *c) : ScriptedAI(c)
@@ -42,39 +48,50 @@ struct TRINITY_DLL_DECL boss_thespiaAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance *pInstance;
     bool HeroicMode;
+
     uint32 LightningCloud_Timer;
     uint32 LungBurst_Timer;
     uint32 EnvelopingWinds_Timer;
+
     void Reset()
     {
         LightningCloud_Timer = 15000;
         LungBurst_Timer = 7000;
         EnvelopingWinds_Timer = 9000;
+
         if (pInstance)
             pInstance->SetData(TYPE_HYDROMANCER_THESPIA, NOT_STARTED);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEAD, m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_HYDROMANCER_THESPIA, DONE);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_HYDROMANCER_THESPIA, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //LightningCloud_Timer
         if (LightningCloud_Timer < diff)
         {
@@ -86,6 +103,7 @@ struct TRINITY_DLL_DECL boss_thespiaAI : public ScriptedAI
                     DoCast(target, SPELL_LIGHTNING_CLOUD);
             LightningCloud_Timer = 15000+rand()%10000;
         }else LightningCloud_Timer -=diff;
+
         //LungBurst_Timer
         if (LungBurst_Timer < diff)
         {
@@ -93,6 +111,7 @@ struct TRINITY_DLL_DECL boss_thespiaAI : public ScriptedAI
                 DoCast(target, SPELL_LUNG_BURST);
             LungBurst_Timer = 7000+rand()%5000;
         }else LungBurst_Timer -=diff;
+
         //EnvelopingWinds_Timer
         if (EnvelopingWinds_Timer < diff)
         {
@@ -104,49 +123,63 @@ struct TRINITY_DLL_DECL boss_thespiaAI : public ScriptedAI
                     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 TRINITY_DLL_DECL mob_coilfang_waterelementalAI : public ScriptedAI
 {
     mob_coilfang_waterelementalAI(Creature *c) : ScriptedAI(c) {}
+
     bool HeroicMode;
     uint32 WaterBoltVolley_Timer;
+
     void Reset()
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
         WaterBoltVolley_Timer = 3000+rand()%3000;
     }
+
     void EnterCombat(Unit *who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (WaterBoltVolley_Timer < diff)
         {
             DoCast(m_creature, HEROIC(SPELL_WATER_BOLT_VOLLEY, H_SPELL_WATER_BOLT_VOLLEY));
             WaterBoltVolley_Timer = 7000+rand()%5000;
         }else WaterBoltVolley_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_thespiaAI(Creature* pCreature)
 {
     return new boss_thespiaAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_coilfang_waterelementalAI(Creature* pCreature)
 {
     return new mob_coilfang_waterelementalAI (pCreature);
 }
+
 void AddSC_boss_hydromancer_thespia()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_hydromancer_thespia";
     newscript->GetAI = &GetAI_boss_thespiaAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_coilfang_waterelemental";
     newscript->GetAI = &GetAI_mob_coilfang_waterelementalAI;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp
index 14dd8c90afb..d24279be1ec 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp
@@ -13,18 +13,22 @@
  * along with 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               -1545007
 #define SAY_AGGRO_1                 -1545008
 #define SAY_AGGRO_2                 -1545009
@@ -34,11 +38,14 @@ EndContentData */
 #define SAY_SLAY_2                  -1545013
 #define SAY_SLAY_3                  -1545014
 #define SAY_DEATH                   -1545015
+
 #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 TRINITY_DLL_DECL boss_mekgineer_steamriggerAI : public ScriptedAI
 {
     boss_mekgineer_steamriggerAI(Creature *c) : ScriptedAI(c)
@@ -46,76 +53,95 @@ struct TRINITY_DLL_DECL boss_mekgineer_steamriggerAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance *pInstance;
     bool HeroicMode;
+
     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)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, DONE);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, IN_PROGRESS);
     }
+
     //no known summon spells exist
     void SummonMechanichs()
     {
         DoScriptText(SAY_MECHANICS, m_creature);
+
         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 (!UpdateVictim())
             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)
@@ -124,6 +150,7 @@ struct TRINITY_DLL_DECL boss_mekgineer_steamriggerAI : public ScriptedAI
                 Summon75 = true;
             }
         }
+
         if (!Summon50)
         {
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50)
@@ -132,6 +159,7 @@ struct TRINITY_DLL_DECL boss_mekgineer_steamriggerAI : public ScriptedAI
                 Summon50 = true;
             }
         }
+
         if (!Summon25)
         {
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25)
@@ -140,18 +168,23 @@ struct TRINITY_DLL_DECL boss_mekgineer_steamriggerAI : public ScriptedAI
                 Summon25 = true;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_mekgineer_steamrigger(Creature* pCreature)
 {
     return new boss_mekgineer_steamriggerAI (pCreature);
 }
+
 #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 TRINITY_DLL_DECL mob_steamrigger_mechanicAI : public ScriptedAI
 {
     mob_steamrigger_mechanicAI(Creature *c) : ScriptedAI(c)
@@ -159,19 +192,25 @@ struct TRINITY_DLL_DECL mob_steamrigger_mechanicAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool HeroicMode;
+
     uint32 Repair_Timer;
+
     void Reset()
     {
         Repair_Timer = 2000;
     }
+
     void MoveInLineOfSight(Unit* who)
     {
         //react only if attacked
         return;
     }
+
     void EnterCombat(Unit *who) { }
+
     void UpdateAI(const uint32 diff)
     {
         if (Repair_Timer < diff)
@@ -187,6 +226,7 @@ struct TRINITY_DLL_DECL mob_steamrigger_mechanicAI : public ScriptedAI
                         {
                             //m_creature->GetMotionMaster()->MovementExpired();
                             //m_creature->GetMotionMaster()->MoveIdle();
+
                             DoCast(m_creature,HEROIC(SPELL_REPAIR, H_SPELL_REPAIR), true);
                         }
                         Repair_Timer = 5000;
@@ -199,22 +239,28 @@ struct TRINITY_DLL_DECL mob_steamrigger_mechanicAI : public ScriptedAI
                 }
             }else Repair_Timer = 5000;
         }else Repair_Timer -= diff;
+
         if (!UpdateVictim())
             return;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_steamrigger_mechanic(Creature* pCreature)
 {
     return new mob_steamrigger_mechanicAI (pCreature);
 }
+
 void AddSC_boss_mekgineer_steamrigger()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_mekgineer_steamrigger";
     newscript->GetAI = &GetAI_boss_mekgineer_steamrigger;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_steamrigger_mechanic";
     newscript->GetAI = &GetAI_mob_steamrigger_mechanic;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp
index ce6302a04eb..f3a0be3bcfb 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp
@@ -13,14 +13,17 @@
  * along with 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                   -1545016
 #define SAY_REGEN                   -1545017
 #define SAY_AGGRO1                  -1545018
@@ -29,22 +32,28 @@ EndScriptData */
 #define SAY_SLAY1                   -1545021
 #define SAY_SLAY2                   -1545022
 #define SAY_DEATH                   -1545023
+
 #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 TRINITY_DLL_DECL mob_naga_distillerAI : public ScriptedAI
 {
     mob_naga_distillerAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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)
         {
@@ -55,15 +64,20 @@ struct TRINITY_DLL_DECL mob_naga_distillerAI : public ScriptedAI
             }
         }
     }
+
     void EnterCombat(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)
@@ -71,36 +85,45 @@ struct TRINITY_DLL_DECL mob_naga_distillerAI : public ScriptedAI
                 pInstance->SetData(TYPE_DISTILLER,DONE);
     }
 };
+
 struct TRINITY_DLL_DECL boss_warlord_kalithreshAI : public ScriptedAI
 {
     boss_warlord_kalithreshAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 Reflection_Timer;
     uint32 Impale_Timer;
     uint32 Rage_Timer;
     bool CanRage;
+
     void Reset()
     {
         Reflection_Timer = 10000;
         Impale_Timer = 7000+rand()%7000;
         Rage_Timer = 45000;
         CanRage = false;
+
         if (pInstance)
             pInstance->SetData(TYPE_WARLORD_KALITHRESH, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_WARLORD_KALITHRESH, IN_PROGRESS);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         //hack :(
@@ -109,16 +132,20 @@ struct TRINITY_DLL_DECL boss_warlord_kalithreshAI : public ScriptedAI
                 if (pInstance->GetData(TYPE_DISTILLER) == DONE)
                     m_creature->RemoveAurasDueToSpell(SPELL_WARLORDS_RAGE_PROC);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(TYPE_WARLORD_KALITHRESH, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Rage_Timer < diff)
         {
             if (Creature* distiller = me->FindNearestCreature(17954, 100.0f))
@@ -129,37 +156,46 @@ struct TRINITY_DLL_DECL boss_warlord_kalithreshAI : public ScriptedAI
             }
             Rage_Timer = 3000+rand()%15000;
         }else Rage_Timer -= diff;
+
         //Reflection_Timer
         if (Reflection_Timer < diff)
         {
             DoCast(m_creature, SPELL_SPELL_REFLECTION);
             Reflection_Timer = 15000+rand()%10000;
         }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* pCreature)
 {
     return new mob_naga_distillerAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_warlord_kalithresh(Creature* pCreature)
 {
     return new boss_warlord_kalithreshAI (pCreature);
 }
+
 void AddSC_boss_warlord_kalithresh()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_naga_distiller";
     newscript->GetAI = &GetAI_mob_naga_distiller;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_warlord_kalithresh";
     newscript->GetAI = &GetAI_boss_warlord_kalithresh;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/def_steam_vault.h b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/def_steam_vault.h
index 8ee0f69acb8..4b407ac4816 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/def_steam_vault.h
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/def_steam_vault.h
@@ -1,12 +1,15 @@
 /* Copyright (C) 2006 - 2009 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
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/instance_steam_vault.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/instance_steam_vault.cpp
index 4af96fb71b6..1ee00f2ef81 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/instance_steam_vault.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/steam_vault/instance_steam_vault.cpp
@@ -13,47 +13,63 @@
  * along 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: 80
 SDComment:  Instance script and access panel GO
 SDCategory: Coilfang Resevoir, The Steamvault
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_steam_vault.h"
+
 #define MAX_ENCOUNTER 4
+
 #define MAIN_CHAMBERS_DOOR      183049
 #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
 */
+
 bool GOHello_go_main_chambers_access_panel(Player* pPlayer, GameObject* pGo)
 {
     ScriptedInstance* pInstance = pGo->GetInstanceData();
+
     if (!pInstance)
         return false;
+
     if (pGo->GetEntry() == ACCESS_PANEL_HYDRO && (pInstance->GetData(TYPE_HYDROMANCER_THESPIA) == DONE || pInstance->GetData(TYPE_HYDROMANCER_THESPIA) == SPECIAL))
         pInstance->SetData(TYPE_HYDROMANCER_THESPIA,SPECIAL);
+
     if (pGo->GetEntry() == ACCESS_PANEL_MEK && (pInstance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == DONE || pInstance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == SPECIAL))
         pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER,SPECIAL);
+
     return true;
 }
+
 struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
 {
     instance_steam_vault(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     uint64 ThespiaGUID;
     uint64 MekgineerGUID;
     uint64 KalithreshGUID;
+
     uint64 MainChambersDoor;
     uint64 AccessPanelHydro;
     uint64 AccessPanelMek;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         ThespiaGUID = 0;
         MekgineerGUID = 0;
         KalithreshGUID = 0;
@@ -61,13 +77,16 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
         AccessPanelHydro = 0;
         AccessPanelMek = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
              if (m_auiEncounter[i] == IN_PROGRESS)
                  return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
           switch(pCreature->GetEntry())
@@ -77,6 +96,7 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
           case 17798: KalithreshGUID = pCreature->GetGUID(); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -86,6 +106,7 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
         case ACCESS_PANEL_MEK:   AccessPanelMek = pGo->GetGUID(); break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -94,8 +115,10 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
                 if (data == SPECIAL)
                 {
                     HandleGameObject(AccessPanelHydro, true);
+
                     if (GetData(TYPE_MEKGINEER_STEAMRIGGER) == SPECIAL)
                         HandleGameObject(MainChambersDoor, true);
+
                     debug_log("TSCR: Instance Steamvault: Access panel used.");
                 }
                 m_auiEncounter[0] = data;
@@ -104,8 +127,10 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
                 if (data == SPECIAL)
                 {
                     HandleGameObject(AccessPanelMek, true);
+
                     if (GetData(TYPE_HYDROMANCER_THESPIA) == SPECIAL)
                         HandleGameObject(MainChambersDoor, true);
+
                     debug_log("TSCR: Instance Steamvault: Access panel used.");
                 }
                 m_auiEncounter[1] = data;
@@ -117,9 +142,11 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
                 m_auiEncounter[3] = data;
                 break;
         }
+
         if (data == DONE || data == SPECIAL)
             SaveToDB();
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -135,6 +162,7 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 data)
     {
         switch(data)
@@ -148,6 +176,7 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
         }
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
@@ -162,6 +191,7 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
         }
         return NULL;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -172,23 +202,27 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
         OUT_LOAD_INST_DATA(in);
         std::istringstream stream(in);
         stream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)
                 m_auiEncounter[i] = NOT_STARTED;
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_steam_vault(Map* pMap)
 {
     return new instance_steam_vault(pMap);
 }
+
 void AddSC_instance_steam_vault()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "go_main_chambers_access_panel";
     newscript->pGOHello = &GOHello_go_main_chambers_access_panel;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "instance_steam_vault";
     newscript->GetInstanceData = &GetInstanceData_instance_steam_vault;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/underbog/boss_hungarfen.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/underbog/boss_hungarfen.cpp
index fb5570f4fd9..c8337023b78 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/underbog/boss_hungarfen.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/underbog/boss_hungarfen.cpp
@@ -13,38 +13,47 @@
  * along with 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 TRINITY_DLL_DECL boss_hungarfenAI : public ScriptedAI
 {
     boss_hungarfenAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     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 EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 20)
         {
             if (!Root)
@@ -53,20 +62,24 @@ struct TRINITY_DLL_DECL boss_hungarfenAI : public ScriptedAI
                 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();
     }
 };
@@ -74,35 +87,46 @@ CreatureAI* GetAI_boss_hungarfen(Creature* pCreature)
 {
     return new boss_hungarfenAI (pCreature);
 }
+
 #define SPELL_SPORE_CLOUD       34168
 #define SPELL_PUTRID_MUSHROOM   31690
 #define SPELL_GROW              31698
+
 struct TRINITY_DLL_DECL mob_underbog_mushroomAI : public ScriptedAI
 {
     mob_underbog_mushroomAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(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);
@@ -114,13 +138,16 @@ CreatureAI* GetAI_mob_underbog_mushroom(Creature* pCreature)
 {
     return new mob_underbog_mushroomAI (pCreature);
 }
+
 void AddSC_boss_hungarfen()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_hungarfen";
     newscript->GetAI = &GetAI_boss_hungarfen;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_underbog_mushroom";
     newscript->GetAI = &GetAI_mob_underbog_mushroom;
diff --git a/src/bindings/scripts/scripts/outland/coilfang_resevoir/underbog/boss_the_black_stalker.cpp b/src/bindings/scripts/scripts/outland/coilfang_resevoir/underbog/boss_the_black_stalker.cpp
index 44adb9b39bc..1b76860cf60 100644
--- a/src/bindings/scripts/scripts/outland/coilfang_resevoir/underbog/boss_the_black_stalker.cpp
+++ b/src/bindings/scripts/scripts/outland/coilfang_resevoir/underbog/boss_the_black_stalker.cpp
@@ -13,13 +13,16 @@
  * along with 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_black_stalker
 SD%Complete: 95
 SDComment: Timers may be incorrect
 SDCategory: Coilfang Resevoir, Underbog
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SPELL_LEVITATE             31704
 #define SPELL_SUSPENSION           31719
 #define SPELL_LEVITATION_PULSE     31701
@@ -27,13 +30,16 @@ EndScriptData */
 #define SPELL_CHAIN_LIGHTNING      31717
 #define SPELL_STATIC_CHARGE        31715
 #define SPELL_SUMMON_SPORE_STRIDER 38755
+
 #define ENTRY_SPORE_STRIDER        22299
+
 struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
 {
     boss_the_black_stalkerAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
     uint32 SporeStriders_Timer;
     uint32 Levitate_Timer;
@@ -44,6 +50,7 @@ struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
     bool InAir;
     uint32 check_Timer;
     std::list Striders;
+
     void Reset()
     {
         Levitate_Timer = 12000;
@@ -55,7 +62,9 @@ struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
         LevitatedTarget_Timer = 0;
         Striders.clear();
     }
+
     void EnterCombat(Unit *who) {}
+
     void JustSummoned(Creature *summon)
     {
         if (summon && summon->GetEntry() == ENTRY_SPORE_STRIDER)
@@ -68,16 +77,19 @@ struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
                     summon->AI()->AttackStart(m_creature->getVictim());
         }
     }
+
     void JustDied(Unit *who)
     {
-        for (std::list::iterator i = Striders.begin(); i != Striders.end(); ++i)
+        for(std::list::iterator i = Striders.begin(); i != Striders.end(); ++i)
             if (Creature *strider = Unit::GetCreature(*m_creature, *i))
                 strider->DisappearAndDie();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         // Evade if too far
         if (check_Timer < diff)
         {
@@ -90,12 +102,14 @@ struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
             }
             check_Timer = 1000;
         }else check_Timer -= diff;
+
         // Spore Striders
         if (HeroicMode && SporeStriders_Timer < diff)
         {
             DoCast(m_creature,SPELL_SUMMON_SPORE_STRIDER);
             SporeStriders_Timer = 10000+rand()%5000;
         }else SporeStriders_Timer -= diff;
+
         // Levitate
         if (LevitatedTarget)
         {
@@ -135,6 +149,7 @@ struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
             }
             Levitate_Timer = 12000+rand()%3000;
         }else Levitate_Timer -= diff;
+
         // Chain Lightning
         if (ChainLightning_Timer < diff)
         {
@@ -142,6 +157,7 @@ struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
                 DoCast(target, SPELL_CHAIN_LIGHTNING);
             ChainLightning_Timer = 7000;
         }else ChainLightning_Timer -= diff;
+
         // Static Charge
         if (StaticCharge_Timer < diff)
         {
@@ -149,16 +165,20 @@ struct TRINITY_DLL_DECL boss_the_black_stalkerAI : public ScriptedAI
                 DoCast(target, SPELL_STATIC_CHARGE);
             StaticCharge_Timer = 10000;
         }else StaticCharge_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_the_black_stalker(Creature* pCreature)
 {
     return new boss_the_black_stalkerAI (pCreature);
 }
+
 void AddSC_boss_the_black_stalker()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_the_black_stalker";
     newscript->GetAI = &GetAI_boss_the_black_stalker;
diff --git a/src/bindings/scripts/scripts/outland/gruuls_lair/boss_gruul.cpp b/src/bindings/scripts/scripts/outland/gruuls_lair/boss_gruul.cpp
index 3a5a61a00af..97de7ab4149 100644
--- a/src/bindings/scripts/scripts/outland/gruuls_lair/boss_gruul.cpp
+++ b/src/bindings/scripts/scripts/outland/gruuls_lair/boss_gruul.cpp
@@ -13,14 +13,17 @@
  * along with 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: 60
 SDComment: Ground Slam need further development (knock back effect and shatter effect must be added to mangos)
 SDCategory: Gruul's Lair
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_gruuls_lair.h"
+
 enum eEnums
 {
     SAY_AGGRO                   = -1565010,
@@ -32,32 +35,41 @@ enum eEnums
     SAY_SLAY2                   = -1565016,
     SAY_SLAY3                   = -1565017,
     SAY_DEATH                   = -1565018,
+
     EMOTE_GROW                  = -1565019,
+
     SPELL_GROWTH                = 36300,
     SPELL_CAVE_IN               = 36240,
     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)
     SPELL_REVERBERATION         = 36297,
     SPELL_SHATTER               = 33654,
+
     SPELL_SHATTER_EFFECT        = 33671,
     SPELL_HURTFUL_STRIKE        = 33813,
     SPELL_STONED                = 33652,                    //Spell is self cast by target
+
     SPELL_MAGNETIC_PULL         = 28337,
     SPELL_KNOCK_BACK            = 24199,                    //Knockback spell until correct implementation is made
 };
+
 struct TRINITY_DLL_DECL boss_gruulAI : public ScriptedAI
 {
     boss_gruulAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 m_uiGrowth_Timer;
     uint32 m_uiCaveIn_Timer;
     uint32 m_uiCaveIn_StaticTimer;
     uint32 m_uiGroundSlamTimer;
     uint32 m_uiHurtfulStrike_Timer;
     uint32 m_uiReverberation_Timer;
+
     bool m_bPerformingGroundSlam;
+
     void Reset()
     {
         m_uiGrowth_Timer= 30000;
@@ -67,28 +79,35 @@ struct TRINITY_DLL_DECL boss_gruulAI : public ScriptedAI
         m_bPerformingGroundSlam= false;
         m_uiHurtfulStrike_Timer= 8000;
         m_uiReverberation_Timer= 60000+45000;
+
         if (pInstance)
             pInstance->SetData(DATA_GRUULEVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_GRUULEVENT, IN_PROGRESS);
     }
+
     void KilledUnit()
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
         {
             pInstance->SetData(DATA_GRUULEVENT, DONE);
             pInstance->HandleGameObject(pInstance->GetData64(DATA_GRUULDOOR), true);         // Open the encounter door
         }
     }
+
     void SpellHitTarget(Unit* pTarget, const SpellEntry* pSpell)
     {
         //This to emulate effect1 (77) of SPELL_GROUND_SLAM, knock back to any direction
@@ -104,17 +123,21 @@ struct TRINITY_DLL_DECL boss_gruulAI : public ScriptedAI
                 }
             }
         }
+
         //this part should be in mangos
         if (pSpell->Id == SPELL_SHATTER)
         {
             //this spell must have custom handling in mangos, dealing damage based on distance
             pTarget->CastSpell(pTarget, SPELL_SHATTER_EFFECT, true);
+
             if (pTarget->HasAura(SPELL_STONED))
                 pTarget->RemoveAurasDueToSpell(SPELL_STONED);
+
             //clear this, if we are still performing
             if (m_bPerformingGroundSlam)
             {
                 m_bPerformingGroundSlam = false;
+
                 //and correct movement, if not already
                 if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE)
                 {
@@ -124,11 +147,13 @@ struct TRINITY_DLL_DECL boss_gruulAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         // Growth
         // Gruul can cast this spell up to 30 times
         if (m_uiGrowth_Timer < uiDiff)
@@ -139,14 +164,17 @@ struct TRINITY_DLL_DECL boss_gruulAI : public ScriptedAI
         }
         else
             m_uiGrowth_Timer -= uiDiff;
+
         if (m_bPerformingGroundSlam)
         {
             if (m_uiGroundSlamTimer < uiDiff)
             {
                 m_uiGroundSlamTimer =120000;
                 m_uiHurtfulStrike_Timer= 8000;
+
                 if (m_uiReverberation_Timer < 10000)     //Give a little time to the players to undo the damage from shatter
                     m_uiReverberation_Timer += 10000;
+
                 DoCast(m_creature, SPELL_SHATTER);
             }
             else
@@ -158,14 +186,17 @@ struct TRINITY_DLL_DECL boss_gruulAI : public ScriptedAI
             if (m_uiHurtfulStrike_Timer < uiDiff)
             {
                 Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO,1);
+
                 if (target && m_creature->IsWithinMeleeRange(m_creature->getVictim()))
                     DoCast(target,SPELL_HURTFUL_STRIKE);
                 else
                     DoCast(m_creature->getVictim(),SPELL_HURTFUL_STRIKE);
+
                 m_uiHurtfulStrike_Timer= 8000;
             }
             else
                 m_uiHurtfulStrike_Timer -= uiDiff;
+
             // Reverberation
             if (m_uiReverberation_Timer < uiDiff)
             {
@@ -174,36 +205,45 @@ struct TRINITY_DLL_DECL boss_gruulAI : public ScriptedAI
             }
             else
                 m_uiReverberation_Timer -= uiDiff;
+
             // Cave In
             if (m_uiCaveIn_Timer < uiDiff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                     DoCast(target,SPELL_CAVE_IN);
+
                 if (m_uiCaveIn_StaticTimer >= 4000)
                     m_uiCaveIn_StaticTimer -= 2000;
+
                     m_uiCaveIn_Timer = m_uiCaveIn_StaticTimer;
             }
             else
                 m_uiCaveIn_Timer -= uiDiff;
+
             // Ground Slam, Gronn Lord's Grasp, Stoned, Shatter
             if (m_uiGroundSlamTimer < uiDiff)
             {
                 m_creature->GetMotionMaster()->Clear();
                 m_creature->GetMotionMaster()->MoveIdle();
+
                 m_bPerformingGroundSlam= true;
                 m_uiGroundSlamTimer = 10000;
+
                 DoCast(m_creature, SPELL_GROUND_SLAM);
             }
             else
                 m_uiGroundSlamTimer -= uiDiff;
+
             DoMeleeAttackIfReady();
         }
     }
 };
+
 CreatureAI* GetAI_boss_gruul(Creature* pCreature)
 {
     return new boss_gruulAI (pCreature);
 }
+
 void AddSC_boss_gruul()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/gruuls_lair/boss_high_king_maulgar.cpp b/src/bindings/scripts/scripts/outland/gruuls_lair/boss_high_king_maulgar.cpp
index 148f7b1ff1d..849712ab336 100644
--- a/src/bindings/scripts/scripts/outland/gruuls_lair/boss_high_king_maulgar.cpp
+++ b/src/bindings/scripts/scripts/outland/gruuls_lair/boss_high_king_maulgar.cpp
@@ -13,14 +13,17 @@
  * along with 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: 90
 SDComment: Correct timers, after whirlwind melee attack bug, prayer of healing
 SDCategory: Gruul's Lair
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_gruuls_lair.h"
+
 #define SAY_AGGRO               -1565000
 #define SAY_ENRAGE              -1565001
 #define SAY_OGRE_DEATH1         -1565002
@@ -31,6 +34,7 @@ EndScriptData */
 #define SAY_SLAY2               -1565007
 #define SAY_SLAY3               -1565008
 #define SAY_DEATH               -1565009
+
 // High King Maulgar
 #define SPELL_ARCING_SMASH      39144
 #define SPELL_MIGHTY_BLOW       33230
@@ -39,70 +43,88 @@ EndScriptData */
 #define SPELL_ROAR              16508
 #define SPELL_FLURRY            33232
 #define SPELL_DUAL_WIELD        29651 //used in phase
+
 // Olm the Summoner
 #define SPELL_DARK_DECAY        33129
 #define SPELL_DEATH_COIL        33130
 #define SPELL_SUMMON_WFH        33131
+
 //Kiggler the Craed
 #define SPELL_GREATER_POLYMORPH     33173
 #define SPELL_LIGHTNING_BOLT        36152
 #define SPELL_ARCANE_SHOCK          33175
 #define SPELL_ARCANE_EXPLOSION      33237
+
 //Blindeye the Seer
 #define SPELL_GREATER_PW_SHIELD         33147
 #define SPELL_HEAL                      33144
 #define SPELL_PRAYER_OH                 33152
+
 //Krosh Firehand
 #define SPELL_GREATER_FIREBALL  33051
 #define SPELL_SPELLSHIELD       33054
 #define SPELL_BLAST_WAVE        33061
+
 bool CheckAllBossDied(ScriptedInstance* pInstance, Creature* m_creature)
 {
     if (!pInstance || !m_creature)
         return false;
+
     uint64 MaulgarGUID = 0;
     uint64 KigglerGUID = 0;
     uint64 BlindeyeGUID = 0;
     uint64 OlmGUID = 0;
     uint64 KroshGUID = 0;
+
     Creature* Maulgar = NULL;
     Creature* Kiggler = NULL;
     Creature* Blindeye = NULL;
     Creature* Olm = NULL;
     Creature* Krosh = NULL;
+
     MaulgarGUID = pInstance->GetData64(DATA_MAULGAR);
     KigglerGUID = pInstance->GetData64(DATA_KIGGLERTHECRAZED);
     BlindeyeGUID = pInstance->GetData64(DATA_BLINDEYETHESEER);
     OlmGUID = pInstance->GetData64(DATA_OLMTHESUMMONER);
     KroshGUID = pInstance->GetData64(DATA_KROSHFIREHAND);
+
     Maulgar = (Unit::GetCreature((*m_creature), MaulgarGUID));
     Kiggler = (Unit::GetCreature((*m_creature), KigglerGUID));
     Blindeye = (Unit::GetCreature((*m_creature), BlindeyeGUID));
     Olm = (Unit::GetCreature((*m_creature), OlmGUID));
     Krosh = (Unit::GetCreature((*m_creature), KroshGUID));
+
     if (!Maulgar || !Kiggler || !Blindeye || !Olm || !Krosh)
         return false;
+
     if (!Maulgar->isAlive() && !Kiggler->isAlive() && !Blindeye->isAlive() && !Olm->isAlive() && !Krosh->isAlive())
         return true;
+
     return false;
 }
+
 //High King Maulgar AI
 struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI
 {
     boss_high_king_maulgarAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
             Council[i] = 0;
     }
+
     ScriptedInstance* pInstance;
+
     uint32 ArcingSmash_Timer;
     uint32 MightyBlow_Timer;
     uint32 Whirlwind_Timer;
     uint32 Charging_Timer;
     uint32 Roar_Timer;
+
     bool Phase2;
+
     uint64 Council[4];
+
     void Reset()
     {
         ArcingSmash_Timer = 10000;
@@ -110,10 +132,13 @@ struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI
         Whirlwind_Timer = 30000;
         Charging_Timer = 0;
         Roar_Timer = 0;
+
         m_creature->CastSpell(m_creature, SPELL_DUAL_WIELD, false);
+
         Phase2 = false;
+
         Creature *pCreature = NULL;
-        for (uint8 i = 0; i < 4; ++i)
+        for(uint8 i = 0; i < 4; ++i)
         {
             if (Council[i])
             {
@@ -125,29 +150,36 @@ struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI
                 }
             }
         }
+
         //reset encounter
         if (pInstance)
             pInstance->SetData(DATA_MAULGAREVENT, NOT_STARTED);
     }
+
     void KilledUnit()
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (CheckAllBossDied(pInstance, m_creature))
             pInstance->SetData(DATA_MAULGAREVENT, DONE);
     }
+
        void AddDeath()
        {
             DoScriptText(RAND(SAY_OGRE_DEATH1,SAY_OGRE_DEATH2,SAY_OGRE_DEATH3,SAY_OGRE_DEATH4), m_creature);
        }
 
+
     void EnterCombat(Unit *who)
     {
         StartEvent(who);
     }
+
     void GetCouncil()
     {
         if(pInstance)
@@ -159,64 +191,79 @@ struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI
             Council[3] = pInstance->GetData64(DATA_KROSHFIREHAND);
         }
     }
+
     void StartEvent(Unit *who)
     {
         if (!pInstance)
             return;
+
         GetCouncil();
+
         DoScriptText(SAY_AGGRO, m_creature);
+
         pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID());
         pInstance->SetData(DATA_MAULGAREVENT, IN_PROGRESS);
+
         DoZoneInCombat();
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_MAULGAREVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK));
+
             if (target)
             {
                 AttackStart(target);
                 GetCouncil();
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_MAULGAREVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         //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;
             DoScriptText(SAY_ENRAGE, m_creature);
+
             m_creature->CastSpell(m_creature, SPELL_DUAL_WIELD, true);
             m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 0);
             m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0);
         }
+
         if (Phase2)
         {
             //Charging_Timer
@@ -231,6 +278,7 @@ struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI
                 }
                 Charging_Timer = 20000;
             }else Charging_Timer -= diff;
+
             //Intimidating Roar
             if (Roar_Timer < diff)
             {
@@ -238,9 +286,11 @@ struct TRINITY_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI
                 Roar_Timer = 40000+(rand()%10000);
             }else Roar_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Olm The Summoner AI
 struct TRINITY_DLL_DECL boss_olm_the_summonerAI : public ScriptedAI
 {
@@ -248,31 +298,39 @@ struct TRINITY_DLL_DECL boss_olm_the_summonerAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 DarkDecay_Timer;
     uint32 Summon_Timer;
        uint32 DeathCoil_Timer;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         DarkDecay_Timer = 10000;
         Summon_Timer = 15000;
         DeathCoil_Timer = 20000;
+
         //reset encounter
         if (pInstance)
             pInstance->SetData(DATA_MAULGAREVENT, NOT_STARTED);
     }
+
     void AttackStart(Unit* pWho)
     {
         if (!pWho)
             return;
+
         if (m_creature->Attack(pWho, true))
         {
             m_creature->AddThreat(pWho, 0.0f);
             m_creature->SetInCombatWith(pWho);
             pWho->SetInCombatWith(m_creature);
+
             m_creature->GetMotionMaster()->MoveChase(pWho, 30.0f);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -281,50 +339,60 @@ struct TRINITY_DLL_DECL boss_olm_the_summonerAI : public ScriptedAI
             pInstance->SetData(DATA_MAULGAREVENT, IN_PROGRESS);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
         {
             Creature *Maulgar = NULL;
             Maulgar = (Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_MAULGAR)));
+
             if (Maulgar)
                 CAST_AI(boss_high_king_maulgarAI, Maulgar->AI())->AddDeath();
+
             if (CheckAllBossDied(pInstance, m_creature))
                 pInstance->SetData(DATA_MAULGAREVENT, DONE);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_MAULGAREVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK));
+
             if (target)
             {
                 AttackStart(target);
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_MAULGAREVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         //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)
         {
             DoCast(m_creature, SPELL_SUMMON_WFH);
             Summon_Timer = 30000;
         }else Summon_Timer -= diff;
+
         //DeathCoil Timer /need correct timer
         if (DeathCoil_Timer < diff)
         {
@@ -335,9 +403,11 @@ struct TRINITY_DLL_DECL boss_olm_the_summonerAI : public ScriptedAI
             DeathCoil_Timer = 20000;
         }else DeathCoil_Timer -= diff;
 
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Kiggler The Crazed AI
 struct TRINITY_DLL_DECL boss_kiggler_the_crazedAI : public ScriptedAI
 {
@@ -345,21 +415,26 @@ struct TRINITY_DLL_DECL boss_kiggler_the_crazedAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 GreaterPolymorph_Timer;
     uint32 LightningBolt_Timer;
     uint32 ArcaneShock_Timer;
     uint32 ArcaneExplosion_Timer;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         GreaterPolymorph_Timer = 5000;
         LightningBolt_Timer = 10000;
         ArcaneShock_Timer = 20000;
         ArcaneExplosion_Timer = 30000;
+
         //reset encounter
         if (pInstance)
             pInstance->SetData(DATA_MAULGAREVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -368,67 +443,81 @@ struct TRINITY_DLL_DECL boss_kiggler_the_crazedAI : public ScriptedAI
             pInstance->SetData(DATA_MAULGAREVENT, IN_PROGRESS);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
         {
             Creature *Maulgar = NULL;
             Maulgar = (Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_MAULGAR)));
+
             if (Maulgar)
                 CAST_AI(boss_high_king_maulgarAI, Maulgar->AI())->AddDeath();
+
             if (CheckAllBossDied(pInstance, m_creature))
                 pInstance->SetData(DATA_MAULGAREVENT, DONE);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_MAULGAREVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK));
+
             if (target)
             {
                 AttackStart(target);
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_MAULGAREVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         //GreaterPolymorph_Timer
         if (GreaterPolymorph_Timer < diff)
         {
             Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
             if (target)
                 DoCast(target, SPELL_GREATER_POLYMORPH);
+
             GreaterPolymorph_Timer = 15000 + rand()%5000;
         }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 TRINITY_DLL_DECL boss_blindeye_the_seerAI : public ScriptedAI
 {
@@ -436,19 +525,24 @@ struct TRINITY_DLL_DECL boss_blindeye_the_seerAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     uint32 GreaterPowerWordShield_Timer;
     uint32 Heal_Timer;
     uint32 PrayerofHealing_Timer;
+
     ScriptedInstance* pInstance;
+
     void Reset()
     {
         GreaterPowerWordShield_Timer = 5000;
         Heal_Timer = 25000 + rand()%15000;
         PrayerofHealing_Timer = 45000 + rand()%10000;
+
         //reset encounter
         if (pInstance)
             pInstance->SetData(DATA_MAULGAREVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -457,59 +551,71 @@ struct TRINITY_DLL_DECL boss_blindeye_the_seerAI : public ScriptedAI
             pInstance->SetData(DATA_MAULGAREVENT, IN_PROGRESS);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
         {
             Creature *Maulgar = NULL;
             Maulgar = (Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_MAULGAR)));
+
             if (Maulgar)
                 CAST_AI(boss_high_king_maulgarAI, Maulgar->AI())->AddDeath();
+
             if (CheckAllBossDied(pInstance, m_creature))
                 pInstance->SetData(DATA_MAULGAREVENT, DONE);
         }
     }
+
      void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_MAULGAREVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK));
+
             if (target)
             {
                 AttackStart(target);
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_MAULGAREVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         //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 = 15000 + rand()%25000;
         }else Heal_Timer -= diff;
+
         //PrayerofHealing_Timer
         if (PrayerofHealing_Timer < diff)
         {
             DoCast(m_creature, SPELL_PRAYER_OH);
             PrayerofHealing_Timer = 35000 + rand()%15000;
         }else PrayerofHealing_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Krosh Firehand AI
 struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI
 {
@@ -517,19 +623,24 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI
     {
         pInstance = c->GetInstanceData();
     }
+
     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, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
@@ -538,44 +649,53 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI
             pInstance->SetData(DATA_MAULGAREVENT, IN_PROGRESS);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
         {
             Creature *Maulgar = NULL;
             Maulgar = (Unit::GetCreature((*m_creature), pInstance->GetData64(DATA_MAULGAR)));
+
             if (Maulgar)
                 CAST_AI(boss_high_king_maulgarAI, Maulgar->AI())->AddDeath();
+
             if (CheckAllBossDied(pInstance, m_creature))
                 pInstance->SetData(DATA_MAULGAREVENT, DONE);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Only if not incombat check if the event is started
         if (!m_creature->isInCombat() && pInstance && pInstance->GetData(DATA_MAULGAREVENT))
         {
             Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK));
+
             if (target)
             {
                 AttackStart(target);
             }
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //someone evaded!
         if (pInstance && !pInstance->GetData(DATA_MAULGAREVENT))
         {
             EnterEvadeMode();
             return;
         }
+
         //GreaterFireball_Timer
         if (GreaterFireball_Timer < diff || m_creature->IsWithinDist(m_creature->getVictim(), 30))
         {
             DoCast(m_creature->getVictim(), SPELL_GREATER_FIREBALL);
             GreaterFireball_Timer = 2000;
         }else GreaterFireball_Timer -= diff;
+
         //SpellShield_Timer
         if (SpellShield_Timer < diff)
         {
@@ -583,13 +703,14 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI
             DoCast(m_creature->getVictim(), SPELL_SPELLSHIELD);
             SpellShield_Timer = 30000;
         }else SpellShield_Timer -= diff;
+
         //BlastWave_Timer
         if (BlastWave_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)
+            for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
             {
                 target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                                                             //15 yard radius minimum
@@ -599,51 +720,63 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI
             }
             if (target_list.size())
                 target = *(target_list.begin()+rand()%target_list.size());
+
             m_creature->InterruptNonMeleeSpells(false);
                        DoCast(target, SPELL_BLAST_WAVE);
             BlastWave_Timer = 60000;
         }else BlastWave_Timer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_high_king_maulgar(Creature* pCreature)
 {
     return new boss_high_king_maulgarAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_olm_the_summoner(Creature* pCreature)
 {
     return new boss_olm_the_summonerAI (pCreature);
 }
+
 CreatureAI *GetAI_boss_kiggler_the_crazed(Creature* pCreature)
 {
     return new boss_kiggler_the_crazedAI (pCreature);
 }
+
 CreatureAI *GetAI_boss_blindeye_the_seer(Creature* pCreature)
 {
     return new boss_blindeye_the_seerAI (pCreature);
 }
+
 CreatureAI *GetAI_boss_krosh_firehand(Creature* pCreature)
 {
     return new boss_krosh_firehandAI (pCreature);
 }
+
 void AddSC_boss_high_king_maulgar()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_high_king_maulgar";
     newscript->GetAI = &GetAI_boss_high_king_maulgar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_kiggler_the_crazed";
     newscript->GetAI = &GetAI_boss_kiggler_the_crazed;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_blindeye_the_seer";
     newscript->GetAI = &GetAI_boss_blindeye_the_seer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_olm_the_summoner";
     newscript->GetAI = &GetAI_boss_olm_the_summoner;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_krosh_firehand";
     newscript->GetAI = &GetAI_boss_krosh_firehand;
diff --git a/src/bindings/scripts/scripts/outland/gruuls_lair/def_gruuls_lair.h b/src/bindings/scripts/scripts/outland/gruuls_lair/def_gruuls_lair.h
index f2ffa525311..7003dcb1e26 100644
--- a/src/bindings/scripts/scripts/outland/gruuls_lair/def_gruuls_lair.h
+++ b/src/bindings/scripts/scripts/outland/gruuls_lair/def_gruuls_lair.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
@@ -13,6 +15,7 @@
 #define DATA_MAULGARDOOR               8
 #define DATA_GRUULDOOR                 9
 #define DATA_MAULGAR                  10
+
 #define ERROR_INST_DATA "TSCR Error: Instance Data not set properly for Gruul's Lair instance (map 565). Encounters will be buggy."
 #endif
 
diff --git a/src/bindings/scripts/scripts/outland/gruuls_lair/instance_gruuls_lair.cpp b/src/bindings/scripts/scripts/outland/gruuls_lair/instance_gruuls_lair.cpp
index b52887990db..0ac5cbcaf7a 100644
--- a/src/bindings/scripts/scripts/outland/gruuls_lair/instance_gruuls_lair.cpp
+++ b/src/bindings/scripts/scripts/outland/gruuls_lair/instance_gruuls_lair.cpp
@@ -13,49 +13,63 @@
  * along 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 MAX_ENCOUNTER 2
+
 /* Gruuls Lair encounters:
 1 - High King Maulgar event
 2 - Gruul event
 */
+
 struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
 {
     instance_gruuls_lair(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     uint64 MaulgarEvent_Tank;
     uint64 KigglerTheCrazed;
     uint64 BlindeyeTheSeer;
     uint64 OlmTheSummoner;
     uint64 KroshFirehand;
     uint64 Maulgar;
+
     uint64 MaulgarDoor;
     uint64 GruulDoor;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         MaulgarEvent_Tank = 0;
         KigglerTheCrazed = 0;
         BlindeyeTheSeer = 0;
         OlmTheSummoner = 0;
         KroshFirehand = 0;
         Maulgar = 0;
+
         MaulgarDoor = 0;
         GruulDoor = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -67,6 +81,7 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
             case 18831: Maulgar = pCreature->GetGUID();          break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -78,11 +93,13 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
             case 184662: GruulDoor = pGo->GetGUID(); break;
         }
     }
+
     void SetData64(uint32 type, uint64 data)
     {
         if (type == DATA_MAULGAREVENT_TANK)
             MaulgarEvent_Tank = data;
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -98,6 +115,7 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -110,9 +128,11 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
                 else HandleGameObject(GruulDoor, true);
                 m_auiEncounter[1] = data; break;
         }
+
         if (data == DONE)
             SaveToDB();
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -122,6 +142,7 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
         }
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
@@ -134,8 +155,10 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
             OUT_SAVE_INST_DATA_COMPLETE;
             return out;
         }
+
         return NULL;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -143,19 +166,22 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
         std::istringstream stream(in);
         stream >> m_auiEncounter[0] >> m_auiEncounter[1];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)                // Do not load an encounter as "In Progress" - reset it instead.
                 m_auiEncounter[i] = NOT_STARTED;
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_gruuls_lair(Map* pMap)
 {
     return new instance_gruuls_lair(pMap);
 }
+
 void AddSC_instance_gruuls_lair()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_broggok.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_broggok.cpp
index 3ee5c895546..d359c9c25f7 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_broggok.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_broggok.cpp
@@ -13,32 +13,41 @@
  * along with 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: 70
 SDComment: pre-event not made
 SDCategory: Hellfire Citadel, Blood Furnace
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_blood_furnace.h"
+
 enum eEnums
 {
     SAY_AGGRO               = -1542008,
+
     SPELL_SLIME_SPRAY       = 30913,
     SPELL_POISON_CLOUD      = 30916,
     SPELL_POISON_BOLT       = 30917,
+
     SPELL_POISON            = 30914
 };
+
 struct TRINITY_DLL_DECL boss_broggokAI : public ScriptedAI
 {
     boss_broggokAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 AcidSpray_Timer;
     uint32 PoisonSpawn_Timer;
     uint32 PoisonBolt_Timer;
+
     void Reset()
     {
         AcidSpray_Timer = 10000;
@@ -50,6 +59,7 @@ struct TRINITY_DLL_DECL boss_broggokAI : public ScriptedAI
             pInstance->HandleGameObject(pInstance->GetData64(DATA_DOOR4), true);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
@@ -59,6 +69,7 @@ struct TRINITY_DLL_DECL boss_broggokAI : public ScriptedAI
             pInstance->HandleGameObject(pInstance->GetData64(DATA_DOOR4), false);
         }
     }
+
     void JustSummoned(Creature *summoned)
     {
         summoned->setFaction(16);
@@ -66,27 +77,33 @@ struct TRINITY_DLL_DECL boss_broggokAI : public ScriptedAI
         summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         summoned->CastSpell(summoned,SPELL_POISON,false,0,0,m_creature->GetGUID());
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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();
     }
+
     void JustDied(Unit* who)
     {
         if (pInstance)
@@ -96,11 +113,14 @@ struct TRINITY_DLL_DECL boss_broggokAI : public ScriptedAI
             pInstance->SetData(TYPE_BROGGOK_EVENT, DONE);
         }
     }
+
 };
+
 CreatureAI* GetAI_boss_broggok(Creature* pCreature)
 {
     return new boss_broggokAI (pCreature);
 }
+
 void AddSC_boss_broggok()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp
index fb782f94322..d47c3eecceb 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp
@@ -13,18 +13,22 @@
  * along with 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: 100
 SDComment:
 SDCategory: Hellfire Citadel, Blood Furnace
 EndScriptData */
+
 /* ContentData
 boss_kelidan_the_breaker
 mob_shadowmoon_channeler
 EndContentData */
+
 #include "precompiled.h"
 #include "def_blood_furnace.h"
+
 enum eKelidan
 {
     SAY_WAKE                    = -1542000,
@@ -35,17 +39,23 @@ enum eKelidan
     SAY_KILL_2                  = -1542005,
     SAY_NOVA                    = -1542006,
     SAY_DIE                     = -1542007,
+
     SPELL_CORRUPTION            = 30938,
     SPELL_EVOCATION             = 30935,
+
     SPELL_FIRE_NOVA             = 33132,
     H_SPELL_FIRE_NOVA           = 37371,
+
     SPELL_SHADOW_BOLT_VOLLEY    = 28599,
     H_SPELL_SHADOW_BOLT_VOLLEY  = 40070,
+
     SPELL_BURNING_NOVA          = 30940,
     SPELL_VORTEX                = 37370,
+
     ENTRY_KELIDAN               = 17377,
     ENTRY_CHANNELER             = 17653
 };
+
 const float ShadowmoonChannelers[5][4]=
 {
     {302,-87,-24.4,0.157},
@@ -54,17 +64,20 @@ const float ShadowmoonChannelers[5][4]=
     {344,-103.5,-24.5,2.356},
     {316,-109,-24.6,1.257}
 };
+
 struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
 {
     boss_kelidan_the_breakerAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
-        for (uint8 i=0; i<5; ++i)
+        for(uint8 i=0; i<5; ++i)
             Channelers[i] = 0;
     }
+
     ScriptedInstance* pInstance;
     bool HeroicMode;
+
     uint32 ShadowVolley_Timer;
     uint32 BurningNova_Timer;
     uint32 Firenova_Timer;
@@ -73,6 +86,7 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
     bool Firenova;
     bool addYell;
     uint64 Channelers[5];
+
     void Reset()
     {
         ShadowVolley_Timer = 1000;
@@ -85,6 +99,7 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(TYPE_KELIDAN_THE_BREAKER_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_WAKE, m_creature);
@@ -94,12 +109,15 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
         if (pInstance)
             pInstance->SetData(TYPE_KELIDAN_THE_BREAKER_EVENT, IN_PROGRESS);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (rand()%2)
             return;
+
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void ChannelerEngaged(Unit* who)
     {
         if (who && !addYell)
@@ -107,30 +125,33 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
             addYell = true;
             DoScriptText(RAND(SAY_ADD_AGGRO_1,SAY_ADD_AGGRO_2,SAY_ADD_AGGRO_3), m_creature);
         }
-        for (uint8 i=0; i<5; ++i)
+        for(uint8 i=0; i<5; ++i)
         {
             Creature *channeler = Unit::GetCreature(*m_creature, Channelers[i]);
             if (who && channeler && !channeler->isInCombat())
                 channeler->AI()->AttackStart(who);
         }
     }
+
     void ChannelerDied(Unit* killer)
     {
-        for (uint8 i=0; i<5; ++i)
+        for(uint8 i=0; i<5; ++i)
         {
             Creature *channeler = Unit::GetCreature(*m_creature, Channelers[i]);
             if (channeler && channeler->isAlive())
                 return;
         }
+
         if (killer)
             m_creature->AI()->AttackStart(killer);
     }
+
     uint64 GetChanneled(Creature *channeler1)
     {
         SummonChannelers();
         if (!channeler1) return NULL;
         uint8 i;
-        for (i=0; i<5; ++i)
+        for(i=0; i<5; ++i)
         {
             Creature *channeler = Unit::GetCreature(*m_creature, Channelers[i]);
             if (channeler && channeler->GetGUID() == channeler1->GetGUID())
@@ -138,9 +159,10 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
         }
         return Channelers[(i+2)%5];
     }
+
     void SummonChannelers()
     {
-        for (uint8 i=0; i<5; ++i)
+        for(uint8 i=0; i<5; ++i)
         {
             Creature *channeler = Unit::GetCreature(*m_creature, Channelers[i]);
             if (!channeler || channeler->isDead())
@@ -151,15 +173,19 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
                 Channelers[i] = 0;
         }
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DIE, m_creature);
+
         if (!pInstance)
             return;
+
         pInstance->SetData(TYPE_KELIDAN_THE_BREAKER_EVENT, DONE);
         pInstance->HandleGameObject(pInstance->GetData64(DATA_DOOR1), true);
         pInstance->HandleGameObject(pInstance->GetData64(DATA_DOOR6), true);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -172,6 +198,7 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
             }else check_Timer -= diff;
             return;
         }
+
         if (Firenova)
         {
             if (Firenova_Timer < diff)
@@ -180,23 +207,29 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
                 Firenova = false;
                 ShadowVolley_Timer = 2000;
             }else Firenova_Timer -=diff;
+
             return;
         }
+
         if (ShadowVolley_Timer < diff)
         {
             DoCast(m_creature, HEROIC(SPELL_SHADOW_BOLT_VOLLEY, H_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);
+
             DoScriptText(SAY_NOVA, m_creature);
+
             if (SpellEntry *nova = GET_SPELL(SPELL_BURNING_NOVA))
             {
                 uint8 eff_mask=0;
@@ -208,39 +241,51 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
                 }
                 m_creature->AddAura(new Aura(nova, eff_mask, me, me, me));
             }
+
             if (HeroicMode)
                 DoTeleportAll(m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),m_creature->GetOrientation());
+
             BurningNova_Timer = 20000+rand()%8000;
             Firenova_Timer= 5000;
             Firenova = true;
         }else BurningNova_Timer -=diff;
+
         DoMeleeAttackIfReady();
     }
+
 };
+
 CreatureAI* GetAI_boss_kelidan_the_breaker(Creature* pCreature)
 {
     return new boss_kelidan_the_breakerAI (pCreature);
 }
+
 /*######
 ## mob_shadowmoon_channeler
 ######*/
+
 enum eShadowmoon
 {
     SPELL_SHADOW_BOLT       = 12739,
     H_SPELL_SHADOW_BOLT     = 15472,
+
     SPELL_MARK_OF_SHADOW    = 30937,
     SPELL_CHANNELING        = 39123
 };
+
 struct TRINITY_DLL_DECL mob_shadowmoon_channelerAI : public ScriptedAI
 {
     mob_shadowmoon_channelerAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
+
     uint32 ShadowBolt_Timer;
     uint32 MarkOfShadow_Timer;
     uint32 check_Timer;
+
     void Reset()
     {
         ShadowBolt_Timer = 1000+rand()%1000;
@@ -249,6 +294,7 @@ struct TRINITY_DLL_DECL mob_shadowmoon_channelerAI : public ScriptedAI
         if (m_creature->IsNonMeleeSpellCasted(false))
             m_creature->InterruptNonMeleeSpells(true);
     }
+
     void EnterCombat(Unit* who)
     {
         if (Creature *Kelidan = me->FindNearestCreature(ENTRY_KELIDAN, 100))
@@ -257,11 +303,13 @@ struct TRINITY_DLL_DECL mob_shadowmoon_channelerAI : public ScriptedAI
             m_creature->InterruptNonMeleeSpells(true);
         DoStartMovement(who);
     }
+
     void JustDied(Unit* Killer)
     {
        if (Creature *Kelidan = me->FindNearestCreature(ENTRY_KELIDAN, 100))
            CAST_AI(boss_kelidan_the_breakerAI, Kelidan->AI())->ChannelerDied(Killer);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -279,31 +327,38 @@ struct TRINITY_DLL_DECL mob_shadowmoon_channelerAI : public ScriptedAI
             }else check_Timer -= diff;
             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(), HEROIC(SPELL_SHADOW_BOLT, H_SPELL_SHADOW_BOLT));
             ShadowBolt_Timer = 5000+rand()%1000;
         }else ShadowBolt_Timer -=diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_shadowmoon_channeler(Creature* pCreature)
 {
     return new mob_shadowmoon_channelerAI (pCreature);
 }
+
 void AddSC_boss_kelidan_the_breaker()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_kelidan_the_breaker";
     newscript->GetAI = &GetAI_boss_kelidan_the_breaker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_shadowmoon_channeler";
     newscript->GetAI = &GetAI_mob_shadowmoon_channeler;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_the_maker.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_the_maker.cpp
index 44fa1ea95ff..9c19888c92c 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_the_maker.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/boss_the_maker.cpp
@@ -13,14 +13,17 @@
  * along with 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"
 #include "def_blood_furnace.h"
+
 enum eEnums
 {
     SAY_AGGRO_1                 = -1542009,
@@ -29,91 +32,116 @@ enum eEnums
     SAY_KILL_1                  = -1542012,
     SAY_KILL_2                  = -1542013,
     SAY_DIE                     = -1542014,
+
     SPELL_ACID_SPRAY            = 38153,                    // heroic 38973 ??? 38153
     SPELL_EXPLODING_BREAKER     = 30925,
     SPELL_KNOCKDOWN             = 20276,
     SPELL_DOMINATION            = 25772                     // ???
 };
+
 struct TRINITY_DLL_DECL boss_the_makerAI : public ScriptedAI
 {
     boss_the_makerAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 AcidSpray_Timer;
     uint32 ExplodingBreaker_Timer;
     uint32 Domination_Timer;
     uint32 Knockdown_Timer;
+
     void Reset()
     {
         AcidSpray_Timer = 15000;
         ExplodingBreaker_Timer = 6000;
         Domination_Timer = 120000;
         Knockdown_Timer = 10000;
+
         if (!pInstance)
             return;
+
         pInstance->SetData(TYPE_THE_MAKER_EVENT, NOT_STARTED);
         pInstance->HandleGameObject(pInstance->GetData64(DATA_DOOR2), true);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
+
         if (!pInstance)
             return;
+
         pInstance->SetData(TYPE_THE_MAKER_EVENT, IN_PROGRESS);
         pInstance->HandleGameObject(pInstance->GetData64(DATA_DOOR2), false);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DIE, m_creature);
+
         if (!pInstance)
             return;
+
         pInstance->SetData(TYPE_THE_MAKER_EVENT, DONE);
         pInstance->HandleGameObject(pInstance->GetData64(DATA_DOOR2), true);
         pInstance->HandleGameObject(pInstance->GetData64(DATA_DOOR3), true);
 
+
      }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (AcidSpray_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_ACID_SPRAY);
             AcidSpray_Timer = 15000+rand()%8000;
         }else AcidSpray_Timer -=diff;
+
         if (ExplodingBreaker_Timer < diff)
         {
             if (Unit* 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* pCreature)
 {
     return new boss_the_makerAI (pCreature);
 }
+
 void AddSC_boss_the_maker()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/def_blood_furnace.h b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/def_blood_furnace.h
index 9774cb7a00c..b845c66823f 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/def_blood_furnace.h
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/def_blood_furnace.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_BLOOD_FURNACE_H
 #define DEF_BLOOD_FURNACE_H
+
 #define DATA_THE_MAKER                  1
 #define DATA_BROGGOK                    2
 #define DATA_KELIDAN_THE_MAKER          3
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp
index 4e980eec361..5a18ded0c08 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp
@@ -13,29 +13,36 @@
  * along 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_Blood_Furnace
 SD%Complete: 85
 SDComment:
 SDCategory: Hellfire Citadel, Blood Furnace
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_blood_furnace.h"
+
 #define ENTRY_SEWER1                 181823
 #define ENTRY_SEWER2                 181766
 #define MAX_ENCOUNTER                   3
+
 struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
 {
     instance_blood_furnace(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 The_MakerGUID;
     uint64 BroggokGUID;
     uint64 Kelidan_The_BreakerGUID;
+
     uint64 Door1GUID;
     uint64 Door2GUID;
     uint64 Door3GUID;
     uint64 Door4GUID;
     uint64 Door5GUID;
     uint64 Door6GUID;
+
     uint64 PrisonCell1GUID;
     uint64 PrisonCell2GUID;
     uint64 PrisonCell3GUID;
@@ -44,20 +51,25 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
     uint64 PrisonCell6GUID;
     uint64 PrisonCell7GUID;
     uint64 PrisonCell8GUID;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     std::string str_data;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         The_MakerGUID = 0;
         BroggokGUID = 0;
         Kelidan_The_BreakerGUID = 0;
+
         Door1GUID = 0;
         Door2GUID = 0;
         Door3GUID = 0;
         Door4GUID = 0;
         Door5GUID = 0;
         Door6GUID = 0;
+
         PrisonCell1GUID = 0;
         PrisonCell2GUID = 0;
         PrisonCell3GUID = 0;
@@ -68,10 +80,12 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
         PrisonCell8GUID = 0;
     }
 
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         if (!add)
             return;
+
         switch(pCreature->GetEntry())
         {
              case 17381: The_MakerGUID = pCreature->GetGUID(); break;
@@ -79,10 +93,12 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
              case 17377: Kelidan_The_BreakerGUID = pCreature->GetGUID(); break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         if (!add)
             return;
+
      if (pGo->GetEntry() == 181766)                //Final exit door
          Door1GUID = pGo->GetGUID();
      if (pGo->GetEntry() == 181811)               //The Maker Front door
@@ -95,6 +111,7 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
          Door5GUID = pGo->GetGUID();
      if (pGo->GetEntry() == 181823)               //Kelidan exit door
          Door6GUID = pGo->GetGUID();
+
      if (pGo->GetEntry() == 181813)               //The Maker prison cell front right
          PrisonCell1GUID = pGo->GetGUID();
      if (pGo->GetEntry() == 181814)               //The Maker prison cell back right
@@ -112,6 +129,7 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
      if (pGo->GetEntry() == 181817)               //Broggok prison cell back left
          PrisonCell8GUID = pGo->GetGUID();
     }
+
     uint64 GetData64(uint32 data)
     {
         switch(data)
@@ -134,8 +152,10 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
              case DATA_PRISON_CELL7:         return PrisonCell7GUID;
              case DATA_PRISON_CELL8:         return PrisonCell8GUID;
         }
+
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
          switch(data)
@@ -144,16 +164,21 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
              case TYPE_BROGGOK_EVENT:               m_auiEncounter[1] = data;     break;
              case TYPE_KELIDAN_THE_BREAKER_EVENT:   m_auiEncounter[2] = data;     break;
          }
+
         if (data == DONE)
         {
             OUT_SAVE_INST_DATA;
+
             std::ostringstream saveStream;
             saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2];
+
             str_data = saveStream.str();
+
             SaveToDB();
             OUT_SAVE_INST_DATA_COMPLETE;
         }
     }
+
     uint32 GetData(uint32 data)
     {
         switch(data)
@@ -162,12 +187,15 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
             case TYPE_BROGGOK_EVENT:               return m_auiEncounter[1];
             case TYPE_KELIDAN_THE_BREAKER_EVENT:   return m_auiEncounter[2];
         }
+
         return 0;
     }
+
     const char* Save()
     {
         return str_data.c_str();
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -175,20 +203,26 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance
             OUT_LOAD_INST_DATA_FAIL;
             return;
         }
+
         OUT_LOAD_INST_DATA(in);
+
         std::istringstream loadStream(in);
         loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS || m_auiEncounter[i] == FAIL)
                 m_auiEncounter[i] = NOT_STARTED;
+
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
 
+
 InstanceData* GetInstanceData_instance_blood_furnace(Map* pMap)
 {
     return new instance_blood_furnace(pMap);
 }
+
 void AddSC_instance_blood_furnace()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp
index f2ab659f93c..d1ec8b79b57 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp
@@ -13,13 +13,16 @@
  * along with 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: 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 SAY_AGGRO_1                 -1543009
 #define SAY_AGGRO_2                 -1543010
 #define SAY_AGGRO_3                 -1543011
@@ -28,6 +31,7 @@ EndScriptData */
 #define SAY_KILL_1                  -1543014
 #define SAY_DIE                     -1543015
 #define SAY_WIPE                    -1543016
+
 #define SPELL_ORBITAL_STRIKE        30637
 #define SPELL_SHADOW_WHIP           30638
 #define SPELL_TREACHEROUS_AURA      30695
@@ -36,6 +40,7 @@ EndScriptData */
 #define SPELL_SHADOW_BOLT           30686
 #define H_SPELL_SHADOW_BOLT         39297
 #define SPELL_SUMMON_FIENDISH_HOUND 30707
+
 struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI
 {
     boss_omor_the_unscarredAI(Creature *c) : ScriptedAI(c)
@@ -43,7 +48,9 @@ struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI
         SetCombatMovement(false);
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
+
     uint32 OrbitalStrike_Timer;
     uint32 ShadowWhip_Timer;
     uint32 Aura_Timer;
@@ -53,9 +60,11 @@ struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI
     uint32 SummonedCount;
     uint64 PlayerGUID;
     bool CanPullBack;
+
     void Reset()
     {
         DoScriptText(SAY_WIPE, m_creature);
+
         OrbitalStrike_Timer = 25000;
         ShadowWhip_Timer = 2000;
         Aura_Timer = 10000;
@@ -66,31 +75,40 @@ struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI
         PlayerGUID = 0;
         CanPullBack = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (rand()%2)
             return;
+
         DoScriptText(SAY_KILL_1, m_creature);
     }
+
     void JustSummoned(Creature* summoned)
     {
         DoScriptText(SAY_SUMMON, m_creature);
+
         if (Unit* random = SelectUnit(SELECT_TARGET_RANDOM,0))
             summoned->AI()->AttackStart(random);
+
         ++SummonedCount;
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DIE, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //only two may be wrong, perhaps increase timer and spawn periodically instead.
         if (SummonedCount < 2)
         {
@@ -101,6 +119,7 @@ struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI
                 Summon_Timer = 15000+rand()%15000;
             }else Summon_Timer -= diff;
         }
+
         if (CanPullBack)
         {
             if (ShadowWhip_Timer < diff)
@@ -125,15 +144,18 @@ struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI
             if (m_creature->IsWithinMeleeRange(m_creature->getVictim()))
                 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)
@@ -142,35 +164,43 @@ struct TRINITY_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI
                 DemonicShield_Timer = 15000;
             }else DemonicShield_Timer -= diff;
         }
+
         if (Aura_Timer < diff)
         {
             DoScriptText(SAY_CURSE, m_creature);
+
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
             {
                 DoCast(target,HEROIC(SPELL_TREACHEROUS_AURA, H_SPELL_BANE_OF_TREACHERY));
                 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();
+
                 DoCast(target,HEROIC(SPELL_SHADOW_BOLT, H_SPELL_SHADOW_BOLT));
                 Shadowbolt_Timer = 4000+rand()%2500;
             }
         }else Shadowbolt_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_omor_the_unscarredAI(Creature* pCreature)
 {
     return new boss_omor_the_unscarredAI (pCreature);
 }
+
 void AddSC_boss_omor_the_unscarred()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_omor_the_unscarred";
     newscript->GetAI = &GetAI_boss_omor_the_unscarredAI;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp
index fc793b83c8e..667c672c97d 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp
@@ -13,13 +13,16 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 /* ScriptData
 Name: Boss_Vazruden_the_Herald
 %Complete: 90
 Comment:
 Category: Hellfire Citadel, Hellfire Ramparts
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SPELL_FIREBALL              (HeroicMode?36920:34653)
 #define SPELL_CONE_OF_FIRE          (HeroicMode?36921:30926)
 #define SPELL_SUMMON_LIQUID_FIRE    (HeroicMode?30928:23971)
@@ -27,12 +30,14 @@ EndScriptData */
 #define SPELL_REVENGE               (HeroicMode?40392:19130)
 #define SPELL_KIDNEY_SHOT           30621
 #define SPELL_FIRE_NOVA_VISUAL      19823
+
 #define ENTRY_HELLFIRE_SENTRY       17517
 #define ENTRY_VAZRUDEN_HERALD       17307
 #define ENTRY_VAZRUDEN              17537
 #define ENTRY_NAZAN                 17536
 #define ENTRY_LIQUID_FIRE           22515
 #define ENTRY_REINFORCED_FEL_IRON_CHEST (HeroicMode?185169:185168)
+
 #define SAY_INTRO               -1543017
 #define SAY_WIPE                -1543018
 #define SAY_AGGRO_1             -1543019
@@ -42,13 +47,16 @@ EndScriptData */
 #define SAY_KILL_2              -1543023
 #define SAY_DIE                 -1543024
 #define EMOTE                   -1543025
+
 #define PATH_ENTRY              2081
+
 const float VazrudenMiddle[3] = {-1406.5, 1746.5, 81.2};
 const float VazrudenRing[2][3] =
 {
     {-1430, 1705, 112},
     {-1377, 1760, 112}
 };
+
 struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
 {
     boss_nazanAI(Creature *c) : ScriptedAI(c)
@@ -57,6 +65,7 @@ struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
         VazrudenGUID = 0;
         flight = true;
     }
+
     uint32 Fireball_Timer;
     uint32 ConeOfFire_Timer;
     uint32 BellowingRoar_Timer;
@@ -67,6 +76,7 @@ struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
     uint64 VazrudenGUID;
     bool HeroicMode;
     SpellEntry *liquid_fire;
+
     void Reset()
     {
         Fireball_Timer = 4000;
@@ -74,7 +84,9 @@ struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
         Turn_Timer = 0;
         UnsummonCheck = 5000;
     }
+
     void EnterCombat(Unit* who) {}
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned && summoned->GetEntry() == ENTRY_LIQUID_FIRE)
@@ -85,11 +97,13 @@ struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
             summoned->CastSpell(summoned,SPELL_FIRE_NOVA_VISUAL,true);
         }
     }
+
     void SpellHitTarget(Unit* target, const SpellEntry* entry)
     {
         if (target && entry->Id == SPELL_FIREBALL)
             m_creature->SummonCreature(ENTRY_LIQUID_FIRE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),target->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,30000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -100,12 +114,14 @@ struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
                 UnsummonCheck -= diff;
             return;
         }
+
         if (Fireball_Timer < diff)
         {
             if (Unit *victim = SelectUnit(SELECT_TARGET_RANDOM,0))
                 DoCast(victim, SPELL_FIREBALL,true);
             Fireball_Timer = urand(4000,7000);
         } else Fireball_Timer -= diff;
+
         if (flight) // phase 1 - the flight
         {
             Creature *Vazruden = Unit::GetCreature(*m_creature,VazrudenGUID);
@@ -123,6 +139,7 @@ struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
                 DoScriptText(EMOTE, m_creature);
                 return;
             }else Fly_Timer -= diff;
+
             if (Turn_Timer < diff)
             {
                 uint32 waypoint = (Fly_Timer/10000)%2;
@@ -139,45 +156,54 @@ struct TRINITY_DLL_DECL boss_nazanAI : public ScriptedAI
                 ConeOfFire_Timer = 12000;
                 Fireball_Timer = 4000;
             } else ConeOfFire_Timer -= diff;
+
             if (HeroicMode && BellowingRoar_Timer < diff)
             {
                 DoCast(m_creature, SPELL_BELLOWING_ROAR);
                 BellowingRoar_Timer = 45000;
             } else BellowingRoar_Timer -= diff;
+
             DoMeleeAttackIfReady();
         }
     }
 };
+
 struct TRINITY_DLL_DECL boss_vazrudenAI : public ScriptedAI
 {
     boss_vazrudenAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 Revenge_Timer;
     bool HeroicMode;
     bool WipeSaid;
     uint32 UnsummonCheck;
+
     void Reset()
     {
         Revenge_Timer = 4000;
         UnsummonCheck = 2000;
         WipeSaid = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
     }
+
     void KilledUnit(Unit* who)
     {
         if (who && who->GetEntry()!=ENTRY_VAZRUDEN)
             DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void JustDied(Unit* who)
     {
         if (who && who != m_creature)
             DoScriptText(SAY_DIE, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -193,15 +219,18 @@ struct TRINITY_DLL_DECL boss_vazrudenAI : public ScriptedAI
             } else UnsummonCheck -= diff;
             return;
         }
+
         if (Revenge_Timer < diff)
         {
             if (Unit *victim = m_creature->getVictim())
                 DoCast(victim, SPELL_REVENGE);
             Revenge_Timer = 5000;
         } else Revenge_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
 {
     boss_vazruden_the_heraldAI(Creature *c) : ScriptedAI(c)
@@ -212,6 +241,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
         VazrudenGUID = 0;
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     uint32 phase;
     uint32 waypoint;
     uint32 check;
@@ -220,6 +250,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
     uint64 VazrudenGUID;
     bool summoned;
     bool HeroicMode;
+
     void Reset()
     {
         phase = 0;
@@ -228,6 +259,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
         UnsummonAdds();
         m_creature->GetMotionMaster()->MovePath(PATH_ENTRY, true);
     }
+
     void UnsummonAdds()
     {
         if (summoned)
@@ -249,6 +281,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
             m_creature->SetVisibility(VISIBILITY_ON);
         }
     }
+
     void SummonAdds()
     {
         if (!summoned)
@@ -262,6 +295,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
             m_creature->addUnitState(UNIT_STAT_ROOT);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (phase==0)
@@ -271,6 +305,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
             DoScriptText(SAY_INTRO, m_creature);
         }
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (!summoned) return;
@@ -286,6 +321,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
         else if (victim)
             summoned->AI()->AttackStart(victim);
     }
+
     void SentryDownBy(Unit* killer)
     {
         if (sentryDown)
@@ -296,6 +332,7 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
         else
             sentryDown = true;
     }
+
     void UpdateAI(const uint32 diff)
     {
         switch(phase)
@@ -348,50 +385,63 @@ struct TRINITY_DLL_DECL boss_vazruden_the_heraldAI : public ScriptedAI
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_hellfire_sentryAI : public ScriptedAI
 {
     mob_hellfire_sentryAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 KidneyShot_Timer;
+
     void Reset()
     {
         KidneyShot_Timer = urand(3000,7000);
     }
+
     void EnterCombat(Unit* who) {}
+
     void JustDied(Unit* who)
     {
         if (Creature *herald = me->FindNearestCreature(ENTRY_VAZRUDEN_HERALD,150))
             CAST_AI(boss_vazruden_the_heraldAI, herald->AI())->SentryDownBy(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (KidneyShot_Timer < diff)
         {
             if (Unit *victim = m_creature->getVictim())
                 DoCast(victim, SPELL_KIDNEY_SHOT);
             KidneyShot_Timer = 20000;
         } else KidneyShot_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_vazruden_the_herald(Creature* pCreature)
 {
     return new boss_vazruden_the_heraldAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_vazruden(Creature* pCreature)
 {
     return new boss_vazrudenAI (pCreature);
 }
 
+
 CreatureAI* GetAI_boss_nazan(Creature* pCreature)
 {
     return new boss_nazanAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_hellfire_sentry(Creature* pCreature)
 {
     return new mob_hellfire_sentryAI (pCreature);
 }
+
 void AddSC_boss_vazruden_the_herald()
 {
     Script *newscript;
@@ -399,14 +449,17 @@ void AddSC_boss_vazruden_the_herald()
     newscript->Name = "boss_vazruden_the_herald";
     newscript->GetAI = &GetAI_boss_vazruden_the_herald;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_vazruden";
     newscript->GetAI = &GetAI_boss_vazruden;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_nazan";
     newscript->GetAI = &GetAI_boss_nazan;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_hellfire_sentry";
     newscript->GetAI = &GetAI_mob_hellfire_sentry;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp
index e746e3d6259..aa8fe3e20e9 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp
@@ -13,13 +13,16 @@
  * along with 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: 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_TAUNT               -1543000
 #define SAY_HEAL                -1543001
 #define SAY_SURGE               -1543002
@@ -29,40 +32,50 @@ EndScriptData */
 #define SAY_KILL_1              -1543006
 #define SAY_KILL_2              -1543007
 #define SAY_DIE                 -1543008
+
 #define SPELL_MORTAL_WOUND      30641
 #define H_SPELL_MORTAL_WOUND    36814
 #define SPELL_SURGE             34645
 #define SPELL_RETALIATION       22857
+
 struct TRINITY_DLL_DECL boss_watchkeeper_gargolmarAI : public ScriptedAI
 {
     boss_watchkeeper_gargolmarAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
+
     uint32 Surge_Timer;
     uint32 MortalWound_Timer;
     uint32 Retaliation_Timer;
+
     bool HasTaunted;
     bool YelledForHeal;
+
     void Reset()
     {
         Surge_Timer = 5000;
         MortalWound_Timer = 4000;
         Retaliation_Timer = 0;
+
         HasTaunted = false;
         YelledForHeal = false;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
     }
+
     void MoveInLineOfSight(Unit* who)
     {
         if (!m_creature->getVictim() && who->isTargetableForAttack() && (m_creature->IsHostileTo(who)) && who->isInAccessiblePlaceFor(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))
             {
@@ -76,30 +89,38 @@ struct TRINITY_DLL_DECL boss_watchkeeper_gargolmarAI : public ScriptedAI
             }
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DIE, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (MortalWound_Timer < diff)
         {
             DoCast(m_creature->getVictim(),HEROIC(SPELL_MORTAL_WOUND, H_SPELL_MORTAL_WOUND));
             MortalWound_Timer = 5000+rand()%8000;
         }else MortalWound_Timer -= diff;
+
         if (Surge_Timer < diff)
         {
             DoScriptText(SAY_SURGE, m_creature);
+
             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)
@@ -108,6 +129,7 @@ struct TRINITY_DLL_DECL boss_watchkeeper_gargolmarAI : public ScriptedAI
                 Retaliation_Timer = 30000;
             }else Retaliation_Timer -= diff;
         }
+
         if (!YelledForHeal)
         {
             if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 40)
@@ -116,13 +138,16 @@ struct TRINITY_DLL_DECL boss_watchkeeper_gargolmarAI : public ScriptedAI
                 YelledForHeal = true;
             }
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_watchkeeper_gargolmarAI(Creature* pCreature)
 {
     return new boss_watchkeeper_gargolmarAI (pCreature);
 }
+
 void AddSC_boss_watchkeeper_gargolmar()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/def_hellfire_ramparts.h b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/def_hellfire_ramparts.h
index d6227237bca..3c453949baa 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/def_hellfire_ramparts.h
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/def_hellfire_ramparts.h
@@ -1,12 +1,16 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
  * This program is free software licensed under GPL version 2
  * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef DEF_RAMPARTS_H
 #define DEF_RAMPARTS_H
+
 #define MAX_ENCOUNTER  2
+
 enum eEnums
 {
     TYPE_VAZRUDEN       = 1,
     TYPE_NAZAN          = 2
 };
+
 #endif
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp
index 26e8c9c9195..5942f0142ef 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp
@@ -13,26 +13,33 @@
  * along 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_Hellfire_Ramparts
 SD%Complete: 50
 SDComment:
 SDCategory: Hellfire Ramparts
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_hellfire_ramparts.h"
+
 struct TRINITY_DLL_DECL instance_ramparts : public ScriptedInstance
 {
     instance_ramparts(Map* pMap) : ScriptedInstance(pMap) {Initialize();}
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     uint64 m_uiChestNGUID;
     uint64 m_uiChestHGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         m_uiChestNGUID = 0;
         m_uiChestHGUID = 0;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -41,9 +48,11 @@ struct TRINITY_DLL_DECL instance_ramparts : public ScriptedInstance
             case 185169: m_uiChestHGUID = pGo->GetGUID(); break;
         }
     }
+
     void SetData(uint32 uiType, uint32 uiData)
     {
         debug_log("TSCR: Instance Ramparts: SetData received for type %u with data %u",uiType,uiData);
+
         switch(uiType)
         {
             case TYPE_VAZRUDEN:
@@ -59,10 +68,12 @@ struct TRINITY_DLL_DECL instance_ramparts : public ScriptedInstance
         }
     }
 };
+
 InstanceData* GetInstanceData_instance_ramparts(Map* pMap)
 {
     return new instance_ramparts(pMap);
 }
+
 void AddSC_instance_ramparts()
 {
     Script* pNewScript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp
index 239eec11480..3f2dba74aa8 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp
@@ -13,18 +13,22 @@
 * along with 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"
+
 struct Yell
 {
     int32 id;
 };
+
 static Yell RandomTaunt[]=
 {
     {-1544000},
@@ -34,19 +38,23 @@ static Yell RandomTaunt[]=
     {-1544004},
     {-1544005},
 };
+
 #define SAY_FREED                   -1544006
 #define SAY_AGGRO                   -1544007
 #define SAY_BANISH                  -1544008
 #define SAY_CHAMBER_DESTROY         -1544009
 #define SAY_PLAYER_KILLED           -1544010
 #define SAY_DEATH                   -1544011
+
 #define EMOTE_BERSERK               -1544012
 #define EMOTE_BLASTNOVA             -1544013
 #define EMOTE_BEGIN                 -1544014
+
 #define MOB_MAGTHERIDON     17257
 #define MOB_ROOM            17516
 #define MOB_CHANNELLER      17256
 #define MOB_ABYSSAL         17454
+
 #define SPELL_BLASTNOVA             30616
 #define SPELL_CLEAVE                30619
 #define SPELL_QUAKE_TRIGGER         30657 // must be cast with 30561 as the proc spell
@@ -58,21 +66,28 @@ static Yell RandomTaunt[]=
 #define SPELL_DEBRIS_DAMAGE         30631 // core bug, does not support target 8
 #define SPELL_CAMERA_SHAKE          36455
 #define SPELL_BERSERK               27680
+
 #define SPELL_SHADOW_CAGE           30168
 #define SPELL_SHADOW_GRASP          30410
 #define SPELL_SHADOW_GRASP_VISUAL   30166
 #define SPELL_MIND_EXHAUSTION       44032   //Casted by the cubes when channeling ends
+
 #define SPELL_SHADOW_CAGE_C         30205
 #define SPELL_SHADOW_GRASP_C        30207
+
 #define SPELL_SHADOW_BOLT_VOLLEY    30510
 #define SPELL_DARK_MENDING          30528
 #define SPELL_FEAR                  30530 //39176
 #define SPELL_BURNING_ABYSSAL       30511
 #define SPELL_SOUL_TRANSFER         30531 // core bug, does not support target 7
+
 #define SPELL_FIRE_BLAST            37110
+
 // count of clickers needed to interrupt blast nova
 #define CLICKERS_COUNT              5
+
 typedef std::map CubeMap;
+
 struct TRINITY_DLL_DECL mob_abyssalAI : public ScriptedAI
 {
     mob_abyssalAI(Creature *c) : ScriptedAI(c)
@@ -80,13 +95,16 @@ struct TRINITY_DLL_DECL mob_abyssalAI : public ScriptedAI
         trigger = 0;
         Despawn_Timer = 60000;
     }
+
     uint32 FireBlast_Timer;
     uint32 Despawn_Timer;
     uint32 trigger;
+
     void Reset()
     {
         FireBlast_Timer = 6000;
     }
+
     void SpellHit(Unit*, const SpellEntry *spell)
     {
         if (trigger == 2 && spell->Id == SPELL_BLAZE_TARGET)
@@ -96,6 +114,7 @@ struct TRINITY_DLL_DECL mob_abyssalAI : public ScriptedAI
             Despawn_Timer = 130000;
         }
     }
+
     void SetTrigger(uint32 _trigger)
     {
         trigger = _trigger;
@@ -108,9 +127,11 @@ struct TRINITY_DLL_DECL mob_abyssalAI : public ScriptedAI
             Despawn_Timer = 10000;
         }
     }
+
     void EnterCombat(Unit* who) {DoZoneInCombat();}
     void AttackStart(Unit *who) {if (!trigger) ScriptedAI::AttackStart(who);}
     void MoveInLineOfSight(Unit *who) {if (!trigger) ScriptedAI::MoveInLineOfSight(who);}
+
     void UpdateAI(const uint32 diff)
     {
         if (trigger)
@@ -125,20 +146,25 @@ struct TRINITY_DLL_DECL mob_abyssalAI : public ScriptedAI
             }
             return;
         }
+
         if (Despawn_Timer < diff)
         {
             m_creature->ForcedDespawn();
         }else Despawn_Timer -= diff;
+
         if (!UpdateVictim())
             return;
+
         if (FireBlast_Timer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_FIRE_BLAST);
             FireBlast_Timer = 5000+rand()%10000;
         }else FireBlast_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
 {
     boss_magtheridonAI(Creature *c) : ScriptedAI(c)
@@ -146,6 +172,7 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         m_creature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10);
         m_creature->SetFloatValue(UNIT_FIELD_COMBATREACH, 10);
+
         // target 7, random target with certain entry spell, need core fix
         SpellEntry *TempSpell;
         TempSpell = GET_SPELL(SPELL_BLAZE_TARGET);
@@ -160,8 +187,11 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
             TempSpell->EffectTriggerSpell[0] = SPELL_QUAKE_KNOCKBACK;
         }
     }
+
     CubeMap Cube;
+
     ScriptedInstance* pInstance;
+
     uint32 Berserk_Timer;
     uint32 Quake_Timer;
     uint32 Cleave_Timer;
@@ -169,8 +199,10 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
     uint32 Blaze_Timer;
     uint32 Debris_Timer;
     uint32 RandChat_Timer;
+
     bool Phase3;
     bool NeedCheckCube;
+
     void Reset()
     {
         Berserk_Timer = 1320000;
@@ -180,14 +212,17 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
         BlastNova_Timer = 60000;
         Cleave_Timer = 15000;
         RandChat_Timer = 90000;
+
         Phase3 = false;
         NeedCheckCube = false;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
         m_creature->addUnitState(UNIT_STAT_STUNNED);
         m_creature->CastSpell(m_creature, SPELL_SHADOW_CAGE_C, true);
     }
+
     void JustReachedHome()
     {
         if (pInstance)
@@ -196,6 +231,7 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
             pInstance->SetData(DATA_COLLAPSE, false);
         }
     }
+
     void SetClicker(uint64 cubeGUID, uint64 clickerGUID)
     {
         // to avoid multiclicks from 1 cube
@@ -204,21 +240,24 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
         Cube[cubeGUID] = clickerGUID;
         NeedCheckCube = true;
     }
+
     //function to interrupt channeling and debuff clicker with mind exh(used if second person clicks with same cube or after dispeling/ending shadow grasp DoT)
     void DebuffClicker(Unit *clicker)
     {
         if (!clicker || !clicker->isAlive())
             return;
+
         clicker->RemoveAurasDueToSpell(SPELL_SHADOW_GRASP); // cannot interrupt triggered spells
         clicker->InterruptNonMeleeSpells(false);
         clicker->CastSpell(clicker, SPELL_MIND_EXHAUSTION, true);
     }
+
     void NeedCheckCubeStatus()
     {
         uint32 ClickerNum = 0;
         // now checking if every clicker has debuff from manticron(it is dispelable atm rev 6110 : S)
         // if not - apply mind exhaustion and delete from clicker's list
-        for (CubeMap::iterator i = Cube.begin(); i != Cube.end(); ++i)
+        for(CubeMap::iterator i = Cube.begin(); i != Cube.end(); ++i)
         {
             Unit *clicker = Unit::GetUnit(*m_creature, (*i).second);
             if (!clicker || !clicker->HasAura(SPELL_SHADOW_GRASP))
@@ -227,6 +266,7 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
                 (*i).second = 0;
             }else ClickerNum++;
         }
+
         // if 5 clickers from other cubes apply shadow cage
         if (ClickerNum >= CLICKERS_COUNT && !m_creature->HasAura(SPELL_SHADOW_CAGE))
         {
@@ -235,33 +275,43 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
         }
         else if (ClickerNum < CLICKERS_COUNT && m_creature->HasAura(SPELL_SHADOW_CAGE))
             m_creature->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE);
+
         if (!ClickerNum) NeedCheckCube = false;
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(SAY_PLAYER_KILLED, m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
             pInstance->SetData(DATA_MAGTHERIDON_EVENT, DONE);
+
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void MoveInLineOfSight(Unit* who) {}
+
     void AttackStart(Unit *who)
     {
         if (!m_creature->hasUnitState(UNIT_STAT_STUNNED))
             ScriptedAI::AttackStart(who);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_MAGTHERIDON_EVENT, IN_PROGRESS);
         DoZoneInCombat();
+
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE_C);
+
         DoScriptText(SAY_FREED, m_creature);
    }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->isInCombat())
@@ -272,20 +322,25 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
                 RandChat_Timer = 90000;
             }else RandChat_Timer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         if (NeedCheckCube) NeedCheckCubeStatus();
+
         if (Berserk_Timer < diff)
         {
             m_creature->CastSpell(m_creature, SPELL_BERSERK, true);
             DoScriptText(EMOTE_BERSERK, m_creature);
             Berserk_Timer = 60000;
         }else Berserk_Timer -= diff;
+
         if (Cleave_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_CLEAVE);
             Cleave_Timer = 10000;
         }else Cleave_Timer -= diff;
+
         if (BlastNova_Timer < diff)
         {
             // to avoid earthquake interruption
@@ -296,6 +351,7 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
                 BlastNova_Timer = 60000;
             }
         }else BlastNova_Timer -= diff;
+
         if (Quake_Timer < diff)
         {
             // to avoid blastnova interruption
@@ -305,6 +361,7 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
                 Quake_Timer = 50000;
             }
         }else Quake_Timer -= diff;
+
         if (Blaze_Timer < diff)
         {
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -321,6 +378,7 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
             }
             Blaze_Timer = 20000 + rand()%20000;
         }else Blaze_Timer -= diff;
+
         if (!Phase3 && m_creature->GetHealth()*10 < m_creature->GetMaxHealth()*3
             && !m_creature->IsNonMeleeSpellCasted(false) // blast nova
             && !m_creature->hasUnitState(UNIT_STAT_STUNNED)) // shadow cage and earthquake
@@ -329,9 +387,11 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
             DoScriptText(SAY_CHAMBER_DESTROY, m_creature);
             m_creature->CastSpell(m_creature, SPELL_CAMERA_SHAKE, true);
             m_creature->CastSpell(m_creature, SPELL_DEBRIS_KNOCKDOWN, true);
+
             if (pInstance)
                 pInstance->SetData(DATA_COLLAPSE, true);
         }
+
         if (Phase3)
         {
             if (Debris_Timer < diff)
@@ -346,86 +406,107 @@ struct TRINITY_DLL_DECL boss_magtheridonAI : public ScriptedAI
                 Debris_Timer = 10000;
             }else Debris_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_hellfire_channelerAI : public ScriptedAI
 {
     mob_hellfire_channelerAI(Creature *c) : ScriptedAI(c)
     {
         pInstance =m_creature->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 ShadowBoltVolley_Timer;
     uint32 DarkMending_Timer;
     uint32 Fear_Timer;
     uint32 Infernal_Timer;
+
     uint32 Check_Timer;
+
     void Reset()
     {
         ShadowBoltVolley_Timer = 8000 + rand()%2000;
         DarkMending_Timer = 10000;
         Fear_Timer = 15000 + rand()%5000;
         Infernal_Timer = 10000 + rand()%40000;
+
         Check_Timer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_CHANNELER_EVENT, IN_PROGRESS);
+
         m_creature->InterruptNonMeleeSpells(false);
         DoZoneInCombat();
     }
+
     void JustReachedHome()
     {
         if (pInstance)
             pInstance->SetData(DATA_CHANNELER_EVENT, NOT_STARTED);
+
         m_creature->CastSpell(m_creature, SPELL_SHADOW_GRASP_C, false);
     }
+
     void JustSummoned(Creature *summon)
     {
         summon->AI()->AttackStart(m_creature->getVictim());
     }
+
     void DamageTaken(Unit*, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth())
             m_creature->CastSpell(m_creature, SPELL_SOUL_TRANSFER, true);
     }
+
     void JustDied(Unit* who)
     {
         if (pInstance)
             pInstance->SetData(DATA_CHANNELER_EVENT, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (ShadowBoltVolley_Timer < diff)
         {
             DoCast(m_creature, SPELL_SHADOW_BOLT_VOLLEY);
             ShadowBoltVolley_Timer = 10000 + rand()%10000;
         }else ShadowBoltVolley_Timer -= diff;
+
         if (DarkMending_Timer < diff)
         {
             if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50)
                 DoCast(m_creature, SPELL_DARK_MENDING);
             DarkMending_Timer = 10000 +(rand() % 10000);
         }else DarkMending_Timer -= diff;
+
         if (Fear_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1))
                 DoCast(target, SPELL_FEAR);
             Fear_Timer = 25000 + rand()%15000;
         }else Fear_Timer -= diff;
+
         if (Infernal_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 m_creature->CastSpell(target, SPELL_BURNING_ABYSSAL, true);
             Infernal_Timer = 30000 + rand()%10000;
         }else Infernal_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Manticron Cube
 bool GOHello_go_Manticron_Cube(Player* pPlayer, GameObject* pGo)
 {
@@ -435,27 +516,33 @@ bool GOHello_go_Manticron_Cube(Player* pPlayer, GameObject* pGo)
     if (pInstance->GetData(DATA_MAGTHERIDON_EVENT) != IN_PROGRESS) return true;
     Creature *Magtheridon =Unit::GetCreature(*pGo, pInstance->GetData64(DATA_MAGTHERIDON));
     if (!Magtheridon || !Magtheridon->isAlive()) return true;
+
     // if exhausted or already channeling return
     if (pPlayer->HasAura(SPELL_MIND_EXHAUSTION) || pPlayer->HasAura(SPELL_SHADOW_GRASP))
         return true;
+
     pPlayer->InterruptNonMeleeSpells(false);
     pPlayer->CastSpell(pPlayer, SPELL_SHADOW_GRASP, true);
     pPlayer->CastSpell(pPlayer, SPELL_SHADOW_GRASP_VISUAL, false);
     CAST_AI(boss_magtheridonAI, Magtheridon->AI())->SetClicker(pGo->GetGUID(), pPlayer->GetGUID());
     return true;
 }
+
 CreatureAI* GetAI_boss_magtheridon(Creature* pCreature)
 {
     return new boss_magtheridonAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_hellfire_channeler(Creature* pCreature)
 {
     return new mob_hellfire_channelerAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_abyssalAI(Creature* pCreature)
 {
     return new mob_abyssalAI(pCreature);
 }
+
 void AddSC_boss_magtheridon()
 {
     Script *newscript;
@@ -463,17 +550,21 @@ void AddSC_boss_magtheridon()
     newscript->Name = "boss_magtheridon";
     newscript->GetAI = &GetAI_boss_magtheridon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_hellfire_channeler";
     newscript->GetAI = &GetAI_mob_hellfire_channeler;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_manticron_cube";
     newscript->pGOHello = &GOHello_go_Manticron_Cube;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_abyssal";
     newscript->GetAI = &GetAI_mob_abyssalAI;
     newscript->RegisterSelf();
+
 }
 
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h b/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h
index 2fb87069fa9..c5469acaea0 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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_MAGTHERIDON_EVENT          1
 #define DATA_MAGTHERIDON                3
 #define DATA_CHANNELER_EVENT        2
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp
index 2acdae10f37..33946926976 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp
@@ -13,50 +13,65 @@
  * along 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"
+
 #define SPELL_SOUL_TRANSFER         30531 // core bug, does not support target 7
 #define SPELL_BLAZE_TARGET          30541 // core bug, does not support target 7
+
 #define CHAMBER_CENTER_X            -15.14
 #define CHAMBER_CENTER_Y              1.8
 #define CHAMBER_CENTER_Z             -0.4
+
 #define MAX_ENCOUNTER 2
+
 #define EMOTE_BONDS_WEAKEN          "'s bonds begin to weaken!"
+
 struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
 {
     instance_magtheridons_lair(Map* pMap) : ScriptedInstance(pMap)
     {
         Initialize();
     }
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     uint64 MagtheridonGUID;
     std::set ChannelerGUID;
     uint64 DoorGUID;
     std::set ColumnGUID;
+
     uint32 CageTimer;
     uint32 RespawnTimer;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         MagtheridonGUID = 0;
         ChannelerGUID.clear();
         DoorGUID = 0;
         ColumnGUID.clear();
+
         CageTimer = 0;
         RespawnTimer = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -69,6 +84,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
             break;
         }
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -90,6 +106,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
             break;
         }
     }
+
     uint64 GetData64(uint32 type)
     {
         switch(type)
@@ -99,6 +116,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -117,7 +135,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
                 if (m_auiEncounter[1] != NOT_STARTED)
                 {
                     m_auiEncounter[1] = NOT_STARTED;
-                    for (std::set::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
+                    for(std::set::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                     {
                         if (Creature *Channeler = instance->GetCreature(*i))
                         {
@@ -135,7 +153,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
                 {
                     m_auiEncounter[1] = IN_PROGRESS;
                     // Let all five channelers aggro.
-                    for (std::set::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
+                    for(std::set::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                     {
                         Creature *Channeler = instance->GetCreature(*i);
                         if (Channeler && Channeler->isAlive())
@@ -151,7 +169,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
                     HandleGameObject(DoorGUID, false);
                 }break;
             case DONE: // Add buff and check if all channelers are dead.
-                for (std::set::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
+                for(std::set::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                 {
                     Creature *Channeler = instance->GetCreature(*i);
                     if (Channeler && Channeler->isAlive())
@@ -166,19 +184,21 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
             break;
         case DATA_COLLAPSE:
             // true - collapse / false - reset
-            for (std::set::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i)
+            for(std::set::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i)
                 DoUseDoorOrButton(*i);
             break;
         default:
             break;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         if (type == DATA_MAGTHERIDON_EVENT)
             return m_auiEncounter[0];
         return 0;
     }
+
     void Update(uint32 diff)
     {
         if (CageTimer)
@@ -194,11 +214,12 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
                 CageTimer = 0;
             }else CageTimer -= diff;
         }
+
         if (RespawnTimer)
         {
             if (RespawnTimer <= diff)
             {
-                for (std::set::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
+                for(std::set::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                 {
                     if (Creature *Channeler = instance->GetCreature(*i))
                     {
@@ -213,10 +234,12 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
         }
     }
 };
+
 InstanceData* GetInstanceData_instance_magtheridons_lair(Map* pMap)
 {
     return new instance_magtheridons_lair(pMap);
 }
+
 void AddSC_instance_magtheridons_lair()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_nethekurse.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_nethekurse.cpp
index c29269bd7ab..4ae379d988e 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_nethekurse.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_nethekurse.cpp
@@ -13,23 +13,28 @@
  * along with 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 completed. 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
 {
     int32 id;
 };
+
 static Say PeonAttacked[]=
 {
     {-1540001},
@@ -44,6 +49,7 @@ static Say PeonDies[]=
     {-1540007},
     {-1540008},
 };
+
 #define SAY_INTRO           -1540000
 #define SAY_TAUNT_1         -1540009
 #define SAY_TAUNT_2         -1540010
@@ -54,14 +60,19 @@ static Say PeonDies[]=
 #define SAY_SLAY_1          -1540015
 #define SAY_SLAY_2          -1540016
 #define SAY_DIE             -1540017
+
 #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 TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI
 {
     boss_grand_warlock_nethekurseAI(Creature *c) : ScriptedAI(c)
@@ -69,49 +80,62 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     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);
+
         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;
+
         DoScriptText(PeonAttacked[PeonEngagedCount].id, m_creature);
         ++PeonEngagedCount;
     }
+
     void DoYellForPeonDeath()
     {
         if (PeonKilledCount >= 4)
             return;
+
         DoScriptText(PeonDies[PeonKilledCount].id, m_creature);
         ++PeonKilledCount;
+
         if (PeonKilledCount == 4)
         {
             IsIntroEvent = false;
@@ -119,9 +143,11 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI
             m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         }
     }
+
     void DoTauntPeons()
     {
         DoScriptText(RAND(SAY_TAUNT_1,SAY_TAUNT_2,SAY_TAUNT_3), m_creature);
+
         //TODO: kill the peons first
         IsIntroEvent = false;
         PeonEngagedCount = 4;
@@ -129,10 +155,12 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI
         IsMainEvent = true;
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
     }
+
     void AttackStart(Unit* who)
     {
         if (IsIntroEvent || !IsMainEvent)
             return;
+
         if (m_creature->Attack(who, true))
         {
             if (Phase)
@@ -141,53 +169,67 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI
                 DoStartMovement(who);
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!IntroOnce && m_creature->IsWithinDistInMap(who, 50.0f))
             {
             if (who->GetTypeId() != TYPEID_PLAYER)
                 return;
+
                 DoScriptText(SAY_INTRO, m_creature);
                 IntroOnce = true;
                 IsIntroEvent = true;
+
                 if (pInstance)
                     pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS);
             }
+
             if (IsIntroEvent || !IsMainEvent)
                 return;
+
             ScriptedAI::MoveInLineOfSight(who);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO_1,SAY_AGGRO_2,SAY_AGGRO_3), m_creature);
     }
+
     void JustSummoned(Creature *summoned)
     {
         summoned->setFaction(16);
         summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
         //triggered spell of consumption does not properly show it's SpellVisual, wrong spellid?
         summoned->CastSpell(summoned,SPELL_TEMPORARY_VISUAL,true);
         summoned->CastSpell(summoned,SPELL_CONSUMPTION,false,0,0,m_creature->GetGUID());
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DIE, m_creature);
+
         if (!pInstance)
             return;
+
         pInstance->SetData(TYPE_NETHEKURSE,DONE);
         pInstance->HandleGameObject(pInstance->GetData64(DATA_NETHEKURSE_DOOR), true);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (IsIntroEvent)
         {
             if (!pInstance)
                 return;
+
             if (pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS)
             {
                 if (IntroEvent_Timer < diff)
@@ -196,10 +238,13 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI
                     IntroEvent_Timer -= diff;
             }
         }
+
         if (!UpdateVictim())
             return;
+
         if (!IsMainEvent)
             return;
+
         if (Phase)
         {
             if (!SpinOnce)
@@ -207,6 +252,7 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI
                 DoCast(m_creature->getVictim(),SPELL_DARK_SPIN);
                 SpinOnce = true;
             }
+
             if (Cleave_Timer < diff)
             {
                 DoCast(m_creature->getVictim(),HEROIC(SPELL_SHADOW_CLEAVE, H_SPELL_SHADOW_SLAM));
@@ -221,34 +267,42 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI
                     DoCast(target,SPELL_SHADOW_FISSURE);
                 ShadowFissure_Timer = urand(7500,15000);
             } else ShadowFissure_Timer -= diff;
+
             if (DeathCoil_Timer < diff)
             {
                 if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0))
                     DoCast(target,SPELL_DEATH_COIL);
                 DeathCoil_Timer = urand(15000,20000);
             } else DeathCoil_Timer -= diff;
+
             if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 20)
                 Phase = true;
+
             DoMeleeAttackIfReady();
         }
     }
 };
+
 struct TRINITY_DLL_DECL mob_fel_orc_convertAI : public ScriptedAI
 {
     mob_fel_orc_convertAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
     uint32 Hemorrhage_Timer;
+
     void Reset()
     {
         m_creature->SetNoCallAssistance(true);              //we don't want any assistance (WE R HEROZ!)
         Hemorrhage_Timer = 3000;
     }
+
     void MoveInLineOfSight(Unit *who)
     {
     }
+
     void EnterCombat(Unit* who)
     {
         if (pInstance)
@@ -259,6 +313,7 @@ struct TRINITY_DLL_DECL mob_fel_orc_convertAI : public ScriptedAI
                 if (pKurse && m_creature->IsWithinDist(pKurse, 45.0f))
                 {
                     CAST_AI(boss_grand_warlock_nethekurseAI, pKurse->AI())->DoYellForPeonAggro();
+
                     if (pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS)
                         return;
                     else
@@ -267,6 +322,7 @@ struct TRINITY_DLL_DECL mob_fel_orc_convertAI : public ScriptedAI
             }
         }
     }
+
     void JustDied(Unit* Killer)
     {
         if (pInstance)
@@ -278,50 +334,62 @@ struct TRINITY_DLL_DECL mob_fel_orc_convertAI : public ScriptedAI
                     CAST_AI(boss_grand_warlock_nethekurseAI, pKurse->AI())->DoYellForPeonDeath();
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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 TRINITY_DLL_DECL mob_lesser_shadow_fissureAI : public ScriptedAI
 {
     mob_lesser_shadow_fissureAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() { }
     void MoveInLineOfSight(Unit *who) { }
     void AttackStart(Unit* who) { }
     void EnterCombat(Unit* who) { }
 };
+
 CreatureAI* GetAI_boss_grand_warlock_nethekurse(Creature* pCreature)
 {
     return new boss_grand_warlock_nethekurseAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_fel_orc_convert(Creature* pCreature)
 {
     return new mob_fel_orc_convertAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_lesser_shadow_fissure(Creature* pCreature)
 {
     return new mob_lesser_shadow_fissureAI (pCreature);
 }
+
 void AddSC_boss_grand_warlock_nethekurse()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_grand_warlock_nethekurse";
     newscript->GetAI = &GetAI_boss_grand_warlock_nethekurse;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_fel_orc_convert";
     newscript->GetAI = &GetAI_mob_fel_orc_convert;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_lesser_shadow_fissure";
     newscript->GetAI = &GetAI_mob_lesser_shadow_fissure;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp
index d715b1ea5fc..2fe6fec2684 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp
@@ -13,36 +13,45 @@
  * along with 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"
+
 enum eEnums
 {
     YELL_DIE_L                  = -1540039,
     YELL_DIE_R                  = -1540040,
     EMOTE_ENRAGE                = -1540041,
+
     SPELL_BLAST_WAVE            = 30600,
     SPELL_FEAR                  = 30584,
     SPELL_THUNDERCLAP           = 30633,
+
     SPELL_BURNING_MAUL          = 30598,
     H_SPELL_BURNING_MAUL        = 36056,
+
     NPC_LEFT_HEAD               = 19523,
     NPC_RIGHT_HEAD              = 19524
 };
+
 struct Yell
 {
     int32 id;
     uint32 creature;
 };
+
 static Yell GoCombat[]=
 {
     {-1540018, NPC_LEFT_HEAD},
@@ -55,6 +64,7 @@ static Yell GoCombatDelay[]=
     {-1540022, NPC_RIGHT_HEAD},
     {-1540023, NPC_RIGHT_HEAD},
 };
+
 static Yell Threat[]=
 {
     {-1540024, NPC_LEFT_HEAD},
@@ -76,6 +86,7 @@ static Yell ThreatDelay2[]=
     {-1540034, NPC_LEFT_HEAD},
     {-1540035, NPC_LEFT_HEAD},
 };
+
 static Yell Killing[]=
 {
     {-1540036, NPC_LEFT_HEAD},
@@ -86,25 +97,31 @@ static Yell KillingDelay[]=
     {-1540038, NPC_RIGHT_HEAD},
     {-1000000, NPC_LEFT_HEAD},
 };
+
 struct TRINITY_DLL_DECL mob_omrogg_headsAI : public ScriptedAI
 {
     mob_omrogg_headsAI(Creature *c) : ScriptedAI(c) {}
+
     bool DeathYell;
     uint32 Death_Timer;
+
     void Reset()
     {
         Death_Timer = 4000;
         DeathYell = false;
     }
     void EnterCombat(Unit* who) { }
+
     void DoDeathYell()
     {
         DeathYell = true;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!DeathYell)
             return;
+
         if (Death_Timer < diff)
         {
             DoScriptText(YELL_DIE_R, m_creature);
@@ -113,6 +130,7 @@ struct TRINITY_DLL_DECL mob_omrogg_headsAI : public ScriptedAI
         }else Death_Timer -= diff;
     }
 };
+
 struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI
 {
     boss_warbringer_omroggAI(Creature *c) : ScriptedAI(c)
@@ -122,17 +140,21 @@ struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance* pInstance;
     bool HeroicMode;
+
     uint64 LeftHeadGUID;
     uint64 RightHeadGUID;
     int iaggro;
     int ithreat;
     int ikilling;
+
     bool AggroYell;
     bool ThreatYell;
     bool ThreatYell2;
     bool KillingYell;
+
     uint32 Delay_Timer;
     uint32 BlastWave_Timer;
     uint32 BlastCount;
@@ -140,6 +162,7 @@ struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI
     uint32 BurningMaul_Timer;
     uint32 ThunderClap_Timer;
     uint32 ResetThreat_Timer;
+
     void Reset()
     {
         if (Unit* pLeftHead  = Unit::GetUnit(*m_creature,LeftHeadGUID))
@@ -147,16 +170,19 @@ struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI
             pLeftHead->setDeathState(JUST_DIED);
             LeftHeadGUID = 0;
         }
+
         if (Unit* pRightHead  = Unit::GetUnit(*m_creature,RightHeadGUID))
         {
             pRightHead->setDeathState(JUST_DIED);
             RightHeadGUID = 0;
         }
 
+
         AggroYell = false;
         ThreatYell = false;
         ThreatYell2 = false;
         KillingYell = false;
+
         Delay_Timer = 4000;
         BlastWave_Timer = 0;
         BlastCount = 0;
@@ -164,54 +190,74 @@ struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI
         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()
     {
         Unit *pLeftHead  = Unit::GetUnit(*m_creature,LeftHeadGUID);
         Unit *pRightHead = Unit::GetUnit(*m_creature,RightHeadGUID);
+
         if (!pLeftHead || !pRightHead)
             return;
+
         ithreat = rand()%4;
+
         Unit *source = (pLeftHead->GetEntry() == Threat[ithreat].creature ? pLeftHead : pRightHead);
+
         DoScriptText(Threat[ithreat].id, source);
+
         Delay_Timer = 3500;
         ThreatYell = true;
     }
+
     void EnterCombat(Unit *who)
     {
         m_creature->SummonCreature(NPC_LEFT_HEAD, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_DEAD_DESPAWN, 0);
         m_creature->SummonCreature(NPC_RIGHT_HEAD, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_DEAD_DESPAWN, 0);
+
         if (Unit *pLeftHead = Unit::GetUnit(*m_creature,LeftHeadGUID))
         {
             iaggro = rand()%3;
+
             DoScriptText(GoCombat[iaggro].id, pLeftHead);
+
             Delay_Timer = 3500;
             AggroYell = true;
         }
+
         if (pInstance)
             pInstance->SetData(TYPE_OMROGG, IN_PROGRESS);
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned->GetEntry() == NPC_LEFT_HEAD)
             LeftHeadGUID = summoned->GetGUID();
+
         if (summoned->GetEntry() == NPC_RIGHT_HEAD)
             RightHeadGUID = 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)
     {
         Unit* pLeftHead  = Unit::GetUnit(*m_creature,LeftHeadGUID);
         Unit* pRightHead = Unit::GetUnit(*m_creature,RightHeadGUID);
 
+
         if (!pLeftHead || !pRightHead)
             return;
+
         ikilling = rand()%2;
+
         Unit *source = (pLeftHead->GetEntry() == Killing[ikilling].creature ? pLeftHead : pRightHead);
+
         switch(ikilling)
         {
             case 0:
@@ -225,61 +271,80 @@ struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI
                 break;
         }
     }
+
     void JustDied(Unit* Killer)
     {
         Unit* pLeftHead  = Unit::GetUnit(*m_creature,LeftHeadGUID);
         Unit* pRightHead = Unit::GetUnit(*m_creature,RightHeadGUID);
+
         if (!pLeftHead || !pRightHead)
             return;
+
         DoScriptText(YELL_DIE_L, pLeftHead);
+
         CAST_AI(mob_omrogg_headsAI, CAST_CRE(pRightHead)->AI())->DoDeathYell();
+
         if (pInstance)
             pInstance->SetData(TYPE_OMROGG, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Delay_Timer < diff)
         {
             Delay_Timer = 3500;
+
             Unit* pLeftHead  = Unit::GetUnit(*m_creature,LeftHeadGUID);
             Unit* pRightHead = Unit::GetUnit(*m_creature,RightHeadGUID);
+
             if (!pLeftHead || !pRightHead)
                 return;
+
             if (AggroYell)
             {
                 DoScriptText(GoCombatDelay[iaggro].id, pRightHead);
                 AggroYell = false;
             }
+
             if (ThreatYell2)
             {
                 Unit *source = (pLeftHead->GetEntry() == ThreatDelay2[ithreat].creature ? pLeftHead : pRightHead);
+
                 DoScriptText(ThreatDelay2[ithreat].id, source);
                 ThreatYell2 = false;
             }
+
             if (ThreatYell)
             {
                 Unit *source = (pLeftHead->GetEntry() == ThreatDelay1[ithreat].creature ? pLeftHead : pRightHead);
+
                 DoScriptText(ThreatDelay1[ithreat].id, source);
                 ThreatYell = false;
                 ThreatYell2 = true;
             }
+
             if (KillingYell)
             {
                 Unit *source = (pLeftHead->GetEntry() == KillingDelay[ikilling].creature ? pLeftHead : pRightHead);
+
                 DoScriptText(KillingDelay[ikilling].id, source);
                 KillingYell = false;
             }
         }else Delay_Timer -= diff;
+
         if (!UpdateVictim())
             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)
         {
             DoScriptText(EMOTE_ENRAGE, m_creature);
@@ -288,6 +353,7 @@ struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI
             BlastWave_Timer = 16000;
             BlastCount = 1;
         }else BurningMaul_Timer -= diff;
+
         if (ResetThreat_Timer < diff)
         {
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0))
@@ -298,34 +364,42 @@ struct TRINITY_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI
             }
             ResetThreat_Timer = 25000+rand()%15000;
         }else ResetThreat_Timer -= diff;
+
         if (Fear_Timer < diff)
         {
             DoCast(m_creature,SPELL_FEAR);
             Fear_Timer = 15000+rand()%20000;
         }else Fear_Timer -= diff;
+
         if (ThunderClap_Timer < diff)
         {
             DoCast(m_creature,SPELL_THUNDERCLAP);
             ThunderClap_Timer = 15000+rand()%15000;
         }else ThunderClap_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_warbringer_omrogg(Creature* pCreature)
 {
     return new boss_warbringer_omroggAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_omrogg_heads(Creature* pCreature)
 {
     return new mob_omrogg_headsAI (pCreature);
 }
+
 void AddSC_boss_warbringer_omrogg()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_warbringer_omrogg";
     newscript->GetAI = &GetAI_boss_warbringer_omrogg;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_omrogg_heads";
     newscript->GetAI = &GetAI_mob_omrogg_heads;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp
index f01cf7ebad2..98a5cea12c3 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp
@@ -13,68 +13,89 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 /* ScriptData
 SDName: Boss_Warchief_Kargath_Bladefist
 SD%Complete: 90
 SDComment:
 SDCategory: Hellfire Citadel, Shattered Halls
 EndScriptData */
+
 /* ContentData
 boss_warchief_kargath_bladefist
 EndContentData */
+
 #include "precompiled.h"
+
 #define SAY_AGGRO1                      -1540042
 #define SAY_AGGRO2                      -1540043
 #define SAY_AGGRO3                      -1540044
 #define SAY_SLAY1                       -1540045
 #define SAY_SLAY2                       -1540046
 #define SAY_DEATH                       -1540047
+
 #define SPELL_BLADE_DANCE               30739
 #define H_SPELL_CHARGE                  25821
+
 #define TARGET_NUM                      5
+
 #define MOB_SHATTERED_ASSASSIN          17695
 #define MOB_HEARTHEN_GUARD              17621
 #define MOB_SHARPSHOOTER_GUARD          17622
 #define MOB_REAVER_GUARD                17623
+
 float AssassEntrance[3] = {275.136,-84.29,2.3}; // y -8
 float AssassExit[3] = {184.233,-84.29,2.3}; // y -8
 float AddsEntrance[3] = {306.036,-84.29,1.93};
+
 struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
 {
     boss_warchief_kargath_bladefistAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
+
     std::vector adds;
     std::vector assassins;
+
     uint32 Charge_timer;
     uint32 Blade_Dance_Timer;
     uint32 Summon_Assistant_Timer;
     uint32 resetcheck_timer;
     uint32 Wait_Timer;
+
     uint32 Assassins_Timer;
+
     uint32 summoned;
     bool InBlade;
+
     uint32 target_num;
+
     void Reset()
     {
         removeAdds();
+
         m_creature->SetSpeed(MOVE_RUN,2);
         m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+
         summoned = 2;
         InBlade = false;
         Wait_Timer = 0;
+
         Charge_timer = 0;
         Blade_Dance_Timer = 45000;
         Summon_Assistant_Timer = 30000;
         Assassins_Timer = 5000;
         resetcheck_timer = 5000;
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), m_creature);
     }
+
     void JustSummoned(Creature *summoned)
     {
         switch(summoned->GetEntry())
@@ -90,6 +111,7 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
                 break;
         }
     }
+
     void KilledUnit(Unit *victim)
     {
         if (victim->GetTypeId() == TYPEID_PLAYER)
@@ -97,19 +119,23 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
             DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
         }
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
         removeAdds();
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (InBlade)
         {
             if (type != POINT_MOTION_TYPE)
                 return;
+
             if (id != 1)
                 return;
+
             if (target_num > 0) // to prevent loops
             {
                 Wait_Timer = 1;
@@ -118,9 +144,10 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
             }
         }
     }
+
     void removeAdds()
     {
-        for (std::vector::iterator itr = adds.begin(); itr!= adds.end(); ++itr)
+        for(std::vector::iterator itr = adds.begin(); itr!= adds.end(); ++itr)
         {
             Unit* temp = Unit::GetUnit((*m_creature),*itr);
             if (temp && temp->isAlive())
@@ -131,7 +158,8 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
             }
         }
         adds.clear();
-        for (std::vector::iterator itr = assassins.begin(); itr!= assassins.end(); ++itr)
+
+        for(std::vector::iterator itr = assassins.begin(); itr!= assassins.end(); ++itr)
         {
             Unit* temp = Unit::GetUnit((*m_creature),*itr);
             if (temp && temp->isAlive())
@@ -150,17 +178,20 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
         m_creature->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassExit[0],AssassExit[1]+8, AssassExit[2], 0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,30000);
         m_creature->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassExit[0],AssassExit[1]-8, AssassExit[2], 0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,30000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (Assassins_Timer)
             if (Assassins_Timer <= diff)
             {
                 SpawnAssassin();
                 Assassins_Timer = 0;
             }else Assassins_Timer -= diff;
+
         if (InBlade)
         {
             if (Wait_Timer)
@@ -202,16 +233,19 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
                     m_creature->SetSpeed(MOVE_RUN,4);
                     return;
                 }else Blade_Dance_Timer -= diff;
+
             if (Charge_timer)
                 if (Charge_timer <= diff)
                 {
                     DoCast(SelectUnit(SELECT_TARGET_RANDOM,0),H_SPELL_CHARGE);
                     Charge_timer = 0;
                 }else Charge_timer -= diff;
+
             if (Summon_Assistant_Timer < diff)
             {
                 Unit* target = NULL;
-                for (uint8 i = 0; i < summoned; ++i)
+
+                for(uint8 i = 0; i < summoned; ++i)
                 {
                     switch(rand()%3)
                     {
@@ -223,8 +257,10 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
                 if (rand()%100 < 20) summoned++;
                     Summon_Assistant_Timer = 25000 + (rand()%10000) ;
             }else Summon_Assistant_Timer -= diff;
+
             DoMeleeAttackIfReady();
         }
+
         if (resetcheck_timer < diff)
         {
             uint32 tempx,tempy;
@@ -239,10 +275,12 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
         }else resetcheck_timer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_warchief_kargath_bladefist(Creature* pCreature)
 {
     return new boss_warchief_kargath_bladefistAI (pCreature);
 }
+
 void AddSC_boss_warchief_kargath_bladefist()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/def_shattered_halls.h b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/def_shattered_halls.h
index 91815f29de6..cbfa23ec4e0 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/def_shattered_halls.h
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/def_shattered_halls.h
@@ -1,11 +1,14 @@
 /* Copyright (C) 2006 - 2009 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/outland/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp
index f8d47c4c3f2..864a49a84ba 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp
@@ -13,28 +13,37 @@
  * along 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 MAX_ENCOUNTER  2
+
 #define DOOR_NETHEKURSE     1
+
 struct TRINITY_DLL_DECL instance_shattered_halls : public ScriptedInstance
 {
     instance_shattered_halls(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
     uint64 nethekurseGUID;
     uint64 nethekurseDoorGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         nethekurseGUID = 0;
         nethekurseDoorGUID = 0;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -42,6 +51,7 @@ struct TRINITY_DLL_DECL instance_shattered_halls : public ScriptedInstance
             case DOOR_NETHEKURSE: nethekurseDoorGUID = pGo->GetGUID(); break;
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -49,6 +59,7 @@ struct TRINITY_DLL_DECL instance_shattered_halls : public ScriptedInstance
             case 16807: nethekurseGUID = pCreature->GetGUID(); break;
         }
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -61,6 +72,7 @@ struct TRINITY_DLL_DECL instance_shattered_halls : public ScriptedInstance
                 break;
         }
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -72,6 +84,7 @@ struct TRINITY_DLL_DECL instance_shattered_halls : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 data)
     {
         switch(data)
@@ -84,10 +97,12 @@ struct TRINITY_DLL_DECL instance_shattered_halls : public ScriptedInstance
         return 0;
     }
 };
+
 InstanceData* GetInstanceData_instance_shattered_halls(Map* pMap)
 {
     return new instance_shattered_halls(pMap);
 }
+
 void AddSC_instance_shattered_halls()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/hellfire_peninsula.cpp b/src/bindings/scripts/scripts/outland/hellfire_peninsula.cpp
index 077ac13e1de..fe0a52e2c47 100644
--- a/src/bindings/scripts/scripts/outland/hellfire_peninsula.cpp
+++ b/src/bindings/scripts/scripts/outland/hellfire_peninsula.cpp
@@ -13,12 +13,14 @@
  * along 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: 9375, 9410, 9418, 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths)
 SDCategory: Hellfire Peninsula
 EndScriptData */
+
 /* ContentData
 npc_aeranas
 npc_ancestral_wolf
@@ -28,36 +30,48 @@ npc_tracy_proudwell
 npc_trollbane
 npc_wounded_blood_elf
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_aeranas
 ######*/
+
 enum eAeranas
 {
     SAY_SUMMON              = -1000138,
     SAY_FREE                = -1000139,
+
     FACTION_HOSTILE         = 16,
     FACTION_FRIENDLY        = 35,
+
     SPELL_ENVELOPING_WINDS  = 15535,
     SPELL_SHOCK             = 12553,
+
     C_AERANAS               = 17085
 };
+
 struct TRINITY_DLL_DECL npc_aeranasAI : public ScriptedAI
 {
     npc_aeranasAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 Faction_Timer;
     uint32 EnvelopingWinds_Timer;
     uint32 Shock_Timer;
+
     void Reset()
     {
         Faction_Timer = 8000;
         EnvelopingWinds_Timer = 9000;
         Shock_Timer = 5000;
+
         m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
         m_creature->setFaction(FACTION_FRIENDLY);
+
         DoScriptText(SAY_SUMMON, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Faction_Timer)
@@ -68,8 +82,10 @@ struct TRINITY_DLL_DECL npc_aeranasAI : public ScriptedAI
                 Faction_Timer = 0;
             }else Faction_Timer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 30)
         {
             m_creature->setFaction(FACTION_FRIENDLY);
@@ -80,34 +96,43 @@ struct TRINITY_DLL_DECL npc_aeranasAI : public ScriptedAI
             DoScriptText(SAY_FREE, m_creature);
             return;
         }
+
         if (Shock_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_SHOCK);
             Shock_Timer = 10000;
         }else Shock_Timer -= diff;
+
         if (EnvelopingWinds_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_ENVELOPING_WINDS);
             EnvelopingWinds_Timer = 25000;
         }else EnvelopingWinds_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_aeranas(Creature* pCreature)
 {
     return new npc_aeranasAI (pCreature);
 }
+
 /*######
 ## npc_ancestral_wolf
 ######*/
+
 enum eAncestralWolf
 {
     EMOTE_WOLF_LIFT_HEAD            = -1000496,
     EMOTE_WOLF_HOWL                 = -1000497,
     SAY_WOLF_WELCOME                = -1000498,
+
     SPELL_ANCESTRAL_WOLF_BUFF       = 29981,
+
     NPC_RYGA                        = 17123
 };
+
 struct TRINITY_DLL_DECL npc_ancestral_wolfAI : public npc_escortAI
 {
     npc_ancestral_wolfAI(Creature* pCreature) : npc_escortAI(pCreature)
@@ -116,21 +141,27 @@ struct TRINITY_DLL_DECL npc_ancestral_wolfAI : public npc_escortAI
             Start(false, false, pCreature->GetOwner()->GetGUID());
         else
             error_log("TRINITY: npc_ancestral_wolf can not obtain owner or owner is not a player.");
+
         pCreature->SetSpeed(MOVE_WALK, 1.5f);
         Reset();
     }
+
     Unit* pRyga;
+
     void Reset()
     {
         pRyga = NULL;
         m_creature->CastSpell(m_creature, SPELL_ANCESTRAL_WOLF_BUFF, true);
     }
+
     void MoveInLineOfSight(Unit* pWho)
     {
         if (!pRyga && pWho->GetTypeId() == TYPEID_UNIT && pWho->GetEntry() == NPC_RYGA && m_creature->IsWithinDistInMap(pWho, 15.0f))
             pRyga = pWho;
+
         npc_escortAI::MoveInLineOfSight(pWho);
     }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
@@ -148,62 +179,80 @@ struct TRINITY_DLL_DECL npc_ancestral_wolfAI : public npc_escortAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_ancestral_wolf(Creature* pCreature)
 {
     return new npc_ancestral_wolfAI(pCreature);
 }
+
 /*######
 ## go_haaleshi_altar
 ######*/
+
 bool GOHello_go_haaleshi_altar(Player* pPlayer, GameObject* pGo)
 {
     pGo->SummonCreature(C_AERANAS,-1321.79, 4043.80, 116.24, 1.25, TEMPSUMMON_TIMED_DESPAWN, 180000);
     return false;
 }
+
 /*######
 ## npc_naladu
 ######*/
+
 #define GOSSIP_NALADU_ITEM1 "Why don't you escape?"
+
 enum eNaladu
 {
     GOSSIP_TEXTID_NALADU1   = 9788
 };
+
 bool GossipHello_npc_naladu(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_NALADU_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_naladu(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
         pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_NALADU1, pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 ## npc_tracy_proudwell
 ######*/
+
 #define GOSSIP_TEXT_REDEEM_MARKS        "I have marks to redeem!"
 #define GOSSIP_TRACY_PROUDWELL_ITEM1    "I heard that your dog Fei Fei took Klatu's prayer beads..."
 #define GOSSIP_TRACY_PROUDWELL_ITEM2    ""
+
 enum eTracy
 {
     GOSSIP_TEXTID_TRACY_PROUDWELL1       = 10689,
     QUEST_DIGGING_FOR_PRAYER_BEADS       = 10916
 };
+
 bool GossipHello_npc_tracy_proudwell(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_REDEEM_MARKS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     if (pPlayer->GetQuestStatus(QUEST_DIGGING_FOR_PRAYER_BEADS) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TRACY_PROUDWELL_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_tracy_proudwell(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -219,29 +268,36 @@ bool GossipSelect_npc_tracy_proudwell(Player* pPlayer, Creature* pCreature, uint
             pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
             break;
     }
+
     return true;
 }
+
 /*######
 ## npc_trollbane
 ######*/
+
 #define GOSSIP_TROLLBANE_ITEM1      "Tell me of the Sons of Lothar."
 #define GOSSIP_TROLLBANE_ITEM2      ""
 #define GOSSIP_TROLLBANE_ITEM3      "Tell me of your homeland."
+
 enum eTrollbane
 {
     GOSSIP_TEXTID_TROLLBANE1        = 9932,
     GOSSIP_TEXTID_TROLLBANE2        = 9933,
     GOSSIP_TEXTID_TROLLBANE3        = 8772
 };
+
 bool GossipHello_npc_trollbane(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TROLLBANE_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TROLLBANE_ITEM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_trollbane(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -257,11 +313,14 @@ bool GossipSelect_npc_trollbane(Player* pPlayer, Creature* pCreature, uint32 uiS
             pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TROLLBANE3, pCreature->GetGUID());
             break;
     }
+
     return true;
 }
+
 /*######
 ## npc_wounded_blood_elf
 ######*/
+
 enum eWoundedBloodElf
 {
     SAY_ELF_START               = -1000117,
@@ -270,16 +329,21 @@ enum eWoundedBloodElf
     SAY_ELF_SUMMON2             = -1000120,
     SAY_ELF_COMPLETE            = -1000121,
     SAY_ELF_AGGRO               = -1000122,
+
     QUEST_ROAD_TO_FALCON_WATCH  = 9375
 };
+
 struct TRINITY_DLL_DECL npc_wounded_blood_elfAI : public npc_escortAI
 {
     npc_wounded_blood_elfAI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch (i)
         {
         case 0:
@@ -307,62 +371,77 @@ struct TRINITY_DLL_DECL npc_wounded_blood_elfAI : public npc_escortAI
             break;
         }
     }
+
     void Reset() { }
+
     void EnterCombat(Unit* who)
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
             DoScriptText(SAY_ELF_AGGRO, m_creature);
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
 };
+
 CreatureAI* GetAI_npc_wounded_blood_elf(Creature* pCreature)
 {
     return new npc_wounded_blood_elfAI(pCreature);
 }
+
 bool QuestAccept_npc_wounded_blood_elf(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_ROAD_TO_FALCON_WATCH)
     {
         if (npc_escortAI* pEscortAI = CAST_AI(npc_wounded_blood_elfAI, pCreature->AI()))
             pEscortAI->Start(true, false, pPlayer->GetGUID());
+
         // Change faction so mobs attack
         pCreature->setFaction(775);
     }
+
     return true;
 }
+
 void AddSC_hellfire_peninsula()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_aeranas";
     newscript->GetAI = &GetAI_npc_aeranas;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_ancestral_wolf";
     newscript->GetAI = &GetAI_npc_ancestral_wolf;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_haaleshi_altar";
     newscript->pGOHello = &GOHello_go_haaleshi_altar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_naladu";
     newscript->pGossipHello = &GossipHello_npc_naladu;
     newscript->pGossipSelect = &GossipSelect_npc_naladu;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_tracy_proudwell";
     newscript->pGossipHello = &GossipHello_npc_tracy_proudwell;
     newscript->pGossipSelect = &GossipSelect_npc_tracy_proudwell;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_trollbane";
     newscript->pGossipHello = &GossipHello_npc_trollbane;
     newscript->pGossipSelect = &GossipSelect_npc_trollbane;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_wounded_blood_elf";
     newscript->GetAI = &GetAI_npc_wounded_blood_elf;
diff --git a/src/bindings/scripts/scripts/outland/nagrand.cpp b/src/bindings/scripts/scripts/outland/nagrand.cpp
index c589677f1f7..f4f3792283f 100644
--- a/src/bindings/scripts/scripts/outland/nagrand.cpp
+++ b/src/bindings/scripts/scripts/outland/nagrand.cpp
@@ -13,12 +13,14 @@
  * along 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, 9868, 9918, 9874, 9991, 10107, 10108, 10044, 10172, 10646, 10085, 10987. TextId's unknown for altruis_the_sufferer and greatmother_geyah (npc_text)
 SDCategory: Nagrand
 EndScriptData */
+
 /* ContentData
 mob_shattered_rumbler
 mob_lump
@@ -30,20 +32,27 @@ npc_maghar_captive
 npc_creditmarker_visit_with_ancestors
 mob_sparrowhawk
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## mob_shattered_rumbler - this should be done with ACID
 ######*/
+
 struct TRINITY_DLL_DECL mob_shattered_rumblerAI : public ScriptedAI
 {
     bool Spawn;
+
     mob_shattered_rumblerAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         Spawn = false;
     }
+
     void EnterCombat(Unit* who) {}
+
     void SpellHit(Unit *Hitter, const SpellEntry *Spellkind)
     {
         if (Spellkind->Id == 32001 && !Spawn)
@@ -51,6 +60,7 @@ struct TRINITY_DLL_DECL mob_shattered_rumblerAI : public ScriptedAI
             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);
@@ -64,41 +74,54 @@ CreatureAI* GetAI_mob_shattered_rumbler(Creature* pCreature)
 {
     return new mob_shattered_rumblerAI (pCreature);
 }
+
 /*######
 ## mob_lump
 ######*/
+
 #define SPELL_VISUAL_SLEEP  16093
 #define SPELL_SPEAR_THROW   32248
+
 #define LUMP_SAY0 -1000293
 #define LUMP_SAY1 -1000294
+
 #define LUMP_DEFEAT -1000295
+
 #define GOSSIP_HL "I need answers, ogre!"
 #define GOSSIP_SL1 "Why are Boulderfist out this far? You know that this is Kurenai territory."
 #define GOSSIP_SL2 "And you think you can just eat anything you want? You're obviously trying to eat the Broken of Telaar."
 #define GOSSIP_SL3 "This means war, Lump! War I say!"
+
 struct TRINITY_DLL_DECL mob_lumpAI : public ScriptedAI
 {
     mob_lumpAI(Creature *c) : ScriptedAI(c)
     {
         bReset = false;
     }
+
     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 AttackedBy(Unit* pAttacker)
     {
         if (m_creature->getVictim())
             return;
+
         if (m_creature->IsFriendlyTo(pAttacker))
             return;
+
         AttackStart(pAttacker);
     }
+
     void DamageTaken(Unit *done_by, uint32 & damage)
     {
         if (done_by->GetTypeId() == TYPEID_PLAYER && (m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 30)
@@ -107,6 +130,7 @@ struct TRINITY_DLL_DECL mob_lumpAI : public ScriptedAI
             {
                 //Take 0 damage
                 damage = 0;
+
                 CAST_PLR(done_by)->AttackStop();
                 m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                 m_creature->RemoveAllAuras();
@@ -115,18 +139,23 @@ struct TRINITY_DLL_DECL mob_lumpAI : public ScriptedAI
                 m_creature->setFaction(1080);               //friendly
                 m_creature->SetStandState(UNIT_STAND_STATE_SIT);
                 DoScriptText(LUMP_DEFEAT, m_creature);
+
                 bReset = true;
             }
         }
     }
+
     void EnterCombat(Unit *who)
     {
         if (m_creature->HasAura(SPELL_VISUAL_SLEEP))
             m_creature->RemoveAura(SPELL_VISUAL_SLEEP);
+
         if (!m_creature->IsStandState())
              m_creature->SetStandState(UNIT_STAND_STATE_STAND);
+
         DoScriptText(RAND(LUMP_SAY0,LUMP_SAY1), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //check if we waiting for a reset
@@ -141,29 +170,37 @@ struct TRINITY_DLL_DECL mob_lumpAI : public ScriptedAI
             }
             else Reset_Timer -= diff;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             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* pCreature)
 {
     return new mob_lumpAI(pCreature);
 }
+
 bool GossipHello_mob_lump(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(9352, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_mob_lump(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -187,18 +224,23 @@ bool GossipSelect_mob_lump(Player* pPlayer, Creature* pCreature, uint32 uiSender
     }
     return true;
 }
+
 /*####
 # mob_sunspring_villager - should be done with ACID
 ####*/
+
 struct TRINITY_DLL_DECL mob_sunspring_villagerAI : public ScriptedAI
 {
     mob_sunspring_villagerAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
         m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
     }
+
     void EnterCombat(Unit *who) {}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (spell->Id == 32146)
@@ -212,34 +254,44 @@ CreatureAI* GetAI_mob_sunspring_villager(Creature* pCreature)
 {
     return new mob_sunspring_villagerAI (pCreature);
 }
+
 /*######
 ## npc_altruis_the_sufferer
 ######*/
+
 #define GOSSIP_HATS1 "I see twisted steel and smell sundered earth."
 #define GOSSIP_HATS2 "Well...?"
 #define GOSSIP_HATS3 "[PH] Story about Illidan's Pupil"
+
 #define GOSSIP_SATS1 "Legion?"
 #define GOSSIP_SATS2 "And now?"
 #define GOSSIP_SATS3 "How do you see them now?"
 #define GOSSIP_SATS4 "Forge camps?"
 #define GOSSIP_SATS5 "Ok."
 #define GOSSIP_SATS6 "[PH] Story done"
+
 bool GossipHello_npc_altruis_the_sufferer(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     //gossip before obtaining Survey the Land
     if (pPlayer->GetQuestStatus(9991) == QUEST_STATUS_NONE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10);
+
     //gossip when Survey the Land is incomplete (technically, after the flight)
     if (pPlayer->GetQuestStatus(9991) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20);
+
     //wowwiki.com/Varedis
     if (pPlayer->GetQuestStatus(10646) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+30);
+
     pPlayer->SEND_GOSSIP_MENU(9419, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_altruis_the_sufferer(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -263,6 +315,7 @@ bool GossipSelect_npc_altruis_the_sufferer(Player* pPlayer, Creature* pCreature,
         case GOSSIP_ACTION_INFO_DEF+14:
             pPlayer->SEND_GOSSIP_MENU(9424, pCreature->GetGUID());
             break;
+
         case GOSSIP_ACTION_INFO_DEF+20:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21);
             pPlayer->SEND_GOSSIP_MENU(9427, pCreature->GetGUID());
@@ -271,6 +324,7 @@ bool GossipSelect_npc_altruis_the_sufferer(Player* pPlayer, Creature* pCreature,
             pPlayer->CLOSE_GOSSIP_MENU();
             pPlayer->AreaExploredOrEventHappens(9991);
             break;
+
         case GOSSIP_ACTION_INFO_DEF+30:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 31);
             pPlayer->SEND_GOSSIP_MENU(384, pCreature->GetGUID());
@@ -282,6 +336,7 @@ bool GossipSelect_npc_altruis_the_sufferer(Player* pPlayer, Creature* pCreature,
     }
     return true;
 }
+
 bool QuestAccept_npc_altruis_the_sufferer(Player* pPlayer, Creature* pCreature, Quest const *quest)
 {
     if (!pPlayer->GetQuestRewardStatus(9991))              //Survey the Land, q-id 9991
@@ -291,11 +346,14 @@ bool QuestAccept_npc_altruis_the_sufferer(Player* pPlayer, Creature* pCreature,
     }
     return true;
 }
+
 /*######
 ## npc_greatmother_geyah
 ######*/
+
 #define GOSSIP_HGG1 "Hello, Greatmother. Garrosh told me that you wanted to speak with me."
 #define GOSSIP_HGG2 "Garrosh is beyond redemption, Greatmother. I fear that in helping the Mag'har, I have convinced Garrosh that he is unfit to lead."
+
 #define GOSSIP_SGG1 "You raised all of the orcs here, Greatmother?"
 #define GOSSIP_SGG2 "Do you believe that?"
 #define GOSSIP_SGG3 "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."
@@ -307,11 +365,13 @@ bool QuestAccept_npc_altruis_the_sufferer(Player* pPlayer, Creature* pCreature,
 #define GOSSIP_SGG9 "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.)"
 #define GOSSIP_SGG10 "It is my Warchief, Greatmother. The leader of my people. From my world. He ... He is the son of Durotan. He is your grandchild."
 #define GOSSIP_SGG11 "I will return to Azeroth at once, Greatmother."
+
 //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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(10044) == QUEST_STATUS_INCOMPLETE)
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HGG1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -323,9 +383,12 @@ bool GossipHello_npc_greatmother_geyah(Player* pPlayer, Creature* pCreature)
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     }
     else
+
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_greatmother_geyah(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -358,6 +421,7 @@ bool GossipSelect_npc_greatmother_geyah(Player* pPlayer, Creature* pCreature, ui
             pPlayer->AreaExploredOrEventHappens(10044);
             pPlayer->CLOSE_GOSSIP_MENU();
             break;
+
         case GOSSIP_ACTION_INFO_DEF + 10:
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SGG7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11);
             pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
@@ -385,9 +449,11 @@ bool GossipSelect_npc_greatmother_geyah(Player* pPlayer, Creature* pCreature, ui
     }
     return true;
 }
+
 /*######
 ## npc_lantresor_of_the_blade
 ######*/
+
 #define GOSSIP_HLB "I have killed many of your ogres, Lantresor. I have no fear."
 #define GOSSIP_SLB1 "Should I know? You look like an orc to me."
 #define GOSSIP_SLB2 "And the other half?"
@@ -396,15 +462,20 @@ bool GossipSelect_npc_greatmother_geyah(Player* pPlayer, Creature* pCreature, ui
 #define GOSSIP_SLB5 "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."
 #define GOSSIP_SLB6 "We will fight you until the end, then, Lantresor. We will not stand idly by as you pillage our towns and kill our people."
 #define GOSSIP_SLB7 "What do I need to do?"
+
 bool GossipHello_npc_lantresor_of_the_blade(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HLB, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(9361, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_lantresor_of_the_blade(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -447,9 +518,11 @@ bool GossipSelect_npc_lantresor_of_the_blade(Player* pPlayer, Creature* pCreatur
     }
     return true;
 }
+
 /*#####
 ## npc_maghar_captive
 #####*/
+
 enum eMagharCaptive
 {
     SAY_MAG_START               = -1000482,
@@ -459,77 +532,99 @@ enum eMagharCaptive
     SAY_MAG_LIGHTNING           = -1000486,
     SAY_MAG_SHOCK               = -1000487,
     SAY_MAG_COMPLETE            = -1000488,
+
     SPELL_CHAIN_LIGHTNING       = 16006,
     SPELL_EARTHBIND_TOTEM       = 15786,
     SPELL_FROST_SHOCK           = 12548,
     SPELL_HEALING_WAVE          = 12491,
+
     QUEST_TOTEM_KARDASH_H       = 9868,
+
     NPC_MURK_RAIDER             = 18203,
     NPC_MURK_BRUTE              = 18211,
     NPC_MURK_SCAVENGER          = 18207,
     NPC_MURK_PUTRIFIER          = 18202
 };
+
 static float m_afAmbushA[]= {-1568.805786, 8533.873047, 1.958};
 static float m_afAmbushB[]= {-1491.554321, 8506.483398, 1.248};
+
 struct TRINITY_DLL_DECL npc_maghar_captiveAI : public npc_escortAI
 {
     npc_maghar_captiveAI(Creature* pCreature) : npc_escortAI(pCreature) { Reset(); }
+
     uint32 m_uiChainLightningTimer;
     uint32 m_uiHealTimer;
     uint32 m_uiFrostShockTimer;
+
     void Reset()
     {
         m_uiChainLightningTimer = 1000;
         m_uiHealTimer = 0;
         m_uiFrostShockTimer = 6000;
     }
+
     void Aggro(Unit* pWho)
     {
         m_creature->CastSpell(m_creature, SPELL_EARTHBIND_TOTEM, false);
     }
+
     void WaypointReached(uint32 uiPointId)
     {
         switch(uiPointId)
         {
             case 7:
                 DoScriptText(SAY_MAG_MORE, m_creature);
+
                 if (Creature* pTemp = m_creature->SummonCreature(NPC_MURK_PUTRIFIER, m_afAmbushB[0], m_afAmbushB[1], m_afAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000))
                     DoScriptText(SAY_MAG_MORE_REPLY, pTemp);
+
                 m_creature->SummonCreature(NPC_MURK_PUTRIFIER, m_afAmbushB[0]-2.5f, m_afAmbushB[1]-2.5f, m_afAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+
                 m_creature->SummonCreature(NPC_MURK_SCAVENGER, m_afAmbushB[0]+2.5f, m_afAmbushB[1]+2.5f, m_afAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                 m_creature->SummonCreature(NPC_MURK_SCAVENGER, m_afAmbushB[0]+2.5f, m_afAmbushB[1]-2.5f, m_afAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                 break;
             case 16:
                 DoScriptText(SAY_MAG_COMPLETE, m_creature);
+
                 if (Player* pPlayer = GetPlayerForEscort())
                     pPlayer->GroupEventHappens(QUEST_TOTEM_KARDASH_H, m_creature);
+
                 SetRun();
                 break;
         }
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (pSummoned->GetEntry() == NPC_MURK_BRUTE)
             DoScriptText(SAY_MAG_NO_ESCAPE, pSummoned);
+
         if (pSummoned->isTotem())
             return;
+
         pSummoned->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
         pSummoned->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
         pSummoned->AI()->AttackStart(m_creature);
+
     }
+
     void SpellHitTarget(Unit* pTarget, const SpellEntry* pSpell)
     {
         if (pSpell->Id == SPELL_CHAIN_LIGHTNING)
         {
             if (rand()%10)
                 return;
+
             DoScriptText(SAY_MAG_LIGHTNING, m_creature);
         }
     }
+
     void UpdateEscortAI(const uint32 uiDiff)
     {
         if (/*!m_creature->SelectHostilTarget() ||*/ !m_creature->getVictim())
             return;
+
         if (m_uiChainLightningTimer < uiDiff)
         {
             DoCast(m_creature->getVictim(), SPELL_CHAIN_LIGHTNING);
@@ -537,6 +632,7 @@ struct TRINITY_DLL_DECL npc_maghar_captiveAI : public npc_escortAI
         }
         else
             m_uiChainLightningTimer -= uiDiff;
+
         if (m_creature->GetHealth()*100 < m_creature->GetMaxHealth()*30)
         {
             if (m_uiHealTimer < uiDiff)
@@ -547,6 +643,7 @@ struct TRINITY_DLL_DECL npc_maghar_captiveAI : public npc_escortAI
             else
                 m_uiHealTimer -= uiDiff;
         }
+
         if (m_uiFrostShockTimer < uiDiff)
         {
             DoCast(m_creature->getVictim(), SPELL_FROST_SHOCK);
@@ -554,9 +651,11 @@ struct TRINITY_DLL_DECL npc_maghar_captiveAI : public npc_escortAI
         }
         else
             m_uiFrostShockTimer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 bool QuestAccept_npc_maghar_captive(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_TOTEM_KARDASH_H)
@@ -565,8 +664,11 @@ bool QuestAccept_npc_maghar_captive(Player* pPlayer, Creature* pCreature, const
         {
             pCreature->SetStandState(UNIT_STAND_STATE_STAND);
             pCreature->setFaction(232);
+
             pEscortAI->Start(true, false, pPlayer->GetGUID(), pQuest);
+
             DoScriptText(SAY_MAG_START, pCreature);
+
             pCreature->SummonCreature(NPC_MURK_RAIDER, m_afAmbushA[0]+2.5f, m_afAmbushA[1]-2.5f, m_afAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
             pCreature->SummonCreature(NPC_MURK_PUTRIFIER, m_afAmbushA[0]-2.5f, m_afAmbushA[1]+2.5f, m_afAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
             pCreature->SummonCreature(NPC_MURK_BRUTE, m_afAmbushA[0], m_afAmbushA[1], m_afAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
@@ -574,22 +676,29 @@ bool QuestAccept_npc_maghar_captive(Player* pPlayer, Creature* pCreature, const
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_maghar_captive(Creature* pCreature)
 {
     return new npc_maghar_captiveAI(pCreature);
 }
+
 /*######
 ## npc_creditmarker_visist_with_ancestors
 ######*/
+
 struct TRINITY_DLL_DECL npc_creditmarker_visit_with_ancestorsAI : public ScriptedAI
 {
     npc_creditmarker_visit_with_ancestorsAI(Creature* c) : ScriptedAI(c) {}
+
     void Reset() {}
+
     void EnterCombat(Unit* who) {}
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who)
             return;
+
         if (who->GetTypeId() == TYPEID_PLAYER)
         {
             if (CAST_PLR(who)->GetQuestStatus(10085) == QUEST_STATUS_INCOMPLETE)
@@ -605,21 +714,28 @@ struct TRINITY_DLL_DECL npc_creditmarker_visit_with_ancestorsAI : public Scripte
         }
     }
 };
+
 CreatureAI* GetAI_npc_creditmarker_visit_with_ancestors(Creature* pCreature)
 {
     return new npc_creditmarker_visit_with_ancestorsAI (pCreature);
 }
+
 /*######
 ## mob_sparrowhawk
 ######*/
+
 #define SPELL_SPARROWHAWK_NET 39810
 #define SPELL_ITEM_CAPTIVE_SPARROWHAWK 39812
+
 struct TRINITY_DLL_DECL mob_sparrowhawkAI : public ScriptedAI
 {
+
     mob_sparrowhawkAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Check_Timer;
     uint64 PlayerGUID;
     bool fleeing;
+
     void Reset()
     {
         m_creature->RemoveAurasDueToSpell(SPELL_SPARROWHAWK_NET);
@@ -631,20 +747,26 @@ struct TRINITY_DLL_DECL mob_sparrowhawkAI : public ScriptedAI
     {
         if (PlayerGUID)
             return;
+
         ScriptedAI::AttackStart(who);
     }
+
     void EnterCombat(Unit* who) {}
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || PlayerGUID)
             return;
+
         if (!PlayerGUID && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 30) && CAST_PLR(who)->GetQuestStatus(10987) == QUEST_STATUS_INCOMPLETE)
         {
             PlayerGUID = who->GetGUID();
             return;
         }
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Check_Timer < diff)
@@ -653,6 +775,7 @@ struct TRINITY_DLL_DECL mob_sparrowhawkAI : public ScriptedAI
             {
                 if (fleeing && m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLEEING_MOTION_TYPE)
                     fleeing = false;
+
                 Player* pPlayer = Unit::GetPlayer(PlayerGUID);
                 if (pPlayer && m_creature->IsWithinDistInMap(pPlayer, 30))
                 {
@@ -672,10 +795,13 @@ struct TRINITY_DLL_DECL mob_sparrowhawkAI : public ScriptedAI
             }
             Check_Timer = 1000;
         } else Check_Timer -= diff;
+
         if (PlayerGUID)
             return;
+
         ScriptedAI::UpdateAI(diff);
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (caster->GetTypeId() == TYPEID_PLAYER)
@@ -690,55 +816,67 @@ struct TRINITY_DLL_DECL mob_sparrowhawkAI : public ScriptedAI
         return;
     }
 };
+
 CreatureAI* GetAI_mob_sparrowhawk(Creature* pCreature)
 {
     return new mob_sparrowhawkAI (pCreature);
 }
+
 /*####
 #
 ####*/
+
 void AddSC_nagrand()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_shattered_rumbler";
     newscript->GetAI = &GetAI_mob_shattered_rumbler;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_lump";
     newscript->GetAI = &GetAI_mob_lump;
     newscript->pGossipHello =  &GossipHello_mob_lump;
     newscript->pGossipSelect = &GossipSelect_mob_lump;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_sunspring_villager";
     newscript->GetAI = &GetAI_mob_sunspring_villager;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_greatmother_geyah";
     newscript->pGossipHello =  &GossipHello_npc_greatmother_geyah;
     newscript->pGossipSelect = &GossipSelect_npc_greatmother_geyah;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_maghar_captive";
     newscript->GetAI = &GetAI_npc_maghar_captive;
     newscript->pQuestAccept = &QuestAccept_npc_maghar_captive;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_creditmarker_visit_with_ancestors";
     newscript->GetAI = &GetAI_npc_creditmarker_visit_with_ancestors;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_sparrowhawk";
     newscript->GetAI = &GetAI_mob_sparrowhawk;
diff --git a/src/bindings/scripts/scripts/outland/netherstorm.cpp b/src/bindings/scripts/scripts/outland/netherstorm.cpp
index 5a8cb6399ec..d648c26b571 100644
--- a/src/bindings/scripts/scripts/outland/netherstorm.cpp
+++ b/src/bindings/scripts/scripts/outland/netherstorm.cpp
@@ -13,23 +13,28 @@
  * along 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: 10337, 10438, 10652 (special flight paths), 10299,10321,10322,10323,10329,10330,10338,10365(Shutting Down Manaforge), 10198
 SDCategory: Netherstorm
 EndScriptData */
+
 /* ContentData
 npc_manaforge_control_console
 go_manaforge_control_console
 npc_commander_dawnforge
 npc_bessy
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_manaforge_control_console
 ######*/
+
 //used by 20209,20417,20418,20440, signed for 20209
 #define EMOTE_START     -1000296
 #define EMOTE_60        -1000297
@@ -37,21 +42,27 @@ EndContentData */
 #define EMOTE_10        -1000299
 #define EMOTE_COMPLETE  -1000300
 #define EMOTE_ABORT     -1000301
+
 #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 TRINITY_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI
 {
     npc_manaforge_control_consoleAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Event_Timer;
     uint32 Wave_Timer;
     uint32 Phase;
@@ -59,6 +70,7 @@ struct TRINITY_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI
     uint64 someplayer;
     uint64 goConsole;
     Creature* add;
+
     void Reset()
     {
         Event_Timer = 3000;
@@ -69,7 +81,9 @@ struct TRINITY_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI
         goConsole = 0;
         Creature* add = NULL;
     }
+
     void EnterCombat(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
@@ -77,9 +91,11 @@ struct TRINITY_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI
         if (spell->Id == SPELL_INTERRUPT_1)
             DoSay("Silence! I kill you!",LANG_UNIVERSAL, NULL);
     }*/
+
     void JustDied(Unit* killer)
     {
         DoScriptText(EMOTE_ABORT, m_creature);
+
         if (someplayer)
         {
             Unit* p = Unit::GetUnit((*m_creature),someplayer);
@@ -106,12 +122,14 @@ struct TRINITY_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI
                 }
             }
         }
+
         if (goConsole)
         {
             if (GameObject* pGo = GameObject::GetGameObject((*m_creature),goConsole))
                 pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
         }
     }
+
     void DoWaveSpawnForCreature(Creature* pCreature)
     {
         switch(pCreature->GetEntry())
@@ -198,6 +216,7 @@ struct TRINITY_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI
                 break;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Event_Timer < diff)
@@ -249,6 +268,7 @@ struct TRINITY_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI
                     break;
             }
         } else Event_Timer -= diff;
+
         if (Wave)
         {
             if (Wave_Timer < diff)
@@ -262,9 +282,11 @@ CreatureAI* GetAI_npc_manaforge_control_console(Creature* pCreature)
 {
     return new npc_manaforge_control_consoleAI (pCreature);
 }
+
 /*######
 ## go_manaforge_control_console
 ######*/
+
 //TODO: clean up this workaround when Trinity adds support to do it properly (with gossip selections instead of instant summon)
 bool GOHello_go_manaforge_control_console(Player* pPlayer, GameObject* pGo)
 {
@@ -273,8 +295,10 @@ bool GOHello_go_manaforge_control_console(Player* pPlayer, GameObject* pGo)
         pPlayer->PrepareQuestMenu(pGo->GetGUID());
         pPlayer->SendPreparedQuest(pGo->GetGUID());
     }
+
     Creature* manaforge;
     manaforge = NULL;
+
     switch(pGo->GetAreaId())
     {
         case 3726:                                          //b'naar
@@ -298,6 +322,7 @@ bool GOHello_go_manaforge_control_console(Player* pPlayer, GameObject* pGo)
                 manaforge = pPlayer->SummonCreature(ENTRY_ARA_C_CONSOLE,4013.71,4028.76,192.10,1.25,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000);
             break;
     }
+
     if (manaforge)
     {
         CAST_AI(npc_manaforge_control_consoleAI, manaforge->AI())->someplayer = pPlayer->GetGUID();
@@ -306,9 +331,11 @@ bool GOHello_go_manaforge_control_console(Player* pPlayer, GameObject* pGo)
     }
     return true;
 }
+
 /*######
 ## npc_commander_dawnforge
 ######*/
+
 // The Speech of Dawnforge, Ardonis & Pathaleon
 #define SAY_COMMANDER_DAWNFORGE_1           -1000128
 #define SAY_ARCANIST_ARDONIS_1              -1000129
@@ -321,8 +348,10 @@ bool GOHello_go_manaforge_control_console(Player* pPlayer, GameObject* pGo)
 #define SAY_COMMANDER_DAWNFORGE_4           -1000136
 #define SAY_ARCANIST_ARDONIS_2              -1000136
 #define SAY_COMMANDER_DAWNFORGE_5           -1000137
+
 #define QUEST_INFO_GATHERING                10198
 #define SPELL_SUNFURY_DISGUISE              34603
+
 // Entries of Arcanist Ardonis, Commander Dawnforge, Pathaleon the Curators Image
 const uint32 CreatureEntry[3] =
 {
@@ -330,77 +359,96 @@ const uint32 CreatureEntry[3] =
     19831,                                                // Dawnforge
     21504                                                 // Pathaleon
 };
+
 struct TRINITY_DLL_DECL npc_commander_dawnforgeAI : public ScriptedAI
 {
     npc_commander_dawnforgeAI(Creature *c) : ScriptedAI(c) { Reset (); }
 
+
     uint64 PlayerGUID;
     uint64 ardonisGUID;
     uint64 pathaleonGUID;
 
+
     uint32 Phase;
     uint32 PhaseSubphase;
     uint32 Phase_Timer;
     bool isEvent;
+
     float angle_dawnforge;
     float angle_ardonis;
+
     void Reset()
     {
         PlayerGUID = 0;
         ardonisGUID = 0;
         pathaleonGUID = 0;
+
         Phase = 1;
         PhaseSubphase = 0;
         Phase_Timer = 4000;
         isEvent = false;
     }
+
     void EnterCombat(Unit *who) { }
+
     void JustSummoned(Creature *summoned)
     {
         pathaleonGUID = summoned->GetGUID();
     }
+
     // Emote Ardonis and Pathaleon
     void Turn_to_Pathaleons_Image()
     {
         Creature *ardonis = Unit::GetCreature(*m_creature,ardonisGUID);
         Creature *pathaleon = Unit::GetCreature(*m_creature,pathaleonGUID);
         Player* pPlayer = Unit::GetPlayer(PlayerGUID);
+
         if (!ardonis || !pathaleon || !pPlayer)
             return;
+
         //Calculate the angle to Pathaleon
         angle_dawnforge = m_creature->GetAngle(pathaleon->GetPositionX(), pathaleon->GetPositionY());
         angle_ardonis = ardonis->GetAngle(pathaleon->GetPositionX(), pathaleon->GetPositionY());
+
         //Turn Dawnforge and update
         m_creature->SetOrientation(angle_dawnforge);
         m_creature->SendUpdateToPlayer(pPlayer);
         //Turn Ardonis and update
         ardonis->SetOrientation(angle_ardonis);
         ardonis->SendUpdateToPlayer(pPlayer);
+
         //Set them to kneel
         m_creature->SetStandState(UNIT_STAND_STATE_KNEEL);
         ardonis->SetStandState(UNIT_STAND_STATE_KNEEL);
     }
+
     //Set them back to each other
     void Turn_to_eachother()
     {
         if (Unit *ardonis = Unit::GetUnit(*m_creature,ardonisGUID))
         {
             Player* pPlayer = Unit::GetPlayer(PlayerGUID);
+
             if (!pPlayer)
                 return;
+
             angle_dawnforge = m_creature->GetAngle(ardonis->GetPositionX(), ardonis->GetPositionY());
             angle_ardonis = ardonis->GetAngle(m_creature->GetPositionX(), m_creature->GetPositionY());
+
             //Turn Dawnforge and update
             m_creature->SetOrientation(angle_dawnforge);
             m_creature->SendUpdateToPlayer(pPlayer);
             //Turn Ardonis and update
             ardonis->SetOrientation(angle_ardonis);
             ardonis->SendUpdateToPlayer(pPlayer);
+
             //Set state
             m_creature->SetStandState(UNIT_STAND_STATE_STAND);
             ardonis->SetStandState(UNIT_STAND_STATE_STAND);
         }
     }
+
     bool CanStartEvent(Player* pPlayer)
     {
         if (!isEvent)
@@ -408,39 +456,49 @@ struct TRINITY_DLL_DECL npc_commander_dawnforgeAI : public ScriptedAI
             Creature* ardonis = me->FindNearestCreature(CreatureEntry[0], 10.0f);
             if (!ardonis)
                 return false;
+
             ardonisGUID = ardonis->GetGUID();
             PlayerGUID = pPlayer->GetGUID();
+
             isEvent = true;
+
             Turn_to_eachother();
             return true;
         }
+
         debug_log("TSCR: npc_commander_dawnforge event already in progress, need to wait.");
         return false;
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Is event even running?
         if (!isEvent)
             return;
+
         //Phase timing
         if (Phase_Timer >= diff)
         {
             Phase_Timer -= diff;
             return;
         }
+
         Unit *ardonis = Unit::GetUnit(*m_creature,ardonisGUID);
         Unit *pathaleon = Unit::GetUnit(*m_creature,pathaleonGUID);
         Player* pPlayer = Unit::GetPlayer(PlayerGUID);
+
         if (!ardonis || !pPlayer)
         {
             Reset();
             return;
         }
+
         if (Phase > 4 && !pathaleon)
         {
             Reset();
             return;
         }
+
         //Phase 1 Dawnforge say
         switch (Phase)
         {
@@ -543,42 +601,55 @@ struct TRINITY_DLL_DECL npc_commander_dawnforgeAI : public ScriptedAI
         }
      }
 };
+
 CreatureAI* GetAI_npc_commander_dawnforge(Creature* pCreature)
 {
     return new npc_commander_dawnforgeAI(pCreature);
 }
+
 bool AreaTrigger_at_commander_dawnforge(Player* pPlayer, AreaTriggerEntry *at)
 {
     //if player lost aura or not have at all, we should not try start event.
     if (!pPlayer->HasAura(SPELL_SUNFURY_DISGUISE))
         return false;
+
     if (pPlayer->isAlive() && pPlayer->GetQuestStatus(QUEST_INFO_GATHERING) == QUEST_STATUS_INCOMPLETE)
     {
         Creature* Dawnforge = pPlayer->FindNearestCreature(CreatureEntry[1], 30.0f);
+
         if (!Dawnforge)
             return false;
+
         if (CAST_AI(npc_commander_dawnforgeAI, Dawnforge->AI())->CanStartEvent(pPlayer))
             return true;
     }
     return false;
 }
+
 /*######
 ## npc_professor_dabiri
 ######*/
+
 #define SPELL_PHASE_DISTRUPTOR  35780
 #define GOSSIP_ITEM "I need a new phase distruptor, Professor"
 #define WHISPER_DABIRI -1000302
+
 #define QUEST_DIMENSIUS 10439
 #define QUEST_ON_NETHERY_WINGS 10438
+
 bool GossipHello_npc_professor_dabiri(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_ON_NETHERY_WINGS) == QUEST_STATUS_INCOMPLETE && !pPlayer->HasItemCount(29778, 1))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_professor_dabiri(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -586,54 +657,69 @@ bool GossipSelect_npc_professor_dabiri(Player* pPlayer, Creature* pCreature, uin
         pCreature->CastSpell(pPlayer, SPELL_PHASE_DISTRUPTOR, false);
         pPlayer->CLOSE_GOSSIP_MENU();
     }
+
     return true;
 }
+
 bool QuestAccept_npc_professor_dabiri(Player* pPlayer, Creature* pCreature, Quest const *quest)
 {
     if (quest->GetQuestId() == QUEST_DIMENSIUS)
         DoScriptText(WHISPER_DABIRI, pCreature, pPlayer);
+
     return true;
 }
+
 /*######
 ## mob_phase_hunter
 ######*/
+
 #define SUMMONED_MOB            19595
 #define EMOTE_WEAK              -1000303
+
 // Spells
 #define SPELL_PHASE_SLIP        36574
 #define SPELL_MANA_BURN         13321
 #define SPELL_MATERIALIZE       34804
 #define SPELL_DE_MATERIALIZE    34804
+
 struct TRINITY_DLL_DECL mob_phase_hunterAI : public ScriptedAI
 {
+
     mob_phase_hunterAI(Creature *c) : ScriptedAI(c) {}
+
     bool Weak;
     bool Materialize;
     bool Drained;
+
     int WeakPercent;
     uint64 PlayerGUID;
     uint32 Health;
     uint32 Level;
     uint32 PhaseSlipVulnerabilityTimer;
     uint32 ManaBurnTimer;
+
     void Reset()
     {
         Weak = false;
         Materialize = false;
         Drained = false;
+
         WeakPercent = 25 + (rand()%16); // 25-40
         PlayerGUID = 0;
         ManaBurnTimer = 5000 + (rand()%3 * 1000); // 5-8 sec cd
     }
+
     void EnterCombat(Unit *who)
     {
         if (Player* pPlayer = who->GetCharmerOrOwnerPlayerOrPlayerItself())
             PlayerGUID = pPlayer->GetGUID();
     }
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         DoCast(m_creature, SPELL_DE_MATERIALIZE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Materialize)
@@ -641,10 +727,13 @@ struct TRINITY_DLL_DECL mob_phase_hunterAI : public ScriptedAI
             DoCast(m_creature, SPELL_MATERIALIZE);
             Materialize = true;
         }
+
         if (m_creature->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED) || m_creature->hasUnitState(UNIT_STAT_ROOT)) // if the mob is rooted/slowed by spells eg.: Entangling Roots, Frost Nova, Hamstring, Crippling Poison, etc. => remove it
             DoCast(m_creature, SPELL_PHASE_SLIP);
+
         if (!UpdateVictim())
             return;
+
         if (ManaBurnTimer < diff) // cast Mana Burn
         {
             if (m_creature->getVictim()->GetCreateMana() > 0)
@@ -653,9 +742,11 @@ struct TRINITY_DLL_DECL mob_phase_hunterAI : public ScriptedAI
                 ManaBurnTimer = 8000 + (rand()%10 * 1000); // 8-18 sec cd
             }
         }else ManaBurnTimer -= diff;
+
         if (PlayerGUID) // start: support for quest 10190
         {
             Unit* target = Unit::GetUnit((*m_creature), PlayerGUID);
+
             if (target && !Weak && m_creature->GetHealth() < (m_creature->GetMaxHealth() / 100 * WeakPercent)
                 && CAST_PLR(target)->GetQuestStatus(10190) == QUEST_STATUS_INCOMPLETE)
             {
@@ -665,14 +756,19 @@ struct TRINITY_DLL_DECL mob_phase_hunterAI : public ScriptedAI
             if (Weak && !Drained && m_creature->HasAura(34219))
             {
                 Drained = true;
+
                 Health = m_creature->GetHealth(); // get the normal mob's data
                 Level = m_creature->getLevel();
+
                 m_creature->AttackStop(); // delete the normal mob
                 m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                 m_creature->RemoveCorpse();
+
                 Creature* DrainedPhaseHunter = NULL;
+
                 if (!DrainedPhaseHunter)
                     DrainedPhaseHunter = m_creature->SummonCreature(SUMMONED_MOB, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); // summon the mob
+
                 if (DrainedPhaseHunter)
                 {
                     DrainedPhaseHunter->SetLevel(Level); // set the summoned mob's data
@@ -682,35 +778,45 @@ struct TRINITY_DLL_DECL mob_phase_hunterAI : public ScriptedAI
                 }
             }
         }// end: support for quest 10190
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_phase_hunter(Creature* pCreature)
 {
     return new mob_phase_hunterAI (pCreature);
 }
+
 /*######
 ## npc_bessy
 ######*/
+
 #define Q_ALMABTRIEB    10337
 #define N_THADELL       20464
 #define SPAWN_FIRST     20512
 #define SPAWN_SECOND    19881
 #define SAY_THADELL_1   -1000304
 #define SAY_THADELL_2   -1000305
+
 struct TRINITY_DLL_DECL npc_bessyAI : public npc_escortAI
 {
+
     npc_bessyAI(Creature *c) : npc_escortAI(c) {}
+
     void JustDied(Unit* killer)
     {
         if (Player* pPlayer = GetPlayerForEscort())
             pPlayer->FailQuest(Q_ALMABTRIEB);
     }
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
             case 3: //first spawn
@@ -718,10 +824,12 @@ struct TRINITY_DLL_DECL npc_bessyAI : public npc_escortAI
                 m_creature->SummonCreature(SPAWN_FIRST, 2449.53, 2184.43, 96.36, 6.27, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                 m_creature->SummonCreature(SPAWN_FIRST, 2449.85, 2186.34, 97.57, 6.08, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                 break;
+
             case 7:
                 m_creature->SummonCreature(SPAWN_SECOND, 2309.64, 2186.24, 92.25, 6.06, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                 m_creature->SummonCreature(SPAWN_SECOND, 2309.25, 2183.46, 91.75, 6.22, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                 break;
+
             case 12:
                 if (pPlayer)
                     pPlayer->GroupEventHappens(Q_ALMABTRIEB, m_creature);
@@ -732,15 +840,19 @@ struct TRINITY_DLL_DECL npc_bessyAI : public npc_escortAI
                     DoScriptText(SAY_THADELL_2, m_creature, pPlayer); break;
         }
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AI()->AttackStart(m_creature);
     }
+
     void Reset()
     {
         me->RestoreFaction();
     }
+
 };
+
 bool QuestAccept_npc_bessy(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == Q_ALMABTRIEB)
@@ -751,42 +863,52 @@ bool QuestAccept_npc_bessy(Player* pPlayer, Creature* pCreature, Quest const* qu
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_bessy(Creature* pCreature)
 {
     return new npc_bessyAI(pCreature);
 }
+
 /*######
 ##
 ######*/
+
 void AddSC_netherstorm()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "go_manaforge_control_console";
     newscript->pGOHello = &GOHello_go_manaforge_control_console;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_manaforge_control_console";
     newscript->GetAI = &GetAI_npc_manaforge_control_console;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_commander_dawnforge";
     newscript->GetAI = &GetAI_npc_commander_dawnforge;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "at_commander_dawnforge";
     newscript->pAreaTrigger = &AreaTrigger_at_commander_dawnforge;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_professor_dabiri";
     newscript->pGossipHello =   &GossipHello_npc_professor_dabiri;
     newscript->pGossipSelect =  &GossipSelect_npc_professor_dabiri;
     newscript->pQuestAccept = &QuestAccept_npc_professor_dabiri;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_phase_hunter";
     newscript->GetAI = &GetAI_mob_phase_hunter;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_bessy";
     newscript->GetAI = &GetAI_npc_bessy;
diff --git a/src/bindings/scripts/scripts/outland/shadowmoon_valley.cpp b/src/bindings/scripts/scripts/outland/shadowmoon_valley.cpp
index a0424c5ac7d..3a6a121ff4d 100644
--- a/src/bindings/scripts/scripts/outland/shadowmoon_valley.cpp
+++ b/src/bindings/scripts/scripts/outland/shadowmoon_valley.cpp
@@ -13,12 +13,14 @@
  * along 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, 10458, 10481, 10480, 11082, 10781, 10451. Vendor Drake Dealer Hurlunk.
 SDCategory: Shadowmoon Valley
 EndScriptData */
+
 /* ContentData
 mob_mature_netherwing_drake
 mob_enslaved_netherwing_drake
@@ -36,53 +38,70 @@ npc_lord_illidan_stormrage
 go_crystal_prison
 npc_enraged_spirit
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*#####
 # mob_mature_netherwing_drake
 #####*/
+
 enum eMatureNetherwing
 {
     SAY_JUST_EATEN              = -1000222,
+
     SPELL_PLACE_CARCASS         = 38439,
     SPELL_JUST_EATEN            = 38502,
     SPELL_NETHER_BREATH         = 38467,
     POINT_ID                    = 1,
+
     GO_CARCASS                  = 185155,
+
     QUEST_KINDNESS              = 10804,
     NPC_EVENT_PINGER            = 22131
 };
 
+
 struct TRINITY_DLL_DECL mob_mature_netherwing_drakeAI : public ScriptedAI
 {
     mob_mature_netherwing_drakeAI(Creature* c) : ScriptedAI(c) { }
+
     uint64 uiPlayerGUID;
+
     bool bCanEat;
     bool bIsEating;
+
     uint32 EatTimer;
     uint32 CastTimer;
+
     void Reset()
     {
         uiPlayerGUID = 0;
+
         bCanEat = false;
         bIsEating = false;
+
         EatTimer = 5000;
         CastTimer = 5000;
     }
+
     void SpellHit(Unit* pCaster, SpellEntry const* pSpell)
     {
         if (bCanEat || bIsEating)
             return;
+
         if (pCaster->GetTypeId() == TYPEID_PLAYER && pSpell->Id == SPELL_PLACE_CARCASS && !m_creature->HasAura(SPELL_JUST_EATEN))
         {
             uiPlayerGUID = pCaster->GetGUID();
             bCanEat = true;
         }
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type != POINT_MOTION_TYPE)
             return;
+
         if (id == POINT_ID)
         {
             bIsEating = true;
@@ -90,6 +109,7 @@ struct TRINITY_DLL_DECL mob_mature_netherwing_drakeAI : public ScriptedAI
             m_creature->HandleEmoteCommand(EMOTE_ONESHOT_ATTACKUNARMED);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (bCanEat || bIsEating)
@@ -104,8 +124,10 @@ struct TRINITY_DLL_DECL mob_mature_netherwing_drakeAI : public ScriptedAI
                         {
                             if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
                                 m_creature->GetMotionMaster()->MovementExpired();
+
                             m_creature->GetMotionMaster()->MoveIdle();
                             m_creature->StopMoving();
+
                             m_creature->GetMotionMaster()->MovePoint(POINT_ID, pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ());
                         }
                     }
@@ -115,43 +137,56 @@ struct TRINITY_DLL_DECL mob_mature_netherwing_drakeAI : public ScriptedAI
                 {
                     DoCast(m_creature, SPELL_JUST_EATEN);
                     DoScriptText(SAY_JUST_EATEN, m_creature);
+
                     if (Player* pPlr = Unit::GetPlayer(uiPlayerGUID))
                     {
                         pPlr->KilledMonsterCredit(NPC_EVENT_PINGER, m_creature->GetGUID());
+
                         if (GameObject* pGo = pPlr->FindNearestGameObject(GO_CARCASS, 10))
                             pGo->Delete();
                     }
+
                     Reset();
                     m_creature->GetMotionMaster()->Clear();
                 }
             }
             else
                 EatTimer -= diff;
+
         return;
         }
+
         if (!UpdateVictim())
             return;
+
         if (CastTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_NETHER_BREATH);
             CastTimer = 5000;
         }else CastTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_mature_netherwing_drake(Creature* pCreature)
 {
     return new mob_mature_netherwing_drakeAI(pCreature);
 }
+
 /*###
 # 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 TRINITY_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI
 {
     mob_enslaved_netherwing_drakeAI(Creature* c) : ScriptedAI(c)
@@ -160,42 +195,53 @@ struct TRINITY_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI
         Tapped = false;
         Reset();
     }
+
     uint64 PlayerGUID;
     uint32 FlyTimer;
     bool Tapped;
+
     void Reset()
     {
         if (!Tapped)
             m_creature->setFaction(FACTION_DEFAULT);
+
         FlyTimer = 10000;
         m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
         m_creature->SetVisibility(VISIBILITY_ON);
     }
+
     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);
+
             Unit* Dragonmaw = me->FindNearestCreature(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)
@@ -203,6 +249,7 @@ struct TRINITY_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI
                 Unit* plr = Unit::GetUnit((*m_creature), PlayerGUID);
                 if (plr)
                     DoCast(plr, SPELL_FORCE_OF_NELTHARAKU, true);
+
                 PlayerGUID = 0;
             }
             m_creature->SetVisibility(VISIBILITY_OFF);
@@ -211,6 +258,7 @@ struct TRINITY_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI
             m_creature->RemoveCorpse();
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -228,9 +276,11 @@ struct TRINITY_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI
                         /*
                         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*/
+
                         Position pos;
                         if(Unit* EscapeDummy = me->FindNearestCreature(CREATURE_ESCAPE_DUMMY, 30))
                             EscapeDummy->GetPosition(&pos);
@@ -239,6 +289,7 @@ struct TRINITY_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI
                             m_creature->GetRandomNearPosition(pos, 20);
                             pos.m_positionZ += 25;
                         }
+
                         m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
                         m_creature->GetMotionMaster()->MovePoint(1, pos);
                     }
@@ -246,52 +297,65 @@ struct TRINITY_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI
             }else FlyTimer -= diff;
             return;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_enslaved_netherwing_drake(Creature* pCreature)
 {
     return new mob_enslaved_netherwing_drakeAI(pCreature);
 }
+
 /*#####
 # mob_dragonmaw_peon
 #####*/
+
 struct TRINITY_DLL_DECL mob_dragonmaw_peonAI : public ScriptedAI
 {
     mob_dragonmaw_peonAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 PlayerGUID;
     bool Tapped;
     uint32 PoisonTimer;
+
     void Reset()
     {
         PlayerGUID = 0;
         Tapped = false;
         PoisonTimer = 0;
     }
+
     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)
@@ -308,40 +372,53 @@ struct TRINITY_DLL_DECL mob_dragonmaw_peonAI : public ScriptedAI
         }else PoisonTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_mob_dragonmaw_peon(Creature* pCreature)
 {
     return new mob_dragonmaw_peonAI(pCreature);
 }
+
 /*######
 ## npc_drake_dealer_hurlunk
 ######*/
+
 bool GossipHello_npc_drake_dealer_hurlunk(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isVendor() && pPlayer->GetReputationRank(1015) == REP_EXALTED)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_drake_dealer_hurlunk(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 ## npc_flanis_swiftwing_and_kagrosh
 ######*/
+
 #define GOSSIP_HSK1 "Take Flanis's Pack"
 #define GOSSIP_HSK2 "Take Kagrosh's Pack"
+
 bool GossipHello_npcs_flanis_swiftwing_and_kagrosh(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(10583) == QUEST_STATUS_INCOMPLETE && !pPlayer->HasItemCount(30658,1,true))
         pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_HSK1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     if (pPlayer->GetQuestStatus(10601) == QUEST_STATUS_INCOMPLETE && !pPlayer->HasItemCount(30659,1,true))
         pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_HSK2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npcs_flanis_swiftwing_and_kagrosh(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -366,23 +443,29 @@ bool GossipSelect_npcs_flanis_swiftwing_and_kagrosh(Player* pPlayer, Creature* p
     }
     return true;
 }
+
 /*######
 ## npc_murkblood_overseer
 ######*/
+
 #define QUEST_11082     11082
+
 #define GOSSIP_HMO "I am here for you, overseer."
 #define GOSSIP_SMO1 "How dare you question an overseer of the Dragonmaw!"
 #define GOSSIP_SMO2 "Who speaks of me? What are you talking about, broken?"
 #define GOSSIP_SMO3 "Continue please."
 #define GOSSIP_SMO4 "Who are these bidders?"
 #define GOSSIP_SMO5 "Well... yes."
+
 bool GossipHello_npc_murkblood_overseer(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_11082) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_HMO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(10940, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_murkblood_overseer(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -421,22 +504,29 @@ bool GossipSelect_npc_murkblood_overseer(Player* pPlayer, Creature* pCreature, u
     }
     return true;
 }
+
 /*######
 ## npc_neltharaku
 ######*/
+
 #define GOSSIP_HN "I am listening, dragon"
 #define GOSSIP_SN1 "But you are dragons! How could orcs do this to you?"
 #define GOSSIP_SN2 "Your mate?"
 #define GOSSIP_SN3 "I have battled many beasts, dragon. I will help you."
+
 bool GossipHello_npc_neltharaku(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(10814) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_HN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(10613, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_neltharaku(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -460,9 +550,11 @@ bool GossipSelect_npc_neltharaku(Player* pPlayer, Creature* pCreature, uint32 ui
     }
     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?"
@@ -470,20 +562,24 @@ bool GossipSelect_npc_neltharaku(Player* pPlayer, Creature* pCreature, uint32 ui
 #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* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
     if (pCreature->isVendor())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     if (pPlayer->GetQuestStatus(10519) == QUEST_STATUS_INCOMPLETE)
     {
         pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_ORONOK1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
         pPlayer->SEND_GOSSIP_MENU(10312, pCreature->GetGUID());
     }else
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_oronok_tornheart(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -522,38 +618,50 @@ bool GossipSelect_npc_oronok_tornheart(Player* pPlayer, Creature* pCreature, uin
     }
     return true;
 }
+
 /*####
 # npc_karynaku
 ####*/
+
 enum eKarynaku
 {
     QUEST_ALLY_OF_NETHER    = 10870,
+
     TAXI_PATH_ID            = 649
 };
+
 bool QuestAccept_npc_karynaku(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_ALLY_OF_NETHER)
         pPlayer->ActivateTaxiPathTo(TAXI_PATH_ID);        //pPlayer->ActivateTaxiPathTo(649);
+
     return true;
 }
+
 /*####
 # npc_overlord_morghor
 ####*/
+
 #define QUEST_LORD_ILLIDAN_STORMRAGE 11108
+
 #define C_ILLIDAN 22083
 #define C_YARZILL 23141
+
 #define SPELL_ONE 39990 // Red Lightning Bolt
 #define SPELL_TWO 41528 // Mark of Stormrage
 #define SPELL_THREE 40216 // Dragonaw Faction
 #define SPELL_FOUR 42016 // Dragonaw Trasform
+
 #define OVERLORD_SAY_1 -1000206
 #define OVERLORD_SAY_2 -1000207
 #define OVERLORD_SAY_3 -1000208 //signed for 28315
 #define OVERLORD_SAY_4 -1000209
 #define OVERLORD_SAY_5 -1000210
 #define OVERLORD_SAY_6 -1000211
+
 #define OVERLORD_YELL_1 -1000212
 #define OVERLORD_YELL_2 -1000213
+
 #define LORD_ILLIDAN_SAY_1 -1000214
 #define LORD_ILLIDAN_SAY_2 -1000215
 #define LORD_ILLIDAN_SAY_3 -1000216
@@ -561,23 +669,32 @@ bool QuestAccept_npc_karynaku(Player* pPlayer, Creature* pCreature, Quest const*
 #define LORD_ILLIDAN_SAY_5 -1000218
 #define LORD_ILLIDAN_SAY_6 -1000219
 #define LORD_ILLIDAN_SAY_7 -1000220
+
 #define YARZILL_THE_MERC_SAY -1000221
+
 struct TRINITY_DLL_DECL npc_overlord_morghorAI : public ScriptedAI
 {
     npc_overlord_morghorAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 PlayerGUID;
     uint64 IllidanGUID;
+
     uint32 ConversationTimer;
     uint32 Step;
+
     bool Event;
+
     void Reset()
     {
         PlayerGUID = 0;
         IllidanGUID = 0;
+
         ConversationTimer = 0;
         Step = 0;
+
         Event = false;
     }
+
     void StartEvent()
     {
         m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 0);
@@ -598,15 +715,19 @@ struct TRINITY_DLL_DECL npc_overlord_morghorAI : public ScriptedAI
         Step = 0;
         Event = true;
     }
+
     uint32 NextStep(uint32 Step)
     {
         Unit* plr = Unit::GetUnit((*m_creature), PlayerGUID);
+
         Unit* Illi = Unit::GetUnit((*m_creature), IllidanGUID);
+
         if (!plr || !Illi)
         {
             EnterEvadeMode();
             return 0;
         }
+
         switch(Step)
         {
         case 0: return 0; break;
@@ -637,9 +758,7 @@ struct TRINITY_DLL_DECL npc_overlord_morghorAI : public ScriptedAI
                 plr->RemoveAurasDueToSpell(SPELL_THREE);
                 plr->RemoveAurasDueToSpell(SPELL_FOUR);
                 return 5000;
-            }
-            else
-            {
+            }else{
                 CAST_PLR(plr)->FailQuest(QUEST_LORD_ILLIDAN_STORMRAGE); Step = 30; return 100;
             }break;
         case 17: DoScriptText(LORD_ILLIDAN_SAY_5, Illi); return 5000; break;
@@ -693,13 +812,16 @@ struct TRINITY_DLL_DECL npc_overlord_morghorAI : public ScriptedAI
             return 1000;}break;
         case 32: m_creature->GetMotionMaster()->MovePoint(0, -5085.77, 577.231, 86.6719); return 5000; break;
         case 33: Reset(); return 100; break;
+
         default : return 0;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!ConversationTimer)
             return;
+
         if (ConversationTimer <= diff)
         {
             if (Event && IllidanGUID && PlayerGUID)
@@ -709,10 +831,12 @@ struct TRINITY_DLL_DECL npc_overlord_morghorAI : public ScriptedAI
         }else ConversationTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_npc_overlord_morghor(Creature* pCreature)
 {
 return new npc_overlord_morghorAI(pCreature);
 }
+
 bool QuestAccept_npc_overlord_morghor(Player* pPlayer, Creature* pCreature, const Quest *_Quest)
 {
     if (_Quest->GetQuestId() == QUEST_LORD_ILLIDAN_STORMRAGE)
@@ -723,9 +847,11 @@ bool QuestAccept_npc_overlord_morghor(Player* pPlayer, Creature* pCreature, cons
     }
     return false;
 }
+
 /*####
 # npc_earthmender_wilda
 ####*/
+
 enum eEarthmender
 {
     SAY_WIL_START               = -1000381,
@@ -738,27 +864,35 @@ enum eEarthmender
     SAY_WIL_PROGRESS5           = -1000388,
     SAY_WIL_JUST_AHEAD          = -1000389,
     SAY_WIL_END                 = -1000390,
+
     SPELL_CHAIN_LIGHTNING       = 16006,
     SPELL_EARTHBING_TOTEM       = 15786,
     SPELL_FROST_SHOCK           = 12548,
     SPELL_HEALING_WAVE          = 12491,
+
     QUEST_ESCAPE_COILSCAR       = 10451,
     NPC_COILSKAR_ASSASSIN       = 21044,
     FACTION_EARTHEN             = 1726                      //guessed
 };
+
 struct TRINITY_DLL_DECL npc_earthmender_wildaAI : public npc_escortAI
 {
     npc_earthmender_wildaAI(Creature* pCreature) : npc_escortAI(pCreature) { }
+
     uint32 m_uiHealingTimer;
+
     void Reset()
     {
         m_uiHealingTimer = 0;
     }
+
     void WaypointReached(uint32 uiPointId)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(uiPointId)
         {
             case 13:
@@ -806,31 +940,37 @@ struct TRINITY_DLL_DECL npc_earthmender_wildaAI : public npc_escortAI
                 break;
             case 50:
                 DoScriptText(SAY_WIL_END, m_creature, pPlayer);
+
                 if (Player* pPlayer = GetPlayerForEscort())
                     pPlayer->GroupEventHappens(QUEST_ESCAPE_COILSCAR, m_creature);
                 break;
         }
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (pSummoned->GetEntry() == NPC_COILSKAR_ASSASSIN)
             pSummoned->AI()->AttackStart(m_creature);
     }
+
     //this is very unclear, random say without no real relevance to script/event
     void DoRandomSay()
     {
         DoScriptText(RAND(SAY_WIL_PROGRESS2,SAY_WIL_PROGRESS4,SAY_WIL_PROGRESS5), m_creature);
     }
+
     void DoSpawnAssassin()
     {
         //unknown where they actually appear
         DoSummon(NPC_COILSKAR_ASSASSIN, me, 15.0f, 5000, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT);
     }
+
     void Aggro(Unit* pWho)
     {
         //don't always use
         if (rand()%5)
             return;
+
         //only aggro text if not player
         if (pWho->GetTypeId() != TYPEID_PLAYER)
         {
@@ -839,11 +979,14 @@ struct TRINITY_DLL_DECL npc_earthmender_wildaAI : public npc_escortAI
                 DoScriptText(RAND(SAY_WIL_AGGRO1, SAY_WIL_AGGRO2), pWho);
         }
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         npc_escortAI::UpdateAI(uiDiff);
+
         if (!UpdateVictim())
             return;
+
         //TODO: add more abilities
         if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30)
         {
@@ -857,24 +1000,29 @@ struct TRINITY_DLL_DECL npc_earthmender_wildaAI : public npc_escortAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_earthmender_wilda(Creature* pCreature)
 {
     return new npc_earthmender_wildaAI(pCreature);
 }
+
 bool QuestAccept_npc_earthmender_wilda(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_ESCAPE_COILSCAR)
     {
         DoScriptText(SAY_WIL_START, pCreature, pPlayer);
         pCreature->setFaction(FACTION_EARTHEN);
+
         if (npc_earthmender_wildaAI* pEscortAI = CAST_AI(npc_earthmender_wildaAI, pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID(), pQuest);
     }
     return true;
 }
+
 /*#####
 # Quest: Battle of the crimson watch
 #####*/
+
 /* ContentData
 Battle of the crimson watch - creatures, gameobjects and defines
 mob_illidari_spawn : Adds that are summoned in the Crimson Watch battle.
@@ -882,15 +1030,19 @@ mob_torloth_the_magnificent : Final Creature that players have to face before qu
 npc_lord_illidan_stormrage : Creature that controls the event.
 go_crystal_prison : GameObject that begins the event and hands out quest
 EndContentData */
+
 #define END_TEXT -1000366 //signed for 10646
+
 #define QUEST_BATTLE_OF_THE_CRIMSON_WATCH 10781
 #define EVENT_AREA_RADIUS 65 //65yds
 #define EVENT_COOLDOWN 30000 //in ms. appear after event completed or failed (should be = Adds despawn time)
+
 struct TorlothCinematic
 {
     int32 TextId;
     uint32 pCreature, Timer;
 };
+
 // Creature 0 - Torloth, 1 - Illidan
 static TorlothCinematic TorlothAnim[]=
 {
@@ -902,10 +1054,12 @@ static TorlothCinematic TorlothAnim[]=
     {NULL, 0, 3000},
     {NULL, 0, NULL}
 };
+
 struct Location
 {
     float x, y, z, o;
 };
+
 //Cordinates for Spawns
 static Location SpawnLocation[]=
 {
@@ -927,12 +1081,14 @@ static Location SpawnLocation[]=
     {-4616.4736, 1384.2170, 139.9, 4.971},//Illidari Highlord
     {-4627.1240, 1378.8752, 139.9, 2.544} //Torloth The Magnificent
 };
+
 struct WaveData
 {
     uint8 SpawnCount, UsedSpawnPoint;
     uint32 CreatureId, SpawnTimer,YellTimer;
     int32 WaveTextId;
 };
+
 static WaveData WavesInfo[]=
 {
     {9, 0, 22075, 10000, 7000, -1000371},   //Illidari Soldier
@@ -940,10 +1096,12 @@ static WaveData WavesInfo[]=
     {4, 11, 19797, 10000, 7000, -1000373},  //Illidari Highlord
     {1, 15, 22076, 10000, 7000, -1000374}   //Torloth The Magnificent
 };
+
 struct SpawnSpells
 {
  uint32 Timer1, Timer2, SpellId;
 };
+
 static SpawnSpells SpawnCast[]=
 {
     {10000, 15000, 35871},  // Illidari Soldier Cast - Spellbreaker
@@ -956,39 +1114,46 @@ static SpawnSpells SpawnCast[]=
     {18000, 20000, 39082},  // Torloth the Magnificent Cast - Shadowfury
     {25000, 28000, 33961}   // Torloth the Magnificent Cast - Spell Reflection
 };
+
 /*######
 # mob_illidari_spawn
 ######*/
+
 struct TRINITY_DLL_DECL mob_illidari_spawnAI : public ScriptedAI
 {
     mob_illidari_spawnAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 LordIllidanGUID;
     uint32 SpellTimer1, SpellTimer2, SpellTimer3;
     bool Timers;
+
     void Reset()
     {
         LordIllidanGUID = 0;
         Timers = false;
     }
+
     void EnterCombat(Unit* who) {}
     void JustDied(Unit* slayer);
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (!Timers)
         {
-            if (m_creature->GetEntry() == 22075) //Illidari Soldier
+            if (m_creature->GetEntry() == 22075)//Illidari Soldier
             {
                 SpellTimer1 = SpawnCast[0].Timer1 + (rand()%4 * 1000);
             }
-            if (m_creature->GetEntry() == 22074) //Illidari Mind Breaker
+            if (m_creature->GetEntry() == 22074)//Illidari Mind Breaker
             {
                 SpellTimer1 = SpawnCast[1].Timer1 + (rand()%10 * 1000);
                 SpellTimer2 = SpawnCast[2].Timer1 + (rand()%4 * 1000);
                 SpellTimer3 = SpawnCast[3].Timer1 + (rand()%4 * 1000);
             }
-            if (m_creature->GetEntry() == 19797) // Illidari Highlord
+            if (m_creature->GetEntry() == 19797)// Illidari Highlord
             {
                 SpellTimer1 = SpawnCast[4].Timer1 + (rand()%4 * 1000);
                 SpellTimer2 = SpawnCast[5].Timer1 + (rand()%4 * 1000);
@@ -1018,11 +1183,13 @@ struct TRINITY_DLL_DECL mob_illidari_spawnAI : public ScriptedAI
                     }else SpellTimer1 = 2000;
                 }
             }else SpellTimer1 -= diff;
+
             if (SpellTimer2 < diff)
             {
                 DoCast(m_creature->getVictim(), SpawnCast[2].SpellId);//Psychic Scream
                 SpellTimer2 = SpawnCast[2].Timer2 + (rand()%13 * 1000);
             }else SpellTimer2 -= diff;
+
             if (SpellTimer3 < diff)
             {
                 DoCast(m_creature->getVictim(), SpawnCast[3].SpellId);//Mind Blast
@@ -1037,26 +1204,35 @@ struct TRINITY_DLL_DECL mob_illidari_spawnAI : public ScriptedAI
                 DoCast(m_creature->getVictim(), SpawnCast[4].SpellId);//Curse Of Flames
                 SpellTimer1 = SpawnCast[4].Timer2 + (rand()%10 * 1000);
             }else SpellTimer1 -= diff;
+
             if (SpellTimer2 < diff)
             {
                 DoCast(m_creature->getVictim(), SpawnCast[5].SpellId);//Flamestrike
                 SpellTimer2 = SpawnCast[5].Timer2 + (rand()%7 * 13000);
             }else SpellTimer2 -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 /*######
 # mob_torloth_the_magnificent
 #####*/
+
 struct TRINITY_DLL_DECL mob_torloth_the_magnificentAI : public ScriptedAI
 {
     mob_torloth_the_magnificentAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 AnimationTimer, SpellTimer1, SpellTimer2, SpellTimer3;
+
     uint8 AnimationCount;
+
     uint64 LordIllidanGUID;
     uint64 AggroTargetGUID;
+
     bool Timers;
+
     void Reset()
     {
         AnimationTimer = 4000;
@@ -1064,23 +1240,31 @@ struct TRINITY_DLL_DECL mob_torloth_the_magnificentAI : public ScriptedAI
         LordIllidanGUID = 0;
         AggroTargetGUID = 0;
         Timers = false;
+
         m_creature->addUnitState(UNIT_STAT_ROOT);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0);
     }
+
     void EnterCombat(Unit* who){}
+
     void HandleAnimation()
     {
         Creature* pCreature = m_creature;
+
         if (TorlothAnim[AnimationCount].pCreature == 1)
         {
             pCreature = (Unit::GetCreature(*m_creature, LordIllidanGUID));
+
             if (!pCreature)
                 return;
         }
+
         if (TorlothAnim[AnimationCount].TextId)
             DoScriptText(TorlothAnim[AnimationCount].TextId, pCreature);
+
         AnimationTimer = TorlothAnim[AnimationCount].Timer;
+
         switch(AnimationCount)
         {
         case 0:
@@ -1102,6 +1286,7 @@ struct TRINITY_DLL_DECL mob_torloth_the_magnificentAI : public ScriptedAI
             {
                 m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                 m_creature->clearUnitState(UNIT_STAT_ROOT);
+
                 float x, y, z;
                 AggroTarget->GetPosition(x,y,z);
                 m_creature->GetMotionMaster()->MovePoint(0,x,y,z);
@@ -1110,6 +1295,7 @@ struct TRINITY_DLL_DECL mob_torloth_the_magnificentAI : public ScriptedAI
         }
         ++AnimationCount;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (AnimationTimer)
@@ -1119,16 +1305,19 @@ struct TRINITY_DLL_DECL mob_torloth_the_magnificentAI : public ScriptedAI
                 HandleAnimation();
             }else AnimationTimer -= diff;
         }
+
         if (AnimationCount < 6)
         {
             m_creature->CombatStop();
         }else if (!Timers)
         {
+
             SpellTimer1 = SpawnCast[6].Timer1;
             SpellTimer2 = SpawnCast[7].Timer1;
             SpellTimer3 = SpawnCast[8].Timer1;
             Timers = true;
         }
+
         if (Timers)
         {
             if (SpellTimer1 < diff)
@@ -1136,19 +1325,23 @@ struct TRINITY_DLL_DECL mob_torloth_the_magnificentAI : public ScriptedAI
                 DoCast(m_creature->getVictim(), SpawnCast[6].SpellId);//Cleave
                 SpellTimer1 = SpawnCast[6].Timer2 + (rand()%10 * 1000);
             }else SpellTimer1 -= diff;
+
             if (SpellTimer2 < diff)
             {
                 DoCast(m_creature->getVictim(), SpawnCast[7].SpellId);//Shadowfury
                 SpellTimer2 = SpawnCast[7].Timer2 + (rand()%5 * 1000);
             }else SpellTimer2 -= diff;
+
             if (SpellTimer3 < diff)
             {
                 DoCast(m_creature, SpawnCast[8].SpellId);
                 SpellTimer3 = SpawnCast[8].Timer2 + (rand()%7 * 1000);//Spell Reflection
             }else SpellTimer3 -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
+
     void JustDied(Unit* slayer)
     {
         if (slayer)
@@ -1159,10 +1352,12 @@ struct TRINITY_DLL_DECL mob_torloth_the_magnificentAI : public ScriptedAI
                     if (owner->GetTypeId() == TYPEID_PLAYER)
                         CAST_PLR(owner)->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, m_creature);
                 break;
+
             case TYPEID_PLAYER:
                 CAST_PLR(slayer)->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, m_creature);
                 break;
         }
+
         if (Creature* LordIllidan = (Unit::GetCreature(*m_creature, LordIllidanGUID)))
         {
             DoScriptText(END_TEXT, LordIllidan, slayer);
@@ -1170,35 +1365,47 @@ struct TRINITY_DLL_DECL mob_torloth_the_magnificentAI : public ScriptedAI
         }
     }
 };
+
 /*#####
 # npc_lord_illidan_stormrage
 #####*/
+
 struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
 {
     npc_lord_illidan_stormrageAI(Creature* c) : ScriptedAI(c) {}
+
     uint64 PlayerGUID;
+
     uint32 WaveTimer;
     uint32 AnnounceTimer;
+
     int8 LiveCount;
     uint8 WaveCount;
+
     bool EventStarted;
     bool Announced;
     bool Failed;
+
     void Reset()
     {
         PlayerGUID = 0;
+
         WaveTimer = 10000;
         AnnounceTimer = 7000;
         LiveCount = 0;
         WaveCount = 0;
+
         EventStarted = false;
         Announced = false;
         Failed = false;
+
         m_creature->SetVisibility(VISIBILITY_OFF);
     }
+
     void EnterCombat(Unit* who) {}
     void MoveInLineOfSight(Unit* who) {}
     void AttackStart(Unit* who) {}
+
     void SummonNextWave()
     {
         uint8 count = WavesInfo[WaveCount].SpawnCount;
@@ -1206,7 +1413,8 @@ struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
         srand(time(NULL));//initializing random seed
         uint8 FelguardCount = 0;
         uint8 DreadlordCount = 0;
-        for (uint8 i = 0; i < count; ++i)
+
+        for(uint8 i = 0; i < count; ++i)
         {
             Creature* Spawn = NULL;
             float X = SpawnLocation[locIndex + i].x;
@@ -1215,10 +1423,12 @@ struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
             float O = SpawnLocation[locIndex + i].o;
             Spawn = m_creature->SummonCreature(WavesInfo[WaveCount].CreatureId, X, Y, Z, O, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000);
             ++LiveCount;
+
             if (Spawn)
             {
                 Spawn->LoadCreaturesAddon();
-                if (WaveCount == 0) //1 Wave
+
+                if (WaveCount == 0)//1 Wave
                 {
                     if (rand()%3 == 1 && FelguardCount<2)
                     {
@@ -1236,7 +1446,8 @@ struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
                         ++FelguardCount;
                     }
                 }
-                if (WaveCount < 3) //1-3 Wave
+
+                if (WaveCount < 3)//1-3 Wave
                 {
                     if (PlayerGUID)
                     {
@@ -1249,6 +1460,7 @@ struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
                     }
                     CAST_AI(mob_illidari_spawnAI, Spawn->AI())->LordIllidanGUID = m_creature->GetGUID();
                 }
+
                 if (WavesInfo[WaveCount].CreatureId == 22076) // Torloth
                 {
                     CAST_AI(mob_torloth_the_magnificentAI, Spawn->AI())->LordIllidanGUID = m_creature->GetGUID();
@@ -1261,19 +1473,25 @@ struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
         WaveTimer = WavesInfo[WaveCount].SpawnTimer;
         AnnounceTimer = WavesInfo[WaveCount].YellTimer;
     }
+
     void CheckEventFail()
     {
         Player* pPlayer = Unit::GetPlayer(PlayerGUID);
+
         if (!pPlayer)
             return;
+
         if (Group *EventGroup = pPlayer->GetGroup())
         {
             Player* GroupMember;
+
             uint8 GroupMemberCount = 0;
             uint8 DeadMemberCount = 0;
             uint8 FailedMemberCount = 0;
+
             const Group::MemberSlotList members = EventGroup->GetMemberSlots();
-            for (Group::member_citerator itr = members.begin(); itr!= members.end(); itr++)
+
+            for(Group::member_citerator itr = members.begin(); itr!= members.end(); itr++)
             {
                 GroupMember = (Unit::GetPlayer(itr->guid));
                 if (!GroupMember)
@@ -1285,20 +1503,24 @@ struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
                     ++FailedMemberCount;
                 }
                 ++GroupMemberCount;
+
                 if (GroupMember->isDead())
                 {
                     ++DeadMemberCount;
                 }
             }
+
             if (GroupMemberCount == FailedMemberCount)
             {
                 Failed = true;
             }
+
             if (GroupMemberCount == DeadMemberCount)
             {
-                for (Group::member_citerator itr = members.begin(); itr!= members.end(); itr++)
+                for(Group::member_citerator itr = members.begin(); itr!= members.end(); itr++)
                 {
                     GroupMember = Unit::GetPlayer(itr->guid);
+
                     if (GroupMember && GroupMember->GetQuestStatus(QUEST_BATTLE_OF_THE_CRIMSON_WATCH) == QUEST_STATUS_INCOMPLETE)
                     {
                         GroupMember->FailQuest(QUEST_BATTLE_OF_THE_CRIMSON_WATCH);
@@ -1313,16 +1535,19 @@ struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
             Failed = true;
         }
     }
+
     void LiveCounter()
     {
         --LiveCount;
         if (!LiveCount)
             Announced = false;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!PlayerGUID || !EventStarted)
             return;
+
         if (!LiveCount && WaveCount < 4)
         {
             if (!Announced && AnnounceTimer < diff)
@@ -1330,16 +1555,19 @@ struct TRINITY_DLL_DECL npc_lord_illidan_stormrageAI : public ScriptedAI
                 DoScriptText(WavesInfo[WaveCount].WaveTextId, m_creature);
                 Announced = true;
             }else AnnounceTimer -= diff;
+
             if (WaveTimer < diff)
             {
                 SummonNextWave();
             }else WaveTimer -= diff;
         }
         CheckEventFail();
+
         if (Failed)
             EnterEvadeMode();
     }
 };
+
 void mob_illidari_spawnAI::JustDied(Unit *slayer)
 {
     m_creature->RemoveCorpse();
@@ -1347,14 +1575,17 @@ void mob_illidari_spawnAI::JustDied(Unit *slayer)
         if (LordIllidan)
             CAST_AI(npc_lord_illidan_stormrageAI, LordIllidan->AI())->LiveCounter();
 }
+
 /*#####
 # go_crystal_prison
 ######*/
+
 bool GOQuestAccept_GO_crystal_prison(Player* plr, GameObject* go, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_BATTLE_OF_THE_CRIMSON_WATCH)
     {
         Creature* Illidan = plr->FindNearestCreature(22083, 50);
+
         if (Illidan && !CAST_AI(npc_lord_illidan_stormrageAI, Illidan->AI())->EventStarted)
         {
             CAST_AI(npc_lord_illidan_stormrageAI, Illidan->AI())->PlayerGUID = plr->GetGUID();
@@ -1364,58 +1595,74 @@ bool GOQuestAccept_GO_crystal_prison(Player* plr, GameObject* go, Quest const* q
     }
  return true;
 }
+
 CreatureAI* GetAI_npc_lord_illidan_stormrage(Creature* c)
 {
     return new npc_lord_illidan_stormrageAI(c);
 }
+
 CreatureAI* GetAI_mob_illidari_spawn(Creature* c)
 {
     return new mob_illidari_spawnAI(c);
 }
+
 CreatureAI* GetAI_mob_torloth_the_magnificent(Creature* c)
 {
     return new mob_torloth_the_magnificentAI(c);
 }
+
 /*####
 # npc_enraged_spirits
 ####*/
+
 /* QUESTS */
 #define QUEST_ENRAGED_SPIRITS_FIRE_EARTH 10458
 #define QUEST_ENRAGED_SPIRITS_AIR 10481
 #define QUEST_ENRAGED_SPIRITS_WATER 10480
+
 /* Totem */
 #define ENTRY_TOTEM_OF_SPIRITS 21071
 #define RADIUS_TOTEM_OF_SPIRITS 15
+
 /* SPIRITS */
 #define ENTRY_ENRAGED_EARTH_SPIRIT 21050
 #define ENTRY_ENRAGED_FIRE_SPIRIT 21061
 #define ENTRY_ENRAGED_AIR_SPIRIT 21060
 #define ENTRY_ENRAGED_WATER_SPIRIT 21059
+
 /* SOULS */
 #define ENTRY_EARTHEN_SOUL 21073
 #define ENTRY_FIERY_SOUL 21097
 #define ENTRY_ENRAGED_AIRY_SOUL 21116
 #define ENTRY_ENRAGED_WATERY_SOUL 21109  // wrong model
+
 /* SPELL KILLCREDIT - not working!?! - using KilledMonsterCredit */
 #define SPELL_EARTHEN_SOUL_CAPTURED_CREDIT 36108
 #define SPELL_FIERY_SOUL_CAPTURED_CREDIT 36117
 #define SPELL_AIRY_SOUL_CAPTURED_CREDIT 36182
 #define SPELL_WATERY_SOUL_CAPTURED_CREDIT 36171
+
 /* KilledMonsterCredit Workaround */
 #define CREDIT_FIRE 21094
 #define CREDIT_WATER 21095
 #define CREDIT_AIR 21096
 #define CREDIT_EARTH 21092
+
 /* Captured Spell/Buff */
 #define SPELL_SOUL_CAPTURED 36115
+
 /* Factions */
 #define ENRAGED_SOUL_FRIENDLY 35
 #define ENRAGED_SOUL_HOSTILE 14
+
 struct TRINITY_DLL_DECL npc_enraged_spiritAI : public ScriptedAI
 {
     npc_enraged_spiritAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()   { }
+
     void EnterCombat(Unit *who){}
+
     void JustDied(Unit* killer)
     {
         // always spawn spirit on death
@@ -1423,6 +1670,7 @@ struct TRINITY_DLL_DECL npc_enraged_spiritAI : public ScriptedAI
         // move spirit to totem and cast kill count
         uint32 entry = 0;
         uint32 credit = 0;
+
         switch(m_creature->GetEntry()) {
           case ENTRY_ENRAGED_FIRE_SPIRIT:
             entry  = ENTRY_FIERY_SOUL;
@@ -1445,11 +1693,14 @@ struct TRINITY_DLL_DECL npc_enraged_spiritAI : public ScriptedAI
             credit = CREDIT_WATER;
           break;
         }
+
         // Spawn Soul on Kill ALWAYS!
         Creature* Summoned = NULL;
         Unit* totemOspirits = NULL;
+
         if (entry != 0)
             Summoned = DoSpawnCreature(entry, 0, 0, 1, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 5000);
+
         // FIND TOTEM, PROCESS QUEST
         if (Summoned)
         {
@@ -1458,6 +1709,7 @@ struct TRINITY_DLL_DECL npc_enraged_spiritAI : public ScriptedAI
              {
                  Summoned->setFaction(ENRAGED_SOUL_FRIENDLY);
                  Summoned->GetMotionMaster()->MovePoint(0,totemOspirits->GetPositionX(), totemOspirits->GetPositionY(), Summoned->GetPositionZ());
+
                  Unit* Owner = totemOspirits->GetOwner();
                  if (Owner && Owner->GetTypeId() == TYPEID_PLAYER)
                      // DoCast(Owner, credit); -- not working!
@@ -1467,83 +1719,102 @@ struct TRINITY_DLL_DECL npc_enraged_spiritAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_enraged_spirit(Creature* pCreature)
 {
 return new npc_enraged_spiritAI(pCreature);
 }
+
 /*#####
 #
 ######*/
+
 void AddSC_shadowmoon_valley()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_mature_netherwing_drake";
     newscript->GetAI = &GetAI_mob_mature_netherwing_drake;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_enslaved_netherwing_drake";
     newscript->GetAI = &GetAI_mob_enslaved_netherwing_drake;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_dragonmaw_peon";
     newscript->GetAI = &GetAI_mob_dragonmaw_peon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_drake_dealer_hurlunk";
     newscript->pGossipHello =  &GossipHello_npc_drake_dealer_hurlunk;
     newscript->pGossipSelect = &GossipSelect_npc_drake_dealer_hurlunk;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_murkblood_overseer";
     newscript->pGossipHello =  &GossipHello_npc_murkblood_overseer;
     newscript->pGossipSelect = &GossipSelect_npc_murkblood_overseer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_neltharaku";
     newscript->pGossipHello =  &GossipHello_npc_neltharaku;
     newscript->pGossipSelect = &GossipSelect_npc_neltharaku;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_karynaku";
     newscript->pQuestAccept = &QuestAccept_npc_karynaku;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_oronok_tornheart";
     newscript->pGossipHello =  &GossipHello_npc_oronok_tornheart;
     newscript->pGossipSelect = &GossipSelect_npc_oronok_tornheart;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_overlord_morghor";
     newscript->GetAI = &GetAI_npc_overlord_morghor;
     newscript->pQuestAccept = &QuestAccept_npc_overlord_morghor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_earthmender_wilda";
     newscript->GetAI = &GetAI_npc_earthmender_wilda;
     newscript->pQuestAccept = &QuestAccept_npc_earthmender_wilda;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_lord_illidan_stormrage";
     newscript->GetAI = &GetAI_npc_lord_illidan_stormrage;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_crystal_prison";
     newscript->pGOQuestAccept = &GOQuestAccept_GO_crystal_prison;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_illidari_spawn";
     newscript->GetAI = &GetAI_mob_illidari_spawn;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_torloth_the_magnificent";
     newscript->GetAI = &GetAI_mob_torloth_the_magnificent;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_enraged_spirit";
     newscript->GetAI = &GetAI_npc_enraged_spirit;
diff --git a/src/bindings/scripts/scripts/outland/shattrath_city.cpp b/src/bindings/scripts/scripts/outland/shattrath_city.cpp
index 54e29840957..cd25653fc61 100644
--- a/src/bindings/scripts/scripts/outland/shattrath_city.cpp
+++ b/src/bindings/scripts/scripts/outland/shattrath_city.cpp
@@ -13,12 +13,14 @@
  * along 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, 10211, 10231. Flask vendors, Teleport to Caverns of Time
 SDCategory: Shattrath City
 EndScriptData */
+
 /* ContentData
 npc_raliq_the_drunk
 npc_salsalabim
@@ -29,54 +31,68 @@ npc_dirty_larry
 npc_ishanah
 npc_khadgar
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## npc_raliq_the_drunk
 ######*/
+
 #define GOSSIP_RALIQ            "You owe Sim'salabim money. Hand them over or die!"
+
 enum eRaliq
 {
     SPELL_UPPERCUT          = 10966,
     QUEST_CRACK_SKULLS      = 10009,
     FACTION_HOSTILE_RD      = 45
 };
+
 struct TRINITY_DLL_DECL npc_raliq_the_drunkAI : public ScriptedAI
 {
     npc_raliq_the_drunkAI(Creature* c) : ScriptedAI(c)
     {
         m_uiNormFaction = c->getFaction();
     }
+
     uint32 m_uiNormFaction;
     uint32 Uppercut_Timer;
+
     void Reset()
     {
         Uppercut_Timer = 5000;
         me->RestoreFaction();
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new npc_raliq_the_drunkAI (pCreature);
 }
+
 bool GossipHello_npc_raliq_the_drunk(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_CRACK_SKULLS) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_RALIQ, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(9440, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_raliq_the_drunk(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -87,22 +103,29 @@ bool GossipSelect_npc_raliq_the_drunk(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 /*######
 # npc_salsalabim
 ######*/
+
 #define FACTION_HOSTILE_SA              90
 #define FACTION_FRIENDLY_SA             35
 #define QUEST_10004                     10004
+
 #define SPELL_MAGNETIC_PULL             31705
+
 struct TRINITY_DLL_DECL npc_salsalabimAI : public ScriptedAI
 {
     npc_salsalabimAI(Creature* c) : ScriptedAI(c) {}
+
     uint32 MagneticPull_Timer;
+
     void Reset()
     {
         MagneticPull_Timer = 15000;
         me->RestoreFaction();
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by->GetTypeId() == TYPEID_PLAYER)
@@ -113,15 +136,18 @@ struct TRINITY_DLL_DECL npc_salsalabimAI : public ScriptedAI
             EnterEvadeMode();
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (MagneticPull_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_MAGNETIC_PULL);
             MagneticPull_Timer = 15000;
         }else MagneticPull_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -129,6 +155,7 @@ CreatureAI* GetAI_npc_salsalabim(Creature* pCreature)
 {
     return new npc_salsalabimAI (pCreature);
 }
+
 bool GossipHello_npc_salsalabim(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_10004) == QUEST_STATUS_INCOMPLETE)
@@ -144,6 +171,7 @@ bool GossipHello_npc_salsalabim(Player* pPlayer, Creature* pCreature)
     }
     return true;
 }
+
 /*
 ##################################################
 Shattrath City Flask Vendors provides flasks to people exalted with 3 factions:
@@ -154,6 +182,7 @@ 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* pPlayer, Creature* pCreature)
 {
     if (pCreature->GetEntry() == 23484)
@@ -169,6 +198,7 @@ bool GossipHello_npc_shattrathflaskvendors(Player* pPlayer, Creature* pCreature)
             pPlayer->SEND_GOSSIP_MENU(11083, pCreature->GetGUID());
         }
     }
+
     if (pCreature->GetEntry() == 23483)
     {
         // Scryers vendor
@@ -182,34 +212,46 @@ bool GossipHello_npc_shattrathflaskvendors(Player* pPlayer, Creature* pCreature)
             pPlayer->SEND_GOSSIP_MENU(11084, pCreature->GetGUID());
         }
     }
+
     return true;
 }
+
 bool GossipSelect_npc_shattrathflaskvendors(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 # npc_zephyr
 ######*/
+
 #define GOSSIP_HZ "Take me to the Caverns of Time."
+
 bool GossipHello_npc_zephyr(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetReputationRank(989) >= REP_REVERED)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HZ, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_zephyr(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
         pPlayer->CastSpell(pPlayer,37778,false);
+
     return true;
 }
+
 /*######
 # npc_kservant
 ######*/
+
 #define SAY1       -1000306
 #define WHISP1     -1000307
 #define WHISP2     -1000308
@@ -232,16 +274,20 @@ bool GossipSelect_npc_zephyr(Player* pPlayer, Creature* pCreature, uint32 uiSend
 #define WHISP19    -1000325
 #define WHISP20    -1000326
 #define WHISP21    -1000327
+
 struct TRINITY_DLL_DECL npc_kservantAI : public npc_escortAI
 {
 public:
     npc_kservantAI(Creature *c) : npc_escortAI(c) {}
 
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
             case 0: DoScriptText(SAY1, m_creature, pPlayer); break;
@@ -271,10 +317,12 @@ public:
                 break;
         }
     }
+
     void MoveInLineOfSight(Unit* pWho)
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
             return;
+
         if (pWho->GetTypeId() == TYPEID_PLAYER)
         {
             if (CAST_PLR(pWho)->GetQuestStatus(10211) == QUEST_STATUS_INCOMPLETE)
@@ -287,42 +335,54 @@ public:
             }
         }
     }
+
     void Reset() {}
 };
 CreatureAI* GetAI_npc_kservantAI(Creature* pCreature)
 {
     return new npc_kservantAI(pCreature);
 }
+
 /*######
 # npc_dirty_larry
 ######*/
+
 #define GOSSIP_BOOK "Ezekiel said that you might have a certain book..."
+
 #define SAY_1       -1000328
 #define SAY_2       -1000329
 #define SAY_3       -1000330
 #define SAY_4       -1000331
 #define SAY_5       -1000332
 #define SAY_GIVEUP  -1000333
+
 #define QUEST_WBI       10231
 #define NPC_CREEPJACK   19726
 #define NPC_MALONE      19725
+
 struct TRINITY_DLL_DECL npc_dirty_larryAI : public ScriptedAI
 {
     npc_dirty_larryAI(Creature* c) : ScriptedAI(c) {}
+
     bool Event;
     bool Attack;
     bool Done;
+
     uint64 PlayerGUID;
+
     uint32 SayTimer;
     uint32 Step;
+
     void Reset()
     {
         Event = false;
         Attack = false;
         Done = false;
+
         PlayerGUID = 0;
         SayTimer = 0;
         Step = 0;
+
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->setFaction(1194);
         Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20);
@@ -340,9 +400,11 @@ struct TRINITY_DLL_DECL npc_dirty_larryAI : public ScriptedAI
             Malone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         }
     }
+
     uint32 NextStep(uint32 Step)
     {
         Player* pPlayer = Unit::GetPlayer(PlayerGUID);
+
         switch(Step)
         {
         case 0:{ m_creature->SetInFront(pPlayer);
@@ -362,7 +424,9 @@ struct TRINITY_DLL_DECL npc_dirty_larryAI : public ScriptedAI
         default: return 0;
         }
     }
+
     void EnterCombat(Unit* who){}
+
     void UpdateAI(const uint32 diff)
     {
         if (SayTimer < diff)
@@ -370,6 +434,7 @@ struct TRINITY_DLL_DECL npc_dirty_larryAI : public ScriptedAI
             if (Event)
                 SayTimer = NextStep(++Step);
         }else SayTimer -= diff;
+
         if (Attack)
         {
             Player* pPlayer = Unit::GetPlayer(PlayerGUID);
@@ -398,6 +463,7 @@ struct TRINITY_DLL_DECL npc_dirty_larryAI : public ScriptedAI
             }
             Attack = false;
         }
+
         if ((m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 1 && !Done)
         {
             Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20);
@@ -430,15 +496,19 @@ struct TRINITY_DLL_DECL npc_dirty_larryAI : public ScriptedAI
         DoMeleeAttackIfReady();
     }
 };
+
 bool GossipHello_npc_dirty_larry(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->GetQuestStatus(QUEST_WBI) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BOOK, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_dirty_larry(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -447,52 +517,69 @@ bool GossipSelect_npc_dirty_larry(Player* pPlayer, Creature* pCreature, uint32 u
         CAST_AI(npc_dirty_larryAI, pCreature->AI())->PlayerGUID = pPlayer->GetGUID();
         pPlayer->CLOSE_GOSSIP_MENU();
     }
+
     return true;
 }
+
 CreatureAI* GetAI_npc_dirty_larryAI(Creature* pCreature)
 {
     return new npc_dirty_larryAI (pCreature);
 }
+
 /*######
 # npc_ishanah
 ######*/
+
 #define ISANAH_GOSSIP_1 "Who are the Sha'tar?"
 #define ISANAH_GOSSIP_2 "Isn't Shattrath a draenei city? Why do you allow others here?"
+
 bool GossipHello_npc_ishanah(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, ISANAH_GOSSIP_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, ISANAH_GOSSIP_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_ishanah(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
         pPlayer->SEND_GOSSIP_MENU(9458, pCreature->GetGUID());
     else if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
         pPlayer->SEND_GOSSIP_MENU(9459, pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 # npc_khadgar
 ######*/
+
 #define KHADGAR_GOSSIP_1    "I've heard your name spoken only in whispers, mage. Who are you?"
 #define KHADGAR_GOSSIP_2    "Go on, please."
 #define KHADGAR_GOSSIP_3    "I see." //6th too this
 #define KHADGAR_GOSSIP_4    "What did you do then?"
 #define KHADGAR_GOSSIP_5    "What happened next?"
 #define KHADGAR_GOSSIP_7    "There was something else I wanted to ask you."
+
 bool GossipHello_npc_khadgar(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (!pPlayer->hasQuest(10211))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, KHADGAR_GOSSIP_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
         pPlayer->SEND_GOSSIP_MENU(9243, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_khadgar(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -528,45 +615,54 @@ bool GossipSelect_npc_khadgar(Player* pPlayer, Creature* pCreature, uint32 uiSen
     }
     return true;
 }
+
 void AddSC_shattrath_city()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_raliq_the_drunk";
     newscript->GetAI = &GetAI_npc_raliq_the_drunk;
     newscript->pGossipHello =  &GossipHello_npc_raliq_the_drunk;
     newscript->pGossipSelect = &GossipSelect_npc_raliq_the_drunk;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_salsalabim";
     newscript->GetAI = &GetAI_npc_salsalabim;
     newscript->pGossipHello =  &GossipHello_npc_salsalabim;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_shattrathflaskvendors";
     newscript->pGossipHello =  &GossipHello_npc_shattrathflaskvendors;
     newscript->pGossipSelect = &GossipSelect_npc_shattrathflaskvendors;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_zephyr";
     newscript->pGossipHello =  &GossipHello_npc_zephyr;
     newscript->pGossipSelect = &GossipSelect_npc_zephyr;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_kservant";
     newscript->GetAI = &GetAI_npc_kservantAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_dirty_larry";
     newscript->GetAI = &GetAI_npc_dirty_larryAI;
     newscript->pGossipHello =   &GossipHello_npc_dirty_larry;
     newscript->pGossipSelect = &GossipSelect_npc_dirty_larry;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_ishanah";
     newscript->pGossipHello =  &GossipHello_npc_ishanah;
     newscript->pGossipSelect = &GossipSelect_npc_ishanah;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_khadgar";
     newscript->pGossipHello =  &GossipHello_npc_khadgar;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/arcatraz.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/arcatraz.cpp
index b329e1a2f3b..6c5460e1d83 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/arcatraz.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/arcatraz.cpp
@@ -13,22 +13,27 @@
  * along 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                 -1552010
 #define SAY_INTRO_2                 -1552011
 #define SAY_WATER                   -1552012
@@ -42,46 +47,57 @@ EndContentData */
 #define SAY_LOWHP                   -1552020
 #define SAY_DEATH                   -1552021
 #define SAY_COMPLETE                -1552022
+
 #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 TRINITY_DLL_DECL npc_millhouse_manastormAI : public ScriptedAI
 {
     npc_millhouse_manastormAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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)
             {
                 DoScriptText(SAY_COMPLETE, m_creature);
             }
         }
     }
+
     void AttackStart(Unit* pWho)
     {
         if (m_creature->Attack(pWho, true))
@@ -89,23 +105,29 @@ struct TRINITY_DLL_DECL npc_millhouse_manastormAI : public ScriptedAI
             m_creature->AddThreat(pWho, 0.0f);
             m_creature->SetInCombatWith(pWho);
             pWho->SetInCombatWith(m_creature);
+
             m_creature->GetMotionMaster()->MoveChase(pWho, 25.0f);
         }
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         /*for questId 10886 (heroic mode only)
         if (pInstance && pInstance->GetData(TYPE_HARBINGERSKYRISS) != DONE)
             ->FailQuest();*/
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Init)
@@ -153,36 +175,46 @@ struct TRINITY_DLL_DECL npc_millhouse_manastormAI : public ScriptedAI
                 }
             } else EventProgress_Timer -= diff;
         }
+
         if (!UpdateVictim())
             return;
+
         if (!LowHp && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20))
         {
             DoScriptText(SAY_LOWHP, m_creature);
             LowHp = true;
         }
+
         if (Pyroblast_Timer < diff)
         {
             if (m_creature->IsNonMeleeSpellCasted(false))
                 return;
+
              DoScriptText(SAY_PYRO, m_creature);
+
             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* pCreature)
 {
     return new npc_millhouse_manastormAI (pCreature);
 }
+
 /*#####
 # npc_warden_mellichar
 #####*/
+
 #define YELL_INTRO1         -1552023
 #define YELL_INTRO2         -1552024
 #define YELL_RELEASE1       -1552025
@@ -191,6 +223,7 @@ CreatureAI* GetAI_npc_millhouse_manastorm(Creature* pCreature)
 #define YELL_RELEASE3       -1552028
 #define YELL_RELEASE4       -1552029
 #define YELL_WELCOME        -1552030
+
 //phase 2(acid mobs)
 #define ENTRY_TRICKSTER     20905
 #define ENTRY_PH_HUNTER     20906
@@ -204,6 +237,7 @@ CreatureAI* GetAI_npc_millhouse_manastorm(Creature* pCreature)
 #define ENTRY_BL_DRAK       20911
 //phase 6
 #define ENTRY_SKYRISS       20912
+
 //TARGET_SCRIPT
 #define SPELL_TARGET_ALPHA  36856
 #define SPELL_TARGET_BETA   36854
@@ -211,48 +245,62 @@ CreatureAI* GetAI_npc_millhouse_manastorm(Creature* pCreature)
 #define SPELL_TARGET_GAMMA  36858
 #define SPELL_TARGET_OMEGA  36852
 #define SPELL_BUBBLE_VISUAL 36849
+
 struct TRINITY_DLL_DECL npc_warden_mellicharAI : public ScriptedAI
 {
     npc_warden_mellicharAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     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->isInAccessiblePlaceFor(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))
                 EnterCombat(who);
         }
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(YELL_INTRO1, m_creature);
         DoCast(m_creature,SPELL_BUBBLE_VISUAL);
+
         if (pInstance)
         {
             pInstance->SetData(TYPE_HARBINGERSKYRISS,IN_PROGRESS);
@@ -260,6 +308,7 @@ struct TRINITY_DLL_DECL npc_warden_mellicharAI : public ScriptedAI
             IsRunning = true;
         }
     }
+
     bool CanProgress()
     {
         if (pInstance)
@@ -282,12 +331,14 @@ struct TRINITY_DLL_DECL npc_warden_mellicharAI : public ScriptedAI
         }
         return false;
     }
+
     void DoPrepareForPhase()
     {
         if (pInstance)
         {
             m_creature->InterruptNonMeleeSpells(true);
             m_creature->RemoveAurasByType(SPELL_AURA_DUMMY);
+
             switch(Phase)
             {
                 case 2:
@@ -314,10 +365,12 @@ struct TRINITY_DLL_DECL npc_warden_mellicharAI : public ScriptedAI
             CanSpawn = true;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!IsRunning)
             return;
+
         if (EventProgress_Timer < diff)
         {
             if (pInstance)
@@ -328,11 +381,13 @@ struct TRINITY_DLL_DECL npc_warden_mellicharAI : public ScriptedAI
                     return;
                 }
             }
+
             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:
@@ -416,37 +471,47 @@ CreatureAI* GetAI_npc_warden_mellichar(Creature* pCreature)
 {
     return new npc_warden_mellicharAI (pCreature);
 }
+
 /*#####
 # mob_zerekethvoidzone (this script probably not needed in future -> `creature_template_addon`.`auras`='36120 0')
 #####*/
+
 #define SPELL_VOID_ZONE_DAMAGE 36120
+
 struct TRINITY_DLL_DECL mob_zerekethvoidzoneAI : public ScriptedAI
 {
     mob_zerekethvoidzoneAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit* who) {}
 };
 CreatureAI* GetAI_mob_zerekethvoidzoneAI(Creature* pCreature)
 {
     return new mob_zerekethvoidzoneAI (pCreature);
 }
+
 void AddSC_arcatraz()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_millhouse_manastorm";
     newscript->GetAI = &GetAI_npc_millhouse_manastorm;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_warden_mellichar";
     newscript->GetAI = &GetAI_npc_warden_mellichar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_zerekethvoidzone";
     newscript->GetAI = &GetAI_mob_zerekethvoidzoneAI;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp
index ba7851b7a47..e5620e908c2 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp
@@ -13,18 +13,22 @@
  * along with 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 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               -1552000
 #define SAY_AGGRO               -1552001
 #define SAY_KILL_1              -1552002
@@ -35,14 +39,20 @@ EndContentData */
 #define SAY_FEAR_2              -1552007
 #define SAY_IMAGE               -1552008
 #define SAY_DEATH               -1552009
+
 #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 TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI
 {
     boss_harbinger_skyrissAI(Creature *c) : ScriptedAI(c)
@@ -51,23 +61,29 @@ struct TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI
         HeroicMode = c->GetMap()->IsHeroic();
         Intro = false;
     }
+
     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()
     {
         if (!Intro)
             m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_OOC_NOT_ATTACKABLE);
+
         IsImage33 = false;
         IsImage66 = false;
+
         Intro_Phase = 1;
         Intro_Timer = 5000;
         MindRend_Timer = 3000;
@@ -75,6 +91,7 @@ struct TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI
         Domination_Timer = 30000;
         ManaBurn_Timer = 25000;
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!Intro)
@@ -83,13 +100,16 @@ struct TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI
         }
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void EnterCombat(Unit *who) {}
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
         if (pInstance)
             pInstance->SetData(TYPE_HARBINGERSKYRISS,DONE);
     }
+
     void JustSummoned(Creature *summon)
     {
         if (!summon)
@@ -102,29 +122,36 @@ struct TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 summon->AI()->AttackStart(target);
      }
+
     void KilledUnit(Unit* victim)
     {
         //won't yell killing pet/other unit
         if (victim->GetEntry() == 21436)
             return;
+
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void DoSplit(uint32 val)
     {
         if (m_creature->IsNonMeleeSpellCasted(false))
             m_creature->InterruptNonMeleeSpells(false);
+
         DoScriptText(SAY_IMAGE, m_creature);
+
         if (val == 66)
             DoCast(m_creature, SPELL_66_ILLUSION);
         else
             DoCast(m_creature, SPELL_33_ILLUSION);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Intro)
         {
             if (!pInstance)
                 return;
+
             if (Intro_Timer < diff)
             {
                 switch(Intro_Phase)
@@ -154,8 +181,10 @@ struct TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI
                 }
             }else Intro_Timer -=diff;
         }
+
         if (!UpdateVictim())
             return;
+
         if (!IsImage66 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 66))
         {
             DoSplit(66);
@@ -166,77 +195,101 @@ struct TRINITY_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI
             DoSplit(33);
             IsImage33 = true;
         }
+
         if (MindRend_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1))
                 DoCast(target,HEROIC(SPELL_MIND_REND, H_SPELL_MIND_REND));
             else
                 DoCast(m_creature->getVictim(),HEROIC(SPELL_MIND_REND, H_SPELL_MIND_REND));
+
             MindRend_Timer = 8000;
         }else MindRend_Timer -=diff;
+
         if (Fear_Timer < diff)
         {
             if (m_creature->IsNonMeleeSpellCasted(false))
                 return;
+
             DoScriptText(RAND(SAY_FEAR_1,SAY_FEAR_2), m_creature);
+
             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;
+
             DoScriptText(RAND(SAY_MIND_1,SAY_MIND_2), m_creature);
+
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1))
                 DoCast(target,HEROIC(SPELL_DOMINATION, H_SPELL_DOMINATION));
             else
                 DoCast(m_creature->getVictim(),HEROIC(SPELL_DOMINATION, H_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* pCreature)
 {
     return new boss_harbinger_skyrissAI (pCreature);
 }
+
 #define SPELL_MIND_REND_IMAGE   36929
 #define H_SPELL_MIND_REND_IMAGE 39021
+
 struct TRINITY_DLL_DECL boss_harbinger_skyriss_illusionAI : public ScriptedAI
 {
     boss_harbinger_skyriss_illusionAI(Creature *c) : ScriptedAI(c)
     {
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
+
     void Reset() { }
+
     void EnterCombat(Unit *who) { }
 };
+
 CreatureAI* GetAI_boss_harbinger_skyriss_illusion(Creature* pCreature)
 {
     return new boss_harbinger_skyriss_illusionAI (pCreature);
 }
+
 void AddSC_boss_harbinger_skyriss()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_harbinger_skyriss";
     newscript->GetAI = &GetAI_boss_harbinger_skyriss;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_harbinger_skyriss_illusion";
     newscript->GetAI = &GetAI_boss_harbinger_skyriss_illusion;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/def_arcatraz.h b/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/def_arcatraz.h
index 56810237064..3f8dee8bbd0 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/def_arcatraz.h
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/def_arcatraz.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/instance_arcatraz.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/instance_arcatraz.cpp
index 44c13e4c3a1..ebf5484671c 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/instance_arcatraz.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/arcatraz/instance_arcatraz.cpp
@@ -13,15 +13,19 @@
  * along 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 MAX_ENCOUNTER 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
@@ -31,18 +35,23 @@ EndScriptData */
 #define POD_OMEGA   183965                                  //pod fifth boss wave
 #define WARDENS_SHIELD  184802                              // warden shield
 #define SEAL_SPHERE 184802                                  //shield 'protecting' mellichar
+
 #define MELLICHAR   20904                                   //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 TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
 {
     instance_arcatraz(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     GameObject *Containment_Core_Security_Field_Alpha;
     GameObject *Containment_Core_Security_Field_Beta;
     GameObject *Pod_Alpha;
@@ -51,11 +60,14 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
     GameObject *Pod_Delta;
     GameObject *Pod_Omega;
     GameObject *Wardens_Shield;
+
     uint64 GoSphereGUID;
     uint64 MellicharGUID;
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         Containment_Core_Security_Field_Alpha = NULL;
         Containment_Core_Security_Field_Beta  = NULL;
         Pod_Alpha = NULL;
@@ -64,15 +76,19 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
         Pod_Gamma = NULL;
         Pod_Omega = NULL;
         Wardens_Shield = NULL;
+
         GoSphereGUID = 0;
         MellicharGUID = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnGameObjectCreate(GameObject* pGo, bool add)
     {
         switch(pGo->GetEntry())
@@ -88,11 +104,13 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
             //case WARDENS_SHIELD: Wardens_Shield = pGo; break;
         }
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         if (pCreature->GetEntry() == MELLICHAR)
             MellicharGUID = pCreature->GetGUID();
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -100,18 +118,21 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
             case TYPE_ZEREKETH:
                 m_auiEncounter[0] = data;
                 break;
+
             case TYPE_DALLIAH:
                 if (data == DONE)
                     if (Containment_Core_Security_Field_Beta)
                         Containment_Core_Security_Field_Beta->UseDoorOrButton();
                 m_auiEncounter[1] = data;
                 break;
+
             case TYPE_SOCCOTHRATES:
                 if (data == DONE)
                     if (Containment_Core_Security_Field_Alpha)
                         Containment_Core_Security_Field_Alpha->UseDoorOrButton();
                 m_auiEncounter[2] = data;
                 break;
+
             case TYPE_HARBINGERSKYRISS:
                 if (data == NOT_STARTED || data == FAIL)
                 {
@@ -123,36 +144,42 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
                 }
                 m_auiEncounter[3] = data;
                 break;
+
             case TYPE_WARDEN_1:
                 if (data == IN_PROGRESS)
                     if (Pod_Alpha)
                         Pod_Alpha->UseDoorOrButton();
                 m_auiEncounter[4] = data;
                 break;
+
             case TYPE_WARDEN_2:
                 if (data == IN_PROGRESS)
                     if (Pod_Beta)
                         Pod_Beta->UseDoorOrButton();
                 m_auiEncounter[5] = data;
                 break;
+
             case TYPE_WARDEN_3:
                 if (data == IN_PROGRESS)
                     if (Pod_Delta)
                         Pod_Delta->UseDoorOrButton();
                 m_auiEncounter[6] = data;
                 break;
+
             case TYPE_WARDEN_4:
                 if (data == IN_PROGRESS)
                     if (Pod_Gamma)
                         Pod_Gamma->UseDoorOrButton();
                 m_auiEncounter[7] = data;
                 break;
+
             case TYPE_WARDEN_5:
                 if (data == IN_PROGRESS)
                     if (Pod_Omega)
                         Pod_Omega->UseDoorOrButton();
                 m_auiEncounter[8] = data;
                 break;
+
             case TYPE_SHIELD_OPEN:
                 if (data == IN_PROGRESS)
                     if (Wardens_Shield)
@@ -160,6 +187,7 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
                 break;
         }
     }
+
     uint32 GetData(uint32 type)
     {
          switch(type)
@@ -179,6 +207,7 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
         }
         return 0;
     }
+
     uint64 GetData64(uint32 data)
     {
         switch(data)
@@ -191,10 +220,12 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance
         return 0;
     }
 };
+
 InstanceData* GetInstanceData_instance_arcatraz(Map* pMap)
 {
     return new instance_arcatraz(pMap);
 }
+
 void AddSC_instance_arcatraz()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_high_botanist_freywinn.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_high_botanist_freywinn.cpp
index e3868d56115..2e48e5147a3 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_high_botanist_freywinn.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_high_botanist_freywinn.cpp
@@ -13,54 +13,68 @@
  * along with 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                   -1553000
 #define SAY_KILL_1                  -1553001
 #define SAY_KILL_2                  -1553002
 #define SAY_TREE_1                  -1553003
 #define SAY_TREE_2                  -1553004
 #define SAY_DEATH                   -1553005
+
 #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 TRINITY_DLL_DECL boss_high_botanist_freywinnAI : public ScriptedAI
 {
     boss_high_botanist_freywinnAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void JustSummoned(Creature *summoned)
     {
         if (summoned->GetEntry() == ENTRY_FRAYER)
             Adds_List.push_back(summoned->GetGUID());
     }
+
     void DoSummonSeedling()
     {
         switch(rand()%4)
@@ -71,38 +85,48 @@ struct TRINITY_DLL_DECL boss_high_botanist_freywinnAI : public ScriptedAI
             case 3: DoCast(m_creature,SPELL_PLANT_RED); break;
         }
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (TreeForm_Timer < diff)
         {
             DoScriptText(RAND(SAY_TREE_1,SAY_TREE_2), m_creature);
+
             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)
+                    for(std::list::iterator itr = Adds_List.begin(); itr != Adds_List.end(); ++itr)
                     {
                         if (Unit *temp = Unit::GetUnit(*m_creature,*itr))
                         {
@@ -115,12 +139,15 @@ struct TRINITY_DLL_DECL boss_high_botanist_freywinnAI : public ScriptedAI
                         }
                     }
                 }
+
                 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());
@@ -129,26 +156,33 @@ struct TRINITY_DLL_DECL boss_high_botanist_freywinnAI : public ScriptedAI
                 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* pCreature)
 {
     return new boss_high_botanist_freywinnAI (pCreature);
 }
+
 void AddSC_boss_high_botanist_freywinn()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_high_botanist_freywinn";
     newscript->GetAI = &GetAI_boss_high_botanist_freywinn;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_laj.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_laj.cpp
index 1788cf749a4..58ff64a9493 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_laj.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_laj.cpp
@@ -13,16 +13,21 @@
  * along with 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: 90
 SDComment: Immunities are wrong, must be adjusted to use resistance from creature_templates. Most spells require database support.
 SDCategory: Tempest Keep, The Botanica
 EndScriptData */
+
 #include "precompiled.h"
+
 #define EMOTE_SUMMON                -1553006
+
 #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
@@ -31,19 +36,23 @@ EndScriptData */
 #define SPELL_SUMMON_FLAYER_4       34687
 #define SPELL_SUMMON_LASHER_4       34688
 #define SPELL_SUMMON_FLAYER_3       34690
+
 #define MODEL_DEFAULT               13109
 #define MODEL_ARCANE                14213
 #define MODEL_FIRE                  13110
 #define MODEL_FROST                 14112
 #define MODEL_NATURE                14214
+
 struct TRINITY_DLL_DECL boss_lajAI : public ScriptedAI
 {
     boss_lajAI(Creature *c) : ScriptedAI(c) {}
+
     bool CanSummon;
     uint32 Teleport_Timer;
     uint32 Summon_Timer;
     uint32 Transform_Timer;
     uint32 Allergic_Timer;
+
     void Reset()
     {
         m_creature->SetDisplayId(MODEL_DEFAULT);
@@ -52,12 +61,14 @@ struct TRINITY_DLL_DECL boss_lajAI : public ScriptedAI
         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)
@@ -104,6 +115,7 @@ struct TRINITY_DLL_DECL boss_lajAI : public ScriptedAI
                 break;
         }
     }
+
     void DoSummons()
     {
         switch(rand()%4)
@@ -127,18 +139,22 @@ struct TRINITY_DLL_DECL boss_lajAI : public ScriptedAI
         }
         CanSummon = false;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void JustSummoned(Creature *summon)
     {
         if (summon && m_creature->getVictim())
             summon->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0));
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (CanSummon)
         {
             if (Summon_Timer < diff)
@@ -148,32 +164,39 @@ struct TRINITY_DLL_DECL boss_lajAI : public ScriptedAI
                 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* pCreature)
 {
     return new boss_lajAI (pCreature);
 }
+
 void AddSC_boss_laj()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_laj";
     newscript->GetAI = &GetAI_boss_laj;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_warp_splinter.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_warp_splinter.cpp
index b50d15cd3a2..e06b1b03a41 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_warp_splinter.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/botanica/boss_warp_splinter.cpp
@@ -13,31 +13,41 @@
 * along with 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).
 SDCategory: Tempest Keep, The Botanica
 EndScriptData */
+
 #include "precompiled.h"
+
 /*#####
 # mob_treant (Sapling)
 #####*/
+
 #define SPELL_HEAL_FATHER   6262
+
 struct TRINITY_DLL_DECL mob_treantAI  : public ScriptedAI
 {
     mob_treantAI (Creature *c) : ScriptedAI(c)
     {
         WarpGuid = 0;
     }
+
     uint64 WarpGuid;
     uint32 check_Timer;
+
     void Reset()
     {
         check_Timer = 0;
     }
+
     void EnterCombat(Unit *who) {}
+
     void MoveInLineOfSight(Unit* who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -59,24 +69,31 @@ struct TRINITY_DLL_DECL mob_treantAI  : public ScriptedAI
             }else check_Timer -= diff;
             return;
         }
+
         if (m_creature->getVictim()->GetGUID() !=  WarpGuid)
             DoMeleeAttackIfReady();
     }
 };
+
 /*#####
 # boss_warp_splinter
 #####*/
+
 #define SAY_AGGRO           -1553007
 #define SAY_SLAY_1          -1553008
 #define SAY_SLAY_2          -1553009
 #define SAY_SUMMON_1        -1553010
 #define SAY_SUMMON_2        -1553011
 #define SAY_DEATH           -1553012
+
 #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       (HeroicMode?39133:36705)
+
 #define CREATURE_TREANT     19949
+
 #define TREANT_SPAWN_DIST   50                              //50 yards from Warp Splinter's spawn point
+
 float treant_pos[6][3] =
 {
     {24.301233, 427.221100, -27.060635},
@@ -86,6 +103,7 @@ float treant_pos[6][3] =
     {109.861877, 423.201630, -27.356019},
     {106.780159, 355.582581, -27.593357}
 };
+
 struct TRINITY_DLL_DECL boss_warp_splinterAI : public ScriptedAI
 {
     boss_warp_splinterAI(Creature *c) : ScriptedAI(c)
@@ -94,84 +112,104 @@ struct TRINITY_DLL_DECL boss_warp_splinterAI : public ScriptedAI
         Treant_Spawn_Pos_X = c->GetPositionX();
         Treant_Spawn_Pos_Y = c->GetPositionY();
     }
+
     uint32 War_Stomp_Timer;
     uint32 Summon_Treants_Timer;
     uint32 Arcane_Volley_Timer;
     bool HeroicMode;
+
     float Treant_Spawn_Pos_X;
     float Treant_Spawn_Pos_Y;
+
     void Reset()
     {
         War_Stomp_Timer = 25000 + rand()%15000;
         Summon_Treants_Timer = 45000;
         Arcane_Volley_Timer = 8000 + rand()%12000;
+
         m_creature->SetSpeed(MOVE_RUN, 0.7f, true);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
     }
+
     void SummonTreants()
     {
-        for (uint8 i = 0; i < 6; ++i)
+        for(uint8 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 O = - m_creature->GetAngle(X,Y);
+
             if (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,25000))
                 CAST_AI(mob_treantAI, pTreant->AI())->WarpGuid = m_creature->GetGUID();
         }
         DoScriptText(RAND(SAY_SUMMON_1,SAY_SUMMON_2), m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         //Check for War Stomp
         if (War_Stomp_Timer < diff)
         {
             DoCast(m_creature->getVictim(),WAR_STOMP);
             War_Stomp_Timer = 25000 + rand()%15000;
         }else War_Stomp_Timer -= diff;
+
         //Check for Arcane Volley
         if (Arcane_Volley_Timer < diff)
         {
             DoCast(m_creature->getVictim(),ARCANE_VOLLEY);
             Arcane_Volley_Timer = 20000 + rand()%15000;
         }else Arcane_Volley_Timer -= diff;
+
         //Check for Summon Treants
         if (Summon_Treants_Timer < diff)
         {
             SummonTreants();
             Summon_Treants_Timer = 45000;
         }else Summon_Treants_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_warp_splinter(Creature* pCreature)
 {
     return new boss_warp_splinterAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_treant(Creature* pCreature)
 {
     return new mob_treantAI (pCreature);
 }
+
 void AddSC_boss_warp_splinter()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_warp_splinter";
     newscript->GetAI = &GetAI_boss_warp_splinter;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_warp_splinter_treant";
     newscript->GetAI = &GetAI_mob_treant;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_alar.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_alar.cpp
index 13b572aa865..b96ca667835 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_alar.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_alar.cpp
@@ -13,14 +13,17 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: boss_alar
 SD%Complete: 95
 SDComment:
 SDCategory: Tempest Keep, The Eye
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_the_eye.h"
+
 #define SPELL_FLAME_BUFFET            34121 // Flame Buffet - every 1,5 secs in phase 1 if there is no victim in melee range and after Dive Bomb in phase 2 with same conditions
 #define SPELL_FLAME_QUILLS            34229 // Randomly after changing position in phase after watching tonns of movies, set probability 20%
 #define SPELL_REBIRTH                 34342 // Rebirth - beginning of second phase(after loose all health in phase 1)
@@ -30,10 +33,13 @@ EndScriptData */
 #define SPELL_DIVE_BOMB_VISUAL        35367 // Bosskillers says 30 sec cooldown, wowwiki says 30 sec colldown, DBM and BigWigs addons says ~47 sec
 #define SPELL_DIVE_BOMB               35181 // after watching tonns of movies, set cooldown to 40+rand()%5.
 #define SPELL_BERSERK                 45078 // 10 minutes after phase 2 starts(id is wrong, but proper id is unknown)
+
 #define CREATURE_EMBER_OF_ALAR        19551 // Al'ar summons one Ember of Al'ar every position change in phase 1 and two after Dive Bomb. Also in phase 2 when Ember of Al'ar dies, boss loose 3% health.
 #define SPELL_EMBER_BLAST             34133 // When Ember of Al'ar dies, it casts Ember Blast
+
 #define CREATURE_FLAME_PATCH_ALAR     20602 // Flame Patch - every 30 sec in phase 2
 #define SPELL_FLAME_PATCH             35380 //
+
 static float waypoint[6][3] =
 {
     {340.15, 58.65, 17.71},
@@ -43,6 +49,7 @@ static float waypoint[6][3] =
     {332, 0.01, 39}, // better not use the same xy coord
     {331, 0.01, -2.39}
 };
+
 enum WaitEventType
 {
     WE_NONE     = 0,
@@ -57,6 +64,7 @@ enum WaitEventType
     WE_LAND     = 9,
     WE_SUMMON   = 10
 };
+
 struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
 {
     boss_alarAI(Creature *c) : ScriptedAI(c)
@@ -64,34 +72,46 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
         pInstance =c->GetInstanceData();
         DefaultMoveSpeedRate = c->GetSpeedRate(MOVE_RUN);
     }
+
     ScriptedInstance *pInstance;
+
     WaitEventType WaitEvent;
     uint32 WaitTimer;
+
     bool AfterMoving;
+
     uint32 Platforms_Move_Timer;
     uint32 DiveBomb_Timer;
     uint32 MeltArmor_Timer;
     uint32 Charge_Timer;
     uint32 FlamePatch_Timer;
     uint32 Berserk_Timer;
+
     float DefaultMoveSpeedRate;
+
     bool Phase1;
     bool ForceMove;
     uint32 ForceTimer;
+
     int8 cur_wp;
+
     void Reset()
     {
         if (pInstance)
             pInstance->SetData(DATA_ALAREVENT, NOT_STARTED);
+
         Berserk_Timer = 1200000;
         Platforms_Move_Timer = 0;
+
         Phase1 = true;
         WaitEvent = WE_NONE;
         WaitTimer = 0;
         AfterMoving = false;
         ForceMove = false;
         ForceTimer = 5000;
+
         cur_wp = 4;
+
         m_creature->SetDisplayId(m_creature->GetNativeDisplayId());
         m_creature->SetSpeed(MOVE_RUN, DefaultMoveSpeedRate);
         //m_creature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10);
@@ -101,26 +121,32 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->setActive(false);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_ALAREVENT, IN_PROGRESS);
+
         m_creature->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING); // after enterevademode will be set walk movement
         DoZoneInCombat();
         m_creature->setActive(true);
     }
+
     void JustDied(Unit *victim)
     {
         if (pInstance)
             pInstance->SetData(DATA_ALAREVENT, DONE);
     }
+
     void JustSummoned(Creature *summon)
     {
         if (summon->GetEntry() == CREATURE_EMBER_OF_ALAR)
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 summon->AI()->AttackStart(target);
     }
+
     void MoveInLineOfSight(Unit *who) {}
+
     void AttackStart(Unit* who)
     {
         if (Phase1)
@@ -128,6 +154,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
         else
             ScriptedAI::AttackStart(who);
     }
+
     void DamageTaken(Unit* pKiller, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth() && Phase1)
@@ -149,6 +176,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
             }
         }
     }
+
     void SpellHit(Unit*, const SpellEntry *spell)
     {
         if (spell->Id == SPELL_DIVE_BOMB_VISUAL)
@@ -158,6 +186,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
             //m_creature->SendUpdateObjectToAllExcept(NULL);
         }
     }
+
     void MovementInform(uint32 type, uint32 id)
     {
         if (type == POINT_MOTION_TYPE)
@@ -167,15 +196,18 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
             ForceMove = false;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!m_creature->isInCombat()) // sometimes isincombat but !incombat, faction bug?
             return;
+
         if (Berserk_Timer < diff)
         {
             m_creature->CastSpell(m_creature, SPELL_BERSERK, true);
             Berserk_Timer = 60000;
         }else Berserk_Timer -= diff;
+
         if (ForceMove)
         {
             if (ForceTimer < diff)
@@ -183,6 +215,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
                 m_creature->GetMotionMaster()->MovePoint(0, waypoint[cur_wp][0], waypoint[cur_wp][1], waypoint[cur_wp][2]);
                 ForceTimer = 5000;
             }else ForceTimer -= diff;
+
         }
         if (WaitEvent)
         {
@@ -195,6 +228,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
                         m_creature->GetMotionMaster()->MoveIdle();
                         AfterMoving = false;
                     }
+
                     switch(WaitEvent)
                     {
                     case WE_PLATFORM:
@@ -254,7 +288,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
                         WaitTimer = 2000;
                         return;
                     case WE_SUMMON:
-                        for (uint8 i = 0; i < 2; ++i)
+                        for(uint8 i = 0; i < 2; ++i)
                             DoSpawnCreature(CREATURE_EMBER_OF_ALAR, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                         m_creature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10);
                         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -265,12 +299,14 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
                     default:
                         break;
                     }
+
                     WaitEvent = WE_NONE;
                     WaitTimer = 0;
                 }else WaitTimer -= diff;
             }
             return;
         }
+
         if (Phase1)
         {
             if (m_creature->getThreatManager().getThreatList().empty())
@@ -278,6 +314,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
                 EnterEvadeMode();
                 return;
             }
+
             if (Platforms_Move_Timer < diff)
             {
                 if (cur_wp == 4)
@@ -318,11 +355,13 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
                     DoCast(target, SPELL_CHARGE);
                 Charge_Timer = 30000;
             }else Charge_Timer -= diff;
+
             if (MeltArmor_Timer < diff)
             {
                 DoCast(m_creature->getVictim(), SPELL_MELT_ARMOR);
                 MeltArmor_Timer = 60000;
             }else MeltArmor_Timer -= diff;
+
             if (DiveBomb_Timer < diff)
             {
                 m_creature->AttackStop();
@@ -334,6 +373,7 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
                 DiveBomb_Timer = 40000+rand()%5000;
                 return;
             }else DiveBomb_Timer -= diff;
+
             if (FlamePatch_Timer < diff)
             {
                 if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
@@ -352,8 +392,10 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
                 FlamePatch_Timer = 30000;
             }else FlamePatch_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
+
     void DoMeleeAttackIfReady()
     {
         if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
@@ -378,10 +420,12 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_boss_alar(Creature* pCreature)
 {
     return new boss_alarAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_ember_of_alarAI : public ScriptedAI
 {
     mob_ember_of_alarAI(Creature *c) : ScriptedAI(c)
@@ -390,11 +434,14 @@ struct TRINITY_DLL_DECL mob_ember_of_alarAI : public ScriptedAI
         c->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
         c->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true);
     }
+
     ScriptedInstance *pInstance;
     bool toDie;
+
     void Reset() {toDie = false;}
     void EnterCombat(Unit *who) {DoZoneInCombat();}
     void EnterEvadeMode() {m_creature->setDeathState(JUST_DIED);}
+
     void DamageTaken(Unit* pKiller, uint32 &damage)
     {
         if (damage >= m_creature->GetHealth() && pKiller != m_creature && !toDie)
@@ -417,22 +464,28 @@ struct TRINITY_DLL_DECL mob_ember_of_alarAI : public ScriptedAI
             toDie = true;
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (toDie)
         {
             m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
             //m_creature->SetVisibility(VISIBILITY_OFF);
         }
+
         DoMeleeAttackIfReady();
     }
+
 };
+
 CreatureAI* GetAI_mob_ember_of_alar(Creature* pCreature)
 {
     return new mob_ember_of_alarAI(pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_flame_patch_alarAI : public ScriptedAI
 {
     mob_flame_patch_alarAI(Creature *c) : ScriptedAI(c) {}
@@ -442,21 +495,26 @@ struct TRINITY_DLL_DECL mob_flame_patch_alarAI : public ScriptedAI
     void MoveInLineOfSight(Unit* who) {}
     void UpdateAI(const uint32 diff) {}
 };
+
 CreatureAI* GetAI_mob_flame_patch_alar(Creature* pCreature)
 {
     return new mob_flame_patch_alarAI(pCreature);
 }
+
 void AddSC_boss_alar()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_alar";
     newscript->GetAI = &GetAI_boss_alar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ember_of_alar";
     newscript->GetAI = &GetAI_mob_ember_of_alar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_flame_patch_alar";
     newscript->GetAI = &GetAI_mob_flame_patch_alar;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_astromancer.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_astromancer.cpp
index e8ba7e3a197..7cf9f3b1c62 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_astromancer.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_astromancer.cpp
@@ -13,14 +13,17 @@
  * along with 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: 80
 SDComment:
 SDCategory: Tempest Keep, The Eye
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_the_eye.h"
+
 enum eEnums
 {
     SAY_AGGRO                           = -1550007,
@@ -32,22 +35,29 @@ enum eEnums
     SAY_DEATH                           = -1550013,
     SAY_VOIDA                           = -1550014,
     SAY_VOIDB                           = -1550015,
+
     SPELL_ARCANE_MISSILES               = 33031,
     SPELL_WRATH_OF_THE_ASTROMANCER      = 42783,
     SPELL_BLINDING_LIGHT                = 33009,
     SPELL_FEAR                          = 34322,
     SPELL_VOID_BOLT                     = 39329,
+
     SPELL_SPOTLIGHT                     = 25824,
     NPC_ASTROMANCER_SOLARIAN_SPOTLIGHT  = 18928,
+
     NPC_SOLARIUM_AGENT                  = 18925,
     NPC_SOLARIUM_PRIEST                 = 18806,
+
     MODEL_HUMAN                         = 18239,
     MODEL_VOIDWALKER                    = 18988,
+
     SPELL_SOLARIUM_GREAT_HEAL           = 33387,
     SPELL_SOLARIUM_HOLY_SMITE           = 25054,
     SPELL_SOLARIUM_ARCANE_TORRENT       = 33390,
+
     WV_ARMOR                            = 31000
 };
+
 const float CENTER_X                    = 432.909f;
 const float CENTER_Y                    = -373.424f;
 const float CENTER_Z                    = 17.9608f;
@@ -55,19 +65,25 @@ const float CENTER_O                    = 1.06421f;
 const float SMALL_PORTAL_RADIUS         = 12.6f;
 const float LARGE_PORTAL_RADIUS         = 26.0f;
 const float PORTAL_Z                    = 17.005f;
+
                             // x,          y,      z,         o
 static float SolarianPos[4] = {432.909, -373.424, 17.9608, 1.06421};
+
 struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
 {
     boss_high_astromancer_solarianAI(Creature *c) : ScriptedAI(c), Summons(m_creature)
     {
         pInstance = c->GetInstanceData();
+
         defaultarmor = c->GetArmor();
         defaultsize = c->GetFloatValue(OBJECT_FIELD_SCALE_X);
     }
+
     ScriptedInstance *pInstance;
     SummonList Summons;
+
     uint8 Phase;
+
     uint32 ArcaneMissiles_Timer;
     uint32 m_uiWrathOfTheAstromancer_Timer;
     uint32 BlindingLight_Timer;
@@ -79,10 +95,13 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
     uint32 AppearDelay_Timer;
     uint32 defaultarmor;
     uint32 Wrath_Timer;
+
     float defaultsize;
     float Portals[3][3];
+
     bool AppearDelay;
     bool BlindingLight;
+
     void Reset()
     {
         ArcaneMissiles_Timer = 2000;
@@ -99,34 +118,43 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
         Wrath_Timer = 20000+rand()%5000;//twice in phase one
         Phase = 1;
         Wrath_Timer = 20000+rand()%5000;//twice in phase one
+
         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->SetDisplayId(MODEL_HUMAN);
+
         Summons.DespawnAll();
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_KILL1,SAY_KILL2,SAY_KILL3), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize);
         m_creature->SetDisplayId(MODEL_HUMAN);
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
         DoZoneInCombat();
+
         if (pInstance)
             pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, IN_PROGRESS);
     }
+
     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);
@@ -134,18 +162,23 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 Summoned->AI()->AttackStart(target);
+
             Summons.Summon(Summoned);
         }
     }
+
     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 = 0.0f;
+
         switch(rand()%2)
         {
             case 0: z = 1; break;
@@ -153,10 +186,12 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
         }
         return (z*sqrt(radius*radius - (x - CENTER_X)*(x - CENTER_X)) + CENTER_Y);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (AppearDelay)
         {
             m_creature->StopMoving();
@@ -172,38 +207,43 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
                 AppearDelay_Timer = 2000;
             }else AppearDelay_Timer -= diff;
         }
+
         if (Phase == 1)
         {
             if (BlindingLight_Timer < diff){
                 BlindingLight = true;
                 BlindingLight_Timer = 45000;
             }else BlindingLight_Timer -= diff;
+
             if (Wrath_Timer < diff)
             {
                 m_creature->InterruptNonMeleeSpells(false);
                 DoCast(SelectTarget(SELECT_TARGET_RANDOM,1,100,true), SPELL_WRATH_OF_THE_ASTROMANCER, true);
                 Wrath_Timer = 20000+rand()%5000;
             }else Wrath_Timer -= diff;
+
             if (ArcaneMissiles_Timer < diff)
             {
                 if (BlindingLight)
                 {
                     DoCast(m_creature->getVictim(), SPELL_BLINDING_LIGHT);
                     BlindingLight = false;
-                }
-                else
-                {
+                }else{
                     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;
+
             if (m_uiWrathOfTheAstromancer_Timer < diff)
             {
                 m_creature->InterruptNonMeleeSpells(false);
+
                 //Target the tank ?
                 if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1))
                     if (pTarget->GetTypeId() == TYPEID_PLAYER)
@@ -214,6 +254,7 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
                     else
                         m_uiWrathOfTheAstromancer_Timer = 1000;
             }else m_uiWrathOfTheAstromancer_Timer -= diff;
+
             //Phase1_Timer
             if (Phase1_Timer < diff)
             {
@@ -222,7 +263,7 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
                 //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->GetMap()->CreatureRelocation(m_creature, CENTER_X, CENTER_Y, CENTER_Z, CENTER_O);
-                for (uint8 i=0; i<=2; ++i)
+                for(uint8 i=0; i<=2; ++i)
                 {
                     if (!i)
                     {
@@ -267,6 +308,7 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
                 for (int i=0; i<=2; ++i)
                     for (int j=1; j<=4; j++)
                         SummonMinion(NPC_SOLARIUM_AGENT, Portals[i][0], Portals[i][1], Portals[i][2]);
+
                 DoScriptText(SAY_SUMMON1, m_creature);
                 Phase2_Timer = 10000;
             } else Phase2_Timer -= diff;
@@ -275,19 +317,24 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
         {
             m_creature->AttackStop();
             m_creature->StopMoving();
+
             //Check Phase3_Timer
             if (Phase3_Timer < diff)
             {
                 Phase = 1;
+
                 //15 seconds later Solarian reappears out of one of the 3 portals. Simultaneously, 2 healers appear in the two other portals.
                 int i = rand()%3;
                 m_creature->GetMotionMaster()->Clear();
                 m_creature->GetMap()->CreatureRelocation(m_creature, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O);
+
                 for (int j=0; j<=2; j++)
                     if (j!=i)
                         SummonMinion(NPC_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);
+
                 DoScriptText(SAY_SUMMON2, m_creature);
                 AppearDelay = true;
                 Phase3_Timer = 15000;
@@ -301,6 +348,7 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
                 DoCast(m_creature, SPELL_FEAR);
                 Fear_Timer = 20000;
             }else Fear_Timer -= diff;
+
             //VoidBolt_Timer
             if (VoidBolt_Timer < diff)
             {
@@ -308,10 +356,12 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
                 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);
@@ -321,35 +371,44 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
             m_creature->SetDisplayId(MODEL_VOIDWALKER);
             m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize*2.5f);
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 struct TRINITY_DLL_DECL mob_solarium_priestAI : public ScriptedAI
 {
     mob_solarium_priestAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance *pInstance;
+
     uint32 healTimer;
     uint32 holysmiteTimer;
     uint32 aoesilenceTimer;
+
     void Reset()
     {
         healTimer = 9000;
         holysmiteTimer = 1;
         aoesilenceTimer = 15000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (healTimer < diff)
         {
             Unit* target = NULL;
+
             switch(rand()%2)
             {
                 case 0:
@@ -360,33 +419,40 @@ struct TRINITY_DLL_DECL mob_solarium_priestAI : public ScriptedAI
                     target = m_creature;
                     break;
             }
+
             if (target)
             {
                 DoCast(target,SPELL_SOLARIUM_GREAT_HEAL);
                 healTimer = 9000;
             }
         } else healTimer -= diff;
+
         if (holysmiteTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SOLARIUM_HOLY_SMITE);
             holysmiteTimer = 4000;
         } else holysmiteTimer -= diff;
+
         if (aoesilenceTimer < diff)
         {
             DoCast(m_creature->getVictim(), SPELL_SOLARIUM_ARCANE_TORRENT);
             aoesilenceTimer = 13000;
         } else aoesilenceTimer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_mob_solarium_priest(Creature* pCreature)
 {
     return new mob_solarium_priestAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_high_astromancer_solarian(Creature* pCreature)
 {
     return new boss_high_astromancer_solarianAI (pCreature);
 }
+
 void AddSC_boss_high_astromancer_solarian()
 {
     Script *newscript;
@@ -394,6 +460,7 @@ void AddSC_boss_high_astromancer_solarian()
     newscript->Name = "boss_high_astromancer_solarian";
     newscript->GetAI = &GetAI_boss_high_astromancer_solarian;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_solarium_priest";
     newscript->GetAI = &GetAI_mob_solarium_priest;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_kaelthas.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_kaelthas.cpp
index b5a950e8dee..2341f78ebe3 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_kaelthas.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_kaelthas.cpp
@@ -13,15 +13,18 @@
  * along with 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, weapon scripts, mind control, need correct spells(interruptible/uninterruptible), phoenix spawn location & animation, phoenix behaviour & spawn during gravity lapse
 SDCategory: Tempest Keep, The Eye
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_the_eye.h"
 #include "WorldPacket.h"
+
 enum eEnums
 {
     //kael'thas Speech
@@ -44,19 +47,24 @@ enum eEnums
     SAY_SUMMON_PHOENIX1                 = -1550032,
     SAY_SUMMON_PHOENIX2                 = -1550033,
     SAY_DEATH                           = -1550034,
+
     //Thaladred the Darkener speech
     SAY_THALADRED_AGGRO                 = -1550035,
     SAY_THALADRED_DEATH                 = -1550036,
     EMOTE_THALADRED_GAZE                = -1550037,
+
     //Lord Sanguinar speech
     SAY_SANGUINAR_AGGRO                 = -1550038,
     SAY_SANGUINAR_DEATH                 = -1550039,
+
     //Grand Astromancer Capernian speech
     SAY_CAPERNIAN_AGGRO                 = -1550040,
     SAY_CAPERNIAN_DEATH                 = -1550041,
+
     //Master Engineer Telonicus speech
     SAY_TELONICUS_AGGRO                 = -1550042,
     SAY_TELONICUS_DEATH                 = -1550043,
+
     //Phase 2 spells
     SPELL_SUMMON_WEAPONS                = 36976,
     SPELL_SUMMON_WEAPONA                = 36958,
@@ -67,6 +75,7 @@ enum eEnums
     SPELL_SUMMON_WEAPONF                = 36963,
     SPELL_SUMMON_WEAPONG                = 36964,
     SPELL_RES_VISUAL                    = 24171,
+
     //Phase 4 spells
     SPELL_FIREBALL                      = 22088,           //wrong but works with CastCustomSpell
     SPELL_PYROBLAST                     = 36819,
@@ -77,6 +86,7 @@ enum eEnums
     SPELL_SHOCK_BARRIER                 = 36815,
     SPELL_PHOENIX_ANIMATION             = 36723,
     SPELL_MIND_CONTROL                  = 32830,
+
     //Phase 5 spells
     SPELL_EXPLODE                       = 36092,
     SPELL_FULLPOWER                     = 36187,
@@ -84,12 +94,14 @@ enum eEnums
     SPELL_GRAVITY_LAPSE                 = 34480,
     SPELL_GRAVITY_LAPSE_AURA            = 39432,
     SPELL_NETHER_BEAM                   = 35873,
+
     //Thaladred the Darkener spells
     SPELL_PSYCHIC_BLOW                  = 10689,
     SPELL_SILENCE                       = 30225,
     //Lord Sanguinar spells
     SPELL_BELLOWING_ROAR                = 40636,
     //Grand Astromancer Capernian spells
+
     SPELL_CAPERNIAN_FIREBALL            = 36971,
     SPELL_CONFLAGRATION                 = 37018,
     SPELL_ARCANE_EXPLOSION              = 36970,
@@ -102,24 +114,32 @@ enum eEnums
     SPELL_BURN                          = 36720,
     SPELL_EMBER_BLAST                   = 34341,
     SPELL_REBIRTH                       = 41587,
+
     //Creature IDs
     NPC_PHOENIX                         = 21362,
     NPC_PHOENIX_EGG                     = 21364,
+
     //Phoenix egg and phoenix model
     MODEL_ID_PHOENIX                    = 19682,
     MODEL_ID_PHOENIX_EGG                = 20245,
+
     MAX_ADVISORS                        = 4
 };
+
 uint32 m_auiSpellSummonWeapon[]=
 {
     SPELL_SUMMON_WEAPONA, SPELL_SUMMON_WEAPONB, SPELL_SUMMON_WEAPONC, SPELL_SUMMON_WEAPOND,
     SPELL_SUMMON_WEAPONE, SPELL_SUMMON_WEAPONF, SPELL_SUMMON_WEAPONG
 };
+
 const float CAPERNIAN_DISTANCE          = 20.0f;            //she casts away from the target
 const float KAEL_VISIBLE_RANGE          = 50.0f;
+
 const float afGravityPos[3]             = {795.0f, 0.0f, 70.0f};
+
 #define TIME_PHASE_2_3      120000
 #define TIME_PHASE_3_4      180000
+
 //Base AI for Advisors
 struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI
 {
@@ -128,11 +148,13 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI
         m_pInstance = pCreature->GetInstanceData();
         m_bDoubled_Health = false;
     }
+
     ScriptedInstance* m_pInstance;
     bool FakeDeath;
     bool m_bDoubled_Health;
     uint32 DelayRes_Timer;
     uint64 DelayRes_Target;
+
     void Reset()
     {
         if (m_bDoubled_Health)
@@ -140,29 +162,37 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI
             m_creature->SetMaxHealth(m_creature->GetMaxHealth() / 2);
             m_bDoubled_Health = false;
         }
+
         FakeDeath = false;
         DelayRes_Timer = 0;
         DelayRes_Target = 0;
+
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
         //reset encounter
         if (m_pInstance && (m_pInstance->GetData(DATA_KAELTHASEVENT) == 1 || m_pInstance->GetData(DATA_KAELTHASEVENT) == 3))
             if (Creature *Kaelthas = Unit::GetCreature((*m_creature), m_pInstance->GetData64(DATA_KAELTHAS)))
                 Kaelthas->AI()->EnterEvadeMode();
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         ScriptedAI::MoveInLineOfSight(who);
     }
+
     void AttackStart(Unit* who)
     {
         if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         ScriptedAI::AttackStart(who);
     }
+
     void Revive(Unit* Target)
     {
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -171,25 +201,30 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI
         m_bDoubled_Health = true;
         m_creature->SetHealth(m_creature->GetMaxHealth());
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
+
         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 && m_pInstance && m_pInstance->GetData(DATA_KAELTHASEVENT) != 0)
         {
             damage = 0;
             return;
         }
+
         //Don't really die in phase 1 & 3, only die after that
         if (m_pInstance && m_pInstance->GetData(DATA_KAELTHASEVENT) != 0)
         {
             //prevent death
             damage = 0;
             FakeDeath = true;
+
             m_creature->InterruptNonMeleeSpells(false);
             m_creature->SetHealth(0);
             m_creature->StopMoving();
@@ -206,6 +241,7 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI
             JustDied(pKiller);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (DelayRes_Timer)
@@ -214,9 +250,11 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI
             {
                 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();
@@ -225,7 +263,9 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI
             } else DelayRes_Timer -= diff;
         }
     }
+
 };
+
 //Kael'thas AI
 struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
 {
@@ -234,7 +274,9 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
         m_pInstance = pCreature->GetInstanceData();
         memset(&m_auiAdvisorGuid, 0, sizeof(m_auiAdvisorGuid));
     }
+
     ScriptedInstance* m_pInstance;
+
     uint32 Fireball_Timer;
     uint32 ArcaneDisruption_Timer;
     uint32 Phoenix_Timer;
@@ -249,11 +291,15 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
     uint32 PhaseSubphase;                                   //generic
     uint32 Phase_Timer;                                     //generic timer
     uint32 PyrosCasted;
+
     bool InGravityLapse;
     bool IsCastingFireball;
     bool ChainPyros;
+
     SummonList summons;
+
     uint64 m_auiAdvisorGuid[MAX_ADVISORS];
+
     void Reset()
     {
         Fireball_Timer = 5000+rand()%10000;
@@ -271,17 +317,22 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
         InGravityLapse = false;
         IsCastingFireball = false;
         ChainPyros = false;
+
         if (m_creature->isInCombat())
             PrepareAdvisors();
+
         summons.DespawnAll();
+
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
         if (m_pInstance)
             m_pInstance->SetData(DATA_KAELTHASEVENT, 0);
     }
+
     void PrepareAdvisors()
     {
-        for (uint8 i = 0; i < MAX_ADVISORS; ++i)
+        for(uint8 i = 0; i < MAX_ADVISORS; ++i)
         {
             if (Creature *pCreature = Unit::GetCreature((*m_creature), m_auiAdvisorGuid[i]))
             {
@@ -292,36 +343,49 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
             }
         }
     }
+
     void StartEvent()
     {
         if (!m_pInstance)
             return;
+
         m_auiAdvisorGuid[0] = m_pInstance->GetData64(DATA_THALADREDTHEDARKENER);
         m_auiAdvisorGuid[1] = m_pInstance->GetData64(DATA_LORDSANGUINAR);
         m_auiAdvisorGuid[2] = m_pInstance->GetData64(DATA_GRANDASTROMANCERCAPERNIAN);
         m_auiAdvisorGuid[3] = m_pInstance->GetData64(DATA_MASTERENGINEERTELONICUS);
+
         if (!m_auiAdvisorGuid[0] || !m_auiAdvisorGuid[1] || !m_auiAdvisorGuid[2] || !m_auiAdvisorGuid[3])
         {
             error_log("TSCR: Kael'Thas One or more advisors missing, Skipping Phases 1-3");
+
             DoScriptText(SAY_PHASE4_INTRO2, m_creature);
+
             Phase = 4;
+
             m_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);
+
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 AttackStart(target);
+
         }
         else
         {
             PrepareAdvisors();
+
             DoScriptText(SAY_INTRO, m_creature);
+
             m_pInstance->SetData(DATA_KAELTHASEVENT, 1);
             m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
             PhaseSubphase = 0;
             Phase_Timer = 23000;
             Phase = 1;
         }
     }
+
     void MoveInLineOfSight(Unit *who)
     {
         if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && who->isTargetableForAttack() &&
@@ -329,6 +393,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
         {
             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))
             {
@@ -341,21 +406,25 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                 {
                     if (m_pInstance && !m_pInstance->GetData(DATA_KAELTHASEVENT) && !Phase)
                         StartEvent();
+
                     who->SetInCombatWith(m_creature);
                     m_creature->AddThreat(who, 0.0f);
                 }
             }
         }
     }
+
     void Aggro(Unit *who)
     {
         if (m_pInstance && !m_pInstance->GetData(DATA_KAELTHASEVENT) && !Phase)
             StartEvent();
     }
+
     void KilledUnit()
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         // if not phoenix, then it's one of the 7 weapons
@@ -363,24 +432,32 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 pSummoned->AI()->AttackStart(pTarget);
+
             summons.Summon(pSummoned);
         }
     }
+
     void SummonedCreatureDespawn(Creature *summon) {summons.Despawn(summon);}
+
     void JustDied(Unit* Killer)
     {
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
         DoScriptText(SAY_DEATH, m_creature);
+
         summons.DespawnAll();
+
         if (m_pInstance)
             m_pInstance->SetData(DATA_KAELTHASEVENT, 0);
-        for (uint8 i = 0; i < MAX_ADVISORS; ++i)
+
+        for(uint8 i = 0; i < MAX_ADVISORS; ++i)
         {
             if (Unit* pAdvisor = Unit::GetUnit((*m_creature), m_auiAdvisorGuid[i]))
                 pAdvisor->Kill(pAdvisor);
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Phase 1
@@ -390,6 +467,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
             {
                 Unit *target = NULL;
                 Creature* Advisor = NULL;
+
                 //Subphase switch
                 switch(PhaseSubphase)
                 {
@@ -398,118 +476,148 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                         if (Phase_Timer < diff)
                         {
                             DoScriptText(SAY_INTRO_THALADRED, m_creature);
+
                             //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 = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[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 = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[0]));
+
                         if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
                         {
                             DoScriptText(SAY_INTRO_SANGUINAR, m_creature);
+
                             //start advisor within 12.5 seconds
                             Phase_Timer = 12500;
                             ++PhaseSubphase;
                         }
                         break;
+
                     //Subphase 2 - Unlock advisor
                     case 3:
                         if (Phase_Timer < diff)
                         {
                             Advisor = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[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 = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[1]));
+
                         if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
                         {
                             DoScriptText(SAY_INTRO_CAPERNIAN, m_creature);
+
                             //start advisor within 7 seconds
                             Phase_Timer = 7000;
                             ++PhaseSubphase;
                         }
                         break;
+
                     //Subphase 3 - Unlock advisor
                     case 5:
                         if (Phase_Timer < diff)
                         {
                             Advisor = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[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 = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[2]));
+
                         if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
                         {
                             DoScriptText(SAY_INTRO_TELONICUS, m_creature);
+
                             //start advisor within 8.4 seconds
                             Phase_Timer = 8400;
                             ++PhaseSubphase;
                         }
                         break;
+
                     //Subphase 4 - Unlock advisor
                     case 7:
                         if (Phase_Timer < diff)
                         {
                             Advisor = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[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 = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[3]));
+
                         if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
                         {
                             Phase = 2;
                             if(m_pInstance)
                                 m_pInstance->SetData(DATA_KAELTHASEVENT, 2);
+
                             DoScriptText(SAY_PHASE2_WEAPON, m_creature);
+
                             PhaseSubphase = 0;
                             Phase_Timer = 3500;
                             DoCast(m_creature, SPELL_SUMMON_WEAPONS);
@@ -517,6 +625,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                         break;
                 }
             }break;
+
             case 2:
             {
                 if (PhaseSubphase == 0)
@@ -526,16 +635,21 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                         PhaseSubphase = 1;
                     }else Phase_Timer -= diff;
                 }
+
                 //Spawn weapons
                 if (PhaseSubphase == 1)
                 {
                     m_creature->CastSpell(m_creature, SPELL_SUMMON_WEAPONS, false);
+
                     uint8 uiMaxWeapon = sizeof(m_auiSpellSummonWeapon)/sizeof(uint32);
+
                     for (uint32 i = 0; i < uiMaxWeapon; ++i)
                         m_creature->CastSpell(m_creature,m_auiSpellSummonWeapon[i],true);
+
                     PhaseSubphase = 2;
                     Phase_Timer = TIME_PHASE_2_3;
                 }
+
                 if (PhaseSubphase == 2)
                 {
                     if (Phase_Timer < diff)
@@ -548,40 +662,51 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                     }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 < MAX_ADVISORS; ++i)
                     {
                         Advisor = (Unit::GetCreature((*m_creature), m_auiAdvisorGuid[i]));
+
                         if (!Advisor)
                             error_log("SD2: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i);
                         else
                             CAST_AI(advisorbase_ai, Advisor->AI())->Revive(Target);
                     }
+
                     PhaseSubphase = 1;
                     Phase_Timer = TIME_PHASE_3_4;
                 }
+
                 if (Phase_Timer < diff)
                 {
                     DoScriptText(SAY_PHASE4_INTRO2, m_creature);
                     Phase = 4;
+
                     if(m_pInstance)
                         m_pInstance->SetData(DATA_KAELTHASEVENT, 4);
+
                     // Sometimes people can collect Aggro in Phase 1-3. Reset threat before releasing Kael.
                     DoResetThreat();
+
                     m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                     m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
                     if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                         AttackStart(target);
+
                     Phase_Timer = 30000;
                 } else Phase_Timer -= diff;
             }
             break;
+
             case 4:
             case 5:
             case 6:
@@ -589,6 +714,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                 //Return since we have no target
                 if (!UpdateVictim())
                     return;
+
                 //Fireball_Timer
                 if (!InGravityLapse && !ChainPyros && Phase != 5)
                 {
@@ -614,18 +740,22 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                             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)
                     {
                         if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                             DoCast(pUnit, SPELL_FLAME_STRIKE);
+
                         FlameStrike_Timer = 30000;
                     } else FlameStrike_Timer -= diff;
+
                     if (MindControl_Timer < diff)
                     {
                         if (m_creature->getThreatManager().getThreatList().size() >= 2)
@@ -634,16 +764,20 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                             debug_log("SD2: Kael'Thas mind control not supported.");
                             //DoCast(pUnit, SPELL_MIND_CONTROL);
                         }
+
                         MindControl_Timer = 60000;
                     } else MindControl_Timer -= diff;
                 }
+
                 //Phoenix_Timer
                 if (Phoenix_Timer < diff)
                 {
                     DoCast(m_creature, SPELL_PHOENIX_ANIMATION);
                     DoScriptText(RAND(SAY_SUMMON_PHOENIX1,SAY_SUMMON_PHOENIX2), m_creature);
+
                     Phoenix_Timer = 60000;
                 } else Phoenix_Timer -= diff;
+
                 //Phase 4 specific spells
                 if (Phase == 4)
                 {
@@ -653,16 +787,20 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                             m_pInstance->SetData(DATA_KAELTHASEVENT, 4);
                         Phase = 5;
                         Phase_Timer = 10000;
+
                         DoScriptText(SAY_PHASE5_NUTS, m_creature);
+
                         m_creature->StopMoving();
                         m_creature->GetMotionMaster()->Clear();
                         m_creature->GetMotionMaster()->MoveIdle();
                         m_creature->GetMap()->CreatureRelocation(m_creature, afGravityPos[0], afGravityPos[1], afGravityPos[2], 0);
                         m_creature->SendMonsterMove(afGravityPos[0], afGravityPos[1], afGravityPos[2], 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)
                     {
@@ -671,6 +809,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                         PyrosCasted = 0;
                         ShockBarrier_Timer = 60000;
                     }else ShockBarrier_Timer -= diff;
+
                     //Chain Pyros (3 of them max)
                     if (ChainPyros && !m_creature->IsNonMeleeSpellCasted(false))
                     {
@@ -687,21 +826,26 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                         }
                     }
                 }
+
                 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;
                         AttackStart(m_creature->getVictim());
                     } else Phase_Timer -= diff;
                 }
+
                 //Phase 5
                 if (Phase == 6)
                 {
+
                     //GravityLapse_Timer
                     if (GravityLapse_Timer < diff)
                     {
@@ -714,6 +858,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                                 m_creature->GetMotionMaster()->MoveIdle();
                                 m_creature->GetMap()->CreatureRelocation(m_creature, afGravityPos[0], afGravityPos[1], afGravityPos[2], 0);
                                 m_creature->SendMonsterMove(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0, MOVEMENTFLAG_NONE, 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)
                                 {
@@ -724,14 +869,17 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                                         DoTeleportPlayer(pUnit, afGravityPos[0], afGravityPos[1], afGravityPos[2], pUnit->GetOrientation());
                                     }
                                 }
+
                                 GravityLapse_Timer = 500;
                                 ++GravityLapse_Phase;
                                 InGravityLapse = true;
                                 ShockBarrier_Timer = 1000;
                                 NetherBeam_Timer = 5000;
                                 break;
+
                             case 1:
                                 DoScriptText(RAND(SAY_GRAVITYLAPSE1,SAY_GRAVITYLAPSE2), m_creature);
+
                                 // 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)
                                 {
@@ -739,8 +887,10 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                                     {
                                         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);
@@ -752,13 +902,16 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                                 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)
@@ -773,6 +926,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                                         pUnit->SendMessageToSet(&data, true);
                                     }
                                 }
+
                                 m_creature->RemoveAurasDueToSpell(SPELL_NETHER_VAPOR);
                                 InGravityLapse = false;
                                 GravityLapse_Timer = 60000;
@@ -781,6 +935,7 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                                 break;
                         }
                     }else GravityLapse_Timer -= diff;
+
                     if (InGravityLapse)
                     {
                         //ShockBarrier_Timer
@@ -789,58 +944,73 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
                             DoCast(m_creature, SPELL_SHOCK_BARRIER);
                             ShockBarrier_Timer = 20000;
                         } else ShockBarrier_Timer -= diff;
+
                         //NetherBeam_Timer
                         if (NetherBeam_Timer < diff)
                         {
                             if (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 TRINITY_DLL_DECL boss_thaladred_the_darkenerAI : public advisorbase_ai
 {
     boss_thaladred_the_darkenerAI(Creature* pCreature) : advisorbase_ai(pCreature) {}
+
     uint32 Gaze_Timer;
     uint32 Silence_Timer;
     uint32 PsychicBlow_Timer;
+
     void Reset()
     {
         Gaze_Timer = 100;
         Silence_Timer = 20000;
         PsychicBlow_Timer = 10000;
+
         advisorbase_ai::Reset();
     }
+
     void Aggro(Unit *who)
     {
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         if (!who || FakeDeath)
             return;
+
         DoScriptText(SAY_THALADRED_AGGRO, m_creature);
         m_creature->AddThreat(who, 5000000.0f);
     }
+
     void JustDied(Unit* pKiller)
     {
         if (m_pInstance && m_pInstance->GetData(DATA_KAELTHASEVENT) == 3)
             DoScriptText(SAY_THALADRED_DEATH, m_creature);
     }
+
     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 (!UpdateVictim())
             return;
+
         //Gaze_Timer
         if (Gaze_Timer < diff)
         {
@@ -852,71 +1022,89 @@ struct TRINITY_DLL_DECL boss_thaladred_the_darkenerAI : public advisorbase_ai
                 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 TRINITY_DLL_DECL boss_lord_sanguinarAI : public advisorbase_ai
 {
     boss_lord_sanguinarAI(Creature* pCreature) : advisorbase_ai(pCreature) {}
+
     uint32 Fear_Timer;
+
     void Reset()
     {
         Fear_Timer = 20000;
         advisorbase_ai::Reset();
     }
+
     void Aggro(Unit *who)
     {
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         if (!who || FakeDeath)
             return;
+
         DoScriptText(SAY_SANGUINAR_AGGRO, m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         if (m_pInstance && m_pInstance->GetData(DATA_KAELTHASEVENT) == 3)
             DoScriptText(SAY_SANGUINAR_DEATH, m_creature);
     }
+
     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 (!UpdateVictim())
             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 TRINITY_DLL_DECL boss_grand_astromancer_capernianAI : public advisorbase_ai
 {
     boss_grand_astromancer_capernianAI(Creature* pCreature) : advisorbase_ai(pCreature) {}
+
     uint32 Fireball_Timer;
     uint32 Conflagration_Timer;
     uint32 ArcaneExplosion_Timer;
     uint32 Yell_Timer;
     bool Yell;
+
     void Reset()
     {
         Fireball_Timer = 2000;
@@ -924,41 +1112,52 @@ struct TRINITY_DLL_DECL boss_grand_astromancer_capernianAI : public advisorbase_
         ArcaneExplosion_Timer = 5000;
         Yell_Timer = 2000;
         Yell = false;
+
         advisorbase_ai::Reset();
     }
+
     void JustDied(Unit* pKiller)
     {
         if (m_pInstance && m_pInstance->GetData(DATA_KAELTHASEVENT) == 3)
             DoScriptText(SAY_CAPERNIAN_DEATH, m_creature);
     }
+
     void AttackStart(Unit* who)
     {
         if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         if (m_creature->Attack(who, true))
         {
             m_creature->AddThreat(who, 0.0f);
             m_creature->SetInCombatWith(who);
             who->SetInCombatWith(m_creature);
+
             m_creature->GetMotionMaster()->MoveChase(who, CAPERNIAN_DISTANCE);
         }
     }
+
     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 (!UpdateVictim())
             return;
+
         //Yell_Timer
         if (!Yell)
         {
@@ -968,23 +1167,28 @@ struct TRINITY_DLL_DECL boss_grand_astromancer_capernianAI : public advisorbase_
                 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)
         {
@@ -1002,79 +1206,103 @@ struct TRINITY_DLL_DECL boss_grand_astromancer_capernianAI : public advisorbase_
                     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 TRINITY_DLL_DECL boss_master_engineer_telonicusAI : public advisorbase_ai
 {
     boss_master_engineer_telonicusAI(Creature* pCreature) : advisorbase_ai(pCreature) {}
+
     uint32 Bomb_Timer;
     uint32 RemoteToy_Timer;
+
     void Reset()
     {
         Bomb_Timer = 10000;
         RemoteToy_Timer = 5000;
+
         advisorbase_ai::Reset();
     }
+
     void JustDied(Unit* pKiller)
     {
         if (m_pInstance && m_pInstance->GetData(DATA_KAELTHASEVENT) == 3)
             DoScriptText(SAY_TELONICUS_DEATH, m_creature);
     }
+
     void Aggro(Unit *who)
     {
         if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
             return;
+
         if (!who || FakeDeath)
             return;
+
         DoScriptText(SAY_TELONICUS_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 diff)
     {
         advisorbase_ai::UpdateAI(diff);
+
         //Faking Death, do nothing
         if (FakeDeath)
             return;
+
         //Return since we have no target
         if (!UpdateVictim())
             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)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(target, SPELL_REMOTE_TOY);
+
             RemoteToy_Timer = 10000+rand()%5000;
         } else RemoteToy_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Flame Strike AI
 struct TRINITY_DLL_DECL mob_kael_flamestrikeAI : public ScriptedAI
 {
     mob_kael_flamestrikeAI(Creature* pCreature) : ScriptedAI(pCreature) {}
+
     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 MoveInLineOfSight(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!Casting)
@@ -1082,6 +1310,7 @@ struct TRINITY_DLL_DECL mob_kael_flamestrikeAI : public ScriptedAI
             DoCast(m_creature, SPELL_FLAME_STRIKE_VIS);
             Casting = true;
         }
+
         //Timer
         if (Timer < diff)
         {
@@ -1090,31 +1319,38 @@ struct TRINITY_DLL_DECL mob_kael_flamestrikeAI : public ScriptedAI
                 m_creature->InterruptNonMeleeSpells(false);
                 DoCast(m_creature, SPELL_FLAME_STRIKE_DMG);
             } else m_creature->Kill(m_creature);
+
             KillSelf = true;
             Timer = 1000;
         } else Timer -= diff;
     }
 };
+
 //Phoenix AI
 struct TRINITY_DLL_DECL mob_phoenix_tkAI : public ScriptedAI
 {
     mob_phoenix_tkAI(Creature* pCreature) : ScriptedAI(pCreature) {}
+
     uint32 Cycle_Timer;
+
     void Reset()
     {
         Cycle_Timer = 2000;
         m_creature->CastSpell(m_creature,SPELL_BURN,true);
     }
+
     void JustDied(Unit* killer)
     {
         //is this spell in use anylonger?
         //m_creature->CastSpell(m_creature,SPELL_EMBER_BLAST,true);
         m_creature->SummonCreature(NPC_PHOENIX_EGG,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),m_creature->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,16000);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (Cycle_Timer < diff)
         {
             //spell Burn should possible do this, but it doesn't, so do this for now.
@@ -1123,38 +1359,48 @@ struct TRINITY_DLL_DECL mob_phoenix_tkAI : public ScriptedAI
                 m_creature->SetHealth(uint32(m_creature->GetHealth()-dmg));
             Cycle_Timer = 2000;
         } else Cycle_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 //Phoenix Egg AI
 struct TRINITY_DLL_DECL mob_phoenix_egg_tkAI : public ScriptedAI
 {
     mob_phoenix_egg_tkAI(Creature* pCreature) : ScriptedAI(pCreature) {}
+
     uint32 Rebirth_Timer;
+
     void Reset()
     {
         Rebirth_Timer = 15000;
     }
+
     //ignore any
     void MoveInLineOfSight(Unit* who) { return; }
+
     void AttackStart(Unit* who)
     {
         if (m_creature->Attack(who, false))
         {
             m_creature->SetInCombatWith(who);
             who->SetInCombatWith(m_creature);
+
             DoStartNoMovement(who);
         }
     }
+
     void JustSummoned(Creature* summoned)
     {
         summoned->AddThreat(m_creature->getVictim(), 0.0f);
         summoned->CastSpell(summoned,SPELL_REBIRTH,false);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!Rebirth_Timer)
             return;
+
         if (Rebirth_Timer <= diff)
         {
             m_creature->SummonCreature(NPC_PHOENIX,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),m_creature->GetOrientation(),TEMPSUMMON_CORPSE_DESPAWN,5000);
@@ -1162,38 +1408,47 @@ struct TRINITY_DLL_DECL mob_phoenix_egg_tkAI : public ScriptedAI
         } else Rebirth_Timer -= diff;
     }
 };
+
 CreatureAI* GetAI_boss_kaelthas(Creature* pCreature)
 {
     return new boss_kaelthasAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_thaladred_the_darkener(Creature* pCreature)
 {
     return new boss_thaladred_the_darkenerAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_lord_sanguinar(Creature* pCreature)
 {
     return new boss_lord_sanguinarAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_grand_astromancer_capernian(Creature* pCreature)
 {
     return new boss_grand_astromancer_capernianAI(pCreature);
 }
+
 CreatureAI* GetAI_boss_master_engineer_telonicus(Creature* pCreature)
 {
     return new boss_master_engineer_telonicusAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_kael_flamestrike(Creature* pCreature)
 {
     return new mob_kael_flamestrikeAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_phoenix_tk(Creature* pCreature)
 {
     return new mob_phoenix_tkAI(pCreature);
 }
+
 CreatureAI* GetAI_mob_phoenix_egg_tk(Creature* pCreature)
 {
     return new mob_phoenix_egg_tkAI(pCreature);
 }
+
 void AddSC_boss_kaelthas()
 {
     Script *newscript;
@@ -1201,30 +1456,37 @@ void AddSC_boss_kaelthas()
     newscript->Name = "boss_kaelthas";
     newscript->GetAI = &GetAI_boss_kaelthas;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_thaladred_the_darkener";
     newscript->GetAI = &GetAI_boss_thaladred_the_darkener;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_lord_sanguinar";
     newscript->GetAI = &GetAI_boss_lord_sanguinar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_grand_astromancer_capernian";
     newscript->GetAI = &GetAI_boss_grand_astromancer_capernian;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_master_engineer_telonicus";
     newscript->GetAI = &GetAI_boss_master_engineer_telonicus;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_kael_flamestrike";
     newscript->GetAI = &GetAI_mob_kael_flamestrike;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_phoenix_tk";
     newscript->GetAI = &GetAI_mob_phoenix_tk;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_phoenix_egg_tk";
     newscript->GetAI = &GetAI_mob_phoenix_egg_tk;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_void_reaver.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_void_reaver.cpp
index afd513b4a30..c1de7772120 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_void_reaver.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/boss_void_reaver.cpp
@@ -13,14 +13,17 @@
  * along with 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: 90
 SDComment: Should reset if raid are out of room.
 SDCategory: Tempest Keep, The Eye
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_the_eye.h"
+
 enum eEnums
 {
     SAY_AGGRO                   = -1550000,
@@ -30,111 +33,141 @@ enum eEnums
     SAY_DEATH                   = -1550004,
     SAY_POUNDING1               = -1550005,
     SAY_POUNDING2               = -1550006,
+
     SPELL_POUNDING              = 34162,
     SPELL_ARCANE_ORB            = 34172,
     SPELL_KNOCK_AWAY            = 25778,
     SPELL_BERSERK               = 27680
 };
+
 struct TRINITY_DLL_DECL boss_void_reaverAI : public ScriptedAI
 {
     boss_void_reaverAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();
     }
+
     ScriptedInstance* pInstance;
+
     uint32 Pounding_Timer;
     uint32 ArcaneOrb_Timer;
     uint32 KnockAway_Timer;
     uint32 Berserk_Timer;
+
     bool Enraged;
+
     void Reset()
     {
         Pounding_Timer = 15000;
         ArcaneOrb_Timer = 3000;
         KnockAway_Timer = 30000;
         Berserk_Timer = 600000;
+
         Enraged = false;
+
         if (pInstance && m_creature->isAlive())
             pInstance->SetData(DATA_VOIDREAVEREVENT, NOT_STARTED);
     }
+
     void KilledUnit(Unit *victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature);
     }
+
     void JustDied(Unit *victim)
     {
         DoScriptText(SAY_DEATH, m_creature);
         DoZoneInCombat();
+
         if (pInstance)
             pInstance->SetData(DATA_VOIDREAVEREVENT, DONE);
     }
+
     void EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_VOIDREAVEREVENT, IN_PROGRESS);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         // Pounding
         if (Pounding_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_POUNDING);
+
             DoScriptText(RAND(SAY_POUNDING1,SAY_POUNDING2), m_creature);
              Pounding_Timer = 15000;                         //cast time(3000) + cooldown time(12000)
         }else Pounding_Timer -= diff;
+
         // Arcane Orb
         if (ArcaneOrb_Timer < diff)
         {
             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)
+            for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
             {
                 target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                 if (!target)
                     continue;
+
                 // exclude pets & totems
                 if (target->GetTypeId() != TYPEID_PLAYER)
                     continue;
+
                 //18 yard radius minimum
                 if (target && target->GetTypeId() == TYPEID_PLAYER && target->isAlive() && !target->IsWithinDist(m_creature, 18, false))
                     target_list.push_back(target);
                 target = NULL;
             }
+
             if (target_list.size())
                 target = *(target_list.begin()+rand()%target_list.size());
             else
                 target = m_creature->getVictim();
+
             if (target)
                 m_creature->CastSpell(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), SPELL_ARCANE_ORB, false, NULL, NULL, NULL, target);
+
             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 (DoGetThreat(m_creature->getVictim()))
                 DoModifyThreatPercent(m_creature->getVictim(),-25);
+
             KnockAway_Timer = 30000;
         }else KnockAway_Timer -= diff;
+
         //Berserk
         if (Berserk_Timer < diff && !Enraged)
         {
             DoCast(m_creature,SPELL_BERSERK);
             Enraged = true;
         }else Berserk_Timer -= diff;
+
         DoMeleeAttackIfReady();
+
         EnterEvadeIfOutOfCombatArea(diff);
     }
 };
+
 CreatureAI* GetAI_boss_void_reaver(Creature* pCreature)
 {
     return new boss_void_reaverAI (pCreature);
 }
+
 void AddSC_boss_void_reaver()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/def_the_eye.h b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/def_the_eye.h
index 3fe81530bc4..d0d3ea09061 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/def_the_eye.h
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/def_the_eye.h
@@ -1,8 +1,10 @@
 /* Copyright (C) 2006 - 2009 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
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/instance_the_eye.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/instance_the_eye.cpp
index 79183547c50..f973f96c1ff 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/instance_the_eye.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/instance_the_eye.cpp
@@ -13,24 +13,30 @@
  * along 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 MAX_ENCOUNTER 5
+
 /* The Eye encounters:
 0 - Kael'thas event
 1 - Al' ar event
 2 - Solarian Event
 3 - Void Reaver event
 */
+
 struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
 {
     instance_the_eye(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
+
     uint64 ThaladredTheDarkener;
     uint64 LordSanguinar;
     uint64 GrandAstromancerCapernian;
@@ -38,12 +44,16 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
     uint64 Kaelthas;
     uint64 Astromancer;
     uint64 Alar;
+
     uint8 KaelthasEventPhase;
     uint8 AlarEventPhase;
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
+
         ThaladredTheDarkener = 0;
         LordSanguinar = 0;
         GrandAstromancerCapernian = 0;
@@ -51,15 +61,19 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
         Kaelthas = 0;
         Astromancer = 0;
         Alar = 0;
+
         KaelthasEventPhase = 0;
         AlarEventPhase = 0;
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS) return true;
+
         return false;
     }
+
     void OnCreatureCreate(Creature* pCreature, bool add)
     {
         switch(pCreature->GetEntry())
@@ -73,6 +87,7 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
             case 19514: Alar = pCreature->GetGUID(); break;
         }
     }
+
     uint64 GetData64(uint32 identifier)
     {
         switch(identifier)
@@ -87,6 +102,7 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
         }
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -99,6 +115,7 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
         if (data == DONE)
             SaveToDB();
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
@@ -110,6 +127,7 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
         }
         return 0;
     }
+
     std::string GetSaveData()
     {
         OUT_SAVE_INST_DATA;
@@ -124,6 +142,7 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
         }
         return NULL;
     }
+
     void Load(const char* in)
     {
         if (!in)
@@ -134,16 +153,18 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
         OUT_LOAD_INST_DATA(in);
         std::istringstream stream(in);
         stream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3];
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)                // Do not load an encounter as "In Progress" - reset it instead.
                 m_auiEncounter[i] = NOT_STARTED;
         OUT_LOAD_INST_DATA_COMPLETE;
     }
 };
+
 InstanceData* GetInstanceData_instance_the_eye(Map* pMap)
 {
     return new instance_the_eye(pMap);
 }
+
 void AddSC_instance_the_eye()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/the_eye.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/the_eye.cpp
index e39457fedf5..a7e47718017 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/the_eye.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_eye/the_eye.cpp
@@ -13,63 +13,81 @@
  * along 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 TRINITY_DLL_DECL mob_crystalcore_devastatorAI : public ScriptedAI
 {
     mob_crystalcore_devastatorAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 Knockaway_Timer;
     uint32 Countercharge_Timer;
+
     void Reset()
     {
         Countercharge_Timer = 9000;
         Knockaway_Timer = 25000;
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new mob_crystalcore_devastatorAI (pCreature);
 }
+
 void AddSC_the_eye()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp
index 16b3e443769..90f17e299b7 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp
@@ -13,13 +13,16 @@
  * along with 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"
+
 //not used
 #define SAY_AGGRO                       -1554000
 #define SAY_SAW_ATTACK1                 -1554001
@@ -27,6 +30,7 @@ EndScriptData */
 #define SAY_SLAY1                       -1554003
 #define SAY_SLAY2                       -1554004
 #define SAY_DEATH                       -1554005
+
 #define SPELL_STREAM_OF_MACHINE_FLUID   35311
 #define SPELL_SAW_BLADE                 35318
 #define H_SPELL_SAW_BLADE               39192
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp
index 66e1580f3d8..946108a72f0 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp
@@ -13,13 +13,16 @@
 * along with 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: 75
 SDComment:
 SDCategory: Tempest Keep, The Mechanar
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SAY_AGGRO_1                     -1554006
 #define SAY_HAMMER_1                    -1554007
 #define SAY_HAMMER_2                    -1554008
@@ -27,6 +30,7 @@ EndScriptData */
 #define SAY_SLAY_2                      -1554010
 #define SAY_DEATH_1                     -1554011
 #define EMOTE_HAMMER                    -1554012
+
 // Spells to be casted
 #define SPELL_SHADOW_POWER              35322
 #define H_SPELL_SHADOW_POWER            39193
@@ -34,6 +38,7 @@ EndScriptData */
 #define SPELL_JACKHAMMER                35327
 #define H_SPELL_JACKHAMMER              39194
 #define SPELL_STREAM_OF_MACHINE_FLUID   35311
+
 // Gatewatcher Iron-Hand AI
 struct TRINITY_DLL_DECL boss_gatewatcher_iron_handAI : public ScriptedAI
 {
@@ -41,60 +46,74 @@ struct TRINITY_DLL_DECL boss_gatewatcher_iron_handAI : public ScriptedAI
     {
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     bool HeroicMode;
+
     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 EnterCombat(Unit *who)
     {
         DoScriptText(SAY_AGGRO_1, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         if (rand()%2)
             return;
+
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH_1, m_creature);
         //TODO: Add door check/open code
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Shadow Power
         if (Shadow_Power_Timer < diff)
         {
             DoCast(m_creature,HEROIC(SPELL_SHADOW_POWER, H_SPELL_SHADOW_POWER));
             Shadow_Power_Timer = 20000 + rand()%8000;
         }else Shadow_Power_Timer -= diff;
+
         //Jack Hammer
         if (Jackhammer_Timer < diff)
         {
             //TODO: expect cast this about 5 times in a row (?), announce it by emote only once
             DoScriptText(EMOTE_HAMMER, m_creature);
             DoCast(m_creature->getVictim(),HEROIC(SPELL_JACKHAMMER, H_SPELL_JACKHAMMER));
+
             //chance to yell, but not same time as emote (after spell in fact casted)
             if (rand()%2)
                 return;
+
             DoScriptText(RAND(SAY_HAMMER_1,SAY_HAMMER_2), m_creature);
             Jackhammer_Timer = 30000;
         }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 = 35000 + rand()%15000;
         }else Stream_of_Machine_Fluid_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
@@ -102,6 +121,7 @@ CreatureAI* GetAI_boss_gatewatcher_iron_hand(Creature* pCreature)
 {
     return new boss_gatewatcher_iron_handAI (pCreature);
 }
+
 void AddSC_boss_gatewatcher_iron_hand()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp
index e7d861dbee7..aef118ff42f 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp
@@ -13,14 +13,17 @@
 * along with 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: 90
 SDComment: Need adjustments to initial summons
 SDCategory: Tempest Keep, The Mechanar
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_mechanar.h"
+
 #define SAY_AGGRO                       -1554013
 #define SAY_SUMMON                      -1554014
 #define SAY_DRAGONS_BREATH_1            -1554015
@@ -28,13 +31,16 @@ EndScriptData */
 #define SAY_SLAY1                       -1554017
 #define SAY_SLAY2                       -1554018
 #define SAY_DEATH                       -1554019
+
 #define SPELL_SUMMON_RAGIN_FLAMES       35275
 #define H_SPELL_SUMMON_RAGIN_FLAMES     39084
+
 #define SPELL_FROST_ATTACK              35263
 #define SPELL_ARCANE_BLAST              35314
 #define SPELL_DRAGONS_BREATH            35250
 #define SPELL_KNOCKBACK                 37317
 #define SPELL_SOLARBURN                 35267
+
 struct TRINITY_DLL_DECL boss_nethermancer_sepethreaAI : public ScriptedAI
 {
     boss_nethermancer_sepethreaAI(Creature *c) : ScriptedAI(c)
@@ -42,13 +48,17 @@ struct TRINITY_DLL_DECL boss_nethermancer_sepethreaAI : public ScriptedAI
         pInstance = c->GetInstanceData();
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     ScriptedInstance *pInstance;
+
     bool HeroicMode;
+
     uint32 frost_attack_Timer;
     uint32 arcane_blast_Timer;
     uint32 dragons_breath_Timer;
     uint32 knockback_Timer;
     uint32 solarburn_Timer;
+
     void Reset()
     {
         frost_attack_Timer = 7000 + rand()%3000;
@@ -56,44 +66,54 @@ struct TRINITY_DLL_DECL boss_nethermancer_sepethreaAI : public ScriptedAI
         dragons_breath_Timer = 18000 + rand()%4000;
         knockback_Timer = 22000 + rand()%6000;
         solarburn_Timer = 30000;
+
         if (pInstance)
             pInstance->SetData(DATA_NETHERMANCER_EVENT, NOT_STARTED);
     }
+
     void EnterCombat(Unit *who)
     {
         if (pInstance)
             pInstance->SetData(DATA_NETHERMANCER_EVENT, IN_PROGRESS);
+
         DoScriptText(SAY_AGGRO, m_creature);
         DoCast(who, HEROIC(SPELL_SUMMON_RAGIN_FLAMES, H_SPELL_SUMMON_RAGIN_FLAMES));
         DoScriptText(SAY_SUMMON, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         if (pInstance)
             pInstance->SetData(DATA_NETHERMANCER_EVENT, DONE);
     }
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Frost Attack
         if (frost_attack_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_FROST_ATTACK);
             frost_attack_Timer = 7000 + rand()%3000;
         }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)
         {
@@ -101,44 +121,56 @@ struct TRINITY_DLL_DECL boss_nethermancer_sepethreaAI : public ScriptedAI
             {
                 if (rand()%2)
                     return;
+
                 DoScriptText(RAND(SAY_DRAGONS_BREATH_1,SAY_DRAGONS_BREATH_2), m_creature);
             }
             dragons_breath_Timer = 12000 + rand()%10000;
         }else dragons_breath_Timer -= diff;
+
         //Knockback
         if (knockback_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_KNOCKBACK);
             knockback_Timer = 15000 + rand()%10000;
         }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* pCreature)
 {
     return new boss_nethermancer_sepethreaAI (pCreature);
 }
+
 #define SPELL_INFERNO                   35268
 #define H_SPELL_INFERNO                 39346
 #define SPELL_FIRE_TAIL                 35278
+
 struct TRINITY_DLL_DECL mob_ragin_flamesAI : public ScriptedAI
 {
     mob_ragin_flamesAI(Creature *c) : ScriptedAI(c)
     {
         pInstance = c->GetInstanceData();        HeroicMode = m_creature->GetMap()->IsHeroic();
     }
+
     ScriptedInstance *pInstance;
+
     bool HeroicMode;
+
     uint32 inferno_Timer;
     uint32 flame_timer;
     uint32 Check_Timer;
+
     bool onlyonce;
+
     void Reset()
     {
         inferno_Timer = 10000;
@@ -149,9 +181,11 @@ struct TRINITY_DLL_DECL mob_ragin_flamesAI : public ScriptedAI
         m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, true);
         m_creature->SetSpeed(MOVE_RUN, HeroicMode ? 0.7f : 0.5f);
     }
+
     void EnterCombat(Unit* who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
          //Check_Timer
@@ -168,27 +202,33 @@ struct TRINITY_DLL_DECL mob_ragin_flamesAI : public ScriptedAI
             }
             Check_Timer = 1000;
         }else Check_Timer -= diff;
+
         if (!UpdateVictim())
             return;
+
         if (!onlyonce)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                 m_creature->GetMotionMaster()->MoveChase(target);
             onlyonce = true;
         }
+
         if (inferno_Timer < diff)
         {
             DoCast(m_creature->getVictim(),HEROIC(SPELL_INFERNO, H_SPELL_INFERNO));
             m_creature->TauntApply(m_creature->getVictim());
             inferno_Timer = 10000;
         }else inferno_Timer -= diff;
+
         if (flame_timer < diff)
         {
             DoCast(m_creature,SPELL_FIRE_TAIL);
             flame_timer = 500;
         }else flame_timer -=diff;
+
         DoMeleeAttackIfReady();
     }
+
 };
 CreatureAI* GetAI_mob_ragin_flames(Creature* pCreature)
 {
@@ -201,6 +241,7 @@ void AddSC_boss_nethermancer_sepethrea()
     newscript->Name = "boss_nethermancer_sepethrea";
     newscript->GetAI = &GetAI_boss_nethermancer_sepethrea;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_ragin_flames";
     newscript->GetAI = &GetAI_mob_ragin_flames;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp
index 077cb0e0ecc..02e44616b52 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp
@@ -13,13 +13,16 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 /* ScriptData
 SDName: Boss Pathaleon the Calculator
 SD%Complete: 50
 SDComment: Event missing. Script for himself 99% blizzlike.
 SDCategory: Tempest Keep, The Mechanar
 EndScriptData */
+
 #include "precompiled.h"
+
 #define SAY_AGGRO                       -1554020
 #define SAY_DOMINATION_1                -1554021
 #define SAY_DOMINATION_2                -1554022
@@ -28,25 +31,30 @@ EndScriptData */
 #define SAY_SLAY_1                      -1554025
 #define SAY_SLAY_2                      -1554026
 #define SAY_DEATH                       -1554027
+
 // Spells to be casted
 #define SPELL_MANA_TAP                36021
 #define SPELL_ARCANE_TORRENT          36022
 #define SPELL_DOMINATION              35280
 #define H_SPELL_ARCANE_EXPLOSION        15453
 #define SPELL_FRENZY                    36992
+
 #define SPELL_SUMMON_NETHER_WRAITH_1    35285               //Spells work, but not implemented
 #define SPELL_SUMMON_NETHER_WRAITH_2    35286
 #define SPELL_SUMMON_NETHER_WRAITH_3    35287
 #define SPELL_SUMMON_NETHER_WRAITH_4    35288
+
 // Add Spells
 #define SPELL_DETONATION              35058
 #define SPELL_ARCANE_MISSILES         35034
+
 struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI
 {
     boss_pathaleon_the_calculatorAI(Creature *c) : ScriptedAI(c), summons(m_creature)
     {
         HeroicMode = c->GetMap()->IsHeroic();
     }
+
     uint32 Summon_Timer;
     SummonList summons;
     uint32 ManaTap_Timer;
@@ -55,7 +63,9 @@ struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI
     uint32 ArcaneExplosion_Timer;
     bool HeroicMode;
     bool Enraged;
+
     uint32 Counter;
+
     void Reset()
     {
         Summon_Timer = 30000;
@@ -63,7 +73,9 @@ struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI
         ArcaneTorrent_Timer = 16000 + rand()%9000;
         Domination_Timer = 25000 + rand()%15000;
         ArcaneExplosion_Timer = 8000 + rand()%5000;
+
         Enraged = false;
+
         Counter = 0;
         summons.DespawnAll();
     }
@@ -71,25 +83,31 @@ struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void KilledUnit(Unit* victim)
     {
         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
     }
+
     void JustDied(Unit* Killer)
     {
         DoScriptText(SAY_DEATH, m_creature);
+
         summons.DespawnAll();
     }
+
     void JustSummoned(Creature *summon) {summons.Summon(summon);}
     void SummonedCreatureDespawn(Creature *summon) {summons.Despawn(summon);}
+
     void UpdateAI(const uint32 diff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         if (Summon_Timer < diff)
         {
-            for (uint8 i = 0; i < 3; ++i)
+            for(uint8 i = 0; i < 3; ++i)
             {
                 Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
                 Creature* Wraith = m_creature->SummonCreature(21062,m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
@@ -99,25 +117,30 @@ struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI
             DoScriptText(SAY_SUMMON, m_creature);
             Summon_Timer = 30000 + rand()%15000;
         }else Summon_Timer -= diff;
+
         if (ManaTap_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_MANA_TAP);
             ManaTap_Timer = 14000 + rand()%8000;
         }else ManaTap_Timer -= diff;
+
         if (ArcaneTorrent_Timer < diff)
         {
             DoCast(m_creature->getVictim(),SPELL_ARCANE_TORRENT);
             ArcaneTorrent_Timer = 12000 + rand()%6000;
         }else ArcaneTorrent_Timer -= diff;
+
         if (Domination_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1))
             {
                 DoScriptText(RAND(SAY_DOMINATION_1,SAY_DOMINATION_2), m_creature);
+
                 DoCast(target,SPELL_DOMINATION);
             }
                 Domination_Timer = 25000 + rand()%5000;
             }else Domination_Timer -= diff;
+
         //Only casting if Heroic Mode is used
         if (HeroicMode)
         {
@@ -127,12 +150,15 @@ struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI
                 ArcaneExplosion_Timer = 10000 + rand()%4000;
             }else ArcaneExplosion_Timer -= diff;
         }
+
         if (!Enraged && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21)
         {
             DoCast(m_creature, SPELL_FRENZY);
             DoScriptText(SAY_ENRAGE, m_creature);
             Enraged = true;
+
         }
+
         DoMeleeAttackIfReady();
     }
 };
@@ -140,35 +166,44 @@ CreatureAI* GetAI_boss_pathaleon_the_calculator(Creature* pCreature)
 {
     return new boss_pathaleon_the_calculatorAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL mob_nether_wraithAI : public ScriptedAI
 {
     mob_nether_wraithAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ArcaneMissiles_Timer;
     uint32 Detonation_Timer;
     uint32 Die_Timer;
     bool Detonation;
+
     void Reset()
     {
         ArcaneMissiles_Timer = 1000 + rand()%3000;
         Detonation_Timer = 20000;
         Die_Timer = 2200;
         Detonation = false;
+
     }
+
     void EnterCombat(Unit* who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (ArcaneMissiles_Timer < diff)
         {
             if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1))
                 DoCast(target,SPELL_ARCANE_MISSILES);
             else
                 DoCast(m_creature->getVictim(),SPELL_ARCANE_MISSILES);
+
             ArcaneMissiles_Timer = 5000 + rand()%5000;
         }else ArcaneMissiles_Timer -=diff;
+
         if (!Detonation)
         {
             if (Detonation_Timer < diff)
@@ -177,6 +212,7 @@ struct TRINITY_DLL_DECL mob_nether_wraithAI : public ScriptedAI
                 Detonation = true;
             }else Detonation_Timer -= diff;
         }
+
         if (Detonation)
         {
             if (Die_Timer < diff)
@@ -185,13 +221,16 @@ struct TRINITY_DLL_DECL mob_nether_wraithAI : public ScriptedAI
                 m_creature->RemoveCorpse();
             }else Die_Timer -= diff;
         }
+
         DoMeleeAttackIfReady();
     }
+
 };
 CreatureAI* GetAI_mob_nether_wraith(Creature* pCreature)
 {
     return new mob_nether_wraithAI (pCreature);
 }
+
 void AddSC_boss_pathaleon_the_calculator()
 {
     Script *newscript;
@@ -199,6 +238,7 @@ void AddSC_boss_pathaleon_the_calculator()
     newscript->Name = "boss_pathaleon_the_calculator";
     newscript->GetAI = &GetAI_boss_pathaleon_the_calculator;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_nether_wraith";
     newscript->GetAI = &GetAI_mob_nether_wraith;
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/def_mechanar.h b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/def_mechanar.h
index 97c756d0fef..d1b53eebf53 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/def_mechanar.h
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/def_mechanar.h
@@ -1,5 +1,6 @@
 #ifndef DEF_MECHANAR_H
 #define DEF_MECHANAR_H
+
 #define DATA_NETHERMANCER_EVENT 1
 #endif
 
diff --git a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/instance_mechanar.cpp b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/instance_mechanar.cpp
index c4d36178e0f..e43190620d9 100644
--- a/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/instance_mechanar.cpp
+++ b/src/bindings/scripts/scripts/outland/tempest_keep/the_mechanar/instance_mechanar.cpp
@@ -13,43 +13,55 @@
  * along 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_Mechanar
 SD%Complete: 100
 SDComment:
 SDCategory: Mechanar
 EndScriptData */
+
 #include "precompiled.h"
 #include "def_mechanar.h"
+
 #define MAX_ENCOUNTER      1
+
 struct TRINITY_DLL_DECL instance_mechanar : public ScriptedInstance
 {
     instance_mechanar(Map* pMap) : ScriptedInstance(pMap) {Initialize();};
 
+
     uint32 m_auiEncounter[MAX_ENCOUNTER];
+
     void Initialize()
     {
         memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
     }
+
     bool IsEncounterInProgress() const
     {
-        for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
+        for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
             if (m_auiEncounter[i] == IN_PROGRESS)
                 return true;
+
         return false;
     }
+
     uint32 GetData(uint32 type)
     {
         switch(type)
         {
         case DATA_NETHERMANCER_EVENT:   return m_auiEncounter[0];
         }
+
         return false;
     }
+
     uint64 GetData64 (uint32 identifier)
     {
         return 0;
     }
+
     void SetData(uint32 type, uint32 data)
     {
         switch(type)
@@ -58,10 +70,12 @@ struct TRINITY_DLL_DECL instance_mechanar : public ScriptedInstance
         }
     }
 };
+
 InstanceData* GetInstanceData_instance_mechanar(Map* pMap)
 {
     return new instance_mechanar(pMap);
 }
+
 void AddSC_instance_mechanar()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/outland/terokkar_forest.cpp b/src/bindings/scripts/scripts/outland/terokkar_forest.cpp
index 0474b5f5de9..76776234d98 100644
--- a/src/bindings/scripts/scripts/outland/terokkar_forest.cpp
+++ b/src/bindings/scripts/scripts/outland/terokkar_forest.cpp
@@ -13,12 +13,14 @@
  * along 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: 85
 SDComment: Quest support: 9889, 10009, 10873, 10896, 10898, 11096, 10052, 10051. Skettis->Ogri'la Flight
 SDCategory: Terokkar Forest
 EndScriptData */
+
 /* ContentData
 mob_unkor_the_ruthless
 mob_infested_root_walker
@@ -28,23 +30,31 @@ npc_floon
 npc_isla_starmane
 npc_slim
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
+
 /*######
 ## mob_unkor_the_ruthless
 ######*/
+
 #define SAY_SUBMIT                      -1000351
+
 #define FACTION_HOSTILE                 45
 #define FACTION_FRIENDLY                35
 #define QUEST_DONTKILLTHEFATONE         9889
+
 #define SPELL_PULVERIZE                 2676
 //#define SPELL_QUID9889                32174
+
 struct TRINITY_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI
 {
     mob_unkor_the_ruthlessAI(Creature* c) : ScriptedAI(c) {}
+
     bool CanDoQuest;
     uint32 UnkorUnfriendly_Timer;
     uint32 Pulverize_Timer;
+
     void Reset()
     {
         CanDoQuest = false;
@@ -53,7 +63,9 @@ struct TRINITY_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI
         m_creature->SetStandState(UNIT_STAND_STATE_STAND);
         m_creature->setFaction(FACTION_HOSTILE);
     }
+
     void EnterCombat(Unit *who) {}
+
     void DoNice()
     {
         DoScriptText(SAY_SUBMIT, m_creature);
@@ -64,6 +76,7 @@ struct TRINITY_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI
         m_creature->CombatStop(true);
         UnkorUnfriendly_Timer = 60000;
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by->GetTypeId() == TYPEID_PLAYER)
@@ -71,7 +84,7 @@ struct TRINITY_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI
         {
             if (Group* pGroup = CAST_PLR(done_by)->GetGroup())
             {
-                for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
+                for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
                 {
                     Player *pGroupie = itr->getSource();
                     if (pGroupie &&
@@ -92,6 +105,7 @@ struct TRINITY_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (CanDoQuest)
@@ -110,28 +124,36 @@ struct TRINITY_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI
                 }else UnkorUnfriendly_Timer -= diff;
             }
         }
+
         if (!UpdateVictim())
             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* pCreature)
 {
     return new mob_unkor_the_ruthlessAI (pCreature);
 }
+
 /*######
 ## mob_infested_root_walker
 ######*/
+
 struct TRINITY_DLL_DECL mob_infested_root_walkerAI : public ScriptedAI
 {
     mob_infested_root_walkerAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() { }
     void EnterCombat(Unit *who) { }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by && done_by->GetTypeId() == TYPEID_PLAYER)
@@ -146,6 +168,7 @@ CreatureAI* GetAI_mob_infested_root_walker(Creature* pCreature)
     return new mob_infested_root_walkerAI (pCreature);
 }
 
+
 /*######
 ## mob_skywing
 ######*/
@@ -153,11 +176,13 @@ struct TRINITY_DLL_DECL npc_skywingAI : public npc_escortAI
 {
 public:
     npc_skywingAI(Creature *c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
         if (!pPlayer)
             return;
+
         switch(i)
         {
             case 8:
@@ -165,11 +190,14 @@ public:
                 break;
         }
     }
+
     void EnterCombat(Unit* who) {}
+
     void MoveInLineOfSight(Unit *who)
     {
         if (HasEscortState(STATE_ESCORT_ESCORTING))
             return;
+
         if (who->GetTypeId() == TYPEID_PLAYER)
         {
             if (CAST_PLR(who)->GetQuestStatus(10898) == QUEST_STATUS_INCOMPLETE)
@@ -182,24 +210,31 @@ public:
             }
         }
     }
+
     void Reset() {}
+
     void UpdateAI(const uint32 diff)
     {
         npc_escortAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_npc_skywingAI(Creature* pCreature)
 {
     return new npc_skywingAI(pCreature);
 }
+
 /*######
 ## mob_rotting_forest_rager
 ######*/
+
 struct TRINITY_DLL_DECL mob_rotting_forest_ragerAI : public ScriptedAI
 {
     mob_rotting_forest_ragerAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() { }
     void EnterCombat(Unit *who) { }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         if (done_by->GetTypeId() == TYPEID_PLAYER)
@@ -213,11 +248,14 @@ CreatureAI* GetAI_mob_rotting_forest_rager(Creature* pCreature)
 {
     return new mob_rotting_forest_ragerAI (pCreature);
 }
+
 /*######
 ## mob_netherweb_victim
 ######*/
+
 #define QUEST_TARGET        22459
 //#define SPELL_FREE_WEBBED   38950
+
 const uint32 netherwebVictims[6] =
 {
     18470, 16805, 21242, 18452, 22482, 21285
@@ -225,9 +263,11 @@ const uint32 netherwebVictims[6] =
 struct TRINITY_DLL_DECL mob_netherweb_victimAI : public ScriptedAI
 {
     mob_netherweb_victimAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() { }
     void EnterCombat(Unit *who) { }
     void MoveInLineOfSight(Unit *who) { }
+
     void JustDied(Unit* Killer)
     {
         if (Killer->GetTypeId() == TYPEID_PLAYER)
@@ -241,6 +281,7 @@ struct TRINITY_DLL_DECL mob_netherweb_victimAI : public ScriptedAI
                 }
                 else
                     m_creature->SummonCreature(netherwebVictims[rand()%6], 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
+
                 if (rand()%100 < 75)
                     m_creature->SummonCreature(netherwebVictims[rand()%6], 0.0f, 0.0f, 0.0f,0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                 m_creature->SummonCreature(netherwebVictims[rand()%6], 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
@@ -252,30 +293,38 @@ CreatureAI* GetAI_mob_netherweb_victim(Creature* pCreature)
 {
     return new mob_netherweb_victimAI (pCreature);
 }
+
 /*######
 ## 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!"
+
 enum eFloon
 {
     SAY_FLOON_ATTACK        = -1000352,
+
     SPELL_SILENCE           = 6726,
     SPELL_FROSTBOLT         = 9672,
     SPELL_FROST_NOVA        = 11831,
+
     FACTION_HOSTILE_FL      = 1738,
     QUEST_CRACK_SKULLS      = 10009
 };
+
 struct TRINITY_DLL_DECL npc_floonAI : public ScriptedAI
 {
     npc_floonAI(Creature* c) : ScriptedAI(c)
     {
         m_uiNormFaction = c->getFaction();
     }
+
     uint32 m_uiNormFaction;
     uint32 Silence_Timer;
     uint32 Frostbolt_Timer;
     uint32 FrostNova_Timer;
+
     void Reset()
     {
         Silence_Timer = 2000;
@@ -284,40 +333,50 @@ struct TRINITY_DLL_DECL npc_floonAI : public ScriptedAI
         if (m_creature->getFaction() != m_uiNormFaction)
             m_creature->setFaction(m_uiNormFaction);
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new npc_floonAI (pCreature);
 }
+
 bool GossipHello_npc_floon(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_CRACK_SKULLS) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_FLOON1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(9442, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_floon(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
@@ -334,25 +393,32 @@ bool GossipSelect_npc_floon(Player* pPlayer, Creature* pCreature, uint32 uiSende
     }
     return true;
 }
+
 /*######
 ## npc_isla_starmane
 ######*/
+
 #define SAY_PROGRESS_1  -1000353
 #define SAY_PROGRESS_2  -1000354
 #define SAY_PROGRESS_3  -1000355
 #define SAY_PROGRESS_4  -1000356
+
 #define QUEST_EFTW_H    10052
 #define QUEST_EFTW_A    10051
 #define GO_CAGE         182794
 #define SPELL_CAT       32447
+
 struct TRINITY_DLL_DECL npc_isla_starmaneAI : public npc_escortAI
 {
     npc_isla_starmaneAI(Creature* c) : npc_escortAI(c) {}
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
         case 0:
@@ -378,10 +444,12 @@ struct TRINITY_DLL_DECL npc_isla_starmaneAI : public npc_escortAI
             m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); break;
         }
     }
+
     void Reset()
     {
         me->RestoreFaction();
     }
+
     void JustDied(Unit* killer)
     {
         if (Player* pPlayer = GetPlayerForEscort())
@@ -393,6 +461,7 @@ struct TRINITY_DLL_DECL npc_isla_starmaneAI : public npc_escortAI
         }
     }
 };
+
 bool QuestAccept_npc_isla_starmane(Player* pPlayer, Creature* pCreature, Quest const* quest)
 {
     if (quest->GetQuestId() == QUEST_EFTW_H || quest->GetQuestId() == QUEST_EFTW_A)
@@ -402,10 +471,12 @@ bool QuestAccept_npc_isla_starmane(Player* pPlayer, Creature* pCreature, Quest c
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_isla_starmaneAI(Creature* pCreature)
 {
     return new npc_isla_starmaneAI(pCreature);
 }
+
 /*######
 ## go_skull_pile
 ######*/
@@ -413,6 +484,7 @@ CreatureAI* GetAI_npc_isla_starmaneAI(Creature* pCreature)
 #define GOSSIP_S_KARROG         "Summon Karrog"
 #define GOSSIP_S_GEZZARAK_THE_HUNTRESS         "Summon Gezzarak the Huntress"
 #define GOSSIP_S_VAKKIZ_THE_WINDRAGER         "Summon Vakkiz the Windrager"
+
 bool GossipHello_go_skull_pile(Player* pPlayer, GameObject* pGo)
 {
     if ((pPlayer->GetQuestStatus(11885) == QUEST_STATUS_INCOMPLETE) || pPlayer->GetQuestRewardStatus(11885))
@@ -422,9 +494,11 @@ bool GossipHello_go_skull_pile(Player* pPlayer, GameObject* pGo)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_S_GEZZARAK_THE_HUNTRESS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_S_VAKKIZ_THE_WINDRAGER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
     }
+
     pPlayer->SEND_GOSSIP_MENU(pGo->GetGOInfo()->questgiver.gossipID, pGo->GetGUID());
     return true;
 }
+
 void SendActionMenu_go_skull_pile(Player* pPlayer, GameObject* pGo, uint32 uiAction)
 {
     switch(uiAction)
@@ -443,6 +517,7 @@ void SendActionMenu_go_skull_pile(Player* pPlayer, GameObject* pGo, uint32 uiAct
             break;
     }
 }
+
 bool GossipSelect_go_skull_pile(Player* pPlayer, GameObject* pGo, uint32 uiSender, uint32 uiAction)
 {
     switch(uiSender)
@@ -451,13 +526,16 @@ bool GossipSelect_go_skull_pile(Player* pPlayer, GameObject* pGo, uint32 uiSende
     }
     return true;
 }
+
 /*######
 ## npc_slim
 ######*/
+
 enum eSlim
 {
     FACTION_CONSORTIUM  = 933
 };
+
 bool GossipHello_npc_slim(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isVendor() && pPlayer->GetReputationRank(FACTION_CONSORTIUM) >= REP_FRIENDLY)
@@ -467,31 +545,42 @@ bool GossipHello_npc_slim(Player* pPlayer, Creature* pCreature)
     }
     else
         pPlayer->SEND_GOSSIP_MENU(9895, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_slim(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
+
     return true;
 }
+
 /*########
 ####npc_Akuno
 #####*/
+
 #define QUEST_NPC_AKUNO 10887
 #define Summon 21661
+
 struct TRINITY_DLL_DECL npc_akunoAI : public npc_escortAI
 {
     npc_akunoAI(Creature *c) : npc_escortAI(c) {}
+
     bool IsWalking;
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if(!pPlayer)
             return;
+
         if(IsWalking && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
             m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
 
+
         switch(i)
         {
         case 0: m_creature->setFaction(5); break;
@@ -506,6 +595,7 @@ struct TRINITY_DLL_DECL npc_akunoAI : public npc_escortAI
             break;
         }
     }
+
     void Reset()
     {
         if (IsWalking && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
@@ -516,6 +606,7 @@ struct TRINITY_DLL_DECL npc_akunoAI : public npc_escortAI
         IsWalking=false;
     }
 };
+
 bool QuestAccept_npc_akuno(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     if(pQuest->GetQuestId() == QUEST_NPC_AKUNO)
@@ -525,54 +616,66 @@ bool QuestAccept_npc_akuno(Player* pPlayer, Creature* pCreature, Quest const* pQ
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_akuno(Creature* pCreature)
 {
     return new npc_akunoAI(pCreature);
 }
+
 void AddSC_terokkar_forest()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "mob_unkor_the_ruthless";
     newscript->GetAI = &GetAI_mob_unkor_the_ruthless;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_infested_root_walker";
     newscript->GetAI = &GetAI_mob_infested_root_walker;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_rotting_forest_rager";
     newscript->GetAI = &GetAI_mob_rotting_forest_rager;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_netherweb_victim";
     newscript->GetAI = &GetAI_mob_netherweb_victim;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_floon";
     newscript->GetAI = &GetAI_npc_floon;
     newscript->pGossipHello =  &GossipHello_npc_floon;
     newscript->pGossipSelect = &GossipSelect_npc_floon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_isla_starmane";
     newscript->GetAI = &GetAI_npc_isla_starmaneAI;
     newscript->pQuestAccept = &QuestAccept_npc_isla_starmane;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_skull_pile";
     newscript->pGOHello  = &GossipHello_go_skull_pile;
     newscript->pGOSelect = &GossipSelect_go_skull_pile;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_skywing";
     newscript->GetAI = &GetAI_npc_skywingAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_slim";
     newscript->pGossipHello =  &GossipHello_npc_slim;
     newscript->pGossipSelect = &GossipSelect_npc_slim;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_akuno";
     newscript->GetAI = &GetAI_npc_akuno;
diff --git a/src/bindings/scripts/scripts/outland/zangarmarsh.cpp b/src/bindings/scripts/scripts/outland/zangarmarsh.cpp
index a8b66a8764c..d03e161a2c5 100644
--- a/src/bindings/scripts/scripts/outland/zangarmarsh.cpp
+++ b/src/bindings/scripts/scripts/outland/zangarmarsh.cpp
@@ -13,12 +13,14 @@
  * along 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: 9752, 9785, 9803, 10009. Mark Of ... buffs.
 SDCategory: Zangarmarsh
 EndScriptData */
+
 /* ContentData
 npcs_ashyen_and_keleth
 npc_cooshcoosh
@@ -27,16 +29,20 @@ npc_mortog_steamhead
 npc_kayra_longmane
 npc_timothy_daniels
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.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."
 //signed for 17900 but used by 17900,17901
 #define GOSSIP_REWARD_BLESS       -1000359
 //#define TEXT_BLESSINGS        ""
+
 bool GossipHello_npcs_ashyen_and_keleth(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetReputationRank(942) > REP_NEUTRAL)
@@ -47,8 +53,10 @@ bool GossipHello_npcs_ashyen_and_keleth(Player* pPlayer, Creature* pCreature)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_BLESS_KEL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
     }
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npcs_ashyen_and_keleth(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -56,6 +64,7 @@ bool GossipSelect_npcs_ashyen_and_keleth(Player* pPlayer, Creature* pCreature, u
         pCreature->setPowerType(POWER_MANA);
         pCreature->SetMaxPower(POWER_MANA,200);             //set a "fake" mana value, we can't depend on database doing it in this case
         pCreature->SetPower(POWER_MANA,200);
+
         if (pCreature->GetEntry() == 17900)                //check which Creature we are dealing with
         {
             switch (pPlayer->GetReputationRank(942))
@@ -78,6 +87,7 @@ bool GossipSelect_npcs_ashyen_and_keleth(Player* pPlayer, Creature* pCreature, u
                     break;
             }
         }
+
         if (pCreature->GetEntry() == 17901)
         {
             switch (pPlayer->GetReputationRank(942))         //mark of war
@@ -105,54 +115,68 @@ bool GossipSelect_npcs_ashyen_and_keleth(Player* pPlayer, Creature* pCreature, u
     }
     return true;
 }
+
 /*######
 ## npc_cooshcoosh
 ######*/
+
 #define GOSSIP_COOSH            "You owe Sim'salabim money. Hand them over or die!"
+
 enum eCooshhooosh
 {
     SPELL_LIGHTNING_BOLT    = 9532,
     QUEST_CRACK_SKULLS      = 10009,
     FACTION_HOSTILE_CO      = 45
 };
+
 struct TRINITY_DLL_DECL npc_cooshcooshAI : public ScriptedAI
 {
     npc_cooshcooshAI(Creature* c) : ScriptedAI(c)
     {
         m_uiNormFaction = c->getFaction();
     }
+
     uint32 m_uiNormFaction;
     uint32 LightningBolt_Timer;
+
     void Reset()
     {
         LightningBolt_Timer = 2000;
         if (m_creature->getFaction() != m_uiNormFaction)
             m_creature->setFaction(m_uiNormFaction);
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             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* pCreature)
 {
     return new npc_cooshcooshAI (pCreature);
 }
+
 bool GossipHello_npc_cooshcoosh(Player* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(QUEST_CRACK_SKULLS) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_COOSH, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(9441, pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_cooshcoosh(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF)
@@ -163,19 +187,25 @@ bool GossipSelect_npc_cooshcoosh(Player* pPlayer, Creature* pCreature, uint32 ui
     }
     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* pPlayer, Creature* pCreature)
 {
     if (pPlayer->GetQuestStatus(9803) == QUEST_STATUS_INCOMPLETE)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KUR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+
     pPlayer->SEND_GOSSIP_MENU(9226, pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_elder_kuruti(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiAction)
@@ -207,16 +237,21 @@ bool GossipSelect_npc_elder_kuruti(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*######
 ## npc_mortog_steamhead
 ######*/
+
 bool GossipHello_npc_mortog_steamhead(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isVendor() && pPlayer->GetReputationRank(942) == REP_EXALTED)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_mortog_steamhead(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
@@ -225,9 +260,11 @@ bool GossipSelect_npc_mortog_steamhead(Player* pPlayer, Creature* pCreature, uin
     }
     return true;
 }
+
 /*######
 ## npc_kayra_longmane
 ######*/
+
 enum eKayra
 {
     SAY_START           = -1000360,
@@ -236,18 +273,24 @@ enum eKayra
     SAY_AMBUSH2         = -1000363,
     SAY_NEAR_END        = -1000364,
     SAY_END             = -1000365, //this is signed for 10646
+
     QUEST_ESCAPE_FROM   = 9752,
     NPC_SLAVEBINDER     = 18042
 };
+
 struct TRINITY_DLL_DECL npc_kayra_longmaneAI : public npc_escortAI
 {
     npc_kayra_longmaneAI(Creature* c) : npc_escortAI(c) {}
+
     void Reset() { }
+
     void WaypointReached(uint32 i)
     {
         Player* pPlayer = GetPlayerForEscort();
+
         if (!pPlayer)
             return;
+
         switch(i)
         {
             case 4:
@@ -275,39 +318,49 @@ struct TRINITY_DLL_DECL npc_kayra_longmaneAI : public npc_escortAI
         }
     }
 };
+
 bool QuestAccept_npc_kayra_longmane(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
 {
     if (pQuest->GetQuestId() == QUEST_ESCAPE_FROM)
     {
         DoScriptText(SAY_START, pCreature, pPlayer);
+
         if (npc_escortAI* pEscortAI = CAST_AI(npc_kayra_longmaneAI, pCreature->AI()))
             pEscortAI->Start(false, false, pPlayer->GetGUID());
     }
     return true;
 }
+
 CreatureAI* GetAI_npc_kayra_longmaneAI(Creature* pCreature)
 {
     return new npc_kayra_longmaneAI(pCreature);
 }
+
 /*######
 ## npc_timothy_daniels
 ######*/
+
 #define GOSSIP_TIMOTHY_DANIELS_ITEM1    "Specialist, eh? Just what kind of specialist are you, anyway?"
 #define GOSSIP_TEXT_BROWSE_POISONS      "Let me browse your reagents and poison supplies."
+
 enum eTimothy
 {
     GOSSIP_TEXTID_TIMOTHY_DANIELS1      = 9239
 };
+
 bool GossipHello_npc_timothy_daniels(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isVendor())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_POISONS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TIMOTHY_DANIELS_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_timothy_daniels(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -319,40 +372,49 @@ bool GossipSelect_npc_timothy_daniels(Player* pPlayer, Creature* pCreature, uint
             pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
             break;
     }
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_cooshcoosh";
     newscript->GetAI = &GetAI_npc_cooshcoosh;
     newscript->pGossipHello =  &GossipHello_npc_cooshcoosh;
     newscript->pGossipSelect = &GossipSelect_npc_cooshcoosh;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_elder_kuruti";
     newscript->pGossipHello =  &GossipHello_npc_elder_kuruti;
     newscript->pGossipSelect = &GossipSelect_npc_elder_kuruti;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_mortog_steamhead";
     newscript->pGossipHello =  &GossipHello_npc_mortog_steamhead;
     newscript->pGossipSelect = &GossipSelect_npc_mortog_steamhead;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_kayra_longmane";
     newscript->GetAI = &GetAI_npc_kayra_longmaneAI;
     newscript->pQuestAccept = &QuestAccept_npc_kayra_longmane;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_timothy_daniels";
     newscript->pGossipHello =  &GossipHello_npc_timothy_daniels;
diff --git a/src/bindings/scripts/scripts/world/areatrigger_scripts.cpp b/src/bindings/scripts/scripts/world/areatrigger_scripts.cpp
index ed84c0e2b0c..5aa7ecb7f04 100644
--- a/src/bindings/scripts/scripts/world/areatrigger_scripts.cpp
+++ b/src/bindings/scripts/scripts/world/areatrigger_scripts.cpp
@@ -13,26 +13,33 @@
  * along 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_legion_teleporter    4560 Teleporter TO Invasion Point: Cataclysm
 EndContentData */
+
 #include "precompiled.h"
+
 /*#####
 ## at_legion_teleporter
 #####*/
+
 enum eLegionTeleporter
 {
     SPELL_TELE_A_TO         = 37387,
     QUEST_GAINING_ACCESS_A  = 10589,
+
     SPELL_TELE_H_TO         = 37389,
     QUEST_GAINING_ACCESS_H  = 10604
 };
+
 bool AreaTrigger_at_legion_teleporter(Player* pPlayer, AreaTriggerEntry* pAt)
 {
     if (pPlayer->isAlive() && !pPlayer->isInCombat())
@@ -42,33 +49,41 @@ bool AreaTrigger_at_legion_teleporter(Player* pPlayer, AreaTriggerEntry* pAt)
             pPlayer->CastSpell(pPlayer,SPELL_TELE_A_TO,false);
             return true;
         }
+
         if (pPlayer->GetTeam()== HORDE && pPlayer->GetQuestRewardStatus(QUEST_GAINING_ACCESS_H))
         {
             pPlayer->CastSpell(pPlayer,SPELL_TELE_H_TO,false);
             return true;
         }
+
         return false;
     }
     return false;
 }
+
 enum eRavenholdt
 {
     QUEST_MANOR_RAVENHOLDT  = 6681,
     NPC_RAVENHOLDT          = 13936
 };
+
 bool AreaTrigger_at_ravenholdt(Player* pPlayer, AreaTriggerEntry* pAt)
 {
     if (pPlayer->GetQuestStatus(QUEST_MANOR_RAVENHOLDT) == QUEST_STATUS_INCOMPLETE)
         pPlayer->KilledMonsterCredit(NPC_RAVENHOLDT, 0);
+
     return false;
 }
+
 void AddSC_areatrigger_scripts()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "at_legion_teleporter";
     newscript->pAreaTrigger = &AreaTrigger_at_legion_teleporter;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "at_ravenholdt";
     newscript->pAreaTrigger = &AreaTrigger_at_ravenholdt;
diff --git a/src/bindings/scripts/scripts/world/boss_emeriss.cpp b/src/bindings/scripts/scripts/world/boss_emeriss.cpp
index 233bbac5fa5..fa53ed89d21 100644
--- a/src/bindings/scripts/scripts/world/boss_emeriss.cpp
+++ b/src/bindings/scripts/scripts/world/boss_emeriss.cpp
@@ -13,17 +13,21 @@
  * along 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"
+
 enum eEnums
 {
     SAY_AGGRO               = -1000401,
     SAY_CASTCORRUPTION      = -1000402, //signed for 6182
+
     SPELL_SLEEP             = 24777,
     SPELL_NOXIOUSBREATH     = 24818,
     SPELL_TAILSWEEP         = 15847,
@@ -31,9 +35,11 @@ enum eEnums
     SPELL_VOLATILEINFECTION = 24928,
     SPELL_CORRUPTIONOFEARTH = 24910
 };
+
 struct TRINITY_DLL_DECL boss_emerissAI : public ScriptedAI
 {
     boss_emerissAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 m_uiSleep_Timer;
     uint32 m_uiNoxiousBreath_Timer;
     uint32 m_uiTailSweep_Timer;
@@ -41,6 +47,7 @@ struct TRINITY_DLL_DECL boss_emerissAI : public ScriptedAI
     uint32 m_uiVolatileInfection_Timer;
     uint32 m_uiCorruptionsCasted;
 
+
     void Reset()
     {
         m_uiSleep_Timer = 15000 + rand()%5000;
@@ -50,24 +57,29 @@ struct TRINITY_DLL_DECL boss_emerissAI : public ScriptedAI
         m_uiVolatileInfection_Timer = 12000;
         m_uiCorruptionsCasted = 0;
     }
+
     void Aggro(Unit* pWho)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Sleep_Timer
         if (m_uiSleep_Timer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, SPELL_SLEEP);
+
             m_uiSleep_Timer = 8000 + rand()%8000;
         }
         else
             m_uiSleep_Timer -= uiDiff;
+
         //NoxiousBreath_Timer
         if (m_uiNoxiousBreath_Timer < uiDiff)
         {
@@ -76,6 +88,7 @@ struct TRINITY_DLL_DECL boss_emerissAI : public ScriptedAI
         }
         else
             m_uiNoxiousBreath_Timer -= uiDiff;
+
         //Tailsweep every 2 seconds
         if (m_uiTailSweep_Timer < uiDiff)
         {
@@ -84,6 +97,7 @@ struct TRINITY_DLL_DECL boss_emerissAI : public ScriptedAI
         }
         else
             m_uiTailSweep_Timer -= uiDiff;
+
         //MarkOfNature_Timer
         //if (m_uiMarkOfNature_Timer < uiDiff)
         //{
@@ -93,6 +107,7 @@ struct TRINITY_DLL_DECL boss_emerissAI : public ScriptedAI
         //else
         //    m_uiMarkOfNature_Timer -= uiDiff;
 
+
         //VolatileInfection_Timer
         if (m_uiVolatileInfection_Timer < uiDiff)
         {
@@ -101,6 +116,7 @@ struct TRINITY_DLL_DECL boss_emerissAI : public ScriptedAI
         }
         else
             m_uiVolatileInfection_Timer -= uiDiff;
+
         //CorruptionofEarth_Timer
         //CorruptionofEarth at 75%, 50% and 25%
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= (100-(25*m_uiCorruptionsCasted)))
@@ -109,13 +125,16 @@ struct TRINITY_DLL_DECL boss_emerissAI : public ScriptedAI
             DoScriptText(SAY_CASTCORRUPTION, m_creature);
             DoCast(m_creature->getVictim(), SPELL_CORRUPTIONOFEARTH);
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_emeriss(Creature* pCreature)
 {
     return new boss_emerissAI (pCreature);
 }
+
 void AddSC_boss_emeriss()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/world/boss_lethon.cpp b/src/bindings/scripts/scripts/world/boss_lethon.cpp
index 7b323b256f3..e387891efed 100644
--- a/src/bindings/scripts/scripts/world/boss_lethon.cpp
+++ b/src/bindings/scripts/scripts/world/boss_lethon.cpp
@@ -13,11 +13,13 @@
  * along 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/world/boss_taerar.cpp b/src/bindings/scripts/scripts/world/boss_taerar.cpp
index d11da293921..6659924c41b 100644
--- a/src/bindings/scripts/scripts/world/boss_taerar.cpp
+++ b/src/bindings/scripts/scripts/world/boss_taerar.cpp
@@ -13,17 +13,21 @@
  * along 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: 70
 SDComment: Mark of Nature & Teleport NYI. Fix the way to be banished.
 SDCategory: Bosses
 EndScriptData */
+
 #include "precompiled.h"
+
 enum eEnums
 {
     SAY_AGGRO               = -1000399, //signed for 20021
     SAY_SUMMONSHADE         = -1000400, //signed for 20021
+
     //Spells of Taerar
     SPELL_SLEEP             = 24777,
     SPELL_NOXIOUSBREATH     = 24818,
@@ -31,20 +35,25 @@ enum eEnums
     // SPELL_MARKOFNATURE   = 25040,                        // Not working
     SPELL_ARCANEBLAST       = 24857,
     SPELL_BELLOWINGROAR     = 22686,
+
     SPELL_SUMMONSHADE_1     = 24841,
     SPELL_SUMMONSHADE_2     = 24842,
     SPELL_SUMMONSHADE_3     = 24843,
+
     //Spells of Shades of Taerar
     SPELL_POSIONCLOUD       = 24840,
     SPELL_POSIONBREATH      = 20667
 };
+
 uint32 m_auiSpellSummonShade[]=
 {
     SPELL_SUMMONSHADE_1, SPELL_SUMMONSHADE_2, SPELL_SUMMONSHADE_3
 };
+
 struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
 {
     boss_taerarAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 m_uiSleep_Timer;
     uint32 m_uiNoxiousBreath_Timer;
     uint32 m_uiTailSweep_Timer;
@@ -53,7 +62,9 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
     uint32 m_uiBellowingRoar_Timer;
     uint32 m_uiShades_Timer;
     uint32 m_uiShadesSummoned;
+
     bool m_bShades;
+
     void Reset()
     {
         m_uiSleep_Timer = 15000 + rand()%5000;
@@ -64,17 +75,21 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
         m_uiBellowingRoar_Timer = 30000;
         m_uiShades_Timer = 60000;                               //The time that Taerar is banished
         m_uiShadesSummoned = 0;
+
         m_bShades = false;
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
             pSummoned->AI()->AttackStart(pTarget);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (m_bShades && m_uiShades_Timer < uiDiff)
@@ -90,18 +105,22 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
             //Do nothing while banished
             return;
         }
+
         //Return since we have no target
         if (!UpdateVictim())
             return;
+
         //Sleep_Timer
         if (m_uiSleep_Timer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, SPELL_SLEEP);
+
             m_uiSleep_Timer = 8000 + rand()%7000;
         }
         else
             m_uiSleep_Timer -= uiDiff;
+
         //NoxiousBreath_Timer
         if (m_uiNoxiousBreath_Timer < uiDiff)
         {
@@ -110,6 +129,7 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
         }
         else
             m_uiNoxiousBreath_Timer -= uiDiff;
+
         //Tailsweep every 2 seconds
         if (m_uiTailSweep_Timer < uiDiff)
         {
@@ -118,6 +138,7 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
         }
         else
             m_uiTailSweep_Timer -= uiDiff;
+
         //MarkOfNature_Timer
         //if (m_uiMarkOfNature_Timer < uiDiff)
         //{
@@ -126,6 +147,7 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
         //}
         //else
         //    m_uiMarkOfNature_Timer -= uiDiff;
+
         //ArcaneBlast_Timer
         if (m_uiArcaneBlast_Timer < uiDiff)
         {
@@ -134,6 +156,7 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
         }
         else
             m_uiArcaneBlast_Timer -= uiDiff;
+
         //BellowingRoar_Timer
         if (m_uiBellowingRoar_Timer < uiDiff)
         {
@@ -142,6 +165,7 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
         }
         else
             m_uiBellowingRoar_Timer -= uiDiff;
+
         //Summon 3 Shades at 75%, 50% and 25% (if bShades is true we already left in line 117, no need to check here again)
         if (!m_bShades && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= (100-(25*m_uiShadesSummoned)))
         {
@@ -149,36 +173,47 @@ struct TRINITY_DLL_DECL boss_taerarAI : public ScriptedAI
             {
                 //Inturrupt any spell casting
                 m_creature->InterruptNonMeleeSpells(false);
+
                 //horrible workaround, need to fix
                 m_creature->setFaction(35);
                 m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
                 DoScriptText(SAY_SUMMONSHADE, m_creature);
+
                 int iSize = sizeof(m_auiSpellSummonShade) / sizeof(uint32);
-                for (int i = 0; i < iSize; ++i)
+
+                for(int i = 0; i < iSize; ++i)
                     m_creature->CastSpell(pTarget, m_auiSpellSummonShade[i], true);
+
                 ++m_uiShadesSummoned;                       // prevent casting twice at same health
                 m_bShades = true;
             }
             m_uiShades_Timer = 60000;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 // Shades of Taerar Script
 struct TRINITY_DLL_DECL boss_shadeoftaerarAI : public ScriptedAI
 {
     boss_shadeoftaerarAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 m_uiPoisonCloud_Timer;
     uint32 m_uiPosionBreath_Timer;
+
     void Reset()
     {
         m_uiPoisonCloud_Timer = 8000;
         m_uiPosionBreath_Timer = 12000;
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         //PoisonCloud_Timer
         if (m_uiPoisonCloud_Timer < uiDiff)
         {
@@ -187,6 +222,7 @@ struct TRINITY_DLL_DECL boss_shadeoftaerarAI : public ScriptedAI
         }
         else
             m_uiPoisonCloud_Timer -= uiDiff;
+
         //PosionBreath_Timer
         if (m_uiPosionBreath_Timer < uiDiff)
         {
@@ -195,24 +231,30 @@ struct TRINITY_DLL_DECL boss_shadeoftaerarAI : public ScriptedAI
         }
         else
             m_uiPosionBreath_Timer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_taerar(Creature* pCreature)
 {
     return new boss_taerarAI (pCreature);
 }
+
 CreatureAI* GetAI_boss_shadeoftaerar(Creature* pCreature)
 {
     return new boss_shadeoftaerarAI (pCreature);
 }
+
 void AddSC_boss_taerar()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_taerar";
     newscript->GetAI = &GetAI_boss_taerar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "boss_shade_of_taerar";
     newscript->GetAI = &GetAI_boss_shadeoftaerar;
diff --git a/src/bindings/scripts/scripts/world/boss_ysondre.cpp b/src/bindings/scripts/scripts/world/boss_ysondre.cpp
index fe4d0eb159e..2f3948d38d9 100644
--- a/src/bindings/scripts/scripts/world/boss_ysondre.cpp
+++ b/src/bindings/scripts/scripts/world/boss_ysondre.cpp
@@ -13,37 +13,46 @@
  * along 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"
+
 enum eEnums
 {
     SAY_AGGRO               = -1000360, //signed for 17969
     SAY_SUMMONDRUIDS        = -1000361, //signed for 17969
+
     SPELL_SLEEP             = 24777,
     SPELL_NOXIOUSBREATH     = 24818,
     SPELL_TAILSWEEP         = 15847,
     //SPELL_MARKOFNATURE   = 25040,                        // Not working
     SPELL_LIGHTNINGWAVE     = 24819,
     SPELL_SUMMONDRUIDS      = 24795,
+
     SPELL_SUMMON_PLAYER     = 24776,
+
     //druid spells
     SPELL_MOONFIRE          = 21669
 };
+
 // Ysondre script
 struct TRINITY_DLL_DECL boss_ysondreAI : public ScriptedAI
 {
     boss_ysondreAI(Creature* pCreature) : ScriptedAI(pCreature) {}
+
     uint32 m_uiSleep_Timer;
     uint32 m_uiNoxiousBreath_Timer;
     uint32 m_uiTailSweep_Timer;
     //uint32 m_uiMarkOfNature_Timer;
     uint32 m_uiLightningWave_Timer;
     uint32 m_uiSummonDruidModifier;
+
     void Reset()
     {
         m_uiSleep_Timer = 15000 + rand()%5000;
@@ -53,28 +62,34 @@ struct TRINITY_DLL_DECL boss_ysondreAI : public ScriptedAI
         m_uiLightningWave_Timer = 12000;
         m_uiSummonDruidModifier = 0;
     }
+
     void EnterCombat(Unit* pWho)
     {
         DoScriptText(SAY_AGGRO, m_creature);
     }
+
     void JustSummoned(Creature* pSummoned)
     {
         if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
             pSummoned->AI()->AttackStart(pTarget);
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         //Sleep_Timer
         if (m_uiSleep_Timer < uiDiff)
         {
             if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(pTarget, SPELL_SLEEP);
+
             m_uiSleep_Timer = 8000 + rand()%7000;
         }
         else
             m_uiSleep_Timer -= uiDiff;
+
         //NoxiousBreath_Timer
         if (m_uiNoxiousBreath_Timer < uiDiff)
         {
@@ -83,15 +98,18 @@ struct TRINITY_DLL_DECL boss_ysondreAI : public ScriptedAI
         }
         else
             m_uiNoxiousBreath_Timer -= uiDiff;
+
         //Tailsweep every 2 seconds
         if (m_uiTailSweep_Timer < uiDiff)
         {
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(target, SPELL_TAILSWEEP);
+
             m_uiTailSweep_Timer = 2000;
         }
         else
             m_uiTailSweep_Timer -= uiDiff;
+
         //MarkOfNature_Timer
         //if (m_uiMarkOfNature_Timer < uiDiff)
         //{
@@ -100,40 +118,51 @@ struct TRINITY_DLL_DECL boss_ysondreAI : public ScriptedAI
         //}
         //else
         //    m_uiMarkOfNature_Timer -= uiDiff;
+
         //LightningWave_Timer
         if (m_uiLightningWave_Timer < uiDiff)
         {
             //Cast LIGHTNINGWAVE on a Random target
             if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                 DoCast(target, SPELL_LIGHTNINGWAVE);
+
             m_uiLightningWave_Timer = 7000 + rand()%5000;
         }
         else
             m_uiLightningWave_Timer -= uiDiff;
+
         //Summon Druids
         if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= (100-(25*m_uiSummonDruidModifier)))
         {
             DoScriptText(SAY_SUMMONDRUIDS, m_creature);
-            for (int i = 0; i < 10; ++i)
+
+            for(int i = 0; i < 10; ++i)
                 DoCast(m_creature, SPELL_SUMMONDRUIDS, true);
+
             ++m_uiSummonDruidModifier;
         }
+
         DoMeleeAttackIfReady();
     }
 };
+
 // Summoned druid script
 struct TRINITY_DLL_DECL mob_dementeddruidsAI : public ScriptedAI
 {
     mob_dementeddruidsAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 m_uiMoonFire_Timer;
+
     void Reset()
     {
         m_uiMoonFire_Timer = 3000;
     }
+
     void UpdateAI(const uint32 uiDiff)
     {
         if (!UpdateVictim())
             return;
+
         //MoonFire_Timer
         if (m_uiMoonFire_Timer < uiDiff)
         {
@@ -142,24 +171,30 @@ struct TRINITY_DLL_DECL mob_dementeddruidsAI : public ScriptedAI
         }
         else
             m_uiMoonFire_Timer -= uiDiff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_boss_ysondre(Creature* pCreature)
 {
     return new boss_ysondreAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_dementeddruids(Creature* pCreature)
 {
     return new mob_dementeddruidsAI (pCreature);
 }
+
 void AddSC_boss_ysondre()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "boss_ysondre";
     newscript->GetAI = &GetAI_boss_ysondre;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_dementeddruids";
     newscript->GetAI = &GetAI_mob_dementeddruids;
diff --git a/src/bindings/scripts/scripts/world/go_scripts.cpp b/src/bindings/scripts/scripts/world/go_scripts.cpp
index 05f21918479..668dd513191 100644
--- a/src/bindings/scripts/scripts/world/go_scripts.cpp
+++ b/src/bindings/scripts/scripts/world/go_scripts.cpp
@@ -13,12 +13,14 @@
  * along 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, 6481, 10990, 10991, 10992, Field_Repair_Bot->Teaches spell 22704. Barov_journal->Teaches spell 26089
 SDCategory: Game Objects
 EndScriptData */
+
 /* ContentData
 go_cat_figurine (the "trap" version of GO, two different exist)
 go_northern_crystal_pylon
@@ -38,22 +40,28 @@ go_tablet_of_the_seven
 go_tele_to_dalaran_crystal
 go_tele_to_violet_stand
 EndContentData */
+
 #include "precompiled.h"
+
 /*######
 ## go_cat_figurine
 ######*/
+
 enum eCatFigurine
 {
     SPELL_SUMMON_GHOST_SABER    = 5968,
 };
+
 bool GOHello_go_cat_figurine(Player* pPlayer, GameObject* pGo)
 {
     pPlayer->CastSpell(pPlayer,SPELL_SUMMON_GHOST_SABER,true);
     return false;
 }
+
 /*######
 ## go_crystal_pylons (3x)
 ######*/
+
 bool GOHello_go_northern_crystal_pylon(Player* pPlayer, GameObject* pGo)
 {
     if (pGo->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
@@ -61,10 +69,13 @@ bool GOHello_go_northern_crystal_pylon(Player* pPlayer, GameObject* pGo)
         pPlayer->PrepareQuestMenu(pGo->GetGUID());
         pPlayer->SendPreparedQuest(pGo->GetGUID());
     }
+
     if (pPlayer->GetQuestStatus(4285) == QUEST_STATUS_INCOMPLETE)
         pPlayer->AreaExploredOrEventHappens(4285);
+
     return true;
 }
+
 bool GOHello_go_eastern_crystal_pylon(Player* pPlayer, GameObject* pGo)
 {
     if (pGo->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
@@ -72,10 +83,13 @@ bool GOHello_go_eastern_crystal_pylon(Player* pPlayer, GameObject* pGo)
         pPlayer->PrepareQuestMenu(pGo->GetGUID());
         pPlayer->SendPreparedQuest(pGo->GetGUID());
     }
+
     if (pPlayer->GetQuestStatus(4287) == QUEST_STATUS_INCOMPLETE)
         pPlayer->AreaExploredOrEventHappens(4287);
+
     return true;
 }
+
 bool GOHello_go_western_crystal_pylon(Player* pPlayer, GameObject* pGo)
 {
     if (pGo->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
@@ -83,13 +97,17 @@ bool GOHello_go_western_crystal_pylon(Player* pPlayer, GameObject* pGo)
         pPlayer->PrepareQuestMenu(pGo->GetGUID());
         pPlayer->SendPreparedQuest(pGo->GetGUID());
     }
+
     if (pPlayer->GetQuestStatus(4288) == QUEST_STATUS_INCOMPLETE)
         pPlayer->AreaExploredOrEventHappens(4288);
+
     return true;
 }
+
 /*######
 ## go_barov_journal
 ######*/
+
 bool GOHello_go_barov_journal(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->HasSkill(SKILL_TAILORING) && pPlayer->GetBaseSkillValue(SKILL_TAILORING) >= 280 && !pPlayer->HasSpell(26086))
@@ -98,9 +116,11 @@ bool GOHello_go_barov_journal(Player* pPlayer, GameObject* pGo)
     }
     return true;
 }
+
 /*######
 ## go_field_repair_bot_74A
 ######*/
+
 bool GOHello_go_field_repair_bot_74A(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->HasSkill(SKILL_ENGINERING) && pPlayer->GetBaseSkillValue(SKILL_ENGINERING) >= 300 && !pPlayer->HasSpell(22704))
@@ -109,32 +129,41 @@ bool GOHello_go_field_repair_bot_74A(Player* pPlayer, GameObject* pGo)
     }
     return true;
 }
+
 /*######
 ## go_gilded_brazier
 ######*/
+
 enum eGildedBrazier
 {
     NPC_STILLBLADE  = 17716,
 };
+
 bool GOHello_go_gilded_brazier(Player* pPlayer, GameObject* pGO)
 {
     if (pGO->GetGoType() == GAMEOBJECT_TYPE_GOOBER)
         if (Creature* pCreature = pPlayer->SummonCreature(NPC_STILLBLADE, 8087.632, -7542.740, 151.568, 0.122, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000))
             pCreature->AI()->AttackStart(pPlayer);
+
     return true;
 }
+
 /*######
 ## go_orb_of_command
 ######*/
+
 bool GOHello_go_orb_of_command(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->GetQuestRewardStatus(7761))
         pPlayer->CastSpell(pPlayer,23460,true);
+
     return true;
 }
+
 /*######
 ## go_tablet_of_madness
 ######*/
+
 bool GOHello_go_tablet_of_madness(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->HasSkill(SKILL_ALCHEMY) && pPlayer->GetSkillValue(SKILL_ALCHEMY) >= 300 && !pPlayer->HasSpell(24266))
@@ -143,30 +172,39 @@ bool GOHello_go_tablet_of_madness(Player* pPlayer, GameObject* pGo)
     }
     return true;
 }
+
 /*######
 ## go_tablet_of_the_seven
 ######*/
+
 //TODO: use gossip option ("Transcript the Tablet") instead, if Trinity adds support.
 bool GOHello_go_tablet_of_the_seven(Player* pPlayer, GameObject* pGo)
 {
     if (pGo->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
         return true;
+
     if (pPlayer->GetQuestStatus(4296) == QUEST_STATUS_INCOMPLETE)
         pPlayer->CastSpell(pPlayer,15065,false);
+
     return true;
 }
+
 /*#####
 ## go_jump_a_tron
 ######*/
+
 bool GOHello_go_jump_a_tron(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->GetQuestStatus(10111) == QUEST_STATUS_INCOMPLETE)
      pPlayer->CastSpell(pPlayer,33382,true);
+
     return true;
 }
+
 /*######
 ## go_ethereum_prison
 ######*/
+
 enum eEthereumPrison
 {
     SPELL_REP_LC        = 39456,
@@ -176,14 +214,17 @@ enum eEthereumPrison
     SPELL_REP_KT        = 39475,
     SPELL_REP_SPOR      = 39476
 };
+
 const uint32 NpcPrisonEntry[] =
 {
     22810, 22811, 22812, 22813, 22814, 22815,               //good guys
     20783, 20784, 20785, 20786, 20788, 20789, 20790         //bad guys
 };
+
 bool GOHello_go_ethereum_prison(Player* pPlayer, GameObject* pGo)
 {
     int Random = rand() % (sizeof(NpcPrisonEntry) / sizeof(uint32));
+
     if (Creature* pCreature = pPlayer->SummonCreature(NpcPrisonEntry[Random],
         pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ(), pGo->GetAngle(pPlayer),
         TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000))
@@ -191,6 +232,7 @@ bool GOHello_go_ethereum_prison(Player* pPlayer, GameObject* pGo)
         if (!pCreature->IsHostileTo(pPlayer))
         {
             uint32 Spell = 0;
+
             if (FactionTemplateEntry const* pFaction = pCreature->getFactionTemplateEntry())
             {
                 switch(pFaction->faction)
@@ -202,6 +244,7 @@ bool GOHello_go_ethereum_prison(Player* pPlayer, GameObject* pGo)
                     case 989: Spell = SPELL_REP_KT; break;
                     case 970: Spell = SPELL_REP_SPOR; break;
                 }
+
                 if (Spell)
                     pCreature->CastSpell(pPlayer, Spell, false);
                 else
@@ -209,49 +252,65 @@ bool GOHello_go_ethereum_prison(Player* pPlayer, GameObject* pGo)
             }
         }
     }
+
     return false;
 }
+
 /*######
 ## go_ethereum_stasis
 ######*/
+
 const uint32 NpcStasisEntry[] =
 {
     22825, 20888, 22827, 22826, 22828
 };
+
 bool GOHello_go_ethereum_stasis(Player* pPlayer, GameObject* pGo)
 {
     int Random = rand() % (sizeof(NpcStasisEntry) / sizeof(uint32));
+
     pPlayer->SummonCreature(NpcStasisEntry[Random],
         pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ(), pGo->GetAngle(pPlayer),
         TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
+
     return false;
 }
+
 /*######
 ## go_resonite_cask
 ######*/
+
 enum eResoniteCask
 {
     NPC_GOGGEROC    = 11920
 };
+
 bool GOHello_go_resonite_cask(Player* pPlayer, GameObject* pGO)
 {
     if (pGO->GetGoType() == GAMEOBJECT_TYPE_GOOBER)
         pGO->SummonCreature(NPC_GOGGEROC, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000);
+
     return false;
 }
+
 /*######
 ## go_sacred_fire_of_life
 ######*/
+
 #define NPC_ARIKARA  10882
+
 bool GOHello_go_sacred_fire_of_life(Player* pPlayer, GameObject* pGO)
 {
     if (pGO->GetGoType() == GAMEOBJECT_TYPE_GOOBER)
         pPlayer->SummonCreature(NPC_ARIKARA, -5008.338, -2118.894, 83.657, 0.874, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
+
     return true;
 }
+
 /*######
 ## go_shrine_of_the_birds
 ######*/
+
 enum eShrineOfTheBirds
 {
     NPC_HAWK_GUARD      = 22992,
@@ -261,11 +320,14 @@ enum eShrineOfTheBirds
     GO_SHRINE_EAGLE     = 185547,
     GO_SHRINE_FALCON    = 185553
 };
+
 bool GOHello_go_shrine_of_the_birds(Player* pPlayer, GameObject* pGo)
 {
     uint32 BirdEntry = 0;
+
     float fX, fY, fZ;
     pGo->GetClosePoint(fX, fY, fZ, pGo->GetObjectSize(), INTERACTION_DISTANCE);
+
     switch(pGo->GetEntry())
     {
         case GO_SHRINE_HAWK:
@@ -278,73 +340,96 @@ bool GOHello_go_shrine_of_the_birds(Player* pPlayer, GameObject* pGo)
             BirdEntry = NPC_FALCON_GUARD;
             break;
     }
+
     if (BirdEntry)
         pPlayer->SummonCreature(BirdEntry, fX, fY, fZ, pGo->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
+
     return false;
 }
+
 /*######
 ## go_southfury_moonstone
 ######*/
+
 enum eSouthfury
 {
     NPC_RIZZLE                  = 23002,
     SPELL_BLACKJACK             = 39865, //stuns player
     SPELL_SUMMON_RIZZLE         = 39866
+
 };
+
 bool GOHello_go_southfury_moonstone(Player* pPlayer, GameObject* pGo)
 {
     //implicitTarget=48 not implemented as of writing this code, and manual summon may be just ok for our purpose
     //pPlayer->CastSpell(pPlayer,SPELL_SUMMON_RIZZLE,false);
+
     if (Creature* pCreature = pPlayer->SummonCreature(NPC_RIZZLE, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_DEAD_DESPAWN, 0))
         pCreature->CastSpell(pPlayer,SPELL_BLACKJACK,false);
+
     return false;
 }
+
 /*######
 ## go_tele_to_dalaran_crystal
 ######*/
+
 enum eDalaranCrystal
 {
     QUEST_LEARN_LEAVE_RETURN    = 12790,
     QUEST_TELE_CRYSTAL_FLAG     = 12845
 };
+
 bool GOHello_go_tele_to_dalaran_crystal(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->GetQuestRewardStatus(QUEST_TELE_CRYSTAL_FLAG))
         return false;
+
     //TODO: must send error message (what kind of message? On-screen?)
     return true;
 }
+
 /*######
 ## go_tele_to_violet_stand
 ######*/
+
 bool GOHello_go_tele_to_violet_stand(Player* pPlayer, GameObject* pGo)
 {
     if (pPlayer->GetQuestRewardStatus(QUEST_LEARN_LEAVE_RETURN) || pPlayer->GetQuestStatus(QUEST_LEARN_LEAVE_RETURN) == QUEST_STATUS_INCOMPLETE)
         return false;
+
     return true;
 }
+
 /*######
 ## go_fel_crystalforge
 ######*/
+
 #define GOSSIP_FEL_CRYSTALFORGE_TEXT 31000
 #define GOSSIP_FEL_CRYSTALFORGE_ITEM_TEXT_RETURN 31001
 #define GOSSIP_FEL_CRYSTALFORGE_ITEM_1 "Purchase 1 Unstable Flask of the Beast for the cost of 10 Apexis Shards"
 #define GOSSIP_FEL_CRYSTALFORGE_ITEM_5 "Purchase 5 Unstable Flask of the Beast for the cost of 50 Apexis Shards"
 #define GOSSIP_FEL_CRYSTALFORGE_ITEM_RETURN "Use the fel crystalforge to make another purchase."
+
 enum eFelCrystalforge
 {
     SPELL_CREATE_1_FLASK_OF_BEAST   = 40964,
     SPELL_CREATE_5_FLASK_OF_BEAST   = 40965,
 };
+
 bool GOHello_go_fel_crystalforge(Player* pPlayer, GameObject* pGO)
 {
     if ( pGO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER ) /* != GAMEOBJECT_TYPE_QUESTGIVER) */
         pPlayer->PrepareQuestMenu(pGO->GetGUID()); /* return true*/
+
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_FEL_CRYSTALFORGE_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_FEL_CRYSTALFORGE_ITEM_5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
+
     pPlayer->SEND_GOSSIP_MENU(GOSSIP_FEL_CRYSTALFORGE_TEXT, pGO->GetGUID());
+
     return true;
 }
+
 bool GOSelect_go_fel_crystalforge(Player* pPlayer, GameObject* pGO, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -367,19 +452,23 @@ bool GOSelect_go_fel_crystalforge(Player* pPlayer, GameObject* pGO, uint32 uiSen
     }
     return true;
 }
+
 /*######
 ## go_bashir_crystalforge
 ######*/
+
 enum eBashirCrystalforge
 {
     SPELL_CREATE_1_FLASK_OF_SORCERER   = 40968,
     SPELL_CREATE_5_FLASK_OF_SORCERER   = 40970,
 };
+
 bool GOHello_go_bashir_crystalforge(Player* pPlayer, GameObject* pGO)
 {
     pPlayer->CastSpell(pPlayer,SPELL_CREATE_1_FLASK_OF_SORCERER,false);
     return false;
 }
+
 bool GOHello_go_wg2voa_portal(Player* pPlayer, GameObject* pGO)
 {
     // teleport player inside VoA if faction controls WG, core has already set faction for this GO
@@ -387,9 +476,11 @@ bool GOHello_go_wg2voa_portal(Player* pPlayer, GameObject* pGO)
     pPlayer->SetPvP(false);
     return false;
 }
+
 /*######
 ## matrix_punchograph
 ######*/
+
 enum eMatrixPunchograph
 {
     ITEM_WHITE_PUNCH_CARD = 9279,
@@ -406,6 +497,7 @@ enum eMatrixPunchograph
     MATRIX_PUNCHOGRAPH_3005_C = 142476,
     MATRIX_PUNCHOGRAPH_3005_D = 142696,
 };
+
 bool GOHello_go_matrix_punchograph(Player* pPlayer, GameObject* pGo)
 {
     switch(pGo->GetEntry())
@@ -443,98 +535,122 @@ bool GOHello_go_matrix_punchograph(Player* pPlayer, GameObject* pGo)
     }
     return false;
 }
+
 void AddSC_go_scripts()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "go_cat_figurine";
     newscript->pGOHello =           &GOHello_go_cat_figurine;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_northern_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_northern_crystal_pylon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_eastern_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_eastern_crystal_pylon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_western_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_western_crystal_pylon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_barov_journal";
     newscript->pGOHello =           &GOHello_go_barov_journal;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_field_repair_bot_74A";
     newscript->pGOHello =           &GOHello_go_field_repair_bot_74A;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_gilded_brazier";
     newscript->pGOHello =           &GOHello_go_gilded_brazier;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_orb_of_command";
     newscript->pGOHello =           &GOHello_go_orb_of_command;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_shrine_of_the_birds";
     newscript->pGOHello =           &GOHello_go_shrine_of_the_birds;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_southfury_moonstone";
     newscript->pGOHello =           &GOHello_go_southfury_moonstone;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_tablet_of_madness";
     newscript->pGOHello =           &GOHello_go_tablet_of_madness;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_tablet_of_the_seven";
     newscript->pGOHello =           &GOHello_go_tablet_of_the_seven;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_jump_a_tron";
     newscript->pGOHello =           &GOHello_go_jump_a_tron;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_ethereum_prison";
     newscript->pGOHello =           &GOHello_go_ethereum_prison;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_ethereum_stasis";
     newscript->pGOHello =           &GOHello_go_ethereum_stasis;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_resonite_cask";
     newscript->pGOHello =           &GOHello_go_resonite_cask;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_sacred_fire_of_life";
     newscript->pGOHello =           &GOHello_go_sacred_fire_of_life;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_tele_to_dalaran_crystal";
     newscript->pGOHello =           &GOHello_go_tele_to_dalaran_crystal;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_tele_to_violet_stand";
     newscript->pGOHello =           &GOHello_go_tele_to_violet_stand;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_fel_crystalforge";
     newscript->pGOHello =           &GOHello_go_fel_crystalforge;
     newscript->pGOSelect =          &GOSelect_go_fel_crystalforge;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_bashir_crystalforge";
     newscript->pGOHello =           &GOHello_go_bashir_crystalforge;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_wg2voa_portal";
     newscript->pGOHello =           &GOHello_go_wg2voa_portal;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "go_matrix_punchograph";
     newscript->pGOHello =           &GOHello_go_matrix_punchograph;
diff --git a/src/bindings/scripts/scripts/world/guards.cpp b/src/bindings/scripts/scripts/world/guards.cpp
index 218e6fc489a..ead30387b18 100644
--- a/src/bindings/scripts/scripts/world/guards.cpp
+++ b/src/bindings/scripts/scripts/world/guards.cpp
@@ -13,12 +13,14 @@
  * along 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
@@ -42,15 +44,19 @@ 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"
@@ -67,13 +73,17 @@ EndContentData */
 #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"
+
 /*******************************************************
  * guard_azuremyst start
  *******************************************************/
+
 bool GossipHello_guard_azuremyst(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK            , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -86,6 +96,7 @@ bool GossipHello_guard_azuremyst(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(10066, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_azuremyst(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -139,6 +150,7 @@ void SendDefaultMenu_guard_azuremyst(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_azuremyst(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -173,6 +185,7 @@ void SendClassTrainerMenu_guard_azuremyst(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_azuremyst(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -234,6 +247,7 @@ void SendProfTrainerMenu_guard_azuremyst(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 bool GossipSelect_guard_azuremyst(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -244,16 +258,20 @@ bool GossipSelect_guard_azuremyst(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*******************************************************
  * guard_azuremyst end
  *******************************************************/
+
 CreatureAI* GetAI_guard_azuremyst(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_bluffwatcher start
  *******************************************************/
+
 bool GossipHello_guard_bluffwatcher(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK         , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -270,6 +288,7 @@ bool GossipHello_guard_bluffwatcher(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(3543, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_bluffwatcher(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -338,6 +357,7 @@ void SendDefaultMenu_guard_bluffwatcher(Player* pPlayer, Creature* pCreature, ui
             break;
     }
 }
+
 void SendBattleMasterMenu_guard_bluffwatcher(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -356,6 +376,7 @@ void SendBattleMasterMenu_guard_bluffwatcher(Player* pPlayer, Creature* pCreatur
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_bluffwatcher(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -386,6 +407,7 @@ void SendClassTrainerMenu_guard_bluffwatcher(Player* pPlayer, Creature* pCreatur
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_bluffwatcher(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -440,6 +462,7 @@ void SendProfTrainerMenu_guard_bluffwatcher(Player* pPlayer, Creature* pCreature
             break;
     }
 }
+
 bool GossipSelect_guard_bluffwatcher(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -451,16 +474,20 @@ bool GossipSelect_guard_bluffwatcher(Player* pPlayer, Creature* pCreature, uint3
     }
     return true;
 }
+
 /*******************************************************
  * guard_bluffwatcher end
  *******************************************************/
+
 CreatureAI* GetAI_guard_bluffwatcher(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_contested start
  *******************************************************/
+
 CreatureAI* GetAI_guard_contested(Creature* pCreature)
 {
      return new guardAI (pCreature);
@@ -468,9 +495,11 @@ CreatureAI* GetAI_guard_contested(Creature* pCreature)
 /*******************************************************
  * guard_contested end
  *******************************************************/
+
 /*******************************************************
  * guard_darnassus start
  *******************************************************/
+
 bool GossipHello_guard_darnassus(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_AUCTIONHOUSE   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -487,6 +516,7 @@ bool GossipHello_guard_darnassus(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(3016, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_darnassus(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -552,6 +582,7 @@ void SendDefaultMenu_guard_darnassus(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendBattleMasterMenu_guard_darnassus(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -570,6 +601,7 @@ void SendBattleMasterMenu_guard_darnassus(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_darnassus(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -596,6 +628,7 @@ void SendClassTrainerMenu_guard_darnassus(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_darnassus(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -642,6 +675,7 @@ void SendProfTrainerMenu_guard_darnassus(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 bool GossipSelect_guard_darnassus(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -653,16 +687,20 @@ bool GossipSelect_guard_darnassus(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*******************************************************
  * guard_darnassus end
  *******************************************************/
+
 CreatureAI* GetAI_guard_darnassus(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_dunmorogh start
  *******************************************************/
+
 bool GossipHello_guard_dunmorogh(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK             , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -673,8 +711,10 @@ bool GossipHello_guard_dunmorogh(Player* pPlayer, Creature* pCreature)
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_CLASSTRAINER     , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_PROFTRAINER      , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
     pPlayer->SEND_GOSSIP_MENU(4287, pCreature->GetGUID());
+
     return true;
 }
+
 void SendDefaultMenu_guard_dunmorogh(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -724,6 +764,7 @@ void SendDefaultMenu_guard_dunmorogh(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_dunmorogh(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -758,6 +799,7 @@ void SendClassTrainerMenu_guard_dunmorogh(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_dunmorogh(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -809,6 +851,7 @@ void SendProfTrainerMenu_guard_dunmorogh(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 bool GossipSelect_guard_dunmorogh(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -819,16 +862,20 @@ bool GossipSelect_guard_dunmorogh(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*******************************************************
  * guard_dunmorogh end
  *******************************************************/
+
 CreatureAI* GetAI_guard_dunmorogh(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_durotar start
  *******************************************************/
+
 bool GossipHello_guard_durotar(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK         , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -840,6 +887,7 @@ bool GossipHello_guard_durotar(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(4037, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_durotar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -886,6 +934,7 @@ void SendDefaultMenu_guard_durotar(Player* pPlayer, Creature* pCreature, uint32
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_durotar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -920,6 +969,7 @@ void SendClassTrainerMenu_guard_durotar(Player* pPlayer, Creature* pCreature, ui
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_durotar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -969,6 +1019,7 @@ void SendProfTrainerMenu_guard_durotar(Player* pPlayer, Creature* pCreature, uin
             break;
     }
 }
+
 bool GossipSelect_guard_durotar(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -979,16 +1030,20 @@ bool GossipSelect_guard_durotar(Player* pPlayer, Creature* pCreature, uint32 uiS
     }
     return true;
 }
+
 /*******************************************************
  * guard_durotar end
  *******************************************************/
+
 CreatureAI* GetAI_guard_durotar(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_elwynnforest start
  *******************************************************/
+
 bool GossipHello_guard_elwynnforest(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK          , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -1001,6 +1056,7 @@ bool GossipHello_guard_elwynnforest(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(933, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_elwynnforest(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1050,6 +1106,7 @@ void SendDefaultMenu_guard_elwynnforest(Player* pPlayer, Creature* pCreature, ui
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_elwynnforest(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1086,6 +1143,7 @@ void SendClassTrainerMenu_guard_elwynnforest(Player* pPlayer, Creature* pCreatur
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_elwynnforest(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1141,6 +1199,7 @@ void SendProfTrainerMenu_guard_elwynnforest(Player* pPlayer, Creature* pCreature
             break;
     }
 }
+
 bool GossipSelect_guard_elwynnforest(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -1151,16 +1210,20 @@ bool GossipSelect_guard_elwynnforest(Player* pPlayer, Creature* pCreature, uint3
     }
     return true;
 }
+
 /*******************************************************
  * guard_elwynnforest end
  *******************************************************/
+
 CreatureAI* GetAI_guard_elwynnforest(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_eversong start
  *******************************************************/
+
 bool GossipHello_guard_eversong(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BATHANDLER    , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -1172,6 +1235,7 @@ bool GossipHello_guard_eversong(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(10180, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_eversong(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1219,6 +1283,7 @@ void SendDefaultMenu_guard_eversong(Player* pPlayer, Creature* pCreature, uint32
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_eversong(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1252,6 +1317,7 @@ void SendClassTrainerMenu_guard_eversong(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_eversong(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1307,6 +1373,7 @@ void SendProfTrainerMenu_guard_eversong(Player* pPlayer, Creature* pCreature, ui
             break;
     }
 }
+
 bool GossipSelect_guard_eversong(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -1317,16 +1384,20 @@ bool GossipSelect_guard_eversong(Player* pPlayer, Creature* pCreature, uint32 ui
     }
     return true;
 }
+
 /*******************************************************
  * guard_eversong end
  *******************************************************/
+
 CreatureAI* GetAI_guard_eversong(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_exodar start
  *******************************************************/
+
 bool GossipHello_guard_exodar(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_AUCTIONHOUSE   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -1343,6 +1414,7 @@ bool GossipHello_guard_exodar(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(9551, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_exodar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1416,6 +1488,7 @@ void SendDefaultMenu_guard_exodar(Player* pPlayer, Creature* pCreature, uint32 u
             break;
     }
 }
+
 void SendBattleMasterMenu_guard_exodar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1442,6 +1515,7 @@ void SendBattleMasterMenu_guard_exodar(Player* pPlayer, Creature* pCreature, uin
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_exodar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1476,6 +1550,7 @@ void SendClassTrainerMenu_guard_exodar(Player* pPlayer, Creature* pCreature, uin
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_exodar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1538,6 +1613,7 @@ void SendProfTrainerMenu_guard_exodar(Player* pPlayer, Creature* pCreature, uint
             break;
     }
 }
+
 bool GossipSelect_guard_exodar(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -1549,16 +1625,20 @@ bool GossipSelect_guard_exodar(Player* pPlayer, Creature* pCreature, uint32 uiSe
     }
     return true;
 }
+
 /*******************************************************
  * guard_exodar end
  *******************************************************/
+
 CreatureAI* GetAI_guard_exodar(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_ironforge start
  *******************************************************/
+
 bool GossipHello_guard_ironforge(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_AUCTIONHOUSE      , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -1576,6 +1656,7 @@ bool GossipHello_guard_ironforge(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(2760, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_ironforge(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1651,6 +1732,7 @@ void SendDefaultMenu_guard_ironforge(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendBattleMasterMenu_guard_ironforge(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1669,6 +1751,7 @@ void SendBattleMasterMenu_guard_ironforge(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_ironforge(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1708,6 +1791,7 @@ void SendClassTrainerMenu_guard_ironforge(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_ironforge(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1766,6 +1850,7 @@ void SendProfTrainerMenu_guard_ironforge(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 bool GossipSelect_guard_ironforge(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -1777,16 +1862,20 @@ bool GossipSelect_guard_ironforge(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*******************************************************
  * guard_ironforge end
  *******************************************************/
+
 CreatureAI* GetAI_guard_ironforge(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_mulgore start
  *******************************************************/
+
 bool GossipHello_guard_mulgore(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK         , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -1798,6 +1887,7 @@ bool GossipHello_guard_mulgore(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(3543, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_mulgore(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1840,6 +1930,7 @@ void SendDefaultMenu_guard_mulgore(Player* pPlayer, Creature* pCreature, uint32
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_mulgore(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1862,6 +1953,7 @@ void SendClassTrainerMenu_guard_mulgore(Player* pPlayer, Creature* pCreature, ui
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_mulgore(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -1909,6 +2001,7 @@ void SendProfTrainerMenu_guard_mulgore(Player* pPlayer, Creature* pCreature, uin
             break;
     }
 }
+
 bool GossipSelect_guard_mulgore(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -1919,16 +2012,20 @@ bool GossipSelect_guard_mulgore(Player* pPlayer, Creature* pCreature, uint32 uiS
     }
     return true;
 }
+
 /*******************************************************
  * guard_mulgore end
  *******************************************************/
+
 CreatureAI* GetAI_guard_mulgore(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_orgrimmar start
  *******************************************************/
+
 bool GossipHello_guard_orgrimmar(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK          , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -1945,8 +2042,10 @@ bool GossipHello_guard_orgrimmar(Player* pPlayer, Creature* pCreature)
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_CLASSTRAINER  , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_PROFTRAINER   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13);
     pPlayer->SEND_GOSSIP_MENU(2593, pCreature->GetGUID());
+
     return true;
 }
+
 void SendDefaultMenu_guard_orgrimmar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2026,6 +2125,7 @@ void SendDefaultMenu_guard_orgrimmar(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendBattleMasterMenu_guard_orgrimmar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2044,6 +2144,7 @@ void SendBattleMasterMenu_guard_orgrimmar(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_orgrimmar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2082,6 +2183,7 @@ void SendClassTrainerMenu_guard_orgrimmar(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_orgrimmar(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2140,6 +2242,7 @@ void SendProfTrainerMenu_guard_orgrimmar(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 bool GossipSelect_guard_orgrimmar(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -2151,16 +2254,20 @@ bool GossipSelect_guard_orgrimmar(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*******************************************************
  * guard_orgrimmar end
  *******************************************************/
+
 CreatureAI* GetAI_guard_orgrimmar(Creature* pCreature)
 {
     return new guardAI_orgrimmar (pCreature);
 }
+
 /*******************************************************
  * guard_shattrath start
  *******************************************************/
+
 bool GossipHello_guard_shattrath(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_TAVERN                       , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -2175,8 +2282,10 @@ bool GossipHello_guard_shattrath(Player* pPlayer, Creature* pCreature)
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_ALCHEMYLAB                   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10);
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_GEMMERCHANT                  , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11);
     pPlayer->SEND_GOSSIP_MENU(10321, pCreature->GetGUID());
+
     return true;
 }
+
 void SendDefaultMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2243,6 +2352,7 @@ void SendDefaultMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendBankMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -2256,6 +2366,7 @@ void SendBankMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 u
         pPlayer->SEND_GOSSIP_MENU(10381, pCreature->GetGUID());
     }
 }
+
 void SendInnMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -2269,6 +2380,7 @@ void SendInnMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 ui
         pPlayer->SEND_GOSSIP_MENU(10384, pCreature->GetGUID());
     }
 }
+
 void SendMailboxMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2291,6 +2403,7 @@ void SendMailboxMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendStableMasterMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -2304,6 +2417,7 @@ void SendStableMasterMenu_guard_shattrath(Player* pPlayer, Creature* pCreature,
         pPlayer->SEND_GOSSIP_MENU(10321, pCreature->GetGUID());
     }
 }
+
 void SendBattleMasterMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2322,6 +2436,7 @@ void SendBattleMasterMenu_guard_shattrath(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2360,6 +2475,7 @@ void SendProfTrainerMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 void SendGemMerchantMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -2373,6 +2489,7 @@ void SendGemMerchantMenu_guard_shattrath(Player* pPlayer, Creature* pCreature, u
         pPlayer->SEND_GOSSIP_MENU(10699, pCreature->GetGUID());
     }
 }
+
 bool GossipSelect_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -2388,27 +2505,34 @@ bool GossipSelect_guard_shattrath(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*******************************************************
  * guard_shattrath end
  *******************************************************/
+
 CreatureAI* GetAI_guard_shattrath(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * 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 TRINITY_DLL_DECL guard_shattrath_aldorAI : public guardAI
 {
     guard_shattrath_aldorAI(Creature *c) : guardAI(c) {}
+
     uint32 Exile_Timer;
     uint32 Banish_Timer;
     uint64 PlayerGUID;
     bool CanTeleport;
+
     void Reset()
     {
         Banish_Timer = 5000;
@@ -2416,11 +2540,14 @@ struct TRINITY_DLL_DECL guard_shattrath_aldorAI : public guardAI
         PlayerGUID = 0;
         CanTeleport = false;
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (CanTeleport)
         {
             if (Exile_Timer < diff)
@@ -2447,9 +2574,11 @@ struct TRINITY_DLL_DECL guard_shattrath_aldorAI : public guardAI
                     CanTeleport = true;
             }
         }else Banish_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 bool GossipHello_guard_shattrath_aldor(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_TAVERN                       , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -2466,6 +2595,7 @@ bool GossipHello_guard_shattrath_aldor(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(10524, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_shattrath_aldor(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2526,6 +2656,7 @@ void SendDefaultMenu_guard_shattrath_aldor(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_shattrath_aldor(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2564,6 +2695,7 @@ void SendProfTrainerMenu_guard_shattrath_aldor(Player* pPlayer, Creature* pCreat
             break;
     }
 }
+
 bool GossipSelect_guard_shattrath_aldor(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -2574,23 +2706,29 @@ bool GossipSelect_guard_shattrath_aldor(Player* pPlayer, Creature* pCreature, ui
     }
     return true;
 }
+
 /*******************************************************
  * guard_shattrath_aldor end
  *******************************************************/
+
 CreatureAI* GetAI_guard_shattrath_aldor(Creature* pCreature)
 {
     return new guard_shattrath_aldorAI (pCreature);
 }
+
 /*******************************************************
  * guard_shattrath_scryer
  *******************************************************/
+
 struct TRINITY_DLL_DECL guard_shattrath_scryerAI : public guardAI
 {
     guard_shattrath_scryerAI(Creature *c) : guardAI(c) {}
+
     uint32 Exile_Timer;
     uint32 Banish_Timer;
     uint64 PlayerGUID;
     bool CanTeleport;
+
     void Reset()
     {
         Banish_Timer = 5000;
@@ -2598,11 +2736,14 @@ struct TRINITY_DLL_DECL guard_shattrath_scryerAI : public guardAI
         PlayerGUID = 0;
         CanTeleport = false;
     }
+
     void EnterCombat(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (CanTeleport)
         {
             if (Exile_Timer < diff)
@@ -2629,9 +2770,11 @@ struct TRINITY_DLL_DECL guard_shattrath_scryerAI : public guardAI
                     CanTeleport = true;
             }
         }else Banish_Timer -= diff;
+
         DoMeleeAttackIfReady();
     }
 };
+
 bool GossipHello_guard_shattrath_scryer(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_TAVERN                       , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -2648,6 +2791,7 @@ bool GossipHello_guard_shattrath_scryer(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(10430, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_shattrath_scryer(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2707,6 +2851,7 @@ void SendDefaultMenu_guard_shattrath_scryer(Player* pPlayer, Creature* pCreature
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_shattrath_scryer(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2745,6 +2890,7 @@ void SendProfTrainerMenu_guard_shattrath_scryer(Player* pPlayer, Creature* pCrea
             break;
     }
 }
+
 bool GossipSelect_guard_shattrath_scryer(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -2755,16 +2901,20 @@ bool GossipSelect_guard_shattrath_scryer(Player* pPlayer, Creature* pCreature, u
     }
     return true;
 }
+
 /*******************************************************
  * guard_shattrath_scryer end
  *******************************************************/
+
 CreatureAI* GetAI_guard_shattrath_scryer(Creature* pCreature)
 {
     return new guard_shattrath_scryerAI (pCreature);
 }
+
 /*******************************************************
  * guard_silvermoon start
  *******************************************************/
+
 bool GossipHello_guard_silvermoon(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_AUCTIONHOUSE   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -2781,6 +2931,7 @@ bool GossipHello_guard_silvermoon(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(9316, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2856,6 +3007,7 @@ void SendDefaultMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint
             break;
     }
 }
+
 void SendAuctionhouseMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -2869,6 +3021,7 @@ void SendAuctionhouseMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature,
         pPlayer->SEND_GOSSIP_MENU(9319, pCreature->GetGUID());
     }
 }
+
 void SendInnMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
@@ -2882,6 +3035,7 @@ void SendInnMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32 u
         pPlayer->SEND_GOSSIP_MENU(9603, pCreature->GetGUID());
     }
 }
+
 void SendBattleMasterMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2908,6 +3062,7 @@ void SendBattleMasterMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -2942,6 +3097,7 @@ void SendClassTrainerMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3004,6 +3160,7 @@ void SendProfTrainerMenu_guard_silvermoon(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 bool GossipSelect_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -3017,16 +3174,20 @@ bool GossipSelect_guard_silvermoon(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*******************************************************
  * guard_silvermoon end
  *******************************************************/
+
 CreatureAI* GetAI_guard_silvermoon(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_stormwind start
  *******************************************************/
+
 bool GossipHello_guard_stormwind(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_AUCTIONHOUSE      , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -3045,6 +3206,7 @@ bool GossipHello_guard_stormwind(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(933, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_stormwind(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3125,6 +3287,7 @@ void SendDefaultMenu_guard_stormwind(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendBattleMasterMenu_guard_stormwind(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3143,6 +3306,7 @@ void SendBattleMasterMenu_guard_stormwind(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_stormwind(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3186,6 +3350,7 @@ void SendClassTrainerMenu_guard_stormwind(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_stormwind(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3244,6 +3409,7 @@ void SendProfTrainerMenu_guard_stormwind(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 bool GossipSelect_guard_stormwind(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -3255,16 +3421,20 @@ bool GossipSelect_guard_stormwind(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*******************************************************
  * guard_stormwind end
  *******************************************************/
+
 CreatureAI* GetAI_guard_stormwind(Creature* pCreature)
 {
     return new guardAI_stormwind (pCreature);
 }
+
 /*******************************************************
  * guard_teldrassil start
  *******************************************************/
+
 bool GossipHello_guard_teldrassil(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK         , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -3277,6 +3447,7 @@ bool GossipHello_guard_teldrassil(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(4316, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_teldrassil(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3321,6 +3492,7 @@ void SendDefaultMenu_guard_teldrassil(Player* pPlayer, Creature* pCreature, uint
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_teldrassil(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3347,6 +3519,7 @@ void SendClassTrainerMenu_guard_teldrassil(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_teldrassil(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3390,6 +3563,7 @@ void SendProfTrainerMenu_guard_teldrassil(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 bool GossipSelect_guard_teldrassil(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -3400,16 +3574,20 @@ bool GossipSelect_guard_teldrassil(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*******************************************************
  * guard_teldrassil end
  *******************************************************/
+
 CreatureAI* GetAI_guard_teldrassil(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_tirisfal start
  *******************************************************/
+
 bool GossipHello_guard_tirisfal(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK            , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -3421,6 +3599,7 @@ bool GossipHello_guard_tirisfal(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(4097, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_tirisfal(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3465,6 +3644,7 @@ void SendDefaultMenu_guard_tirisfal(Player* pPlayer, Creature* pCreature, uint32
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_tirisfal(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3491,6 +3671,7 @@ void SendClassTrainerMenu_guard_tirisfal(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_tirisfal(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3544,6 +3725,7 @@ void SendProfTrainerMenu_guard_tirisfal(Player* pPlayer, Creature* pCreature, ui
             break;
     }
 }
+
 bool GossipSelect_guard_tirisfal(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -3554,16 +3736,20 @@ bool GossipSelect_guard_tirisfal(Player* pPlayer, Creature* pCreature, uint32 ui
     }
     return true;
 }
+
 /*******************************************************
  * guard_tirisfal end
  *******************************************************/
+
 CreatureAI* GetAI_guard_tirisfal(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * guard_undercity start
  *******************************************************/
+
 bool GossipHello_guard_undercity(Player* pPlayer, Creature* pCreature)
 {
     pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TEXT_BANK          , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
@@ -3581,6 +3767,7 @@ bool GossipHello_guard_undercity(Player* pPlayer, Creature* pCreature)
     pPlayer->SEND_GOSSIP_MENU(3543, pCreature->GetGUID());
     return true;
 }
+
 void SendDefaultMenu_guard_undercity(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3652,6 +3839,7 @@ void SendDefaultMenu_guard_undercity(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendBattleMasterMenu_guard_undercity(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3670,6 +3858,7 @@ void SendBattleMasterMenu_guard_undercity(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendClassTrainerMenu_guard_undercity(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3696,6 +3885,7 @@ void SendClassTrainerMenu_guard_undercity(Player* pPlayer, Creature* pCreature,
             break;
     }
 }
+
 void SendProfTrainerMenu_guard_undercity(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch (uiAction)
@@ -3750,6 +3940,7 @@ void SendProfTrainerMenu_guard_undercity(Player* pPlayer, Creature* pCreature, u
             break;
     }
 }
+
 bool GossipSelect_guard_undercity(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch (uiSender)
@@ -3761,131 +3952,155 @@ bool GossipSelect_guard_undercity(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*******************************************************
  * guard_undercity end
  *******************************************************/
+
 CreatureAI* GetAI_guard_undercity(Creature* pCreature)
 {
     return new guardAI (pCreature);
 }
+
 /*******************************************************
  * 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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_bluffwatcher";
     newscript->pGossipHello          = &GossipHello_guard_bluffwatcher;
     newscript->pGossipSelect         = &GossipSelect_guard_bluffwatcher;
     newscript->GetAI = &GetAI_guard_bluffwatcher;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_contested";
     newscript->GetAI = &GetAI_guard_contested;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_darnassus";
     newscript->pGossipHello          = &GossipHello_guard_darnassus;
     newscript->pGossipSelect         = &GossipSelect_guard_darnassus;
     newscript->GetAI = &GetAI_guard_darnassus;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_dunmorogh";
     newscript->pGossipHello          = &GossipHello_guard_dunmorogh;
     newscript->pGossipSelect         = &GossipSelect_guard_dunmorogh;
     newscript->GetAI = &GetAI_guard_dunmorogh;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_durotar";
     newscript->pGossipHello          = &GossipHello_guard_durotar;
     newscript->pGossipSelect         = &GossipSelect_guard_durotar;
     newscript->GetAI = &GetAI_guard_durotar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_elwynnforest";
     newscript->pGossipHello          = &GossipHello_guard_elwynnforest;
     newscript->pGossipSelect         = &GossipSelect_guard_elwynnforest;
     newscript->GetAI = &GetAI_guard_elwynnforest;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_eversong";
     newscript->pGossipHello          = &GossipHello_guard_eversong;
     newscript->pGossipSelect         = &GossipSelect_guard_eversong;
     newscript->GetAI = &GetAI_guard_eversong;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_exodar";
     newscript->pGossipHello          = &GossipHello_guard_exodar;
     newscript->pGossipSelect         = &GossipSelect_guard_exodar;
     newscript->GetAI = &GetAI_guard_exodar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_ironforge";
     newscript->pGossipHello          = &GossipHello_guard_ironforge;
     newscript->pGossipSelect         = &GossipSelect_guard_ironforge;
     newscript->GetAI = &GetAI_guard_ironforge;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_mulgore";
     newscript->pGossipHello          = &GossipHello_guard_mulgore;
     newscript->pGossipSelect         = &GossipSelect_guard_mulgore;
     newscript->GetAI = &GetAI_guard_mulgore;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_orgrimmar";
     newscript->pGossipHello          = &GossipHello_guard_orgrimmar;
     newscript->pGossipSelect         = &GossipSelect_guard_orgrimmar;
     newscript->GetAI = &GetAI_guard_orgrimmar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_shattrath";
     newscript->pGossipHello          = &GossipHello_guard_shattrath;
     newscript->pGossipSelect         = &GossipSelect_guard_shattrath;
     newscript->GetAI = &GetAI_guard_shattrath;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_silvermoon";
     newscript->pGossipHello          = &GossipHello_guard_silvermoon;
     newscript->pGossipSelect         = &GossipSelect_guard_silvermoon;
     newscript->GetAI = &GetAI_guard_silvermoon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_stormwind";
     newscript->pGossipHello          = &GossipHello_guard_stormwind;
     newscript->pGossipSelect         = &GossipSelect_guard_stormwind;
     newscript->GetAI = &GetAI_guard_stormwind;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_teldrassil";
     newscript->pGossipHello          = &GossipHello_guard_teldrassil;
     newscript->pGossipSelect         = &GossipSelect_guard_teldrassil;
     newscript->GetAI = &GetAI_guard_teldrassil;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_tirisfal";
     newscript->pGossipHello          = &GossipHello_guard_tirisfal;
     newscript->pGossipSelect         = &GossipSelect_guard_tirisfal;
     newscript->GetAI = &GetAI_guard_tirisfal;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "guard_undercity";
     newscript->pGossipHello          = &GossipHello_guard_undercity;
diff --git a/src/bindings/scripts/scripts/world/item_scripts.cpp b/src/bindings/scripts/scripts/world/item_scripts.cpp
index b1f04f67e56..0e0f5795be9 100644
--- a/src/bindings/scripts/scripts/world/item_scripts.cpp
+++ b/src/bindings/scripts/scripts/world/item_scripts.cpp
@@ -13,12 +13,14 @@
  * along 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_draenei_fishing_net(i23654)    Hacklike implements chance to spawn item or creature
 item_nether_wraith_beacon(i31742)   Summons creatures for quest Becoming a Spellfire Tailor (q10832)
@@ -26,19 +28,24 @@ item_flying_machine(i34060,i34061)  Engineering crafted flying machines
 item_gor_dreks_ointment(i30175)     Protecting Our Own(q10488)
 item_only_for_flight                Items which should only useable while flying
 EndContentData */
+
 #include "precompiled.h"
 #include "Spell.h"
+
 /*#####
 # item_only_for_flight
 #####*/
+
 enum eOnlyForFlight
 {
     SPELL_ARCANE_CHARGES    = 45072
 };
+
 bool ItemUse_item_only_for_flight(Player* pPlayer, Item* _Item, SpellCastTargets const& targets)
 {
     uint32 itemId = _Item->GetEntry();
     bool disabled = false;
+
     //for special scripts
     switch(itemId)
     {
@@ -55,16 +62,20 @@ bool ItemUse_item_only_for_flight(Player* pPlayer, Item* _Item, SpellCastTargets
                 Spell::SendCastResult(pPlayer, pSpellInfo, 1, SPELL_FAILED_NOT_ON_GROUND);
                 break;
     }
+
     // allow use in flight only
     if (pPlayer->isInFlight() && !disabled)
         return false;
+
     // error
     pPlayer->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_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* pPlayer, Item* _Item, SpellCastTargets const& targets)
@@ -96,9 +107,11 @@ bool ItemUse_item_draenei_fishing_net(Player* pPlayer, Item* _Item, SpellCastTar
     //}
     return false;
 }
+
 /*#####
 # item_nether_wraith_beacon
 #####*/
+
 bool ItemUse_item_nether_wraith_beacon(Player* pPlayer, Item* _Item, SpellCastTargets const& targets)
 {
     if (pPlayer->GetQuestStatus(10832) == QUEST_STATUS_INCOMPLETE)
@@ -111,36 +124,45 @@ bool ItemUse_item_nether_wraith_beacon(Player* pPlayer, Item* _Item, SpellCastTa
     }
     return false;
 }
+
 /*#####
 # item_flying_machine
 #####*/
+
 bool ItemUse_item_flying_machine(Player* pPlayer, Item* _Item, SpellCastTargets const& targets)
 {
     uint32 itemId = _Item->GetEntry();
     if (itemId == 34060)
         if (pPlayer->GetBaseSkillValue(SKILL_RIDING) >= 225)
             return false;
+
     if (itemId == 34061)
         if (pPlayer->GetBaseSkillValue(SKILL_RIDING) == 300)
             return false;
+
     debug_log("TSCR: Player attempt to use item %u, but did not meet riding requirement",itemId);
     pPlayer->SendEquipError(EQUIP_ERR_ERR_CANT_EQUIP_SKILL,_Item,NULL);
     return true;
 }
+
 /*#####
 # item_gor_dreks_ointment
 #####*/
+
 bool ItemUse_item_gor_dreks_ointment(Player* pPlayer, Item* _Item, SpellCastTargets const& targets)
 {
     if (targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT &&
         targets.getUnitTarget()->GetEntry() == 20748 && !targets.getUnitTarget()->HasAura(32578))
         return false;
+
     pPlayer->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL);
     return true;
 }
+
 /*#####
 # item_incendiary_explosives
 #####*/
+
 bool ItemUse_item_incendiary_explosives(Player* pPlayer, Item* _Item, SpellCastTargets const& targets)
 {
     if (pPlayer->FindNearestCreature(26248,15) || pPlayer->FindNearestCreature(26249,15))
@@ -153,9 +175,11 @@ bool ItemUse_item_incendiary_explosives(Player* pPlayer, Item* _Item, SpellCastT
         return true;
     }
 }
+
 /*#####
 # item_mysterious_egg
 #####*/
+
 bool ItemExpire_item_mysterious_egg(Player* pPlayer, ItemPrototype const * _ItemProto)
 {
     ItemPosCountVec dest;
@@ -166,9 +190,11 @@ bool ItemExpire_item_mysterious_egg(Player* pPlayer, ItemPrototype const * _Item
     }
     return true;
 }
+
 /*#####
 # item_disgusting_jar
 #####*/
+
 bool ItemExpire_item_disgusting_jar(Player* pPlayer, ItemPrototype const * _ItemProto)
 {
     ItemPosCountVec dest;
@@ -179,6 +205,7 @@ bool ItemExpire_item_disgusting_jar(Player* pPlayer, ItemPrototype const * _Item
     }
     return true;
 }
+
 /*#####
 # item_harvesters_gift
 #####*/
@@ -187,6 +214,7 @@ bool ItemUse_item_harvesters_gift(Player* pPlayer, Item* _Item, SpellCastTargets
 {
     std::list MinionList;
     pPlayer->GetAllMinionsByEntry(MinionList,GHOULS);
+
     if (pPlayer->GetQuestStatus(12698) == QUEST_STATUS_INCOMPLETE)
     {
         if (!MinionList.empty())
@@ -209,41 +237,51 @@ bool ItemUse_item_harvesters_gift(Player* pPlayer, Item* _Item, SpellCastTargets
         return true;
     }
 }
+
 void AddSC_item_scripts()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "item_only_for_flight";
     newscript->pItemUse = &ItemUse_item_only_for_flight;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_draenei_fishing_net";
     newscript->pItemUse = &ItemUse_item_draenei_fishing_net;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_nether_wraith_beacon";
     newscript->pItemUse = &ItemUse_item_nether_wraith_beacon;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_flying_machine";
     newscript->pItemUse = &ItemUse_item_flying_machine;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_gor_dreks_ointment";
     newscript->pItemUse = &ItemUse_item_gor_dreks_ointment;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_incendiary_explosives";
     newscript->pItemUse = &ItemUse_item_incendiary_explosives;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_mysterious_egg";
     newscript->pItemExpire = &ItemExpire_item_mysterious_egg;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_disgusting_jar";
     newscript->pItemExpire = &ItemExpire_item_disgusting_jar;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "item_harvesters_gift";
     newscript->pItemUse = &ItemUse_item_harvesters_gift;
diff --git a/src/bindings/scripts/scripts/world/mob_generic_creature.cpp b/src/bindings/scripts/scripts/world/mob_generic_creature.cpp
index 6c398779410..45807337f5e 100644
--- a/src/bindings/scripts/scripts/world/mob_generic_creature.cpp
+++ b/src/bindings/scripts/scripts/world/mob_generic_creature.cpp
@@ -13,26 +13,33 @@
 * along 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 TRINITY_DLL_DECL generic_creatureAI : public ScriptedAI
 {
     generic_creatureAI(Creature *c) : ScriptedAI(c) {}
+
     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 EnterCombat(Unit *who)
     {
         if (!m_creature->IsWithinMeleeRange(who))
@@ -40,32 +47,39 @@ struct TRINITY_DLL_DECL generic_creatureAI : public ScriptedAI
             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 (!m_creature->isInCombat() && 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 (!UpdateVictim())
             return;
+
         //If we are within range melee the target
         if (m_creature->IsWithinMeleeRange(m_creature->getVictim()))
         {
@@ -74,22 +88,27 @@ struct TRINITY_DLL_DECL generic_creatureAI : public ScriptedAI
             {
                 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();
             }
         }
@@ -100,12 +119,15 @@ struct TRINITY_DLL_DECL generic_creatureAI : public ScriptedAI
             {
                 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, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE);
+
                 //Found a spell, check if we arn't on cooldown
                 if (info && !GlobalCooldown)
                 {
@@ -114,12 +136,15 @@ struct TRINITY_DLL_DECL generic_creatureAI : public ScriptedAI
                     {
                         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)
                 {
@@ -131,10 +156,12 @@ struct TRINITY_DLL_DECL generic_creatureAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_generic_creature(Creature* pCreature)
 {
     return new generic_creatureAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL trigger_periodicAI : public NullCreatureAI
 {
     trigger_periodicAI(Creature* c) : NullCreatureAI(c)
@@ -143,8 +170,10 @@ struct TRINITY_DLL_DECL trigger_periodicAI : public NullCreatureAI
         interval = me->GetAttackTime(BASE_ATTACK);
         timer = interval;
     }
+
     uint32 timer, interval;
     const SpellEntry * spell;
+
     void UpdateAI(const uint32 diff)
     {
         if (timer < diff)
@@ -157,6 +186,7 @@ struct TRINITY_DLL_DECL trigger_periodicAI : public NullCreatureAI
             timer -= diff;
     }
 };
+
 struct TRINITY_DLL_DECL trigger_deathAI : public NullCreatureAI
 {
     trigger_deathAI(Creature* c) : NullCreatureAI(c) {}
@@ -166,10 +196,13 @@ struct TRINITY_DLL_DECL trigger_deathAI : public NullCreatureAI
             me->CastSpell(killer, me->m_spells[0], true);
     }
 };
+
 struct TRINITY_DLL_DECL mob_webwrapAI : public NullCreatureAI
 {
     mob_webwrapAI(Creature *c) : NullCreatureAI(c), victimGUID(0) {}
+
     uint64 victimGUID;
+
     void SetGUID(const uint64 &guid, int32 param)
     {
         victimGUID = guid;
@@ -177,6 +210,7 @@ struct TRINITY_DLL_DECL mob_webwrapAI : public NullCreatureAI
             if (Unit *victim = Unit::GetUnit(*me, victimGUID))
                 victim->CastSpell(victim, me->m_spells[0], true, NULL, NULL, me->GetGUID());
     }
+
     void JustDied(Unit *killer)
     {
         if (me->m_spells[0] && victimGUID)
@@ -184,18 +218,22 @@ struct TRINITY_DLL_DECL mob_webwrapAI : public NullCreatureAI
                 victim->RemoveAurasDueToSpell(me->m_spells[0], me->GetGUID());
     }
 };
+
 CreatureAI* GetAI_trigger_periodic(Creature* pCreature)
 {
     return new trigger_periodicAI (pCreature);
 }
+
 CreatureAI* GetAI_trigger_death(Creature* pCreature)
 {
     return new trigger_deathAI (pCreature);
 }
+
 CreatureAI* GetAI_mob_webwrap(Creature* pCreature)
 {
     return new mob_webwrapAI (pCreature);
 }
+
 void AddSC_generic_creature()
 {
     Script *newscript;
@@ -203,14 +241,17 @@ void AddSC_generic_creature()
     newscript->Name = "generic_creature";
     newscript->GetAI = &GetAI_generic_creature;
     newscript->RegisterSelf();*/
+
     newscript = new Script;
     newscript->Name = "trigger_periodic";
     newscript->GetAI = &GetAI_trigger_periodic;
     newscript->RegisterSelf();
+
     /*newscript = new Script;
     newscript->Name = "trigger_death";
     newscript->GetAI = &GetAI_trigger_death;
     newscript->RegisterSelf();*/
+
     newscript = new Script;
     newscript->Name = "mob_webwrap";
     newscript->GetAI = &GetAI_mob_webwrap;
diff --git a/src/bindings/scripts/scripts/world/npc_innkeeper.cpp b/src/bindings/scripts/scripts/world/npc_innkeeper.cpp
index 865de42c0e8..da124eeb720 100644
--- a/src/bindings/scripts/scripts/world/npc_innkeeper.cpp
+++ b/src/bindings/scripts/scripts/world/npc_innkeeper.cpp
@@ -13,20 +13,25 @@
  * along 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()
 {
     /*
@@ -41,10 +46,12 @@ bool isEventActive()
      }*/
     return false;
 }
+
 bool GossipHello_npc_innkeeper(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (isEventActive()&& !pPlayer->GetAura(SPELL_TRICK_OR_TREATED, pPlayer->GetGUID()))
     {
         char* localizedEntry;
@@ -65,18 +72,22 @@ bool GossipHello_npc_innkeeper(Player* pPlayer, Creature* pCreature)
             default:
                 localizedEntry=LOCALE_TRICK_OR_TREAT_0;
         }
+
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, localizedEntry, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID);
     }
+
     pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_innkeeper(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID && isEventActive() && !pPlayer->GetAura(SPELL_TRICK_OR_TREATED, pPlayer->GetGUID()))
     {
         pPlayer->CLOSE_GOSSIP_MENU();
         pPlayer->CastSpell(pPlayer, SPELL_TRICK_OR_TREATED, true);
+
         // either trick or treat, 50% chance
         if (rand()%2)
         {
@@ -121,6 +132,7 @@ bool GossipSelect_npc_innkeeper(Player* pPlayer, Creature* pCreature, uint32 uiS
     }
     return false;                                           // the player didn't select "trick or treat" or cheated, normal core handling
 }
+
 void AddSC_npc_innkeeper()
 {
     Script *newscript;
diff --git a/src/bindings/scripts/scripts/world/npc_professions.cpp b/src/bindings/scripts/scripts/world/npc_professions.cpp
index 59b4f4c5ff4..484339c59bb 100644
--- a/src/bindings/scripts/scripts/world/npc_professions.cpp
+++ b/src/bindings/scripts/scripts/world/npc_professions.cpp
@@ -13,144 +13,186 @@
  * along 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* pPlayer)                           //tailor, alchemy
 {
     return 200000;
 }
+
 int32 DoHighUnlearnCost(Player* pPlayer)                     //tailor, alchemy
 {
     return 1500000;
 }
+
 int32 DoMedUnlearnCost(Player* pPlayer)                      //blacksmith, leatherwork
 {
     uint32 level = pPlayer->getLevel();
@@ -161,6 +203,7 @@ int32 DoMedUnlearnCost(Player* pPlayer)                      //blacksmith, leath
     else
         return 1000000;
 }
+
 int32 DoLowUnlearnCost(Player* pPlayer)                      //blacksmith
 {
     uint32 level = pPlayer->getLevel();
@@ -169,21 +212,26 @@ int32 DoLowUnlearnCost(Player* pPlayer)                      //blacksmith
     else
         return 100000;
 }
+
 /*###
 # unlearning related profession spells
 ###*/
+
 bool EquippedOk(Player* pPlayer, uint32 spellId)
 {
     SpellEntry const* spell = GetSpellStore()->LookupEntry(spellId);
+
     if (!spell)
         return false;
-    for (uint8 i=0; i<3; ++i)
+
+    for(uint8 i=0; i<3; ++i)
     {
         uint32 reqSpell = spell->EffectTriggerSpell[i];
         if (!reqSpell)
             continue;
+
         Item* pItem;
-        for (uint8 j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; j++)
+        for(uint8 j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; j++)
         {
             pItem = pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, j);
             if (pItem)
@@ -197,6 +245,7 @@ bool EquippedOk(Player* pPlayer, uint32 spellId)
     }
     return true;
 }
+
 void ProfessionUnlearnSpells(Player* pPlayer, uint32 type)
 {
     switch (type)
@@ -289,15 +338,18 @@ void ProfessionUnlearnSpells(Player* pPlayer, uint32 type)
             break;
     }
 }
+
 /*###
 # start menues alchemy
 ###*/
+
 bool HasAlchemySpell(Player* pPlayer)
 {
     if (pPlayer->HasSpell(S_TRANSMUTE) || pPlayer->HasSpell(S_ELIXIR) || pPlayer->HasSpell(S_POTION))
         return true;
     return false;
 }
+
 bool GossipHello_npc_prof_alchemy(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
@@ -306,7 +358,9 @@ bool GossipHello_npc_prof_alchemy(Player* pPlayer, Creature* pCreature)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
     if (pCreature->isTrainer())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
+
     uint32 eCreature = pCreature->GetEntry();
+
     if (pPlayer->HasSkill(SKILL_ALCHEMY) && pPlayer->GetBaseSkillValue(SKILL_ALCHEMY)>=350 && pPlayer->getLevel() > 67)
     {
         if (pPlayer->GetQuestRewardStatus(10899) || pPlayer->GetQuestRewardStatus(10902) || pPlayer->GetQuestRewardStatus(10897))
@@ -334,9 +388,11 @@ bool GossipHello_npc_prof_alchemy(Player* pPlayer, Creature* pCreature)
             }
         }
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 void SendActionMenu_npc_prof_alchemy(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch(uiAction)
@@ -405,6 +461,7 @@ void SendActionMenu_npc_prof_alchemy(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendConfirmLearn_npc_prof_alchemy(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction)
@@ -430,6 +487,7 @@ void SendConfirmLearn_npc_prof_alchemy(Player* pPlayer, Creature* pCreature, uin
         }
     }
 }
+
 void SendConfirmUnlearn_npc_prof_alchemy(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction)
@@ -455,6 +513,7 @@ void SendConfirmUnlearn_npc_prof_alchemy(Player* pPlayer, Creature* pCreature, u
         }
     }
 }
+
 bool GossipSelect_npc_prof_alchemy(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiSender)
@@ -466,15 +525,18 @@ bool GossipSelect_npc_prof_alchemy(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*###
 # start menues blacksmith
 ###*/
+
 bool HasWeaponSub(Player* pPlayer)
 {
     if (pPlayer->HasSpell(S_HAMMER) || pPlayer->HasSpell(S_AXE) || pPlayer->HasSpell(S_SWORD))
         return true;
     return false;
 }
+
 bool GossipHello_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
@@ -483,6 +545,7 @@ bool GossipHello_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
     if (pCreature->isTrainer())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
+
     uint32 eCreature = pCreature->GetEntry();
     //WEAPONSMITH & ARMORSMITH
     if (pPlayer->GetBaseSkillValue(SKILL_BLACKSMITHING)>=225)
@@ -533,9 +596,11 @@ bool GossipHello_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature)
                 break;
         }
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 void SendActionMenu_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch(uiAction)
@@ -661,6 +726,7 @@ void SendActionMenu_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature, ui
             break;
     }
 }
+
 void SendConfirmLearn_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction)
@@ -686,6 +752,7 @@ void SendConfirmLearn_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature,
         }
     }
 }
+
 void SendConfirmUnlearn_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction)
@@ -701,6 +768,7 @@ void SendConfirmUnlearn_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature
                                                             //unknown textID (TALK_UNLEARN_AXEORWEAPON)
                 pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
                 break;
+
             case 11191:
                 pPlayer->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_CHECK, uiAction,    BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(pPlayer),false);
                                                             //unknown textID (TALK_HAMMER_UNLEARN)
@@ -719,6 +787,7 @@ void SendConfirmUnlearn_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature
         }
     }
 }
+
 bool GossipSelect_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiSender)
@@ -730,43 +799,54 @@ bool GossipSelect_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature, uint
     }
     return true;
 }
+
 /*bool QuestComplete_npc_prof_blacksmith(Player* pPlayer, Creature* pCreature, Quest const *_Quest)
 {
     if ((_Quest->GetQuestId() == 5283) || (_Quest->GetQuestId() == 5301))             //armorsmith
         pCreature->CastSpell(pPlayer, 17451, true);
+
     if ((_Quest->GetQuestId() == 5284) || (_Quest->GetQuestId() == 5302))             //weaponsmith
         pCreature->CastSpell(pPlayer, 17452, true);
+
     return true;
 }*/
+
 /*###
 # engineering trinkets
 ###*/
+
 enum eEngineeringTrinkets
 {
     NPC_ZAP                     = 14742,
     NPC_JHORDY                  = 14743,
     NPC_KABLAM                  = 21493,
     NPC_SMILES                  = 21494,
+
     SPELL_LEARN_TO_EVERLOOK     = 23490,
     SPELL_LEARN_TO_GADGET       = 23491,
     SPELL_LEARN_TO_AREA52       = 36956,
     SPELL_LEARN_TO_TOSHLEY      = 36957,
+
     SPELL_TO_EVERLOOK           = 23486,
     SPELL_TO_GADGET             = 23489,
     SPELL_TO_AREA52             = 36954,
     SPELL_TO_TOSHLEY            = 36955,
+
     ITEM_GNOMISH_CARD           = 10790,
     ITEM_GOBLIN_CARD            = 10791
 };
+
 #define GOSSIP_ITEM_ZAP         "[PH] Unknown"
 #define GOSSIP_ITEM_JHORDY      "I must build a beacon for this marvelous device!"
 #define GOSSIP_ITEM_KABLAM      "[PH] Unknown"
 #define GOSSIP_ITEM_SMILES      "[PH] Unknown"
+
 bool GossipHello_npc_engineering_tele_trinket(Player* pPlayer, Creature* pCreature)
 {
     uint32 NpcTextId = 0;
     std::string GossipItem;
     bool CanLearn = false;
+
     if (pPlayer->HasSkill(SKILL_ENGINERING))
     {
         switch(pCreature->GetEntry())
@@ -825,20 +905,25 @@ bool GossipHello_npc_engineering_tele_trinket(Player* pPlayer, Creature* pCreatu
                 break;
         }
     }
+
     if (CanLearn)
     {
         if (pPlayer->HasItemCount(ITEM_GOBLIN_CARD,1) || pPlayer->HasItemCount(ITEM_GNOMISH_CARD,1))
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GossipItem, pCreature->GetEntry(), GOSSIP_ACTION_INFO_DEF+1);
     }
+
     pPlayer->SEND_GOSSIP_MENU(NpcTextId ? NpcTextId : pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_engineering_tele_trinket(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
         pPlayer->CLOSE_GOSSIP_MENU();
+
     if (uiSender != pCreature->GetEntry())
         return true;
+
     switch(uiSender)
     {
         case NPC_ZAP:
@@ -854,11 +939,14 @@ bool GossipSelect_npc_engineering_tele_trinket(Player* pPlayer, Creature* pCreat
             pPlayer->CastSpell(pPlayer, SPELL_LEARN_TO_TOSHLEY, false);
             break;
     }
+
     return true;
 }
+
 /*###
 # start menues leatherworking
 ###*/
+
 bool GossipHello_npc_prof_leather(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
@@ -867,7 +955,9 @@ bool GossipHello_npc_prof_leather(Player* pPlayer, Creature* pCreature)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
     if (pCreature->isTrainer())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
+
     uint32 eCreature = pCreature->GetEntry();
+
     if (pPlayer->HasSkill(SKILL_LEATHERWORKING) && pPlayer->GetBaseSkillValue(SKILL_LEATHERWORKING)>=250 && pPlayer->getLevel() > 49)
     {
         switch (eCreature)
@@ -889,9 +979,11 @@ bool GossipHello_npc_prof_leather(Player* pPlayer, Creature* pCreature)
                 break;
         }
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 void SendActionMenu_npc_prof_leather(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch(uiAction)
@@ -947,6 +1039,7 @@ void SendActionMenu_npc_prof_leather(Player* pPlayer, Creature* pCreature, uint3
             break;
     }
 }
+
 void SendConfirmUnlearn_npc_prof_leather(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction)
@@ -975,6 +1068,7 @@ void SendConfirmUnlearn_npc_prof_leather(Player* pPlayer, Creature* pCreature, u
         }
     }
 }
+
 bool GossipSelect_npc_prof_leather(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiSender)
@@ -985,15 +1079,18 @@ bool GossipSelect_npc_prof_leather(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*###
 # start menues tailoring
 ###*/
+
 bool HasTailorSpell(Player* pPlayer)
 {
     if (pPlayer->HasSpell(S_MOONCLOTH) || pPlayer->HasSpell(S_SHADOWEAVE) || pPlayer->HasSpell(S_SPELLFIRE))
         return true;
     return false;
 }
+
 bool GossipHello_npc_prof_tailor(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
@@ -1002,6 +1099,7 @@ bool GossipHello_npc_prof_tailor(Player* pPlayer, Creature* pCreature)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
     if (pCreature->isTrainer())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
+
     uint32 eCreature = pCreature->GetEntry();
                                                             //TAILORING SPEC
     if (pPlayer->HasSkill(SKILL_TAILORING) && pPlayer->GetBaseSkillValue(SKILL_TAILORING)>=350 && pPlayer->getLevel() > 59)
@@ -1031,9 +1129,11 @@ bool GossipHello_npc_prof_tailor(Player* pPlayer, Creature* pCreature)
             }
         }
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 void SendActionMenu_npc_prof_tailor(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch(uiAction)
@@ -1117,6 +1217,7 @@ void SendActionMenu_npc_prof_tailor(Player* pPlayer, Creature* pCreature, uint32
             break;
     }
 }
+
 void SendConfirmLearn_npc_prof_tailor(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction)
@@ -1142,6 +1243,7 @@ void SendConfirmLearn_npc_prof_tailor(Player* pPlayer, Creature* pCreature, uint
         }
     }
 }
+
 void SendConfirmUnlearn_npc_prof_tailor(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     if (uiAction)
@@ -1167,6 +1269,7 @@ void SendConfirmUnlearn_npc_prof_tailor(Player* pPlayer, Creature* pCreature, ui
         }
     }
 }
+
 bool GossipSelect_npc_prof_tailor(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiSender)
@@ -1178,46 +1281,58 @@ bool GossipSelect_npc_prof_tailor(Player* pPlayer, Creature* pCreature, uint32 u
     }
     return true;
 }
+
 /*###
 # start menues for GO (engineering and leatherworking)
 ###*/
+
 /*bool GOHello_go_soothsaying_for_dummies(Player* pPlayer, GameObject* pGo)
 {
     pPlayer->PlayerTalkClass->GetGossipMenu()->AddMenuItem(0,GOSSIP_LEARN_DRAGON, GOSSIP_SENDER_INFO, GOSSIP_ACTION_INFO_DEF, "", 0);
+
     pPlayer->SEND_GOSSIP_MENU(5584, pGo->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;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_prof_blacksmith";
     newscript->pGossipHello =  &GossipHello_npc_prof_blacksmith;
     newscript->pGossipSelect = &GossipSelect_npc_prof_blacksmith;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_engineering_tele_trinket";
     newscript->pGossipHello =  &GossipHello_npc_engineering_tele_trinket;
     newscript->pGossipSelect = &GossipSelect_npc_engineering_tele_trinket;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_prof_leather";
     newscript->pGossipHello =  &GossipHello_npc_prof_leather;
     newscript->pGossipSelect = &GossipSelect_npc_prof_leather;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_prof_tailor";
     newscript->pGossipHello =  &GossipHello_npc_prof_tailor;
     newscript->pGossipSelect = &GossipSelect_npc_prof_tailor;
     newscript->RegisterSelf();
+
     /*newscript = new Script;
     newscript->Name = "go_soothsaying_for_dummies";
     newscript->pGOHello =  &GOHello_go_soothsaying_for_dummies;
diff --git a/src/bindings/scripts/scripts/world/npc_taxi.cpp b/src/bindings/scripts/scripts/world/npc_taxi.cpp
index 0dfc0f7e51d..44f05abbfc0 100644
--- a/src/bindings/scripts/scripts/world/npc_taxi.cpp
+++ b/src/bindings/scripts/scripts/world/npc_taxi.cpp
@@ -13,6 +13,7 @@
  * along 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_Taxi
 SD%Complete: 0%
@@ -20,7 +21,9 @@ SDComment: To be used for taxi NPCs that are located globally.
 SDCategory: NPCs
 EndScriptData
 */
+
 #include "precompiled.h"
+
 #define GOSSIP_SUSURRUS         "I am ready."
 #define GOSSIP_NETHER_DRAKE     "I'm ready to fly! Take me up, dragon!"
 #define GOSSIP_BRAZEN           "I am ready to go to Durnholde Keep."
@@ -49,10 +52,12 @@ EndScriptData
 #define GOSSIP_CRIMSONWING      ""
 #define GOSSIP_THRICESTAR1      "Do you think I could take a ride on one of those flying machines?"
 #define GOSSIP_THRICESTAR2      "Kara, I need to be flown out the Dens of Dying to find Bixie."
+
 bool GossipHello_npc_taxi(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     switch(pCreature->GetEntry()) {
     case 17435: // Azuremyst Isle - Susurrus
         if (pPlayer->HasItemCount(23843,1,true))
@@ -72,6 +77,7 @@ bool GossipHello_npc_taxi(Player* pPlayer, Creature* pCreature)
         //Mission: The Murketh and Shaadraz Gateways
         if (pPlayer->GetQuestStatus(10146) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DABIREE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
+
         //Shatter Point
         if (!pPlayer->GetQuestRewardStatus(10340))
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DABIREE2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
@@ -80,6 +86,7 @@ bool GossipHello_npc_taxi(Player* pPlayer, Creature* pCreature)
         //Mission: The Abyssal Shelf || Return to the Abyssal Shelf
         if (pPlayer->GetQuestStatus(10163) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestStatus(10346) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WINDBELLOW1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
+
         //Go to the Front
         if (pPlayer->GetQuestStatus(10382) != QUEST_STATUS_NONE && !pPlayer->GetQuestRewardStatus(10382))
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WINDBELLOW2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
@@ -88,9 +95,11 @@ bool GossipHello_npc_taxi(Player* pPlayer, Creature* pCreature)
         //Mission: The Murketh and Shaadraz Gateways
         if (pPlayer->GetQuestStatus(10129) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8);
+
         //Mission: The Abyssal Shelf || Return to the Abyssal Shelf
         if (pPlayer->GetQuestStatus(10162) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestStatus(10347) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9);
+
         //Spinebreaker Post
         if (pPlayer->GetQuestStatus(10242) == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(10242))
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10);
@@ -102,6 +111,7 @@ bool GossipHello_npc_taxi(Player* pPlayer, Creature* pCreature)
     case 25059: // Isle of Quel'Danas - Ayren Cloudbreaker
         if (pPlayer->GetQuestStatus(11532) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestStatus(11533) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CLOUDBREAKER1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12);
+
         if (pPlayer->GetQuestStatus(11542) == QUEST_STATUS_INCOMPLETE || pPlayer->GetQuestStatus(11543) == QUEST_STATUS_INCOMPLETE)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CLOUDBREAKER2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13);
         break;
@@ -153,9 +163,11 @@ bool GossipHello_npc_taxi(Player* pPlayer, Creature* pCreature)
             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_THRICESTAR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 27);
         break;
     }
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_taxi(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction) {
@@ -277,11 +289,14 @@ bool GossipSelect_npc_taxi(Player* pPlayer, Creature* pCreature, uint32 uiSender
         pPlayer->CastSpell(pPlayer, 51446, false);
         break;
     }
+
     return true;
 }
+
 void AddSC_npc_taxi()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_taxi";
     newscript->pGossipHello = &GossipHello_npc_taxi;
diff --git a/src/bindings/scripts/scripts/world/npcs_special.cpp b/src/bindings/scripts/scripts/world/npcs_special.cpp
index 422713cfff3..ce1d73caf5e 100644
--- a/src/bindings/scripts/scripts/world/npcs_special.cpp
+++ b/src/bindings/scripts/scripts/world/npcs_special.cpp
@@ -13,6 +13,7 @@
  * along 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
@@ -20,6 +21,7 @@ SDComment: To be used for special NPCs that are located globally.
 SDCategory: NPCs
 EndScriptData
 */
+
 /* ContentData
 npc_air_force_bots       80%    support for misc (invisible) guard bots in areas where player allowed to fly. Summon guards after a preset time if tagged by spell
 npc_chicken_cluck       100%    support for quest 3861 (Cluck!)
@@ -34,30 +36,37 @@ npc_rogue_trainer       80%     Scripted trainers, so they are able to offer ite
 npc_sayge               100%    Darkmoon event fortune teller, buff player based on answers given
 npc_snake_trap_serpents 80%     AI for snakes that summoned by Snake Trap
 EndContentData */
+
 #include "precompiled.h"
 #include "escort_ai.h"
 #include "ObjectMgr.h"
+
 /*########
 # npc_air_force_bots
 #########*/
+
 enum SpawnType
 {
     SPAWNTYPE_TRIPWIRE_ROOFTOP,                             // no warning, summon Creature at smaller range
     SPAWNTYPE_ALARMBOT,                                     // cast guards mark and summon npc - if player shows up with that buff duration < 5 seconds attack
 };
+
 struct SpawnAssociation
 {
     uint32 m_uiThisCreatureEntry;
     uint32 m_uiSpawnedCreatureEntry;
     SpawnType m_SpawnType;
 };
+
 enum eEnums
 {
     SPELL_GUARDS_MARK               = 38067,
     AURA_DURATION_TIME_LEFT         = 5000
 };
+
 const float RANGE_TRIPWIRE          = 15.0f;
 const float RANGE_GUARDS_MARK       = 50.0f;
+
 SpawnAssociation m_aSpawnAssociations[] =
 {
     {2614,  15241, SPAWNTYPE_ALARMBOT},                     //Air Force Alarm Bot (Alliance)
@@ -88,14 +97,17 @@ SpawnAssociation m_aSpawnAssociations[] =
     {22125, 22122, SPAWNTYPE_ALARMBOT},                     //Air Force Guard Post (Cenarion - Stormcrow)
     {22126, 22122, SPAWNTYPE_ALARMBOT}                      //Air Force Trip Wire - Rooftop (Cenarion Expedition)
 };
+
 struct TRINITY_DLL_DECL npc_air_force_botsAI : public ScriptedAI
 {
     npc_air_force_botsAI(Creature* pCreature) : ScriptedAI(pCreature)
     {
         m_pSpawnAssoc = NULL;
         m_uiSpawnedGUID = 0;
+
         // find the correct spawnhandling
         static uint32 uiEntryCount = sizeof(m_aSpawnAssociations)/sizeof(SpawnAssociation);
+
         for (uint8 i=0; iGetEntry())
@@ -104,11 +116,13 @@ struct TRINITY_DLL_DECL npc_air_force_botsAI : public ScriptedAI
                 break;
             }
         }
+
         if (!m_pSpawnAssoc)
             error_db_log("TCSR: Creature template entry %u has ScriptName npc_air_force_bots, but it's not handled by that script", pCreature->GetEntry());
         else
         {
             CreatureInfo const* spawnedTemplate = GetCreatureTemplateStore(m_pSpawnAssoc->m_uiSpawnedCreatureEntry);
+
             if (!spawnedTemplate)
             {
                 m_pSpawnAssoc = NULL;
@@ -117,12 +131,16 @@ struct TRINITY_DLL_DECL npc_air_force_botsAI : public ScriptedAI
             }
         }
     }
+
     SpawnAssociation* m_pSpawnAssoc;
     uint64 m_uiSpawnedGUID;
+
     void Reset() { }
+
     Creature* SummonGuard()
     {
         Creature* pSummoned = m_creature->SummonCreature(m_pSpawnAssoc->m_uiSpawnedCreatureEntry, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000);
+
         if (pSummoned)
             m_uiSpawnedGUID = pSummoned->GetGUID();
         else
@@ -130,35 +148,46 @@ struct TRINITY_DLL_DECL npc_air_force_botsAI : public ScriptedAI
             error_db_log("TCSR: npc_air_force_bots: wasn't able to spawn Creature %u", m_pSpawnAssoc->m_uiSpawnedCreatureEntry);
             m_pSpawnAssoc = NULL;
         }
+
         return pSummoned;
     }
+
     Creature* GetSummonedGuard()
     {
         Creature* pCreature = Unit::GetCreature(*m_creature, m_uiSpawnedGUID);
+
         if (pCreature && pCreature->isAlive())
             return pCreature;
+
         return NULL;
     }
+
     void MoveInLineOfSight(Unit* pWho)
     {
         if (!m_pSpawnAssoc)
             return;
+
         if (pWho->isTargetableForAttack() && m_creature->IsHostileTo(pWho))
         {
             Player* pPlayerTarget = pWho->GetTypeId() == TYPEID_PLAYER ? CAST_PLR(pWho) : NULL;
+
             // airforce guards only spawn for players
             if (!pPlayerTarget)
                 return;
+
             Creature* pLastSpawnedGuard = m_uiSpawnedGUID == 0 ? NULL : GetSummonedGuard();
+
             // prevent calling Unit::GetUnit at next MoveInLineOfSight call - speedup
             if (!pLastSpawnedGuard)
                 m_uiSpawnedGUID = 0;
+
             switch(m_pSpawnAssoc->m_SpawnType)
             {
                 case SPAWNTYPE_ALARMBOT:
                 {
                     if (!pWho->IsWithinDistInMap(m_creature, RANGE_GUARDS_MARK))
                         return;
+
                     Aura* pMarkAura = pWho->GetAura(SPELL_GUARDS_MARK, 0);
                     if (pMarkAura)
                     {
@@ -166,9 +195,11 @@ struct TRINITY_DLL_DECL npc_air_force_botsAI : public ScriptedAI
                         if (!pLastSpawnedGuard)
                         {
                             pLastSpawnedGuard = SummonGuard();
+
                             if (!pLastSpawnedGuard)
                                 return;
                         }
+
                         if (pMarkAura->GetAuraDuration() < AURA_DURATION_TIME_LEFT)
                         {
                             if (!pLastSpawnedGuard->getVictim())
@@ -179,8 +210,10 @@ struct TRINITY_DLL_DECL npc_air_force_botsAI : public ScriptedAI
                     {
                         if (!pLastSpawnedGuard)
                             pLastSpawnedGuard = SummonGuard();
+
                         if (!pLastSpawnedGuard)
                             return;
+
                         pLastSpawnedGuard->CastSpell(pWho, SPELL_GUARDS_MARK, true);
                     }
                     break;
@@ -189,10 +222,13 @@ struct TRINITY_DLL_DECL npc_air_force_botsAI : public ScriptedAI
                 {
                     if (!pWho->IsWithinDistInMap(m_creature, RANGE_TRIPWIRE))
                         return;
+
                     if (!pLastSpawnedGuard)
                         pLastSpawnedGuard = SummonGuard();
+
                     if (!pLastSpawnedGuard)
                         return;
+
                     // ROOFTOP only triggers if the player is on the ground
                     if (!pPlayerTarget->IsFlying())
                     {
@@ -205,29 +241,38 @@ struct TRINITY_DLL_DECL npc_air_force_botsAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_air_force_bots(Creature* pCreature)
 {
     return new npc_air_force_botsAI(pCreature);
 }
+
 /*########
 # npc_chicken_cluck
 #########*/
+
 #define EMOTE_HELLO         -1070004
 #define EMOTE_CLUCK_TEXT    -1070006
+
 #define QUEST_CLUCK         3861
 #define FACTION_FRIENDLY    35
 #define FACTION_CHICKEN     31
+
 struct TRINITY_DLL_DECL npc_chicken_cluckAI : public ScriptedAI
 {
     npc_chicken_cluckAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 ResetFlagTimer;
+
     void Reset()
     {
         ResetFlagTimer = 120000;
         m_creature->setFaction(FACTION_CHICKEN);
         m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
     }
+
     void EnterCombat(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
@@ -239,9 +284,11 @@ struct TRINITY_DLL_DECL npc_chicken_cluckAI : public ScriptedAI
                 return;
             }else ResetFlagTimer -= diff;
         }
+
         if (UpdateVictim())
             DoMeleeAttackIfReady();
     }
+
     void ReceiveEmote(Player* pPlayer, uint32 emote)
     {
         switch(emote)
@@ -265,33 +312,43 @@ struct TRINITY_DLL_DECL npc_chicken_cluckAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_chicken_cluck(Creature* pCreature)
 {
     return new npc_chicken_cluckAI(pCreature);
 }
+
 bool QuestAccept_npc_chicken_cluck(Player* pPlayer, Creature* pCreature, const Quest *_Quest)
 {
     if (_Quest->GetQuestId() == QUEST_CLUCK)
         CAST_AI(npc_chicken_cluckAI, pCreature->AI())->Reset();
+
     return true;
 }
+
 bool QuestComplete_npc_chicken_cluck(Player* pPlayer, Creature* pCreature, const Quest *_Quest)
 {
     if (_Quest->GetQuestId() == QUEST_CLUCK)
         CAST_AI(npc_chicken_cluckAI, pCreature->AI())->Reset();
+
     return true;
 }
+
 /*######
 ## npc_dancing_flames
 ######*/
+
 #define SPELL_BRAZIER       45423
 #define SPELL_SEDUCTION     47057
 #define SPELL_FIERY_AURA    45427
+
 struct TRINITY_DLL_DECL npc_dancing_flamesAI : public ScriptedAI
 {
     npc_dancing_flamesAI(Creature *c) : ScriptedAI(c) {}
+
     bool active;
     uint32 can_iteract;
+
     void Reset()
     {
         active = true;
@@ -307,6 +364,7 @@ struct TRINITY_DLL_DECL npc_dancing_flamesAI : public ScriptedAI
         m_creature->BuildHeartBeatMsg(&data);
         m_creature->SendMessageToSet(&data,true);
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!active)
@@ -318,13 +376,16 @@ struct TRINITY_DLL_DECL npc_dancing_flamesAI : public ScriptedAI
             }else can_iteract -= diff;
         }
     }
+
     void EnterCombat(Unit* who){}
+
     void ReceiveEmote(Player* pPlayer, uint32 emote)
     {
         if (m_creature->IsWithinLOS(pPlayer->GetPositionX(),pPlayer->GetPositionY(),pPlayer->GetPositionZ()) && m_creature->IsWithinDistInMap(pPlayer,30.0f))
         {
             m_creature->SetInFront(pPlayer);
             active = false;
+
             WorldPacket data;
             m_creature->BuildHeartBeatMsg(&data);
             m_creature->SendMessageToSet(&data,true);
@@ -344,25 +405,31 @@ struct TRINITY_DLL_DECL npc_dancing_flamesAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_dancing_flames(Creature* pCreature)
 {
     return new npc_dancing_flamesAI(pCreature);
 }
+
 /*######
 ## Triage quest
 ######*/
+
 //signed for 9623
 #define SAY_DOC1    -1000201
 #define SAY_DOC2    -1000202
 #define SAY_DOC3    -1000203
+
 #define DOCTOR_ALLIANCE     12939
 #define DOCTOR_HORDE        12920
 #define ALLIANCE_COORDS     7
 #define HORDE_COORDS        6
+
 struct Location
 {
     float x, y, z, o;
 };
+
 static Location AllianceCoords[]=
 {
     {-3757.38, -4533.05, 14.16, 3.62},                      // Top-far-right bunk as seen from entrance
@@ -373,10 +440,12 @@ static Location AllianceCoords[]=
     {-3749.51, -4527.08, 14.07, 5.26},                      // Mid-left bunk
     {-3746.37, -4525.35, 14.16, 5.22},                      // Left bunk near entrance
 };
+
 //alliance run to where
 #define A_RUNTOX -3742.96
 #define A_RUNTOY -4531.52
 #define A_RUNTOZ 11.91
+
 static Location HordeCoords[]=
 {
     {-1013.75, -3492.59, 62.62, 4.34},                      // Left, Behind
@@ -386,73 +455,98 @@ static Location HordeCoords[]=
     {-1017.25, -3500.85, 62.98, 4.34},                      // Left, front
     {-1020.95, -3499.21, 62.98, 4.34}                       // Right, Front
 };
+
 //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 TRINITY_DLL_DECL npc_doctorAI : public ScriptedAI
 {
     npc_doctorAI(Creature *c) : ScriptedAI(c) {}
+
     uint64 PlayerGUID;
+
     uint32 SummonPatient_Timer;
     uint32 SummonPatientCount;
     uint32 PatientDiedCount;
     uint32 PatientSavedCount;
+
     bool Event;
+
     std::list Patients;
     std::vector Coordinates;
+
     void Reset()
     {
         PlayerGUID = 0;
+
         SummonPatient_Timer = 10000;
         SummonPatientCount = 0;
         PatientDiedCount = 0;
         PatientSavedCount = 0;
+
         Patients.clear();
         Coordinates.clear();
+
         Event = false;
+
         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
     }
+
     void BeginEvent(Player* pPlayer);
     void PatientDied(Location* Point);
     void PatientSaved(Creature* soldier, Player* pPlayer, Location* Point);
     void UpdateAI(const uint32 diff);
+
     void EnterCombat(Unit* who){}
 };
+
 /*#####
 ## npc_injured_patient (handles all the patients, no matter Horde or Alliance)
 #####*/
+
 struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI
 {
     npc_injured_patientAI(Creature *c) : ScriptedAI(c) {}
+
     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, UNIT_STAND_STATE_DEAD);
+
         uint32 mobId = m_creature->GetEntry();
+
         switch (mobId)
         {                                                   //lower max health
             case 12923:
@@ -469,7 +563,9 @@ struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI
                 break;
         }
     }
+
     void EnterCombat(Unit* who){}
+
     void SpellHit(Unit *caster, const SpellEntry *spell)
     {
         if (caster->GetTypeId() == TYPEID_PLAYER && m_creature->isAlive() && spell->Id == 20804)
@@ -478,15 +574,21 @@ struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI
                 if (Doctorguid)
                     if (Creature* Doctor = Unit::GetCreature(*m_creature, Doctorguid))
                         CAST_AI(npc_doctorAI, Doctor->AI())->PatientSaved(m_creature, CAST_PLR(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, UNIT_STAND_STATE_STAND);
+
             DoScriptText(RAND(SAY_DOC1,SAY_DOC2,SAY_DOC3), m_creature);
+
             uint32 mobId = m_creature->GetEntry();
             m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+
             switch (mobId)
             {
                 case 12923:
@@ -502,6 +604,7 @@ struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         //lower HP on every world tick makes it a useful counter, not officlone though
@@ -509,12 +612,14 @@ struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI
         {
             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)
             {
                 if (Creature* Doctor = Unit::GetCreature((*m_creature), Doctorguid))
@@ -523,55 +628,66 @@ struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_injured_patient(Creature* pCreature)
 {
     return new npc_injured_patientAI (pCreature);
 }
+
 /*
 npc_doctor (continue)
 */
+
 void npc_doctorAI::BeginEvent(Player* pPlayer)
 {
     PlayerGUID = pPlayer->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)
+            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)
+            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* pPlayer = Unit::GetPlayer(PlayerGUID);
     if (pPlayer && ((pPlayer->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (pPlayer->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)))
     {
         ++PatientDiedCount;
+
         if (PatientDiedCount > 5 && Event)
         {
             if (pPlayer->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE)
                 pPlayer->FailQuest(6624);
             else if (pPlayer->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)
                 pPlayer->FailQuest(6622);
+
             Reset();
             return;
         }
+
         Coordinates.push_back(Point);
     }
     else
         // If no player or player abandon quest in progress
         Reset();
 }
+
 void npc_doctorAI::PatientSaved(Creature* soldier, Player* pPlayer, Location* Point)
 {
     if (pPlayer && PlayerGUID == pPlayer->GetGUID())
@@ -579,28 +695,33 @@ void npc_doctorAI::PatientSaved(Creature* soldier, Player* pPlayer, Location* Po
         if ((pPlayer->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (pPlayer->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE))
         {
             ++PatientSavedCount;
+
             if (PatientSavedCount == 15)
             {
                 if (!Patients.empty())
                 {
                     std::list::iterator itr;
-                    for (itr = Patients.begin(); itr != Patients.end(); ++itr)
+                    for(itr = Patients.begin(); itr != Patients.end(); ++itr)
                     {
                         if (Creature* Patient = Unit::GetCreature((*m_creature), *itr))
                             Patient->setDeathState(JUST_DIED);
                     }
                 }
+
                 if (pPlayer->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE)
                     pPlayer->AreaExploredOrEventHappens(6624);
                 else if (pPlayer->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)
                     pPlayer->AreaExploredOrEventHappens(6622);
+
                 Reset();
                 return;
             }
+
             Coordinates.push_back(Point);
         }
     }
 }
+
 void npc_doctorAI::UpdateAI(const uint32 diff)
 {
     if (Event && SummonPatientCount >= 20)
@@ -608,16 +729,20 @@ void npc_doctorAI::UpdateAI(const uint32 diff)
         Reset();
         return;
     }
+
     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;
@@ -626,16 +751,22 @@ void npc_doctorAI::UpdateAI(const uint32 diff)
                     error_log("TSCR: 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)
             {
                 //303, this flag appear to be required for client side item->spell to work (TARGET_SINGLE_FRIEND)
                 Patient->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
+
                 Patients.push_back(Patient->GetGUID());
                 CAST_AI(npc_injured_patientAI, Patient->AI())->Doctorguid = m_creature->GetGUID();
+
                 if (Point)
                     CAST_AI(npc_injured_patientAI, Patient->AI())->Coord = Point;
+
                 Coordinates.erase(itr);
             }
             SummonPatient_Timer = 10000;
@@ -643,34 +774,43 @@ void npc_doctorAI::UpdateAI(const uint32 diff)
         }else SummonPatient_Timer -= diff;
     }
 }
+
 bool QuestAccept_npc_doctor(Player* pPlayer, Creature* pCreature, Quest const *quest)
 {
     if ((quest->GetQuestId() == 6624) || (quest->GetQuestId() == 6622))
         CAST_AI(npc_doctorAI, pCreature->AI())->BeginEvent(pPlayer);
+
     return true;
 }
+
 CreatureAI* GetAI_npc_doctor(Creature* pCreature)
 {
     return new npc_doctorAI (pCreature);
 }
+
 /*######
 ## npc_garments_of_quests
 ######*/
+
 //TODO: get text for each NPC
+
 enum eGarments
 {
     SPELL_LESSER_HEAL_R2    = 2052,
     SPELL_FORTITUDE_R1      = 1243,
+
     QUEST_MOON              = 5621,
     QUEST_LIGHT_1           = 5624,
     QUEST_LIGHT_2           = 5625,
     QUEST_SPIRIT            = 5648,
     QUEST_DARKNESS          = 5650,
+
     ENTRY_SHAYA             = 12429,
     ENTRY_ROBERTS           = 12423,
     ENTRY_DOLF              = 12427,
     ENTRY_KORJA             = 12430,
     ENTRY_DG_KEL            = 12428,
+
     //used by 12429,12423,12427,12430,12428, but signed for 12429
     SAY_COMMON_HEALED       = -1000164,
     SAY_DG_KEL_THANKS       = -1000165,
@@ -684,24 +824,34 @@ enum eGarments
     SAY_SHAYA_THANKS        = -1000173,
     SAY_SHAYA_GOODBYE       = -1000174, //signed for 21469
 };
+
 struct TRINITY_DLL_DECL npc_garments_of_questsAI : public npc_escortAI
 {
     npc_garments_of_questsAI(Creature *c) : npc_escortAI(c) {Reset();}
+
     uint64 caster;
+
     bool bIsHealed;
     bool bCanRun;
+
     uint32 RunAwayTimer;
+
     void Reset()
     {
         caster = 0;
+
         bIsHealed = false;
         bCanRun = false;
+
         RunAwayTimer = 5000;
+
         m_creature->SetStandState(UNIT_STAND_STATE_KNEEL);
         //expect database to have RegenHealth=0
         m_creature->SetHealth(int(m_creature->GetMaxHealth()*0.7));
     }
+
     void EnterCombat(Unit *who) {}
+
     void SpellHit(Unit* pCaster, const SpellEntry *Spell)
     {
         if (Spell->Id == SPELL_LESSER_HEAL_R2 || Spell->Id == SPELL_FORTITUDE_R1)
@@ -709,9 +859,11 @@ struct TRINITY_DLL_DECL npc_garments_of_questsAI : public npc_escortAI
             //not while in combat
             if (m_creature->isInCombat())
                 return;
+
             //nothing to be done now
             if (bIsHealed && bCanRun)
                 return;
+
             if (pCaster->GetTypeId() == TYPEID_PLAYER)
             {
                 switch(m_creature->GetEntry())
@@ -802,15 +954,18 @@ struct TRINITY_DLL_DECL npc_garments_of_questsAI : public npc_escortAI
                         }
                         break;
                 }
+
                 //give quest credit, not expect any special quest objectives
                 if (bCanRun)
                     CAST_PLR(pCaster)->TalkedToCreature(m_creature->GetEntry(),m_creature->GetGUID());
             }
         }
     }
+
     void WaypointReached(uint32 uiPoint)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (bCanRun && !m_creature->isInCombat())
@@ -827,38 +982,49 @@ struct TRINITY_DLL_DECL npc_garments_of_questsAI : public npc_escortAI
                         case ENTRY_KORJA: DoScriptText(SAY_KORJA_GOODBYE,m_creature,pUnit); break;
                         case ENTRY_DG_KEL: DoScriptText(SAY_DG_KEL_GOODBYE,m_creature,pUnit); break;
                     }
+
                     Start(false,true,true);
                 }
                 else
                     EnterEvadeMode();                       //something went wrong
+
                 RunAwayTimer = 30000;
             }else RunAwayTimer -= diff;
         }
+
     npc_escortAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_npc_garments_of_quests(Creature* pCreature)
 {
     return new npc_garments_of_questsAI(pCreature);
 }
+
 /*######
 ## npc_guardian
 ######*/
+
 #define SPELL_DEATHTOUCH                5
+
 struct TRINITY_DLL_DECL npc_guardianAI : public ScriptedAI
 {
     npc_guardianAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset()
     {
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
     }
+
     void EnterCombat(Unit *who)
     {
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
             return;
+
         if (m_creature->isAttackReady())
         {
             m_creature->CastSpell(m_creature->getVictim(),SPELL_DEATHTOUCH, true);
@@ -866,13 +1032,16 @@ struct TRINITY_DLL_DECL npc_guardianAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_guardian(Creature* pCreature)
 {
     return new npc_guardianAI (pCreature);
 }
+
 /*######
 ## npc_kingdom_of_dalaran_quests
 ######*/
+
 enum eKingdomDalaran
 {
     SPELL_TELEPORT_DALARAN  = 53360,
@@ -881,17 +1050,22 @@ enum eKingdomDalaran
     QUEST_MAGICAL_KINGDOM_H = 12791,
     QUEST_MAGICAL_KINGDOM_N = 12796
 };
+
 #define GOSSIP_ITEM_TELEPORT_TO "I am ready to be teleported to Dalaran."
+
 bool GossipHello_npc_kingdom_of_dalaran_quests(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->HasItemCount(ITEM_KT_SIGNET,1) && (!pPlayer->GetQuestRewardStatus(QUEST_MAGICAL_KINGDOM_A) ||
         !pPlayer->GetQuestRewardStatus(QUEST_MAGICAL_KINGDOM_H) || !pPlayer->GetQuestRewardStatus(QUEST_MAGICAL_KINGDOM_N)))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELEPORT_TO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+
     pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
     return true;
 }
+
 bool GossipSelect_npc_kingdom_of_dalaran_quests(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
@@ -901,17 +1075,21 @@ bool GossipSelect_npc_kingdom_of_dalaran_quests(Player* pPlayer, Creature* pCrea
     }
     return true;
 }
+
 /*######
 ## npc_mount_vendor
 ######*/
+
 bool GossipHello_npc_mount_vendor(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     bool canBuy;
     canBuy = false;
     uint32 vendor = pCreature->GetEntry();
     uint8 race = pPlayer->getRace();
+
     switch (vendor)
     {
         case 384:                                           //Katie Hunter
@@ -968,6 +1146,7 @@ bool GossipHello_npc_mount_vendor(Player* pPlayer, Creature* pCreature)
             else canBuy = true;
             break;
     }
+
     if (canBuy)
     {
         if (pCreature->isVendor())
@@ -976,33 +1155,43 @@ bool GossipHello_npc_mount_vendor(Player* pPlayer, Creature* pCreature)
     }
     return true;
 }
+
 bool GossipSelect_npc_mount_vendor(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     if (uiAction == GOSSIP_ACTION_TRADE)
         pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
+
     return true;
 }
+
 /*######
 ## npc_rogue_trainer
 ######*/
+
 #define GOSSIP_HELLO_ROGUE1 "I wish to unlearn my talents"
 #define GOSSIP_HELLO_ROGUE2 ""
+
 bool GossipHello_npc_rogue_trainer(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pCreature->isTrainer())
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
+
     if (pCreature->isCanTrainingAndResetTalentsOf(pPlayer))
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_HELLO_ROGUE1, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_UNLEARNTALENTS);
+
     if (pPlayer->getClass() == CLASS_ROGUE && pPlayer->getLevel() >= 24 && !pPlayer->HasItemCount(17126,1) && !pPlayer->GetQuestRewardStatus(6681))
     {
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_ROGUE2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->SEND_GOSSIP_MENU(5996, pCreature->GetGUID());
     } else
         pPlayer->SEND_GOSSIP_MENU(pCreature->GetNpcTextId(), pCreature->GetGUID());
+
     return true;
 }
+
 bool GossipSelect_npc_rogue_trainer(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiAction)
@@ -1021,9 +1210,11 @@ bool GossipSelect_npc_rogue_trainer(Player* pPlayer, Creature* pCreature, uint32
     }
     return true;
 }
+
 /*######
 ## npc_sayge
 ######*/
+
 #define SPELL_DMG       23768                               //dmg
 #define SPELL_RES       23769                               //res
 #define SPELL_ARM       23767                               //arm
@@ -1033,6 +1224,7 @@ bool GossipSelect_npc_rogue_trainer(Player* pPlayer, Creature* pCreature, uint32
 #define SPELL_STR       23735                               //str
 #define SPELL_AGI       23736                               //agi
 #define SPELL_FORTUNE   23765                               //faire fortune
+
 #define GOSSIP_HELLO_SAYGE  "Yes"
 #define GOSSIP_SENDACTION_SAYGE1    "Slay the Man"
 #define GOSSIP_SENDACTION_SAYGE2    "Turn him over to liege"
@@ -1051,10 +1243,12 @@ bool GossipSelect_npc_rogue_trainer(Player* pPlayer, Creature* pCreature, uint32
 #define GOSSIP_SENDACTION_SAYGE15   "Take credit, share the gold"
 #define GOSSIP_SENDACTION_SAYGE16   "Let the knight take credit"
 #define GOSSIP_SENDACTION_SAYGE17   "Thanks"
+
 bool GossipHello_npc_sayge(Player* pPlayer, Creature* pCreature)
 {
     if (pCreature->isQuestGiver())
         pPlayer->PrepareQuestMenu(pCreature->GetGUID());
+
     if (pPlayer->HasSpellCooldown(SPELL_INT) ||
         pPlayer->HasSpellCooldown(SPELL_ARM) ||
         pPlayer->HasSpellCooldown(SPELL_DMG) ||
@@ -1069,8 +1263,10 @@ bool GossipHello_npc_sayge(Player* pPlayer, Creature* pCreature)
         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_SAYGE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
         pPlayer->SEND_GOSSIP_MENU(7339, pCreature->GetGUID());
     }
+
     return true;
 }
+
 void SendAction_npc_sayge(Player* pPlayer, Creature* pCreature, uint32 uiAction)
 {
     switch(uiAction)
@@ -1116,6 +1312,7 @@ void SendAction_npc_sayge(Player* pPlayer, Creature* pCreature, uint32 uiAction)
             break;
     }
 }
+
 bool GossipSelect_npc_sayge(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
 {
     switch(uiSender)
@@ -1166,11 +1363,14 @@ bool GossipSelect_npc_sayge(Player* pPlayer, Creature* pCreature, uint32 uiSende
     }
     return true;
 }
+
 struct TRINITY_DLL_DECL npc_steam_tonkAI : public ScriptedAI
 {
     npc_steam_tonkAI(Creature *c) : ScriptedAI(c) {}
+
     void Reset() {}
     void EnterCombat(Unit *who) {}
+
     void OnPossess(bool apply)
     {
         if (apply)
@@ -1178,31 +1378,40 @@ struct TRINITY_DLL_DECL npc_steam_tonkAI : public ScriptedAI
             // Initialize the action bar without the melee attack command
             m_creature->InitCharmInfo();
             m_creature->GetCharmInfo()->InitEmptyActionBar(false);
+
             m_creature->SetReactState(REACT_PASSIVE);
         }
         else
             m_creature->SetReactState(REACT_AGGRESSIVE);
     }
+
 };
+
 CreatureAI* GetAI_npc_steam_tonk(Creature* pCreature)
 {
     return new npc_steam_tonkAI(pCreature);
 }
+
 #define SPELL_TONK_MINE_DETONATE 25099
+
 struct TRINITY_DLL_DECL npc_tonk_mineAI : public ScriptedAI
 {
     npc_tonk_mineAI(Creature *c) : ScriptedAI(c)
     {
         m_creature->SetReactState(REACT_PASSIVE);
     }
+
     uint32 ExplosionTimer;
+
     void Reset()
     {
         ExplosionTimer = 3000;
     }
+
     void EnterCombat(Unit *who) {}
     void AttackStart(Unit *who) {}
     void MoveInLineOfSight(Unit *who) {}
+
     void UpdateAI(const uint32 diff)
     {
         if (ExplosionTimer < diff)
@@ -1213,18 +1422,22 @@ struct TRINITY_DLL_DECL npc_tonk_mineAI : public ScriptedAI
             ExplosionTimer -= diff;
     }
 };
+
 CreatureAI* GetAI_npc_tonk_mine(Creature* pCreature)
 {
     return new npc_tonk_mineAI(pCreature);
 }
+
 /*####
 ## npc_winter_reveler
 ####*/
+
 bool ReceiveEmote_npc_winter_reveler(Player* pPlayer, Creature* pCreature, uint32 emote)
 {
     //TODO: check auralist.
     if (pPlayer->HasAura(26218))
         return false;
+
     if (emote == TEXTEMOTE_KISS)
     {
         pCreature->CastSpell(pCreature, 26218, false);
@@ -1238,51 +1451,68 @@ bool ReceiveEmote_npc_winter_reveler(Player* pPlayer, Creature* pCreature, uint3
     }
     return true;
 }
+
 /*####
 ## npc_brewfest_reveler
 ####*/
+
 bool ReceiveEmote_npc_brewfest_reveler(Player* pPlayer, Creature* pCreature, uint32 emote)
 {
     if (emote == TEXTEMOTE_DANCE)
         pCreature->CastSpell(pPlayer, 41586, false);
+
     return true;
 }
+
 /*####
 ## npc_snake_trap_serpents
 ####*/
+
 #define SPELL_MIND_NUMBING_POISON    8692    //Viper
 #define SPELL_DEADLY_POISON          34655   //Venomous Snake
 #define SPELL_CRIPPLING_POISON       3409    //Viper
+
 #define VENOMOUS_SNAKE_TIMER 1200
 #define VIPER_TIMER 3000
+
 #define C_VIPER 19921
+
 #define RAND 5
+
 struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
 {
     npc_snake_trap_serpentsAI(Creature *c) : ScriptedAI(c) {}
+
     uint32 SpellTimer;
     bool IsViper;
     bool Spawn;
+
     void EnterCombat(Unit *who) {}
+
     void Reset()
     {
         Spawn = true;
         SpellTimer = 0;
+
         CreatureInfo const *Info = m_creature->GetCreatureInfo();
+
         if (Info->Entry == C_VIPER)
             IsViper = true;
         else
             IsViper = false;
+
         //We have to reload the states from db for summoned guardians
         m_creature->SetMaxHealth(Info->maxhealth);
         m_creature->SetHealth(Info->maxhealth);
         m_creature->SetStatFloatValue(UNIT_FIELD_MINDAMAGE, Info->mindmg);
         m_creature->SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, Info->maxdmg);
+
         //Add delta to make them not all hit the same time
         uint32 delta = (rand() % 7) *100;
         m_creature->SetStatFloatValue(UNIT_FIELD_BASEATTACKTIME, Info->baseattacktime + delta);
         m_creature->SetStatFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER , Info->attackpower);
     }
+
     //Redefined for random target selection:
     void MoveInLineOfSight(Unit *who)
     {
@@ -1290,6 +1520,7 @@ struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
         {
             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))
             {
@@ -1302,6 +1533,7 @@ struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
             }
         }
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (Spawn)
@@ -1313,12 +1545,14 @@ struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
                     if (Owner->getAttackerForHelper())
                         AttackStart(Owner->getAttackerForHelper());
         }
+
         if (!m_creature->getVictim())
         {
             if (m_creature->isInCombat())
                 DoStopAttack();
             return;
         }
+
         if (SpellTimer < diff)
         {
             if (IsViper) //Viper
@@ -1330,8 +1564,10 @@ struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
                         spell = SPELL_MIND_NUMBING_POISON;
                     else
                         spell = SPELL_CRIPPLING_POISON;
+
                     DoCast(m_creature->getVictim(),spell);
                 }
+
                 SpellTimer = VIPER_TIMER;
             }
             else //Venomous Snake
@@ -1344,10 +1580,12 @@ struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
         DoMeleeAttackIfReady();
     }
 };
+
 CreatureAI* GetAI_npc_snake_trap_serpents(Creature* pCreature)
 {
     return new npc_snake_trap_serpentsAI(pCreature);
 }
+
 #define SAY_RANDOM_MOJO0    "Now that's what I call froggy-style!"
 #define SAY_RANDOM_MOJO1    "Your lily pad or mine?"
 #define SAY_RANDOM_MOJO2    "This won't take long, did it?"
@@ -1357,6 +1595,7 @@ CreatureAI* GetAI_npc_snake_trap_serpents(Creature* pCreature)
 #define SAY_RANDOM_MOJO6a   "Listen, "
 #define SAY_RANDOM_MOJO6b   ", I know of a little swamp not too far from here...."
 #define SAY_RANDOM_MOJO7    "There's just never enough Mojo to go around..."
+
 struct TRINITY_DLL_DECL mob_mojoAI : public ScriptedAI
 {
     mob_mojoAI(Creature *c) : ScriptedAI(c) {Reset();}
@@ -1421,13 +1660,16 @@ struct TRINITY_DLL_DECL mob_mojoAI : public ScriptedAI
         }
     }
 };
+
 CreatureAI* GetAI_mob_mojo(Creature* pCreature)
 {
     return new mob_mojoAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_mirror_image : CasterAI
 {
     npc_mirror_image(Creature *c) : CasterAI(c) {}
+
     void InitializeAI()
     {
         CasterAI::InitializeAI();
@@ -1441,12 +1683,15 @@ struct TRINITY_DLL_DECL npc_mirror_image : CasterAI
         // Clone Me!
         owner->CastSpell(me, 45204, false);
     }
+
     // Do not reload Creature templates on evade mode enter - prevent visual lost
     void EnterEvadeMode()
     {
         if (me->IsInEvadeMode() || !me->isAlive())
             return;
+
         Unit *owner = me->GetCharmerOrOwner();
+
         me->CombatStop(true);
         if (owner && !me->hasUnitState(UNIT_STAT_FOLLOW))
         {
@@ -1455,14 +1700,18 @@ struct TRINITY_DLL_DECL npc_mirror_image : CasterAI
         }
     }
 };
+
 CreatureAI* GetAI_npc_mirror_image(Creature* pCreature)
 {
     return new npc_mirror_image (pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_ebon_gargoyleAI : CasterAI
 {
     npc_ebon_gargoyleAI(Creature *c) : CasterAI(c) {}
+
     int despawnTimer;
+
     void InitializeAI()
     {
         CasterAI::InitializeAI();
@@ -1476,32 +1725,38 @@ struct TRINITY_DLL_DECL npc_ebon_gargoyleAI : CasterAI
         Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(m_creature, m_creature, 30);
         Trinity::UnitListSearcher searcher(m_creature, targets, u_check);
         m_creature->VisitNearbyObject(30, searcher);
-        for (std::list::iterator iter = targets.begin(); iter != targets.end(); ++iter)
+        for(std::list::iterator iter = targets.begin(); iter != targets.end(); ++iter)
             if((*iter)->GetAura(49206,owner->GetGUID()))
             {
                 me->Attack((*iter),false);
                 break;
             }
     }
+
     void JustDied(Unit *killer)
     {
         // Stop Feeding Gargoyle when it dies
         if (Unit *owner = me->GetOwner())
             owner->RemoveAurasDueToSpell(50514);
     }
+
     // Fly away when dismissed
     void SpellHit(Unit *source, const SpellEntry *spell)
     {
         if(spell->Id != 50515 || !me->isAlive() )
             return;
+
         Unit *owner = me->GetOwner();
+
         if (!owner || owner != source)
             return;
+
         // Stop Fighting
         me->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE, true);
         // Sanctuary
         me->CastSpell(m_creature, 54661, true);
         me->SetReactState(REACT_PASSIVE);
+
         // Fly Away
         me->AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE);
         me->SetSpeed(MOVE_FLIGHT, 0.25f, true);
@@ -1510,9 +1765,11 @@ struct TRINITY_DLL_DECL npc_ebon_gargoyleAI : CasterAI
         float y = me->GetPositionY() + 10 * sin(me->GetOrientation());
         float z = me->GetPositionZ() + 25;
         me->GetMotionMaster()->MovePoint(0, x, y, z);
+
         // Despawn as soon as possible
         despawnTimer = 4 * IN_MILISECONDS;
     }
+
     void UpdateAI(const uint32 diff)
     {
         if (despawnTimer > 0)
@@ -1528,25 +1785,31 @@ struct TRINITY_DLL_DECL npc_ebon_gargoyleAI : CasterAI
         CasterAI::UpdateAI(diff);
     }
 };
+
 CreatureAI* GetAI_npc_ebon_gargoyle(Creature* pCreature)
 {
     return new npc_ebon_gargoyleAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_lightwellAI : public PassiveAI
 {
     npc_lightwellAI(Creature *c) : PassiveAI(c) {}
+
     void Reset()
     {
         m_creature->CastSpell(m_creature, 59907, false); // Spell for Lightwell Charges
     }
 };
+
 CreatureAI* GetAI_npc_lightwellAI(Creature* pCreature)
 {
     return new npc_lightwellAI (pCreature);
 }
+
 struct TRINITY_DLL_DECL npc_training_dummy : Scripted_NoMovementAI
 {
     npc_training_dummy(Creature *c) : Scripted_NoMovementAI(c) {}
+
     uint32 ResetTimer;
     void Reset()
     {
@@ -1555,12 +1818,15 @@ struct TRINITY_DLL_DECL npc_training_dummy : Scripted_NoMovementAI
         m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, true);
         ResetTimer = 10000;
     }
+
     void DamageTaken(Unit *done_by, uint32 &damage)
     {
         ResetTimer = 10000;
         damage = 0;
     }
+
     void EnterCombat(Unit *who){return;}
+
     void UpdateAI(const uint32 diff)
     {
         if (!UpdateVictim())
@@ -1576,100 +1842,123 @@ struct TRINITY_DLL_DECL npc_training_dummy : Scripted_NoMovementAI
     }
     void MoveInLineOfSight(Unit *who){return;}
 };
+
 CreatureAI* GetAI_npc_training_dummy(Creature* pCreature)
 {
     return new npc_training_dummy (pCreature);
 }
+
 void AddSC_npcs_special()
 {
     Script *newscript;
+
     newscript = new Script;
     newscript->Name = "npc_air_force_bots";
     newscript->GetAI = &GetAI_npc_air_force_bots;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_chicken_cluck";
     newscript->GetAI = &GetAI_npc_chicken_cluck;
     newscript->pQuestAccept =   &QuestAccept_npc_chicken_cluck;
     newscript->pQuestComplete = &QuestComplete_npc_chicken_cluck;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_dancing_flames";
     newscript->GetAI = &GetAI_npc_dancing_flames;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_injured_patient";
     newscript->GetAI = &GetAI_npc_injured_patient;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_doctor";
     newscript->GetAI = &GetAI_npc_doctor;
     newscript->pQuestAccept = &QuestAccept_npc_doctor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_garments_of_quests";
     newscript->GetAI = &GetAI_npc_garments_of_quests;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_guardian";
     newscript->GetAI = &GetAI_npc_guardian;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_kingdom_of_dalaran_quests";
     newscript->pGossipHello =  &GossipHello_npc_kingdom_of_dalaran_quests;
     newscript->pGossipSelect = &GossipSelect_npc_kingdom_of_dalaran_quests;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_mount_vendor";
     newscript->pGossipHello =  &GossipHello_npc_mount_vendor;
     newscript->pGossipSelect = &GossipSelect_npc_mount_vendor;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_rogue_trainer";
     newscript->pGossipHello =  &GossipHello_npc_rogue_trainer;
     newscript->pGossipSelect = &GossipSelect_npc_rogue_trainer;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_sayge";
     newscript->pGossipHello = &GossipHello_npc_sayge;
     newscript->pGossipSelect = &GossipSelect_npc_sayge;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_steam_tonk";
     newscript->GetAI = &GetAI_npc_steam_tonk;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_tonk_mine";
     newscript->GetAI = &GetAI_npc_tonk_mine;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_winter_reveler";
     //newscript->pReceiveEmote =  &ReceiveEmote_npc_winter_reveler;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_brewfest_reveler";
     //newscript->pReceiveEmote =  &ReceiveEmote_npc_brewfest_reveler;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_snake_trap_serpents";
     newscript->GetAI = &GetAI_npc_snake_trap_serpents;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_mirror_image";
     newscript->GetAI = &GetAI_npc_mirror_image;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_ebon_gargoyle";
     newscript->GetAI = &GetAI_npc_ebon_gargoyle;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_lightwell";
     newscript->GetAI = &GetAI_npc_lightwellAI;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "mob_mojo";
     newscript->GetAI = &GetAI_mob_mojo;
     newscript->RegisterSelf();
+
     newscript = new Script;
     newscript->Name = "npc_training_dummy";
     newscript->GetAI = &GetAI_npc_training_dummy;
diff --git a/src/bindings/scripts/system/ScriptLoader.cpp b/src/bindings/scripts/system/ScriptLoader.cpp
index c19015181c5..aa36753cf84 100644
--- a/src/bindings/scripts/system/ScriptLoader.cpp
+++ b/src/bindings/scripts/system/ScriptLoader.cpp
@@ -1,13 +1,17 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
 * This program is free software licensed under GPL version 2
 * Please see the included DOCS/LICENSE.TXT for more information */
+
 #include "precompiled.h"
+
 //custom
+
 //examples
 extern void AddSC_example_creature();
 extern void AddSC_example_escort();
 extern void AddSC_example_gossip_codebox();
 extern void AddSC_example_misc();
+
 //world
 extern void AddSC_areatrigger_scripts();
 extern void AddSC_boss_emeriss();
@@ -20,6 +24,7 @@ extern void AddSC_item_scripts();
 extern void AddSC_npc_professions();
 extern void AddSC_npcs_special();
 extern void AddSC_npc_taxi();
+
 //eastern kingdoms
 extern void AddSC_blackrock_depths();               //Blackrock Depths
 extern void AddSC_boss_ambassador_flamelash();
@@ -164,6 +169,7 @@ extern void AddSC_boss_hazzarah();
 extern void AddSC_boss_renataki();
 extern void AddSC_boss_wushoolay();
 extern void AddSC_instance_zulgurub();
+
 //extern void AddSC_alterac_mountains();
 extern void AddSC_arathi_highlands();
 extern void AddSC_blasted_lands();
@@ -189,6 +195,7 @@ extern void AddSC_undercity();
 extern void AddSC_western_plaguelands();
 extern void AddSC_westfall();
 extern void AddSC_wetlands();
+
 //kalimdor
 extern void AddSC_instance_blackfathom_deeps();     //Blackfathom Depths
 extern void AddSC_hyjal();                          //CoT Battle for Mt. Hyjal
@@ -229,6 +236,7 @@ extern void AddSC_instance_temple_of_ahnqiraj();
 extern void AddSC_wailing_caverns();                //Wailing caverns
 extern void AddSC_instance_wailing_caverns();
 extern void AddSC_zulfarrak();                      //Zul'Farrak
+
 extern void AddSC_ashenvale();
 extern void AddSC_azshara();
 extern void AddSC_azuremyst_isle();
@@ -251,6 +259,7 @@ extern void AddSC_thousand_needles();
 extern void AddSC_thunder_bluff();
 extern void AddSC_ungoro_crater();
 extern void AddSC_winterspring();
+
 //northrend
 extern void AddSC_boss_slad_ran();
 extern void AddSC_boss_moorabi();
@@ -330,6 +339,7 @@ extern void AddSC_boss_xevozz();
 extern void AddSC_boss_zuramat();
 extern void AddSC_instance_violet_hold();
 extern void AddSC_violet_hold();
+
 extern void AddSC_borean_tundra();
 extern void AddSC_dragonblight();
 extern void AddSC_grizzly_hills();
@@ -339,6 +349,7 @@ extern void AddSC_sholazar_basin();
 extern void AddSC_storm_peaks();
 extern void AddSC_wintergrasp();
 extern void AddSC_zuldrak();
+
 //outland
 extern void AddSC_boss_exarch_maladaar();           //Auchindoun Auchenai Crypts
 extern void AddSC_boss_shirrak_the_dead_watcher();
@@ -409,6 +420,7 @@ extern void AddSC_boss_gatewatcher_iron_hand();     //TK The Mechanar
 extern void AddSC_boss_nethermancer_sepethrea();
 extern void AddSC_boss_pathaleon_the_calculator();
 extern void AddSC_instance_mechanar();
+
 extern void AddSC_blades_edge_mountains();
 extern void AddSC_boss_doomlordkazzak();
 extern void AddSC_boss_doomwalker();
@@ -420,14 +432,17 @@ extern void AddSC_shattrath_city();
 extern void AddSC_terokkar_forest();
 extern void AddSC_zangarmarsh();
 extern void AddSC_onevents();
+
 void AddScripts()
 {
     //custom
+
     //examples
     AddSC_example_creature();
     AddSC_example_escort();
     AddSC_example_gossip_codebox();
     AddSC_example_misc();
+
     //world
     AddSC_areatrigger_scripts();
     AddSC_boss_emeriss();
@@ -440,6 +455,7 @@ void AddScripts()
     AddSC_npc_professions();
     AddSC_npcs_special();
     AddSC_npc_taxi();
+
     //eastern kingdoms
     AddSC_blackrock_depths();               //Blackrock Depths
     AddSC_boss_ambassador_flamelash();
@@ -584,6 +600,7 @@ void AddScripts()
     AddSC_boss_renataki();
     AddSC_boss_wushoolay();
     AddSC_instance_zulgurub();
+
     //AddSC_alterac_mountains();
     AddSC_arathi_highlands();
     AddSC_blasted_lands();
@@ -609,6 +626,7 @@ void AddScripts()
     AddSC_western_plaguelands();
     AddSC_westfall();
     AddSC_wetlands();
+
     //kalimdor
     AddSC_instance_blackfathom_deeps();     //Blackfathom Depths
     AddSC_hyjal();                          //CoT Battle for Mt. Hyjal
@@ -649,6 +667,7 @@ void AddScripts()
     AddSC_wailing_caverns();                //Wailing caverns
     AddSC_instance_wailing_caverns();
     AddSC_zulfarrak();                      //Zul'Farrak
+
     AddSC_ashenvale();
     AddSC_azshara();
     AddSC_azuremyst_isle();
@@ -671,6 +690,7 @@ void AddScripts()
     AddSC_thunder_bluff();
     AddSC_ungoro_crater();
     AddSC_winterspring();
+
     //northrend
     AddSC_boss_slad_ran();               //Gundrak
     AddSC_boss_moorabi();
@@ -750,6 +770,7 @@ void AddScripts()
     AddSC_boss_zuramat();
     AddSC_instance_violet_hold();
     AddSC_violet_hold();
+
     AddSC_borean_tundra();
     AddSC_dragonblight();
     AddSC_grizzly_hills();
@@ -759,6 +780,7 @@ void AddScripts()
     AddSC_storm_peaks();
     AddSC_wintergrasp();
     AddSC_zuldrak();
+
     //outland
     AddSC_boss_exarch_maladaar();           //Auchindoun Auchenai Crypts
     AddSC_boss_shirrak_the_dead_watcher();
@@ -829,6 +851,7 @@ void AddScripts()
     AddSC_boss_nethermancer_sepethrea();
     AddSC_boss_pathaleon_the_calculator();
     AddSC_instance_mechanar();
+
     AddSC_blades_edge_mountains();
     AddSC_boss_doomlordkazzak();
     AddSC_boss_doomwalker();
diff --git a/src/bindings/scripts/system/ScriptLoader.h b/src/bindings/scripts/system/ScriptLoader.h
index ad992e5cf12..57fb7d821f1 100644
--- a/src/bindings/scripts/system/ScriptLoader.h
+++ b/src/bindings/scripts/system/ScriptLoader.h
@@ -1,7 +1,10 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
 * This program is free software licensed under GPL version 2
 * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef SC_SCRIPTLOADER_H
 #define SC_SCRIPTLOADER_H
+
 void AddScripts();
+
 #endif
diff --git a/src/bindings/scripts/system/system.cpp b/src/bindings/scripts/system/system.cpp
index 1518f5bb29e..4ed51825262 100644
--- a/src/bindings/scripts/system/system.cpp
+++ b/src/bindings/scripts/system/system.cpp
@@ -17,27 +17,34 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "precompiled.h"
 #include "system.h"
 #include "ProgressBar.h"
 #include "ObjectMgr.h"
 #include "Database/DatabaseEnv.h"
+
 DatabaseType TScriptDB;
+
 SystemMgr::SystemMgr()
 {
 }
+
 SystemMgr& SystemMgr::Instance()
 {
     static SystemMgr pSysMgr;
     return pSysMgr;
 }
+
 void SystemMgr::LoadVersion()
 {
     //Get Version information
     QueryResult* pResult = TScriptDB.PQuery("SELECT script_version FROM version LIMIT 1");
+
     if (pResult)
     {
         Field* pFields = pResult->Fetch();
+
         outstring_log("TSCR: Database version is: %s", pFields[0].GetString());
         outstring_log("");
     }
@@ -47,48 +54,61 @@ void SystemMgr::LoadVersion()
         outstring_log("");
     }
 }
+
 void SystemMgr::LoadScriptTexts()
 {
     outstring_log("TSCR: Loading Script Texts...");
     LoadTrinityStrings(TScriptDB,"script_texts",TEXT_SOURCE_RANGE,1+(TEXT_SOURCE_RANGE*2));
+
     QueryResult* pResult = TScriptDB.PQuery("SELECT entry, sound, type, language, emote FROM script_texts");
+
     outstring_log("TSCR: Loading Script Texts additional data...");
+
     if (pResult)
     {
         barGoLink bar(pResult->GetRowCount());
         uint32 uiCount = 0;
+
         do
         {
             bar.step();
             Field* pFields = pResult->Fetch();
             StringTextData pTemp;
+
             int32 iId           = pFields[0].GetInt32();
             pTemp.uiSoundId     = pFields[1].GetUInt32();
             pTemp.uiType        = pFields[2].GetUInt32();
             pTemp.uiLanguage    = pFields[3].GetUInt32();
             pTemp.uiEmote       = pFields[4].GetUInt32();
+
             if (iId >= 0)
             {
                 error_db_log("TSCR: Entry %i in table `script_texts` is not a negative value.", iId);
                 continue;
             }
+
             if (iId > TEXT_SOURCE_RANGE || iId <= TEXT_SOURCE_RANGE*2)
             {
                 error_db_log("TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.", iId);
                 continue;
             }
+
             if (pTemp.uiSoundId)
             {
                 if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
                     error_db_log("TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
             }
+
             if (!GetLanguageDescByID(pTemp.uiLanguage))
                 error_db_log("TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);
+
             if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
                 error_db_log("TSCR: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType);
+
             m_mTextDataMap[iId] = pTemp;
             ++uiCount;
         } while (pResult->NextRow());
+
         outstring_log("");
         outstring_log(">> Loaded %u additional Script Texts data.", uiCount);
     }
@@ -100,48 +120,61 @@ void SystemMgr::LoadScriptTexts()
         outstring_log(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty.");
     }
 }
+
 void SystemMgr::LoadScriptTextsCustom()
 {
     outstring_log("TSCR: Loading Custom Texts...");
     LoadTrinityStrings(TScriptDB,"custom_texts",TEXT_SOURCE_RANGE*2,1+(TEXT_SOURCE_RANGE*3));
+
     QueryResult* pResult = TScriptDB.PQuery("SELECT entry, sound, type, language, emote FROM custom_texts");
+
     outstring_log("TSCR: Loading Custom Texts additional data...");
+
     if (pResult)
     {
         barGoLink bar(pResult->GetRowCount());
         uint32 uiCount = 0;
+
         do
         {
             bar.step();
             Field* pFields = pResult->Fetch();
             StringTextData pTemp;
+
             int32 iId              = pFields[0].GetInt32();
             pTemp.uiSoundId        = pFields[1].GetUInt32();
             pTemp.uiType           = pFields[2].GetUInt32();
             pTemp.uiLanguage       = pFields[3].GetUInt32();
             pTemp.uiEmote          = pFields[4].GetUInt32();
+
             if (iId >= 0)
             {
                 error_db_log("TSCR: Entry %i in table `custom_texts` is not a negative value.", iId);
                 continue;
             }
+
             if (iId > TEXT_SOURCE_RANGE*2 || iId <= TEXT_SOURCE_RANGE*3)
             {
                 error_db_log("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.", iId);
                 continue;
             }
+
             if (pTemp.uiSoundId)
             {
                 if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
                     error_db_log("TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
             }
+
             if (!GetLanguageDescByID(pTemp.uiLanguage))
                 error_db_log("TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);
+
             if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
                 error_db_log("TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType);
+
             m_mTextDataMap[iId] = pTemp;
             ++uiCount;
         } while (pResult->NextRow());
+
         outstring_log("");
         outstring_log(">> Loaded %u additional Custom Texts data.", uiCount);
     }
@@ -153,11 +186,14 @@ void SystemMgr::LoadScriptTextsCustom()
         outstring_log(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty.");
     }
 }
+
 void SystemMgr::LoadScriptWaypoints()
 {
     // Drop Existing Waypoint list
     m_mPointMoveMap.clear();
+
     uint64 uiCreatureCount = 0;
+
     // Load Waypoints
     QueryResult* pResult = TScriptDB.PQuery("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
     if (pResult)
@@ -165,17 +201,22 @@ void SystemMgr::LoadScriptWaypoints()
         uiCreatureCount = pResult->GetRowCount();
         delete pResult;
     }
+
     outstring_log("TSCR: Loading Script Waypoints for %u creature(s)...", uiCreatureCount);
+
     pResult = TScriptDB.PQuery("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
+
     if (pResult)
     {
         barGoLink bar(pResult->GetRowCount());
         uint32 uiNodeCount = 0;
+
         do
         {
             bar.step();
             Field* pFields = pResult->Fetch();
             ScriptPointMove pTemp;
+
             pTemp.uiCreatureEntry   = pFields[0].GetUInt32();
             uint32 uiEntry          = pTemp.uiCreatureEntry;
             pTemp.uiPointId         = pFields[1].GetUInt32();
@@ -183,18 +224,24 @@ void SystemMgr::LoadScriptWaypoints()
             pTemp.fY                = pFields[3].GetFloat();
             pTemp.fZ                = pFields[4].GetFloat();
             pTemp.uiWaitTime        = pFields[5].GetUInt32();
+
             CreatureInfo const* pCInfo = GetCreatureTemplateStore(pTemp.uiCreatureEntry);
+
             if (!pCInfo)
             {
                 error_db_log("TSCR: DB table script_waypoint has waypoint for non-existant creature entry %u", pTemp.uiCreatureEntry);
                 continue;
             }
+
             if (!pCInfo->ScriptID)
                 error_db_log("TSCR: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.uiCreatureEntry);
+
             m_mPointMoveMap[uiEntry].push_back(pTemp);
             ++uiNodeCount;
         } while (pResult->NextRow());
+
         delete pResult;
+
         outstring_log("");
         outstring_log(">> Loaded %u Script Waypoint nodes.", uiNodeCount);
     }
diff --git a/src/bindings/scripts/system/system.h b/src/bindings/scripts/system/system.h
index 83742a3c329..479f856514a 100644
--- a/src/bindings/scripts/system/system.h
+++ b/src/bindings/scripts/system/system.h
@@ -1,10 +1,14 @@
 /* Copyright (C) 2006 - 2009 ScriptDev2 
 * This program is free software licensed under GPL version 2
 * Please see the included DOCS/LICENSE.TXT for more information */
+
 #ifndef SC_SYSTEM_H
 #define SC_SYSTEM_H
+
 extern DatabaseType TScriptDB;
+
 #define TEXT_SOURCE_RANGE -1000000                          //the amount of entries each text source has available
+
 //TODO: find better namings and definitions.
 //N=Neutral, A=Alliance, H=Horde.
 //NEUTRAL or FRIEND = Hostility to player surroundings (not a good definition)
@@ -14,16 +18,21 @@ enum eEscortFaction
     FACTION_ESCORT_A_NEUTRAL_PASSIVE    = 10,
     FACTION_ESCORT_H_NEUTRAL_PASSIVE    = 33,
     FACTION_ESCORT_N_NEUTRAL_PASSIVE    = 113,
+
     FACTION_ESCORT_A_NEUTRAL_ACTIVE     = 231,
     FACTION_ESCORT_H_NEUTRAL_ACTIVE     = 232,
     FACTION_ESCORT_N_NEUTRAL_ACTIVE     = 250,
+
     FACTION_ESCORT_N_FRIEND_PASSIVE     = 290,
     FACTION_ESCORT_N_FRIEND_ACTIVE      = 495,
+
     FACTION_ESCORT_A_PASSIVE            = 774,
     FACTION_ESCORT_H_PASSIVE            = 775,
+
     FACTION_ESCORT_N_ACTIVE             = 1986,
     FACTION_ESCORT_H_ACTIVE             = 2046
 };
+
 struct ScriptPointMove
 {
     uint32 uiCreatureEntry;
@@ -33,6 +42,7 @@ struct ScriptPointMove
     float  fZ;
     uint32 uiWaitTime;
 };
+
 struct StringTextData
 {
     uint32 uiSoundId;
@@ -40,39 +50,53 @@ struct StringTextData
     uint32 uiLanguage;
     uint32 uiEmote;
 };
+
 #define pSystemMgr SystemMgr::Instance()
+
 class SystemMgr
 {
     public:
         SystemMgr();
         ~SystemMgr() {}
+
         static SystemMgr& Instance();
+
         //Maps and lists
         typedef UNORDERED_MAP TextDataMap;
         typedef UNORDERED_MAP > PointMoveMap;
+
         //Database
         void LoadVersion();
         void LoadScriptTexts();
         void LoadScriptTextsCustom();
         void LoadScriptWaypoints();
+
         //Retrive from storage
         StringTextData const* GetTextData(int32 uiTextId) const
         {
             TextDataMap::const_iterator itr = m_mTextDataMap.find(uiTextId);
+
             if (itr == m_mTextDataMap.end())
                 return NULL;
+
             return &itr->second;
         }
+
         std::vector const &GetPointMoveList(uint32 uiCreatureEntry) const
         {
             static std::vector vEmpty;
+
             PointMoveMap::const_iterator itr = m_mPointMoveMap.find(uiCreatureEntry);
+
             if (itr == m_mPointMoveMap.end())
                 return vEmpty;
+
             return itr->second;
         }
+
     protected:
         TextDataMap     m_mTextDataMap;                     //additional data for text strings
         PointMoveMap    m_mPointMoveMap;                    //coordinates for waypoints
 };
+
 #endif
diff --git a/src/bindings/scripts/trinityscripts.rc b/src/bindings/scripts/trinityscripts.rc
index 0dfb6f08ec6..ae93c329eb6 100644
--- a/src/bindings/scripts/trinityscripts.rc
+++ b/src/bindings/scripts/trinityscripts.rc
@@ -15,34 +15,43 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "../../trinitycore/resource.h"
 #include "../../shared/revision.h"
+
 #define APSTUDIO_READONLY_SYMBOLS
 /////////////////////////////////////////////////////////////////////////////
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
 #include "windows.h" //"afxres.h"
+
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS
+
 /////////////////////////////////////////////////////////////////////////////
 //
 // Icon
 //
+
 // Icon with lowest ID value placed first to ensure application icon
 // remains consistent on all systems.
 //IDI_APPICON             ICON                    "TrinityRealm.ico"
+
 /////////////////////////////////////////////////////////////////////////////
 // Neutre (Par défaut système) resources
+
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
 #ifdef _WIN32
 LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
 #pragma code_page(1252)
 #endif //_WIN32
+
 /////////////////////////////////////////////////////////////////////////////
 //
 // Version
 //
+
 VS_VERSION_INFO VERSIONINFO
  FILEVERSION FILEVER
  PRODUCTVERSION PRODUCTVER
diff --git a/src/framework/Dynamic/FactoryHolder.h b/src/framework/Dynamic/FactoryHolder.h
index ab3671fc2c3..858b8c1e1d3 100644
--- a/src/framework/Dynamic/FactoryHolder.h
+++ b/src/framework/Dynamic/FactoryHolder.h
@@ -17,12 +17,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_FACTORY_HOLDER
 #define TRINITY_FACTORY_HOLDER
+
 #include "Platform/Define.h"
 #include "Utilities/TypeList.h"
 #include "ObjectRegistry.h"
 #include "Policies/SingletonImp.h"
+
 /** FactoryHolder holds a factory object of a specific type
  */
 template
@@ -31,16 +34,20 @@ class TRINITY_DLL_DECL FactoryHolder
     public:
         typedef ObjectRegistry, Key > FactoryHolderRegistry;
         typedef Trinity::Singleton FactoryHolderRepository;
+
         FactoryHolder(Key k) : i_key(k) {}
         virtual ~FactoryHolder() {}
         inline Key key() const { return i_key; }
+
         void RegisterSelf(void) { FactoryHolderRepository::Instance().InsertItem(this, i_key); }
         void DeregisterSelf(void) { FactoryHolderRepository::Instance().RemoveItem(this, false); }
+
         /// Abstract Factory create method
         virtual T* Create(void *data = NULL) const = 0;
     private:
         Key i_key;
 };
+
 /** Permissible is a classic way of letting the object decide
  * whether how good they handle things.  This is not retricted
  * to factory selectors.
diff --git a/src/framework/Dynamic/ObjectRegistry.h b/src/framework/Dynamic/ObjectRegistry.h
index d266c280eb5..8c2659e8f53 100644
--- a/src/framework/Dynamic/ObjectRegistry.h
+++ b/src/framework/Dynamic/ObjectRegistry.h
@@ -17,14 +17,18 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_OBJECTREGISTRY_H
 #define TRINITY_OBJECTREGISTRY_H
+
 #include "Platform/Define.h"
 #include "Utilities/UnorderedMap.h"
 #include "Policies/Singleton.h"
+
 #include 
 #include 
 #include 
+
 /** ObjectRegistry holds all registry item of the same type
  */
 template
@@ -32,12 +36,14 @@ class TRINITY_DLL_DECL ObjectRegistry
 {
     public:
         typedef std::map RegistryMapType;
+
         /// Returns a registry item
         const T* GetRegistryItem(Key key) const
         {
             typename RegistryMapType::const_iterator iter = i_registeredObjects.find(key);
             return( iter == i_registeredObjects.end() ? NULL : iter->second );
         }
+
         /// Inserts a registry item
         bool InsertItem(T *obj, Key key, bool override = false)
         {
@@ -49,9 +55,11 @@ class TRINITY_DLL_DECL ObjectRegistry
                 delete iter->second;
                 i_registeredObjects.erase(iter);
             }
+
             i_registeredObjects[key] = obj;
             return true;
         }
+
         /// Removes a registry item
         void RemoveItem(Key key, bool delete_object = true)
         {
@@ -63,11 +71,13 @@ class TRINITY_DLL_DECL ObjectRegistry
                 i_registeredObjects.erase(iter);
             }
         }
+
         /// Returns true if registry contains an item
         bool HasItem(Key key) const
         {
             return (i_registeredObjects.find(key) != i_registeredObjects.end());
         }
+
         /// Inefficiently return a vector of registered items
         unsigned int GetRegisteredItems(std::vector &l) const
         {
@@ -77,14 +87,17 @@ class TRINITY_DLL_DECL ObjectRegistry
                 l[sz++] = iter->first;
             return i_registeredObjects.size();
         }
+
         /// Return the map of registered items
         RegistryMapType const &GetRegisteredItems() const
         {
             return i_registeredObjects;
         }
+
     private:
         RegistryMapType i_registeredObjects;
         friend class Trinity::OperatorNew >;
+
         // protected for friend use since it should be a singleton
         ObjectRegistry() {}
         ~ObjectRegistry()
diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h
index 04f0735ce87..cebaebc68c6 100644
--- a/src/framework/GameSystem/Grid.h
+++ b/src/framework/GameSystem/Grid.h
@@ -17,8 +17,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_GRID_H
 #define TRINITY_GRID_H
+
 /*
   @class Grid
   Grid is a logical segment of the game world represented inside TrinIty.
@@ -29,12 +31,15 @@
   this is implementation specific to the loader class.  From the
   Grid's perspective, the loader meets its API requirement is suffice.
 */
+
 #include "Platform/Define.h"
 #include "Policies/ThreadingModel.h"
 #include "TypeContainer.h"
 #include "TypeContainerVisitor.h"
+
 // forward declaration
 template class GridLoader;
+
 template
 <
 class ACTIVE_OBJECT,
@@ -47,10 +52,12 @@ class TRINITY_DLL_DECL Grid
     // allows the GridLoader to access its internals
     template friend class GridLoader;
     public:
+
         /** destructor to clean up its resources. This includes unloading the
         grid if it has not been unload.
         */
         ~Grid() {}
+
         /** an object of interested enters the grid
          */
         template void AddWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
@@ -58,6 +65,7 @@ class TRINITY_DLL_DECL Grid
             if(!i_objects.template insert(hdl, obj))
                 assert(false);
         }
+
         /** an object of interested exits the grid
          */
         template void RemoveWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
@@ -65,38 +73,47 @@ class TRINITY_DLL_DECL Grid
             if(!i_objects.template remove(obj, hdl))
                 assert(false);
         }
+
         /** Accessors: Returns a specific type of object in the WORDL_OBJECT_TYPES
          */
         template const SPECIFIC_OBJECT* GetWorldObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT* fake) const { return i_objects.template find(hdl); }
         template       SPECIFIC_OBJECT* GetWorldObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake)       { return i_objects.template find(hdl, fake); }
+
         /** Refreshes/update the grid. This required for remote grids.
          */
         void RefreshGrid(void) { /* TBI */}
+
         /** Locks a grid.  Any object enters must wait until the grid is unlock.
          */
         void LockGrid(void) { /* TBI */ }
+
         /** Unlocks the grid.
          */
         void UnlockGrid(void) { /* TBI */ }
+
         /** Grid visitor for grid objects
          */
         template void Visit(TypeContainerVisitor > &visitor)
         {
             visitor.Visit(i_container);
         }
+
         /** Grid visitor for world objects
          */
         template void Visit(TypeContainerVisitor > &visitor)
         {
             visitor.Visit(i_objects);
         }
+
         /** Returns the number of object within the grid.
          */
         unsigned int ActiveObjectsInGrid(void) const { return /*m_activeGridObjects.size()+*/i_objects.template Count(); }
+
         /** Accessors: Returns a specific type of object in the GRID_OBJECT_TYPES
          */
         template const SPECIFIC_OBJECT* GetGridObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake) const { return i_container.template find(hdl, fake); }
         template       SPECIFIC_OBJECT* GetGridObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake)       { return i_container.template find(hdl, fake); }
+
         /** Inserts a container type object into the grid.
          */
         template void AddGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
@@ -104,6 +121,7 @@ class TRINITY_DLL_DECL Grid
             if(!i_container.template insert(hdl, obj))
                 assert(false);
         }
+
         /** Removes a containter type object from the grid
          */
         template void RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
@@ -111,17 +129,21 @@ class TRINITY_DLL_DECL Grid
             if(!i_container.template remove(obj, hdl))
                 assert(false);
         }
+
         /*bool NoWorldObjectInGrid() const
         {
             return i_objects.GetElements().isEmpty();
         }
+
         bool NoGridObjectInGrid() const
         {
             return i_container.GetElements().isEmpty();
         }*/
     private:
+
         typedef typename ThreadModel::Lock Guard;
         typedef typename ThreadModel::VolatileType VolatileType;
+
         TypeMapContainer i_container;
         TypeMapContainer i_objects;
         //typedef std::set ActiveGridObjects;
diff --git a/src/framework/GameSystem/GridLoader.h b/src/framework/GameSystem/GridLoader.h
index c5eb1155e48..8a483044f8f 100644
--- a/src/framework/GameSystem/GridLoader.h
+++ b/src/framework/GameSystem/GridLoader.h
@@ -17,8 +17,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_GRIDLOADER_H
 #define TRINITY_GRIDLOADER_H
+
 /**
   @class GridLoader
   The GridLoader is working in conjuction with the Grid and responsible
@@ -29,9 +31,11 @@
   delicate its loading and unloading for the actualy loader and unloader.
   GridLoader manages the grid (both local and remote).
  */
+
 #include "Platform/Define.h"
 #include "Grid.h"
 #include "TypeContainerVisitor.h"
+
 template
 <
 class ACTIVE_OBJECT,
@@ -41,6 +45,7 @@ class GRID_OBJECT_TYPES
 class TRINITY_DLL_DECL GridLoader
 {
     public:
+
         /** Loads the grid
          */
         template
@@ -50,6 +55,7 @@ class TRINITY_DLL_DECL GridLoader
             loader.Load(grid);
             grid.UnlockGrid();
         }
+
         /** Stop the grid
          */
         template
diff --git a/src/framework/GameSystem/GridRefManager.h b/src/framework/GameSystem/GridRefManager.h
index 3d97135f867..bd32f836e18 100644
--- a/src/framework/GameSystem/GridRefManager.h
+++ b/src/framework/GameSystem/GridRefManager.h
@@ -17,18 +17,24 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef _GRIDREFMANAGER
 #define _GRIDREFMANAGER
+
 #include "Utilities/LinkedReference/RefManager.h"
+
 template
 class GridReference;
+
 template
 class GridRefManager : public RefManager, OBJECT>
 {
     public:
         typedef LinkedListHead::Iterator< GridReference > iterator;
+
         GridReference* getFirst() { return (GridReference*)RefManager, OBJECT>::getFirst(); }
         GridReference* getLast() { return (GridReference*)RefManager, OBJECT>::getLast(); }
+
         iterator begin() { return iterator(getFirst()); }
         iterator end() { return iterator(NULL); }
         iterator rbegin() { return iterator(getLast()); }
diff --git a/src/framework/GameSystem/GridReference.h b/src/framework/GameSystem/GridReference.h
index e6bd5da1237..d4bd6752515 100644
--- a/src/framework/GameSystem/GridReference.h
+++ b/src/framework/GameSystem/GridReference.h
@@ -17,11 +17,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef _GRIDREFERENCE_H
 #define _GRIDREFERENCE_H
+
 #include "Utilities/LinkedReference/Reference.h"
+
 template
 class GridRefManager;
+
 template
 class TRINITY_DLL_SPEC GridReference : public Reference, OBJECT>
 {
diff --git a/src/framework/GameSystem/NGrid.h b/src/framework/GameSystem/NGrid.h
index f6dac7db955..6ba5d10ffc1 100644
--- a/src/framework/GameSystem/NGrid.h
+++ b/src/framework/GameSystem/NGrid.h
@@ -17,13 +17,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_NGRID_H
 #define TRINITY_NGRID_H
+
 /** NGrid is nothing more than a wrapper of the Grid with an NxN cells
  */
+
 #include "GameSystem/Grid.h"
 #include "GameSystem/GridReference.h"
 #include "Timer.h"
+
 class GridInfo
 {
 public:
@@ -37,15 +41,18 @@ public:
     void setUnloadReferenceLock( bool on ) { i_unloadReferenceLock = on; }
     void incUnloadActiveLock() { ++i_unloadActiveLockCount; }
     void decUnloadActiveLock() { if(i_unloadActiveLockCount) --i_unloadActiveLockCount; }
+
     void setTimer(const TimeTracker& pTimer) { i_timer = pTimer; }
     void ResetTimeTracker(time_t interval) { i_timer.Reset(interval); }
     void UpdateTimeTracker(time_t diff) { i_timer.Update(diff); }
+
 private:
     TimeTracker i_timer;
     uint16 i_unloadActiveLockCount : 16;                    // lock from active object spawn points (prevent clone loading)
     bool   i_unloadExplicitLock    : 1;                     // explicit manual lock or config setting
     bool   i_unloadReferenceLock   : 1;                     // lock from instance map copy
 };
+
 typedef enum
 {
     GRID_STATE_INVALID = 0,
@@ -54,6 +61,7 @@ typedef enum
     GRID_STATE_REMOVAL= 3,
     MAX_GRID_STATE = 4
 } grid_state_t;
+
 template
 <
 unsigned int N,
@@ -65,36 +73,42 @@ class ThreadModel = Trinity::SingleThreaded
 class TRINITY_DLL_DECL NGrid
 {
     public:
+
         typedef Grid GridType;
         NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true)
             : i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false)
         {
             i_GridInfo = GridInfo(expiry, unload);
         }
+
         const GridType& operator()(unsigned short x, unsigned short y) const
         {
             ASSERT(x < N);
             ASSERT(y < N);
             return i_cells[x][y];
         }
+ 
         GridType& operator()(unsigned short x, unsigned short y)
         {
             ASSERT(x < N);
             ASSERT(y < N);
             return i_cells[x][y];
         }
+
         const uint32& GetGridId(void) const { return i_gridId; }
         void SetGridId(const uint32 id) const { i_gridId = id; }
         grid_state_t GetGridState(void) const { return i_cellstate; }
         void SetGridState(grid_state_t s) { i_cellstate = s; }
         int32 getX() const { return i_x; }
         int32 getY() const { return i_y; }
+
         void link(GridRefManager >* pTo)
         {
             i_Reference.link(pTo, this);
         }
         bool isGridObjectDataLoaded() const { return i_GridObjectDataLoaded; }
         void setGridObjectDataLoaded(bool pLoaded) { i_GridObjectDataLoaded = pLoaded; }
+
         GridInfo* getGridInfoRef() { return &i_GridInfo; }
         const TimeTracker& getTimeTracker() const { return i_GridInfo.getTimeTracker(); }
         bool getUnloadLock() const { return i_GridInfo.getUnloadLock(); }
@@ -104,24 +118,29 @@ class TRINITY_DLL_DECL NGrid
         void decUnloadActiveLock() { i_GridInfo.decUnloadActiveLock(); }
         void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); }
         void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); }
+
         template void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
         {
             getGridType(x, y).AddWorldObject(obj, hdl);
         }
+
         template void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
         {
             getGridType(x, y).RemoveWorldObject(obj, hdl);
         }
+
         template void Visit(TypeContainerVisitor > &visitor)
         {
             for(unsigned int x=0; x < N; ++x)
                 for(unsigned int y=0; y < N; ++y)
                     getGridType(x, y).Visit(visitor);
         }
+
         template void Visit(const uint32 &x, const uint32 &y, TypeContainerVisitor > &visitor)
         {
             getGridType(x, y).Visit(visitor);
         }
+
         unsigned int ActiveObjectsInGrid(void) const
         {
             unsigned int count=0;
@@ -130,29 +149,36 @@ class TRINITY_DLL_DECL NGrid
                     count += i_cells[x][y].ActiveObjectsInGrid();
             return count;
         }
+
         template const SPECIFIC_OBJECT* GetGridObject(const uint32 x, const uint32 y, OBJECT_HANDLE hdl) const
         {
             return getGridType(x, y).template GetGridObject(hdl);
         }
+
         template SPECIFIC_OBJECT* GetGridObject(const uint32 x, const uint32 y, OBJECT_HANDLE hdl)
         {
             return getGridType(x, y).template GetGridObject(hdl);
         }
+
         template bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
         {
             return getGridType(x, y).AddGridObject(hdl, obj);
         }
+
         template bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
         {
             return getGridType(x, y).RemoveGridObject(obj, hdl);
         }
+
     private:
+
         GridType& getGridType(const uint32& x, const uint32& y)
         {
             ASSERT(x < N);
             ASSERT(y < N);
             return i_cells[x][y];
         }
+
         uint32 i_gridId;
         GridInfo i_GridInfo;
         GridReference > i_Reference;
diff --git a/src/framework/GameSystem/TypeContainer.h b/src/framework/GameSystem/TypeContainer.h
index 9d32d398527..9e4c6da65e2 100644
--- a/src/framework/GameSystem/TypeContainer.h
+++ b/src/framework/GameSystem/TypeContainer.h
@@ -17,17 +17,21 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_TYPECONTAINER_H
 #define TRINITY_TYPECONTAINER_H
+
 /*
  * Here, you'll find a series of containers that allow you to hold multiple
  * types of object at the same time.
  */
+
 #include 
 #include 
 #include "Platform/Define.h"
 #include "Utilities/TypeList.h"
 #include "GameSystem/GridRefManager.h"
+
 /*
  * @class ContainerMapList is a mulit-type container for map elements
  * By itself its meaningless but collaborate along with TypeContainers,
@@ -38,6 +42,7 @@ template struct ContainerMapList
     //std::map _element;
     GridRefManager _element;
 };
+
 template<> struct ContainerMapList                /* nothing is in type null */
 {
 };
@@ -46,6 +51,7 @@ template struct ContainerMapList >
     ContainerMapList _elements;
     ContainerMapList _TailElements;
 };
+
 /*
  * @class ContaierArrayList is a multi-type container for
  * array of elements.
@@ -54,6 +60,7 @@ template struct ContainerArrayList
 {
     std::vector _element;
 };
+
 // termination condition
 template<> struct ContainerArrayList {};
 // recursion
@@ -62,6 +69,7 @@ template struct ContainerArrayList >
     ContainerArrayList _elements;
     ContainerArrayList _TailElements;
 };
+
 /*
  * @class ContainerList is a simple list of different types of elements
  *
@@ -70,6 +78,7 @@ template struct ContainerList
 {
     OBJECT _element;
 };
+
 /* TypeNull is underfined */
 template<> struct ContainerList {};
 template struct ContainerList >
@@ -77,35 +86,44 @@ template struct ContainerList >
     ContainerList _elements;
     ContainerMapList _TailElements;
 };
+
 #include "TypeContainerFunctions.h"
+
 /*
  * @class TypeMapContainer contains a fixed number of types and is
  * determined at compile time.  This is probably the most complicated
  * class and do its simplest thing, that is, holds objects
  * of different types.
  */
+
 template
 class TRINITY_DLL_DECL TypeMapContainer
 {
     public:
         template size_t Count() const { return Trinity::Count(i_elements, (SPECIFIC_TYPE*)NULL); }
+
         template SPECIFIC_TYPE* find(OBJECT_HANDLE hdl, SPECIFIC_TYPE *fake) { return Trinity::Find(i_elements, hdl,fake); }
+
         /// find a specific type of object in the container
         template const SPECIFIC_TYPE* find(OBJECT_HANDLE hdl, SPECIFIC_TYPE *fake) const { return Trinity::Find(i_elements, hdl,fake); }
+
         /// inserts a specific object into the container
         template bool insert(OBJECT_HANDLE hdl, SPECIFIC_TYPE *obj)
         {
             SPECIFIC_TYPE* t = Trinity::Insert(i_elements, obj, hdl);
             return (t != NULL);
         }
+
         ///  Removes the object from the container, and returns the removed object
         template bool remove(SPECIFIC_TYPE* obj, OBJECT_HANDLE hdl)
         {
             SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj, hdl);
             return (t != NULL);
         }
+
         ContainerMapList & GetElements(void) { return i_elements; }
         const ContainerMapList & GetElements(void) const { return i_elements;}
+
     private:
         ContainerMapList i_elements;
 };
diff --git a/src/framework/GameSystem/TypeContainerFunctions.h b/src/framework/GameSystem/TypeContainerFunctions.h
index 618c2584961..f9945f84ac7 100644
--- a/src/framework/GameSystem/TypeContainerFunctions.h
+++ b/src/framework/GameSystem/TypeContainerFunctions.h
@@ -17,16 +17,20 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TYPECONTAINER_FUNCTIONS_H
 #define TYPECONTAINER_FUNCTIONS_H
+
 /*
  * Here you'll find a list of helper functions to make
  * the TypeContainer usefull.  Without it, its hard
  * to access or mutate the container.
  */
+
 #include "Platform/Define.h"
 #include "Utilities/TypeList.h"
 #include 
+
 namespace Trinity
 {
     /* ContainerMapList Helpers */
@@ -35,22 +39,27 @@ namespace Trinity
     {
         return elements._element.getSize();
     };
+
     template size_t Count(const ContainerMapList &/*elements*/, SPECIFIC_TYPE* /*fake*/)
     {
         return 0;
     }
+
     template size_t Count(const ContainerMapList &/*elements*/, SPECIFIC_TYPE* /*fake*/)
     {
         return 0;
     }
+
     template size_t Count(const ContainerMapList >&elements, SPECIFIC_TYPE* fake)
     {
         return Count(elements._elements,fake);
     }
+
     template size_t Count(const ContainerMapList >&elements, SPECIFIC_TYPE* fake)
     {
         return Count(elements._TailElements, fake);
     }
+
     // non-const find functions
     template SPECIFIC_TYPE* Find(ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/)
     {
@@ -58,20 +67,24 @@ namespace Trinity
         //return (iter == elements._element.end() ? NULL : iter->second);
         return NULL;
     };
+
     template SPECIFIC_TYPE* Find(ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/)
     {
         return NULL;                                        // terminate recursion
     }
+
     template SPECIFIC_TYPE* Find(ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/)
     {
         return NULL;                                        // this is a missed
     }
+
     template SPECIFIC_TYPE* Find(ContainerMapList >&/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/)
     {
         //SPECIFIC_TYPE* t = Find(elements._elements, hdl,fake);
         //return (t != NULL ? t :Find(elements._TailElements, hdl,fake));
         return NULL;
     }
+
     // const find functions
     template const SPECIFIC_TYPE* Find(const ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/)
     {
@@ -79,21 +92,26 @@ namespace Trinity
         //return (iter == elements._element.end() ? NULL : iter->second);
         return NULL;
     };
+
     template const SPECIFIC_TYPE* Find(const ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/)
     {
         return NULL;
     }
+
     template const SPECIFIC_TYPE* Find(const ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/)
     {
         return NULL;
     }
+
     template SPECIFIC_TYPE* Find(const ContainerMapList >&elements, OBJECT_HANDLE hdl, SPECIFIC_TYPE* fake)
     {
         SPECIFIC_TYPE* t = Find(elements._elements, hdl,fake);
         if( t)
             return t;
+
         return Find(elements._TailElement, hdl,fake);
     }
+
     // non-const insert functions
     template SPECIFIC_TYPE* Insert(ContainerMapList &elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE /*hdl*/)
     {
@@ -101,21 +119,25 @@ namespace Trinity
         obj->GetGridRef().link(&elements._element, obj);
         return obj;
     };
+
     template SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/)
     {
         return NULL;
     }
+
     // this is a missed
     template SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/)
     {
         return NULL;                                        // a missed
     }
+
     // Recursion
     template SPECIFIC_TYPE* Insert(ContainerMapList >&elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE hdl)
     {
         SPECIFIC_TYPE* t= Insert(elements._elements, obj, hdl);
         return (t != NULL ? t : Insert(elements._TailElements, obj, hdl));
     }
+
     // non-const remove method
     template SPECIFIC_TYPE* Remove(ContainerMapList & /*elements*/, SPECIFIC_TYPE *obj, OBJECT_HANDLE /*hdl*/)
     {
@@ -129,21 +151,25 @@ namespace Trinity
         obj->GetGridRef().unlink();
         return obj;
     }
+
     template SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/)
     {
         return NULL;
     }
+
     // this is a missed
     template SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/)
     {
         return NULL;                                        // a missed
     }
+
     template SPECIFIC_TYPE* Remove(ContainerMapList > &elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE hdl)
     {
         // The head element is bad
         SPECIFIC_TYPE* t = Remove(elements._elements, obj, hdl);
         return ( t != NULL ? t : Remove(elements._TailElements, obj, hdl) );
     }
+
 }
 #endif
 
diff --git a/src/framework/GameSystem/TypeContainerVisitor.h b/src/framework/GameSystem/TypeContainerVisitor.h
index fc861cfe3da..97570b370c2 100644
--- a/src/framework/GameSystem/TypeContainerVisitor.h
+++ b/src/framework/GameSystem/TypeContainerVisitor.h
@@ -17,82 +17,101 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_TYPECONTAINERVISITOR_H
 #define TRINITY_TYPECONTAINERVISITOR_H
+
 /*
  * @class TypeContainerVisitor is implemented as a visitor pattern.  It is
  * a visitor to the TypeContainerList or TypeContainerMapList.  The visitor has
  * to overload its types as a visit method is called.
  */
+
 #include "Platform/Define.h"
 #include "TypeContainer.h"
+
 // forward declaration
 template class TypeContainerVisitor;
+
 // visitor helper
 template void VisitorHelper(VISITOR &v, TYPE_CONTAINER &c)
 {
     v.Visit(c);
 };
+
 // terminate condition for container list
 template void VisitorHelper(VISITOR &v, ContainerList &c)
 {
 }
+
 template void VisitorHelper(VISITOR &v, ContainerList &c)
 {
     v.Visit(c._element);
 }
+
 // recursion for container list
 template void VisitorHelper(VISITOR &v, ContainerList > &c)
 {
     VisitorHelper(v, c._elements);
     VisitorHelper(v, c._TailElements);
 }
+
 // terminate condition container map list
 template void VisitorHelper(VISITOR &/*v*/, ContainerMapList &/*c*/)
 {
 }
+
 template void VisitorHelper(VISITOR &v, ContainerMapList &c)
 {
     v.Visit(c._element);
 }
+
 // recursion container map list
 template void VisitorHelper(VISITOR &v, ContainerMapList > &c)
 {
     VisitorHelper(v, c._elements);
     VisitorHelper(v, c._TailElements);
 }
+
 // array list
 template void VisitorHelper(VISITOR &v, ContainerArrayList &c)
 {
     v.Visit(c._element);
 }
+
 template void VisitorHelper(VISITOR &/*v*/, ContainerArrayList &/*c*/)
 {
 }
+
 // recursion
 template void VisitorHelper(VISITOR &v, ContainerArrayList > &c)
 {
     VisitorHelper(v, c._elements);
     VisitorHelper(v, c._TailElements);
 }
+
 // for TypeMapContainer
 template void VisitorHelper(VISITOR &v, TypeMapContainer &c)
 {
     VisitorHelper(v, c.GetElements());
 }
+
 template
 class TRINITY_DLL_DECL TypeContainerVisitor
 {
     public:
         TypeContainerVisitor(VISITOR &v) : i_visitor(v) {}
+
         void Visit(TYPE_CONTAINER &c)
         {
             VisitorHelper(i_visitor, c);
         }
+
         void Visit(const TYPE_CONTAINER &c) const
         {
             VisitorHelper(i_visitor, c);
         }
+
     private:
         VISITOR &i_visitor;
 };
diff --git a/src/framework/Network/SocketDefines.h b/src/framework/Network/SocketDefines.h
index 713562f0376..e69f2fb41e0 100644
--- a/src/framework/Network/SocketDefines.h
+++ b/src/framework/Network/SocketDefines.h
@@ -17,17 +17,23 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_SOCKETDEFINES_H
 #define TRINITY_SOCKETDEFINES_H
+
 #ifdef WIN32
+
 /* Windows socket definitions
  */
 #define FD_SETSIZE 1024
 #include 
 #include 
+
 typedef SOCKET SocketHandle;
 typedef fd_set SelectSet;
+
 #else
+
 /* The unix socket definitions
  */
 #include 
@@ -35,6 +41,7 @@ typedef fd_set SelectSet;
 #ifdef __APPLE_CC__
 #include 
 #endif
+
 typedef int SocketHandle;
 typedef fd_set SelectSet;
 #endif
diff --git a/src/framework/Platform/CompilerDefs.h b/src/framework/Platform/CompilerDefs.h
index 863d8bdc2ce..691acb2e6d7 100644
--- a/src/framework/Platform/CompilerDefs.h
+++ b/src/framework/Platform/CompilerDefs.h
@@ -17,12 +17,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_COMPILERDEFS_H
 #define TRINITY_COMPILERDEFS_H
+
 #define PLATFORM_WINDOWS 0
 #define PLATFORM_UNIX    1
 #define PLATFORM_APPLE   2
 #define PLATFORM_INTEL   3
+
 // must be first (win 64 also define WIN32)
 #if defined( _WIN64 )
 #  define PLATFORM PLATFORM_WINDOWS
@@ -35,10 +38,12 @@
 #else
 #  define PLATFORM PLATFORM_UNIX
 #endif
+
 #define COMPILER_MICROSOFT 0
 #define COMPILER_GNU       1
 #define COMPILER_BORLAND   2
 #define COMPILER_INTEL     3
+
 #ifdef _MSC_VER
 #  define COMPILER COMPILER_MICROSOFT
 #elif defined( __BORLANDC__ )
@@ -50,6 +55,7 @@
 #else
 #  pragma error "FATAL ERROR: Unknown compiler."
 #endif
+
 #if COMPILER == COMPILER_MICROSOFT
 #  pragma warning( disable : 4267 )                         // conversion from 'size_t' to 'int', possible loss of data
 #  pragma warning( disable : 4786 )                         // identifier was truncated to '255' characters in the debug information
diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h
index df4d7deaf7d..d29a53dbf31 100644
--- a/src/framework/Platform/Define.h
+++ b/src/framework/Platform/Define.h
@@ -17,14 +17,20 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef TRINITY_DEFINE_H
 #define TRINITY_DEFINE_H
+
 #include 
+
 #include 
 #include 
+
 #include "Platform/CompilerDefs.h"
+
 #define TRINITY_LITTLEENDIAN 0
 #define TRINITY_BIGENDIAN    1
+
 #if !defined(TRINITY_ENDIAN)
 #  if defined (ACE_BIG_ENDIAN)
 #    define TRINITY_ENDIAN TRINITY_BIGENDIAN
@@ -32,6 +38,7 @@
 #    define TRINITY_ENDIAN TRINITY_LITTLEENDIAN
 #  endif //ACE_BYTE_ORDER
 #endif //TRINITY_ENDIAN
+
 #if PLATFORM == PLATFORM_WINDOWS
 #  define TRINITY_EXPORT __declspec(dllexport)
 #  define TRINITY_LIBRARY_HANDLE HMODULE
@@ -72,6 +79,7 @@
 #  endif //__APPLE_CC__
 #  define TRINITY_PATH_MAX PATH_MAX
 #endif //PLATFORM
+
 #if PLATFORM == PLATFORM_WINDOWS
 #  ifdef TRINITY_WIN32_DLL_IMPORT
 #    define TRINITY_DLL_DECL __declspec(dllimport)
@@ -85,6 +93,7 @@
 #else //PLATFORM != PLATFORM_WINDOWS
 #  define TRINITY_DLL_DECL
 #endif //PLATFORM
+
 #if PLATFORM == PLATFORM_WINDOWS
 #  define TRINITY_DLL_SPEC __declspec(dllexport)
 #  ifndef DECLSPEC_NORETURN
@@ -94,6 +103,7 @@
 #  define TRINITY_DLL_SPEC
 #  define DECLSPEC_NORETURN
 #endif //PLATFORM
+
 #if !defined(DEBUG)
 #  define TRINITY_INLINE inline
 #else //DEBUG
@@ -102,6 +112,7 @@
 #  endif //TRINITY_DEBUG
 #  define TRINITY_INLINE
 #endif //!DEBUG
+
 #if COMPILER == COMPILER_GNU
 #  define ATTR_NORETURN __attribute__((noreturn))
 #  define ATTR_PRINTF(F,V) __attribute__ ((format (printf, F, V)))
@@ -109,6 +120,7 @@
 #  define ATTR_NORETURN
 #  define ATTR_PRINTF(F,V)
 #endif //COMPILER == COMPILER_GNU
+
 typedef ACE_INT64 int64;
 typedef ACE_INT32 int32;
 typedef ACE_INT16 int16;
@@ -117,15 +129,19 @@ typedef ACE_UINT64 uint64;
 typedef ACE_UINT32 uint32;
 typedef ACE_UINT16 uint16;
 typedef ACE_UINT8 uint8;
+
 #if COMPILER != COMPILER_MICROSOFT
 typedef uint16      WORD;
 typedef uint32      DWORD;
 #endif //COMPILER
+
 typedef uint64 OBJECT_HANDLE;
+
 #define MaNGOS              Trinity
 #define MANGOS_DLL_DECL     TRINITY_DLL_DECL
 #define MANGOS_DLL_SPEC     TRINITY_DLL_SPEC
 #define GetMangosString     GetTrinityString
+
 #if defined(MANGOS_DEBUG) || defined(TRINITY_DEBUG)
 #  ifndef TRINITY_DEBUG
 #    define TRINITY_DEBUG
@@ -134,15 +150,19 @@ typedef uint64 OBJECT_HANDLE;
 #    define MANGOS_DEBUG
 #  endif
 #endif
+
 #if !defined(DEBUG) && !defined(MANGOS_DEBUG) && !defined(TRINITY_DEBUG)
 #define MULTI_THREAD_MAP
 #endif
+
 #ifdef MULTI_THREAD_MAP
 #define MAP_BASED_RAND_GEN
 #endif
+
 #ifndef CLIENT_VER
 #define CLIENT_VER 313
 #endif
 
+
 #endif //TRINITY_DEFINE_H
 
diff --git a/src/framework/Policies/CreationPolicy.h b/src/framework/Policies/CreationPolicy.h
index 9bca121b632..91bec9eab37 100644
--- a/src/framework/Policies/CreationPolicy.h
+++ b/src/framework/Policies/CreationPolicy.h
@@ -17,10 +17,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_CREATIONPOLICY_H
 #define TRINITY_CREATIONPOLICY_H
+
 #include 
 #include "Platform/Define.h"
+
 namespace Trinity
 {
     /**
@@ -33,6 +36,7 @@ namespace Trinity
             static T* Create(void) { return (new T); }
             static void Destroy(T *obj) { delete obj; }
     };
+
     /**
      * LocalStaticCreation policy creates an object on the stack
      * the first time call Create.
@@ -59,8 +63,10 @@ namespace Trinity
                 static MaxAlign si_localStatic;
                 return new(&si_localStatic) T;
             }
+
             static void Destroy(T *obj) { obj->~T(); }
     };
+
     /**
      * CreateUsingMalloc by pass the memory manger.
      */
@@ -74,12 +80,14 @@ namespace Trinity
                 if (!p) return 0;
                 return new(p) T;
             }
+
             static void Destroy(T* p)
             {
                 p->~T();
                 ::free(p);
             }
     };
+
     /**
      * CreateOnCallBack creates the object base on the call back.
      */
@@ -91,6 +99,7 @@ namespace Trinity
             {
                 return CALL_BACK::createCallBack();
             }
+
             static void Destroy(T *p)
             {
                 CALL_BACK::destroyCallBack(p);
diff --git a/src/framework/Policies/ObjectLifeTime.cpp b/src/framework/Policies/ObjectLifeTime.cpp
index d86e96a8e87..852e382a0e9 100644
--- a/src/framework/Policies/ObjectLifeTime.cpp
+++ b/src/framework/Policies/ObjectLifeTime.cpp
@@ -17,14 +17,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include 
 #include "ObjectLifeTime.h"
+
 namespace Trinity
 {
     extern "C" void external_wrapper(void *p)
     {
         std::atexit( (void (*)())p );
     }
+
     void TRINITY_DLL_SPEC at_exit( void (*func)() )
     {
         external_wrapper((void*)func);
diff --git a/src/framework/Policies/ObjectLifeTime.h b/src/framework/Policies/ObjectLifeTime.h
index 51765d4d4b4..86303f889fb 100644
--- a/src/framework/Policies/ObjectLifeTime.h
+++ b/src/framework/Policies/ObjectLifeTime.h
@@ -17,14 +17,19 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_OBJECTLIFETIME_H
 #define TRINITY_OBJECTLIFETIME_H
+
 #include 
 #include "Platform/Define.h"
+
 typedef void (* Destroyer)(void);
+
 namespace Trinity
 {
     void TRINITY_DLL_SPEC at_exit( void (*func)() );
+
     template 
         class TRINITY_DLL_DECL ObjectLifeTime
     {
@@ -33,8 +38,11 @@ namespace Trinity
             {
                 at_exit( destroyer );
             }
+
             DECLSPEC_NORETURN static void OnDeadReference(void) ATTR_NORETURN;
+
     };
+
     template 
         void ObjectLifeTime::OnDeadReference(void)       // We don't handle Dead Reference for now
     {
diff --git a/src/framework/Policies/Singleton.h b/src/framework/Policies/Singleton.h
index d8d4fd4df20..66daaba5a9a 100644
--- a/src/framework/Policies/Singleton.h
+++ b/src/framework/Policies/Singleton.h
@@ -17,14 +17,18 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_SINGLETON_H
 #define TRINITY_SINGLETON_H
+
 /**
  * @brief class Singleton
  */
+
 #include "CreationPolicy.h"
 #include "ThreadingModel.h"
 #include "ObjectLifeTime.h"
+
 namespace Trinity
 {
     template
@@ -38,14 +42,19 @@ namespace Trinity
     {
         public:
             static T& Instance();
+
         protected:
             Singleton() {};
+
         private:
+
             // Prohibited actions...this does not prevent hijacking.
             Singleton(const Singleton &);
             Singleton& operator=(const Singleton &);
+
             // Singleton Helpers
             static void DestroySingleton();
+
             // data structure
             typedef typename ThreadingModel::Lock Guard;
             static T *si_instance;
diff --git a/src/framework/Policies/SingletonImp.h b/src/framework/Policies/SingletonImp.h
index 44f2d184410..89a4738ae22 100644
--- a/src/framework/Policies/SingletonImp.h
+++ b/src/framework/Policies/SingletonImp.h
@@ -17,11 +17,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_SINGLETONIMPL_H
 #define TRINITY_SINGLETONIMPL_H
+
 #include "Singleton.h"
+
 // avoid the using namespace here cuz
 // its a .h file afterall
+
 template
 <
 typename T,
@@ -47,8 +51,10 @@ Trinity::Singleton::Instance()
             LifeTimePolicy::ScheduleCall(&DestroySingleton);
         }
     }
+
     return *si_instance;
 }
+
 template
 <
 typename T,
@@ -63,18 +69,22 @@ Trinity::Singleton::DestroySing
     si_instance = NULL;
     si_destroyed = true;
 }
+
 #define INSTANTIATE_SINGLETON_1(TYPE) \
     template class TRINITY_DLL_DECL Trinity::Singleton, Trinity::OperatorNew, Trinity::ObjectLifeTime >; \
     template<> TYPE* Trinity::Singleton, Trinity::OperatorNew, Trinity::ObjectLifeTime >::si_instance = 0; \
     template<> bool Trinity::Singleton, Trinity::OperatorNew, Trinity::ObjectLifeTime >::si_destroyed = false
+
 #define INSTANTIATE_SINGLETON_2(TYPE, THREADINGMODEL) \
     template class TRINITY_DLL_DECL Trinity::Singleton, Trinity::ObjectLifeTime >; \
     template<> TYPE* Trinity::Singleton, Trinity::ObjectLifeTime >::si_instance = 0; \
     template<> bool Trinity::Singleton, Trinity::ObjectLifeTime >::si_destroyed = false
+
 #define INSTANTIATE_SINGLETON_3(TYPE, THREADINGMODEL, CREATIONPOLICY ) \
     template class TRINITY_DLL_DECL Trinity::Singleton >; \
     template<> TYPE* Trinity::Singleton >::si_instance = 0; \
     template<> bool Trinity::Singleton >::si_destroyed = false
+
 #define INSTANTIATE_SINGLETON_4(TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME) \
     template class TRINITY_DLL_DECL Trinity::Singleton; \
     template<> TYPE* Trinity::Singleton::si_instance = 0; \
diff --git a/src/framework/Policies/ThreadingModel.h b/src/framework/Policies/ThreadingModel.h
index 3e0593789b5..a380fe78323 100644
--- a/src/framework/Policies/ThreadingModel.h
+++ b/src/framework/Policies/ThreadingModel.h
@@ -17,16 +17,21 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_THREADINGMODEL_H
 #define TRINITY_THREADINGMODEL_H
+
 /**
  * @class ThreadingModel
  *
  */
+
 #include "Platform/Define.h"
+
 namespace Trinity
 {
     inline void Guard(void *) {}
+
     template class TRINITY_DLL_DECL GeneralLock
     {
         public:
@@ -34,6 +39,7 @@ namespace Trinity
             {
                 i_mutex.acquire();
             }
+
             ~GeneralLock()
             {
                 i_mutex.release();
@@ -43,10 +49,12 @@ namespace Trinity
             GeneralLock& operator=(const GeneralLock &);
             MUTEX &i_mutex;
     };
+
     template 
         class TRINITY_DLL_DECL SingleThreaded
     {
         public:
+
             struct Lock                                     // empty object
             {
                 Lock() {}
@@ -55,31 +63,40 @@ namespace Trinity
                 {
                 }
             };
+
             typedef T VolatileType;
     };
+
     // object level lockable
     template
         class TRINITY_DLL_DECL ObjectLevelLockable
     {
         public:
             ObjectLevelLockable() : i_mtx() {}
+
             friend class Lock;
+
             class Lock
             {
                 public:
                     Lock(ObjectLevelLockable &host) : i_lock(host.i_mtx)
                     {
                     }
+
                 private:
                     GeneralLock i_lock;
             };
+
             typedef volatile T VolatileType;
+
         private:
             // prevent the compiler creating a copy construct
             ObjectLevelLockable(const ObjectLevelLockable &);
             ObjectLevelLockable& operator=(const ObjectLevelLockable &);
+
             MUTEX i_mtx;
     };
+
     template
         class TRINITY_DLL_DECL ClassLevelLockable
     {
@@ -87,7 +104,9 @@ namespace Trinity
             class Lock;
             friend class Lock;
             typedef volatile T VolatileType;
+
             ClassLevelLockable() {}
+
             class Lock
             {
                 public:
@@ -96,11 +115,15 @@ namespace Trinity
                     Lock() { ClassLevelLockable::si_mtx.acquire(); }
                     ~Lock() { ClassLevelLockable::si_mtx.release(); }
             };
+
         private:
             static MUTEX si_mtx;
     };
+
 }
+
 template MUTEX Trinity::ClassLevelLockable::si_mtx;
+
 #define INSTANTIATE_CLASS_MUTEX(CTYPE,MUTEX) \
     template class TRINITY_DLL_DECL Trinity::ClassLevelLockable
 #endif
diff --git a/src/framework/Utilities/ByteConverter.h b/src/framework/Utilities/ByteConverter.h
index 38910abfe4d..d9282c1787d 100644
--- a/src/framework/Utilities/ByteConverter.h
+++ b/src/framework/Utilities/ByteConverter.h
@@ -17,13 +17,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef TRINITY_BYTECONVERTER_H
 #define TRINITY_BYTECONVERTER_H
+
 /** ByteConverter reverse your byte order.  This is use
     for cross platform where they have different endians.
  */
+
 #include
 #include
+
 namespace ByteConverter
 {
     template
@@ -32,13 +36,16 @@ namespace ByteConverter
         std::swap(*val, *(val + T - 1));
         convert(val + 1);
     }
+
     template<> inline void convert<0>(char *) {}
     template<> inline void convert<1>(char *) {}            // ignore central byte
+
     template inline void apply(T *val)
     {
         convert((char *)(val));
     }
 }
+
 #if TRINITY_ENDIAN == TRINITY_BIGENDIAN
 template inline void EndianConvert(T& val) { ByteConverter::apply(&val); }
 template inline void EndianConvertReverse(T&) { }
@@ -46,11 +53,14 @@ template inline void EndianConvertReverse(T&) { }
 template inline void EndianConvert(T&) { }
 template inline void EndianConvertReverse(T& val) { ByteConverter::apply(&val); }
 #endif
+
 template void EndianConvert(T*);         // will generate link error
 template void EndianConvertReverse(T*);  // will generate link error
+
 inline void EndianConvert(uint8&) { }
 inline void EndianConvert( int8&) { }
 inline void EndianConvertReverse(uint8&) { }
 inline void EndianConvertReverse( int8&) { }
+
 #endif
 
diff --git a/src/framework/Utilities/Callback.h b/src/framework/Utilities/Callback.h
index 959a493944f..28c0931e6e7 100644
--- a/src/framework/Utilities/Callback.h
+++ b/src/framework/Utilities/Callback.h
@@ -17,9 +17,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_CALLBACK_H
 #define TRINITY_CALLBACK_H
+
 /// ------------ BASE CLASSES ------------
+
 namespace Trinity
 {
     template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void >
@@ -40,6 +43,7 @@ namespace Trinity
             _Callback(_Callback < Class, ParamType1, ParamType2, ParamType3, ParamType4> const& cb)
                 : m_object(cb.object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3), m_param4(cb.m_param4) {}
     };
+
     template < class Class, typename ParamType1, typename ParamType2, typename ParamType3 >
     class _Callback < Class, ParamType1, ParamType2, ParamType3 >
     {
@@ -57,6 +61,7 @@ namespace Trinity
             _Callback(_Callback < Class, ParamType1, ParamType2, ParamType3 > const& cb)
                 : m_object(cb.object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3) {}
     };
+
     template < class Class, typename ParamType1, typename ParamType2 >
     class _Callback < Class, ParamType1, ParamType2 >
     {
@@ -73,6 +78,7 @@ namespace Trinity
             _Callback(_Callback < Class, ParamType1, ParamType2 > const& cb)
                 : m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2) {}
     };
+
     template < class Class, typename ParamType1 >
     class _Callback < Class, ParamType1 >
     {
@@ -88,6 +94,7 @@ namespace Trinity
             _Callback(_Callback < Class, ParamType1 > const& cb)
                 : m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1) {}
     };
+
     template < class Class >
     class _Callback < Class >
     {
@@ -102,7 +109,9 @@ namespace Trinity
             _Callback(_Callback < Class > const& cb)
                 : m_object(cb.m_object), m_method(cb.m_method) {}
     };
+
     /// ---- Statics ----
+
     template < typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void >
     class _SCallback
     {
@@ -120,6 +129,7 @@ namespace Trinity
             _SCallback(_SCallback < ParamType1, ParamType2, ParamType3, ParamType4> const& cb)
                 : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3), m_param4(cb.m_param4) {}
     };
+
     template < typename ParamType1, typename ParamType2, typename ParamType3 >
     class _SCallback < ParamType1, ParamType2, ParamType3 >
     {
@@ -136,6 +146,7 @@ namespace Trinity
             _SCallback(_SCallback < ParamType1, ParamType2, ParamType3 > const& cb)
                 : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3) {}
     };
+
     template < typename ParamType1, typename ParamType2 >
     class _SCallback < ParamType1, ParamType2 >
     {
@@ -151,6 +162,7 @@ namespace Trinity
             _SCallback(_SCallback < ParamType1, ParamType2 > const& cb)
                 : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2) {}
     };
+
     template < typename ParamType1 >
     class _SCallback < ParamType1 >
     {
@@ -165,6 +177,7 @@ namespace Trinity
             _SCallback(_SCallback < ParamType1 > const& cb)
                 : m_method(cb.m_method), m_param1(cb.m_param1) {}
     };
+
     template < >
     class _SCallback < >
     {
@@ -179,7 +192,9 @@ namespace Trinity
                 : m_method(cb.m_method) {}
     };
 }
+
 /// --------- GENERIC CALLBACKS ----------
+
 namespace Trinity
 {
     class ICallback
@@ -188,6 +203,7 @@ namespace Trinity
             virtual void Execute() = 0;
             virtual ~ICallback() {}
     };
+
     template < class CB >
     class _ICallback : public CB, public ICallback
     {
@@ -195,6 +211,7 @@ namespace Trinity
             _ICallback(CB const& cb) : CB(cb) {}
             void Execute() { CB::_Execute(); }
     };
+
     template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void >
     class Callback :
         public _ICallback< _Callback < Class, ParamType1, ParamType2, ParamType3, ParamType4 > >
@@ -205,6 +222,7 @@ namespace Trinity
             Callback(Class *object, typename C4::Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3, ParamType4 param4)
                 : _ICallback< C4 >(C4(object, method, param1, param2, param3, param4)) {}
     };
+
     template < class Class, typename ParamType1, typename ParamType2, typename ParamType3 >
     class Callback < Class, ParamType1, ParamType2, ParamType3 > :
         public _ICallback< _Callback < Class, ParamType1, ParamType2, ParamType3 > >
@@ -215,6 +233,7 @@ namespace Trinity
             Callback(Class *object, typename C3::Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3)
                 : _ICallback< C3 >(C3(object, method, param1, param2, param3)) {}
     };
+
     template < class Class, typename ParamType1, typename ParamType2 >
     class Callback < Class, ParamType1, ParamType2 > :
         public _ICallback< _Callback < Class, ParamType1, ParamType2 > >
@@ -225,6 +244,7 @@ namespace Trinity
             Callback(Class *object, typename C2::Method method, ParamType1 param1, ParamType2 param2)
                 : _ICallback< C2 >(C2(object, method, param1, param2)) {}
     };
+
     template < class Class, typename ParamType1 >
     class Callback < Class, ParamType1 > :
         public _ICallback< _Callback < Class, ParamType1 > >
@@ -235,6 +255,7 @@ namespace Trinity
             Callback(Class *object, typename C1::Method method, ParamType1 param1)
                 : _ICallback< C1 >(C1(object, method, param1)) {}
     };
+
     template < class Class >
     class Callback < Class > : public _ICallback< _Callback < Class > >
     {
@@ -245,8 +266,11 @@ namespace Trinity
                 : _ICallback< C0 >(C0(object, method)) {}
     };
 }
+
 /// ---------- QUERY CALLBACKS -----------
+
 class QueryResult;
+
 namespace Trinity
 {
     class IQueryCallback
@@ -257,6 +281,7 @@ namespace Trinity
             virtual void SetResult(QueryResult* result) = 0;
             virtual QueryResult* GetResult() = 0;
     };
+
     template < class CB >
     class _IQueryCallback : public CB, public IQueryCallback
     {
@@ -266,6 +291,7 @@ namespace Trinity
             void SetResult(QueryResult* result) { CB::m_param1 = result; }
             QueryResult* GetResult() { return CB::m_param1; }
     };
+
     template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void >
     class QueryCallback :
         public _IQueryCallback< _Callback < Class, QueryResult*, ParamType1, ParamType2, ParamType3 > >
@@ -276,6 +302,7 @@ namespace Trinity
             QueryCallback(Class *object, typename QC3::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2, ParamType3 param3)
                 : _IQueryCallback< QC3 >(QC3(object, method, result, param1, param2, param3)) {}
     };
+
     template < class Class, typename ParamType1, typename ParamType2 >
     class QueryCallback < Class, ParamType1, ParamType2 > :
         public _IQueryCallback< _Callback < Class, QueryResult*, ParamType1, ParamType2 > >
@@ -286,6 +313,7 @@ namespace Trinity
             QueryCallback(Class *object, typename QC2::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2)
                 : _IQueryCallback< QC2 >(QC2(object, method, result, param1, param2)) {}
     };
+
     template < class Class, typename ParamType1 >
     class QueryCallback < Class, ParamType1 > :
         public _IQueryCallback< _Callback < Class, QueryResult*, ParamType1 > >
@@ -296,6 +324,7 @@ namespace Trinity
             QueryCallback(Class *object, typename QC1::Method method, QueryResult* result, ParamType1 param1)
                 : _IQueryCallback< QC1 >(QC1(object, method, result, param1)) {}
     };
+
     template < class Class >
     class QueryCallback < Class > : public _IQueryCallback< _Callback < Class, QueryResult* > >
     {
@@ -305,7 +334,9 @@ namespace Trinity
             QueryCallback(Class *object, typename QC0::Method method, QueryResult* result)
                 : _IQueryCallback< QC0 >(QC0(object, method, result)) {}
     };
+
     /// ---- Statics ----
+
     template < typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void >
     class SQueryCallback :
         public _IQueryCallback< _SCallback < QueryResult*, ParamType1, ParamType2, ParamType3 > >
@@ -316,6 +347,7 @@ namespace Trinity
             SQueryCallback(typename QC3::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2, ParamType3 param3)
                 : _IQueryCallback< QC3 >(QC3(method, result, param1, param2, param3)) {}
     };
+
     template < typename ParamType1, typename ParamType2 >
     class SQueryCallback < ParamType1, ParamType2 > :
         public _IQueryCallback< _SCallback < QueryResult*, ParamType1, ParamType2 > >
@@ -326,6 +358,7 @@ namespace Trinity
             SQueryCallback(typename QC2::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2)
                 : _IQueryCallback< QC2 >(QC2(method, result, param1, param2)) {}
     };
+
     template < typename ParamType1 >
     class SQueryCallback < ParamType1 > :
         public _IQueryCallback< _SCallback < QueryResult*, ParamType1 > >
@@ -336,6 +369,7 @@ namespace Trinity
             SQueryCallback(typename QC1::Method method, QueryResult* result, ParamType1 param1)
                 : _IQueryCallback< QC1 >(QC1(method, result, param1)) {}
     };
+
     template < >
     class SQueryCallback < > : public _IQueryCallback< _SCallback < QueryResult* > >
     {
@@ -346,5 +380,6 @@ namespace Trinity
                 : _IQueryCallback< QC0 >(QC0(method, result)) {}
     };
 }
+
 #endif
 
diff --git a/src/framework/Utilities/CountedReference/Reference.h b/src/framework/Utilities/CountedReference/Reference.h
index 49156178258..1e1083e1a66 100644
--- a/src/framework/Utilities/CountedReference/Reference.h
+++ b/src/framework/Utilities/CountedReference/Reference.h
@@ -17,8 +17,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef  TRINITY_REFERENCE_H
 #define  TRINITY_REFERENCE_H
+
 /**
  * Referencer
  * Referencer is an object that holds a reference holder that  hold a reference
@@ -29,10 +31,12 @@
  * reference around.  Objects can be reference counted in both single threaded
  * model and multi-threaded model
  */
+
 #include 
 #include "Platform/Define.h"
 #include "Policies/ThreadingModel.h"
 #include "ReferenceHolder.h"
+
 template
 <
 typename T,
@@ -43,39 +47,52 @@ class TRINITY_DLL_DECL Referencer
     typedef typename THREADING_MODEL::Lock Lock;
     typedef ReferenceHolder ReferenceeHolder;
     public:
+
         /// Constructs a referencer.
         Referencer(T *ref = NULL);
+
         /// Copy constructor
         Referencer(const Referencer &obj) : i_holder(NULL) { *this = obj; }
+
         /// Destructor
         ~Referencer();
+
         /// Referencee accessor
         T* referencee(void) { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
         const T* referencee(void) const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
+
         //T& referencee(void){ return _referencee(); }
         //const T& referencee(void) const { return const_cast(this)->_referencee(); }
         operator T&(void) { return _referencee(); }
         operator const T&(void) const { return *const_cast(this)->_referencee(); }
+
         /// cast operators
         T* operator*() { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
         T const * operator*() const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
+
         /// overload operators
         T* operator->() { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
         const T * operator->() const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
+
         /// operator =
         Referencer& operator=(const Referencer &obj);
         Referencer& operator=(T *);
+
         /// returns true if i_referencee is null
         bool isNull(void) const { return i_holder == NULL; }
+
     private:
+
         T& _referencee(void)
         {
             if( i_holder == NULL )
                 throw std::runtime_error("Invalid access to null pointer");
             return *i_holder->i_referencee;
         }
+
         void deReference(ReferenceeHolder *);
         void addReference(ReferenceeHolder *);
+
         // private data
         ReferenceeHolder *i_holder;
 };
diff --git a/src/framework/Utilities/CountedReference/ReferenceHolder.h b/src/framework/Utilities/CountedReference/ReferenceHolder.h
index 80576a8700d..4cfb7d16ded 100644
--- a/src/framework/Utilities/CountedReference/ReferenceHolder.h
+++ b/src/framework/Utilities/CountedReference/ReferenceHolder.h
@@ -17,12 +17,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_REFERENCEHOLDER_H
 #define TRINITY_REFERENCEHOLDER_H
+
 /** ReferenceHolder holds the actualy referenced obejct as well the refence
     count.  The ReferenecHolder implements as a policy base object and
     will decided by the Reference class to be consnsitent.
  */
+
 template
 <
 typename T,
diff --git a/src/framework/Utilities/CountedReference/ReferenceImpl.h b/src/framework/Utilities/CountedReference/ReferenceImpl.h
index 22c31021bd8..c3116a21cf4 100644
--- a/src/framework/Utilities/CountedReference/ReferenceImpl.h
+++ b/src/framework/Utilities/CountedReference/ReferenceImpl.h
@@ -17,9 +17,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_REFERENCEIMPL_H
 #define TRINITY_REFERENCEIMPL_H
+
 #include "Reference.h"
+
 template
 <
 typename T,
@@ -34,6 +37,7 @@ Referencer::Referencer(T *ref)
         ++i_holder->i_referenceCount;
     }
 }
+
 template
 <
 typename T,
@@ -45,6 +49,7 @@ Referencer::~Referencer()
         deReference(i_holder);
     i_holder = NULL;
 }
+
 template
 <
 typename T,
@@ -60,6 +65,7 @@ Referencer::operator=(const Referencer &
     i_holder = obj.i_holder;
     return *this;
 }
+
 template
 <
 typename T,
@@ -76,8 +82,10 @@ Referencer::operator=(T *ref)
         i_holder = new ReferenceeHolder(ref);
         ++i_holder->i_referenceCount;
     }
+
     return *this;
 }
+
 template
 <
 typename T,
@@ -88,21 +96,25 @@ Referencer::deReference(ReferenceHolder
 {
     assert( holder != NULL && holder->i_referenceCount > 0);
     bool delete_object = false;
+
     {
         // The guard is within the scope due to the guard
         // must release earlier than expected.
         Lock guard(*holder);
         Guard(&guard);
+
         --holder->i_referenceCount;
         if( holder->i_referenceCount == 0 )
             delete_object = true;
     }
+
     if( delete_object )
     {
         delete holder->i_referencee;
         delete holder;
     }
 }
+
 template
 <
 typename T,
@@ -114,6 +126,7 @@ Referencer::addReference(ReferenceHolder
     assert( i_holder != NULL );
     Lock guard(*holder);
     Guard(&guard);
+
     ++holder->i_referenceCount;
 }
 #endif
diff --git a/src/framework/Utilities/EventProcessor.cpp b/src/framework/Utilities/EventProcessor.cpp
index 75cc5776602..852f84bc4e2 100644
--- a/src/framework/Utilities/EventProcessor.cpp
+++ b/src/framework/Utilities/EventProcessor.cpp
@@ -17,20 +17,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "EventProcessor.h"
+
 EventProcessor::EventProcessor()
 {
     m_time = 0;
     m_aborting = false;
 }
+
 EventProcessor::~EventProcessor()
 {
     KillAllEvents(true);
 }
+
 void EventProcessor::Update(uint32 p_time)
 {
     // update time
     m_time += p_time;
+
     // main event loop
     EventList::iterator i;
     while (((i = m_events.begin()) != m_events.end()) && i->first <= m_time)
@@ -38,6 +43,7 @@ void EventProcessor::Update(uint32 p_time)
         // get and remove event from queue
         BasicEvent* Event = i->second;
         m_events.erase(i);
+
         if (!Event->to_Abort)
         {
             if (Event->Execute(m_time, p_time))
@@ -53,34 +59,41 @@ void EventProcessor::Update(uint32 p_time)
         }
     }
 }
+
 void EventProcessor::KillAllEvents(bool force)
 {
     // prevent event insertions
     m_aborting = true;
+
     // first, abort all existing events
     for (EventList::iterator i = m_events.begin(); i != m_events.end();)
     {
         EventList::iterator i_old = i;
         ++i;
+
         i_old->second->to_Abort = true;
         i_old->second->Abort(m_time);
         if(force || i_old->second->IsDeletable())
         {
             delete i_old->second;
+
             if(!force)                                      // need per-element cleanup
                 m_events.erase (i_old);
         }
     }
+
     // fast clear event list (in force case)
     if(force)
         m_events.clear();
 }
+
 void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime)
 {
     if (set_addtime) Event->m_addTime = m_time;
     Event->m_execTime = e_time;
     m_events.insert(std::pair(e_time, Event));
 }
+
 uint64 EventProcessor::CalculateTime(uint64 t_offset)
 {
     return(m_time + t_offset);
diff --git a/src/framework/Utilities/EventProcessor.h b/src/framework/Utilities/EventProcessor.h
index ef33fb1ce9a..d0a98c80e30 100644
--- a/src/framework/Utilities/EventProcessor.h
+++ b/src/framework/Utilities/EventProcessor.h
@@ -17,11 +17,16 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef __EVENTPROCESSOR_H
 #define __EVENTPROCESSOR_H
+
 #include "Platform/Define.h"
+
 #include
+
 // Note. All times are in milliseconds here.
+
 class BasicEvent
 {
     public:
@@ -29,24 +34,32 @@ class BasicEvent
         virtual ~BasicEvent()                               // override destructor to perform some actions on event removal
         {
         };
+
         // this method executes when the event is triggered
         // return false if event does not want to be deleted
         // e_time is execution time, p_time is update interval
         virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; }
+
         virtual bool IsDeletable() const { return true; }   // this event can be safely deleted
+
         virtual void Abort(uint64 /*e_time*/) {}            // this method executes when the event is aborted
+
         bool to_Abort;                                      // set by externals when the event is aborted, aborted events don't execute
         // and get Abort call when deleted
+
         // these can be used for time offset control
         uint64 m_addTime;                                   // time when the event was added to queue, filled by event handler
         uint64 m_execTime;                                  // planned time of next execution, filled by event handler
 };
+
 typedef std::multimap EventList;
+
 class EventProcessor
 {
     public:
         EventProcessor();
         ~EventProcessor();
+
         void Update(uint32 p_time);
         void KillAllEvents(bool force);
         void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
diff --git a/src/framework/Utilities/LinkedList.h b/src/framework/Utilities/LinkedList.h
index 0d10d6a0121..171ff3601e3 100644
--- a/src/framework/Utilities/LinkedList.h
+++ b/src/framework/Utilities/LinkedList.h
@@ -17,31 +17,40 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef _LINKEDLIST
 #define _LINKEDLIST
+
 #include "Common.h"
+
 //============================================
 class LinkedListHead;
+
 class LinkedListElement
 {
     private:
         friend class LinkedListHead;
+
         LinkedListElement* iNext;
         LinkedListElement* iPrev;
     public:
         LinkedListElement() { iNext = NULL; iPrev = NULL; }
         ~LinkedListElement() { delink(); }
+
         bool hasNext() const { return(iNext->iNext != NULL); }
         bool hasPrev() const { return(iPrev->iPrev != NULL); }
         bool isInList() const { return(iNext != NULL && iPrev != NULL); }
+
         LinkedListElement      * next()       { return hasNext() ? iNext : NULL; }
         LinkedListElement const* next() const { return hasNext() ? iNext : NULL; }
         LinkedListElement      * prev()       { return hasPrev() ? iPrev : NULL; }
         LinkedListElement const* prev() const { return hasPrev() ? iPrev : NULL; }
+
         LinkedListElement      * nocheck_next()       { return iNext; }
         LinkedListElement const* nocheck_next() const { return iNext; }
         LinkedListElement      * nocheck_prev()       { return iPrev; }
         LinkedListElement const* nocheck_prev() const { return iPrev; }
+
         void delink()
         {
             if(isInList())
@@ -49,6 +58,7 @@ class LinkedListElement
                 iNext->iPrev = iPrev; iPrev->iNext = iNext; iNext = NULL; iPrev = NULL;
             }
         }
+
         void insertBefore(LinkedListElement* pElem)
         {
             pElem->iNext = this;
@@ -56,6 +66,7 @@ class LinkedListElement
             iPrev->iNext = pElem;
             iPrev = pElem;
         }
+
         void insertAfter(LinkedListElement* pElem)
         {
             pElem->iPrev = this;
@@ -64,7 +75,9 @@ class LinkedListElement
             iNext = pElem;
         }
 };
+
 //============================================
+
 class LinkedListHead
 {
     private:
@@ -75,23 +88,30 @@ class LinkedListHead
         LinkedListHead()
         {
             // create empty list
+
             iFirst.iNext = &iLast;
             iLast.iPrev = &iFirst;
             iSize = 0;
         }
+
         bool isEmpty() const { return(!iFirst.iNext->isInList()); }
+
         LinkedListElement      * getFirst()       { return(isEmpty() ? NULL : iFirst.iNext); }
         LinkedListElement const* getFirst() const { return(isEmpty() ? NULL : iFirst.iNext); }
+
         LinkedListElement      * getLast() { return(isEmpty() ? NULL : iLast.iPrev); }
         LinkedListElement const* getLast() const  { return(isEmpty() ? NULL : iLast.iPrev); }
+
         void insertFirst(LinkedListElement* pElem)
         {
             iFirst.insertAfter(pElem);
         }
+
         void insertLast(LinkedListElement* pElem)
         {
             iLast.insertBefore(pElem);
         }
+
         uint32 getSize() const
         {
             if(!iSize)
@@ -108,8 +128,10 @@ class LinkedListHead
             else
                 return iSize;
         }
+
         void incSize() { ++iSize; }
         void decSize() { --iSize; }
+
         template
             class Iterator
         {
@@ -123,85 +145,105 @@ class LinkedListHead
                 typedef _Ty&                                reference;
                 typedef _Ty const &                         const_reference;
 
+
                 Iterator() : _Ptr(0)
                 {                                           // construct with null node pointer
                 }
+
                 Iterator(pointer _Pnode) : _Ptr(_Pnode)
                 {                                           // construct with node pointer _Pnode
                 }
+
                 Iterator& operator=(Iterator const &_Right)
                 {
                     return (*this) = _Right._Ptr;
                 }
+
                 Iterator& operator=(const_pointer const &_Right)
                 {
                     _Ptr = (pointer)_Right;
                     return (*this);
                 }
+
                 reference operator*()
                 {                                           // return designated value
                     return *_Ptr;
                 }
+
                 pointer operator->()
                 {                                           // return pointer to class object
                     return _Ptr;
                 }
+
                 Iterator& operator++()
                 {                                           // preincrement
                     _Ptr = _Ptr->next();
                     return (*this);
                 }
+
                 Iterator operator++(int)
                 {                                           // postincrement
                     iterator _Tmp = *this;
                     ++*this;
                     return (_Tmp);
                 }
+
                 Iterator& operator--()
                 {                                           // predecrement
                     _Ptr = _Ptr->prev();
                     return (*this);
                 }
+
                 Iterator operator--(int)
                 {                                           // postdecrement
                     iterator _Tmp = *this;
                     --*this;
                     return (_Tmp);
                 }
+
                 bool operator==(Iterator const &_Right) const
                 {                                           // test for iterator equality
                     return (_Ptr == _Right._Ptr);
                 }
+
                 bool operator!=(Iterator const &_Right) const
                 {                                           // test for iterator inequality
                     return (!(*this == _Right));
                 }
+
                 bool operator==(pointer const &_Right) const
                 {                                           // test for pointer equality
                     return (_Ptr != _Right);
                 }
+
                 bool operator!=(pointer const &_Right) const
                 {                                           // test for pointer equality
                     return (!(*this == _Right));
                 }
+
                 bool operator==(const_reference _Right) const
                 {                                           // test for reference equality
                     return (_Ptr == &_Right);
                 }
+
                 bool operator!=(const_reference _Right) const
                 {                                           // test for reference equality
                     return (_Ptr != &_Right);
                 }
 
+
                 pointer _Mynode()
                 {                                           // return node pointer
                     return (_Ptr);
                 }
+
             protected:
                 pointer _Ptr;                               // pointer to node
         };
+
         typedef Iterator iterator;
 };
+
 //============================================
 #endif
 
diff --git a/src/framework/Utilities/LinkedReference/RefManager.h b/src/framework/Utilities/LinkedReference/RefManager.h
index 819e7775bf6..ed580f49ec2 100644
--- a/src/framework/Utilities/LinkedReference/RefManager.h
+++ b/src/framework/Utilities/LinkedReference/RefManager.h
@@ -17,25 +17,31 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef _REFMANAGER_H
 #define _REFMANAGER_H
 //=====================================================
+
 #include "Utilities/LinkedList.h"
 #include "Utilities/LinkedReference/Reference.h"
+
 template  class RefManager : public LinkedListHead
 {
     public:
         typedef LinkedListHead::Iterator< Reference > iterator;
         RefManager() { }
         virtual ~RefManager() { clearReferences(); }
+
         Reference* getFirst() { return ((Reference*) LinkedListHead::getFirst()); }
         Reference const* getFirst() const { return ((Reference const*) LinkedListHead::getFirst()); }
         Reference* getLast() { return ((Reference*) LinkedListHead::getLast()); }
         Reference const* getLast() const { return ((Reference const*) LinkedListHead::getLast()); }
+
         iterator begin() { return iterator(getFirst()); }
         iterator end() { return iterator(NULL); }
         iterator rbegin() { return iterator(getLast()); }
         iterator rend() { return iterator(NULL); }
+
         void clearReferences()
         {
             LinkedListElement* ref;
@@ -46,6 +52,7 @@ template  class RefManager : public LinkedListHead
             }
         }
 };
+
 //=====================================================
 #endif
 
diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h
index 7ac5bd4ef3d..c77d3a2cbdb 100644
--- a/src/framework/Utilities/LinkedReference/Reference.h
+++ b/src/framework/Utilities/LinkedReference/Reference.h
@@ -17,10 +17,14 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef _REFERENCE_H
 #define _REFERENCE_H
+
 #include "Utilities/LinkedList.h"
+
 //=====================================================
+
 template  class Reference : public LinkedListElement
 {
     private:
@@ -29,13 +33,16 @@ template  class Reference : public LinkedListElement
     protected:
         // Tell our refTo (target) object that we have a link
         virtual void targetObjectBuildLink() = 0;
+
         // Tell our refTo (taget) object, that the link is cut
         virtual void targetObjectDestroyLink() = 0;
+
         // Tell our refFrom (source) object, that the link is cut (Target destroyed)
         virtual void sourceObjectDestroyLink() = 0;
     public:
         Reference() { iRefTo = NULL; iRefFrom = NULL; }
         virtual ~Reference() {}
+
         // Create new link
         void link(TO* toObj, FROM* fromObj)
         {
@@ -49,31 +56,39 @@ template  class Reference : public LinkedListElement
                 targetObjectBuildLink();
             }
         }
+
         // We don't need the reference anymore. Call comes from the refFrom object
         // Tell our refTo object, that the link is cut
         void unlink() { targetObjectDestroyLink(); delink(); iRefTo = NULL; iRefFrom = NULL; }
+
         // Link is invalid due to destruction of referenced target object. Call comes from the refTo object
         // Tell our refFrom object, that the link is cut
         void invalidate()                                   // the iRefFrom MUST remain!!
         {
             sourceObjectDestroyLink(); delink(); iRefTo = NULL;
         }
+
         bool isValid() const                                // Only check the iRefTo
         {
             return iRefTo != NULL;
         }
+
         Reference       * next()       { return((Reference       *) LinkedListElement::next()); }
         Reference const * next() const { return((Reference const *) LinkedListElement::next()); }
         Reference       * prev()       { return((Reference       *) LinkedListElement::prev()); }
         Reference const * prev() const { return((Reference const *) LinkedListElement::prev()); }
+
         Reference       * nocheck_next()       { return((Reference       *) LinkedListElement::nocheck_next()); }
         Reference const * nocheck_next() const { return((Reference const *) LinkedListElement::nocheck_next()); }
         Reference       * nocheck_prev()       { return((Reference       *) LinkedListElement::nocheck_prev()); }
         Reference const * nocheck_prev() const { return((Reference const *) LinkedListElement::nocheck_prev()); }
+
         TO* operator ->() const { return iRefTo; }
         TO* getTarget() const { return iRefTo; }
+
         FROM* getSource() const { return iRefFrom; }
 };
+
 //=====================================================
 #endif
 
diff --git a/src/framework/Utilities/TypeList.h b/src/framework/Utilities/TypeList.h
index e1f888e1afe..07b1ebad3e6 100644
--- a/src/framework/Utilities/TypeList.h
+++ b/src/framework/Utilities/TypeList.h
@@ -17,20 +17,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_TYPELIST_H
 #define TRINITY_TYPELIST_H
+
 /*
   @struct TypeList
   TypeList is the most simple but yet the most powerfull class of all.  It holds
   at compile time the different type of objects in a linked list.
  */
+
 class TypeNull;
+
 template
 struct TypeList
 {
     typedef HEAD Head;
     typedef TAIL Tail;
 };
+
 // enough for now.. can be expand at any point in time as needed
 #define TYPELIST_1(T1)                  TypeList
 #define TYPELIST_2(T1, T2)              TypeList
diff --git a/src/framework/Utilities/UnorderedMap.h b/src/framework/Utilities/UnorderedMap.h
index a93300b197e..dd539cc0bda 100644
--- a/src/framework/Utilities/UnorderedMap.h
+++ b/src/framework/Utilities/UnorderedMap.h
@@ -17,10 +17,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_UNORDERED_MAP_H
 #define TRINITY_UNORDERED_MAP_H
+
 #include "Platform/CompilerDefs.h"
 #include "Platform/Define.h"
+
 #if COMPILER == COMPILER_INTEL
 #include 
 #elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
@@ -32,6 +35,7 @@
 #else
 #include 
 #endif
+
 #ifdef _STLPORT_VERSION
 #define UNORDERED_MAP std::hash_map
 using std::hash_map;
@@ -47,6 +51,7 @@ using std::hash_map;
 #define UNORDERED_MAP std::tr1::unordered_map
 #elif COMPILER == COMPILER_GNU && __GNUC__ >= 3
 #define UNORDERED_MAP __gnu_cxx::hash_map
+
 namespace __gnu_cxx
 {
     template<> struct hash
@@ -57,7 +62,9 @@ namespace __gnu_cxx
     {
         size_t operator()(T * const &__x) const { return (size_t)__x; }
     };
+
 };
+
 #else
 #define UNORDERED_MAP std::hash_map
 using std::hash_map;
diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp
index d4c4c4aecce..b3c9a76e720 100644
--- a/src/game/AccountMgr.cpp
+++ b/src/game/AccountMgr.cpp
@@ -17,40 +17,53 @@
  * 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 "Policies/SingletonImp.h"
+
 #include "AccountMgr.h"
 #include "ObjectAccessor.h"
 #include "Player.h"
 #include "Util.h"
 #include "Auth/Sha1.h"
+
 extern DatabaseType loginDatabase;
+
 INSTANTIATE_SINGLETON_1(AccountMgr);
+
 AccountMgr::AccountMgr()
 {}
+
 AccountMgr::~AccountMgr()
 {}
+
 AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password)
 {
     if(utf8length(username) > MAX_ACCOUNT_STR)
         return AOR_NAME_TOO_LONG;                           // username's too long
+
     normalizeString(username);
     normalizeString(password);
+
     if(GetId(username))
     {
         return AOR_NAME_ALREDY_EXIST;                       // username does already exist
     }
+
     if(!loginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s','%s',NOW())", username.c_str(), CalculateShaPassHash(username, password).c_str()))
         return AOR_DB_INTERNAL_ERROR;                       // unexpected error
     loginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL");
+
     return AOR_OK;                                          // everything's fine
 }
+
 AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
 {
     QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
     if(!result)
         return AOR_NAME_NOT_EXIST;                          // account doesn't exist
     delete result;
+
     result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account='%d'",accid);
     if (result)
     {
@@ -59,6 +72,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
             Field *fields = result->Fetch();
             uint32 guidlo = fields[0].GetUInt32();
             uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER);
+
             // kick if player currently
             if(Player* p = ObjectAccessor::GetObjectInWorld(guid, (Player*)NULL))
             {
@@ -66,54 +80,76 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
                 s->KickPlayer();                            // mark session to remove at next session list update
                 s->LogoutPlayer(false);                     // logout player without waiting next session list update
             }
+
             Player::DeleteFromDB(guid, accid, false);       // no need to update realm characters
         } while (result->NextRow());
+
         delete result;
     }
+
     // table realm specific but common for all characters of account for realm
     CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'",accid);
+
     loginDatabase.BeginTransaction();
+
     bool res =
         loginDatabase.PExecute("DELETE FROM account WHERE id='%d'", accid) &&
         loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid='%d'", accid);
+
     loginDatabase.CommitTransaction();
+
     if(!res)
         return AOR_DB_INTERNAL_ERROR;                       // unexpected error;
+
     return AOR_OK;
 }
+
 AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, std::string new_passwd)
 {
     QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
     if(!result)
         return AOR_NAME_NOT_EXIST;                          // account doesn't exist
     delete result;
+
     if(utf8length(new_uname) > MAX_ACCOUNT_STR)
         return AOR_NAME_TOO_LONG;
+
     if(utf8length(new_passwd) > MAX_ACCOUNT_STR)
         return AOR_PASS_TOO_LONG;
+
     normalizeString(new_uname);
     normalizeString(new_passwd);
+
     std::string safe_new_uname = new_uname;
     loginDatabase.escape_string(safe_new_uname);
+
     if(!loginDatabase.PExecute("UPDATE account SET v='0',s='0',username='%s',sha_pass_hash='%s' WHERE id='%d'", safe_new_uname.c_str(),
                 CalculateShaPassHash(new_uname, new_passwd).c_str(), accid))
         return AOR_DB_INTERNAL_ERROR;                       // unexpected error
+
     return AOR_OK;
 }
+
 AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd)
 {
     std::string username;
+
     if(!GetName(accid, username))
         return AOR_NAME_NOT_EXIST;                          // account doesn't exist
+
     if (utf8length(new_passwd) > MAX_ACCOUNT_STR)
         return AOR_PASS_TOO_LONG;
+
     normalizeString(new_passwd);
+
     // also reset s and v to force update at next realmd login
     if(!loginDatabase.PExecute("UPDATE account SET v='0', s='0', sha_pass_hash='%s' WHERE id='%d'",
                 CalculateShaPassHash(username, new_passwd).c_str(), accid))
         return AOR_DB_INTERNAL_ERROR;                       // unexpected error
+
     return AOR_OK;
 }
+
 uint32 AccountMgr::GetId(std::string username)
 {
     loginDatabase.escape_string(username);
@@ -127,6 +163,7 @@ uint32 AccountMgr::GetId(std::string username)
         return id;
     }
 }
+
 uint32 AccountMgr::GetSecurity(uint32 acc_id)
 {
     QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id);
@@ -136,8 +173,10 @@ uint32 AccountMgr::GetSecurity(uint32 acc_id)
         delete result;
         return sec;
     }
+
     return 0;
 }
+
 bool AccountMgr::GetName(uint32 acc_id, std::string &name)
 {
     QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id);
@@ -147,31 +186,41 @@ bool AccountMgr::GetName(uint32 acc_id, std::string &name)
         delete result;
         return true;
     }
+
     return false;
 }
+
 bool AccountMgr::CheckPassword(uint32 accid, std::string passwd)
 {
     std::string username;
     if(!GetName(accid, username))
         return false;
+
     normalizeString(passwd);
+
     QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d' AND sha_pass_hash='%s'", accid, CalculateShaPassHash(username, passwd).c_str());
     if (result)
     {
         delete result;
         return true;
     }
+
     return false;
 }
+
 bool AccountMgr::normalizeString(std::string& utf8str)
 {
     wchar_t wstr_buf[MAX_ACCOUNT_STR+1];
+
     size_t wstr_len = MAX_ACCOUNT_STR;
     if(!Utf8toWStr(utf8str,wstr_buf,wstr_len))
         return false;
+
     std::transform( &wstr_buf[0], wstr_buf+wstr_len, &wstr_buf[0], wcharToUpperOnlyLatin );
+
     return WStrToUtf8(wstr_buf,wstr_len,utf8str);
 }
+
 std::string AccountMgr::CalculateShaPassHash(std::string& name, std::string& password)
 {
     Sha1Hash sha;
@@ -180,8 +229,10 @@ std::string AccountMgr::CalculateShaPassHash(std::string& name, std::string& pas
     sha.UpdateData(":");
     sha.UpdateData(password);
     sha.Finalize();
+
     std::string encoded;
     hexEncodeByteArray(sha.GetDigest(), sha.GetLength(), encoded);
+
     return encoded;
 }
 
diff --git a/src/game/AccountMgr.h b/src/game/AccountMgr.h
index c35b9a37575..c14110036a0 100644
--- a/src/game/AccountMgr.h
+++ b/src/game/AccountMgr.h
@@ -17,11 +17,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef _ACCMGR_H
 #define _ACCMGR_H
+
 #include 
+
 #include "Common.h"
 #include "Policies/Singleton.h"
+
 enum AccountOpResult
 {
     AOR_OK,
@@ -31,23 +35,29 @@ enum AccountOpResult
     AOR_NAME_NOT_EXIST,
     AOR_DB_INTERNAL_ERROR
 };
+
 #define MAX_ACCOUNT_STR 16
+
 class AccountMgr
 {
     public:
         AccountMgr();
         ~AccountMgr();
+
         AccountOpResult CreateAccount(std::string username, std::string password);
         AccountOpResult DeleteAccount(uint32 accid);
         AccountOpResult ChangeUsername(uint32 accid, std::string new_uname, std::string new_passwd);
         AccountOpResult ChangePassword(uint32 accid, std::string new_passwd);
         bool CheckPassword(uint32 accid, std::string passwd);
+
         uint32 GetId(std::string username);
         uint32 GetSecurity(uint32 acc_id);
         bool GetName(uint32 acc_id, std::string &name);
         std::string CalculateShaPassHash(std::string& name, std::string& password);
+
         static bool normalizeString(std::string& utf8str);
 };
+
 #define accmgr Trinity::Singleton::Instance()
 #endif
 
diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp
index 50daa5c565f..c9b98c3ddef 100644
--- a/src/game/AchievementMgr.cpp
+++ b/src/game/AchievementMgr.cpp
@@ -15,6 +15,7 @@
  * 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 "DBCEnums.h"
 #include "ObjectMgr.h"
@@ -22,6 +23,7 @@
 #include "WorldPacket.h"
 #include "Database/DatabaseEnv.h"
 #include "Policies/SingletonImp.h"
+
 #include "AchievementMgr.h"
 #include "ArenaTeam.h"
 #include "CellImpl.h"
@@ -32,11 +34,14 @@
 #include "Player.h"
 #include "ProgressBar.h"
 #include "SpellMgr.h"
+
 #include "MapManager.h"
 #include "BattleGround.h"
 #include "BattleGroundAB.h"
 
+
 INSTANTIATE_SINGLETON_1(AchievementGlobalMgr);
+
 namespace MaNGOS
 {
     class AchievementChatBuilder
@@ -47,6 +52,7 @@ namespace MaNGOS
             void operator()(WorldPacket& data, int32 loc_idx)
             {
                 char const* text = objmgr.GetMangosString(i_textId,loc_idx);
+
                 data << uint8(i_msgtype);
                 data << uint32(LANG_UNIVERSAL);
                 data << uint64(i_player.GetGUID());
@@ -57,6 +63,7 @@ namespace MaNGOS
                 data << uint8(0);
                 data << uint32(i_achievementId);
             }
+
         private:
             Player const& i_player;
             ChatMsg i_msgtype;
@@ -65,6 +72,7 @@ namespace MaNGOS
     };
 }                                                           // namespace MaNGOS
 
+
 bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
 {
     if(dataType >= MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE)
@@ -72,6 +80,7 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
         sLog.outErrorDb( "Table `achievement_criteria_data` for criteria (Entry: %u) have wrong data type (%u), ignore.", criteria->ID,dataType);
         return false;
     }
+
     switch(criteria->requiredType)
     {
         case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
@@ -89,6 +98,7 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
             sLog.outErrorDb( "Table `achievement_criteria_data` have data for not supported criteria type (Entry: %u Type: %u), ignore.", criteria->ID, criteria->requiredType);
             return false;
     }
+
     switch(dataType)
     {
         case ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE:
@@ -235,6 +245,7 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
     }
     return false;
 }
+
 bool AchievementCriteriaData::Meets(Player const* source, Unit const* target, uint32 miscvalue1 /*= 0*/) const
 {
     switch(dataType)
@@ -306,20 +317,25 @@ bool AchievementCriteriaData::Meets(Player const* source, Unit const* target, ui
     }
     return false;
 }
+
 bool AchievementCriteriaDataSet::Meets(Player const* source, Unit const* target, uint32 miscvalue /*= 0*/) const
 {
     for(Storage::const_iterator itr = storage.begin(); itr != storage.end(); ++itr)
         if(!itr->Meets(source,target,miscvalue))
             return false;
+
     return true;
 }
+
 AchievementMgr::AchievementMgr(Player *player)
 {
     m_player = player;
 }
+
 AchievementMgr::~AchievementMgr()
 {
 }
+
 void AchievementMgr::Reset()
 {
     for(CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter)
@@ -328,34 +344,43 @@ void AchievementMgr::Reset()
         data << uint32(iter->first);
         m_player->SendDirectMessage(&data);
     }
+
     for(CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter)
     {
         WorldPacket data(SMSG_CRITERIA_DELETED,4);
         data << uint32(iter->first);
         m_player->SendDirectMessage(&data);
     }
+
     m_completedAchievements.clear();
     m_criteriaProgress.clear();
     DeleteFromDB(m_player->GetGUIDLow());
+
     // re-fill data
     CheckAllAchievementCriteria();
 }
+
 void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1, uint32 miscvalue2)
 {
     if((sLog.getLogFilter() & LOG_FILTER_ACHIEVEMENT_UPDATES)==0)
         sLog.outDetail("AchievementMgr::ResetAchievementCriteria(%u, %u, %u)", type, miscvalue1, miscvalue2);
+
     if (!sWorld.getConfig(CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER)
         return;
+
     AchievementCriteriaEntryList const& achievementCriteriaList = achievementmgr.GetAchievementCriteriaByType(type);
     for(AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i!=achievementCriteriaList.end(); ++i)
     {
         AchievementCriteriaEntry const *achievementCriteria = (*i);
+
         AchievementEntry const *achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement);
         if (!achievement)
             continue;
+
         // don't update already completed criteria
         if (IsCompletedCriteria(achievementCriteria,achievement))
             continue;
+
         switch (type)
         {
             case ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE:     // have total statistic also not expected to be reset
@@ -374,6 +399,7 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin
         }
     }
 }
+
 void AchievementMgr::DeleteFromDB(uint32 lowguid)
 {
     CharacterDatabase.BeginTransaction ();
@@ -381,6 +407,7 @@ void AchievementMgr::DeleteFromDB(uint32 lowguid)
     CharacterDatabase.PExecute("DELETE FROM character_achievement_progress WHERE guid = %u",lowguid);
     CharacterDatabase.CommitTransaction ();
 }
+
 void AchievementMgr::SaveToDB()
 {
     if(!m_completedAchievements.empty())
@@ -392,6 +419,7 @@ void AchievementMgr::SaveToDB()
         {
             if(!iter->second.changed)
                 continue;
+
             /// first new/changed record prefix
             if(!need_execute)
             {
@@ -405,20 +433,25 @@ void AchievementMgr::SaveToDB()
                 ssdel << ", ";
                 ssins << ", ";
             }
+
             // new/changed record data
             ssdel << iter->first;
             ssins << "("<GetGUIDLow() << ", " << iter->first << ", " << uint64(iter->second.date) << ")";
+
             /// mark as saved in db
             iter->second.changed = false;
         }
+
         if(need_execute)
             ssdel << ")";
+
         if(need_execute)
         {
             CharacterDatabase.Execute( ssdel.str().c_str() );
             CharacterDatabase.Execute( ssins.str().c_str() );
         }
     }
+
     if(!m_criteriaProgress.empty())
     {
         /// prepare deleting and insert
@@ -430,6 +463,7 @@ void AchievementMgr::SaveToDB()
         {
             if(!iter->second.changed)
                 continue;
+
             // deleted data (including 0 progress state)
             {
                 /// first new/changed record prefix (for any counter value)
@@ -441,9 +475,11 @@ void AchievementMgr::SaveToDB()
                 /// next new/changed record prefix
                 else
                     ssdel << ", ";
+
                 // new/changed record data
                 ssdel << iter->first;
             }
+
             // store data only for real progress
             if(iter->second.counter != 0)
             {
@@ -456,14 +492,18 @@ void AchievementMgr::SaveToDB()
                 /// next new/changed record prefix
                 else
                     ssins << ", ";
+
                 // new/changed record data
                 ssins << "(" << GetPlayer()->GetGUIDLow() << ", " << iter->first << ", " << iter->second.counter << ", " << iter->second.date << ")";
             }
+
             /// mark as updated in db
             iter->second.changed = false;
         }
+
         if(need_execute_del)                                // DELETE ... IN (.... _)_
             ssdel << ")";
+
         if(need_execute_del || need_execute_ins)
         {
             if(need_execute_del)
@@ -473,6 +513,7 @@ void AchievementMgr::SaveToDB()
         }
     }
 }
+
 void AchievementMgr::LoadFromDB(QueryResult *achievementResult, QueryResult *criteriaResult)
 {
     if(achievementResult)
@@ -480,24 +521,30 @@ void AchievementMgr::LoadFromDB(QueryResult *achievementResult, QueryResult *cri
         do
         {
             Field *fields = achievementResult->Fetch();
+
             uint32 achievement_id = fields[0].GetUInt32();
+
             // don't must happen: cleanup at server startup in achievementmgr.LoadCompletedAchievements()
             if(!sAchievementStore.LookupEntry(achievement_id))
                 continue;
+
             CompletedAchievementData& ca = m_completedAchievements[achievement_id];
             ca.date = time_t(fields[1].GetUInt64());
             ca.changed = false;
         } while(achievementResult->NextRow());
         delete achievementResult;
     }
+
     if(criteriaResult)
     {
         do
         {
             Field *fields = criteriaResult->Fetch();
+
             uint32 id      = fields[0].GetUInt32();
             uint32 counter = fields[1].GetUInt32();
             time_t date    = time_t(fields[2].GetUInt64());
+
             AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(id);
             if (!criteria)
             {
@@ -506,8 +553,10 @@ void AchievementMgr::LoadFromDB(QueryResult *achievementResult, QueryResult *cri
                 CharacterDatabase.PExecute("DELETE FROM character_achievement_progress WHERE criteria = %u",id);
                 continue;
             }
+
             if (criteria->timeLimit && time_t(date + criteria->timeLimit) < time(NULL))
                 continue;
+
             CriteriaProgress& progress = m_criteriaProgress[id];
             progress.counter = counter;
             progress.date    = date;
@@ -515,21 +564,26 @@ void AchievementMgr::LoadFromDB(QueryResult *achievementResult, QueryResult *cri
         } while(criteriaResult->NextRow());
         delete criteriaResult;
     }
+
 }
+
 void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
 {
     if(GetPlayer()->GetSession()->PlayerLoading())
         return;
+
     #ifdef TRINITY_DEBUG
     if((sLog.getLogFilter() & LOG_FILTER_ACHIEVEMENT_UPDATES)==0)
         sLog.outDebug("AchievementMgr::SendAchievementEarned(%u)", achievement->ID);
     #endif
+
     if(Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()))
     {
         MaNGOS::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_GUILD_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED,achievement->ID);
         MaNGOS::LocalizedPacketDo say_do(say_builder);
         guild->BroadcastWorker(say_do,GetPlayer());
     }
+
     if(achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL|ACHIEVEMENT_FLAG_REALM_FIRST_REACH))
     {
         // broadcast realm first reached
@@ -543,9 +597,11 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
     else
     {
         CellPair p = MaNGOS::ComputeCellPair(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
+
         Cell cell(p);
         cell.data.Part.reserved = ALL_DISTRICT;
         cell.SetNoCreate();
+
         MaNGOS::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED,achievement->ID);
         MaNGOS::LocalizedPacketDo say_do(say_builder);
         MaNGOS::PlayerDistWorker > say_worker(GetPlayer(),sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),say_do);
@@ -553,6 +609,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
         CellLock cell_lock(cell, p);
         cell_lock->Visit(cell_lock, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY));
     }
+
     WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8);
     data.append(GetPlayer()->GetPackGUID());
     data << uint32(achievement->ID);
@@ -560,12 +617,15 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
     data << uint32(0);
     GetPlayer()->SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY), true);
 }
+
 void AchievementMgr::SendCriteriaUpdate(uint32 id, CriteriaProgress const* progress)
 {
     WorldPacket data(SMSG_CRITERIA_UPDATE, 8+4+8);
     data << uint32(id);
+
     // the counter is packed like a packed Guid
     data.appendPackGUID(progress->counter);
+
     data.append(GetPlayer()->GetPackGUID());
     data << uint32(0);
     data << uint32(secsToTimeBitFields(progress->date));
@@ -573,6 +633,7 @@ void AchievementMgr::SendCriteriaUpdate(uint32 id, CriteriaProgress const* progr
     data << uint32(0);  // timer 2
     GetPlayer()->SendDirectMessage(&data);
 }
+
 /**
  * called at player login. The player might have fulfilled some achievements when the achievement system wasn't working yet
  */
@@ -582,6 +643,7 @@ void AchievementMgr::CheckAllAchievementCriteria()
     for(uint32 i=0; iGetSession()->GetSecurity() > SEC_PLAYER)
         return;
+
     AchievementCriteriaEntryList const& achievementCriteriaList = achievementmgr.GetAchievementCriteriaByType(type);
     for(AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i!=achievementCriteriaList.end(); ++i)
     {
         AchievementCriteriaEntry const *achievementCriteria = (*i);
+
         if (achievementCriteria->groupFlag & ACHIEVEMENT_CRITERIA_GROUP_NOT_IN_GROUP && GetPlayer()->GetGroup())
             continue;
+
         AchievementEntry const *achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement);
         if (!achievement)
             continue;
+
         if ((achievement->factionFlag == ACHIEVEMENT_FACTION_FLAG_HORDE    && GetPlayer()->GetTeam() != HORDE) ||
             (achievement->factionFlag == ACHIEVEMENT_FACTION_FLAG_ALLIANCE && GetPlayer()->GetTeam() != ALLIANCE))
             continue;
+
         // don't update already completed criteria
         if (IsCompletedCriteria(achievementCriteria,achievement))
             continue;
+
         switch (type)
         {
             // std. case: increment at 1
@@ -659,7 +729,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     continue;
                 SetCriteriaProgress(achievementCriteria, miscvalue1, PROGRESS_HIGHEST);
                 break;
+
             // specialized cases
+
             case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
             {
                 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
@@ -667,6 +739,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     continue;
                 if (achievementCriteria->win_bg.bgMapID != GetPlayer()->GetMapId())
                     continue;
+
                 if (achievementCriteria->win_bg.additionalRequirement1_type)
                 {
                     // those requirements couldn't be found in the dbc
@@ -680,6 +753,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     BattleGround* bg = GetPlayer()->GetBattleGround();
                     if (!bg)
                         continue;
+
                     switch(achievementCriteria->referredAchievement)
                     {
                         case 161:                           // AB, Overcome a 500 resource disadvantage
@@ -702,6 +776,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                             continue;                       // not implemented
                     }
                 }
+
                 SetCriteriaProgress(achievementCriteria, miscvalue1, PROGRESS_ACCUMULATE);
                 break;
             }
@@ -712,10 +787,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     continue;
                 if(achievementCriteria->kill_creature.creatureID != miscvalue1)
                     continue;
+
                 // those requirements couldn't be found in the dbc
                 AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria);
                 if(!data || !data->Meets(GetPlayer(),unit))
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, miscvalue2, PROGRESS_ACCUMULATE);
                 break;
             }
@@ -754,6 +831,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 // speedup for non-login case
                 if(miscvalue1 && miscvalue1 != achievementCriteria->complete_quests_in_zone.zoneID)
                     continue;
+
                 uint32 counter =0;
                 for(QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr!=GetPlayer()->getQuestStatusMap().end(); itr++)
                 {
@@ -794,11 +872,13 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                         BattleGround* bg = GetPlayer()->GetBattleGround();
                         if(!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != j)
                             notfit = true;
+
                         break;
                     }
                 }
                 if(notfit)
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             }
@@ -807,9 +887,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
                 if(!miscvalue1)
                     continue;
+
                 Map const* map = GetPlayer()->IsInWorld() ? GetPlayer()->GetMap() : MapManager::Instance().FindMap(GetPlayer()->GetMapId(), GetPlayer()->GetInstanceId());
                 if(!map || !map->IsDungeon())
                     continue;
+
                 // search case
                 bool found = false;
                 for(int j = 0; achievIdForDangeon[j][0]; ++j)
@@ -834,17 +916,20 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                             if(!achievIdForDangeon[j][3])
                                 break;                      // for
                         }
+
                         found = true;
                         break;                              // for
                     }
                 }
                 if(!found)
                     continue;
+
                 //FIXME: work only for instances where max==min for players
                 if(((InstanceMap*)map)->GetMaxPlayers() != achievementCriteria->death_in_dungeon.manLimit)
                     continue;
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
+
             }
             case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE:
                 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
@@ -858,9 +943,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
                 if(!miscvalue1)
                     continue;
+
                 // if team check required: must kill by opposition faction
                 if(achievement->ID==318 && miscvalue2==GetPlayer()->GetTeam())
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             case ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING:
@@ -868,10 +955,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
                 if(!miscvalue1)
                     continue;
+
                 // those requirements couldn't be found in the dbc
                 AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria);
                 if(!data || !data->Meets(GetPlayer(),unit))
                     continue;
+
                 // miscvalue1 is the ingame fallheight*100 as stored in dbc
                 SetCriteriaProgress(achievementCriteria, miscvalue1);
                 break;
@@ -898,6 +987,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     if(!GetPlayer()->GetQuestRewardStatus(achievementCriteria->complete_quest.questID))
                         continue;
                 }
+
                 // exist many achievements with this criteria, use at this moment hardcoded check to skil simple case
                 switch(achievement->ID)
                 {
@@ -918,6 +1008,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                         break;
                 }
 
+
                 SetCriteriaProgress(achievementCriteria, 1);
                 break;
             }
@@ -932,18 +1023,22 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
             {
                 if (!miscvalue1 || miscvalue1 != achievementCriteria->cast_spell.spellID)
                     continue;
+
                 // those requirements couldn't be found in the dbc
                 AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria);
                 if(!data)
                     continue;
+
                 if(!data->Meets(GetPlayer(),unit))
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             }
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
                 if(miscvalue1 && miscvalue1!=achievementCriteria->learn_spell.spellID)
                     continue;
+
                 if(GetPlayer()->HasSpell(achievementCriteria->learn_spell.spellID))
                     SetCriteriaProgress(achievementCriteria, 1);
                 break;
@@ -955,6 +1050,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     continue;
                 if (miscvalue1 != achievementCriteria->loot_type.lootType)
                     continue;
+
                 // zone specific
                 if(achievementCriteria->loot_type.lootTypeCount==1)
                 {
@@ -963,6 +1059,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     if(!data || !data->Meets(GetPlayer(),unit))
                         continue;
                 }
+
                 SetCriteriaProgress(achievementCriteria, miscvalue2, PROGRESS_ACCUMULATE);
                 break;
             }
@@ -976,6 +1073,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 // miscvalue1 contains the personal rating
                 if (!miscvalue1)                            // no update at login
                     continue;
+
                 // additional requirements
                 if(achievementCriteria->win_rated_arena.flag==ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE)
                 {
@@ -988,6 +1086,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                         continue;
                     }
                 }
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
@@ -1011,23 +1110,28 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 WorldMapOverlayEntry const* worldOverlayEntry = sWorldMapOverlayStore.LookupEntry(achievementCriteria->explore_area.areaReference);
                 if(!worldOverlayEntry)
                     break;
+
                 bool matchFound = false;
                 for (int j = 0; j < MAX_WORLD_MAP_OVERLAY_AREA_IDX; ++j)
                 {
                     uint32 area_id = worldOverlayEntry->areatableID[j];
                     if(!area_id)                            // array have 0 only in empty tail
                         break;
+
                     int32 exploreFlag = GetAreaFlagByAreaID(area_id);
                     if(exploreFlag < 0)
                         continue;
+
                     uint32 playerIndexOffset = uint32(exploreFlag) / 32;
                     uint32 mask = 1<< (uint32(exploreFlag) % 32);
+
                     if(GetPlayer()->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + playerIndexOffset) & mask)
                     {
                         matchFound = true;
                         break;
                     }
                 }
+
                 if(matchFound)
                     SetCriteriaProgress(achievementCriteria, 1);
                 break;
@@ -1040,6 +1144,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 // skip faction check only at loading
                 if (miscvalue1 && miscvalue1 != achievementCriteria->gain_reputation.factionID)
                     continue;
+
                 int32 reputation = GetPlayer()->GetReputationMgr().GetReputation(achievementCriteria->gain_reputation.factionID);
                 if (reputation > 0)
                     SetCriteriaProgress(achievementCriteria, reputation);
@@ -1068,9 +1173,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 if(miscvalue2 != achievementCriteria->roll_greed_on_loot.rollValue)
                     continue;
                 ItemPrototype const *pProto = objmgr.GetItemPrototype( miscvalue1 );
+
                 uint32 requiredItemLevel = 0;
                 if (achievementCriteria->ID == 2412 || achievementCriteria->ID == 2358)
                     requiredItemLevel = 185;
+
                 if(!pProto || pProto->ItemLevel Meets(GetPlayer(),unit))
                         continue;
                 }
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             }
@@ -1098,14 +1206,17 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
             {
                 if (!miscvalue1)
                     continue;
+
                 if (achievementCriteria->healing_done.flag == ACHIEVEMENT_CRITERIA_CONDITION_MAP)
                 {
                     if(GetPlayer()->GetMapId() != achievementCriteria->healing_done.mapid)
                         continue;
+
                     // map specific case (BG in fact) expected player targeted damage/heal
                     if(!unit || unit->GetTypeId()!=TYPEID_PLAYER)
                         continue;
                 }
+
                 SetCriteriaProgress(achievementCriteria, miscvalue1, PROGRESS_ACCUMULATE);
                 break;
             }
@@ -1115,6 +1226,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     continue;
                 if (miscvalue1 != achievementCriteria->equip_item.itemID)
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, 1);
                 break;
             case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT:
@@ -1123,6 +1235,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     continue;
                 if (miscvalue1 != achievementCriteria->use_gameobject.goEntry)
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT:
@@ -1130,12 +1243,14 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                     continue;
                 if (miscvalue1 != achievementCriteria->fish_in_gameobject.goEntry)
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
             {
                 if (miscvalue1 && miscvalue1 != achievementCriteria->learn_skillline_spell.skillLine)
                     continue;
+
                 uint32 spellCount = 0;
                 for (PlayerSpellMap::const_iterator spellIter = GetPlayer()->GetSpellMap().begin();
                     spellIter != GetPlayer()->GetSpellMap().end();
@@ -1155,15 +1270,18 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
                 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
                 if (!miscvalue1)
                     continue;
+
                 if (achievementCriteria->win_duel.duelCount)
                 {
                     // those requirements couldn't be found in the dbc
                     AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria);
                     if (!data)
                         continue;
+
                     if (!data->Meets(GetPlayer(),unit))
                         continue;
                 }
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION:
@@ -1179,6 +1297,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
             {
                 if (miscvalue1 && miscvalue1 != achievementCriteria->learn_skill_line.skillLine)
                     continue;
+
                 uint32 spellCount = 0;
                 for (PlayerSpellMap::const_iterator spellIter = GetPlayer()->GetSpellMap().begin();
                     spellIter != GetPlayer()->GetSpellMap().end();
@@ -1198,11 +1317,13 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
             case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
                 if (!miscvalue1 || miscvalue1 != achievementCriteria->hk_class.classID)
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
                 if (!miscvalue1 || miscvalue1 != achievementCriteria->hk_race.raceID)
                     continue;
+
                 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
                 break;
             case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED:
@@ -1243,6 +1364,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
         }
         if(IsCompletedCriteria(achievementCriteria,achievement))
             CompletedCriteriaFor(achievement);
+
         // check again the completeness for SUMM and REQ COUNT achievements,
         // as they don't depend on the completed criteria but on the sum of the progress of each individual criteria
         if (achievement->flags & ACHIEVEMENT_FLAG_SUMM)
@@ -1250,6 +1372,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
             if (IsCompletedAchievement(achievement))
                 CompletedAchievement(achievement);
         }
+
         if(AchievementEntryList const* achRefList = achievementmgr.GetAchievementByReferencedId(achievement->ID))
         {
             for(AchievementEntryList::const_iterator itr = achRefList->begin(); itr != achRefList->end(); ++itr)
@@ -1258,23 +1381,29 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
         }
     }
 }
+
 static const uint32 achievIdByClass[MAX_CLASSES] = { 0, 459, 465 , 462, 458, 464, 461, 467, 460, 463, 0, 466 };
 static const uint32 achievIdByRace[MAX_RACES]    = { 0, 1408, 1410, 1407, 1409, 1413, 1411, 1404, 1412, 0, 1405, 1406 };
+
 bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement)
 {
     // counter can never complete
     if(achievement->flags & ACHIEVEMENT_FLAG_COUNTER)
         return false;
+
     if(achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_REACH | ACHIEVEMENT_FLAG_REALM_FIRST_KILL))
     {
         // someone on this realm has already completed that achievement
         if(achievementmgr.IsRealmCompleted(achievement))
             return false;
     }
+
     CriteriaProgressMap::const_iterator itr = m_criteriaProgress.find(achievementCriteria->ID);
     if(itr == m_criteriaProgress.end())
         return false;
+
     CriteriaProgress const* progress = &itr->second;
+
     switch(achievementCriteria->requiredType)
     {
         case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
@@ -1287,10 +1416,12 @@ bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achieve
             for(int i = 1; i < MAX_CLASSES; ++i)
                 if(achievIdByClass[i] == achievement->ID && i != GetPlayer()->getClass())
                     return false;
+
             // skip wrong race achievements
             for(int i = 1; i < MAX_RACES; ++i)
                 if(achievIdByRace[i] == achievement->ID && i != GetPlayer()->getRace())
                     return false;
+
             // appropriate class/race or not class/race specific
             return progress->counter >= achievementCriteria->reach_level.level;
         }
@@ -1399,29 +1530,36 @@ bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achieve
     }
     return false;
 }
+
 void AchievementMgr::CompletedCriteriaFor(AchievementEntry const* achievement)
 {
     // counter can never complete
     if(achievement->flags & ACHIEVEMENT_FLAG_COUNTER)
         return;
+
     // already completed and stored
     if (m_completedAchievements.find(achievement->ID)!=m_completedAchievements.end())
         return;
+
     if (IsCompletedAchievement(achievement))
         CompletedAchievement(achievement);
 }
+
 bool AchievementMgr::IsCompletedAchievement(AchievementEntry const* entry)
 {
     // counter can never complete
     if(entry->flags & ACHIEVEMENT_FLAG_COUNTER)
         return false;
+
     // for achievement with referenced achievement criterias get from referenced and counter from self
     uint32 achievmentForTestId = entry->refAchievement ? entry->refAchievement : entry->ID;
     uint32 achievmentForTestCount = entry->count;
+
     AchievementCriteriaEntryList const* cList = achievementmgr.GetAchievementCriteriaByAchievement(achievmentForTestId);
     if(!cList)
         return false;
     uint32 count = 0;
+
     // For SUMM achievements, we have to count the progress of each criteria of the achievement.
     // Oddly, the target count is NOT countained in the achievement, but in each individual criteria
     if (entry->flags & ACHIEVEMENT_FLAG_SUMM)
@@ -1429,48 +1567,62 @@ bool AchievementMgr::IsCompletedAchievement(AchievementEntry const* entry)
         for(AchievementCriteriaEntryList::const_iterator itr = cList->begin(); itr != cList->end(); ++itr)
         {
             AchievementCriteriaEntry const* criteria = *itr;
+
             CriteriaProgressMap::const_iterator itrProgress = m_criteriaProgress.find(criteria->ID);
             if(itrProgress == m_criteriaProgress.end())
                 continue;
+
             CriteriaProgress const* progress = &itrProgress->second;
             count += progress->counter;
+
             // for counters, field4 contains the main count requirement
             if (count >= criteria->raw.count)
                 return true;
         }
         return false;
     }
+
     // Default case - need complete all or
     bool completed_all = true;
     for(AchievementCriteriaEntryList::const_iterator itr = cList->begin(); itr != cList->end(); ++itr)
     {
         AchievementCriteriaEntry const* criteria = *itr;
+
         bool completed = IsCompletedCriteria(criteria,entry);
+
         // found an uncompleted criteria, but DONT return false yet - there might be a completed criteria with ACHIEVEMENT_CRITERIA_COMPLETE_FLAG_ALL
         if(completed)
             ++count;
         else
             completed_all = false;
+
         // completed as have req. count of completed criterias
         if(achievmentForTestCount > 0 && achievmentForTestCount <= count)
            return true;
     }
+
     // all criterias completed requirement
     if(completed_all && achievmentForTestCount==0)
         return true;
+
     return false;
 }
+
 void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry, uint32 changeValue, ProgressType ptype)
 {
     if((sLog.getLogFilter() & LOG_FILTER_ACHIEVEMENT_UPDATES)==0)
         sLog.outDetail("AchievementMgr::SetCriteriaProgress(%u, %u) for (GUID:%u)", entry->ID, changeValue, m_player->GetGUIDLow());
+
     CriteriaProgress *progress = NULL;
+
     CriteriaProgressMap::iterator iter = m_criteriaProgress.find(entry->ID);
+
     if(iter == m_criteriaProgress.end())
     {
         // not create record for 0 counter
         if(changeValue == 0)
             return;
+
         progress = &m_criteriaProgress[entry->ID];
         progress->counter = changeValue;
         progress->date = time(NULL);
@@ -1478,6 +1630,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry,
     else
     {
         progress = &iter->second;
+
         uint32 newValue = 0;
         switch(ptype)
         {
@@ -1495,62 +1648,81 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry,
                 newValue = progress->counter < changeValue ? changeValue : progress->counter;
                 break;
         }
+
         // not update (not mark as changed) if counter will have same value
         if(progress->counter == newValue)
             return;
+
         progress->counter = newValue;
     }
+
     progress->changed = true;
+
     if(entry->timeLimit)
     {
         time_t now = time(NULL);
         if(time_t(progress->date + entry->timeLimit) < now)
             progress->counter = 1;
+
         // also it seems illogical, the timeframe will be extended at every criteria update
         progress->date = now;
     }
     SendCriteriaUpdate(entry->ID,progress);
 }
+
 void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
 {
     sLog.outDetail("AchievementMgr::CompletedAchievement(%u)", achievement->ID);
+
     if(!sWorld.getConfig(CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER)
         return;
+    
     if(achievement->flags & ACHIEVEMENT_FLAG_COUNTER || m_completedAchievements.find(achievement->ID)!=m_completedAchievements.end())
         return;
+
     SendAchievementEarned(achievement);
     CompletedAchievementData& ca =  m_completedAchievements[achievement->ID];
     ca.date = time(NULL);
     ca.changed = true;
+
     // don't insert for ACHIEVEMENT_FLAG_REALM_FIRST_KILL since otherwise only the first group member would reach that achievement
     // TODO: where do set this instead?
     if(!(achievement->flags & ACHIEVEMENT_FLAG_REALM_FIRST_KILL))
         achievementmgr.SetRealmCompleted(achievement);
+
     UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT);
+
     // reward items and titles if any
     AchievementReward const* reward = achievementmgr.GetAchievementReward(achievement);
+
     // no rewards
     if(!reward)
         return;
+
     // titles
     if(uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE ? 0 : 1])
     {
         if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId))
             GetPlayer()->SetTitle(titleEntry);
     }
+
     // mail
     if(reward->sender)
     {
         Item* item = reward->itemId ? Item::CreateItem(reward->itemId,1,GetPlayer ()) : NULL;
+
         MailItemsInfo mi;
         if(item)
         {
             // save new item before send
             item->SaveToDB();                               // save for prevent lost at next mail load, if send fail then item will deleted
+
             // item
             mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item);
         }
+
         int loc_idx = GetPlayer()->GetSession()->GetSessionDbLocaleIndex();
+
         // subject and text
         std::string subject = reward->subject;
         std::string text = reward->text;
@@ -1564,28 +1736,36 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
                     text = loc->text[loc_idx];
             }
         }
+
         uint32 itemTextId = objmgr.CreateItemText( text );
+
         WorldSession::SendMailTo(GetPlayer(), MAIL_CREATURE, MAIL_STATIONERY_NORMAL, reward->sender, GetPlayer()->GetGUIDLow(), subject, itemTextId , &mi, 0, 0, MAIL_CHECK_MASK_NONE);
     }
 }
+
 void AchievementMgr::SendAllAchievementData()
 {
     uint32 size = 18 + m_completedAchievements.size()*8 + m_criteriaProgress.size() * 36;
+
     bool send = false;
+
     WorldPacket data(SMSG_ALL_ACHIEVEMENT_DATA);
     if( size < 0x8000 )
         data.resize( size );
     else
         data.resize( 0x7fff );
         // More than this causes client trouble
+    
     CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin();
     CriteriaProgressMap::const_iterator iter2 = m_criteriaProgress.begin();
+
     bool cAchievements = false;
     bool cProgress = false;
     while( !cAchievements || !cProgress )
     {
         data.clear();
         send = false;
+        
         if( !cAchievements )
         {
             for(; iter != m_completedAchievements.end() && !send; ++iter)
@@ -1594,9 +1774,11 @@ void AchievementMgr::SendAllAchievementData()
                 data << uint32(secsToTimeBitFields(iter->second.date));
                 send = data.size() > 0x7f00;
             }
+
             if( iter == m_completedAchievements.end() )
                 cAchievements = true;
         }
+
         data << int32(-1);
         for(; iter2 != m_criteriaProgress.end() && !send; ++iter2)
         {
@@ -1609,12 +1791,15 @@ void AchievementMgr::SendAllAchievementData()
             data << uint32(0);
             send = data.size() > 0x7f00;
         }
+        
         if( iter2 == m_criteriaProgress.end() )
             cProgress = true;
+
         data << int32(-1);
         GetPlayer()->GetSession()->SendPacket(&data);
     }
 }
+
 void AchievementMgr::SendRespondInspectAchievements(Player* player)
 {
     // since we don't know the exact size of the packed GUIDs this is just an approximation
@@ -1623,6 +1808,7 @@ void AchievementMgr::SendRespondInspectAchievements(Player* player)
     BuildAllDataPacket(&data);
     player->GetSession()->SendPacket(&data);
 }
+
 /**
  * used by SMSG_RESPOND_INSPECT_ACHIEVEMENT
  */
@@ -1634,6 +1820,7 @@ void AchievementMgr::BuildAllDataPacket(WorldPacket *data)
         *data << uint32(secsToTimeBitFields(iter->second.date));
     }
     *data << int32(-1);
+
     for(CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter)
     {
         *data << uint32(iter->first);
@@ -1644,72 +1831,91 @@ void AchievementMgr::BuildAllDataPacket(WorldPacket *data)
         *data << uint32(0);
         *data << uint32(0);
     }
+
     *data << int32(-1);
 }
+
 //==========================================================
 AchievementCriteriaEntryList const& AchievementGlobalMgr::GetAchievementCriteriaByType(AchievementCriteriaTypes type)
 {
     return m_AchievementCriteriasByType[type];
 }
+
 void AchievementGlobalMgr::LoadAchievementCriteriaList()
 {
     if(sAchievementCriteriaStore.GetNumRows()==0)
     {
         barGoLink bar(1);
         bar.step();
+
         sLog.outString();
         sLog.outErrorDb(">> Loaded 0 achievement criteria.");
         return;
     }
+
     barGoLink bar( sAchievementCriteriaStore.GetNumRows() );
     for (uint32 entryId = 0; entryId < sAchievementCriteriaStore.GetNumRows(); ++entryId)
     {
         bar.step();
+
         AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(entryId);
         if(!criteria)
             continue;
+
         m_AchievementCriteriasByType[criteria->requiredType].push_back(criteria);
         m_AchievementCriteriaListByAchievement[criteria->referredAchievement].push_back(criteria);
     }
+
     sLog.outString();
     sLog.outString(">> Loaded %lu achievement criteria.",(unsigned long)m_AchievementCriteriasByType->size());
 }
+
 void AchievementGlobalMgr::LoadAchievementReferenceList()
 {
     if(sAchievementStore.GetNumRows()==0)
     {
         barGoLink bar(1);
         bar.step();
+
         sLog.outString();
         sLog.outErrorDb(">> Loaded 0 achievement references.");
         return;
     }
+
     uint32 count = 0;
     barGoLink bar( sAchievementStore.GetNumRows() );
     for (uint32 entryId = 0; entryId < sAchievementStore.GetNumRows(); ++entryId)
     {
         bar.step();
+
         AchievementEntry const* achievement = sAchievementStore.LookupEntry(entryId);
         if(!achievement || !achievement->refAchievement)
             continue;
+
         m_AchievementListByReferencedId[achievement->refAchievement].push_back(achievement);
         ++count;
     }
+
     sLog.outString();
     sLog.outString(">> Loaded %u achievement references.",count);
 }
+
 void AchievementGlobalMgr::LoadAchievementCriteriaData()
 {
     m_criteriaDataMap.clear();                              // need for reload case
+
     QueryResult *result = WorldDatabase.Query("SELECT criteria_id, type, value1, value2 FROM achievement_criteria_data");
+
     if(!result)
     {
         barGoLink bar(1);
         bar.step();
+
         sLog.outString();
         sLog.outString(">> Loaded 0 additional achievement criteria data. DB table `achievement_criteria_data` is empty.");
         return;
     }
+
     uint32 count = 0;
     uint32 disabled_count = 0;
     barGoLink bar(result->GetRowCount());
@@ -1718,34 +1924,45 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
         bar.step();
         Field *fields = result->Fetch();
         uint32 criteria_id = fields[0].GetUInt32();
+
         AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(criteria_id);
+
         if (!criteria)
         {
             sLog.outErrorDb( "Table `achievement_criteria_data` have data for not existed criteria (Entry: %u), ignore.", criteria_id);
             continue;
         }
+
         AchievementCriteriaData data(fields[1].GetUInt32(),fields[2].GetUInt32(),fields[3].GetUInt32());
+
         if (!data.IsValid(criteria))
         {
             continue;
         }
+
         // this will allocate empty data set storage
         AchievementCriteriaDataSet& dataSet = m_criteriaDataMap[criteria_id];
+
         if (data.dataType == ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED)
             ++disabled_count;
+
         // add real data only for not NONE data types
         if (data.dataType != ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE)
             dataSet.Add(data);
+
         // counting data by and data types
         ++count;
     } while(result->NextRow());
+
     delete result;
+
     // post loading checks
     for (uint32 entryId = 0; entryId < sAchievementCriteriaStore.GetNumRows(); ++entryId)
     {
         AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(entryId);
         if(!criteria)
             continue;
+
         switch(criteria->requiredType)
         {
             case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
@@ -1759,6 +1976,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
                 AchievementEntry const* achievement = sAchievementStore.LookupEntry(criteria->referredAchievement);
                 if(!achievement)
                     continue;
+
                 // exist many achievements with this criteria, use at this moment hardcoded check to skil simple case
                 switch(achievement->ID)
                 {
@@ -1798,28 +2016,35 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
             default:                                        // type not use DB data, ignore
                 continue;
         }
+
         if(!GetCriteriaDataSet(criteria))
             sLog.outErrorDb( "Table `achievement_criteria_data` not have expected data for criteria (Entry: %u Type: %u) for achievement %u.", criteria->ID, criteria->requiredType, criteria->referredAchievement);
     }
+
     sLog.outString();
     sLog.outString(">> Loaded %u additional achievement criteria data (%u disabled).",count,disabled_count);
 }
+
 void AchievementGlobalMgr::LoadCompletedAchievements()
 {
     QueryResult *result = CharacterDatabase.Query("SELECT achievement FROM character_achievement GROUP BY achievement");
+
     if(!result)
     {
         barGoLink bar(1);
         bar.step();
+
         sLog.outString();
         sLog.outString(">> Loaded 0 realm completed achievements . DB table `character_achievement` is empty.");
         return;
     }
+
     barGoLink bar(result->GetRowCount());
     do
     {
         bar.step();
         Field *fields = result->Fetch();
+
         uint32 achievement_id = fields[0].GetUInt32();
         if(!sAchievementStore.LookupEntry(achievement_id))
         {
@@ -1828,30 +2053,41 @@ void AchievementGlobalMgr::LoadCompletedAchievements()
             CharacterDatabase.PExecute("DELETE FROM character_achievement WHERE achievement = %u",achievement_id);
             continue;
         }
+
         m_allCompletedAchievements.insert(achievement_id);
     } while(result->NextRow());
+
     delete result;
+
     sLog.outString();
     sLog.outString(">> Loaded %lu realm completed achievements.",(unsigned long)m_allCompletedAchievements.size());
 }
+
 void AchievementGlobalMgr::LoadRewards()
 {
     m_achievementRewards.clear();                           // need for reload case
+
     //                                                0      1        2        3     4       5        6
     QueryResult *result = WorldDatabase.Query("SELECT entry, title_A, title_H, item, sender, subject, text FROM achievement_reward");
+
     if(!result)
     {
         barGoLink bar(1);
+
         bar.step();
+
         sLog.outString();
         sLog.outErrorDb(">> Loaded 0 achievement rewards. DB table `achievement_reward` is empty.");
         return;
     }
+
     uint32 count = 0;
     barGoLink bar(result->GetRowCount());
+
     do
     {
         bar.step();
+
         Field *fields = result->Fetch();
         uint32 entry = fields[0].GetUInt32();
         if (!sAchievementStore.LookupEntry(entry))
@@ -1859,6 +2095,7 @@ void AchievementGlobalMgr::LoadRewards()
             sLog.outErrorDb( "Table `achievement_reward` has wrong achievement (Entry: %u), ignore", entry);
             continue;
         }
+
         AchievementReward reward;
         reward.titleId[0] = fields[1].GetUInt32();
         reward.titleId[1] = fields[2].GetUInt32();
@@ -1866,14 +2103,17 @@ void AchievementGlobalMgr::LoadRewards()
         reward.sender     = fields[4].GetUInt32();
         reward.subject    = fields[5].GetCppString();
         reward.text       = fields[6].GetCppString();
+
         if ((reward.titleId[0]==0)!=(reward.titleId[1]==0))
             sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has title (A: %u H: %u) only for one from teams.", entry, reward.titleId[0], reward.titleId[1]);
+
         // must be title or mail at least
         if (!reward.titleId[0] && !reward.titleId[1] && !reward.sender)
         {
             sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have title or item reward data, ignore.", entry);
             continue;
         }
+
         if (reward.titleId[0])
         {
             CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.titleId[0]);
@@ -1883,6 +2123,7 @@ void AchievementGlobalMgr::LoadRewards()
                 reward.titleId[0] = 0;
             }
         }
+
         if (reward.titleId[1])
         {
             CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.titleId[1]);
@@ -1892,6 +2133,7 @@ void AchievementGlobalMgr::LoadRewards()
                 reward.titleId[1] = 0;
             }
         }
+
         //check mail data before item for report including wrong item case
         if (reward.sender)
         {
@@ -1905,11 +2147,14 @@ void AchievementGlobalMgr::LoadRewards()
         {
             if (reward.itemId)
                 sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have item reward, item will not rewarded", entry);
+
             if (!reward.subject.empty())
                 sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have mail subject.", entry);
+
             if (!reward.text.empty())
                 sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have mail text.", entry);
         }
+
         if (reward.itemId)
         {
             if (!objmgr.GetItemPrototype(reward.itemId))
@@ -1918,37 +2163,52 @@ void AchievementGlobalMgr::LoadRewards()
                 reward.itemId = 0;
             }
         }
+
         m_achievementRewards[entry] = reward;
         ++count;
+
     } while (result->NextRow());
+
     delete result;
+
     sLog.outString();
     sLog.outString( ">> Loaded %u achievement rewards", count );
 }
+
 void AchievementGlobalMgr::LoadRewardLocales()
 {
     m_achievementRewardLocales.clear();                       // need for reload case
+
     QueryResult *result = WorldDatabase.Query("SELECT entry,subject_loc1,text_loc1,subject_loc2,text_loc2,subject_loc3,text_loc3,subject_loc4,text_loc4,subject_loc5,text_loc5,subject_loc6,text_loc6,subject_loc7,text_loc7,subject_loc8,text_loc8 FROM locales_achievement_reward");
+
     if(!result)
     {
         barGoLink bar(1);
+
         bar.step();
+
         sLog.outString();
         sLog.outString(">> Loaded 0 achievement reward locale strings. DB table `locales_achievement_reward` is empty.");
         return;
     }
+
     barGoLink bar(result->GetRowCount());
+
     do
     {
         Field *fields = result->Fetch();
         bar.step();
+
         uint32 entry = fields[0].GetUInt32();
+
         if(m_achievementRewards.find(entry)==m_achievementRewards.end())
         {
             sLog.outErrorDb( "Table `locales_achievement_reward` (Entry: %u) has locale strings for not existed achievement reward .", entry);
             continue;
         }
+
         AchievementRewardLocale& data = m_achievementRewardLocales[entry];
+
         for(int i = 1; i < MAX_LOCALE; ++i)
         {
             std::string str = fields[1+2*(i-1)].GetCppString();
@@ -1959,6 +2219,7 @@ void AchievementGlobalMgr::LoadRewardLocales()
                 {
                     if(data.subject.size() <= size_t(idx))
                         data.subject.resize(idx+1);
+
                     data.subject[idx] = str;
                 }
             }
@@ -1970,13 +2231,16 @@ void AchievementGlobalMgr::LoadRewardLocales()
                 {
                     if(data.text.size() <= size_t(idx))
                         data.text.resize(idx+1);
+
                     data.text[idx] = str;
                 }
             }
         }
     } while (result->NextRow());
+
     delete result;
 
+
     sLog.outString();
     sLog.outString( ">> Loaded %lu achievement reward locale strings", (unsigned long)m_achievementRewardLocales.size() );
 }
diff --git a/src/game/AchievementMgr.h b/src/game/AchievementMgr.h
index 2a2f02e243f..5020539bb5c 100644
--- a/src/game/AchievementMgr.h
+++ b/src/game/AchievementMgr.h
@@ -17,23 +17,29 @@
  */
 #ifndef __MANGOS_ACHIEVEMENTMGR_H
 #define __MANGOS_ACHIEVEMENTMGR_H
+
 #include 
 #include 
+
 #include "Common.h"
 #include "Policies/Singleton.h"
 #include "Database/DatabaseEnv.h"
 #include "DBCEnums.h"
 #include "DBCStores.h"
+
 typedef std::list AchievementCriteriaEntryList;
 typedef std::list         AchievementEntryList;
+
 typedef std::map AchievementCriteriaListByAchievement;
 typedef std::map         AchievementListByReferencedId;
+
 struct CriteriaProgress
 {
     uint32 counter;
     time_t date;
     bool changed;
 };
+
 enum AchievementCriteriaDataType
 {                                                           // value1         value2        comment
     ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE                = 0, // 0              0
@@ -55,9 +61,12 @@ enum AchievementCriteriaDataType
     ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY             = 16,// holiday_id     0             event in holiday time
     ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_LOSS_TEAM_SCORE  = 17,// min_score      max_score     player's team win bg and opposition team have team score in range
 };
+
 #define MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE               18 // maximum value in AchievementCriteriaDataType enum
+
 class Player;
 class Unit;
+
 struct AchievementCriteriaData
 {
     AchievementCriteriaDataType dataType;
@@ -151,19 +160,23 @@ struct AchievementCriteriaData
             uint32 value2;
         } raw;
     };
+
     AchievementCriteriaData() : dataType(ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE)
     {
         raw.value1 = 0;
         raw.value2 = 0;
     }
+
     AchievementCriteriaData(uint32 _dataType, uint32 _value1, uint32 _value2) : dataType(AchievementCriteriaDataType(_dataType))
     {
         raw.value1 = _value1;
         raw.value2 = _value2;
     }
+
     bool IsValid(AchievementCriteriaEntry const* criteria);
     bool Meets(Player const* source, Unit const* target, uint32 miscvalue1 = 0) const;
 };
+
 struct AchievementCriteriaDataSet
 {
         typedef std::vector Storage;
@@ -173,7 +186,9 @@ struct AchievementCriteriaDataSet
         Storage storage;
 };
 
+
 typedef std::map AchievementCriteriaDataMap;
+
 struct AchievementReward
 {
     uint32 titleId[2];
@@ -182,29 +197,37 @@ struct AchievementReward
     std::string subject;
     std::string text;
 };
+
 typedef std::map AchievementRewards;
+
 struct AchievementRewardLocale
 {
     std::vector subject;
     std::vector text;
 };
+
 typedef std::map AchievementRewardLocales;
 
+
 struct CompletedAchievementData
 {
     time_t date;
     bool changed;
 };
+
 typedef UNORDERED_MAP CriteriaProgressMap;
 typedef UNORDERED_MAP CompletedAchievementMap;
+
 class Unit;
 class Player;
 class WorldPacket;
+
 class AchievementMgr
 {
     public:
         AchievementMgr(Player* pl);
         ~AchievementMgr();
+
         void Reset();
         static void DeleteFromDB(uint32 lowguid);
         void LoadFromDB(QueryResult *achievementResult, QueryResult *criteriaResult);
@@ -216,6 +239,7 @@ class AchievementMgr
         void SendAllAchievementData();
         void SendRespondInspectAchievements(Player* player);
         Player* GetPlayer() { return m_player;}
+
     private:
         enum ProgressType { PROGRESS_SET, PROGRESS_ACCUMULATE, PROGRESS_HIGHEST };
         void SendAchievementEarned(AchievementEntry const* achievement);
@@ -226,10 +250,12 @@ class AchievementMgr
         bool IsCompletedAchievement(AchievementEntry const* entry);
         void CompleteAchievementsWithRefs(AchievementEntry const* entry);
         void BuildAllDataPacket(WorldPacket *data);
+
         Player* m_player;
         CriteriaProgressMap m_criteriaProgress;
         CompletedAchievementMap m_completedAchievements;
 };
+
 class AchievementGlobalMgr
 {
     public:
@@ -239,34 +265,41 @@ class AchievementGlobalMgr
             AchievementCriteriaListByAchievement::const_iterator itr = m_AchievementCriteriaListByAchievement.find(id);
             return itr != m_AchievementCriteriaListByAchievement.end() ? &itr->second : NULL;
         }
+
         AchievementEntryList const* GetAchievementByReferencedId(uint32 id) const
         {
             AchievementListByReferencedId::const_iterator itr = m_AchievementListByReferencedId.find(id);
             return itr != m_AchievementListByReferencedId.end() ? &itr->second : NULL;
         }
+
         AchievementReward const* GetAchievementReward(AchievementEntry const* achievement) const
         {
             AchievementRewards::const_iterator iter = m_achievementRewards.find(achievement->ID);
             return iter!=m_achievementRewards.end() ? &iter->second : NULL;
         }
+
         AchievementRewardLocale const* GetAchievementRewardLocale(AchievementEntry const* achievement) const
         {
             AchievementRewardLocales::const_iterator iter = m_achievementRewardLocales.find(achievement->ID);
             return iter!=m_achievementRewardLocales.end() ? &iter->second : NULL;
         }
+
         AchievementCriteriaDataSet const* GetCriteriaDataSet(AchievementCriteriaEntry const *achievementCriteria)
         {
             AchievementCriteriaDataMap::const_iterator iter = m_criteriaDataMap.find(achievementCriteria->ID);
             return iter!=m_criteriaDataMap.end() ? &iter->second : NULL;
         }
+
         bool IsRealmCompleted(AchievementEntry const* achievement) const
         {
             return m_allCompletedAchievements.find(achievement->ID) != m_allCompletedAchievements.end();
         }
+
         void SetRealmCompleted(AchievementEntry const* achievement)
         {
             m_allCompletedAchievements.insert(achievement->ID);
         }
+
         void LoadAchievementCriteriaList();
         void LoadAchievementCriteriaData();
         void LoadAchievementReferenceList();
@@ -275,16 +308,21 @@ class AchievementGlobalMgr
         void LoadRewardLocales();
     private:
         AchievementCriteriaDataMap m_criteriaDataMap;
+
         // store achievement criterias by type to speed up lookup
         AchievementCriteriaEntryList m_AchievementCriteriasByType[ACHIEVEMENT_CRITERIA_TYPE_TOTAL];
         // store achievement criterias by achievement to speed up lookup
         AchievementCriteriaListByAchievement m_AchievementCriteriaListByAchievement;
         // store achievements by referenced achievement id to speed up lookup
         AchievementListByReferencedId m_AchievementListByReferencedId;
+
         typedef std::set AllCompletedAchievements;
         AllCompletedAchievements m_allCompletedAchievements;
+
         AchievementRewards m_achievementRewards;
         AchievementRewardLocales m_achievementRewardLocales;
 };
+
 #define achievementmgr Trinity::Singleton::Instance()
+
 #endif
diff --git a/src/game/AnimalRandomMovementGenerator.h b/src/game/AnimalRandomMovementGenerator.h
index 4767eff91ad..9c64edcaa44 100644
--- a/src/game/AnimalRandomMovementGenerator.h
+++ b/src/game/AnimalRandomMovementGenerator.h
@@ -17,8 +17,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_ANIMAL_RANDOMMOVEMENTGENERATOR_H
 #define TRINITY_ANIMAL_RANDOMMOVEMENTGENERATOR_H
+
 /** AnimalRandomMovementGenerator follows the research on
  *  quantifying scale-dependant effects of animal movement
  *  with simple per-location models (R.H. Gardner, R.V. O'Neil,
diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp
index c00c22b7b48..22d121c38c1 100644
--- a/src/game/ArenaTeam.cpp
+++ b/src/game/ArenaTeam.cpp
@@ -15,10 +15,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "ObjectMgr.h"
 #include "WorldPacket.h"
+
 #include "ArenaTeam.h"
 #include "World.h"
+
 void ArenaTeamMember::ModifyPersonalRating(Player* plr, int32 mod, uint32 slot)
 {
     int32 memberRating = int32(personal_rating) + mod;
@@ -27,6 +30,7 @@ void ArenaTeamMember::ModifyPersonalRating(Player* plr, int32 mod, uint32 slot)
         plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot*6) + 5, personal_rating);
     //sLog.outArena("Modify personal rating for player %s: personal rating %u, mod %d, rating %d", plr->GetName(), personal_rating, mod, rating);
 }
+
 ArenaTeam::ArenaTeam()
 {
     m_TeamId              = 0;
@@ -48,22 +52,29 @@ ArenaTeam::ArenaTeam()
     m_stats.wins_week     = 0;
     m_stats.wins_season   = 0;
 }
+
 ArenaTeam::~ArenaTeam()
 {
 }
+
 bool ArenaTeam::Create(uint64 captainGuid, uint32 type, std::string ArenaTeamName)
 {
     if(!objmgr.GetPlayer(captainGuid))                      // player not exist
         return false;
     if(objmgr.GetArenaTeamByName(ArenaTeamName))            // arena team with this name already exist
         return false;
+
     sLog.outDebug("GUILD: creating arena team %s to leader: %u", ArenaTeamName.c_str(), GUID_LOPART(captainGuid));
+
     m_CaptainGuid = captainGuid;
     m_Name = ArenaTeamName;
     m_Type = type;
+
     m_TeamId = objmgr.GenerateArenaTeamId();
+
     // ArenaTeamName already assigned to ArenaTeam::name, use it to encode string for DB
     CharacterDatabase.escape_string(ArenaTeamName);
+
     CharacterDatabase.BeginTransaction();
     // CharacterDatabase.PExecute("DELETE FROM arena_team WHERE arenateamid='%u'", m_TeamId); - MAX(arenateam)+1 not exist
     CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid='%u'", m_TeamId);
@@ -72,18 +83,23 @@ bool ArenaTeam::Create(uint64 captainGuid, uint32 type, std::string ArenaTeamNam
         m_TeamId, ArenaTeamName.c_str(), GUID_LOPART(m_CaptainGuid), m_Type, m_BackgroundColor, m_EmblemStyle, m_EmblemColor, m_BorderStyle, m_BorderColor);
     CharacterDatabase.PExecute("INSERT INTO arena_team_stats (arenateamid, rating, games, wins, played, wins2, rank) VALUES "
         "('%u', '%u', '%u', '%u', '%u', '%u', '%u')", m_TeamId, m_stats.rating, m_stats.games_week, m_stats.wins_week, m_stats.games_season, m_stats.wins_season, m_stats.rank);
+
     CharacterDatabase.CommitTransaction();
+
     AddMember(m_CaptainGuid);
     sLog.outArena("New ArenaTeam created [Id: %u] [Type: %u] [Captain GUID: %u]", GetId(), GetType(), GetCaptain());
     return true;
 }
+
 bool ArenaTeam::AddMember(const uint64& PlayerGuid)
 {
     std::string plName;
     uint8 plClass;
+
     // arena team is full (can't have more than type * 2 players!)
     if(GetMembersSize() >= GetType() * 2)
         return false;
+
     Player *pl = objmgr.GetPlayer(PlayerGuid);
     if(pl)
     {
@@ -92,6 +108,7 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
             sLog.outError("Arena::AddMember() : player already in this sized team");
             return false;
         }
+
         plClass = (uint8)pl->getClass();
         plName = pl->GetName();
     }
@@ -101,9 +118,11 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
         QueryResult *result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", GUID_LOPART(PlayerGuid));
         if(!result)
             return false;
+
         plName = (*result)[0].GetCppString();
         plClass = (*result)[1].GetUInt8();
         delete result;
+
         // check if player already in arenateam of that size
         if(Player::GetArenaTeamIdFromDB(PlayerGuid, GetType()) != 0)
         {
@@ -111,9 +130,11 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
             return false;
         }
     }
+
     // remove all player signs from another petitions
     // this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
     Player::RemovePetitionsAndSigns(PlayerGuid, GetType());
+
     ArenaTeamMember newmember;
     newmember.name              = plName;
     newmember.guid              = PlayerGuid;
@@ -134,12 +155,15 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
         newmember.personal_rating = 1500;
     }
     m_members.push_back(newmember);
+
     CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid, personal_rating) VALUES ('%u', '%u', '%u')", m_TeamId, GUID_LOPART(newmember.guid), newmember.personal_rating );
+
     if(pl)
     {
         pl->SetInArenaTeam(m_TeamId, GetSlot());
         pl->SetArenaTeamIdInvited(0);
         pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot()*6) + 5, newmember.personal_rating );
+
         // hide promote/remove buttons
         if(m_CaptainGuid != PlayerGuid)
             pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6) + 1, 1);
@@ -147,12 +171,16 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
     }
     return true;
 }
+
 bool ArenaTeam::LoadArenaTeamFromDB(uint32 ArenaTeamId)
 {
     QueryResult *result = CharacterDatabase.PQuery("SELECT arenateamid,name,captainguid,type,BackgroundColor,EmblemStyle,EmblemColor,BorderStyle,BorderColor FROM arena_team WHERE arenateamid = '%u'", ArenaTeamId);
+
     if(!result)
         return false;
+
     Field *fields = result->Fetch();
+
     m_TeamId = fields[0].GetUInt32();
     m_Name = fields[1].GetCppString();
     m_CaptainGuid  = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER);
@@ -162,10 +190,13 @@ bool ArenaTeam::LoadArenaTeamFromDB(uint32 ArenaTeamId)
     m_EmblemColor = fields[6].GetUInt32();
     m_BorderStyle = fields[7].GetUInt32();
     m_BorderColor = fields[8].GetUInt32();
+
     delete result;
+
     // only load here, so additional checks can be made
     LoadStatsFromDB(ArenaTeamId);
     LoadMembersFromDB(ArenaTeamId);
+
     if(Empty())
     {
         // arena team is empty, delete from db
@@ -176,23 +207,30 @@ bool ArenaTeam::LoadArenaTeamFromDB(uint32 ArenaTeamId)
         CharacterDatabase.CommitTransaction();
         return false;
     }
+
     return true;
 }
+
 void ArenaTeam::LoadStatsFromDB(uint32 ArenaTeamId)
 {
     //                                                     0      1     2    3      4     5
     QueryResult *result = CharacterDatabase.PQuery("SELECT rating,games,wins,played,wins2,rank FROM arena_team_stats WHERE arenateamid = '%u'", ArenaTeamId);
+
     if(!result)
         return;
+
     Field *fields = result->Fetch();
+
     m_stats.rating        = fields[0].GetUInt32();
     m_stats.games_week    = fields[1].GetUInt32();
     m_stats.wins_week     = fields[2].GetUInt32();
     m_stats.games_season  = fields[3].GetUInt32();
     m_stats.wins_season   = fields[4].GetUInt32();
     m_stats.rank          = fields[5].GetUInt32();
+
     delete result;
 }
+
 void ArenaTeam::LoadMembersFromDB(uint32 ArenaTeamId)
 {
     //                                                           0                1           2         3             4        5        6    7
@@ -202,6 +240,7 @@ void ArenaTeam::LoadMembersFromDB(uint32 ArenaTeamId)
                                                    "WHERE member.arenateamid = '%u'", ArenaTeamId);
     if(!result)
         return;
+
     do
     {
         Field *fields = result->Fetch();
@@ -218,16 +257,20 @@ void ArenaTeam::LoadMembersFromDB(uint32 ArenaTeamId)
     }while( result->NextRow() );
     delete result;
 }
+
 void ArenaTeam::SetCaptain(const uint64& guid)
 {
     // disable remove/promote buttons
     Player *oldcaptain = objmgr.GetPlayer(GetCaptain());
     if(oldcaptain)
         oldcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1);
+
     // set new captain
     m_CaptainGuid = guid;
+
     // update database
     CharacterDatabase.PExecute("UPDATE arena_team SET captainguid = '%u' WHERE arenateamid = '%u'", GUID_LOPART(guid), m_TeamId);
+
     // enable remove/promote buttons
     Player *newcaptain = objmgr.GetPlayer(guid);
     if(newcaptain)
@@ -236,6 +279,7 @@ void ArenaTeam::SetCaptain(const uint64& guid)
         sLog.outArena("Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].", oldcaptain->GetName(), oldcaptain->GetGUIDLow(), newcaptain->GetName(), newcaptain->GetGUID(), GetId(), GetType());
     }
 }
+
 void ArenaTeam::DelMember(uint64 guid)
 {
     for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
@@ -246,7 +290,9 @@ void ArenaTeam::DelMember(uint64 guid)
             break;
         }
     }
+
     Player *player = objmgr.GetPlayer(guid);
+
     if(player)
     {
         player->SetInArenaTeam(0, GetSlot());
@@ -260,19 +306,23 @@ void ArenaTeam::DelMember(uint64 guid)
     }
     CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u' AND guid = '%u'", GetId(), GUID_LOPART(guid));
 }
+
 void ArenaTeam::Disband(WorldSession *session)
 {
     // event
     WorldPacket data;
     session->BuildArenaTeamEventPacket(&data, ERR_ARENA_TEAM_DISBANDED_S, 2, session->GetPlayerName(), GetName(), "");
     BroadcastPacket(&data);
+
     while (!m_members.empty())
     {
         // Removing from members is done in DelMember.
         DelMember(m_members.front().guid);
     }
+
     if(Player *player = session->GetPlayer())
         sLog.outArena("Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName(), player->GetGUIDLow(), GetType(), GetId());
+
     CharacterDatabase.BeginTransaction();
     CharacterDatabase.PExecute("DELETE FROM arena_team WHERE arenateamid = '%u'", m_TeamId);
     CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u'", m_TeamId); //< this should be alredy done by calling DelMember(memberGuids[j]); for each member
@@ -280,18 +330,23 @@ void ArenaTeam::Disband(WorldSession *session)
     CharacterDatabase.CommitTransaction();
     objmgr.RemoveArenaTeam(m_TeamId);
 }
+
 void ArenaTeam::Roster(WorldSession *session)
 {
     Player *pl = NULL;
+
     uint8 unk308 = 0;
+
     WorldPacket data(SMSG_ARENA_TEAM_ROSTER, 100);
     data << uint32(GetId());                                // team id
     data << uint8(unk308);                                  // 308 unknown value but affect packet structure
     data << uint32(GetMembersSize());                       // members count
     data << uint32(GetType());                              // arena team type?
+
     for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
     {
         pl = objmgr.GetPlayer(itr->guid);
+
         data << uint64(itr->guid);                          // guid
         data << uint8((pl ? 1 : 0));                        // online flag
         data << itr->name;                                  // member name
@@ -309,9 +364,11 @@ void ArenaTeam::Roster(WorldSession *session)
             data << float(0.0);                             // 308 unk
         }
     }
+
     session->SendPacket(&data);
     sLog.outDebug("WORLD: Sent SMSG_ARENA_TEAM_ROSTER");
 }
+
 void ArenaTeam::Query(WorldSession *session)
 {
     WorldPacket data(SMSG_ARENA_TEAM_QUERY_RESPONSE, 4*7+GetName().size()+1);
@@ -326,6 +383,7 @@ void ArenaTeam::Query(WorldSession *session)
     session->SendPacket(&data);
     sLog.outDebug("WORLD: Sent SMSG_ARENA_TEAM_QUERY_RESPONSE");
 }
+
 void ArenaTeam::Stats(WorldSession *session)
 {
     WorldPacket data(SMSG_ARENA_TEAM_STATS, 4*7);
@@ -338,6 +396,7 @@ void ArenaTeam::Stats(WorldSession *session)
     data << uint32(m_stats.rank);                           // rank
     session->SendPacket(&data);
 }
+
 void ArenaTeam::NotifyStatsChanged()
 {
     // this is called after a rated match ended
@@ -349,11 +408,13 @@ void ArenaTeam::NotifyStatsChanged()
             Stats(plr->GetSession());
     }
 }
+
 void ArenaTeam::InspectStats(WorldSession *session, uint64 guid)
 {
     ArenaTeamMember* member = GetMember(guid);
     if(!member)
         return;
+
     WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8+1+4*6);
     data << uint64(guid);                                   // player guid
     data << uint8(GetSlot());                               // slot (0...2)
@@ -365,6 +426,7 @@ void ArenaTeam::InspectStats(WorldSession *session, uint64 guid)
     data << uint32(member->personal_rating);                // personal rating
     session->SendPacket(&data);
 }
+
 void ArenaTeam::SetEmblem(uint32 backgroundColor, uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor)
 {
     m_BackgroundColor = backgroundColor;
@@ -372,8 +434,10 @@ void ArenaTeam::SetEmblem(uint32 backgroundColor, uint32 emblemStyle, uint32 emb
     m_EmblemColor = emblemColor;
     m_BorderStyle = borderStyle;
     m_BorderColor = borderColor;
+
     CharacterDatabase.PExecute("UPDATE arena_team SET BackgroundColor='%u', EmblemStyle='%u', EmblemColor='%u', BorderStyle='%u', BorderColor='%u' WHERE arenateamid='%u'", m_BackgroundColor, m_EmblemStyle, m_EmblemColor, m_BorderStyle, m_BorderColor, m_TeamId);
 }
+
 void ArenaTeam::SetStats(uint32 stat_type, uint32 value)
 {
     switch(stat_type)
@@ -407,6 +471,7 @@ void ArenaTeam::SetStats(uint32 stat_type, uint32 value)
             break;
     }
 }
+
 void ArenaTeam::BroadcastPacket(WorldPacket *packet)
 {
     for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
@@ -416,6 +481,7 @@ void ArenaTeam::BroadcastPacket(WorldPacket *packet)
             player->GetSession()->SendPacket(packet);
     }
 }
+
 uint8 ArenaTeam::GetSlotByType( uint32 type )
 {
     switch(type)
@@ -429,45 +495,56 @@ uint8 ArenaTeam::GetSlotByType( uint32 type )
     sLog.outError("FATAL: Unknown arena team type %u for some arena team", type);
     return 0xFF;
 }
+
 bool ArenaTeam::HaveMember( const uint64& guid ) const
 {
     for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
         if(itr->guid == guid)
             return true;
+
     return false;
 }
+
 uint32 ArenaTeam::GetPoints(uint32 MemberRating)
 {
     // returns how many points would be awarded with this team type with this rating
     float points;
+
     uint32 rating = MemberRating + 150 < m_stats.rating ? MemberRating : m_stats.rating;
+
     if(rating<=1500)
         // points = (float)1500 * 0.22f + 14.0f;
         points = 344.0f; // 3.1 change - teams with rating below 1500 get arena points for 1500 rating
     else
         points = 1511.26f / (1.0f + 1639.28f * exp(-0.00412f * (float)rating));
+
     // type penalties for <5v5 teams
     if(m_Type == ARENA_TEAM_2v2)
         points *= 0.76f;
     else if(m_Type == ARENA_TEAM_3v3)
         points *= 0.88f;
+
     return (uint32) points;
 }
+
 float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating)
 {
     // returns the chance to win against a team with the given rating, used in the rating adjustment calculation
     // ELO system
+
     if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6)
         if (enemy_rating < 1300)
             enemy_rating = 1300;
     return 1.0f/(1.0f+exp(log(10.0f)*(float)((float)enemy_rating - (float)own_rating)/400.0f));
 }
+
 void ArenaTeam::FinishGame(int32 mod)
 {
     if (int32(m_stats.rating) + mod < 0)
         m_stats.rating = 0;
     else
         m_stats.rating += mod;
+
     m_stats.games_week += 1;
     m_stats.games_season += 1;
     // update team's rank
@@ -479,6 +556,7 @@ void ArenaTeam::FinishGame(int32 mod)
             ++m_stats.rank;
     }
 }
+
 int32 ArenaTeam::WonAgainst(uint32 againstRating)
 {
     // called when the team has won
@@ -490,9 +568,11 @@ int32 ArenaTeam::WonAgainst(uint32 againstRating)
     FinishGame(mod);
     m_stats.wins_week += 1;
     m_stats.wins_season += 1;
+
     // return the rating change, used to display it on the results screen
     return mod;
 }
+
 int32 ArenaTeam::LostAgainst(uint32 againstRating)
 {
     // called when the team has lost
@@ -502,9 +582,11 @@ int32 ArenaTeam::LostAgainst(uint32 againstRating)
     int32 mod = (int32)ceil(32.0f * (0.0f - chance));
     // modify the team stats accordingly
     FinishGame(mod);
+
     // return the rating change, used to display it on the results screen
     return mod;
 }
+
 void ArenaTeam::MemberLost(Player * plr, uint32 againstRating)
 {
     // called for each participant of a match after losing
@@ -526,6 +608,7 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstRating)
         }
     }
 }
+
 void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstRating)
 {
     // called for offline player after ending rated arena match!
@@ -547,6 +630,7 @@ void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstRating)
         }
     }
 }
+
 void ArenaTeam::MemberWon(Player * plr, uint32 againstRating)
 {
     // called for each participant after winning a match
@@ -570,6 +654,7 @@ void ArenaTeam::MemberWon(Player * plr, uint32 againstRating)
         }
     }
 }
+
 void ArenaTeam::UpdateArenaPointsHelper(std::map& PlayerPoints)
 {
     // called after a match has ended and the stats are already modified
@@ -586,6 +671,7 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map& PlayerPoints)
         if (itr->games_week >= min_plays)
             points_to_add = GetPoints(itr->personal_rating);
         // OBSOLETE : CharacterDatabase.PExecute("UPDATE arena_team_member SET points_to_add = '%u' WHERE arenateamid = '%u' AND guid = '%u'", points_to_add, m_TeamId, itr->guid);
+
         std::map::iterator plr_itr = PlayerPoints.find(GUID_LOPART(itr->guid));
         if (plr_itr != PlayerPoints.end())
         {
@@ -597,6 +683,7 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map& PlayerPoints)
             PlayerPoints[GUID_LOPART(itr->guid)] = points_to_add;
     }
 }
+
 void ArenaTeam::SaveToDB()
 {
     // save team and member stats to db
@@ -609,6 +696,7 @@ void ArenaTeam::SaveToDB()
     }
     CharacterDatabase.CommitTransaction();
 }
+
 void ArenaTeam::FinishWeek()
 {
     m_stats.games_week = 0;                                   // played this week
@@ -619,6 +707,7 @@ void ArenaTeam::FinishWeek()
         itr->wins_week = 0;
     }
 }
+
 bool ArenaTeam::IsFighting() const
 {
     for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
@@ -631,6 +720,7 @@ bool ArenaTeam::IsFighting() const
     }
     return false;
 }
+
 /*
 arenateam fields (id from 2.3.3 client):
 1414 - arena team id 2v2
diff --git a/src/game/ArenaTeam.h b/src/game/ArenaTeam.h
index fe7a4d04ea5..dbeac2f09f0 100644
--- a/src/game/ArenaTeam.h
+++ b/src/game/ArenaTeam.h
@@ -17,8 +17,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef TRINITYCORE_ARENATEAM_H
 #define TRINITYCORE_ARENATEAM_H
+
 enum ArenaTeamCommandTypes
 {
     ERR_ARENA_TEAM_CREATE_S                 = 0x00,
@@ -27,6 +29,7 @@ enum ArenaTeamCommandTypes
     ERR_ARENA_TEAM_QUIT_S                   = 0x03,
     ERR_ARENA_TEAM_FOUNDER_S                = 0x0C          // need check, probably wrong...
 };
+
 enum ArenaTeamCommandErrors
 {
     //ARENA_TEAM_PLAYER_NO_MORE_IN_ARENA_TEAM = 0x00,
@@ -46,6 +49,7 @@ enum ArenaTeamCommandErrors
     ERR_ARENA_TEAM_PLAYER_TO_LOW            = 0x15,
     ERR_ARENA_TEAM_FULL                     = 0x16
 };
+
 enum ArenaTeamEvents
 {
     ERR_ARENA_TEAM_JOIN_SS                  = 3,            // player name + arena team name
@@ -55,6 +59,7 @@ enum ArenaTeamEvents
     ERR_ARENA_TEAM_LEADER_CHANGED_SSS       = 7,            // old captain + new captain + arena team name
     ERR_ARENA_TEAM_DISBANDED_S              = 8             // captain name + arena team name
 };
+
 /*
 need info how to send these ones:
 ERR_ARENA_TEAM_YOU_JOIN_S - client show it automatically when accept invite
@@ -62,6 +67,7 @@ ERR_ARENA_TEAM_TARGET_TOO_LOW_S
 ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S
 ERR_ARENA_TEAM_LEVEL_TOO_LOW_I
 */
+
 enum ArenaTeamStatTypes
 {
     STAT_TYPE_RATING        = 0,
@@ -71,12 +77,14 @@ enum ArenaTeamStatTypes
     STAT_TYPE_WINS_SEASON   = 4,
     STAT_TYPE_RANK          = 5
 };
+
 enum ArenaTeamTypes
 {
     ARENA_TEAM_2v2      = 2,
     ARENA_TEAM_3v3      = 3,
     ARENA_TEAM_5v5      = 5
 };
+
 struct ArenaTeamMember
 {
     uint64 guid;
@@ -87,8 +95,10 @@ struct ArenaTeamMember
     uint32 games_season;
     uint32 wins_season;
     uint32 personal_rating;
+
     void ModifyPersonalRating(Player* plr, int32 mod, uint32 slot);
 };
+
 struct ArenaTeamStats
 {
     uint32 rating;
@@ -98,15 +108,20 @@ struct ArenaTeamStats
     uint32 wins_season;
     uint32 rank;
 };
+
 #define MAX_ARENA_SLOT 3                                    // 0..2 slots
+
 class ArenaTeam
 {
     public:
         ArenaTeam();
         ~ArenaTeam();
+
         bool Create(uint64 captainGuid, uint32 type, std::string ArenaTeamName);
         void Disband(WorldSession *session);
+
         typedef std::list MemberList;
+
         uint32 GetId() const              { return m_TeamId; }
         uint32 GetType() const            { return m_Type; }
         uint8  GetSlot() const            { return GetSlotByType(GetType()); }
@@ -116,46 +131,61 @@ class ArenaTeam
         const ArenaTeamStats& GetStats() const { return m_stats; }
         void SetStats(uint32 stat_type, uint32 value);
         uint32 GetRating() const          { return m_stats.rating; }
+
         uint32 GetEmblemStyle() const     { return m_EmblemStyle; }
         uint32 GetEmblemColor() const     { return m_EmblemColor; }
         uint32 GetBorderStyle() const     { return m_BorderStyle; }
         uint32 GetBorderColor() const     { return m_BorderColor; }
         uint32 GetBackgroundColor() const { return m_BackgroundColor; }
+
         void SetCaptain(const uint64& guid);
         bool AddMember(const uint64& PlayerGuid);
+
         // Shouldn't be const uint64& ed, because than can reference guid from members on Disband
         // and this method removes given record from list. So invalid reference can happen.
         void DelMember(uint64 guid);
+
         void SetEmblem(uint32 backgroundColor, uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor);
+
         size_t GetMembersSize() const         { return m_members.size(); }
         bool   Empty() const                  { return m_members.empty(); }
         MemberList::iterator m_membersBegin() { return m_members.begin(); }
         MemberList::iterator m_membersEnd()   { return m_members.end(); }
         bool HaveMember(const uint64& guid) const;
+
         ArenaTeamMember* GetMember(const uint64& guid)
         {
             for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
                 if(itr->guid == guid)
                     return &(*itr);
+
             return NULL;
         }
+
         ArenaTeamMember* GetMember(const std::string& name)
         {
             for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
                 if(itr->name == name)
                     return &(*itr);
+
             return NULL;
         }
+
         bool IsFighting() const;
+
         bool LoadArenaTeamFromDB(uint32 ArenaTeamId);
         void LoadMembersFromDB(uint32 ArenaTeamId);
         void LoadStatsFromDB(uint32 ArenaTeamId);
+
         void SaveToDB();
+
         void BroadcastPacket(WorldPacket *packet);
+
         void Roster(WorldSession *session);
         void Query(WorldSession *session);
         void Stats(WorldSession *session);
         void InspectStats(WorldSession *session, uint64 guid);
+
         uint32 GetPoints(uint32 MemberRating);
         float GetChanceAgainst(uint32 own_rating, uint32 enemy_rating);
         int32 WonAgainst(uint32 againstRating);
@@ -163,20 +193,27 @@ class ArenaTeam
         int32 LostAgainst(uint32 againstRating);
         void MemberLost(Player * plr, uint32 againstRating);
         void OfflineMemberLost(uint64 guid, uint32 againstRating);
+
         void UpdateArenaPointsHelper(std::map & PlayerPoints);
+
         void NotifyStatsChanged();
+
         void FinishWeek();
         void FinishGame(int32 mod);
+
     protected:
+
         uint32 m_TeamId;
         uint32 m_Type;
         std::string m_Name;
         uint64 m_CaptainGuid;
+
         uint32 m_BackgroundColor; // ARGB format
         uint32 m_EmblemStyle;     // icon id
         uint32 m_EmblemColor;     // ARGB format
         uint32 m_BorderStyle;     // border image id
         uint32 m_BorderColor;     // ARGB format
+
         MemberList m_members;
         ArenaTeamStats m_stats;
 };
diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp
index b5ecab3d424..c7ecf5b1d80 100644
--- a/src/game/ArenaTeamHandler.cpp
+++ b/src/game/ArenaTeamHandler.cpp
@@ -17,21 +17,26 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "Player.h"
 #include "World.h"
 #include "WorldPacket.h"
 #include "WorldSession.h"
 #include "Database/DatabaseEnv.h"
+
 #include "ArenaTeam.h"
 #include "Log.h"
 #include "ObjectMgr.h"
 #include "SocialMgr.h"
+
 void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recv_data)
 {
     sLog.outDebug("MSG_INSPECT_ARENA_TEAMS");
+
     uint64 guid;
     recv_data >> guid;
     sLog.outDebug("Inspect Arena stats (GUID: %u TypeId: %u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)));
+
     if(Player *plr = objmgr.GetPlayer(guid))
     {
         for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i)
@@ -44,123 +49,160 @@ void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recv_data)
         }
     }
 }
+
 void WorldSession::HandleArenaTeamQueryOpcode(WorldPacket & recv_data)
 {
     sLog.outDebug( "WORLD: Received CMSG_ARENA_TEAM_QUERY" );
+
     uint32 ArenaTeamId;
     recv_data >> ArenaTeamId;
+
     ArenaTeam *arenateam = objmgr.GetArenaTeamById(ArenaTeamId);
     if(!arenateam)                                          // arena team not found
         return;
+
     arenateam->Query(this);
     arenateam->Stats(this);
 }
+
 void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket & recv_data)
 {
     sLog.outDebug( "WORLD: Received CMSG_ARENA_TEAM_ROSTER" );
+
     uint32 ArenaTeamId;                                     // arena team id
     recv_data >> ArenaTeamId;
+
     ArenaTeam *arenateam = objmgr.GetArenaTeamById(ArenaTeamId);
     if(!arenateam)
         return;
+
     arenateam->Roster(this);
 }
+
 void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data)
 {
     sLog.outDebug("CMSG_ARENA_TEAM_INVITE");
+
     uint32 ArenaTeamId;                                     // arena team id
     std::string Invitedname;
+
     Player * player = NULL;
+
     recv_data >> ArenaTeamId >> Invitedname;
+
     if(!Invitedname.empty())
     {
         if(!normalizePlayerName(Invitedname))
             return;
+
         player = ObjectAccessor::Instance().FindPlayerByName(Invitedname.c_str());
     }
+
     if(!player)
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", Invitedname, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S);
         return;
     }
+
     if(player->getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ARENA_TEAM_PLAYER_TO_LOW);
         return;
     }
+
     ArenaTeam *arenateam = objmgr.GetArenaTeamById(ArenaTeamId);
     if(!arenateam)
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM);
         return;
     }
+
     // OK result but not send invite
     if(player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
         return;
+
     if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != GetPlayer()->GetTeam())
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
         return;
     }
+
     if(player->GetArenaTeamId(arenateam->GetSlot()))
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S);
         return;
     }
+
     if(player->GetArenaTeamIdInvited())
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S);
         return;
     }
+
     if(arenateam->GetMembersSize() >= arenateam->GetType() * 2)
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,arenateam->GetName(),"",ERR_ARENA_TEAM_FULL);
         return;
     }
+
     sLog.outDebug("Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName(), Invitedname.c_str());
+
     player->SetArenaTeamIdInvited(arenateam->GetId());
+
     WorldPacket data(SMSG_ARENA_TEAM_INVITE, (8+10));
     data << GetPlayer()->GetName();
     data << arenateam->GetName();
     player->GetSession()->SendPacket(&data);
+
     sLog.outDebug("WORLD: Sent SMSG_ARENA_TEAM_INVITE");
 }
+
 void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/)
 {
     sLog.outDebug("CMSG_ARENA_TEAM_ACCEPT");                // empty opcode
+
     ArenaTeam *at = objmgr.GetArenaTeamById(_player->GetArenaTeamIdInvited());
     if(!at)
         return;
+
     if(_player->GetArenaTeamId(at->GetSlot()))
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,"","",ERR_ALREADY_IN_ARENA_TEAM);   // already in arena team that size
         return;
     }
+
     if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && _player->GetTeam() != objmgr.GetPlayerTeamByGUID(at->GetCaptain()))
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,"","",ERR_ARENA_TEAM_NOT_ALLIED);// not let enemies sign petition
         return;
     }
+
     if(!at->AddMember(_player->GetGUID()))
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,"","",ERR_ARENA_TEAM_INTERNAL);// arena team not found
         return;
     }
+
     // event
     WorldPacket data;
     BuildArenaTeamEventPacket(&data, ERR_ARENA_TEAM_JOIN_SS, 2, _player->GetName(), at->GetName(), "");
     at->BroadcastPacket(&data);
 }
+
 void WorldSession::HandleArenaTeamDeclineOpcode(WorldPacket & /*recv_data*/)
 {
     sLog.outDebug("CMSG_ARENA_TEAM_DECLINE");               // empty opcode
+
     _player->SetArenaTeamIdInvited(0);                      // no more invited
 }
+
 void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recv_data)
 {
     sLog.outDebug("CMSG_ARENA_TEAM_LEAVE");
+
     uint32 ArenaTeamId;                                     // arena team id
     recv_data >> ArenaTeamId;
+
     ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId);
     if(!at)
         return;
@@ -177,94 +219,124 @@ void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recv_data)
         delete at;
         return;
     }
+
     at->DelMember(_player->GetGUID());
+
     // event
     WorldPacket data;
     BuildArenaTeamEventPacket(&data, ERR_ARENA_TEAM_LEAVE_SS, 2, _player->GetName(), at->GetName(), "");
     at->BroadcastPacket(&data);
+
     //send you are no longer member of team
     SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, at->GetName(), "", 0);
 }
+
 void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket & recv_data)
 {
     sLog.outDebug("CMSG_ARENA_TEAM_DISBAND");
+
     uint32 ArenaTeamId;                                     // arena team id
     recv_data >> ArenaTeamId;
+
     ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId);
     if(!at)
         return;
+
     if(at->GetCaptain() != _player->GetGUID())
         return;
+
     if (at->IsFighting())
         return;
+
     at->Disband(this);
     delete at;
 }
+
 void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recv_data)
 {
     sLog.outDebug("CMSG_ARENA_TEAM_REMOVE");
+
     uint32 ArenaTeamId;
     std::string name;
+
     recv_data >> ArenaTeamId;
     recv_data >> name;
+
     ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId);
     if(!at)                                                 // arena team not found
         return;
+
     if(at->GetCaptain() != _player->GetGUID())
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PERMISSIONS);
         return;
     }
+
     if(!normalizePlayerName(name))
         return;
+
     ArenaTeamMember* member = at->GetMember(name);
     if(!member)                                             // member not found
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", name, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S);
         return;
     }
+
     if(at->GetCaptain() == member->guid)
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAM_LEADER_LEAVE_S);
         return;
     }
+
     at->DelMember(member->guid);
+
     // event
     WorldPacket data;
     BuildArenaTeamEventPacket(&data, ERR_ARENA_TEAM_REMOVE_SSS, 3, name, at->GetName(), _player->GetName());
     at->BroadcastPacket(&data);
 }
+
 void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket & recv_data)
 {
     sLog.outDebug("CMSG_ARENA_TEAM_LEADER");
+
     uint32 ArenaTeamId;
     std::string name;
+
     recv_data >> ArenaTeamId;
     recv_data >> name;
+
     ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId);
     if(!at)                                                 // arena team not found
         return;
+
     if(at->GetCaptain() != _player->GetGUID())
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PERMISSIONS);
         return;
     }
+
     if(!normalizePlayerName(name))
         return;
+
     ArenaTeamMember* member = at->GetMember(name);
     if(!member)                                             // member not found
     {
         SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", name, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S);
         return;
     }
+
     if(at->GetCaptain() == member->guid)                    // target player already captain
         return;
+
     at->SetCaptain(member->guid);
+
     // event
     WorldPacket data;
     BuildArenaTeamEventPacket(&data, ERR_ARENA_TEAM_LEADER_CHANGED_SSS, 3, _player->GetName(), name, at->GetName());
     at->BroadcastPacket(&data);
 }
+
 void WorldSession::SendArenaTeamCommandResult(uint32 team_action, const std::string& team, const std::string& player, uint32 error_id)
 {
     WorldPacket data(SMSG_ARENA_TEAM_COMMAND_RESULT, 4+team.length()+1+player.length()+1+4);
@@ -274,6 +346,7 @@ void WorldSession::SendArenaTeamCommandResult(uint32 team_action, const std::str
     data << error_id;
     SendPacket(&data);
 }
+
 void WorldSession::BuildArenaTeamEventPacket(WorldPacket *data, uint8 eventid, uint8 str_count, const std::string& str1, const std::string& str2, const std::string& str3)
 {
     data->Initialize(SMSG_ARENA_TEAM_EVENT, 1+1+1);
@@ -298,6 +371,7 @@ void WorldSession::BuildArenaTeamEventPacket(WorldPacket *data, uint8 eventid, u
             return;
     }
 }
+
 void WorldSession::SendNotInArenaTeamPacket(uint8 type)
 {
     WorldPacket data(SMSG_ARENA_ERROR, 4+1);                // 886 - You are not in a %uv%u arena team
@@ -307,12 +381,15 @@ void WorldSession::SendNotInArenaTeamPacket(uint8 type)
         data << uint8(type);                                // team type (2=2v2,3=3v3,5=5v5), can be used for custom types...
     SendPacket(&data);
 }
+
 /*
 +ERR_ARENA_NO_TEAM_II "You are not in a %dv%d arena team"
+
 +ERR_ARENA_TEAM_CREATE_S "%s created.  To disband, use /teamdisband [2v2, 3v3, 5v5]."
 +ERR_ARENA_TEAM_INVITE_SS "You have invited %s to join %s"
 +ERR_ARENA_TEAM_QUIT_S "You are no longer a member of %s"
 ERR_ARENA_TEAM_FOUNDER_S "Congratulations, you are a founding member of %s!  To leave, use /teamquit [2v2, 3v3, 5v5]."
+
 +ERR_ARENA_TEAM_INTERNAL "Internal arena team error"
 +ERR_ALREADY_IN_ARENA_TEAM "You are already in an arena team of that size"
 +ERR_ALREADY_IN_ARENA_TEAM_S "%s is already in an arena team of that size"
@@ -326,15 +403,23 @@ ERR_ARENA_TEAM_FOUNDER_S "Congratulations, you are a founding member of %s!  To
 +ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM_SS "%s is not in %s"
 +ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S "\"%s\" not found"
 +ERR_ARENA_TEAM_NOT_ALLIED "You cannot invite players from the opposing alliance"
+
 +ERR_ARENA_TEAM_JOIN_SS "%s has joined %s"
 +ERR_ARENA_TEAM_YOU_JOIN_S "You have joined %s.  To leave, use /teamquit [2v2, 3v3, 5v5]."
+
 +ERR_ARENA_TEAM_LEAVE_SS "%s has left %s"
+
 +ERR_ARENA_TEAM_LEADER_IS_SS "%s is the captain of %s"
 +ERR_ARENA_TEAM_LEADER_CHANGED_SSS "%s has made %s the new captain of %s"
+
 +ERR_ARENA_TEAM_REMOVE_SSS "%s has been kicked out of %s by %s"
+
 +ERR_ARENA_TEAM_DISBANDED_S "%s has disbanded %s"
+
 ERR_ARENA_TEAM_TARGET_TOO_LOW_S "%s is not high enough level to join your team"
+
 ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S "%s is full"
+
 ERR_ARENA_TEAM_LEVEL_TOO_LOW_I "You must be level %d to form an arena team"
 */
 
diff --git a/src/game/AuctionHouseBot.cpp b/src/game/AuctionHouseBot.cpp
index 4722aace318..cef09af8252 100644
--- a/src/game/AuctionHouseBot.cpp
+++ b/src/game/AuctionHouseBot.cpp
@@ -2,8 +2,10 @@
 #include "AuctionHouseMgr.h"
 #include "AuctionHouseBot.h"
 #include 
+
 #include "Policies/SingletonImp.h"
 INSTANTIATE_SINGLETON_1(AuctionHouseBot);
+
 using namespace std;
 vector npcItems;
 vector lootItems;
@@ -27,18 +29,22 @@ AuctionHouseBot::AuctionHouseBot()
     debug_Out_Filters = false;
     AHBSeller = false;
     AHBBuyer = false;
+
     //Begin Filters
+
     Vendor_Items = false;
     Loot_Items = false;
     Other_Items = false;
     Vendor_TGs = false;
     Loot_TGs = false;
     Other_TGs = false;
+
     No_Bind = false;
     Bind_When_Picked_Up = false;
     Bind_When_Equipped = false;
     Bind_When_Use = false;
     Bind_Quest_Item = false;
+
     DisableBeta_PTR_Unused = false;
     DisablePermEnchant = false;
 #if CLIENT_VER > 300
@@ -51,6 +57,7 @@ AuctionHouseBot::AuctionHouseBot()
     DisableKeys = false;
     DisableDuration = false;
     DisableBOP_Or_Quest_NoReqLevel = false;
+
     DisableWarriorItems = false;
     DisablePaladinItems = false;
     DisableHunterItems = false;
@@ -62,6 +69,7 @@ AuctionHouseBot::AuctionHouseBot()
     DisableWarlockItems = false;
     DisableUnusedClassItems = false;
     DisableDruidItems = false;
+
     DisableItemsBelowLevel = 0;
     DisableItemsAboveLevel = 0;
     DisableTGsBelowLevel = 0;
@@ -78,17 +86,22 @@ AuctionHouseBot::AuctionHouseBot()
     DisableItemsAboveReqSkillRank = 0;
     DisableTGsBelowReqSkillRank = 0;
     DisableTGsAboveReqSkillRank = 0;
+
     //End Filters
+
     _lastrun_a = time(NULL);
     _lastrun_h = time(NULL);
     _lastrun_n = time(NULL);
+
     AllianceConfig = AHBConfig(2);
     HordeConfig = AHBConfig(6);
     NeutralConfig = AHBConfig(7);
 }
+
 AuctionHouseBot::~AuctionHouseBot()
 {
 }
+
 void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
 {
     if (!AHBSeller)
@@ -96,13 +109,16 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
         if (debug_Out) sLog.outError("AHSeller: Disabled");
         return;
     }
+
     uint32 minItems = config->GetMinItems();
     uint32 maxItems = config->GetMaxItems();
+
     if (maxItems == 0)
     {
         //if (debug_Out) sLog.outString("AHSeller: Auctions disabled");
         return;
     }
+
     AuctionHouseEntry const* ahEntry = auctionmgr.GetAuctionHouseEntry(config->GetAHFID());
     if (!ahEntry)
     {
@@ -113,24 +129,31 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
     {
         return;
     }
+
     uint32 auctions = auctionHouse->Getcount();
+
     if (auctions >= minItems)
     {
         //if (debug_Out) sLog.outString("AHSeller: Auctions above minimum");
         return;
     }
+
     if (auctions >= maxItems)
     {
         //if (debug_Out) sLog.outString("AHSeller: Auctions at or above maximum");
         return;
     }
+
     uint32 items = 0;
     if ((maxItems - auctions) >= ItemsPerCycle)
         items = ItemsPerCycle;
     else
         items = (maxItems - auctions);
+
     if (debug_Out) sLog.outString("AHSeller: Adding %u Auctions", items);
+
     uint32 AuctioneerGUID = 0;
+
     switch (config->GetAHID())
     {
     case 2:
@@ -147,7 +170,9 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
         AuctioneerGUID = 23442; //default to neutral 7
         break;
     }
+
     if (debug_Out) sLog.outString("AHSeller: Current Auctineer GUID is %u", AuctioneerGUID);
+
     uint32 greyTGcount = config->GetPercents(AHB_GREY_TG);
     uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG);
     uint32 greenTGcount = config->GetPercents(AHB_GREEN_TG);
@@ -166,6 +191,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
         + purpleTGcount + orangeTGcount + yellowTGcount
         + whiteIcount + greenIcount + blueIcount + purpleIcount
         + orangeIcount + yellowIcount;
+
     uint32 greyTGoods = config->GetItemCounts(AHB_GREY_TG);
     uint32 whiteTGoods = config->GetItemCounts(AHB_WHITE_TG);
     uint32 greenTGoods = config->GetItemCounts(AHB_GREEN_TG);
@@ -173,6 +199,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
     uint32 purpleTGoods = config->GetItemCounts(AHB_PURPLE_TG);
     uint32 orangeTGoods = config->GetItemCounts(AHB_ORANGE_TG);
     uint32 yellowTGoods = config->GetItemCounts(AHB_YELLOW_TG);
+
     uint32 greyItems = config->GetItemCounts(AHB_GREY_I);
     uint32 whiteItems = config->GetItemCounts(AHB_WHITE_I);
     uint32 greenItems = config->GetItemCounts(AHB_GREEN_I);
@@ -181,6 +208,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
     uint32 orangeItems = config->GetItemCounts(AHB_ORANGE_I);
     uint32 yellowItems = config->GetItemCounts(AHB_YELLOW_I);
     if (debug_Out) sLog.outString("AHSeller: %u items", items);
+
     // only insert a few at a time, so as not to peg the processor
     for (uint32 cnt = 1;cnt <= items;cnt++)
     {
@@ -299,17 +327,20 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
                     break;
                 }
             }
+
             if (itemID == 0)
             {
                 if (debug_Out) sLog.outError("AHSeller: Item::CreateItem() - ItemID is 0");
                 continue;
             }
+
             ItemPrototype const* prototype = objmgr.GetItemPrototype(itemID);
             if (prototype == NULL)
             {
                 if (debug_Out) sLog.outError("AHSeller: Huh?!?! prototype == NULL");
                 continue;
             }
+
             Item* item = Item::CreateItem(itemID, 1, AHBplayer);
             if (item == NULL)
             {
@@ -317,12 +348,15 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
                 break;
             }
             item->AddToUpdateQueueOf(AHBplayer);
+
             uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID);
             if (randomPropertyId != 0)
                 item->SetItemRandomProperties(randomPropertyId);
+
             uint64 buyoutPrice = 0;
             uint64 bidPrice = 0;
             uint32 stackCount = 1;
+
             switch (SellMethod)
             {
             case 0:
@@ -332,6 +366,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
                 buyoutPrice  = prototype->BuyPrice;
                 break;
             }
+
             if ((prototype->Quality >= 0) && (prototype->Quality <= AHB_MAX_QUALITY))
             {
                 if (config->GetMaxStack(prototype->Quality) > 1 && item->GetMaxStackCount() > 1)
@@ -352,6 +387,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
                 item->RemoveFromUpdateQueueOf(AHBplayer);
                 continue;
             }
+
             uint32 etime = urand(1,3);
             switch(etime)
             {
@@ -369,7 +405,9 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
                 break;
             }
             item->SetCount(stackCount);
+
             uint32 dep = auctionmgr.GetAuctionDeposit(ahEntry, etime, item);
+
             AuctionEntry* auctionEntry = new AuctionEntry;
             auctionEntry->Id = objmgr.GenerateAuctionID();
             auctionEntry->auctioneer = AuctioneerGUID;
@@ -388,6 +426,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
             auctionmgr.AddAItem(item);
             auctionHouse->AddAuction(auctionEntry);
             auctionEntry->SaveToDB();
+
             switch(itemColor)
             {
             case 0:
@@ -445,26 +484,32 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
         if (debug_Out) sLog.outError("AHBuyer: Disabled");
         return;
     }
+    
     QueryResult* result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE itemowner<>%u AND buyguid<>%u", AHBplayerGUID, AHBplayerGUID);
+
     if (!result)
     {
         delete result;
         return;
     }
+
     if (result->GetRowCount() == 0)
     {
         delete result;
         return;
     }
+
     // Fetches content of selected AH
     AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID());
     vector possibleBids;
+
     do
     {
         uint32 tmpdata = result->Fetch()->GetUInt32();
         possibleBids.push_back(tmpdata);
     }while (result->NextRow());
     delete result;
+
     for (uint32 count = 1;count <= config->GetBidsPerInterval();++count)
     {
         // Do we have anything to bid? If not, stop here.
@@ -474,18 +519,23 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
             count = config->GetBidsPerInterval();
             continue;
         }
+
         // Choose random auction from possible auctions
         uint32 vectorPos = urand(0, possibleBids.size() - 1);
         vector::iterator iter = possibleBids.begin();
         advance(iter, vectorPos);
+
         // from auctionhousehandler.cpp, creates auction pointer & player pointer
         AuctionEntry* auction = auctionHouse->GetAuction(*iter);
+
         // Erase the auction from the vector to prevent bidding on item in next iteration.
         possibleBids.erase(iter);
+
         if (!auction)
         {
             continue;
         }
+
         // get exact item information
         Item *pItem = auctionmgr.GetAItem(auction->item_guidlow);
         if (!pItem)
@@ -493,17 +543,21 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
             if (debug_Out) sLog.outError("AHBuyer: Item %u doesn't exist, perhaps bought already?", auction->item_guidlow);
             continue;
         }
+
         // get item prototype
         ItemPrototype const* prototype = objmgr.GetItemPrototype(auction->item_template);
+
         // check which price we have to use, startbid or if it is bidded already
         uint32 currentprice;
         if (auction->bid)
             currentprice = auction->bid;
         else
             currentprice = auction->startbid;
+
         // Prepare portion from maximum bid
         double bidrate = static_cast(urand(1, 100)) / 100;
         long double bidMax = 0;
+
         // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
         switch (BuyMethod)
         {
@@ -538,6 +592,7 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
                 break;
             }
         }
+
         // check some special items, and do recalculating to their prices
         switch (prototype->Class)
         {
@@ -548,18 +603,22 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
         default:
             break;
         }
+
         if (bidMax == 0)
         {
             // quality check failed to get bidmax, let's get out of here
             continue;
         }
+
         // Calculate our bid
         long double bidvalue = currentprice + ((bidMax - currentprice) * bidrate);
         // Convert to uint32
         uint32 bidprice = static_cast(bidvalue);
+
         // Check our bid is high enough to be valid. If not, correct it to minimum.
         if ((currentprice + auction->GetAuctionOutBid()) > bidprice)
             bidprice = currentprice + auction->GetAuctionOutBid();
+
         if (debug_Out)
         {
             sLog.outString("-------------------------------------------------");
@@ -589,9 +648,11 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
             sLog.outString("AHBuyer: Ammo Type: %u", prototype->AmmoType);
             sLog.outString("-------------------------------------------------");
         }
+
         // Check whether we do normal bid, or buyout
         if ((bidprice < auction->buyout) || (auction->buyout == 0))
         {
+
             if (auction->bidder > 0)
             {
                 if (auction->bidder == AHBplayer->GetGUIDLow())
@@ -605,8 +666,10 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
                     //pl->ModifyMoney(-int32(price));
                 }
            }
+
             auction->bidder = AHBplayer->GetGUIDLow();
             auction->bid = bidprice;
+
             // Saving auction into database
             CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
         }
@@ -619,6 +682,7 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
             }
             auction->bidder = AHBplayer->GetGUIDLow();
             auction->bid = auction->buyout;
+
             // Send mails to buyer & seller
             auctionmgr.SendAuctionSalePendingMail(auction);
             auctionmgr.SendAuctionSuccessfulMail(auction);
@@ -630,15 +694,18 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
         }
     }
 }
+
 void AuctionHouseBot::Update()
 {
     time_t _newrun = time(NULL);
     if ((!AHBSeller) && (!AHBBuyer))
         return;
+
     WorldSession _session(AHBplayerAccount, NULL, SEC_PLAYER, true, 0, LOCALE_enUS);
     Player _AHBplayer(&_session);
     _AHBplayer.MinimalLoadFromDB(NULL, AHBplayerGUID);
     ObjectAccessor::Instance().AddObject(&_AHBplayer);
+
     // Only for testing, this can likely be removed, once I know it's working as expected.
     /*
     AuctionHouseObject* auctionHouse1 = auctionmgr.GetAuctionsMap(55);
@@ -652,6 +719,7 @@ void AuctionHouseBot::Update()
         return;
     }
     */
+
     // Add New Bids
     if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
     {
@@ -663,6 +731,7 @@ void AuctionHouseBot::Update()
             addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig, &_session);
             _lastrun_a = _newrun;
         }
+
         addNewAuctions(&_AHBplayer, &HordeConfig);
         if (((_newrun - _lastrun_h) >= (HordeConfig.GetBiddingInterval() * MINUTE)) && (HordeConfig.GetBidsPerInterval() > 0))
         {
@@ -672,6 +741,7 @@ void AuctionHouseBot::Update()
             _lastrun_h = _newrun;
         }
     }
+
     addNewAuctions(&_AHBplayer, &NeutralConfig);
     if (((_newrun - _lastrun_n) >= (NeutralConfig.GetBiddingInterval() * MINUTE)) && (NeutralConfig.GetBidsPerInterval() > 0))
     {
@@ -682,30 +752,37 @@ void AuctionHouseBot::Update()
     }
     ObjectAccessor::Instance().RemoveObject(&_AHBplayer);
 }
+
 void AuctionHouseBot::Initialize()
 {
     debug_Out = sConfig.GetBoolDefault("AuctionHouseBot.DEBUG", false);
     debug_Out_Filters = sConfig.GetBoolDefault("AuctionHouseBot.DEBUG_FILTERS", false);
+
     AHBSeller = sConfig.GetBoolDefault("AuctionHouseBot.EnableSeller", false);
     AHBBuyer = sConfig.GetBoolDefault("AuctionHouseBot.EnableBuyer", false);
     SellMethod = sConfig.GetBoolDefault("AuctionHouseBot.UseBuyPriceForSeller", false);
     BuyMethod = sConfig.GetBoolDefault("AuctionHouseBot.UseBuyPriceForBuyer", false);
+
     AHBplayerAccount = sConfig.GetIntDefault("AuctionHouseBot.Account", 0);
     AHBplayerGUID = sConfig.GetIntDefault("AuctionHouseBot.GUID", 0);
     ItemsPerCycle = sConfig.GetIntDefault("AuctionHouseBot.ItemsPerCycle", 200);
 
+
     //Begin Filters
+
     Vendor_Items = sConfig.GetBoolDefault("AuctionHouseBot.VendorItems", false);
     Loot_Items = sConfig.GetBoolDefault("AuctionHouseBot.LootItems", true);
     Other_Items = sConfig.GetBoolDefault("AuctionHouseBot.OtherItems", false);
     Vendor_TGs = sConfig.GetBoolDefault("AuctionHouseBot.VendorTradeGoods", false);
     Loot_TGs = sConfig.GetBoolDefault("AuctionHouseBot.LootTradeGoods", true);
     Other_TGs = sConfig.GetBoolDefault("AuctionHouseBot.OtherTradeGoods", false);
+
     No_Bind = sConfig.GetBoolDefault("AuctionHouseBot.No_Bind", true);
     Bind_When_Picked_Up = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Picked_Up", false);
     Bind_When_Equipped = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Equipped", true);
     Bind_When_Use = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Use", true);
     Bind_Quest_Item = sConfig.GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", false);
+
     DisableBeta_PTR_Unused = sConfig.GetBoolDefault("AuctionHouseBot.DisableBeta_PTR_Unused", false);
     DisablePermEnchant = sConfig.GetBoolDefault("AuctionHouseBot.DisablePermEnchant", false);
 #if CLIENT_VER > 300
@@ -718,6 +795,7 @@ void AuctionHouseBot::Initialize()
     DisableKeys = sConfig.GetBoolDefault("AuctionHouseBot.DisableKeys", false);
     DisableDuration = sConfig.GetBoolDefault("AuctionHouseBot.DisableDuration", false);
     DisableBOP_Or_Quest_NoReqLevel = sConfig.GetBoolDefault("AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel", false);
+
     DisableWarriorItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableWarriorItems", false);
     DisablePaladinItems = sConfig.GetBoolDefault("AuctionHouseBot.DisablePaladinItems", false);
     DisableHunterItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableHunterItems", false);
@@ -729,6 +807,7 @@ void AuctionHouseBot::Initialize()
     DisableWarlockItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableWarlockItems", false);
     DisableUnusedClassItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableUnusedClassItems", false);
     DisableDruidItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableDruidItems", false);
+
     DisableItemsBelowLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsBelowLevel", 0);
     DisableItemsAboveLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsAboveLevel", 0);
     DisableTGsBelowLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsBelowLevel", 0);
@@ -745,6 +824,7 @@ void AuctionHouseBot::Initialize()
     DisableItemsAboveReqSkillRank = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsAboveReqSkillRank", 0);
     DisableTGsBelowReqSkillRank = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsBelowReqSkillRank", 0);
     DisableTGsAboveReqSkillRank = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsAboveReqSkillRank", 0);
+
     //End Filters
     if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
     {
@@ -752,6 +832,7 @@ void AuctionHouseBot::Initialize()
         LoadValues(&HordeConfig);
     }
     LoadValues(&NeutralConfig);
+
     if (AHBSeller)
     {
         QueryResult* results = (QueryResult*) NULL;
@@ -763,13 +844,16 @@ void AuctionHouseBot::Initialize()
             {
                 Field* fields = results->Fetch();
                 npcItems.push_back(fields[0].GetUInt32());
+
             } while (results->NextRow());
+
             delete results;
         }
         else
         {
             if (debug_Out) sLog.outString("AuctionHouseBot: \"%s\" failed", npcQuery);
         }
+
         char lootQuery[] = "SELECT item FROM creature_loot_template UNION "
             "SELECT item FROM disenchant_loot_template UNION "
             "SELECT item FROM fishing_loot_template UNION "
@@ -781,6 +865,7 @@ void AuctionHouseBot::Initialize()
             "SELECT item FROM pickpocketing_loot_template UNION "
             "SELECT item FROM prospecting_loot_template UNION "
             "SELECT item FROM skinning_loot_template";
+
         results = WorldDatabase.PQuery(lootQuery);
         if (results != NULL)
         {
@@ -788,18 +873,23 @@ void AuctionHouseBot::Initialize()
             {
                 Field* fields = results->Fetch();
                 lootItems.push_back(fields[0].GetUInt32());
+
             } while (results->NextRow());
+
             delete results;
         }
         else
         {
             if (debug_Out) sLog.outString("AuctionHouseBot: \"%s\" failed", lootQuery);
         }
+
         for (uint32 itemID = 0; itemID < sItemStorage.MaxEntry; itemID++)
         {
             ItemPrototype const* prototype = objmgr.GetItemPrototype(itemID);
+
             if (prototype == NULL)
                 continue;
+
             switch (prototype->Bonding)
             {
             case NO_BIND:
@@ -826,6 +916,7 @@ void AuctionHouseBot::Initialize()
                 continue;
                 break;
             }
+
             switch (SellMethod)
             {
             case 0:
@@ -837,56 +928,71 @@ void AuctionHouseBot::Initialize()
                     continue;
                 break;
             }
+
             if ((prototype->Quality < 0) || (prototype->Quality > 6))
                 continue;
+
             if ((Vendor_Items == 0) && !(prototype->Class == ITEM_CLASS_TRADE_GOODS))
             {
                 bool isVendorItem = false;
+
                 for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
                 {
                     if (itemID == npcItems[i])
                         isVendorItem = true;
                 }
+
                 if (isVendorItem)
                     continue;
             }
+
             if ((Vendor_TGs == 0) && (prototype->Class == ITEM_CLASS_TRADE_GOODS))
             {
                 bool isVendorTG = false;
+
                 for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorTG); i++)
                 {
                     if (itemID == npcItems[i])
                         isVendorTG = true;
                 }
+
                 if (isVendorTG)
                     continue;
             }
+
             if ((Loot_Items == 0) && !(prototype->Class == ITEM_CLASS_TRADE_GOODS))
             {
                 bool isLootItem = false;
+
                 for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
                 {
                     if (itemID == lootItems[i])
                         isLootItem = true;
                 }
+
                 if (isLootItem)
                     continue;
             }
+
             if ((Loot_TGs == 0) && (prototype->Class == ITEM_CLASS_TRADE_GOODS))
             {
                 bool isLootTG = false;
+
                 for (unsigned int i = 0; (i < lootItems.size()) && (!isLootTG); i++)
                 {
                     if (itemID == lootItems[i])
                         isLootTG = true;
                 }
+
                 if (isLootTG)
                     continue;
             }
+
             if ((Other_Items == 0) && !(prototype->Class == ITEM_CLASS_TRADE_GOODS))
             {
                 bool isVendorItem = false;
                 bool isLootItem = false;
+
                 for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
                 {
                     if (itemID == npcItems[i])
@@ -900,10 +1006,12 @@ void AuctionHouseBot::Initialize()
                 if ((!isLootItem) && (!isVendorItem))
                     continue;
             }
+
             if ((Other_TGs == 0) && (prototype->Class == ITEM_CLASS_TRADE_GOODS))
             {
                 bool isVendorTG = false;
                 bool isLootTG = false;
+
                 for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorTG); i++)
                 {
                     if (itemID == npcItems[i])
@@ -917,6 +1025,7 @@ void AuctionHouseBot::Initialize()
                 if ((!isLootTG) && (!isVendorTG))
                     continue;
             }
+
              //TODO:Make list of items and create a vector
             // Disable PTR/Beta/Unused items
             if ((DisableBeta_PTR_Unused) && ((prototype->ItemId == 21878) || (prototype->ItemId == 27774) || (prototype->ItemId == 27811) || (prototype->ItemId == 28117) || (prototype->ItemId == 28112)))
@@ -924,12 +1033,14 @@ void AuctionHouseBot::Initialize()
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (PTR/Beta/Unused Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable permanent enchants items
             if ((DisablePermEnchant) && (prototype->Class == ITEM_CLASS_PERMANENT))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Permanent Enchant Item)", prototype->ItemId);
                 continue;
             }
+
 #if CLIENT_VER > 300
             // Disable conjured items
             if ((DisableConjured) && (prototype->IsConjuredConsumable()))
@@ -938,210 +1049,245 @@ void AuctionHouseBot::Initialize()
                 continue;
             }
 #endif
+
             // Disable gems
             if ((DisableGems) && (prototype->Class == ITEM_CLASS_GEM))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Gem)", prototype->ItemId);
                 continue;
             }
+
             // Disable money
             if ((DisableMoney) && (prototype->Class == ITEM_CLASS_MONEY))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Money)", prototype->ItemId);
                 continue;
             }
+
             // Disable moneyloot
             if ((DisableMoneyLoot) && (prototype->MinMoneyLoot > 0))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (MoneyLoot)", prototype->ItemId);
                 continue;
             }
+
             // Disable lootable items
             if ((DisableLootable) && (prototype->Flags & 4))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Lootable Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable Keys
             if ((DisableKeys) && (prototype->Class == ITEM_CLASS_KEY))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Quest Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items with duration
             if ((DisableDuration) && (prototype->Duration > 0))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Has a Duration)", prototype->ItemId);
                 continue;
             }
+
             // Disable items which are BOP or Quest Items and have a required level lower than the item level
             if ((DisableBOP_Or_Quest_NoReqLevel) && ((prototype->Bonding == BIND_WHEN_PICKED_UP || prototype->Bonding == BIND_QUEST_ITEM) && (prototype->RequiredLevel < prototype->ItemLevel)))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (BOP or BQI and Required Level is less than Item Level)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Warrior
             if ((DisableWarriorItems) && (prototype->AllowableClass == 1))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Warrior Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Paladin
             if ((DisablePaladinItems) && (prototype->AllowableClass == 2))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Paladin Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Hunter
             if ((DisableHunterItems) && (prototype->AllowableClass == 4))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Hunter Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Rogue
             if ((DisableRogueItems) && (prototype->AllowableClass == 8))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Rogue Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Priest
             if ((DisablePriestItems) && (prototype->AllowableClass == 16))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Priest Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for DK
             if ((DisableDKItems) && (prototype->AllowableClass == 32))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (DK Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Shaman
             if ((DisableShamanItems) && (prototype->AllowableClass == 64))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Shaman Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Mage
             if ((DisableMageItems) && (prototype->AllowableClass == 128))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Mage Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Warlock
             if ((DisableWarlockItems) && (prototype->AllowableClass == 256))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Warlock Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Unused Class
             if ((DisableUnusedClassItems) && (prototype->AllowableClass == 512))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Unused Item)", prototype->ItemId);
                 continue;
             }
+
             // Disable items specifically for Druid
             if ((DisableDruidItems) && (prototype->AllowableClass == 1024))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Druid Item)", prototype->ItemId);
                 continue;
             }
+
              // Disable Items below level X
             if ((DisableItemsBelowLevel) && (prototype->Class != ITEM_CLASS_TRADE_GOODS) && (prototype->ItemLevel < DisableItemsBelowLevel))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Item Level = %u)", prototype->ItemId, prototype->ItemLevel);
                 continue;
             }
+
             // Disable Items above level X
             if ((DisableItemsAboveLevel) && (prototype->Class != ITEM_CLASS_TRADE_GOODS) && (prototype->ItemLevel > DisableItemsAboveLevel))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Item Level = %u)", prototype->ItemId, prototype->ItemLevel);
                 continue;
             }
+
            // Disable Trade Goods below level X
             if ((DisableTGsBelowLevel) && (prototype->Class == ITEM_CLASS_TRADE_GOODS) && (prototype->ItemLevel < DisableTGsBelowLevel))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Trade Good %u disabled (Trade Good Level = %u)", prototype->ItemId, prototype->ItemLevel);
                 continue;
             }
+
            // Disable Trade Goods above level X
             if ((DisableTGsAboveLevel) && (prototype->Class == ITEM_CLASS_TRADE_GOODS) && (prototype->ItemLevel > DisableTGsAboveLevel))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Trade Good %u disabled (Trade Good Level = %u)", prototype->ItemId, prototype->ItemLevel);
                 continue;
             }
+
             // Disable Items below GUID X
             if ((DisableItemsBelowGUID) && (prototype->Class != ITEM_CLASS_TRADE_GOODS) && (prototype->ItemId < DisableItemsBelowGUID))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Item Level = %u)", prototype->ItemId, prototype->ItemLevel);
                 continue;
             }
+
             // Disable Items above GUID X
             if ((DisableItemsAboveGUID) && (prototype->Class != ITEM_CLASS_TRADE_GOODS) && (prototype->ItemId > DisableItemsAboveGUID))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Item Level = %u)", prototype->ItemId, prototype->ItemLevel);
                 continue;
             }
+
             // Disable Trade Goods below GUID X
             if ((DisableTGsBelowGUID) && (prototype->Class == ITEM_CLASS_TRADE_GOODS) && (prototype->ItemId < DisableTGsBelowGUID))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Trade Good Level = %u)", prototype->ItemId, prototype->ItemLevel);
                 continue;
             }
+
             // Disable Trade Goods above GUID X
             if ((DisableTGsAboveGUID) && (prototype->Class == ITEM_CLASS_TRADE_GOODS) && (prototype->ItemId > DisableTGsAboveGUID))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Trade Good Level = %u)", prototype->ItemId, prototype->ItemLevel);
                 continue;
             }
+
             // Disable Items for level lower than X
             if ((DisableItemsBelowReqLevel) && (prototype->RequiredLevel < DisableItemsBelowReqLevel))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredLevel = %u)", prototype->ItemId, prototype->RequiredLevel);
                 continue;
             }
+
             // Disable Items for level higher than X
             if ((DisableItemsAboveReqLevel) && (prototype->RequiredLevel > DisableItemsAboveReqLevel))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredLevel = %u)", prototype->ItemId, prototype->RequiredLevel);
                 continue;
             }
+
             // Disable Trade Goods for level lower than X
             if ((DisableTGsBelowReqLevel) && (prototype->RequiredLevel < DisableTGsBelowReqLevel))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Trade Good %u disabled (RequiredLevel = %u)", prototype->ItemId, prototype->RequiredLevel);
                 continue;
             }
+
             // Disable Trade Goods for level higher than X
             if ((DisableTGsAboveReqLevel) && (prototype->RequiredLevel > DisableTGsAboveReqLevel))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Trade Good %u disabled (RequiredLevel = %u)", prototype->ItemId, prototype->RequiredLevel);
                 continue;
             }
+
             // Disable Items that require skill lower than X
             if ((DisableItemsBelowReqSkillRank) && (prototype->RequiredSkillRank < DisableItemsBelowReqSkillRank))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", prototype->ItemId, prototype->RequiredSkillRank);
                 continue;
             }
+
             // Disable Items that require skill higher than X
             if ((DisableItemsAboveReqSkillRank) && (prototype->RequiredSkillRank > DisableItemsAboveReqSkillRank))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", prototype->ItemId, prototype->RequiredSkillRank);
                 continue;
             }
+
             // Disable Trade Goods that require skill lower than X
             if ((DisableTGsBelowReqSkillRank) && (prototype->RequiredSkillRank < DisableTGsBelowReqSkillRank))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", prototype->ItemId, prototype->RequiredSkillRank);
                 continue;
             }
+
             // Disable Trade Goods that require skill higher than X
             if ((DisableTGsAboveReqSkillRank) && (prototype->RequiredSkillRank > DisableTGsAboveReqSkillRank))
             {
                 if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", prototype->ItemId, prototype->RequiredSkillRank);
                 continue;
             }
+
             switch (prototype->Quality)
             {
             case AHB_GREY:
@@ -1150,36 +1296,42 @@ void AuctionHouseBot::Initialize()
                 else
                     greyItemsBin.push_back(itemID);
                 break;
+
             case AHB_WHITE:
                 if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
                     whiteTradeGoodsBin.push_back(itemID);
                 else
                     whiteItemsBin.push_back(itemID);
                 break;
+
             case AHB_GREEN:
                 if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
                     greenTradeGoodsBin.push_back(itemID);
                 else
                     greenItemsBin.push_back(itemID);
                 break;
+
             case AHB_BLUE:
                 if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
                     blueTradeGoodsBin.push_back(itemID);
                 else
                     blueItemsBin.push_back(itemID);
                 break;
+
             case AHB_PURPLE:
                 if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
                     purpleTradeGoodsBin.push_back(itemID);
                 else
                     purpleItemsBin.push_back(itemID);
                 break;
+
             case AHB_ORANGE:
                 if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
                     orangeTradeGoodsBin.push_back(itemID);
                 else
                     orangeItemsBin.push_back(itemID);
                 break;
+
             case AHB_YELLOW:
                 if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
                     yellowTradeGoodsBin.push_back(itemID);
@@ -1188,6 +1340,7 @@ void AuctionHouseBot::Initialize()
                 break;
             }
         }
+
         if ((greyTradeGoodsBin.size() == 0) &&
             (whiteTradeGoodsBin.size() == 0) &&
             (greenTradeGoodsBin.size() == 0) &&
@@ -1206,6 +1359,7 @@ void AuctionHouseBot::Initialize()
             sLog.outError("AuctionHouseBot: No items");
             AHBSeller = 0;
         }
+
         sLog.outString("AuctionHouseBot:");
         sLog.outString("loaded %u grey trade goods", greyTradeGoodsBin.size());
         sLog.outString("loaded %u white trade goods", whiteTradeGoodsBin.size());
@@ -1225,9 +1379,11 @@ void AuctionHouseBot::Initialize()
     sLog.outString("AuctionHouseBot by Paradox (original by ChrisK) has been loaded.");
     sLog.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox");
 }
+
 void AuctionHouseBot::IncrementItemCounts(AuctionEntry* ah)
 {
     // from auctionhousehandler.cpp, creates auction pointer & player pointer
+
     // get exact item information
     Item *pItem = auctionmgr.GetAItem(ah->item_guidlow);
     if (!pItem)
@@ -1235,9 +1391,12 @@ void AuctionHouseBot::IncrementItemCounts(AuctionEntry* ah)
         if (debug_Out) sLog.outError("AHBot: Item %u doesn't exist, perhaps bought already?", ah->item_guidlow);
         return;
     }
+
     // get item prototype
     ItemPrototype const* prototype = objmgr.GetItemPrototype(ah->item_template);
+
     AHBConfig *config;
+
     FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseFaction());
     if (!u_entry)
     {
@@ -1259,13 +1418,17 @@ void AuctionHouseBot::IncrementItemCounts(AuctionEntry* ah)
         if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
         config = &NeutralConfig;
     }
+
     config->IncItemCounts(prototype->Class, prototype->Quality);
 }
+
 void AuctionHouseBot::DecrementItemCounts(AuctionEntry* ah, uint32 item_template)
 {
     // get item prototype
     ItemPrototype const* prototype = objmgr.GetItemPrototype(item_template);
+
     AHBConfig *config;
+
     FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseFaction());
     if (!u_entry)
     {
@@ -1287,8 +1450,10 @@ void AuctionHouseBot::DecrementItemCounts(AuctionEntry* ah, uint32 item_template
         if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
         config = &NeutralConfig;
     }
+
     config->DecItemCounts(prototype->Class, prototype->Quality);
 }
+
 void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args)
 {
     AHBConfig *config;
@@ -1336,12 +1501,15 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
     case 0:     //ahexpire
         {
             AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID());
+
             AuctionHouseObject::AuctionEntryMap::iterator itr;
             itr = auctionHouse->GetAuctionsBegin();
+
             while (itr != auctionHouse->GetAuctionsEnd())
             {
                 if (itr->second->owner == AHBplayerGUID)
                     itr->second->expire_time = sWorld.GetGameTime();
+
                 ++itr;
             }
         }
@@ -1396,6 +1564,7 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
             uint32 purplei = (uint32) strtoul(param12, NULL, 0);
             uint32 orangei = (uint32) strtoul(param13, NULL, 0);
             uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
+
             CharacterDatabase.BeginTransaction();
             CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg, ahMapID);
             CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg, ahMapID);
@@ -1483,6 +1652,7 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
         break;
     }
 }
+
 void AuctionHouseBot::LoadValues(AHBConfig *config)
 {
     if (debug_Out) sLog.outString("Start Settings for %s Auctionhouses:", CharacterDatabase.PQuery("SELECT name FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetString());
@@ -1601,8 +1771,10 @@ void AuctionHouseBot::LoadValues(AHBConfig *config)
         }
         AuctionHouseEntry const* ahEntry = auctionmgr.GetAuctionHouseEntry(config->GetAHFID());
         AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID());
+
         config->ResetItemCounts();
         uint32 auctions = auctionHouse->Getcount();
+        
         if (auctions)
         {
             for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr)
diff --git a/src/game/AuctionHouseBot.h b/src/game/AuctionHouseBot.h
index 9e04dde87cf..d135af5c479 100644
--- a/src/game/AuctionHouseBot.h
+++ b/src/game/AuctionHouseBot.h
@@ -1,8 +1,10 @@
 #ifndef AUCTION_HOUSE_BOT_H
 #define AUCTION_HOUSE_BOT_H
+
 #include "World.h"
 #include "Config/ConfigEnv.h"
 #include "ItemPrototype.h"
+
 #define AHB_GREY        0
 #define AHB_WHITE       1
 #define AHB_GREEN       2
@@ -25,6 +27,7 @@
 #define AHB_PURPLE_I    11
 #define AHB_ORANGE_I    12
 #define AHB_YELLOW_I    13
+
 class AHBConfig
 {
 private:
@@ -81,6 +84,7 @@ private:
     uint32 minBidPriceYellow;
     uint32 maxBidPriceYellow;
     uint32 maxStackYellow;
+
     uint32 buyerPriceGrey;
     uint32 buyerPriceWhite;
     uint32 buyerPriceGreen;
@@ -90,6 +94,7 @@ private:
     uint32 buyerPriceYellow;
     uint32 buyerBiddingInterval;
     uint32 buyerBidsPerInterval;
+
     uint32 greytgp;
     uint32 whitetgp;
     uint32 greentgp;
@@ -104,6 +109,7 @@ private:
     uint32 purpleip;
     uint32 orangeip;
     uint32 yellowip;
+
     uint32 greyTGoods;
     uint32 whiteTGoods;
     uint32 greenTGoods;
@@ -111,6 +117,7 @@ private:
     uint32 purpleTGoods;
     uint32 orangeTGoods;
     uint32 yellowTGoods;
+
     uint32 greyItems;
     uint32 whiteItems;
     uint32 greenItems;
@@ -118,6 +125,7 @@ private:
     uint32 purpleItems;
     uint32 orangeItems;
     uint32 yellowItems;
+
 public:
     AHBConfig(uint32 ahid)
     {
@@ -174,6 +182,7 @@ public:
     void SetPercentages(uint32 greytg, uint32 whitetg, uint32 greentg, uint32 bluetg, uint32 purpletg, uint32 orangetg, uint32 yellowtg, uint32 greyi, uint32 whitei, uint32 greeni, uint32 bluei, uint32 purplei, uint32 orangei, uint32 yellowi)
     {
         uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi;
+
         if (totalPercent == 0)
         {
             maxItems = 0;
@@ -883,6 +892,7 @@ public:
             break;
         }
     }
+
     void DecItemCounts(uint32 Class, uint32 Quality)
     {
         switch(Class)
@@ -895,6 +905,7 @@ public:
             break;
         }
     }
+
     void DecItemCounts(uint32 color)
     {
         switch(color)
@@ -945,6 +956,7 @@ public:
             break;
         }
     }
+ 
     void IncItemCounts(uint32 Class, uint32 Quality)
     {
         switch(Class)
@@ -957,6 +969,7 @@ public:
             break;
         }
     }
+
     void IncItemCounts(uint32 color)
     {
         switch(color)
@@ -1007,6 +1020,7 @@ public:
             break;
         }
     }
+
     void ResetItemCounts()
     {
         greyTGoods = 0;
@@ -1016,6 +1030,7 @@ public:
         purpleTGoods = 0;
         orangeTGoods = 0;
         yellowTGoods = 0;
+
         greyItems = 0;
         whiteItems = 0;
         greenItems = 0;
@@ -1024,6 +1039,7 @@ public:
         orangeItems = 0;
         yellowItems = 0;
     }
+
     uint32 TotalItemCounts()
     {
         return(
@@ -1034,6 +1050,7 @@ public:
         purpleTGoods +
         orangeTGoods +
         yellowTGoods +
+
         greyItems +
         whiteItems +
         greenItems +
@@ -1042,6 +1059,7 @@ public:
         orangeItems +
         yellowItems);
     }
+
     uint32 GetItemCounts(uint32 color)
     {
         switch(color)
@@ -1108,27 +1126,34 @@ public:
 class AuctionHouseBot
 {
 private:
+
     bool debug_Out;
     bool debug_Out_Filters;
+
     bool AHBSeller;
     bool AHBBuyer;
     bool BuyMethod;
     bool SellMethod;
+
     uint32 AHBplayerAccount;
     uint32 AHBplayerGUID;
     uint32 ItemsPerCycle;
+
     //Begin Filters
+
     bool Vendor_Items;
     bool Loot_Items;
     bool Other_Items;
     bool Vendor_TGs;
     bool Loot_TGs;
     bool Other_TGs;
+
     bool No_Bind;
     bool Bind_When_Picked_Up;
     bool Bind_When_Equipped;
     bool Bind_When_Use;
     bool Bind_Quest_Item;
+
     bool DisableBeta_PTR_Unused;
     bool DisablePermEnchant;
 #if CLIENT_VER > 300
@@ -1141,6 +1166,7 @@ private:
     bool DisableKeys;
     bool DisableDuration;
     bool DisableBOP_Or_Quest_NoReqLevel;
+
     bool DisableWarriorItems;
     bool DisablePaladinItems;
     bool DisableHunterItems;
@@ -1152,6 +1178,7 @@ private:
     bool DisableWarlockItems;
     bool DisableUnusedClassItems;
     bool DisableDruidItems;
+
     uint32 DisableItemsBelowLevel;
     uint32 DisableItemsAboveLevel;
     uint32 DisableTGsBelowLevel;
@@ -1168,16 +1195,21 @@ private:
     uint32 DisableItemsAboveReqSkillRank;
     uint32 DisableTGsBelowReqSkillRank;
     uint32 DisableTGsAboveReqSkillRank;
+
     //End Filters
+
     AHBConfig AllianceConfig;
     AHBConfig HordeConfig;
     AHBConfig NeutralConfig;
+
     time_t _lastrun_a;
     time_t _lastrun_h;
     time_t _lastrun_n;
+
     inline uint32 minValue(uint32 a, uint32 b) { return a <= b ? a : b; };
     void addNewAuctions(Player *AHBplayer, AHBConfig *config);
     void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session);
+
 public:
     AuctionHouseBot();
     ~AuctionHouseBot();
@@ -1189,5 +1221,7 @@ public:
     void Commands(uint32, uint32, uint32, char*);
     uint32 GetAHBplayerGUID() { return AHBplayerGUID; };
 };
+
 #define auctionbot Trinity::Singleton::Instance()
+
 #endif
diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp
index 13df6c3a6a4..52790526dd7 100644
--- a/src/game/AuctionHouseHandler.cpp
+++ b/src/game/AuctionHouseHandler.cpp
@@ -17,11 +17,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "ObjectMgr.h"
 #include "Player.h"
 #include "World.h"
 #include "WorldPacket.h"
 #include "WorldSession.h"
+
 #include "AuctionHouseBot.h"
 #include "AuctionHouseMgr.h"
 #include "Log.h"
@@ -29,35 +31,43 @@
 #include "UpdateMask.h"
 #include "Util.h"
 
+
 //please DO NOT use iterator++, because it is slower than ++iterator!!!
 //post-incrementation is always slower than pre-incrementation !
+
 //void called when player click on auctioneer npc
 void WorldSession::HandleAuctionHelloOpcode(WorldPacket & recv_data)
 {
     uint64 guid;                                            //NPC guid
     recv_data >> guid;
+
     Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER);
     if (!unit)
     {
         sLog.outDebug("WORLD: HandleAuctionHelloOpcode - 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()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
     SendAuctionHello(guid, unit);
 }
+
 //this void causes that auction window is opened
 void WorldSession::SendAuctionHello(uint64 guid, Creature* unit)
 {
     AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction());
     if (!ahEntry)
         return;
+
     WorldPacket data(MSG_AUCTION_HELLO, 12);
     data << (uint64) guid;
     data << (uint32) ahEntry->houseId;
     SendPacket(&data);
 }
+
 //call this method when player bids, creates, or deletes auction
 void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError)
 {
@@ -69,6 +79,7 @@ void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uin
         data << bidError;                                   //when bid, then send 0, once...
     SendPacket(&data);
 }
+
 //this function sends notification, if bidder is online
 void WorldSession::SendAuctionBidderNotification(uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template)
 {
@@ -82,6 +93,7 @@ void WorldSession::SendAuctionBidderNotification(uint32 location, uint32 auction
     data << uint32(0);
     SendPacket(&data);
 }
+
 //this void causes on client to display: "Your auction sold"
 void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction)
 {
@@ -95,42 +107,53 @@ void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction)
     data << (uint32) 0;                                     //unk
     SendPacket(&data);
 }
+
 //this function sends mail to old bidder
 void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPrice)
 {
     uint64 oldBidder_guid = MAKE_NEW_GUID(auction->bidder,0, HIGHGUID_PLAYER);
     Player *oldBidder = objmgr.GetPlayer(oldBidder_guid);
+
     uint32 oldBidder_accId = 0;
     if (!oldBidder)
         oldBidder_accId = objmgr.GetPlayerAccountIdByGUID(oldBidder_guid);
+
     // old bidder exist
     if (oldBidder || oldBidder_accId)
     {
         std::ostringstream msgAuctionOutbiddedSubject;
         msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED;
+
         if (oldBidder && !_player)
             oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, auctionbot.GetAHBplayerGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
+
         if (oldBidder && _player)
             oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, _player->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
+
         WorldSession::SendMailTo(oldBidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
     }
 }
+
 //this function sends mail, when auction is cancelled to old bidder
 void WorldSession::SendAuctionCancelledToBidderMail(AuctionEntry* auction)
 {
     uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
     Player *bidder = objmgr.GetPlayer(bidder_guid);
+
     uint32 bidder_accId = 0;
     if (!bidder)
         bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid);
+
     // bidder exist
     if (bidder || bidder_accId)
     {
         std::ostringstream msgAuctionCancelledSubject;
         msgAuctionCancelledSubject << auction->item_template << ":0:" << AUCTION_CANCELLED_TO_BIDDER;
+
         WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionCancelledSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
     }
 }
+
 //this void creates new auction and adds auction to some auctionhouse
 void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
 {
@@ -139,24 +162,31 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
     recv_data >> auctioneer >> item;
     recv_data >> bid >> buyout >> etime;
     Player *pl = GetPlayer();
+
     if (!item || !bid || !etime)
         return;                                             //check for cheaters
+
     Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
     if (!pCreature)
     {
         sLog.outDebug("WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));
         return;
     }
+
     AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction());
     if (!auctionHouseEntry)
     {
         sLog.outDebug("WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)));
         return;
     }
+
     sLog.outDebug("WORLD: HandleAuctionSellItem - ETIME: %u", etime);
+
     // client send time in minutes, convert to common used sec time
     etime *= MINUTE;
+
     sLog.outDebug("WORLD: HandleAuctionSellItem - ETIME: %u", etime);
+
     // client understand only 3 auction time
     switch(etime)
     {
@@ -167,9 +197,11 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
         default:
             return;
     }
+
     // remove fake death
     if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
         GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
     Item *it = pl->GetItemByGuid(item);
     //do not allow to sell already auctioned items
     if (auctionmgr.GetAItem(GUID_LOPART(item)))
@@ -184,17 +216,21 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
         SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_ITEM_NOT_FOUND);
         return;
     }
+
     if (!it->CanBeTraded())
     {
         SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
         return;
     }
+
     if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
     {
         SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
         return;
     }
+
     AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction());
+
     //we have to take deposit :
     uint32 deposit = auctionmgr.GetAuctionDeposit(auctionHouseEntry, etime, it);
     if (pl->GetMoney() < deposit)
@@ -202,13 +238,17 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
         SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
         return;
     }
+
     if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
     {
         sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
             GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount());
     }
+
     pl->ModifyMoney(-int32(deposit));
+
     uint32 auction_time = uint32(etime * sWorld.getRate(RATE_AUCTION_TIME));
+
     AuctionEntry *AH = new AuctionEntry;
     AH->Id = objmgr.GenerateAuctionID();
     if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
@@ -225,18 +265,23 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
     AH->expire_time = time(NULL) + auction_time;
     AH->deposit = deposit;
     AH->auctionHouseEntry = auctionHouseEntry;
+
     sLog.outDetail("selling item %u to auctioneer %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", GUID_LOPART(item), AH->auctioneer, bid, buyout, auction_time, AH->GetHouseId());
     auctionmgr.AddAItem(it);
     auctionHouse->AddAuction(AH);
+
     pl->MoveItemFromInventory(it->GetBagSlot(), it->GetSlot(), true);
+
     CharacterDatabase.BeginTransaction();
     it->DeleteFromInventoryDB();
     it->SaveToDB();                                         // recursive and not have transaction guard into self, not in inventiory and can be save standalone
     AH->SaveToDB();
     pl->SaveInventoryAndGoldToDB();
     CharacterDatabase.CommitTransaction();
+
     SendAuctionCommandResult(AH->Id, AUCTION_SELL_ITEM, AUCTION_OK);
 }
+
 //this function is called when client bids or buys out auction
 void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
 {
@@ -245,26 +290,33 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
     uint32 price;
     recv_data >> auctioneer;
     recv_data >> auctionId >> price;
+
     if (!auctionId || !price)
         return;                                             //check for cheaters
+
     Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
     if (!pCreature)
     {
         sLog.outDebug("WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));
         return;
     }
+
     // remove fake death
     if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
         GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
     AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction());
+
     AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
     Player *pl = GetPlayer();
+
     if (!auction || auction->owner == pl->GetGUIDLow())
     {
         //you cannot bid your own auction:
         SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR);
         return;
     }
+
     // impossible have online own another character (use this for speedup check in case online owner)
     Player* auction_owner = objmgr.GetPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));
     if (!auction_owner && objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId())
@@ -273,9 +325,11 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
         SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR);
         return;
     }
+
     // cheating
     if (price <= auction->bid)
         return;
+
     // price too low for next bid if not buyout
     if ((price < auction->buyout || auction->buyout == 0) &&
         price < auction->bid + auction->GetAuctionOutBid())
@@ -283,12 +337,14 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
         //auction has already higher bid, client tests it!
         return;
     }
+
     if (price > pl->GetMoney())
     {
         //you don't have enought money!, client tests!
         //SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);
         return;
     }
+
     if ((price < auction->buyout) || (auction->buyout == 0))
     {
         if (auction->bidder > 0)
@@ -311,8 +367,10 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
         auction->bidder = pl->GetGUIDLow();
         auction->bid = price;
         GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
+
         // after this update we should save player's money ...
         CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
+
         SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0);
     }
     else
@@ -333,9 +391,11 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
         auction->bidder = pl->GetGUIDLow();
         auction->bid = auction->buyout;
         GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout);
+
         auctionmgr.SendAuctionSalePendingMail(auction);
         auctionmgr.SendAuctionSuccessfulMail(auction);
         auctionmgr.SendAuctionWonMail(auction);
+
         SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK);
         auction->DeleteFromDB();
         uint32 item_template = auction->item_template;
@@ -346,6 +406,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
     pl->SaveInventoryAndGoldToDB();
     CharacterDatabase.CommitTransaction();
 }
+
 //this void is called when auction_owner cancels his auction
 void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
 {
@@ -354,18 +415,23 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
     recv_data >> auctioneer;
     recv_data >> auctionId;
     //sLog.outDebug("Cancel AUCTION AuctionID: %u", auctionId);
+
     Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
     if (!pCreature)
     {
         sLog.outDebug("WORLD: HandleAuctionRemoveItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));
         return;
     }
+
     // remove fake death
     if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
         GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
     AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction());
+
     AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
     Player *pl = GetPlayer();
+
     if (auction && auction->owner == pl->GetGUIDLow())
     {
         Item *pItem = auctionmgr.GetAItem(auction->item_guidlow);
@@ -383,8 +449,10 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
             // Return the item by mail
             std::ostringstream msgAuctionCanceledOwner;
             msgAuctionCanceledOwner << auction->item_template << ":0:" << AUCTION_CANCELED;
+
             MailItemsInfo mi;
             mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
+
             // item will deleted or added to received mail list
             WorldSession::SendMailTo(pl, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), pl->GetGUIDLow(), msgAuctionCanceledOwner.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
         }
@@ -402,6 +470,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
         sLog.outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId);
         return;
     }
+
     //inform player, that auction is removed
     SendAuctionCommandResult(auction->Id, AUCTION_CANCEL, AUCTION_OK);
     // Now remove the auction
@@ -413,12 +482,14 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
     auctionmgr.RemoveAItem(auction->item_guidlow);
     auctionHouse->RemoveAuction(auction, item_template);
 }
+
 //called when player lists his bids
 void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data)
 {
     uint64 guid;                                            //NPC guid
     uint32 listfrom;                                        //page of auctions
     uint32 outbiddedCount;                                  //count of outbidded auctions
+
     recv_data >> guid;
     recv_data >> listfrom;                                  // not used in fact (this list not have page control in client)
     recv_data >> outbiddedCount;
@@ -427,16 +498,20 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data)
         sLog.outError("Client sent bad opcode!!! with count: %u and size : %lu (must be: %u)", outbiddedCount, (unsigned long)recv_data.size(),(16 + outbiddedCount * 4));
         outbiddedCount = 0;
     }
+
     Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER);
     if (!pCreature)
     {
         sLog.outDebug("WORLD: HandleAuctionListBidderItems - 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()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
     AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction());
+
     WorldPacket data(SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4));
     Player *pl = GetPlayer();
     data << (uint32) 0;                                     //add 0 as count
@@ -454,39 +529,49 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data)
             ++count;
         }
     }
+
     auctionHouse->BuildListBidderItems(data,pl,count,totalcount);
     data.put(0, count);                           // add count to placeholder
     data << totalcount;
     data << (uint32)300;                                    //unk 2.3.0
     SendPacket(&data);
 }
+
 //this void sends player info about his auctions
 void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recv_data)
 {
     uint32 listfrom;
     uint64 guid;
+
     recv_data >> guid;
     recv_data >> listfrom;                                  // not used in fact (this list not have page control in client)
+
     Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER);
     if (!pCreature)
     {
         sLog.outDebug("WORLD: HandleAuctionListOwnerItems - 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()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
     AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction());
+
     WorldPacket data(SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4));
     data << (uint32) 0;                                     // amount place holder
+
     uint32 count = 0;
     uint32 totalcount = 0;
+
     auctionHouse->BuildListOwnerItems(data,_player,count,totalcount);
     data.put(0, count);
     data << (uint32) totalcount;
     data << (uint32) 0;
     SendPacket(&data);
 }
+
 //this void is called when player clicks on search button
 void WorldSession::HandleAuctionListItems(WorldPacket & recv_data)
 {
@@ -494,47 +579,61 @@ void WorldSession::HandleAuctionListItems(WorldPacket & recv_data)
     uint8 levelmin, levelmax, usable;
     uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
     uint64 guid;
+
     recv_data >> guid;
     recv_data >> listfrom;                                  // start, used for page control listing by 50 elements
     recv_data >> searchedname;
+
     recv_data >> levelmin >> levelmax;
     recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory;
     recv_data >> quality >> usable;
+
     Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER);
     if (!pCreature)
     {
         sLog.outDebug("WORLD: HandleAuctionListItems - 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()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
     AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction());
+
     //sLog.outDebug("Auctionhouse search (GUID: %u TypeId: %u)", , list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
     //  GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
+
     WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4+4+4));
     uint32 count = 0;
     uint32 totalcount = 0;
     data << (uint32) 0;
+
     // converting string that we try to find to lower case
     std::wstring wsearchedname;
     if (!Utf8toWStr(searchedname,wsearchedname))
         return;
+
     wstrToLower(wsearchedname);
+
     auctionHouse->BuildListAuctionItems(data,_player,
         wsearchedname, listfrom, levelmin, levelmax, usable,
         auctionSlotID, auctionMainCategory, auctionSubCategory, quality,
         count,totalcount);
+
     data.put(0, count);
     data << (uint32) totalcount;
     data << (uint32) 300;                                   // unk 2.3.0 const?
     SendPacket(&data);
 }
+
 void WorldSession::HandleAuctionListPendingSales(WorldPacket & recv_data)
 {
     sLog.outDebug("CMSG_AUCTION_LIST_PENDING_SALES");
     recv_data.hexlike();
+
     uint32 count = 0;
+
     WorldPacket data(SMSG_AUCTION_LIST_PENDING_SALES, 4);
     data << uint32(count);                                  // count
     /*for (uint32 i = 0; i < count; ++i)
diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp
index 2f7ba808fb3..ffc0c55d9d3 100644
--- a/src/game/AuctionHouseMgr.cpp
+++ b/src/game/AuctionHouseMgr.cpp
@@ -15,6 +15,7 @@
  * 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 "ObjectMgr.h"
 #include "Player.h"
@@ -25,6 +26,7 @@
 #include "Database/SQLStorage.h"
 #include "Policies/SingletonImp.h"
 #include "DBCStores.h"
+
 #include "AccountMgr.h"
 #include "AuctionHouseMgr.h"
 #include "Item.h"
@@ -33,20 +35,26 @@
 #include "ProgressBar.h"
 #include 
 
+
 INSTANTIATE_SINGLETON_1(AuctionHouseMgr);
+
 using namespace std;
+
 AuctionHouseMgr::AuctionHouseMgr()
 {
 }
+
 AuctionHouseMgr::~AuctionHouseMgr()
 {
     for (ItemMap::const_iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr)
         delete itr->second;
 }
+
 AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap(uint32 factionTemplateId)
 {
     if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
         return &mNeutralAuctions;
+
     // team have linked auction houses
     FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
     if (!u_entry)
@@ -58,15 +66,18 @@ AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap(uint32 factionTemplateId)
     else
         return &mNeutralAuctions;
 }
+
 uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem)
 {
     uint32 MSV = pItem->GetProto()->SellPrice;
     int32 deposit;
     uint32 timeHr = (((time / 60) / 60) / 12);
+
     if (MSV > 0)
         deposit = (int32)floor((double)MSV * (((double)(entry->depositPercent * 3) / 100.0f * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT) * (double)pItem->GetCount()))) * timeHr;
     else
         deposit = 0;
+
     sLog.outDebug("SellPrice:\t\t%u", MSV);
     sLog.outDebug("Deposit Percent:\t%f", ((double)entry->depositPercent / 100.0f));
     sLog.outDebug("Auction Time1:\t\t%u", time);
@@ -84,12 +95,14 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32
         return 0;
     }
 }
+
 //does not clear ram
 void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction)
 {
     Item *pItem = GetAItem(auction->item_guidlow);
     if (!pItem)
         return;
+
     uint32 bidder_accId = 0;
     uint32 bidder_security = 0;
     uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
@@ -108,6 +121,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction)
         {
             bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid);
             bidder_security = accmgr.GetSecurity(bidder_accId);
+
             if (bidder_security > SEC_PLAYER) // not do redundant DB requests
             {
                 if (!objmgr.GetPlayerNameByGUID(bidder_guid,bidder_name))
@@ -119,34 +133,44 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction)
             std::string owner_name;
             if (!objmgr.GetPlayerNameByGUID(auction->owner,owner_name))
                 owner_name = objmgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN);
+
             uint32 owner_accid = objmgr.GetPlayerAccountIdByGUID(auction->owner);
+
             sLog.outCommand(bidder_accId,"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);
         }
     }
+
     // 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 = objmgr.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->GetHouseId(), auction->Id, bidder_guid, 0, 0, auction->item_template);
+
         WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionWonSubject.str(), itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_AUCTION);
     }
 }
+
 void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry * auction)
 {
     uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
@@ -157,19 +181,26 @@ void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry * auction)
     {
         std::ostringstream msgAuctionSalePendingSubject;
         msgAuctionSalePendingSubject << auction->item_template << ":0:" << AUCTION_SALE_PENDING;
+
         std::ostringstream msgAuctionSalePendingBody;
         uint32 auctionCut = auction->GetAuctionCut();
+
         time_t distrTime = time(NULL) + sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY);
+
         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 = objmgr.CreateItemText(msgAuctionSalePendingBody.str());
+
         WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), 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 AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry * auction)
 {
@@ -181,15 +212,21 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry * auction)
     {
         std::ostringstream msgAuctionSuccessfulSubject;
         msgAuctionSuccessfulSubject << auction->item_template << ":0:" << AUCTION_SUCCESSFUL;
+
         std::ostringstream auctionSuccessfulBody;
         uint32 auctionCut = auction->GetAuctionCut();
+
         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 = objmgr.CreateItemText(auctionSuccessfulBody.str());
+
         uint32 profit = auction->bid + auction->deposit - auctionCut;
+
         //FIXME: what do if owner offline
         if (owner && owner->GetGUIDLow() != auctionbot.GetAHBplayerGUID())
         {
@@ -200,12 +237,14 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry * auction)
         WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->owner, msgAuctionSuccessfulSubject.str(), itemTextId, NULL, profit, 0, MAIL_CHECK_MASK_AUCTION, sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY));
     }
 }
+
 //does not clear ram
 void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction)
 { //return an item in auction to its owner by mail
     Item *pItem = GetAItem(auction->item_guidlow);
     if (!pItem)
         return;
+
     uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
     Player *owner = objmgr.GetPlayer(owner_guid);
     uint32 owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid);
@@ -214,17 +253,22 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction)
     {
         std::ostringstream subject;
         subject << auction->item_template << ":0:" << AUCTION_EXPIRED;
+
         if (owner && owner->GetGUIDLow() != auctionbot.GetAHBplayerGUID())
             owner->GetSession()->SendAuctionOwnerNotification(auction);
+
         MailItemsInfo mi;
         mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
+
         WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
     }
 }
+
 void AuctionHouseMgr::LoadAuctionItems()
 {
     // data needs to be at first place for Item::LoadFromDB
     QueryResult *result = CharacterDatabase.Query("SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid");
+
     if (!result)
     {
         barGoLink bar(1);
@@ -233,34 +277,45 @@ void AuctionHouseMgr::LoadAuctionItems()
         sLog.outString(">> Loaded 0 auction items");
         return;
     }
+
     barGoLink bar(result->GetRowCount());
+
     uint32 count = 0;
+
     Field *fields;
     do
     {
         bar.step();
+
         fields = result->Fetch();
         uint32 item_guid        = fields[1].GetUInt32();
         uint32 item_template    = fields[2].GetUInt32();
+
         ItemPrototype const *proto = objmgr.GetItemPrototype(item_template);
+
         if (!proto)
         {
             sLog.outError("AuctionHouseMgr::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, result))
         {
             delete item;
             continue;
         }
         AddAItem(item);
+
         ++count;
     } while (result->NextRow());
     delete result;
+
     sLog.outString();
     sLog.outString(">> Loaded %u auction items", count);
 }
+
 void AuctionHouseMgr::LoadAuctions()
 {
     QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
@@ -272,9 +327,11 @@ void AuctionHouseMgr::LoadAuctions()
         sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
         return;
     }
+
     Field *fields = result->Fetch();
     uint32 AuctionCount=fields[0].GetUInt32();
     delete result;
+
     if (!AuctionCount)
     {
         barGoLink bar(1);
@@ -283,6 +340,7 @@ void AuctionHouseMgr::LoadAuctions()
         sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
         return;
     }
+
     result = CharacterDatabase.Query("SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auctionhouse");
     if (!result)
     {
@@ -292,12 +350,17 @@ void AuctionHouseMgr::LoadAuctions()
         sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
         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();
@@ -310,6 +373,7 @@ void AuctionHouseMgr::LoadAuctions()
         aItem->bid = fields[8].GetUInt32();
         aItem->startbid = fields[9].GetUInt32();
         aItem->deposit = fields[10].GetUInt32();
+
         CreatureData const* auctioneerData = objmgr.GetCreatureData(aItem->auctioneer);
         if (!auctioneerData)
         {
@@ -318,6 +382,7 @@ void AuctionHouseMgr::LoadAuctions()
             delete aItem;
             continue;
         }
+
         CreatureInfo const* auctioneerInfo = objmgr.GetCreatureTemplate(auctioneerData->id);
         if (!auctioneerInfo)
         {
@@ -326,6 +391,7 @@ void AuctionHouseMgr::LoadAuctions()
             delete aItem;
             continue;
         }
+
         aItem->auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(auctioneerInfo->faction_A);
         if (!aItem->auctionHouseEntry)
         {
@@ -335,6 +401,7 @@ void AuctionHouseMgr::LoadAuctions()
             delete aItem;
             continue;
         }
+
         // check if sold item exists for guid
         // and item_template in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems)
         if (!GetAItem(aItem->item_guidlow))
@@ -344,35 +411,44 @@ void AuctionHouseMgr::LoadAuctions()
             delete aItem;
             continue;
         }
+
         GetAuctionsMap(auctioneerInfo->faction_A)->AddAuction(aItem);
+
     } while (result->NextRow());
     delete result;
+
     sLog.outString();
     sLog.outString(">> Loaded %u auctions", AuctionCount);
 }
+
 void AuctionHouseMgr::AddAItem(Item* it)
 {
     ASSERT(it);
     ASSERT(mAitems.find(it->GetGUIDLow()) == mAitems.end());
     mAitems[it->GetGUIDLow()] = it;
 }
+
 bool AuctionHouseMgr::RemoveAItem(uint32 id)
 {
     ItemMap::iterator i = mAitems.find(id);
     if (i == mAitems.end())
         return false;
+
     mAitems.erase(i);
     return true;
 }
+
 void AuctionHouseMgr::Update()
 {
     mHordeAuctions.Update();
     mAllianceAuctions.Update();
     mNeutralAuctions.Update();
 }
+
 AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId)
 {
     uint32 houseid = 7; // goblin auction house
+
     if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
     {
         //FIXME: found way for proper auctionhouse selection by another way
@@ -405,6 +481,7 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTem
             }
         }
     }
+
     return sAuctionHouseStore.LookupEntry(houseid);
 }
     void AuctionHouseObject::AddAuction(AuctionEntry *ah)
@@ -413,45 +490,57 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTem
         AuctionsMap[ah->Id] = ah;
         auctionbot.IncrementItemCounts(ah);
     }
+
     bool AuctionHouseObject::RemoveAuction(AuctionEntry *auction, uint32 item_template)
     {
         auctionbot.DecrementItemCounts(auction, item_template);
         return AuctionsMap.erase(auction->Id) ? true : false;
     }
+
 void AuctionHouseObject::Update()
 {
     time_t curTime = sWorld.GetGameTime();
     ///- Handle expired auctions
+
     // If storage is empty, no need to update. next == NULL in this case.
     if (AuctionsMap.empty())
         return;
+
     QueryResult* result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE time <= %u ORDER BY TIME ASC", (uint32)curTime+60);
+
     if (!result)
     {
         delete result;
         return;
     }
+
     if (result->GetRowCount() == 0)
     {
         delete result;
         return;
     }
+
     vector expiredAuctions;
+
     do
     {
         uint32 tmpdata = result->Fetch()->GetUInt32();
         expiredAuctions.push_back(tmpdata);
     } while (result->NextRow());
     delete result;
+
     vector::iterator iter = expiredAuctions.begin();
     while (!expiredAuctions.empty())
     {
         // from auctionhousehandler.cpp, creates auction pointer & player pointer
         AuctionEntry* auction = GetAuction(*iter);
+
         // Erase the auction from the vector.
         expiredAuctions.erase(iter);
+
         if (!auction)
             continue;
+
         ///- Either cancel the auction if there was no bidder
         if (auction->bidder == 0)
             auctionmgr.SendAuctionExpiredMail(auction);
@@ -464,6 +553,7 @@ void AuctionHouseObject::Update()
             auctionmgr.SendAuctionSuccessfulMail(auction);
             auctionmgr.SendAuctionWonMail(auction);
         }
+
         ///- In any case clear the auction
         auction->DeleteFromDB();
         uint32 item_template = auction->item_template;
@@ -471,6 +561,7 @@ void AuctionHouseObject::Update()
         RemoveAuction(auction, item_template);
     }
 }
+
 void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount)
 {
     for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
@@ -480,10 +571,12 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player,
         {
             if (itr->second->BuildAuctionInfo(data))
                 ++count;
+
             ++totalcount;
         }
     }
 }
+
 void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount)
 {
     for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
@@ -493,38 +586,50 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player,
         {
             if (Aentry->BuildAuctionInfo(data))
                 ++count;
+
             ++totalcount;
         }
     }
 }
+
 void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player,
     std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
     uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
     uint32& count, uint32& totalcount)
 {
     int loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
+
     for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
     {
         AuctionEntry *Aentry = itr->second;
         Item *item = auctionmgr.GetAItem(Aentry->item_guidlow);
         if (!item)
             continue;
+
         ItemPrototype const *proto = item->GetProto();
+
         if (itemClass != 0xffffffff && proto->Class != itemClass)
             continue;
+
         if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
             continue;
+
         if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
             continue;
+
         if (quality != 0xffffffff && proto->Quality != quality)
             continue;
+
         if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
             continue;
+
         if (usable != 0x00 && player->CanUseItem(item) != EQUIP_ERR_OK)
             continue;
+
         std::string name = proto->Name1;
         if (name.empty())
             continue;
+
         // local name
         if (loc_idx >= 0)
         {
@@ -535,8 +640,10 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
                     name = il->Name[loc_idx];
             }
         }
+
         if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname))
             continue;
+
         if (count < 50 && totalcount >= listfrom)
         {
             ++count;
@@ -545,6 +652,7 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
         ++totalcount;
     }
 }
+
 //this function inserts to WorldPacket auction's data
 bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const
 {
@@ -556,12 +664,14 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const
     }
     data << uint32(Id);
     data << uint32(pItem->GetEntry());
+
     for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; ++i)
     {
         data << uint32(pItem->GetEnchantmentId(EnchantmentSlot(i)));
         data << uint32(pItem->GetEnchantmentDuration(EnchantmentSlot(i)));
         data << uint32(pItem->GetEnchantmentCharges(EnchantmentSlot(i)));
     }
+
     data << uint32(pItem->GetItemRandomPropertyId());       //random item property id
     data << uint32(pItem->GetItemSuffixFactor());           //SuffixFactor
     data << uint32(pItem->GetCount());                      //item->count
@@ -577,6 +687,7 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const
     data << uint32(bid);                                    //current bid
     return true;
 }
+
 uint32 AuctionEntry::GetAuctionCut() const
 {
     int32 cut = int32(((double)auctionHouseEntry->cutPercent / 100.0f) * (double)sWorld.getRate(RATE_AUCTION_CUT)) * bid;
@@ -585,6 +696,7 @@ uint32 AuctionEntry::GetAuctionCut() const
     else
         return 0;
 }
+
 /// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c
 uint32 AuctionEntry::GetAuctionOutBid() const
 {
@@ -593,11 +705,13 @@ uint32 AuctionEntry::GetAuctionOutBid() const
         outbid = 1;
     return outbid;
 }
+
 void AuctionEntry::DeleteFromDB() const
 {
     //No SQL injection (Id is integer)
     CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",Id);
 }
+
 void AuctionEntry::SaveToDB() const
 {
     //No SQL injection (no strings)
diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h
index 5d62e16ab85..0e3ead4f608 100644
--- a/src/game/AuctionHouseMgr.h
+++ b/src/game/AuctionHouseMgr.h
@@ -17,15 +17,22 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef _AUCTION_HOUSE_MGR_H
 #define _AUCTION_HOUSE_MGR_H
+
 #include "Policies/Singleton.h"
+
 #include "SharedDefines.h"
+
 #include "AuctionHouseBot.h"
+
 class Item;
 class Player;
 class WorldPacket;
+
 #define MIN_AUCTION_TIME (12*HOUR)
+
 enum AuctionError
 {
     AUCTION_OK = 0,
@@ -34,12 +41,14 @@ enum AuctionError
     AUCTION_ITEM_NOT_FOUND = 4,
     CANNOT_BID_YOUR_AUCTION_ERROR = 10
 };
+
 enum AuctionAction
 {
     AUCTION_SELL_ITEM = 0,
     AUCTION_CANCEL = 1,
     AUCTION_PLACE_BID = 2
 };
+
 struct AuctionEntry
 {
     uint32 Id;
@@ -54,6 +63,7 @@ struct AuctionEntry
     uint32 bidder;
     uint32 deposit;                                         //deposit can be calculated only when creating auction
     AuctionHouseEntry const* auctionHouseEntry;             // in AuctionHouse.dbc
+
     // helpers
     uint32 GetHouseId() const { return auctionHouseEntry->houseId; }
     uint32 GetHouseFaction() const { return auctionHouseEntry->faction; }
@@ -63,6 +73,7 @@ struct AuctionEntry
     void DeleteFromDB() const;
     void SaveToDB() const;
 };
+
 //this class is used as auctionhouse instance
 class AuctionHouseObject
 {
@@ -74,37 +85,51 @@ class AuctionHouseObject
         for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
             delete itr->second;
     }
+
     typedef std::map AuctionEntryMap;
+
     uint32 Getcount() { return AuctionsMap.size(); }
+
     AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();}
     AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();}
+
     AuctionEntry* GetAuction(uint32 id) const
     {
         AuctionEntryMap::const_iterator itr = AuctionsMap.find(id);
         return itr != AuctionsMap.end() ? itr->second : NULL;
     }
+
     void AddAuction(AuctionEntry *ah);
+
     bool RemoveAuction(AuctionEntry *auction, uint32 item_template);
+
     void Update();
+
     void BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
     void BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
     void BuildListAuctionItems(WorldPacket& data, Player* player,
         std::wstring const& searchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
         uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
         uint32& count, uint32& totalcount);
+
   private:
     AuctionEntryMap AuctionsMap;
+
     // storage for "next" auction item for next Update()
     AuctionEntryMap::const_iterator next;
 };
+
 class AuctionHouseMgr
 {
   public:
     AuctionHouseMgr();
     ~AuctionHouseMgr();
+
     typedef UNORDERED_MAP ItemMap;
+
     AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId);
     AuctionHouseObject* GetBidsMap(uint32 factionTemplateId);
+
     Item* GetAItem(uint32 id)
     {
         ItemMap::const_iterator itr = mAitems.find(id);
@@ -114,6 +139,7 @@ class AuctionHouseMgr
         }
         return NULL;
     }
+
     //auction messages
     void SendAuctionWonMail(AuctionEntry * auction);
     void SendAuctionSalePendingMail(AuctionEntry * auction);
@@ -121,18 +147,25 @@ class AuctionHouseMgr
     void SendAuctionExpiredMail(AuctionEntry * auction);
     static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem);
     static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId);
+
   public:
     //load first auction items, because of check if item exists, when loading
     void LoadAuctionItems();
     void LoadAuctions();
+
     void AddAItem(Item* it);
     bool RemoveAItem(uint32 id);
+
     void Update();
+
   private:
     AuctionHouseObject mHordeAuctions;
     AuctionHouseObject mAllianceAuctions;
     AuctionHouseObject mNeutralAuctions;
+
     ItemMap mAitems;
 };
+
 #define auctionmgr Trinity::Singleton::Instance()
+
 #endif
diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp
index 5b406c2eb08..2d58b63c0a9 100644
--- a/src/game/Bag.cpp
+++ b/src/game/Bag.cpp
@@ -17,19 +17,25 @@
  * 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 "ObjectMgr.h"
 #include "Database/DatabaseEnv.h"
+
 #include "Bag.h"
 #include "Log.h"
 #include "UpdateData.h"
+
 Bag::Bag( ): Item()
 {
     m_objectType |= TYPEMASK_CONTAINER;
     m_objectTypeId = TYPEID_CONTAINER;
+
     m_valuesCount = CONTAINER_END;
+
     memset(m_bagslot, 0, sizeof(Item *) * MAX_BAG_SIZE);
 }
+
 Bag::~Bag()
 {
     for(uint8 i = 0; i < MAX_BAG_SIZE; ++i)
@@ -45,52 +51,68 @@ Bag::~Bag()
             delete m_bagslot[i];
         }
 }
+
 void Bag::AddToWorld()
 {
     Item::AddToWorld();
+
     for(uint32 i = 0;  i < GetBagSize(); ++i)
         if(m_bagslot[i])
             m_bagslot[i]->AddToWorld();
 }
+
 void Bag::RemoveFromWorld()
 {
     for(uint32 i = 0; i < GetBagSize(); ++i)
         if(m_bagslot[i])
             m_bagslot[i]->RemoveFromWorld();
+
     Item::RemoveFromWorld();
 }
+
 bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
 {
     ItemPrototype const * itemProto = objmgr.GetItemPrototype(itemid);
+
     if(!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
         return false;
+
     Object::_Create( guidlow, 0, HIGHGUID_CONTAINER );
+
     SetEntry(itemid);
     SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
+
     SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
     SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
+
     SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
     SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
     SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags);
     SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
+
     // Setting the number of Slots the Container has
     SetUInt32Value(CONTAINER_FIELD_NUM_SLOTS, itemProto->ContainerSlots);
+
     // Cleaning 20 slots
     for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
     {
         SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
         m_bagslot[i] = NULL;
     }
+
     return true;
 }
+
 void Bag::SaveToDB()
 {
     Item::SaveToDB();
 }
+
 bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
 {
     if(!Item::LoadFromDB(guid, owner_guid, result))
         return false;
+
     // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
     for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
     {
@@ -101,34 +123,44 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
             m_bagslot[i] = NULL;
         }
     }
+
     return true;
 }
+
 void Bag::DeleteFromDB()
 {
     for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
         if (m_bagslot[i])
             m_bagslot[i]->DeleteFromDB();
+
     Item::DeleteFromDB();
 }
+
 uint32 Bag::GetFreeSlots() const
 {
     uint32 slots = 0;
     for (uint32 i=0; i < GetBagSize(); ++i)
         if (!m_bagslot[i])
             ++slots;
+
     return slots;
 }
+
 void Bag::RemoveItem( uint8 slot, bool /*update*/ )
 {
     assert(slot < MAX_BAG_SIZE);
+
     if (m_bagslot[slot])
         m_bagslot[slot]->SetContainer(NULL);
+
     m_bagslot[slot] = NULL;
     SetUInt64Value( CONTAINER_FIELD_SLOT_1 + (slot * 2), 0 );
 }
+
 void Bag::StoreItem( uint8 slot, Item *pItem, bool /*update*/ )
 {
     assert(slot < MAX_BAG_SIZE);
+
     if( pItem )
     {
         m_bagslot[slot] = pItem;
@@ -139,21 +171,26 @@ void Bag::StoreItem( uint8 slot, Item *pItem, bool /*update*/ )
         pItem->SetSlot(slot);
     }
 }
+
 void Bag::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const
 {
     Item::BuildCreateUpdateBlockForPlayer( data, target );
+
     for (uint32 i = 0; i < GetBagSize(); ++i)
         if(m_bagslot[i])
             m_bagslot[i]->BuildCreateUpdateBlockForPlayer( data, target );
 }
+
 // If the bag is empty returns true
 bool Bag::IsEmpty() const
 {
     for(uint32 i = 0; i < GetBagSize(); ++i)
         if (m_bagslot[i])
             return false;
+
     return true;
 }
+
 uint32 Bag::GetItemCount( uint32 item, Item* eItem ) const
 {
     Item *pItem;
@@ -164,6 +201,7 @@ uint32 Bag::GetItemCount( uint32 item, Item* eItem ) const
         if( pItem && pItem != eItem && pItem->GetEntry() == item )
             count += pItem->GetCount();
     }
+
     if(eItem && eItem->GetProto()->GemProperties)
     {
         for(uint32 i=0; i < GetBagSize(); ++i)
@@ -173,20 +211,25 @@ uint32 Bag::GetItemCount( uint32 item, Item* eItem ) const
                 count += pItem->GetGemCountWithID(item);
         }
     }
+
     return count;
 }
+
 uint8 Bag::GetSlotByItemGUID(uint64 guid) const
 {
     for(uint32 i = 0; i < GetBagSize(); ++i)
         if(m_bagslot[i] != 0)
             if(m_bagslot[i]->GetGUID() == guid)
                 return i;
+
     return NULL_SLOT;
 }
+
 Item* Bag::GetItemByPos( uint8 slot ) const
 {
     if( slot < GetBagSize() )
         return m_bagslot[slot];
+
     return NULL;
 }
 
diff --git a/src/game/Bag.h b/src/game/Bag.h
index 649c2e21a27..3ae786512ce 100644
--- a/src/game/Bag.h
+++ b/src/game/Bag.h
@@ -17,29 +17,40 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_BAG_H
 #define TRINITY_BAG_H
+
 // Maximum 36 Slots ( (CONTAINER_END - CONTAINER_FIELD_SLOT_1)/2
 #define MAX_BAG_SIZE 36                                     // 2.0.12
+
 #include "Item.h"
 #include "ItemPrototype.h"
+
 class Bag : public Item
 {
     public:
+
         Bag();
         ~Bag();
+
         void AddToWorld();
         void RemoveFromWorld();
+
         bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
+
         void Clear();
         void StoreItem( uint8 slot, Item *pItem, bool update );
         void RemoveItem( uint8 slot, bool update );
+
         Item* GetItemByPos( uint8 slot ) const;
         uint32 GetItemCount( uint32 item, Item* eItem = NULL ) const;
+
         uint8 GetSlotByItemGUID(uint64 guid) const;
         bool IsEmpty() const;
         uint32 GetFreeSlots() const;
         uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); }
+
         // DB operations
         // overwrite virtual Item::SaveToDB
         void SaveToDB();
@@ -47,11 +58,15 @@ class Bag : public Item
         bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result = NULL);
         // overwrite virtual Item::DeleteFromDB
         void DeleteFromDB();
+
         void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const;
+
     protected:
+
         // Bag Storage space
         Item* m_bagslot[MAX_BAG_SIZE];
 };
+
 inline Item* NewItemOrBag(ItemPrototype const * proto)
 {
     return (proto->InventoryType == INVTYPE_BAG) ? new Bag : new Item;
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 92c82f620f5..3eb699472d8 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -17,10 +17,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "Player.h"
 #include "ObjectMgr.h"
 #include "World.h"
 #include "WorldPacket.h"
+
 #include "ArenaTeam.h"
 #include "BattleGround.h"
 #include "BattleGroundMgr.h"
@@ -34,6 +36,7 @@
 #include "SpellAuras.h"
 #include "Util.h"
 
+
 namespace MaNGOS
 {
     class BattleGroundChatBuilder
@@ -44,14 +47,17 @@ namespace MaNGOS
             void operator()(WorldPacket& data, int32 loc_idx)
             {
                 char const* text = objmgr.GetMangosString(i_textId,loc_idx);
+
                 if (i_args)
                 {
                     // we need copy va_list before use or original va_list will corrupted
                     va_list ap;
                     va_copy(ap,*i_args);
+
                     char str [2048];
                     vsnprintf(str,2048,text, ap );
                     va_end(ap);
+
                     do_helper(data,&str[0]);
                 }
                 else
@@ -61,6 +67,7 @@ namespace MaNGOS
             void do_helper(WorldPacket& data, char const* text)
             {
                 uint64 target_guid = i_source  ? i_source ->GetGUID() : 0;
+
                 data << uint8(i_msgtype);
                 data << uint32(LANG_UNIVERSAL);
                 data << uint64(target_guid);                // there 0 for BG messages
@@ -70,11 +77,13 @@ namespace MaNGOS
                 data << text;
                 data << uint8(i_source ? i_source->chatTag() : uint8(0));
             }
+
             ChatMsg i_msgtype;
             int32 i_textId;
             Player const* i_source;
             va_list* i_args;
     };
+
     class BattleGround2ChatBuilder
     {
         public:
@@ -85,9 +94,12 @@ namespace MaNGOS
                 char const* text = objmgr.GetMangosString(i_textId,loc_idx);
                 char const* arg1str = i_arg1 ? objmgr.GetMangosString(i_arg1,loc_idx) : "";
                 char const* arg2str = i_arg2 ? objmgr.GetMangosString(i_arg2,loc_idx) : "";
+
                 char str [2048];
                 snprintf(str,2048,text, arg1str, arg2str );
+
                 uint64 target_guid = i_source  ? i_source ->GetGUID() : 0;
+
                 data << uint8(i_msgtype);
                 data << uint32(LANG_UNIVERSAL);
                 data << uint64(target_guid);                // there 0 for BG messages
@@ -98,6 +110,7 @@ namespace MaNGOS
                 data << uint8(i_source ? i_source->chatTag() : uint8(0));
             }
         private:
+
             ChatMsg i_msgtype;
             int32 i_textId;
             Player const* i_source;
@@ -105,6 +118,7 @@ namespace MaNGOS
             int32 i_arg2;
     };
 }                                                           // namespace MaNGOS
+
 template
 void BattleGround::BroadcastWorker(Do& _do)
 {
@@ -112,6 +126,7 @@ void BattleGround::BroadcastWorker(Do& _do)
         if (Player *plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)))
             _do(plr);
 }
+
 BattleGround::BattleGround()
 {
     m_TypeID            = BattleGroundTypeId(0);
@@ -135,32 +150,46 @@ BattleGround::BattleGround()
     m_LevelMax          = 0;
     m_InBGFreeSlotQueue = false;
     m_SetDeleteThis     = false;
+
     m_MaxPlayersPerTeam = 0;
     m_MaxPlayers        = 0;
     m_MinPlayersPerTeam = 0;
     m_MinPlayers        = 0;
+
     m_MapId             = 0;
+
     m_TeamStartLocX[BG_TEAM_ALLIANCE]   = 0;
     m_TeamStartLocX[BG_TEAM_HORDE]      = 0;
+
     m_TeamStartLocY[BG_TEAM_ALLIANCE]   = 0;
     m_TeamStartLocY[BG_TEAM_HORDE]      = 0;
+
     m_TeamStartLocZ[BG_TEAM_ALLIANCE]   = 0;
     m_TeamStartLocZ[BG_TEAM_HORDE]      = 0;
+
     m_TeamStartLocO[BG_TEAM_ALLIANCE]   = 0;
     m_TeamStartLocO[BG_TEAM_HORDE]      = 0;
+
     m_ArenaTeamIds[BG_TEAM_ALLIANCE]   = 0;
     m_ArenaTeamIds[BG_TEAM_HORDE]      = 0;
+
     m_ArenaTeamRatingChanges[BG_TEAM_ALLIANCE]   = 0;
     m_ArenaTeamRatingChanges[BG_TEAM_HORDE]      = 0;
+
     m_BgRaids[BG_TEAM_ALLIANCE]         = NULL;
     m_BgRaids[BG_TEAM_HORDE]            = NULL;
+
     m_PlayersCount[BG_TEAM_ALLIANCE]    = 0;
     m_PlayersCount[BG_TEAM_HORDE]       = 0;
+
     m_TeamScores[BG_TEAM_ALLIANCE]      = 0;
     m_TeamScores[BG_TEAM_HORDE]         = 0;
+
     m_PrematureCountDown = false;
     m_PrematureCountDown = 0;
+
     m_HonorMode = BG_NORMAL;
+
     m_StartDelayTimes[BG_STARTING_EVENT_FIRST]  = BG_START_DELAY_2M;
     m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_1M;
     m_StartDelayTimes[BG_STARTING_EVENT_THIRD]  = BG_START_DELAY_30S;
@@ -171,6 +200,7 @@ BattleGround::BattleGround()
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_BG_WS_START_HALF_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_WS_HAS_BEGUN;
 }
+
 BattleGround::~BattleGround()
 {
     // remove objects and creatures
@@ -178,9 +208,11 @@ BattleGround::~BattleGround()
     int size = m_BgCreatures.size();
     for(int i = 0; i < size; ++i)
         DelCreature(i);
+
     size = m_BgObjects.size();
     for(int i = 0; i < size; ++i)
         DelObject(i);
+
     if (GetInstanceID())                                    // not spam by useless queries in case BG templates
     {
         // delete creature and go respawn times
@@ -190,6 +222,7 @@ BattleGround::~BattleGround()
         CharacterDatabase.PExecute("DELETE FROM instance WHERE id = '%u'",GetInstanceID());
         // remove from battlegrounds
     }
+
     sBattleGroundMgr.RemoveBattleGround(GetInstanceID(), GetTypeID());
     // unload map
     if (Map * map = MapManager::Instance().FindMap(GetMapId(), GetInstanceID()))
@@ -197,9 +230,11 @@ BattleGround::~BattleGround()
             ((BattleGroundMap*)map)->SetUnload();
     // remove from bg free slot queue
     this->RemoveFromBGFreeSlotQueue();
+
     for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr)
         delete itr->second;
 }
+
 void BattleGround::Update(uint32 diff)
 {
     if (!GetPlayersSize())
@@ -218,6 +253,7 @@ void BattleGround::Update(uint32 diff)
             m_SetDeleteThis = true;
         return;
     }
+
     // remove offline players from bg after 5 minutes
     if (!m_OfflineQueue.empty())
     {
@@ -232,9 +268,11 @@ void BattleGround::Update(uint32 diff)
             }
         }
     }
+
     /*********************************************************/
     /***        BATTLEGROUND RESSURECTION SYSTEM           ***/
     /*********************************************************/
+
     //this should be handled by spell system
     m_LastResurrectTime += diff;
     if (m_LastResurrectTime >= RESURRECTION_INTERVAL)
@@ -249,6 +287,7 @@ void BattleGround::Update(uint32 diff)
                     Player *plr = objmgr.GetPlayer(*itr2);
                     if (!plr)
                         continue;
+
                     if (!sh && plr->IsInWorld())
                     {
                         sh = plr->GetMap()->GetCreature(itr->first);
@@ -257,12 +296,14 @@ void BattleGround::Update(uint32 diff)
                             // Spirit Heal, effect 117
                             sh->CastSpell(sh, SPELL_SPIRIT_HEAL, true);
                     }
+
                     // Resurrection visual
                     plr->CastSpell(plr, SPELL_RESURRECTION_VISUAL, true);
                     m_ResurrectQueue.push_back(*itr2);
                 }
                 (itr->second).clear();
             }
+
             m_ReviveQueue.clear();
             m_LastResurrectTime = 0;
         }
@@ -284,9 +325,11 @@ void BattleGround::Update(uint32 diff)
         }
         m_ResurrectQueue.clear();
     }
+
     /*********************************************************/
     /***           BATTLEGROUND BALLANCE SYSTEM            ***/
     /*********************************************************/
+
     // if less then minimum players are in on one side, then start premature finish timer
     if (GetStatus() == STATUS_IN_PROGRESS && !isArena() && sBattleGroundMgr.GetPrematureFinishTime() && (GetPlayersCountByTeam(ALLIANCE) < GetMinPlayersPerTeam() || GetPlayersCountByTeam(HORDE) < GetMinPlayersPerTeam()))
     {
@@ -303,6 +346,7 @@ void BattleGround::Update(uint32 diff)
                 winner = ALLIANCE;
             else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
                 winner = HORDE;
+
             EndBattleGround(winner);
             m_PrematureCountDown = false;
         }
@@ -326,21 +370,26 @@ void BattleGround::Update(uint32 diff)
     }
     else if (m_PrematureCountDown)
         m_PrematureCountDown = false;
+
     /*********************************************************/
     /***           BATTLEGROUND STARTING SYSTEM            ***/
     /*********************************************************/
+
     if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize())
     {
         ModifyStartDelayTime(diff);
+
         if (!(m_Events & BG_STARTING_EVENT_1))
         {
             m_Events |= BG_STARTING_EVENT_1;
+
             // setup here, only when at least one player has ported to the map
             if (!SetupBattleGround())
             {
                 EndNow();
                 return;
             }
+
             StartingEventCloseDoors();
             SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FIRST]);
             //first start warning - 2 or 1 minute
@@ -362,14 +411,18 @@ void BattleGround::Update(uint32 diff)
         else if (GetStartDelayTime() <= 0 && !(m_Events & BG_STARTING_EVENT_4))
         {
             m_Events |= BG_STARTING_EVENT_4;
+
             StartingEventOpenDoors();
+
             SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FOURTH], CHAT_MSG_BG_SYSTEM_NEUTRAL);
             SetStatus(STATUS_IN_PROGRESS);
             SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FOURTH]);
+
             //remove preparation
             if (isArena())
             {
                 //TODO : add arena sound PlaySoundToAll(SOUND_ARENA_START);
+
                 for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
                     if (Player *plr = objmgr.GetPlayer(itr->first))
                     {
@@ -390,11 +443,14 @@ void BattleGround::Update(uint32 diff)
                                 ++iter;
                         }
                     }
+
                 CheckArenaWinConditions();
             }
             else
             {
+
                 PlaySoundToAll(SOUND_BG_START);
+
                 for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
                     if (Player* plr = objmgr.GetPlayer(itr->first))
                         plr->RemoveAurasDueToSpell(SPELL_PREPARATION);
@@ -406,9 +462,11 @@ void BattleGround::Update(uint32 diff)
             }
         }
     }
+
     /*********************************************************/
     /***           BATTLEGROUND ENDING SYSTEM              ***/
     /*********************************************************/
+
     if (GetStatus() == STATUS_WAIT_LEAVE)
     {
         // remove all players from battleground after 2 minutes
@@ -427,9 +485,11 @@ void BattleGround::Update(uint32 diff)
             }
         }
     }
+
     //update start time
     m_StartTime += diff;
 }
+
 void BattleGround::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O)
 {
     BattleGroundTeamId idx = GetTeamIndexByTeamId(TeamID);
@@ -438,6 +498,7 @@ void BattleGround::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, flo
     m_TeamStartLocZ[idx] = Z;
     m_TeamStartLocO[idx] = O;
 }
+
 void BattleGround::SendPacketToAll(WorldPacket *packet)
 {
     for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -449,43 +510,54 @@ void BattleGround::SendPacketToAll(WorldPacket *packet)
             sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
     }
 }
+
 void BattleGround::SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender, bool self)
 {
     for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
     {
         Player *plr = objmgr.GetPlayer(itr->first);
+
         if (!plr)
         {
             sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
             continue;
         }
+
         if (!self && sender == plr)
             continue;
+
         uint32 team = itr->second.Team;
         if(!team) team = plr->GetTeam();
+
         if (team == TeamID)
             plr->GetSession()->SendPacket(packet);
     }
 }
+
 void BattleGround::PlaySoundToAll(uint32 SoundID)
 {
     WorldPacket data;
     sBattleGroundMgr.BuildPlaySoundPacket(&data, SoundID);
     SendPacketToAll(&data);
 }
+
 void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
 {
     WorldPacket data;
+
     for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
     {
         Player *plr = objmgr.GetPlayer(itr->first);
+
         if (!plr)
         {
             sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
             continue;
         }
+
         uint32 team = itr->second.Team;
         if(!team) team = plr->GetTeam();
+
         if (team == TeamID)
         {
             sBattleGroundMgr.BuildPlaySoundPacket(&data, SoundID);
@@ -493,22 +565,27 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
         }
     }
 }
+
 void BattleGround::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
 {
     for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
     {
         Player *plr = objmgr.GetPlayer(itr->first);
+
         if (!plr)
         {
             sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
             continue;
         }
+
         uint32 team = itr->second.Team;
         if(!team) team = plr->GetTeam();
+
         if (team == TeamID)
             plr->CastSpell(plr, SpellID, true);
     }
 }
+
 void BattleGround::YellToAll(Creature* creature, const char* text, uint32 language)
 {
     for(std::map::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -525,81 +602,102 @@ void BattleGround::YellToAll(Creature* creature, const char* text, uint32 langua
     }
 }
 
+
 void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID)
 {
     for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
     {
         Player *plr = objmgr.GetPlayer(itr->first);
+
         if (!plr)
         {
             sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
             continue;
         }
+
         uint32 team = itr->second.Team;
         if(!team) team = plr->GetTeam();
+
         if (team == TeamID)
             UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor);
     }
 }
+
 void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID)
 {
     FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
+
     if (!factionEntry)
         return;
+
     for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
     {
         Player *plr = objmgr.GetPlayer(itr->first);
+
         if (!plr)
         {
             sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
             continue;
         }
+
         uint32 team = itr->second.Team;
         if(!team) team = plr->GetTeam();
+
         if (team == TeamID)
             plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation);
     }
 }
+
 void BattleGround::UpdateWorldState(uint32 Field, uint32 Value)
 {
     WorldPacket data;
     sBattleGroundMgr.BuildUpdateWorldStatePacket(&data, Field, Value);
     SendPacketToAll(&data);
 }
+
 void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source)
 {
     WorldPacket data;
     sBattleGroundMgr.BuildUpdateWorldStatePacket(&data, Field, Value);
     Source->GetSession()->SendPacket(&data);
 }
+
 void BattleGround::EndBattleGround(uint32 winner)
 {
     this->RemoveFromBGFreeSlotQueue();
+
     ArenaTeam * winner_arena_team = NULL;
     ArenaTeam * loser_arena_team = NULL;
     uint32 loser_rating = 0;
     uint32 winner_rating = 0;
     WorldPacket data;
     int32 winmsg_id = 0;
+
     if (winner == ALLIANCE)
     {
         winmsg_id = isBattleGround() ? LANG_BG_A_WINS : LANG_ARENA_GOLD_WINS;
+
         PlaySoundToAll(SOUND_ALLIANCE_WINS);                // alliance wins sound
+
         SetWinner(WINNER_ALLIANCE);
     }
     else if (winner == HORDE)
     {
         winmsg_id = isBattleGround() ? LANG_BG_H_WINS : LANG_ARENA_GREEN_WINS;
+
         PlaySoundToAll(SOUND_HORDE_WINS);                   // horde wins sound
+
         SetWinner(WINNER_HORDE);
     }
     else
     {
         SetWinner(3);
     }
+
     SetStatus(STATUS_WAIT_LEAVE);
     //we must set it this way, because end time is sent in packet!
     m_EndTime = TIME_TO_AUTOREMOVE;
+
     // arena rating calculation
     if (isArena() && isRated())
     {
@@ -622,10 +720,12 @@ void BattleGround::EndBattleGround(uint32 winner)
             SetArenaTeamRatingChangeForTeam(HORDE, 0);
         }
     }
+
     for(BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
     {
         Player *plr = objmgr.GetPlayer(itr->first);
         uint32 team = itr->second.Team;
+
         if (!plr)
         {
             //if rated arena match - make member lost!
@@ -639,9 +739,11 @@ void BattleGround::EndBattleGround(uint32 winner)
             sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
             continue;
         }
+
         // should remove spirit of redemption
         if(plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
             plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
+
         if (!plr->isAlive())
         {
             plr->ResurrectPlayer(1.0f);
@@ -652,8 +754,10 @@ void BattleGround::EndBattleGround(uint32 winner)
             plr->CombatStop();
             plr->getHostilRefManager().deleteReferences();
         }
+
         //this line is obsolete - team is set ALWAYS
         //if(!team) team = plr->GetTeam();
+
         // per player calculation
         if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
         {
@@ -663,15 +767,18 @@ void BattleGround::EndBattleGround(uint32 winner)
                 ArenaTeamMember* member = winner_arena_team->GetMember(plr->GetGUID());
                 if (member)
                     plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->personal_rating);
+
                 winner_arena_team->MemberWon(plr,loser_rating);
             }
             else
             {
                 loser_arena_team->MemberLost(plr,winner_rating);
+
                 // Arena lost => reset the win_rated_arena having the "no_loose" condition
                 plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE);
             }
         }
+
         if (team == winner)
         {
             RewardMark(plr,ITEM_WINNER_COUNT);
@@ -680,15 +787,20 @@ void BattleGround::EndBattleGround(uint32 winner)
         }
         else if(winner)
             RewardMark(plr,ITEM_LOSER_COUNT);
+
         plr->CombatStopWithPets(true);
+
         BlockMovement(plr);
+
         sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
         plr->GetSession()->SendPacket(&data);
+
         BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
         sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType());
         plr->GetSession()->SendPacket(&data);
         plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
     }
+
     if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
     {
         // update arena points only after increasing the player's match count!
@@ -702,14 +814,17 @@ void BattleGround::EndBattleGround(uint32 winner)
         winner_arena_team->NotifyStatsChanged();
         loser_arena_team->NotifyStatsChanged();
     }
+
     if (winmsg_id)
         SendMessageToAll(winmsg_id, CHAT_MSG_BG_SYSTEM_NEUTRAL);
 }
+
 uint32 BattleGround::GetBonusHonorFromKill(uint32 kills) const
 {
     //variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
     return MaNGOS::Honor::hk_honor_at_level(GetMaxLevel(), kills);
 }
+
 uint32 BattleGround::GetBattlemasterEntry() const
 {
     switch(GetTypeID())
@@ -722,6 +837,7 @@ uint32 BattleGround::GetBattlemasterEntry() const
         default:              return 0;
     }
 }
+
 void BattleGround::RewardMark(Player *plr,uint32 count)
 {
     BattleGroundMarks mark;
@@ -742,60 +858,75 @@ void BattleGround::RewardMark(Player *plr,uint32 count)
         default:
             return;
     }
+
     //if (IsSpell)
     //    RewardSpellCast(plr,mark);
     //else
         RewardItem(plr,mark,count);
 }
+
 void BattleGround::RewardSpellCast(Player *plr, uint32 spell_id)
 {
     // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
     if (plr->HasAura(SPELL_AURA_PLAYER_INACTIVE))
         return;
+
     SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
     if(!spellInfo)
     {
         sLog.outError("Battleground reward casting spell %u not exist.",spell_id);
         return;
     }
+
     plr->CastSpell(plr, spellInfo, true);
 }
+
 void BattleGround::RewardItem(Player *plr, uint32 item_id, uint32 count)
 {
     // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
     if (plr->HasAura(SPELL_AURA_PLAYER_INACTIVE))
         return;
+
     ItemPosCountVec dest;
     uint32 no_space_count = 0;
     uint8 msg = plr->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item_id, count, &no_space_count );
+
     if( msg == EQUIP_ERR_ITEM_NOT_FOUND)
     {
         sLog.outErrorDb("Battleground reward item (Entry %u) not exist in `item_template`.",item_id);
         return;
     }
+
     if( msg != EQUIP_ERR_OK )                               // convert to possible store amount
         count -= no_space_count;
+
     if( count != 0 && !dest.empty())                        // can add some
         if (Item* item = plr->StoreNewItem( dest, item_id, true, 0))
             plr->SendNewItem(item,count,true,false);
+
     if (no_space_count > 0)
         SendRewardMarkByMail(plr,item_id,no_space_count);
 }
+
 void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count)
 {
     uint32 bmEntry = GetBattlemasterEntry();
     if (!bmEntry)
         return;
+
     ItemPrototype const* markProto = objmgr.GetItemPrototype(mark);
     if (!markProto)
         return;
+
     if (Item* markItem = Item::CreateItem(mark,count,plr))
     {
         // save new item before send
         markItem->SaveToDB();                               // save for prevent lost at next mail load, if send fail then item will deleted
+
         // item
         MailItemsInfo mi;
         mi.AddItem(markItem->GetGUIDLow(), markItem->GetEntry(), markItem);
+
         // subject: item name
         std::string subject = markProto->Name1;
         int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex();
@@ -803,14 +934,17 @@ void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count)
             if (ItemLocale const *il = objmgr.GetItemLocale(markProto->ItemId))
                 if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
                     subject = il->Name[loc_idx];
+
         // text
         std::string textFormat = plr->GetSession()->GetTrinityString(LANG_BG_MARK_BY_MAIL);
         char textBuf[300];
         snprintf(textBuf,300,textFormat.c_str(),GetName(),GetName());
         uint32 itemTextId = objmgr.CreateItemText( textBuf );
+
         WorldSession::SendMailTo(plr, MAIL_CREATURE, MAIL_STATIONERY_NORMAL, bmEntry, plr->GetGUIDLow(), subject, itemTextId , &mi, 0, 0, MAIL_CHECK_MASK_NONE);
     }
 }
+
 void BattleGround::RewardQuestComplete(Player *plr)
 {
     uint32 quest;
@@ -831,12 +965,15 @@ void BattleGround::RewardQuestComplete(Player *plr)
         default:
             return;
     }
+
     RewardSpellCast(plr, quest);
 }
+
 void BattleGround::BlockMovement(Player *plr)
 {
     plr->SetClientControl(plr, 0);                          // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
 }
+
 void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket)
 {
     uint32 team = GetPlayerTeam(guid);
@@ -850,23 +987,30 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
         // check if the player was a participant of the match, or only entered through gm command (goname)
         participant = true;
     }
+
     BattleGroundScoreMap::iterator itr2 = m_PlayerScores.find(guid);
     if (itr2 != m_PlayerScores.end())
     {
         delete itr2->second;                                // delete player's score
         m_PlayerScores.erase(itr2);
     }
+
     RemovePlayerFromResurrectQueue(guid);
+
     Player *plr = objmgr.GetPlayer(guid);
+
     // should remove spirit of redemption
     if(plr && plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
         plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
+
     if(plr && !plr->isAlive())                              // resurrect on exit
     {
         plr->ResurrectPlayer(1.0f);
         plr->SpawnCorpseBones();
     }
+
     RemovePlayer(plr, guid);                                // BG subclass specific code
+
     if(participant) // if the player was a match participant, remove auras, calc rating, update queue
     {
         BattleGroundTypeId bgTypeId = GetTypeID();
@@ -874,15 +1018,19 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
         if (plr)
         {
             plr->ClearAfkReports();
+
             if(!team) team = plr->GetTeam();
+
             // if arena, remove the specific arena auras
             if (isArena())
             {
                 plr->RemoveArenaAuras(true);                // removes debuffs / dots etc., we don't want the player to die after porting out
                 bgTypeId=BATTLEGROUND_AA;                   // set the bg type to all arenas (it will be used for queue refreshing)
+
                 // unsummon current and summon old pet if there was one and there isn't a current pet
                 plr->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT);
                 plr->ResummonPetTemporaryUnSummonedIfAny();
+
                 if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
                 {
                     //left a rated match while the encounter was in progress, consider as loser
@@ -898,6 +1046,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
                 sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0, 0);
                 plr->GetSession()->SendPacket(&data);
             }
+
             // this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
             plr->RemoveBattleGroundQueueId(bgQueueTypeId);
         }
@@ -913,6 +1062,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
                     players_arena_team->OfflineMemberLost(guid, others_arena_team->GetRating());
             }
         }
+
         // remove from raid group if player is member
         if (Group *group = GetBgRaid(team))
         {
@@ -935,18 +1085,23 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
         sBattleGroundMgr.BuildPlayerLeftBattleGroundPacket(&data, guid);
         SendPacketToTeam(team, &data, plr, false);
     }
+
     if (plr)
     {
         // Do next only if found in battleground
         plr->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE);  // We're not in BG.
         // reset destination bg team
         plr->SetBGTeam(0);
+
         if (Transport)
             plr->TeleportToBGEntryPoint();
+
         sLog.outDetail("BATTLEGROUND: Removed player %s from BattleGround.", plr->GetName());
     }
+
     //battleground object will be deleted next BattleGround::Update() call
 }
+
 // this method is called when no players remains in battleground
 void BattleGround::Reset()
 {
@@ -958,24 +1113,32 @@ void BattleGround::Reset()
     SetLastResurrectTime(0);
     SetArenaType(0);
     SetRated(false);
+
     m_Events = 0;
+
     if (m_InvitedAlliance > 0 || m_InvitedHorde > 0)
         sLog.outError("BattleGround system: bad counter, m_InvitedAlliance: %d, m_InvitedHorde: %d", m_InvitedAlliance, m_InvitedHorde);
+
     m_InvitedAlliance = 0;
     m_InvitedHorde = 0;
     m_InBGFreeSlotQueue = false;
+
     m_Players.clear();
+
     for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr)
         delete itr->second;
     m_PlayerScores.clear();
+
     ResetBGSubclass();
 }
+
 void BattleGround::StartBattleGround()
 {
     SetStartTime(0);
     SetLastResurrectTime(0);
     // add BG to free slot queue
     AddToBGFreeSlotQueue();
+
     // add bg to update list
     // This must be done here, because we need to have already invited some players when first BG::Update() method is executed
     // and it doesn't matter if we call StartBattleGround() more times, because m_BattleGrounds is a map and instance id never changes
@@ -983,23 +1146,31 @@ void BattleGround::StartBattleGround()
     if(m_IsRated)
         sLog.outArena("Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE]);
 }
+
 void BattleGround::AddPlayer(Player *plr)
 {
     // remove afk from player
     if (plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK))
         plr->ToggleAFK();
+
     // score struct must be created in inherited class
+
     uint64 guid = plr->GetGUID();
     uint32 team = plr->GetBGTeam();
+
     BattleGroundPlayer bp;
     bp.OfflineRemoveTime = 0;
     bp.Team = team;
+
     // Add to list/maps
     m_Players[guid] = bp;
+
     UpdatePlayersCountByTeam(team, false);                  // +1 player
+
     WorldPacket data;
     sBattleGroundMgr.BuildPlayerJoinedBattleGroundPacket(&data, plr);
     SendPacketToTeam(team, &data, plr, false);
+
     // add arena specific auras
     if (isArena())
     {
@@ -1020,11 +1191,14 @@ void BattleGround::AddPlayer(Player *plr)
             else
                 plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG,true);
         }
+
         plr->DestroyConjuredItems(true);
         plr->UnsummonPetTemporaryIfAny();
+
         if(GetStatus() == STATUS_WAIT_JOIN)                 // not started yet
         {
             plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true);
+
             plr->SetHealth(plr->GetMaxHealth());
             plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA));
         }
@@ -1034,14 +1208,18 @@ void BattleGround::AddPlayer(Player *plr)
         if(GetStatus() == STATUS_WAIT_JOIN)                 // not started yet
             plr->CastSpell(plr, SPELL_PREPARATION, true);   // reduces all mana cost of spells.
     }
+
     plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_CONDITION_MAP, GetMapId());
     plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_CONDITION_MAP, GetMapId());
+
     // setup BG group membership
     PlayerAddedToBGCheckIfBGIsRunning(plr);
     AddOrSetPlayerToCorrectBgGroup(plr, guid, team);
+
     // Log
     sLog.outDetail("BATTLEGROUND: Player %s joined the battle.", plr->GetName());
 }
+
 /* this method adds player to his team's bg group, or sets his correct group if player is already in bg group */
 void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid, uint32 team)
 {
@@ -1068,6 +1246,7 @@ void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid,
         }
     }
 }
+
 // This method should be called when player logs into running battleground
 void BattleGround::EventPlayerLoggedIn(Player* player, uint64 plr_guid)
 {
@@ -1085,6 +1264,7 @@ void BattleGround::EventPlayerLoggedIn(Player* player, uint64 plr_guid)
     // if battleground is starting, then add preparation aura
     // we don't have to do that, because preparation aura isn't removed when player logs out
 }
+
 // This method should be called when player logs out from running battleground
 void BattleGround::EventPlayerLoggedOut(Player* player)
 {
@@ -1103,6 +1283,7 @@ void BattleGround::EventPlayerLoggedOut(Player* player)
         }
     }
 }
+
 /* This method should be called only once ... it adds pointer to queue */
 void BattleGround::AddToBGFreeSlotQueue()
 {
@@ -1113,6 +1294,7 @@ void BattleGround::AddToBGFreeSlotQueue()
         m_InBGFreeSlotQueue = true;
     }
 }
+
 /* This method removes this battleground from free queue - it must be called when deleting battleground - not used now*/
 void BattleGround::RemoveFromBGFreeSlotQueue()
 {
@@ -1128,6 +1310,7 @@ void BattleGround::RemoveFromBGFreeSlotQueue()
         }
     }
 }
+
 // get the number of free slots for team
 // returns the number how many players can join battleground to MaxPlayersPerTeam
 uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
@@ -1159,6 +1342,7 @@ uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
         // allow join more ppl if the other side has more players
         else if(otherTeam > GetInvitedCount(Team))
             diff = otherTeam - GetInvitedCount(Team);
+
         // difference based on max players per team (don't allow inviting more)
         uint32 diff2 = (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0;
         // difference based on players who already entered
@@ -1173,7 +1357,9 @@ uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
         // or other side has less than minPlayersPerTeam
         else if (GetInvitedCount(Team) <= GetMinPlayersPerTeam())
             diff3 = GetMinPlayersPerTeam() - GetInvitedCount(Team) + 1;
+
         // return the minimum of the 3 differences
+
         // min of diff and diff 2
         diff = diff < diff2 ? diff : diff2;
         // min of diff, diff2 and diff3
@@ -1181,16 +1367,20 @@ uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
     }
     return 0;
 }
+
 bool BattleGround::HasFreeSlots() const
 {
     return GetPlayersSize() < GetMaxPlayers();
 }
+
 void BattleGround::UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
 {
     //this procedure is called from virtual function implemented in bg subclass
     BattleGroundScoreMap::const_iterator itr = m_PlayerScores.find(Source->GetGUID());
+
     if(itr == m_PlayerScores.end())                         // player not found...
         return;
+
     switch(type)
     {
         case SCORE_KILLING_BLOWS:                           // Killing blows
@@ -1223,14 +1413,18 @@ void BattleGround::UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
             break;
     }
 }
+
 void BattleGround::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid)
 {
     m_ReviveQueue[npc_guid].push_back(player_guid);
+
     Player *plr = objmgr.GetPlayer(player_guid);
     if (!plr)
         return;
+
     plr->CastSpell(plr, SPELL_WAITING_FOR_RESURRECT, true);
 }
+
 void BattleGround::RemovePlayerFromResurrectQueue(uint64 player_guid)
 {
     for(std::map >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
@@ -1240,20 +1434,25 @@ void BattleGround::RemovePlayerFromResurrectQueue(uint64 player_guid)
             if (*itr2 == player_guid)
             {
                 (itr->second).erase(itr2);
+
                 Player *plr = objmgr.GetPlayer(player_guid);
                 if (!plr)
                     return;
+
                 plr->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
+
                 return;
             }
         }
     }
 }
+
 bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
 {
     Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID());
     if (!map)
         return false;
+
     // must be created this way, adding to godatamap would add it to the base map of the instance
     // and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
     // so we must create it specific for this instance
@@ -1268,9 +1467,11 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float
     }
 /*
     uint32 guid = go->GetGUIDLow();
+
     // without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
     // iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed
     GameObjectData& data = objmgr.NewGOData(guid);
+
     data.id             = entry;
     data.mapid          = GetMapId();
     data.posX           = x;
@@ -1291,6 +1492,7 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float
     m_BgObjects[type] = go->GetGUID();
     return true;
 }
+
 //some doors aren't despawned so we cannot handle their closing in gameobject::update()
 //it would be nice to correctly implement GO_ACTIVATED state and open/close doors in gameobject code
 void BattleGround::DoorClose(uint32 type)
@@ -1311,6 +1513,7 @@ void BattleGround::DoorClose(uint32 type)
         sLog.outError("BattleGround: Door object not found (cannot close doors)");
     }
 }
+
 void BattleGround::DoorOpen(uint32 type)
 {
     GameObject *obj = HashMapHolder::Find(m_BgObjects[type]);
@@ -1325,6 +1528,7 @@ void BattleGround::DoorOpen(uint32 type)
         sLog.outError("BattleGround: Door object not found! - doors will be closed.");
     }
 }
+
 GameObject* BattleGround::GetBGObject(uint32 type)
 {
     GameObject *obj = HashMapHolder::Find(m_BgObjects[type]);
@@ -1332,6 +1536,7 @@ GameObject* BattleGround::GetBGObject(uint32 type)
         sLog.outError("couldn't get gameobject %i",type);
     return obj;
 }
+
 Creature* BattleGround::GetBGCreature(uint32 type)
 {
     Creature *creature = HashMapHolder::Find(m_BgCreatures[type]);
@@ -1339,6 +1544,7 @@ Creature* BattleGround::GetBGCreature(uint32 type)
         sLog.outError("couldn't get creature %i",type);
     return creature;
 }
+
 void BattleGround::SpawnBGObject(uint32 type, uint32 respawntime)
 {
     Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID());
@@ -1367,11 +1573,13 @@ void BattleGround::SpawnBGObject(uint32 type, uint32 respawntime)
         }
     }
 }
+
 Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, float x, float y, float z, float o, uint32 respawntime)
 {
     Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID());
     if (!map)
         return NULL;
+
     Creature* pCreature = new Creature;
     if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, teamval, x, y, z, o))
     {
@@ -1379,10 +1587,14 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
         delete pCreature;
         return NULL;
     }
+
     pCreature->SetHomePosition(x, y, z, o);
+
     //pCreature->SetDungeonDifficulty(0);
+
     map->Add(pCreature);
     m_BgCreatures[type] = pCreature->GetGUID();
+
     return  pCreature;
 }
 /*
@@ -1391,6 +1603,7 @@ void BattleGround::SpawnBGCreature(uint32 type, uint32 respawntime)
     Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceId());
     if (!map)
         return false;
+
     if (respawntime == 0)
     {
         Creature *obj = HashMapHolder::Find(m_BgCreatures[type]);
@@ -1418,6 +1631,7 @@ bool BattleGround::DelCreature(uint32 type)
 {
     if (!m_BgCreatures[type])
         return true;
+
     Creature *cr = HashMapHolder::Find(m_BgCreatures[type]);
     if (!cr)
     {
@@ -1428,10 +1642,12 @@ bool BattleGround::DelCreature(uint32 type)
     m_BgCreatures[type] = 0;
     return true;
 }
+
 bool BattleGround::DelObject(uint32 type)
 {
     if (!m_BgObjects[type])
         return true;
+
     GameObject *obj = HashMapHolder::Find(m_BgObjects[type]);
     if (!obj)
     {
@@ -1443,13 +1659,16 @@ bool BattleGround::DelObject(uint32 type)
     m_BgObjects[type] = 0;
     return true;
 }
+
 bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float o, uint32 team)
 {
     uint32 entry = 0;
+
     if (team == ALLIANCE)
         entry = BG_CREATURE_ENTRY_A_SPIRITGUIDE;
     else
         entry = BG_CREATURE_ENTRY_H_SPIRITGUIDE;
+
     Creature* pCreature = AddCreature(entry,type,team,x,y,z,o);
     if (!pCreature)
     {
@@ -1457,11 +1676,14 @@ bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float
         EndNow();
         return false;
     }
+
     pCreature->setDeathState(DEAD);
+
     pCreature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, pCreature->GetGUID());
     // aura
     //TODO: Fix display here
     //pCreature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL);
+
     //pCreature->SetUInt32Value(UNIT_FIELD_AURAFLAGS, 0x00000009);
     //pCreature->SetUInt32Value(UNIT_FIELD_AURALEVELS, 0x0000003C);
     //pCreature->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS, 0x000000FF);
@@ -1469,42 +1691,52 @@ bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float
     pCreature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SPIRIT_HEAL_CHANNEL);
     // correct cast speed
     pCreature->SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
+
     //pCreature->CastSpell(pCreature, SPELL_SPIRIT_HEAL_CHANNEL, true);
+
     return true;
 }
+
 void BattleGround::SendMessageToAll(int32 entry, ChatMsg type, Player const* source)
 {
     MaNGOS::BattleGroundChatBuilder bg_builder(type, entry, source);
     MaNGOS::LocalizedPacketDo bg_do(bg_builder);
     BroadcastWorker(bg_do);
 }
+
 void BattleGround::PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...)
 {
     va_list ap;
     va_start(ap, source);
+
     MaNGOS::BattleGroundChatBuilder bg_builder(type, entry, source, &ap);
     MaNGOS::LocalizedPacketDo bg_do(bg_builder);
     BroadcastWorker(bg_do);
+
     va_end(ap);
 }
+
 void BattleGround::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 arg1, int32 arg2)
 {
     MaNGOS::BattleGround2ChatBuilder bg_builder(type, entry, source, arg1, arg2);
     MaNGOS::LocalizedPacketDo bg_do(bg_builder);
     BroadcastWorker(bg_do);
 }
+
 void BattleGround::EndNow()
 {
     RemoveFromBGFreeSlotQueue();
     SetStatus(STATUS_WAIT_LEAVE);
     SetEndTime(0);
 }
+
 //to be removed
 const char *BattleGround::GetTrinityString(int32 entry)
 {
     // FIXME: now we have different DBC locales and need localized message for each target client
     return objmgr.GetTrinityStringForDBCLocale(entry);
 }
+
 /*
 important notice:
 buffs aren't spawned/despawned when players captures anything
@@ -1515,6 +1747,7 @@ void BattleGround::HandleTriggerBuff(uint64 const& go_guid)
     GameObject *obj = HashMapHolder::Find(go_guid);
     if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned())
         return;
+
     //change buff type, when buff is used:
     int32 index = m_BgObjects.size() - 1;
     while (index >= 0 && m_BgObjects[index] != go_guid)
@@ -1524,6 +1757,7 @@ void BattleGround::HandleTriggerBuff(uint64 const& go_guid)
         sLog.outError("BattleGround (Type: %u) has buff gameobject (Guid: %u Entry: %u Type:%u) but it hasn't that object in its internal data",GetTypeID(),GUID_LOPART(go_guid),obj->GetEntry(),obj->GetGoType());
         return;
     }
+
     //randomly select new buff
     uint8 buff = urand(0, 2);
     uint32 entry = obj->GetEntry();
@@ -1539,31 +1773,40 @@ void BattleGround::HandleTriggerBuff(uint64 const& go_guid)
                 index += buff;
             }
     }
+
     SpawnBGObject(index, BUFF_RESPAWN_TIME);
 }
+
 void BattleGround::HandleKillPlayer( Player *player, Player *killer )
 {
     //keep in mind that for arena this will have to be changed a bit
+
     // add +1 deaths
     UpdatePlayerScore(player, SCORE_DEATHS, 1);
+
     // add +1 kills to group and +1 killing_blows to killer
     if (killer)
     {
         UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1);
         UpdatePlayerScore(killer, SCORE_KILLING_BLOWS, 1);
+
         for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
         {
             Player *plr = objmgr.GetPlayer(itr->first);
+
             if (!plr || plr == killer)
                 continue;
+
             if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player))
                 UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1);
         }
     }
+
     // to be able to remove insignia -- ONLY IN BattleGrounds
     if (!isArena())
         player->SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE );
 }
+
 // return the player's team based on battlegroundplayer info
 // used in same faction arena matches mainly
 uint32 BattleGround::GetPlayerTeam(uint64 guid)
@@ -1573,10 +1816,12 @@ uint32 BattleGround::GetPlayerTeam(uint64 guid)
         return itr->second.Team;
     return 0;
 }
+
 uint32 BattleGround::GetOtherTeam(uint32 teamId)
 {
     return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0;
 }
+
 bool BattleGround::IsPlayerInBattleGround(uint64 guid)
 {
     BattleGroundPlayerMap::const_iterator itr = m_Players.find(guid);
@@ -1584,18 +1829,24 @@ bool BattleGround::IsPlayerInBattleGround(uint64 guid)
         return true;
     return false;
 }
+
 void BattleGround::PlayerAddedToBGCheckIfBGIsRunning(Player* plr)
 {
     if (GetStatus() != STATUS_WAIT_LEAVE)
         return;
+
     WorldPacket data;
     BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
+
     BlockMovement(plr);
+
     sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
     plr->GetSession()->SendPacket(&data);
+
     sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType());
     plr->GetSession()->SendPacket(&data);
 }
+
 uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const
 {
     int count = 0;
@@ -1610,6 +1861,7 @@ uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const
     }
     return count;
 }
+
 void BattleGround::SetHoliday(bool is_holiday)
 {
     if(is_holiday)
@@ -1617,6 +1869,7 @@ void BattleGround::SetHoliday(bool is_holiday)
     else
         m_HonorMode = BG_NORMAL;
 }
+
 int32 BattleGround::GetObjectType(uint64 guid)
 {
     for(uint32 i = 0; i < m_BgObjects.size(); ++i)
@@ -1625,9 +1878,11 @@ int32 BattleGround::GetObjectType(uint64 guid)
     sLog.outError("BattleGround: cheating? a player used a gameobject which isnt supposed to be a usable object!");
     return -1;
 }
+
 void BattleGround::HandleKillUnit(Creature *creature, Player *killer)
 {
 }
+
 void BattleGround::CheckArenaWinConditions()
 {
     if (!GetAlivePlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE))
@@ -1635,6 +1890,7 @@ void BattleGround::CheckArenaWinConditions()
     else if (GetPlayersCountByTeam(ALLIANCE) && !GetAlivePlayersCountByTeam(HORDE))
         EndBattleGround(ALLIANCE);
 }
+
 void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid )
 {
     Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE];
@@ -1642,10 +1898,12 @@ void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid )
     if(bg_raid) bg_raid->SetBattlegroundGroup(this);
     old_raid = bg_raid;
 }
+
 WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard( Player* player )
 {
     return objmgr.GetClosestGraveYard( player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam() );
 }
+
 bool BattleGround::IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const
 {
     BattleGroundTeamId team_idx = GetTeamIndexByTeamId(team);
diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h
index cb19fd92525..007f7a642dd 100644
--- a/src/game/BattleGround.h
+++ b/src/game/BattleGround.h
@@ -17,16 +17,21 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef __BATTLEGROUND_H
 #define __BATTLEGROUND_H
+
 #include "Common.h"
 #include "SharedDefines.h"
+
 class Creature;
 class GameObject;
 class Group;
 class Player;
 class WorldPacket;
+
 struct WorldSafeLocsEntry;
+
 enum BattleGroundSounds
 {
     SOUND_HORDE_WINS                = 8454,
@@ -34,6 +39,7 @@ enum BattleGroundSounds
     SOUND_BG_START                  = 3439,
     SOUND_BG_START_L70ETC           = 11803,
 };
+
 enum BattleGroundQuests
 {
     SPELL_WS_QUEST_REWARD           = 43483,
@@ -44,6 +50,7 @@ enum BattleGroundQuests
     SPELL_AB_QUEST_REWARD_4_BASES   = 24061,
     SPELL_AB_QUEST_REWARD_5_BASES   = 24064
 };
+
 enum BattleGroundMarks
 {
     SPELL_WS_MARK_LOSER             = 24950,
@@ -57,16 +64,19 @@ enum BattleGroundMarks
     ITEM_AB_MARK_OF_HONOR           = 20559,
     ITEM_EY_MARK_OF_HONOR           = 29024
 };
+
 enum BattleGroundMarksCount
 {
     ITEM_WINNER_COUNT               = 3,
     ITEM_LOSER_COUNT                = 1
 };
+
 enum BattleGroundCreatures
 {
     BG_CREATURE_ENTRY_A_SPIRITGUIDE      = 13116,           // alliance
     BG_CREATURE_ENTRY_H_SPIRITGUIDE      = 13117,           // horde
 };
+
 enum BattleGroundSpells
 {
     SPELL_WAITING_FOR_RESURRECT     = 2584,                 // Waiting to Resurrect
@@ -83,6 +93,7 @@ enum BattleGroundSpells
     SPELL_RECENTLY_DROPPED_FLAG     = 42792,                // Recently Dropped Flag
     SPELL_AURA_PLAYER_INACTIVE      = 43681                 // Inactive
 };
+
 enum BattleGroundTimeIntervals
 {
     RESURRECTION_INTERVAL           = 30000,                // ms
@@ -95,6 +106,7 @@ enum BattleGroundTimeIntervals
     RESPAWN_IMMEDIATELY             = 0,                    // secs
     BUFF_RESPAWN_TIME               = 180,                  // secs
 };
+
 enum BattleGroundStartTimeIntervals
 {
     BG_START_DELAY_2M               = 120000,               // ms (2 minutes)
@@ -103,13 +115,16 @@ enum BattleGroundStartTimeIntervals
     BG_START_DELAY_15S              = 15000,                // ms (15 seconds) Used only in arena
     BG_START_DELAY_NONE             = 0,                    // ms
 };
+
 enum BattleGroundBuffObjects
 {
     BG_OBJECTID_SPEEDBUFF_ENTRY     = 179871,
     BG_OBJECTID_REGENBUFF_ENTRY     = 179904,
     BG_OBJECTID_BERSERKERBUFF_ENTRY = 179905
 };
+
 const uint32 Buff_Entries[3] = { BG_OBJECTID_SPEEDBUFF_ENTRY, BG_OBJECTID_REGENBUFF_ENTRY, BG_OBJECTID_BERSERKERBUFF_ENTRY };
+
 enum BattleGroundStatus
 {
     STATUS_NONE         = 0,                                // first status, should mean bg is not instance
@@ -118,18 +133,22 @@ enum BattleGroundStatus
     STATUS_IN_PROGRESS  = 3,                                // means bg is running
     STATUS_WAIT_LEAVE   = 4                                 // means some faction has won BG and it is ending
 };
+
 struct BattleGroundPlayer
 {
     time_t  OfflineRemoveTime;                              // for tracking and removing offline players from queue after 5 minutes
     uint32  Team;                                           // Player's team
 };
+
 struct BattleGroundObjectInfo
 {
     BattleGroundObjectInfo() : object(NULL), timer(0), spellid(0) {}
+
     GameObject  *object;
     int32       timer;
     uint32      spellid;
 };
+
 // handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time
 enum BattleGroundQueueTypeId
 {
@@ -144,6 +163,7 @@ enum BattleGroundQueueTypeId
     BATTLEGROUND_QUEUE_5v5      = 8
 };
 #define MAX_BATTLEGROUND_QUEUE_TYPES 9
+
 enum BGQueueIdBasedOnLevel                        // queue_id for level ranges
 {
     QUEUE_ID_MAX_LEVEL_19   = 0,
@@ -156,6 +176,7 @@ enum BGQueueIdBasedOnLevel                        // queue_id for level ranges
     QUEUE_ID_MAX_LEVEL_80   = 7
 };
 #define MAX_BATTLEGROUND_QUEUES 8
+
 enum ScoreType
 {
     SCORE_KILLING_BLOWS         = 1,
@@ -181,29 +202,34 @@ enum ScoreType
     SCORE_SECONDARY_OBJECTIVES  = 17
     // TODO : implement them
 };
+
 enum ArenaType
 {
     ARENA_TYPE_2v2          = 2,
     ARENA_TYPE_3v3          = 3,
     ARENA_TYPE_5v5          = 5
 };
+
 enum BattleGroundType
 {
     TYPE_BATTLEGROUND     = 3,
     TYPE_ARENA            = 4
 };
+
 enum BattleGroundWinner
 {
     WINNER_HORDE            = 0,
     WINNER_ALLIANCE         = 1,
     WINNER_NONE             = 2
 };
+
 enum BattleGroundTeamId
 {
     BG_TEAM_ALLIANCE        = 0,
     BG_TEAM_HORDE           = 1
 };
 #define BG_TEAMS_COUNT  2
+
 enum BattleGroundStartingEvents
 {
     BG_STARTING_EVENT_NONE  = 0x00,
@@ -212,6 +238,7 @@ enum BattleGroundStartingEvents
     BG_STARTING_EVENT_3     = 0x04,
     BG_STARTING_EVENT_4     = 0x08
 };
+
 enum BattleGroundStartingEventsIds
 {
     BG_STARTING_EVENT_FIRST     = 0,
@@ -220,6 +247,7 @@ enum BattleGroundStartingEventsIds
     BG_STARTING_EVENT_FOURTH    = 3
 };
 #define BG_STARTING_EVENT_COUNT 4
+
 enum BattleGroundJoinError
 {
     BG_JOIN_ERR_OK = 0,
@@ -233,6 +261,7 @@ enum BattleGroundJoinError
     BG_JOIN_ERR_ALL_QUEUES_USED = 8,
     BG_JOIN_ERR_GROUP_NOT_ENOUGH = 9
 };
+
 class BattleGroundScore
 {
     public:
@@ -240,6 +269,7 @@ class BattleGroundScore
             BonusHonor(0), DamageDone(0), HealingDone(0)
         {}
         virtual ~BattleGroundScore() {}                     //virtual destructor is used when deleting score from scores map
+
         uint32 KillingBlows;
         uint32 Deaths;
         uint32 HonorableKills;
@@ -247,12 +277,14 @@ class BattleGroundScore
         uint32 DamageDone;
         uint32 HealingDone;
 };
+
 enum BGHonorMode
 {
     BG_NORMAL = 0,
     BG_HOLIDAY,
     BG_HONOR_MODE_NUM
 };
+
 /*
 This class is used to:
 1. Add player to battleground
@@ -263,6 +295,7 @@ This class is used to:
 class BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         /* Construction */
         BattleGround();
@@ -279,9 +312,11 @@ class BattleGround
         virtual void ResetBGSubclass()                      // must be implemented in BG subclass
         {
         }
+
         /* achievement req. */
         virtual bool IsAllNodesConrolledByTeam(uint32 /*team*/) const { return false; }
         bool IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const;
+
         /* Battleground */
         // Get methods:
         char const* GetName() const         { return m_Name; }
@@ -295,15 +330,19 @@ class BattleGround
         uint32 GetLastResurrectTime() const { return m_LastResurrectTime; }
         uint32 GetMaxPlayers() const        { return m_MaxPlayers; }
         uint32 GetMinPlayers() const        { return m_MinPlayers; }
+
         uint32 GetMinLevel() const          { return m_LevelMin; }
         uint32 GetMaxLevel() const          { return m_LevelMax; }
+
         uint32 GetMaxPlayersPerTeam() const { return m_MaxPlayersPerTeam; }
         uint32 GetMinPlayersPerTeam() const { return m_MinPlayersPerTeam; }
+
         int32 GetStartDelayTime() const     { return m_StartDelayTime; }
         uint8 GetArenaType() const          { return m_ArenaType; }
         uint8 GetWinner() const             { return m_Winner; }
         uint32 GetBattlemasterEntry() const;
         uint32 GetBonusHonorFromKill(uint32 kills) const;
+
         // Set methods:
         void SetName(char const* Name)      { m_Name = Name; }
         void SetTypeID(BattleGroundTypeId TypeID) { m_TypeID = TypeID; }
@@ -327,12 +366,16 @@ class BattleGround
         void SetArenaType(uint8 type)       { m_ArenaType = type; }
         void SetArenaorBGType(bool _isArena) { m_IsArena = _isArena; }
         void SetWinner(uint8 winner)        { m_Winner = winner; }
+
         void ModifyStartDelayTime(int diff) { m_StartDelayTime -= diff; }
         void SetStartDelayTime(int Time)    { m_StartDelayTime = Time; }
+
         void SetMaxPlayersPerTeam(uint32 MaxPlayers) { m_MaxPlayersPerTeam = MaxPlayers; }
         void SetMinPlayersPerTeam(uint32 MinPlayers) { m_MinPlayersPerTeam = MinPlayers; }
+
         void AddToBGFreeSlotQueue();                        //this queue will be useful when more battlegrounds instances will be available
         void RemoveFromBGFreeSlotQueue();                   //this method could delete whole BG instance, if another free is available
+
         void DecreaseInvitedCount(uint32 team)      { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; }
         void IncreaseInvitedCount(uint32 team)      { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; }
         uint32 GetInvitedCount(uint32 team) const
@@ -344,25 +387,33 @@ class BattleGround
         }
         bool HasFreeSlots() const;
         uint32 GetFreeSlotsForTeam(uint32 Team) const;
+
         bool isArena() const        { return m_IsArena; }
         bool isBattleGround() const { return !m_IsArena; }
         bool isRated() const        { return m_IsRated; }
+
         typedef std::map BattleGroundPlayerMap;
         BattleGroundPlayerMap const& GetPlayers() const { return m_Players; }
         uint32 GetPlayersSize() const { return m_Players.size(); }
+
         typedef std::map BattleGroundScoreMap;
         BattleGroundScoreMap::const_iterator GetPlayerScoresBegin() const { return m_PlayerScores.begin(); }
         BattleGroundScoreMap::const_iterator GetPlayerScoresEnd() const { return m_PlayerScores.end(); }
         uint32 GetPlayerScoresSize() const { return m_PlayerScores.size(); }
+
         uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); }
+
         void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
         void RemovePlayerFromResurrectQueue(uint64 player_guid);
+
         void StartBattleGround();
+
         GameObject* GetBGObject(uint32 type);
         Creature* GetBGCreature(uint32 type);
         /* Location */
         void SetMapId(uint32 MapID) { m_MapId = MapID; }
         uint32 GetMapId() const { return m_MapId; }
+
         void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O);
         void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const
         {
@@ -372,14 +423,17 @@ class BattleGround
             Z = m_TeamStartLocZ[idx];
             O = m_TeamStartLocO[idx];
         }
+
         /* Packet Transfer */
         // method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!)
         virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
         void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender = NULL, bool self = true);
         void SendPacketToAll(WorldPacket *packet);
         void YellToAll(Creature* creature, const char* text, uint32 language);
+
         template
         void BroadcastWorker(Do& _do);
+
         void PlaySoundToTeam(uint32 SoundID, uint32 TeamID);
         void PlaySoundToAll(uint32 SoundID);
         void CastSpellOnTeam(uint32 SpellID, uint32 TeamID);
@@ -394,14 +448,19 @@ class BattleGround
         void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source);
         void EndBattleGround(uint32 winner);
         void BlockMovement(Player *plr);
+
         void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL);
         void PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...  );
+
         // specialized version with 2 string id args
         void SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 strId1 = 0, int32 strId2 = 0);
+
         /* Raid Group */
         Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; }
         void SetBgRaid(uint32 TeamID, Group *bg_raid);
+
         virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
+
         static BattleGroundTeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; }
         uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; }
         uint32 GetAlivePlayersCountByTeam(uint32 Team) const;   // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases
@@ -412,32 +471,41 @@ class BattleGround
             else
                 ++m_PlayersCount[GetTeamIndexByTeamId(Team)];
         }
+
         // used for rated arena battles
         void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; }
         uint32 GetArenaTeamIdForTeam(uint32 Team) const             { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; }
         void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; }
         int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const    { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; }
         void CheckArenaWinConditions();
+
         /* Triggers handle */
         // must be implemented in BG subclass
         virtual void HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) {}
         // must be implemented in BG subclass if need AND call base class generic code
         virtual void HandleKillPlayer(Player *player, Player *killer);
         virtual void HandleKillUnit(Creature* /*unit*/, Player* /*killer*/);
+
         /* Battleground events */
         virtual void EventPlayerDroppedFlag(Player* /*player*/) {}
         virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {}
         virtual void EventPlayerCapturedFlag(Player* /*player*/) {}
         void EventPlayerLoggedIn(Player* player, uint64 plr_guid);
         void EventPlayerLoggedOut(Player* player);
+
         /* Death related */
         virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
+
         virtual void AddPlayer(Player *plr);                // must be implemented in BG subclass
+
         void AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid, uint32 team);
+
         virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket);
                                                             // can be extended in in BG subclass
+
         void HandleTriggerBuff(uint64 const& go_guid);
         void SetHoliday(bool is_holiday);
+
         // TODO: make this protected:
         typedef std::vector BGObjects;
         typedef std::vector BGCreatures;
@@ -451,30 +519,40 @@ class BattleGround
         bool DelObject(uint32 type);
         bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, uint32 team);
         int32 GetObjectType(uint64 guid);
+
         void DoorOpen(uint32 type);
         void DoorClose(uint32 type);
         //to be removed
         const char *GetTrinityString(int32 entry);
+
         virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; }
+
         // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
         uint32 GetPlayerTeam(uint64 guid);
         uint32 GetOtherTeam(uint32 teamId);
         bool IsPlayerInBattleGround(uint64 guid);
+
         void SetDeleteThis() {m_SetDeleteThis = true;}
+
         /* virtual score-array - get's used in bg-subclasses */
         int32 m_TeamScores[BG_TEAMS_COUNT];
+
     protected:
         //this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends BattleGround
         void EndNow();
         void PlayerAddedToBGCheckIfBGIsRunning(Player* plr);
+
         /* Scorekeeping */
+                                                            
         BattleGroundScoreMap m_PlayerScores;                // Player scores
         // must be implemented in BG subclass
         virtual void RemovePlayer(Player * /*player*/, uint64 /*guid*/) {}
+
         /* Player lists, those need to be accessible by inherited classes */
         BattleGroundPlayerMap  m_Players;
                                                             // Spirit Guide guid + Player list GUIDS
         std::map >  m_ReviveQueue;
+
         /*
         these are important variables used for starting messages
         */
@@ -482,7 +560,9 @@ class BattleGround
         BattleGroundStartTimeIntervals  m_StartDelayTimes[BG_STARTING_EVENT_COUNT];
         //this must be filled in constructors!
         uint32 m_StartMessageIds[BG_STARTING_EVENT_COUNT];
+
         bool   m_BuffChange;
+
         BGHonorMode m_HonorMode;
     private:
         /* Battleground */
@@ -504,21 +584,28 @@ class BattleGround
         bool   m_PrematureCountDown;
         uint32 m_PrematureCountDownTimer;
         char const *m_Name;
+
         /* Player lists */
         std::vector m_ResurrectQueue;               // Player GUID
         std::deque m_OfflineQueue;                  // Player GUID
+
         /* Invited counters are useful for player invitation to BG - do not allow, if BG is started to one faction to have 2 more players than another faction */
         /* Invited counters will be changed only when removing already invited player from queue, removing player from battleground and inviting player to BG */
         /* Invited players counters*/
         uint32 m_InvitedAlliance;
         uint32 m_InvitedHorde;
+
         /* Raid Group */
         Group *m_BgRaids[BG_TEAMS_COUNT];                                // 0 - alliance, 1 - horde
+
         /* Players count by team */
         uint32 m_PlayersCount[BG_TEAMS_COUNT];
+
         /* Arena team ids by team */
         uint32 m_ArenaTeamIds[BG_TEAMS_COUNT];
+
         int32 m_ArenaTeamRatingChanges[BG_TEAMS_COUNT];
+
         /* Limits */
         uint32 m_LevelMin;
         uint32 m_LevelMax;
@@ -526,6 +613,7 @@ class BattleGround
         uint32 m_MaxPlayers;
         uint32 m_MinPlayersPerTeam;
         uint32 m_MinPlayers;
+
         /* Start location */
         uint32 m_MapId;
         float m_TeamStartLocX[BG_TEAMS_COUNT];
diff --git a/src/game/BattleGroundAA.cpp b/src/game/BattleGroundAA.cpp
index 4122325cd66..6133508ece1 100644
--- a/src/game/BattleGroundAA.cpp
+++ b/src/game/BattleGroundAA.cpp
@@ -17,12 +17,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "BattleGround.h"
 #include "BattleGroundAA.h"
 #include "Language.h"
 #include "Player.h"
+
 BattleGroundAA::BattleGroundAA()
 {
+
     m_StartDelayTimes[BG_STARTING_EVENT_FIRST]  = BG_START_DELAY_1M;
     m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
     m_StartDelayTimes[BG_STARTING_EVENT_THIRD]  = BG_START_DELAY_15S;
@@ -33,36 +36,47 @@ BattleGroundAA::BattleGroundAA()
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_ARENA_FIFTEEN_SECONDS;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
 }
+
 BattleGroundAA::~BattleGroundAA()
 {
+
 }
+
 void BattleGroundAA::Update(uint32 diff)
 {
     BattleGround::Update(diff);
 }
+
 void BattleGroundAA::StartingEventCloseDoors()
 {
 }
+
 void BattleGroundAA::StartingEventOpenDoors()
 {
 }
+
 void BattleGroundAA::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in constructor
     BattleGroundAAScore* sc = new BattleGroundAAScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
 }
+
 void BattleGroundAA::RemovePlayer(Player * /*plr*/, uint64 /*guid*/)
 {
 }
+
 void BattleGroundAA::HandleKillPlayer(Player* player, Player* killer)
 {
     BattleGround::HandleKillPlayer(player, killer);
 }
+
 void BattleGroundAA::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/)
 {
 }
+
 bool BattleGroundAA::SetupBattleGround()
 {
     return true;
diff --git a/src/game/BattleGroundAA.h b/src/game/BattleGroundAA.h
index 241a1ba73c1..06793ea38e0 100644
--- a/src/game/BattleGroundAA.h
+++ b/src/game/BattleGroundAA.h
@@ -19,7 +19,9 @@
  */
 #ifndef __BATTLEGROUNDAA_H
 #define __BATTLEGROUNDAA_H
+
 class BattleGround;
+
 class BattleGroundAAScore : public BattleGroundScore
 {
     public:
@@ -27,17 +29,21 @@ class BattleGroundAAScore : public BattleGroundScore
         virtual ~BattleGroundAAScore() {};
         //TODO fix me
 };
+
 class BattleGroundAA : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundAA();
         ~BattleGroundAA();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         void RemovePlayer(Player *plr, uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         bool SetupBattleGround();
diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp
index 16eda4b9e94..6609c3400be 100644
--- a/src/game/BattleGroundAB.cpp
+++ b/src/game/BattleGroundAB.cpp
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "World.h"
 #include "WorldPacket.h"
 #include "ObjectMgr.h"
@@ -28,34 +29,42 @@
 #include "Object.h"
 #include "Player.h"
 #include "Util.h"
+
 // these variables aren't used outside of this file, so declare them only here
 uint32 BG_AB_HonorScoreTicks[BG_HONOR_MODE_NUM] = {
     330, // normal honor
     200  // holiday
 };
+
 uint32 BG_AB_ReputationScoreTicks[BG_HONOR_MODE_NUM] = {
     200, // normal honor
     150  // holiday
 };
+
 BattleGroundAB::BattleGroundAB()
 {
     m_BuffChange = true;
     m_BgObjects.resize(BG_AB_OBJECT_MAX);
     m_BgCreatures.resize(BG_AB_ALL_NODES_COUNT);
+
     m_StartMessageIds[BG_STARTING_EVENT_FIRST]  = LANG_BG_AB_START_TWO_MINUTES;
     m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_AB_START_ONE_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_BG_AB_START_HALF_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_AB_HAS_BEGUN;
 }
+
 BattleGroundAB::~BattleGroundAB()
 {
 }
+
 void BattleGroundAB::Update(uint32 diff)
 {
     BattleGround::Update(diff);
+
     if (GetStatus() == STATUS_IN_PROGRESS)
     {
         int team_points[BG_TEAMS_COUNT] = { 0, 0 };
+
         for (int node = 0; node < BG_AB_DYNAMIC_NODES_COUNT; ++node)
         {
             // 3 sec delay to spawn new banner instead previous despawned one
@@ -69,6 +78,7 @@ void BattleGroundAB::Update(uint32 diff)
                     _CreateBanner(node, m_BannerTimers[node].type, m_BannerTimers[node].teamIndex, false);
                 }
             }
+
             // 1-minute to occupy a node from contested state
             if (m_NodeTimers[node])
             {
@@ -88,6 +98,7 @@ void BattleGroundAB::Update(uint32 diff)
                     _SendNodeUpdate(node);
                     _NodeOccupied(node,(teamIndex == 0) ? ALLIANCE:HORDE);
                     // Message to chatlog
+
                     if (teamIndex == 0)
                     {
                         // FIXME: team and node names not localized
@@ -102,10 +113,12 @@ void BattleGroundAB::Update(uint32 diff)
                     }
                 }
             }
+
             for (int team = 0; team < BG_TEAMS_COUNT; ++team)
                 if (m_Nodes[node] == team + BG_AB_NODE_TYPE_OCCUPIED)
                     ++team_points[team];
         }
+
         // Accumulate points
         for (int team = 0; team < BG_TEAMS_COUNT; ++team)
         {
@@ -138,6 +151,7 @@ void BattleGroundAB::Update(uint32 diff)
                     PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY);
                     m_IsInformedNearVictory = true;
                 }
+
                 if (m_TeamScores[team] > BG_AB_MAX_TEAM_SCORE)
                     m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE;
                 if (team == BG_TEAM_ALLIANCE)
@@ -151,6 +165,7 @@ void BattleGroundAB::Update(uint32 diff)
                     m_TeamScores500Disadvantage[otherTeam] = true;
             }
         }
+
         // Test win condition
         if (m_TeamScores[BG_TEAM_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE)
             EndBattleGround(ALLIANCE);
@@ -158,6 +173,7 @@ void BattleGroundAB::Update(uint32 diff)
             EndBattleGround(HORDE);
     }
 }
+
 void BattleGroundAB::StartingEventCloseDoors()
 {
     // despawn banners, auras and buffs
@@ -165,15 +181,18 @@ void BattleGroundAB::StartingEventCloseDoors()
         SpawnBGObject(obj, RESPAWN_ONE_DAY);
     for (int i = 0; i < BG_AB_DYNAMIC_NODES_COUNT * 3; ++i)
         SpawnBGObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + i, RESPAWN_ONE_DAY);
+
     // Starting doors
     DoorClose(BG_AB_OBJECT_GATE_A);
     DoorClose(BG_AB_OBJECT_GATE_H);
     SpawnBGObject(BG_AB_OBJECT_GATE_A, RESPAWN_IMMEDIATELY);
     SpawnBGObject(BG_AB_OBJECT_GATE_H, RESPAWN_IMMEDIATELY);
+
     // Starting base spirit guides
     _NodeOccupied(BG_AB_SPIRIT_ALIANCE,ALLIANCE);
     _NodeOccupied(BG_AB_SPIRIT_HORDE,HORDE);
 }
+
 void BattleGroundAB::StartingEventOpenDoors()
 {
     // spawn neutral banners
@@ -188,20 +207,26 @@ void BattleGroundAB::StartingEventOpenDoors()
     DoorOpen(BG_AB_OBJECT_GATE_A);
     DoorOpen(BG_AB_OBJECT_GATE_H);
 }
+
 void BattleGroundAB::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in the constructor
     BattleGroundABScore* sc = new BattleGroundABScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
 }
+
 void BattleGroundAB::RemovePlayer(Player * /*plr*/, uint64 /*guid*/)
 {
+
 }
+
 void BattleGroundAB::HandleAreaTrigger(Player *Source, uint32 Trigger)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     switch(Trigger)
     {
         case 3948:                                          // Arathi Basin Alliance Exit.
@@ -230,6 +255,7 @@ void BattleGroundAB::HandleAreaTrigger(Player *Source, uint32 Trigger)
             break;
     }
 }
+
 /*  type: 0-neutral, 1-contested, 3-occupied
     teamIndex: 0-ally, 1-horde                        */
 void BattleGroundAB::_CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay)
@@ -242,24 +268,30 @@ void BattleGroundAB::_CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool
         m_BannerTimers[node].teamIndex = teamIndex;
         return;
     }
+
     uint8 obj = node*8 + type + teamIndex;
+
     SpawnBGObject(obj, RESPAWN_IMMEDIATELY);
+
     // handle aura with banner
     if (!type)
         return;
     obj = node * 8 + ((type == BG_AB_NODE_TYPE_OCCUPIED) ? (5 + teamIndex) : 7);
     SpawnBGObject(obj, RESPAWN_IMMEDIATELY);
 }
+
 void BattleGroundAB::_DelBanner(uint8 node, uint8 type, uint8 teamIndex)
 {
     uint8 obj = node*8 + type + teamIndex;
     SpawnBGObject(obj, RESPAWN_ONE_DAY);
+
     // handle aura with banner
     if (!type)
         return;
     obj = node * 8 + ((type == BG_AB_NODE_TYPE_OCCUPIED) ? (5 + teamIndex) : 7);
     SpawnBGObject(obj, RESPAWN_ONE_DAY);
 }
+
 int32 BattleGroundAB::_GetNodeNameId(uint8 node)
 {
     switch (node)
@@ -274,16 +306,20 @@ int32 BattleGroundAB::_GetNodeNameId(uint8 node)
     }
     return 0;
 }
+
 void BattleGroundAB::FillInitialWorldStates(WorldPacket& data)
 {
     const uint8 plusArray[] = {0, 2, 3, 0, 1};
+
     // Node icons
     for (uint8 node = 0; node < BG_AB_DYNAMIC_NODES_COUNT; ++node)
         data << uint32(BG_AB_OP_NODEICONS[node]) << uint32((m_Nodes[node]==0)?1:0);
+
     // Node occupied states
     for (uint8 node = 0; node < BG_AB_DYNAMIC_NODES_COUNT; ++node)
         for (uint8 i = 1; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
             data << uint32(BG_AB_OP_NODESTATES[node] + plusArray[i]) << uint32((m_Nodes[node]==i)?1:0);
+
     // How many bases each team owns
     uint8 ally = 0, horde = 0;
     for (uint8 node = 0; node < BG_AB_DYNAMIC_NODES_COUNT; ++node)
@@ -291,25 +327,32 @@ void BattleGroundAB::FillInitialWorldStates(WorldPacket& data)
             ++ally;
         else if (m_Nodes[node] == BG_AB_NODE_STATUS_HORDE_OCCUPIED)
             ++horde;
+
     data << uint32(BG_AB_OP_OCCUPIED_BASES_ALLY)  << uint32(ally);
     data << uint32(BG_AB_OP_OCCUPIED_BASES_HORDE) << uint32(horde);
+
     // Team scores
     data << uint32(BG_AB_OP_RESOURCES_MAX)      << uint32(BG_AB_MAX_TEAM_SCORE);
     data << uint32(BG_AB_OP_RESOURCES_WARNING)  << uint32(BG_AB_WARNING_NEAR_VICTORY_SCORE);
     data << uint32(BG_AB_OP_RESOURCES_ALLY)     << uint32(m_TeamScores[BG_TEAM_ALLIANCE]);
     data << uint32(BG_AB_OP_RESOURCES_HORDE)    << uint32(m_TeamScores[BG_TEAM_HORDE]);
+
     // other unknown
     data << uint32(0x745) << uint32(0x2);           // 37 1861 unk
 }
+
 void BattleGroundAB::_SendNodeUpdate(uint8 node)
 {
     // Send node owner state update to refresh map icons on client
     const uint8 plusArray[] = {0, 2, 3, 0, 1};
+
     if (m_prevNodes[node])
         UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_prevNodes[node]], 0);
     else
         UpdateWorldState(BG_AB_OP_NODEICONS[node], 0);
+
     UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_Nodes[node]], 1);
+
     // How many bases each team owns
     uint8 ally = 0, horde = 0;
     for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
@@ -317,14 +360,17 @@ void BattleGroundAB::_SendNodeUpdate(uint8 node)
             ++ally;
         else if (m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED)
             ++horde;
+
     UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_ALLY, ally);
     UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_HORDE, horde);
 }
+
 void BattleGroundAB::_NodeOccupied(uint8 node,Team team)
 {
    if (!AddSpiritGuide(node, BG_AB_SpiritGuidePos[node][0], BG_AB_SpiritGuidePos[node][1], BG_AB_SpiritGuidePos[node][2], BG_AB_SpiritGuidePos[node][3], team))
         sLog.outError("Failed to spawn spirit guide! point: %u, team: %u,", node, team);
 //   SpawnBGCreature(node,RESPAWN_IMMEDIATELY);
+
     uint8 capturedNodes = 0;
     for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
     {
@@ -336,10 +382,12 @@ void BattleGroundAB::_NodeOccupied(uint8 node,Team team)
     if (capturedNodes >= 4)
         CastSpellOnTeam(SPELL_AB_QUEST_REWARD_4_BASES, team);
 }
+
 void BattleGroundAB::_NodeDeOccupied(uint8 node)
 {
     if (node >= BG_AB_DYNAMIC_NODES_COUNT)
         return;
+
     // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard
     std::vector ghost_list = m_ReviveQueue[m_BgCreatures[node]];
     if (!ghost_list.empty())
@@ -350,21 +398,27 @@ void BattleGroundAB::_NodeDeOccupied(uint8 node)
             Player* plr = objmgr.GetPlayer(*itr);
             if (!plr)
                 continue;
+
             if (!ClosestGrave)                              // cache
                 ClosestGrave = GetClosestGraveYard(plr);
+
             if (ClosestGrave)
                 plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation());
         }
     }
+
     if (m_BgCreatures[node])
         DelCreature(node);
+
     // buff object isn't despawned
 }
+
 /* Invoked if a player used a banner as a gameobject */
 void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*target_obj*/)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     uint8 node = BG_AB_NODE_STABLES;
     GameObject* obj=HashMapHolder::Find(m_BgObjects[node*8+7]);
     while ( (node < BG_AB_DYNAMIC_NODES_COUNT) && ((!obj) || (!source->IsWithinDistInMap(obj,10))))
@@ -372,15 +426,19 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ
         ++node;
         obj=HashMapHolder::Find(m_BgObjects[node*8+BG_AB_OBJECT_AURA_CONTESTED]);
     }
+
     if (node == BG_AB_DYNAMIC_NODES_COUNT)
     {
         // this means our player isn't close to any of banners - maybe cheater ??
         return;
     }
+
     BattleGroundTeamId teamIndex = GetTeamIndexByTeamId(source->GetTeam());
+
     // Check if player really could use this banner, not cheated
     if (!(m_Nodes[node] == 0 || teamIndex == m_Nodes[node]%2))
         return;
+
     source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
     uint32 sound = 0;
     // If node is neutral, change to contested
@@ -395,11 +453,13 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ
         _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true);
         _SendNodeUpdate(node);
         m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME;
+
         // FIXME: team and node names not localized
         if (teamIndex == 0)
             SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_AB_ALLY);
         else
             SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_AB_HORDE);
+
         sound = BG_AB_SOUND_NODE_CLAIMED;
     }
     // If node is contested
@@ -417,6 +477,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ
             _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true);
             _SendNodeUpdate(node);
             m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME;
+
             // FIXME: node names not localized
             if (teamIndex == BG_TEAM_ALLIANCE)
                 SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
@@ -436,6 +497,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ
             _SendNodeUpdate(node);
             m_NodeTimers[node] = 0;
             _NodeOccupied(node,(teamIndex == BG_TEAM_ALLIANCE) ? ALLIANCE:HORDE);
+
             // FIXME: node names not localized
             if (teamIndex == BG_TEAM_ALLIANCE)
                 SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
@@ -457,13 +519,16 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ
         _SendNodeUpdate(node);
         _NodeDeOccupied(node);
         m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME;
+
         // FIXME: node names not localized
         if (teamIndex == BG_TEAM_ALLIANCE)
             SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
         else
             SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node));
+
         sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
     }
+
     // If node is occupied again, send "X has taken the Y" msg.
     if (m_Nodes[node] >= BG_AB_NODE_TYPE_OCCUPIED)
     {
@@ -475,6 +540,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ
     }
     PlaySoundToAll(sound);
 }
+
 bool BattleGroundAB::SetupBattleGround()
 {
     for (int i = 0 ; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
@@ -509,12 +575,15 @@ bool BattleGroundAB::SetupBattleGround()
             )
             sLog.outErrorDb("BatteGroundAB: Failed to spawn buff object!");
     }
+
     return true;
 }
+
 void BattleGroundAB::Reset()
 {
     //call parent's class reset
     BattleGround::Reset();
+
     m_TeamScores[BG_TEAM_ALLIANCE]          = 0;
     m_TeamScores[BG_TEAM_HORDE]             = 0;
     m_lastTick[BG_TEAM_ALLIANCE]            = 0;
@@ -529,6 +598,7 @@ void BattleGroundAB::Reset()
     m_ReputationTics = (isBGWeekend) ? BG_AB_ABBGWeekendReputationTicks : BG_AB_NotABBGWeekendReputationTicks;
     m_TeamScores500Disadvantage[BG_TEAM_ALLIANCE] = false;
     m_TeamScores500Disadvantage[BG_TEAM_HORDE]    = false;
+
     for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
     {
         m_Nodes[i] = 0;
@@ -536,10 +606,12 @@ void BattleGroundAB::Reset()
         m_NodeTimers[i] = 0;
         m_BannerTimers[i].timer = 0;
     }
+
     for (uint8 i = 0; i < BG_AB_ALL_NODES_COUNT; ++i)
         if (m_BgCreatures[i])
             DelCreature(i);
 }
+
 void BattleGroundAB::EndBattleGround(uint32 winner)
 {
     //win reward
@@ -550,22 +622,27 @@ void BattleGroundAB::EndBattleGround(uint32 winner)
     //complete map_end rewards (even if no team wins)
     RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
     RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
+
     BattleGround::EndBattleGround(winner);
 }
+
 WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
 {
     BattleGroundTeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
+
     // Is there any occupied node for this team?
     std::vector nodes;
     for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
         if (m_Nodes[i] == teamIndex + 3)
             nodes.push_back(i);
+
     WorldSafeLocsEntry const* good_entry = NULL;
     // If so, select the closest node to place ghost on
     if (!nodes.empty())
     {
         float plr_x = player->GetPositionX();
         float plr_y = player->GetPositionY();
+
         float mindist = 999999.0f;
         for (uint8 i = 0; i < nodes.size(); ++i)
         {
@@ -584,13 +661,16 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
     // If not, place ghost on starting location
     if (!good_entry)
         good_entry = sWorldSafeLocsStore.LookupEntry( BG_AB_GraveyardIds[teamIndex+5] );
+
     return good_entry;
 }
+
 void BattleGroundAB::UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
 {
     BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
     if( itr == m_PlayerScores.end() )                         // player not found...
         return;
+
     switch(type)
     {
         case SCORE_BASES_ASSAULTED:
@@ -604,6 +684,7 @@ void BattleGroundAB::UpdatePlayerScore(Player *Source, uint32 type, uint32 value
             break;
     }
 }
+
 bool BattleGroundAB::IsAllNodesConrolledByTeam(uint32 team) const
 {
     uint32 count = 0;
@@ -611,5 +692,6 @@ bool BattleGroundAB::IsAllNodesConrolledByTeam(uint32 team) const
         if ((team == ALLIANCE && m_Nodes[i] == BG_AB_NODE_STATUS_ALLY_OCCUPIED) ||
             (team == HORDE    && m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED))
             ++count;
+
     return count == BG_AB_DYNAMIC_NODES_COUNT;
 }
diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h
index 7da1c517528..ef151ad187b 100644
--- a/src/game/BattleGroundAB.h
+++ b/src/game/BattleGroundAB.h
@@ -19,7 +19,9 @@
  */
 #ifndef __BATTLEGROUNDAB_H
 #define __BATTLEGROUNDAB_H
+
 class BattleGround;
+
 enum BG_AB_WorldStates
 {
     BG_AB_OP_OCCUPIED_BASES_HORDE       = 1778,
@@ -39,6 +41,7 @@ enum BG_AB_WorldStates
     BG_AB_OP_FARM_STATE_HORDE           = 1773,             //Farm state (HORDE)
     BG_AB_OP_FARM_STATE_CON_ALI         = 1774,             //Farm state (CON ALIENCE)
     BG_AB_OP_FARM_STATE_CON_HOR         = 1775,             //Farm state (CON HORDE)
+
     BG_AB_OP_BLACKSMITH_ICON            = 1846,             //Blacksmith map icon (NONE)
     BG_AB_OP_BLACKSMITH_STATE_ALIENCE   = 1782,             //Blacksmith map state (ALIENCE)
     BG_AB_OP_BLACKSMITH_STATE_HORDE     = 1783,             //Blacksmith map state (HORDE)
@@ -56,8 +59,11 @@ enum BG_AB_WorldStates
     BG_AB_OP_GOLDMINE_STATE_CON_HOR     = 1790,             //Gold Mine map state (CON HORDE)
 */
 };
+
 const uint32 BG_AB_OP_NODESTATES[5] =    {1767, 1782, 1772, 1792, 1787};
+
 const uint32 BG_AB_OP_NODEICONS[5]  =    {1842, 1846, 1845, 1844, 1843};
+
 /* Note: code uses that these IDs follow each other */
 enum BG_AB_NodeObjectId
 {
@@ -67,6 +73,7 @@ enum BG_AB_NodeObjectId
     BG_AB_OBJECTID_NODE_BANNER_3    = 180090,       // Lumber mill banner
     BG_AB_OBJECTID_NODE_BANNER_4    = 180091        // Gold mine banner
 };
+
 enum BG_AB_ObjectType
 {
     // for all 5 node points 8*5=40 objects
@@ -99,6 +106,7 @@ enum BG_AB_ObjectType
     BG_AB_OBJECT_BERSERKBUFF_GOLD_MINE   = 56,
     BG_AB_OBJECT_MAX                     = 57,
 };
+
 /* Object id templates from DB */
 enum BG_AB_ObjectTypes
 {
@@ -106,21 +114,26 @@ enum BG_AB_ObjectTypes
     BG_AB_OBJECTID_BANNER_CONT_A        = 180059,
     BG_AB_OBJECTID_BANNER_H             = 180060,
     BG_AB_OBJECTID_BANNER_CONT_H        = 180061,
+
     BG_AB_OBJECTID_AURA_A               = 180100,
     BG_AB_OBJECTID_AURA_H               = 180101,
     BG_AB_OBJECTID_AURA_C               = 180102,
+
     BG_AB_OBJECTID_GATE_A               = 180255,
     BG_AB_OBJECTID_GATE_H               = 180256
 };
+
 enum BG_AB_Timers
 {
     BG_AB_FLAG_CAPTURING_TIME           = 60000,
 };
+
 enum BG_AB_Score
 {
     BG_AB_WARNING_NEAR_VICTORY_SCORE    = 1800,
     BG_AB_MAX_TEAM_SCORE                = 2000
 };
+
 /* do NOT change the order, else wrong behaviour */
 enum BG_AB_BattleGroundNodes
 {
@@ -129,11 +142,15 @@ enum BG_AB_BattleGroundNodes
     BG_AB_NODE_FARM             = 2,
     BG_AB_NODE_LUMBER_MILL      = 3,
     BG_AB_NODE_GOLD_MINE        = 4,
+
     BG_AB_DYNAMIC_NODES_COUNT   = 5,                        // dynamic nodes that can be captured
+
     BG_AB_SPIRIT_ALIANCE        = 5,
     BG_AB_SPIRIT_HORDE          = 6,
+
     BG_AB_ALL_NODES_COUNT       = 7,                        // all nodes (dynamic and static)
 };
+
 enum BG_AB_NodeStatus
 {
     BG_AB_NODE_TYPE_NEUTRAL             = 0,
@@ -144,6 +161,7 @@ enum BG_AB_NodeStatus
     BG_AB_NODE_STATUS_ALLY_OCCUPIED     = 3,
     BG_AB_NODE_STATUS_HORDE_OCCUPIED    = 4
 };
+
 enum BG_AB_Sounds
 {
     BG_AB_SOUND_NODE_CLAIMED            = 8192,
@@ -153,10 +171,12 @@ enum BG_AB_Sounds
     BG_AB_SOUND_NODE_ASSAULTED_HORDE    = 8174,
     BG_AB_SOUND_NEAR_VICTORY            = 8456
 };
+
 #define BG_AB_NotABBGWeekendHonorTicks      330
 #define BG_AB_ABBGWeekendHonorTicks         200
 #define BG_AB_NotABBGWeekendReputationTicks 200
 #define BG_AB_ABBGWeekendReputationTicks    150
+
 // x, y, z, o
 const float BG_AB_NodePositions[BG_AB_DYNAMIC_NODES_COUNT][4] = {
     {1166.785f, 1200.132f, -56.70859f, 0.9075713f},         // stables
@@ -165,16 +185,20 @@ const float BG_AB_NodePositions[BG_AB_DYNAMIC_NODES_COUNT][4] = {
     {856.1419f, 1148.902f, 11.18469f, -2.303835f},          // lumber mill
     {1146.923f, 848.1782f, -110.917f, -0.7330382f}          // gold mine
 };
+
 // x, y, z, o, rot0, rot1, rot2, rot3
 const float BG_AB_DoorPositions[2][8] = {
     {1284.597f, 1281.167f, -15.97792f, 0.7068594f, 0.012957f, -0.060288f, 0.344959f, 0.93659f},
     {708.0903f, 708.4479f, -17.8342f, -2.391099f, 0.050291f, 0.015127f, 0.929217f, -0.365784f}
 };
+
 // Tick intervals and given points: case 0,1,2,3,4,5 captured nodes
 const uint32 BG_AB_TickIntervals[6] = {0, 12000, 9000, 6000, 3000, 1000};
 const uint32 BG_AB_TickPoints[6] = {0, 10, 10, 10, 10, 30};
+
 // WorldSafeLocs ids for 5 nodes, and for ally, and horde starting location
 const uint32 BG_AB_GraveyardIds[BG_AB_ALL_NODES_COUNT] = {895, 894, 893, 897, 896, 898, 899};
+
 // x, y, z, o
 const float BG_AB_BuffPositions[BG_AB_DYNAMIC_NODES_COUNT][4] = {
     {1185.71f, 1185.24f, -56.36f, 2.56f},                   // stables
@@ -183,6 +207,7 @@ const float BG_AB_BuffPositions[BG_AB_DYNAMIC_NODES_COUNT][4] = {
     {807.46f, 1189.16f, 11.92f, 5.44f},                     // lumber mill
     {1146.62f, 816.94f, -98.49f, 6.14f}                     // gold mine
 };
+
 // x, y, z, o
 const float BG_AB_SpiritGuidePos[BG_AB_ALL_NODES_COUNT][4] = {
     {1200.03f, 1171.09f, -56.47f, 5.15f},                   // stables
@@ -193,12 +218,14 @@ const float BG_AB_SpiritGuidePos[BG_AB_ALL_NODES_COUNT][4] = {
     {1354.05f, 1275.48f, -11.30f, 4.77f},                   // alliance starting base
     {714.61f, 646.15f, -10.87f, 4.34f}                      // horde starting base
 };
+
 struct BG_AB_BannerTimer
 {
     uint32      timer;
     uint8       type;
     uint8       teamIndex;
 };
+
 class BattleGroundABScore : public BattleGroundScore
 {
     public:
@@ -207,12 +234,15 @@ class BattleGroundABScore : public BattleGroundScore
         uint32 BasesAssaulted;
         uint32 BasesDefended;
 };
+
 class BattleGroundAB : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundAB();
         ~BattleGroundAB();
+
         void Update(uint32 diff);
         void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
@@ -223,11 +253,15 @@ class BattleGroundAB : public BattleGround
         virtual void Reset();
         void EndBattleGround(uint32 winner);
         virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
+
         /* Scorekeeping */
         virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
+
         virtual void FillInitialWorldStates(WorldPacket& data);
+
         /* Nodes occupying */
         virtual void EventPlayerClickedOnFlag(Player *source, GameObject* target_obj);
+
         /* achievement req. */
         bool IsAllNodesConrolledByTeam(uint32 team) const;  // overwrited
         bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; }
@@ -236,11 +270,14 @@ class BattleGroundAB : public BattleGround
         void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay);
         void _DelBanner(uint8 node, uint8 type, uint8 teamIndex);
         void _SendNodeUpdate(uint8 node);
+
         /* Creature spawning/despawning */
         // TODO: working, scripted peons spawning
         void _NodeOccupied(uint8 node,Team team);
         void _NodeDeOccupied(uint8 node);
+
         int32 _GetNodeNameId(uint8 node);
+
         /* Nodes info:
             0: neutral
             1: ally contested
diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp
index 4db2f4b3df2..42d15a6ce84 100644
--- a/src/game/BattleGroundAV.cpp
+++ b/src/game/BattleGroundAV.cpp
@@ -17,8 +17,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "ObjectMgr.h"
 #include "WorldPacket.h"
+
 #include "BattleGround.h"
 #include "BattleGroundAV.h"
 #include "Formulas.h"
@@ -26,29 +28,36 @@
 #include "Language.h"
 #include "Player.h"
 #include "SpellAuras.h"
+
 BattleGroundAV::BattleGroundAV()
 {
     m_BgObjects.resize(BG_AV_OBJECT_MAX);
     m_BgCreatures.resize(AV_CPLACE_MAX+AV_STATICCPLACE_MAX);
+
     m_StartMessageIds[BG_STARTING_EVENT_FIRST]  = LANG_BG_AV_START_TWO_MINUTES;
     m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_AV_START_ONE_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_BG_AV_START_HALF_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_AV_HAS_BEGUN;
 }
+
 BattleGroundAV::~BattleGroundAV()
 {
 }
+
 const uint16 BattleGroundAV::GetBonusHonor(uint8 kills) //TODO: move this function to Battleground.cpp (needs to find a way to get m_MaxLevel)
 {
     return Trinity::Honor::hk_honor_at_level(m_MaxLevel, kills);
 }
+
 void BattleGroundAV::HandleKillPlayer(Player *player, Player *killer)
 {
     if(GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     BattleGround::HandleKillPlayer(player, killer);
     UpdateScore(player->GetTeam(),-1);
 }
+
 void BattleGroundAV::HandleKillUnit(Creature *unit, Player *killer)
 {
     sLog.outDebug("bg_av HandleKillUnit %i",unit->GetEntry());
@@ -86,6 +95,7 @@ void BattleGroundAV::HandleKillUnit(Creature *unit, Player *killer)
         Creature* creature = GetBGCreature(AV_CPLACE_HERALD);
         if(creature)
             YellToAll(creature,GetTrinityString(LANG_BG_AV_A_CAPTAIN_DEAD),LANG_UNIVERSAL);
+
     }
     else if ( entry == BG_AV_CreatureInfo[AV_NPC_H_CAPTAIN][0] )
     {
@@ -110,6 +120,7 @@ void BattleGroundAV::HandleKillUnit(Creature *unit, Player *killer)
     else if ( entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_N_4][0] || entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_A_4][0] || entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_H_4][0])
         ChangeMineOwner(AV_SOUTH_MINE,killer->GetTeam());
 }
+
 void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
@@ -213,11 +224,13 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player)
     }
 }
 
+
 void BattleGroundAV::UpdateScore(uint16 team, int16 points )
 { //note: to remove reinforcementpoints points must be negative, for adding reinforcements points must be positive
     assert( team == ALLIANCE || team == HORDE);
     uint8 teamindex = GetTeamIndexByTeamId(team); //0=ally 1=horde
     m_Team_Scores[teamindex] += points;
+
     UpdateWorldState(((teamindex==BG_TEAM_HORDE)?AV_Horde_Score:AV_Alliance_Score), m_Team_Scores[teamindex]);
     if( points < 0)
     {
@@ -234,6 +247,7 @@ void BattleGroundAV::UpdateScore(uint16 team, int16 points )
         }
     }
 }
+
 Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type )
 {
     uint32 level;
@@ -257,6 +271,7 @@ Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type )
         return NULL;
     if(creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_A_CAPTAIN][0] || creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_H_CAPTAIN][0])
         creature->SetRespawnDelay(RESPAWN_ONE_DAY); // TODO: look if this can be done by database + also add this for the wingcommanders
+
     if((isStatic && cinfoid>=10 && cinfoid<=14) || (!isStatic && ((cinfoid >= AV_NPC_A_GRAVEDEFENSE0 && cinfoid<=AV_NPC_A_GRAVEDEFENSE3) ||
         (cinfoid>=AV_NPC_H_GRAVEDEFENSE0 && cinfoid<=AV_NPC_H_GRAVEDEFENSE3))))
     {
@@ -274,14 +289,17 @@ Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type )
         //TODO: find a way to add a motionmaster without killing the creature (i
         //just copied this code from a gm-command
     }
+
     if(level != 0)
         level += m_MaxLevel-60; //maybe we can do this more generic for custom level-range.. actually it's blizzlike
     creature->SetLevel(level);
     return creature;
 }
+
 void BattleGroundAV::Update(uint32 diff)
 {
     BattleGround::Update(diff);
+
     if(GetStatus() == STATUS_IN_PROGRESS)
     {
         for(uint8 i=0; i<=1;i++)//0=alliance, 1=horde
@@ -317,6 +335,7 @@ void BattleGroundAV::Update(uint32 diff)
             {
                 if( m_Mine_Timer <= 0)
                     UpdateScore(m_Mine_Owner[mine],1);
+
                 if(m_Mine_Reclaim_Timer[mine] > diff)
                     m_Mine_Reclaim_Timer[mine] -= diff;
                 else{ //we don't need to set this timer to 0 cause this codepart wont get called when this thing is 0
@@ -326,6 +345,7 @@ void BattleGroundAV::Update(uint32 diff)
         }
         if( m_Mine_Timer <= 0)
             m_Mine_Timer=AV_MINE_TICK_TIMER; //this is at the end, cause we need to update both mines
+
         //looks for all timers of the nodes and destroy the building (for graveyards the building wont get destroyed, it goes just to the other team
         for(BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i)
             if(m_Nodes[i].State == POINT_ASSAULTED) //maybe remove this
@@ -337,11 +357,13 @@ void BattleGroundAV::Update(uint32 diff)
             }
     }
 }
+
 void BattleGroundAV::StartingEventCloseDoors()
 {
     DoorClose(BG_AV_OBJECT_DOOR_A);
     DoorClose(BG_AV_OBJECT_DOOR_H);
 }
+
 void BattleGroundAV::StartingEventOpenDoors()
 {
     sLog.outDebug("BG_AV: start spawning mine stuff");
@@ -351,11 +373,14 @@ void BattleGroundAV::StartingEventOpenDoors()
         SpawnBGObject(i,RESPAWN_IMMEDIATELY);
     for(uint8 mine = AV_NORTH_MINE; mine <= AV_SOUTH_MINE; mine++) //mine population
         ChangeMineOwner(mine, AV_NEUTRAL_TEAM,true);
+
     UpdateWorldState(AV_SHOW_H_SCORE, 1);
     UpdateWorldState(AV_SHOW_A_SCORE, 1);
+
     DoorOpen(BG_AV_OBJECT_DOOR_H);
     DoorOpen(BG_AV_OBJECT_DOOR_A);
 }
+
 void BattleGroundAV::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
@@ -364,7 +389,9 @@ void BattleGroundAV::AddPlayer(Player *plr)
     m_PlayerScores[plr->GetGUID()] = sc;
     if(m_MaxLevel==0)
         m_MaxLevel=(plr->getLevel()%10 == 0)? plr->getLevel() : (plr->getLevel()-(plr->getLevel()%10))+10; //TODO: just look at the code \^_^/ --but queue-info should provide this information..
+
 }
+
 void BattleGroundAV::EndBattleGround(uint32 winner)
 {
     //calculate bonuskills for both teams:
@@ -387,6 +414,7 @@ void BattleGroundAV::EndBattleGround(uint32 winner)
                 }
             }
     }
+
     for(int i=0; i<=1; i++) //0=ally 1=horde
     {
         if(m_CaptainAlive[i])
@@ -399,9 +427,11 @@ void BattleGroundAV::EndBattleGround(uint32 winner)
         if(kills[i] != 0)
             RewardHonorToTeam(GetBonusHonor(kills[i]),(i == 0)?ALLIANCE:HORDE);
     }
+
     //TODO add enterevademode for all attacking creatures
     BattleGround::EndBattleGround(winner);
 }
+
 void BattleGroundAV::RemovePlayer(Player* plr,uint64 /*guid*/)
 {
    if(!plr)
@@ -415,11 +445,13 @@ void BattleGroundAV::RemovePlayer(Player* plr,uint64 /*guid*/)
     plr->RemoveAurasDueToSpell(AV_BUFF_H_CAPTAIN);
 }
 
+
 void BattleGroundAV::HandleAreaTrigger(Player *Source, uint32 Trigger)
 {
     // this is wrong way to implement these things. On official it done by gameobject spell cast.
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     uint32 SpellId = 0;
     switch(Trigger)
     {
@@ -449,14 +481,18 @@ void BattleGroundAV::HandleAreaTrigger(Player *Source, uint32 Trigger)
 //            Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
             break;
     }
+
     if (SpellId)
         Source->CastSpell(Source, SpellId, true);
 }
+
 void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value)
 {
+
     BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
     if(itr == m_PlayerScores.end())                         // player not found...
         return;
+
     switch(type)
     {
         case SCORE_GRAVEYARDS_ASSAULTED:
@@ -486,14 +522,19 @@ void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
     }
 }
 
+
+
 void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
 {
+
     uint32 object = GetObjectThroughNode(node);
     sLog.outDebug("bg_av: player destroyed point node %i object %i",node,object);
+
     //despawn banner
     SpawnBGObject(object, RESPAWN_ONE_DAY);
     DestroyNode(node);
     UpdateNodeWorldState(node);
+
     uint32 owner = m_Nodes[node].Owner;
     if( IsTower(node) )
     {
@@ -506,9 +547,11 @@ void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
         //spawn destroyed aura
         for(uint8 i=0; i<=9; i++)
             SpawnBGObject(BG_AV_OBJECT_BURN_DUNBALDAR_SOUTH + i + (tmp * 10),RESPAWN_IMMEDIATELY);
+
         UpdateScore((owner == ALLIANCE) ? HORDE : ALLIANCE, (-1)*BG_AV_RES_TOWER);
         RewardReputationToTeam((owner == ALLIANCE)?730:729,BG_AV_REP_TOWER,owner);
         RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_TOWER),owner);
+
         SpawnBGObject(BG_AV_OBJECT_TAURA_A_DUNBALDAR_SOUTH+GetTeamIndexByTeamId(owner)+(2*tmp),RESPAWN_ONE_DAY);
         SpawnBGObject(BG_AV_OBJECT_TFLAG_A_DUNBALDAR_SOUTH+GetTeamIndexByTeamId(owner)+(2*tmp),RESPAWN_ONE_DAY);
     }
@@ -536,10 +579,12 @@ void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
         sprintf(buf, GetTrinityString(LANG_BG_AV_TOWER_TAKEN) , GetNodeName(node),( owner == ALLIANCE ) ? GetTrinityString(LANG_BG_AV_ALLY) : GetTrinityString(LANG_BG_AV_HORDE)  );
     else
         sprintf(buf, GetTrinityString(LANG_BG_AV_GRAVE_TAKEN) , GetNodeName(node),( owner == ALLIANCE ) ? GetTrinityString(LANG_BG_AV_ALLY) :GetTrinityString(LANG_BG_AV_HORDE)  );
+
     Creature* creature = GetBGCreature(AV_CPLACE_HERALD);
     if(creature)
         YellToAll(creature,buf,LANG_UNIVERSAL);
 }
+
 void BattleGroundAV::ChangeMineOwner(uint8 mine, uint32 team, bool initial)
 { //mine=0 northmine mine=1 southmin
 //changing the owner results in setting respawntim to infinite for current creatures, spawning new mine owners creatures and changing the chest-objects so that the current owning team can use them
@@ -548,10 +593,12 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, uint32 team, bool initial)
         team = AV_NEUTRAL_TEAM;
     else
         PlaySoundToAll((team==ALLIANCE)?AV_SOUND_ALLIANCE_GOOD:AV_SOUND_HORDE_GOOD);
+
     if(m_Mine_Owner[mine] == team && !initial)
         return;
     m_Mine_PrevOwner[mine] = m_Mine_Owner[mine];
     m_Mine_Owner[mine] = team;
+
     if(!initial)
     {
         sLog.outDebug("bg_av depopulating mine %i (0=north,1=south)",mine);
@@ -564,6 +611,7 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, uint32 team, bool initial)
                 DelCreature(i); //TODO here also
     }
     SendMineWorldStates(mine);
+
     sLog.outDebug("bg_av populating mine %i (0=north,1=south)",mine);
     uint16 miner;
     //also neutral team exists.. after a big time, the neutral team tries to conquer the mine
@@ -626,6 +674,7 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, uint32 team, bool initial)
     }
     return;
 }
+
 bool BattleGroundAV::PlayerCanDoMineQuest(int32 GOId,uint32 team)
 {
     if(GOId == BG_AV_OBJECTID_MINE_N)
@@ -634,10 +683,12 @@ bool BattleGroundAV::PlayerCanDoMineQuest(int32 GOId,uint32 team)
          return (m_Mine_Owner[AV_SOUTH_MINE]==team);
     return true; //cause it's no mine'object it is ok if this is true
 }
+
 void BattleGroundAV::PopulateNode(BG_AV_Nodes node)
 {
     uint32 owner = m_Nodes[node].Owner;
     assert(owner);
+
     uint32 c_place = AV_CPLACE_DEFENSE_STORM_AID + ( 4 * node );
     uint32 creatureid;
     if(IsTower(node))
@@ -658,6 +709,7 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node)
             DelCreature(node);
         if( !AddSpiritGuide(node, BG_AV_CreaturePos[node][0], BG_AV_CreaturePos[node][1], BG_AV_CreaturePos[node][2], BG_AV_CreaturePos[node][3], owner))
             sLog.outError("AV: couldn't spawn spiritguide at node %i",node);
+
     }
     for(uint8 i=0; i<4; i++)
     {
@@ -675,6 +727,7 @@ void BattleGroundAV::DePopulateNode(BG_AV_Nodes node)
         DelCreature(node);
 }
 
+
 const BG_AV_Nodes BattleGroundAV::GetNodeThroughObject(uint32 object)
 {
     sLog.outDebug("bg_AV getnodethroughobject %i",object);
@@ -696,6 +749,7 @@ const BG_AV_Nodes BattleGroundAV::GetNodeThroughObject(uint32 object)
     assert(false);
     return BG_AV_Nodes(0);
 }
+
 const uint32 BattleGroundAV::GetObjectThroughNode(BG_AV_Nodes node)
 { //this function is the counterpart to GetNodeThroughObject()
     sLog.outDebug("bg_AV GetObjectThroughNode %i",node);
@@ -732,7 +786,9 @@ const uint32 BattleGroundAV::GetObjectThroughNode(BG_AV_Nodes node)
     return 0;
 }
 
+
 //called when using banner
+
 void BattleGroundAV::EventPlayerClickedOnFlag(Player *source, GameObject* target_obj)
 {
     if(GetStatus() != STATUS_IN_PROGRESS)
@@ -760,12 +816,15 @@ void BattleGroundAV::EventPlayerClickedOnFlag(Player *source, GameObject* target
             break;
     }
 }
+
 void BattleGroundAV::EventPlayerDefendsPoint(Player* player, uint32 object)
 {
     assert(GetStatus() == STATUS_IN_PROGRESS);
     BG_AV_Nodes node = GetNodeThroughObject(object);
+
     uint32 owner = m_Nodes[node].Owner; //maybe should name it prevowner
     uint32 team = player->GetTeam();
+
     if(owner == player->GetTeam() || m_Nodes[node].State != POINT_ASSAULTED)
         return;
     if(m_Nodes[node].TotalOwner == AV_NEUTRAL_TEAM)
@@ -781,11 +840,13 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, uint32 object)
         return;
     }
 
+
    //spawn new go :)
     if(m_Nodes[node].Owner == ALLIANCE)
         SpawnBGObject(object+22, RESPAWN_IMMEDIATELY); //spawn horde banner
     else
         SpawnBGObject(object-22, RESPAWN_IMMEDIATELY); //spawn alliance banner
+
     if(!IsTower(node))
     {
         SpawnBGObject(BG_AV_OBJECT_AURA_N_FIRSTAID_STATION+3*node,RESPAWN_ONE_DAY);
@@ -793,9 +854,11 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, uint32 object)
     }
         // despawn old go
     SpawnBGObject(object, RESPAWN_ONE_DAY);
+
     DefendNode(node,team);
     PopulateNode(node);
     UpdateNodeWorldState(node);
+
     if(IsTower(node))
     {
         //spawn big flag+aura on top of tower
@@ -825,9 +888,11 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, uint32 object)
     else
         PlaySoundToAll((team==ALLIANCE)?AV_SOUND_ALLIANCE_GOOD:AV_SOUND_HORDE_GOOD);
 }
+
 void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
 {
     assert(GetStatus() == STATUS_IN_PROGRESS);
+
     BG_AV_Nodes node = GetNodeThroughObject(object);
     uint32 owner = m_Nodes[node].Owner; //maybe name it prevowner
     uint32 team  = player->GetTeam();
@@ -835,6 +900,7 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
     if(owner == team || team == m_Nodes[node].TotalOwner)
         return; //surely a gm used this object
 
+
     if(node == BG_AV_NODES_SNOWFALL_GRAVE) //snowfall is a bit special in capping + it gets eyecandy stuff
     {
         if(object == BG_AV_OBJECT_FLAG_N_SNOWFALL_GRAVE) //initial capping
@@ -872,6 +938,7 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
             SpawnBGObject(spawn+i,RESPAWN_IMMEDIATELY);
         }
     }
+
     //if snowfall gots capped it can be handled like all other graveyards
     if( m_Nodes[node].TotalOwner != AV_NEUTRAL_TEAM)
     {
@@ -913,9 +980,11 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
         }
         DePopulateNode(node);
     }
+
     SpawnBGObject(object, RESPAWN_ONE_DAY); //delete old banner
     AssaultNode(node,team);
     UpdateNodeWorldState(node);
+
     //send a nice message to all :)
     char buf[256];
     sprintf(buf, ( IsTower(node) ) ? GetTrinityString(LANG_BG_AV_TOWER_ASSAULTED) : GetTrinityString(LANG_BG_AV_GRAVE_ASSAULTED), GetNodeName(node),  ( team == ALLIANCE ) ?  GetTrinityString(LANG_BG_AV_ALLY) : GetTrinityString(LANG_BG_AV_HORDE ));
@@ -926,6 +995,7 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
     UpdatePlayerScore(player, ( IsTower(node) ) ? SCORE_TOWERS_ASSAULTED : SCORE_GRAVEYARDS_ASSAULTED, 1);
     PlaySoundToAll((team==ALLIANCE)?AV_SOUND_ALLIANCE_ASSAULTS:AV_SOUND_HORDE_ASSAULTS);
 }
+
 void BattleGroundAV::FillInitialWorldStates(WorldPacket& data)
 {
     bool stateok;
@@ -939,6 +1009,7 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data)
             data << uint32(BG_AV_NodeWorldStates[i][GetWorldStateType(j,HORDE)]) << uint32((m_Nodes[i].Owner == HORDE && stateok)?1:0);
         }
     }
+
     //towers
     for (uint8 i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_MAX; i++)
         for (uint8 j =1; j <= 3; j+=2)
@@ -963,6 +1034,7 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data)
     SendMineWorldStates(AV_NORTH_MINE);
     SendMineWorldStates(AV_SOUTH_MINE);
 }
+
 const uint8 BattleGroundAV::GetWorldStateType(uint8 state, uint16 team) //this is used for node worldstates and returns values which fit good into the worldstatesarray
 {
     //neutral stuff cant get handled (currently its only snowfall)
@@ -985,6 +1057,7 @@ const uint8 BattleGroundAV::GetWorldStateType(uint8 state, uint16 team) //this i
     sLog.outError("BG_AV: should update a strange worldstate state:%i team:%i",state,team);
     return 5; //this will crash the game, but i want to know if something is wrong here
 }
+
 void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node)
 {
     UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].State,m_Nodes[node].Owner)],1);
@@ -993,12 +1066,14 @@ void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node)
     else
         UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState,m_Nodes[node].PrevOwner)],0);
 }
+
 void BattleGroundAV::SendMineWorldStates(uint32 mine)
 {
     assert(mine == AV_NORTH_MINE || mine==AV_SOUTH_MINE);
 // currently i'm sure, that this works (:
 //    assert(m_Mine_PrevOwner[mine] == ALLIANCE || m_Mine_PrevOwner[mine] == HORDE || m_Mine_PrevOwner[mine] == AV_NEUTRAL_TEAM);
 //    assert(m_Mine_Owner[mine] == ALLIANCE || m_Mine_Owner[mine] == HORDE || m_Mine_Owner[mine] == AV_NEUTRAL_TEAM);
+
     uint8 owner,prevowner,mine2; //those variables are needed to access the right worldstate in the BG_AV_MineWorldStates array
     mine2 = (mine==AV_NORTH_MINE)?0:1;
     if(m_Mine_PrevOwner[mine] == ALLIANCE)
@@ -1013,11 +1088,13 @@ void BattleGroundAV::SendMineWorldStates(uint32 mine)
         owner = 2;
     else
         owner = 1;
+
     UpdateWorldState(BG_AV_MineWorldStates[mine2][owner],1);
     if( prevowner != owner)
         UpdateWorldState(BG_AV_MineWorldStates[mine2][prevowner],0);
 }
 
+
 WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* player)
 {
     WorldSafeLocsEntry const* good_entry = NULL;
@@ -1043,9 +1120,11 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* player)
     // If not, place ghost on starting location
     if( !good_entry )
         good_entry = sWorldSafeLocsStore.LookupEntry( BG_AV_GraveyardIds[GetTeamIndexByTeamId(player->GetTeam())+7] );
+
     return good_entry;
 }
 
+
 bool BattleGroundAV::SetupBattleGround()
 {
     // Create starting objects
@@ -1058,6 +1137,7 @@ bool BattleGroundAV::SetupBattleGround()
         sLog.outErrorDb("BatteGroundAV: Failed to spawn some object BattleGround not created!1");
         return false;
     }
+
     //spawn node-objects
     for (uint8 i = BG_AV_NODES_FIRSTAID_STATION ; i < BG_AV_NODES_MAX; ++i)
     {
@@ -1152,6 +1232,7 @@ bool BattleGroundAV::SetupBattleGround()
             return false;
         }
     }
+
     if(!AddObject(BG_AV_OBJECT_FLAG_N_SNOWFALL_GRAVE, BG_AV_OBJECTID_BANNER_SNOWFALL_N ,BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][0],BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][1],BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][2],BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][3],0,0,sin(BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][3]/2), cos(BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][3]/2), RESPAWN_ONE_DAY))
     {
         sLog.outError("BatteGroundAV: Failed to spawn some object BattleGround not created!8");
@@ -1168,6 +1249,7 @@ bool BattleGroundAV::SetupBattleGround()
             return false;
         }
     }
+
     uint16 i;
     sLog.outDebug("Alterac Valley: entering state STATUS_WAIT_JOIN ...");
     // Initial Nodes
@@ -1198,6 +1280,7 @@ bool BattleGroundAV::SetupBattleGround()
     for(i = BG_AV_OBJECT_FLAG_N_SNOWFALL_GRAVE; i <= BG_AV_OBJECT_DOOR_A; i++)
         SpawnBGObject(i, RESPAWN_IMMEDIATELY);
     SpawnBGObject(BG_AV_OBJECT_AURA_N_SNOWFALL_GRAVE,RESPAWN_IMMEDIATELY);
+
     //creatures
     sLog.outDebug("BG_AV start poputlating nodes");
     for(BG_AV_Nodes i= BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i )
@@ -1220,6 +1303,7 @@ bool BattleGroundAV::SetupBattleGround()
     AddAVCreature(AV_NPC_HERALD,AV_CPLACE_HERALD);
     return true;
 }
+
 const char* BattleGroundAV::GetNodeName(BG_AV_Nodes node)
 {
     switch (node)
@@ -1247,6 +1331,7 @@ const char* BattleGroundAV::GetNodeName(BG_AV_Nodes node)
             }
     }
 }
+
 void BattleGroundAV::AssaultNode(BG_AV_Nodes node, uint16 team)
 {
     if (m_Nodes[node].TotalOwner == team)
@@ -1276,15 +1361,18 @@ void BattleGroundAV::AssaultNode(BG_AV_Nodes node, uint16 team)
     m_Nodes[node].PrevState  = m_Nodes[node].State;
     m_Nodes[node].State      = POINT_ASSAULTED;
 }
+
 void BattleGroundAV::DestroyNode(BG_AV_Nodes node)
 {
     assert(m_Nodes[node].State == POINT_ASSAULTED);
+
     m_Nodes[node].TotalOwner = m_Nodes[node].Owner;
     m_Nodes[node].PrevOwner  = m_Nodes[node].Owner;
     m_Nodes[node].PrevState  = m_Nodes[node].State;
     m_Nodes[node].State      = (m_Nodes[node].Tower)? POINT_DESTROYED : POINT_CONTROLED;
     m_Nodes[node].Timer      = 0;
 }
+
 void BattleGroundAV::InitNode(BG_AV_Nodes node, uint16 team, bool tower)
 {
     m_Nodes[node].TotalOwner = team;
@@ -1296,6 +1384,7 @@ void BattleGroundAV::InitNode(BG_AV_Nodes node, uint16 team, bool tower)
     m_Nodes[node].Timer      = 0;
     m_Nodes[node].Tower      = tower;
 }
+
 void BattleGroundAV::DefendNode(BG_AV_Nodes node, uint16 team)
 {
     assert(m_Nodes[node].TotalOwner == team);
@@ -1307,6 +1396,7 @@ void BattleGroundAV::DefendNode(BG_AV_Nodes node, uint16 team)
     m_Nodes[node].State      = POINT_CONTROLED;
     m_Nodes[node].Timer      = 0;
 }
+
 void BattleGroundAV::ResetBGSubclass()
 {
     m_MaxLevel=0;
@@ -1330,9 +1420,12 @@ void BattleGroundAV::ResetBGSubclass()
     for(BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) //horde towers
         InitNode(i,HORDE,true);
     InitNode(BG_AV_NODES_SNOWFALL_GRAVE,AV_NEUTRAL_TEAM,false); //give snowfall neutral owner
+
     m_Mine_Timer=AV_MINE_TICK_TIMER;
     for(uint16 i = 0; i < AV_CPLACE_MAX+AV_STATICCPLACE_MAX; i++)
         if(m_BgCreatures[i])
             DelCreature(i);
+
 }
 
+
diff --git a/src/game/BattleGroundAV.h b/src/game/BattleGroundAV.h
index 7e5bd367b70..306c513ae95 100644
--- a/src/game/BattleGroundAV.h
+++ b/src/game/BattleGroundAV.h
@@ -17,32 +17,44 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef __BATTLEGROUNDAV_H
 #define __BATTLEGROUNDAV_H
+
 class BattleGround;
+
 #define LANG_BG_AV_A_CAPTAIN_BUFF       "Begone. Uncouth scum! The Alliance shall prevail in Alterac Valley!"
 #define LANG_BG_AV_H_CAPTAIN_BUFF       "Now is the time to attack! For the Horde!"
 #define LANG_BG_AV_S_MINE_BOSS_CLAIMS   "Snivvle is here! Snivvle claims the Coldtooth Mine!"
+
 #define BG_AV_CAPTIME                    240000  //4:00
 #define BG_AV_SNOWFALL_FIRSTCAP          300000  //5:00 but i also have seen 4:05
+
 #define BG_AV_SCORE_INITIAL_POINTS       600
 #define SEND_MSG_NEAR_LOSE               120
+
 #define BG_AV_KILL_BOSS                 4
 #define BG_AV_REP_BOSS                  350
+
 #define BG_AV_KILL_CAPTAIN              3
 #define BG_AV_REP_CAPTAIN               125
 #define BG_AV_RES_CAPTAIN               100
+
 #define BG_AV_KILL_TOWER                3
 #define BG_AV_REP_TOWER                 12
 #define BG_AV_RES_TOWER                 75
+
 #define BG_AV_GET_COMMANDER            1 //for a safely returned wingcommander
 //bonushonor at the end
 #define BG_AV_KILL_SURVIVING_TOWER      2
 #define BG_AV_REP_SURVIVING_TOWER       12
+
 #define BG_AV_KILL_SURVIVING_CAPTAIN    2
 #define BG_AV_REP_SURVIVING_CAPTAIN     125
+
 enum BG_AV_Sounds
 { //TODO: get out if there comes a sound when neutral team captures mine
+
 /*
 8212:
     alliance grave assault
@@ -50,6 +62,7 @@ enum BG_AV_Sounds
     drek "mlanzenabschaum! In meiner Burg?! Toetet sie all" - nicht immer der sound
 8333:
     galv "sterbt fuer euch ist kein platz hier"
+
 8332:
     bal "Verschwinde, dreckiger Abschaum! Die Allianz wird im Alteractal "
 8174:
@@ -72,16 +85,21 @@ horde:
     mine capture
     horde wins
     */
+
     AV_SOUND_NEAR_VICTORY                   = 8456, //not confirmed yet
+
     AV_SOUND_ALLIANCE_ASSAULTS              = 8212, //tower,grave + enemy boss if someone tries to attack him
     AV_SOUND_HORDE_ASSAULTS                 = 8174,
     AV_SOUND_ALLIANCE_GOOD                  = 8173, //if something good happens for the team:  wins(maybe only through killing the boss), captures mine or grave, destroys tower and defends grave
     AV_SOUND_HORDE_GOOD                     = 8213,
     AV_SOUND_BOTH_TOWER_DEFEND              = 8192,
+
     AV_SOUND_ALLIANCE_CAPTAIN               = 8232, //gets called when someone attacks them and at the beginning after 3min+rand(x)*10sec (maybe buff)
     AV_SOUND_HORDE_CAPTAIN                  = 8333,
 
+
 };
+
 enum BG_AV_OTHER_VALUES
 {
     AV_STATICCPLACE_MAX        = 123,
@@ -100,21 +118,25 @@ enum BG_AV_ObjectIds
     BG_AV_OBJECTID_BANNER_H             = 178943, // can only be used by alliance
     BG_AV_OBJECTID_BANNER_CONT_A        = 178940, // can only be used by horde
     BG_AV_OBJECTID_BANNER_CONT_H        = 179435, // can only be used by alliance
+
     BG_AV_OBJECTID_BANNER_A_B           = 178365,
     BG_AV_OBJECTID_BANNER_H_B           = 178364,
     BG_AV_OBJECTID_BANNER_CONT_A_B      = 179286,
     BG_AV_OBJECTID_BANNER_CONT_H_B      = 179287,
     BG_AV_OBJECTID_BANNER_SNOWFALL_N    = 180418,
+
     //snowfall eyecandy banner:
     BG_AV_OBJECTID_SNOWFALL_CANDY_A     = 179044,
     BG_AV_OBJECTID_SNOWFALL_CANDY_PA    = 179424,
     BG_AV_OBJECTID_SNOWFALL_CANDY_H     = 179064,
     BG_AV_OBJECTID_SNOWFALL_CANDY_PH    = 179425,
+
     //banners on top of towers:
     BG_AV_OBJECTID_TOWER_BANNER_A  = 178927, //[PH] Alliance A1 Tower Banner BIG
     BG_AV_OBJECTID_TOWER_BANNER_H  = 178955, //[PH] Horde H1 Tower Banner BIG
     BG_AV_OBJECTID_TOWER_BANNER_PA = 179446, //[PH] Alliance H1 Tower Pre-Banner BIG
     BG_AV_OBJECTID_TOWER_BANNER_PH = 179436, //[PH] Horde A1 Tower Pre-Banner BIG
+
     //Auras
     BG_AV_OBJECTID_AURA_A               = 180421,
     BG_AV_OBJECTID_AURA_H               = 180422,
@@ -122,14 +144,18 @@ enum BG_AV_ObjectIds
     BG_AV_OBJECTID_AURA_A_S             = 180100,
     BG_AV_OBJECTID_AURA_H_S             = 180101,
     BG_AV_OBJECTID_AURA_N_S             = 180102,
+
     BG_AV_OBJECTID_GATE_A               = 180424,
     BG_AV_OBJECTID_GATE_H               = 180424,
+
     //mine supplies
     BG_AV_OBJECTID_MINE_N        = 178785,
     BG_AV_OBJECTID_MINE_S       = 178784,
+
     BG_AV_OBJECTID_FIRE                 = 179065,
     BG_AV_OBJECTID_SMOKE                 = 179066
 };
+
 enum BG_AV_Nodes
 {
     BG_AV_NODES_FIRSTAID_STATION        = 0,
@@ -147,8 +173,10 @@ enum BG_AV_Nodes
     BG_AV_NODES_TOWER_POINT             = 12,
     BG_AV_NODES_FROSTWOLF_ETOWER        = 13,
     BG_AV_NODES_FROSTWOLF_WTOWER        = 14,
+
     BG_AV_NODES_MAX                     = 15
 };
+
 enum BG_AV_ObjectTypes
 {
     BG_AV_OBJECT_FLAG_A_FIRSTAID_STATION    = 0,
@@ -162,6 +190,7 @@ enum BG_AV_ObjectTypes
     BG_AV_OBJECT_FLAG_A_DUNBALDAR_NORTH     = 8,
     BG_AV_OBJECT_FLAG_A_ICEWING_BUNKER      = 9,
     BG_AV_OBJECT_FLAG_A_STONEHEART_BUNKER   = 10,
+
     BG_AV_OBJECT_FLAG_C_A_FIRSTAID_STATION    = 11,
     BG_AV_OBJECT_FLAG_C_A_STORMPIKE_GRAVE     = 12,
     BG_AV_OBJECT_FLAG_C_A_STONEHEART_GRAVE    = 13,
@@ -173,6 +202,7 @@ enum BG_AV_ObjectTypes
     BG_AV_OBJECT_FLAG_C_A_TOWER_POINT         = 19,
     BG_AV_OBJECT_FLAG_C_A_FROSTWOLF_ETOWER    = 20,
     BG_AV_OBJECT_FLAG_C_A_FROSTWOLF_WTOWER    = 21,
+
     BG_AV_OBJECT_FLAG_C_H_FIRSTAID_STATION    = 22,
     BG_AV_OBJECT_FLAG_C_H_STORMPIKE_GRAVE     = 23,
     BG_AV_OBJECT_FLAG_C_H_STONEHEART_GRAVE    = 24,
@@ -184,6 +214,7 @@ enum BG_AV_ObjectTypes
     BG_AV_OBJECT_FLAG_C_H_DUNBALDAR_NORTH     = 30,
     BG_AV_OBJECT_FLAG_C_H_ICEWING_BUNKER      = 31,
     BG_AV_OBJECT_FLAG_C_H_STONEHEART_BUNKER   = 32,
+
     BG_AV_OBJECT_FLAG_H_FIRSTAID_STATION    = 33,
     BG_AV_OBJECT_FLAG_H_STORMPIKE_GRAVE     = 34,
     BG_AV_OBJECT_FLAG_H_STONEHEART_GRAVE    = 35,
@@ -195,7 +226,9 @@ enum BG_AV_ObjectTypes
     BG_AV_OBJECT_FLAG_H_TOWER_POINT         = 41,
     BG_AV_OBJECT_FLAG_H_FROSTWOLF_ETOWER    = 42,
     BG_AV_OBJECT_FLAG_H_FROSTWOLF_WTOWER    = 43,
+
     BG_AV_OBJECT_FLAG_N_SNOWFALL_GRAVE      = 44,
+
     BG_AV_OBJECT_DOOR_H                     = 45,
     BG_AV_OBJECT_DOOR_A                     = 46,
 //auras for graveyards (3auras per graveyard neutral,alliance,horde)
@@ -220,6 +253,7 @@ enum BG_AV_ObjectTypes
     BG_AV_OBJECT_AURA_N_FROSTWOLF_HUT       = 65,
     BG_AV_OBJECT_AURA_A_FROSTWOLF_HUT       = 66,
     BG_AV_OBJECT_AURA_H_FROSTWOLF_HUT       = 67,
+
     //big flags on top of towers 2 flags on each (contested,(alliance | horde)) + 2 auras
     BG_AV_OBJECT_TFLAG_A_DUNBALDAR_SOUTH     = 67,
     BG_AV_OBJECT_TFLAG_H_DUNBALDAR_SOUTH     = 68,
@@ -253,6 +287,7 @@ enum BG_AV_ObjectTypes
     BG_AV_OBJECT_TAURA_H_FROSTWOLF_ETOWER    = 96,
     BG_AV_OBJECT_TAURA_A_FROSTWOLF_WTOWER    = 97,
     BG_AV_OBJECT_TAURA_H_FROSTWOLF_WTOWER    = 98,
+
     BG_AV_OBJECT_BURN_DUNBALDAR_SOUTH        = 99,
     BG_AV_OBJECT_BURN_DUNBALDAR_NORTH        = 109,
     BG_AV_OBJECT_BURN_ICEWING_BUNKER         = 119,
@@ -271,9 +306,12 @@ enum BG_AV_ObjectTypes
     BG_AV_OBJECT_MINE_SUPPLY_N_MAX           = 224,
     BG_AV_OBJECT_MINE_SUPPLY_S_MIN           = 225,
     BG_AV_OBJECT_MINE_SUPPLY_S_MAX           = 236,
+
     BG_AV_OBJECT_MAX                          = 237
 };
 
+
+
 enum BG_AV_OBJECTS
 {
     AV_OPLACE_FIRSTAID_STATION          = 0,
@@ -299,6 +337,7 @@ enum BG_AV_OBJECTS
     AV_OPLACE_BIGBANNER_TOWER_POINT             = 20,
     AV_OPLACE_BIGBANNER_FROSTWOLF_ETOWER        = 21,
     AV_OPLACE_BIGBANNER_FROSTWOLF_WTOWER        = 22,
+
     AV_OPLACE_BURN_DUNBALDAR_SOUTH         = 23,
     AV_OPLACE_BURN_DUNBALDAR_NORTH         = 33,
     AV_OPLACE_BURN_ICEWING_BUNKER          = 43,
@@ -317,6 +356,7 @@ enum BG_AV_OBJECTS
     AV_OPLACE_MINE_SUPPLY_N_MAX           = 136,
     AV_OPLACE_MINE_SUPPLY_S_MIN           = 137,
     AV_OPLACE_MINE_SUPPLY_S_MAX           = 148,
+
     AV_OPLACE_MAX                         = 149
 };
 const float BG_AV_ObjectPos[AV_OPLACE_MAX][4] = {
@@ -433,6 +473,7 @@ const float BG_AV_ObjectPos[AV_OPLACE_MAX][4] = {
     {-1295.55f,-263.865f,105.033f,0.925024f},
     {-1294.71f,-281.466f,107.664f,-1.50098f},
     {-1289.69f,-259.521f,107.612f,-2.19912f},
+
     //the two buildings of the captains
     //alliance
     {-64.4987f,-289.33f,33.4616f,-2.82743f},
@@ -456,6 +497,7 @@ const float BG_AV_ObjectPos[AV_OPLACE_MAX][4] = {
     {-568.04f,-188.707f,81.55f,0},
     {-501.775f,-151.581f,81.2027f,0},
     {-509.975f,-191.652f,83.2978f,0},
+
 //snowfall eyecandy
     {-191.153f,-129.868f,78.5595f,-1.25664f },
     {-201.282f,-134.319f,78.6753f,-0.942478f },
@@ -487,11 +529,13 @@ const float BG_AV_ObjectPos[AV_OPLACE_MAX][4] = {
     {-947.642f,-208.807f,77.0101f,1.36136f},
     {-951.394f,-193.695f,67.634f,0.802851f}
 };
+
 const float BG_AV_DoorPositons[2][4] = {
     {780.487f, -493.024f, 99.9553f, 3.0976f},   //alliance
     {-1375.193f, -538.981f, 55.2824f, 0.72178f} //horde
 };
 
+
 //creaturestuff starts here
 //is related to BG_AV_CreaturePos
 enum BG_AV_CreaturePlace
@@ -513,6 +557,7 @@ enum BG_AV_CreaturePlace
     AV_CPLACE_DEFENSE_FROSTWOLF      = 25,
     AV_CPLACE_DEFENSE_ICE_GRAVE      = 29,
     AV_CPLACE_DEFENSE_FROST_HUT      = 33,
+
     AV_CPLACE_DEFENSE_DUN_S          = 37,
     AV_CPLACE_DEFENSE_DUN_N          = 41,
     AV_CPLACE_DEFENSE_ICEWING        = 45,
@@ -521,6 +566,7 @@ enum BG_AV_CreaturePlace
     AV_CPLACE_DEFENSE_TOWERPOINT     = 57,
     AV_CPLACE_DEFENSE_FROST_E        = 61,
     AV_CPLACE_DEFENSE_FROST_t        = 65,
+
     AV_CPLACE_A_MARSHAL_SOUTH       = 69,
     AV_CPLACE_A_MARSHAL_NORTH       = 70,
     AV_CPLACE_A_MARSHAL_ICE         = 71,
@@ -550,10 +596,13 @@ enum BG_AV_CreaturePlace
     AV_CPLACE_MINE_S_S_MAX      = 299,
     //boss
     AV_CPLACE_MINE_S_3          = 300,
+
     //herald
     AV_CPLACE_HERALD          = 301,
+
     AV_CPLACE_MAX = 302
 };
+
 //x, y, z, o
 const float BG_AV_CreaturePos[AV_CPLACE_MAX][4] = {
     //spiritguides
@@ -643,6 +692,7 @@ const float BG_AV_CreaturePos[AV_CPLACE_MAX][4] = {
     {-1302.41f,-259.256f,114.065f,1.67602f},
     {-1287.97f,-262.087f,114.165f,6.18264f},
     {-1291.59f,-271.166f,114.151f,5.28257f},
+
     //alliance marshall
     {721.104f,-7.64155f,50.7046f,3.45575f},// south
     {723.058f,-14.1548f,50.7046f,3.40339f},// north
@@ -653,6 +703,7 @@ const float BG_AV_CreaturePos[AV_CPLACE_MAX][4] = {
     {-1370.96f,-223.532f,98.4266f,4.93012f},
     {-1378.37f,-228.614f,99.3546f,5.38565f},
     {-1358.02f,-228.998f,98.868f,3.87768f},
+
  //irondeep mine
  //Irondeep Trogg
     {971.671f,-442.657f,57.6951f,3.1765f},
@@ -888,10 +939,13 @@ const float BG_AV_CreaturePos[AV_CPLACE_MAX][4] = {
     {-848.902f,-92.931f,68.6325f,3.33350},
     //herald
     {-48.459f,-288.802f,55.47f,1.0}
+
 };
 
+
 enum BG_AV_CreatureIds
 {
+
     AV_NPC_A_GRAVEDEFENSE0 = 0,     // stormpike Defender
     AV_NPC_A_GRAVEDEFENSE1 = 1,     // seasoned defender
     AV_NPC_A_GRAVEDEFENSE2 = 2,     // veteran defender
@@ -899,6 +953,7 @@ enum BG_AV_CreatureIds
     AV_NPC_A_TOWERDEFENSE  = 4,     // stormpike bowman
     AV_NPC_A_CAPTAIN       = 5,     // balinda
     AV_NPC_A_BOSS          = 6,     // vanndar
+
     AV_NPC_H_GRAVEDEFENSE0 = 7,     // frostwolf guardian
     AV_NPC_H_GRAVEDEFENSE1 = 8,     // seasoned guardian
     AV_NPC_H_GRAVEDEFENSE2 = 9,     // veteran guardian
@@ -906,6 +961,7 @@ enum BG_AV_CreatureIds
     AV_NPC_H_TOWERDEFENSE  = 11,    // frostwolf bowman
     AV_NPC_H_CAPTAIN       = 12,    // galvangar
     AV_NPC_H_BOSS          = 13,    // drek thar
+
     AV_NPC_A_MARSHAL_SOUTH = 14,
     AV_NPC_MARSHAL_NORTH   = 15,
     AV_NPC_A_MARSHAL_ICE   = 16,
@@ -941,7 +997,9 @@ enum BG_AV_CreatureIds
     AV_NPC_S_MINE_H_4      = 46,
     AV_NPC_HERALD          = 47,
     AV_NPC_INFO_MAX        = 48
+
 };
+
 //entry, team, minlevel, maxlevel
 //TODO this array should be removed, the only needed things are the entrys (for spawning(?) and handlekillunit)
 const uint32 BG_AV_CreatureInfo[AV_NPC_INFO_MAX][4] = {
@@ -963,37 +1021,46 @@ const uint32 BG_AV_CreatureInfo[AV_NPC_INFO_MAX][4] = {
     { 14762, 1534, 60, 60 }, //Dun Baldar North Marshal
     { 14764, 1534, 60, 60 }, //Icewing Marshal
     { 14765, 1534, 60, 60 }, //Stonehearth Marshal
+
     { 14773, 1214, 60, 60 }, //Iceblood Warmaster
     { 14776, 1214, 60, 60 }, //Tower Point Warmaster
     { 14772, 1214, 60, 60 }, //East Frostwolf Warmaster
     { 14777, 1214, 60, 60 }, //West Frostwolf Warmaster
+
     { 10987, 59, 52, 53 }, //Irondeep Trogg
     { 11600, 59, 53, 54 }, //Irondeep Shaman
     { 11602, 59, 54, 55 }, //Irondeep Skullthumper
     { 11657, 59, 58, 58 }, //Morloch
+
     {13396,469,52,53}, //irondeep alliance TODO: get the right ids
     {13080,469,53,54},
     {13098,469,54,55},
     {13078,469,58,58},
+
     {13397,67,52,53}, //irondeep horde
     {13099,67,53,54},
     {13081,67,54,55},
     {13079,67,58,58},
+
     { 11603, 59, 52, 53 }, //south mine neutral
     { 11604, 59, 53, 54 },
     { 11605, 59, 54, 55 },
     { 11677, 59, 58, 58 },
     { 10982, 59, 52, 53 }, //vermin
+
     {13317,469,52,53}, //alliance
     {13096,469,54,55}, //explorer
     {13087,469,54,55}, //invader
     {13086,469,58,58},
+
     {13316,67,52,53}, //horde
     {13097,67,54,55}, //surveypr
     {13089,67,54,55}, //guard
     {13088,67,58,58},
     {14848,67,58,58} //Herald
+
 };
+
 //x,y,z,o,static_creature_info-id
 const float BG_AV_StaticCreaturePos[AV_STATICCPLACE_MAX][5] = { //static creatures
     {-1235.31f,-340.777f,60.5088f,3.31613f,0 },//2225 - Zora Guthrek
@@ -1119,7 +1186,9 @@ const float BG_AV_StaticCreaturePos[AV_STATICCPLACE_MAX][5] = { //static creatur
     {773.651f,-497.482f,99.0408f,2.11185f,46 },//14284 - Stormpike Battleguard
     {949.1f,-506.913f,95.4237f,3.31613f,46 },//14284 - Stormpike Battleguard
     {-1370.9f,-219.793f,98.4258f,5.04381f,47}, //drek thar
+
 };
+
 const uint32 BG_AV_StaticCreatureInfo[51][4] = {
     { 2225, 1215, 55, 55 }, //Zora Guthrek
     { 3343, 1215, 55, 55 }, //Grelkor
@@ -1173,6 +1242,7 @@ const uint32 BG_AV_StaticCreatureInfo[51][4] = {
     { 11947, 1214, 61, 61 }, //Captain Galvangar
     { 11949, 1216, 61, 61 } //Captain Balinda Stonehearth
 };
+
 enum BG_AV_Graveyards
 {
     AV_GRAVE_STORM_AID         = 751,
@@ -1186,6 +1256,8 @@ enum BG_AV_Graveyards
     AV_GRAVE_MAIN_HORDE        = 610
 };
 
+
+
 const uint32 BG_AV_GraveyardIds[9]= {
   AV_GRAVE_STORM_AID,
   AV_GRAVE_STORM_GRAVE,
@@ -1197,6 +1269,7 @@ const uint32 BG_AV_GraveyardIds[9]= {
   AV_GRAVE_MAIN_ALLIANCE,
   AV_GRAVE_MAIN_HORDE
 };
+
 enum BG_AV_BUFF
 { //TODO add all other buffs here
     AV_BUFF_ARMOR = 21163,
@@ -1210,15 +1283,19 @@ enum BG_AV_States
     POINT_DESTROYED            =  2,
     POINT_CONTROLED            =  3
 };
+
 enum BG_AV_WorldStates
 {
     AV_Alliance_Score               = 3127,
     AV_Horde_Score                  = 3128,
     AV_SHOW_H_SCORE                 = 3133,
     AV_SHOW_A_SCORE                 = 3134,
+
 /*
     //the comments behind the state shows which icon overlaps the other.. but is, until now, unused and maybe not a good solution (but give few performance (: )
+
 // Graves
+
     // Alliance
     //Stormpike first aid station
     AV_AID_A_C                      = 1325,
@@ -1261,6 +1338,7 @@ enum BG_AV_WorldStates
     AV_FROSTWOLFHUT_H_C             = 1330,
     AV_FROSTWOLFHUT_H_A             = 1332, //over ac
 
+
 //Towers
     //Alliance
     //Dunbaldar South Bunker
@@ -1296,30 +1374,38 @@ enum BG_AV_WorldStates
     AV_FROSTWOLFE_CONTROLLED        = 1383,
     AV_FROSTWOLFE_DESTROYED         = 1366,
     AV_FROSTWOLFE_ASSAULTED         = 1388,
+
 //mines
+
     AV_N_MINE_N              = 1360,
     AV_N_MINE_A              = 1358,
     AV_N_MINE_H              = 1359,
+
     AV_S_MINE_N                     = 1357,
     AV_S_MINE_A                     = 1355,
     AV_S_MINE_H                     = 1356,
+
 //towers assaulted by own team (unused)
     AV_STONEH_UNUSED                = 1377,
     AV_ICEWING_UNUSED               = 1376,
     AV_DUNS_UNUSED                  = 1375,
     AV_DUNN_UNUSED                  = 1374,
+
     AV_ICEBLOOD_UNUSED              = 1395,
     AV_TOWERPOINT_UNUSED            = 1394,
     AV_FROSTWOLFE_UNUSED            = 1393,
     AV_FROSTWOLFW_UNUSED            = 1392
 */
+
 };
+
 //alliance_control neutral_control horde_control
 const uint32 BG_AV_MineWorldStates[2][3] = {
     {1358, 1360,1359},
     {1355, 1357,1356}
 };
 
+
 //alliance_control alliance_assault h_control h_assault
 const uint32 BG_AV_NodeWorldStates[16][4] = {
     //Stormpike first aid station
@@ -1353,6 +1439,7 @@ const uint32 BG_AV_NodeWorldStates[16][4] = {
     //Frostwolf West
     {1365,1387,1382,1392},
 };
+
 enum BG_AV_QuestIds
 {
     AV_QUEST_A_SCRAPS1      = 7223,
@@ -1378,6 +1465,7 @@ enum BG_AV_QuestIds
     AV_QUEST_A_RIDER_TAME   = 7027,
     AV_QUEST_H_RIDER_TAME   = 7001
 };
+
 struct BG_AV_NodeInfo
 {
     uint16       TotalOwner;
@@ -1388,7 +1476,9 @@ struct BG_AV_NodeInfo
     int          Timer;
     bool         Tower;
 };
+
 inline BG_AV_Nodes &operator++(BG_AV_Nodes &i){ return i = BG_AV_Nodes(i + 1); }
+
 class BattleGroundAVScore : public BattleGroundScore
 {
     public:
@@ -1402,24 +1492,30 @@ class BattleGroundAVScore : public BattleGroundScore
         uint32 LeadersKilled;
         uint32 SecondaryObjectives;
 };
+
 class BattleGroundAV : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundAV();
         ~BattleGroundAV();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         void RemovePlayer(Player *plr,uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         bool SetupBattleGround();
         virtual void ResetBGSubclass();
+
         /*general stuff*/
         void UpdateScore(uint16 team, int16 points);
        void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
+
         /*handlestuff*/ //these are functions which get called from extern
         virtual void EventPlayerClickedOnFlag(Player *source, GameObject* target_obj);
         void HandleKillPlayer(Player* player, Player *killer);
@@ -1427,47 +1523,62 @@ class BattleGroundAV : public BattleGround
         void HandleQuestComplete(uint32 questid, Player *player);
         bool PlayerCanDoMineQuest(int32 GOId,uint32 team);
 
+
         void EndBattleGround(uint32 winner);
+
         virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
+
     private:
         /* Nodes occupying */
         void EventPlayerAssaultsPoint(Player* player, uint32 object);
         void EventPlayerDefendsPoint(Player* player, uint32 object);
         void EventPlayerDestroyedPoint(BG_AV_Nodes node);
+
         void AssaultNode(BG_AV_Nodes node,uint16 team);
         void DestroyNode(BG_AV_Nodes node);
         void InitNode(BG_AV_Nodes node, uint16 team, bool tower);
         void DefendNode(BG_AV_Nodes node, uint16 team);
+
         void PopulateNode(BG_AV_Nodes node);
         void DePopulateNode(BG_AV_Nodes node);
+
         const BG_AV_Nodes GetNodeThroughObject(uint32 object);
         const uint32 GetObjectThroughNode(BG_AV_Nodes node);
         const char* GetNodeName(BG_AV_Nodes node);
         const bool IsTower(BG_AV_Nodes node) {   return m_Nodes[node].Tower; }
 
+
         /*mine*/
         void ChangeMineOwner(uint8 mine, uint32 team, bool initial=false);
+
         /*worldstates*/
         void FillInitialWorldStates(WorldPacket& data);
         const uint8 GetWorldStateType(uint8 state, uint16 team);
         void SendMineWorldStates(uint32 mine);
         void UpdateNodeWorldState(BG_AV_Nodes node);
+
         /*general */
         Creature* AddAVCreature(uint16 cinfoid, uint16 type);
         const uint16 GetBonusHonor(uint8 kills); //TODO remove this when mangos handles this right
+
         /*variables */
         int32 m_Team_Scores[2];
         uint32 m_Team_QuestStatus[2][9]; //[x][y] x=team y=questcounter
+
         BG_AV_NodeInfo m_Nodes[BG_AV_NODES_MAX];
+
         uint32 m_Mine_Owner[2];
         uint32 m_Mine_PrevOwner[2]; //only for worldstates needed
         int32 m_Mine_Timer; //ticks for both teams
         uint32 m_Mine_Reclaim_Timer[2];
         uint32 m_CaptainBuffTimer[2];
         bool m_CaptainAlive[2];
+
         uint8 m_MaxLevel; //TODO remove this when battleground-getmaxlevel() returns something usefull
         bool m_IsInformedNearVictory[2];
 
+
 };
+
 #endif
 
diff --git a/src/game/BattleGroundBE.cpp b/src/game/BattleGroundBE.cpp
index e79d2b606ff..05475328b01 100644
--- a/src/game/BattleGroundBE.cpp
+++ b/src/game/BattleGroundBE.cpp
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "BattleGround.h"
 #include "BattleGroundBE.h"
 #include "Language.h"
@@ -24,9 +25,11 @@
 #include "ObjectMgr.h"
 #include "Player.h"
 #include "WorldPacket.h"
+
 BattleGroundBE::BattleGroundBE()
 {
     m_BgObjects.resize(BG_BE_OBJECT_MAX);
+
     m_StartDelayTimes[BG_STARTING_EVENT_FIRST]  = BG_START_DELAY_1M;
     m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
     m_StartDelayTimes[BG_STARTING_EVENT_THIRD]  = BG_START_DELAY_15S;
@@ -37,72 +40,94 @@ BattleGroundBE::BattleGroundBE()
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_ARENA_FIFTEEN_SECONDS;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
 }
+
 BattleGroundBE::~BattleGroundBE()
 {
+
 }
+
 void BattleGroundBE::Update(uint32 diff)
 {
     BattleGround::Update(diff);
+
     /*if (GetStatus() == STATUS_IN_PROGRESS)
     {
         // update something
     }*/
 }
+
 void BattleGroundBE::StartingEventCloseDoors()
 {
     for(uint32 i = BG_BE_OBJECT_DOOR_1; i <= BG_BE_OBJECT_DOOR_4; ++i)
         SpawnBGObject(i, RESPAWN_IMMEDIATELY);
+
     for(uint32 i = BG_BE_OBJECT_BUFF_1; i <= BG_BE_OBJECT_BUFF_2; ++i)
         SpawnBGObject(i, RESPAWN_ONE_DAY);
 }
+
 void BattleGroundBE::StartingEventOpenDoors()
 {
     for(uint32 i = BG_BE_OBJECT_DOOR_1; i <= BG_BE_OBJECT_DOOR_2; ++i)
         DoorOpen(i);
+
     for(uint32 i = BG_BE_OBJECT_BUFF_1; i <= BG_BE_OBJECT_BUFF_2; ++i)
         SpawnBGObject(i, 60);
 }
+
 void BattleGroundBE::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in constructor
     BattleGroundBEScore* sc = new BattleGroundBEScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
+
     UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
 }
+
 void BattleGroundBE::RemovePlayer(Player* /*plr*/, uint64 /*guid*/)
 {
     if (GetStatus() == STATUS_WAIT_LEAVE)
         return;
+
     UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
+
     CheckArenaWinConditions();
 }
+
 void BattleGroundBE::HandleKillPlayer(Player *player, Player *killer)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     if (!killer)
     {
         sLog.outError("Killer player not found");
         return;
     }
+
     BattleGround::HandleKillPlayer(player,killer);
+
     UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
+
     CheckArenaWinConditions();
 }
+
 bool BattleGroundBE::HandlePlayerUnderMap(Player *player)
 {
     player->TeleportTo(GetMapId(),6238.930176,262.963470,0.889519,player->GetOrientation(),false);
     return true;
 }
+
 void BattleGroundBE::HandleAreaTrigger(Player *Source, uint32 Trigger)
 {
     // this is wrong way to implement these things. On official it done by gameobject spell cast.
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     //uint32 SpellId = 0;
     //uint64 buff_guid = 0;
     switch(Trigger)
@@ -118,20 +143,24 @@ void BattleGroundBE::HandleAreaTrigger(Player *Source, uint32 Trigger)
             Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
             break;
     }
+
     //if (buff_guid)
     //    HandleTriggerBuff(buff_guid,Source);
 }
+
 void BattleGroundBE::FillInitialWorldStates(WorldPacket &data)
 {
     data << uint32(0x9f1) << uint32(GetAlivePlayersCountByTeam(ALLIANCE));           // 7
     data << uint32(0x9f0) << uint32(GetAlivePlayersCountByTeam(HORDE));           // 8
     data << uint32(0x9f3) << uint32(1);           // 9
 }
+
 void BattleGroundBE::Reset()
 {
     //call parent's class reset
     BattleGround::Reset();
 }
+
 bool BattleGroundBE::SetupBattleGround()
 {
     // gates
@@ -146,16 +175,22 @@ bool BattleGroundBE::SetupBattleGround()
         sLog.outErrorDb("BatteGroundBE: Failed to spawn some object!");
         return false;
     }
+
     return true;
 }
+
 void BattleGroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value)
 {
+
     BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
     if(itr == m_PlayerScores.end())                         // player not found...
         return;
+
     //there is nothing special in this score
     BattleGround::UpdatePlayerScore(Source,type,value);
+
 }
+
 /*
 21:45:46 id:231310 [S2C] SMSG_INIT_WORLD_STATES (706 = 0x02C2) len: 86
 0000: 32 02 00 00 76 0e 00 00 00 00 00 00 09 00 f3 09  |  2...v...........
@@ -164,6 +199,7 @@ void BattleGroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
 0030: 00 00 00 00 00 00 d7 08 00 00 00 00 00 00 d6 08  |  ................
 0040: 00 00 00 00 00 00 d5 08 00 00 00 00 00 00 d3 08  |  ................
 0050: 00 00 00 00 00 00                                |  ......
+
 spell 32724 - Gold Team
 spell 32725 - Green Team
 35774 Gold Team
diff --git a/src/game/BattleGroundBE.h b/src/game/BattleGroundBE.h
index b3996498e53..e75e332f44f 100644
--- a/src/game/BattleGroundBE.h
+++ b/src/game/BattleGroundBE.h
@@ -19,7 +19,9 @@
  */
 #ifndef __BATTLEGROUNDBE_H
 #define __BATTLEGROUNDBE_H
+
 class BattleGround;
+
 enum BattleGroundBEObjectTypes
 {
     BG_BE_OBJECT_DOOR_1         = 0,
@@ -30,6 +32,7 @@ enum BattleGroundBEObjectTypes
     BG_BE_OBJECT_BUFF_2         = 5,
     BG_BE_OBJECT_MAX            = 6
 };
+
 enum BattleGroundBEObjects
 {
     BG_BE_OBJECT_TYPE_DOOR_1    = 183971,
@@ -39,23 +42,28 @@ enum BattleGroundBEObjects
     BG_BE_OBJECT_TYPE_BUFF_1    = 184663,
     BG_BE_OBJECT_TYPE_BUFF_2    = 184664
 };
+
 class BattleGroundBEScore : public BattleGroundScore
 {
     public:
         BattleGroundBEScore() {};
         virtual ~BattleGroundBEScore() {};
 };
+
 class BattleGroundBE : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundBE();
         ~BattleGroundBE();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         void RemovePlayer(Player *plr, uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         bool SetupBattleGround();
@@ -63,6 +71,7 @@ class BattleGroundBE : public BattleGround
         virtual void FillInitialWorldStates(WorldPacket &d);
         void HandleKillPlayer(Player* player, Player *killer);
         bool HandlePlayerUnderMap(Player * plr);
+
         /* Scorekeeping */
         void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
 };
diff --git a/src/game/BattleGroundDS.cpp b/src/game/BattleGroundDS.cpp
index e133bc740b0..0be870be175 100644
--- a/src/game/BattleGroundDS.cpp
+++ b/src/game/BattleGroundDS.cpp
@@ -15,12 +15,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "BattleGround.h"
 #include "BattleGroundDS.h"
 #include "Language.h"
 #include "Player.h"
+
 BattleGroundDS::BattleGroundDS()
 {
+
     m_StartDelayTimes[BG_STARTING_EVENT_FIRST]  = BG_START_DELAY_1M;
     m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
     m_StartDelayTimes[BG_STARTING_EVENT_THIRD]  = BG_START_DELAY_15S;
@@ -31,36 +34,47 @@ BattleGroundDS::BattleGroundDS()
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_ARENA_FIFTEEN_SECONDS;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
 }
+
 BattleGroundDS::~BattleGroundDS()
 {
+
 }
+
 void BattleGroundDS::Update(uint32 diff)
 {
     BattleGround::Update(diff);
 }
+
 void BattleGroundDS::StartingEventCloseDoors()
 {
 }
+
 void BattleGroundDS::StartingEventOpenDoors()
 {
 }
+
 void BattleGroundDS::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in constructor
     BattleGroundDSScore* sc = new BattleGroundDSScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
 }
+
 void BattleGroundDS::RemovePlayer(Player * /*plr*/, uint64 /*guid*/)
 {
 }
+
 void BattleGroundDS::HandleKillPlayer(Player* player, Player* killer)
 {
     BattleGround::HandleKillPlayer(player, killer);
 }
+
 void BattleGroundDS::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/)
 {
 }
+
 bool BattleGroundDS::SetupBattleGround()
 {
     return true;
diff --git a/src/game/BattleGroundDS.h b/src/game/BattleGroundDS.h
index 8b310a67da0..44a6cfbd33a 100644
--- a/src/game/BattleGroundDS.h
+++ b/src/game/BattleGroundDS.h
@@ -17,7 +17,9 @@
  */
 #ifndef __BATTLEGROUNDDS_H
 #define __BATTLEGROUNDDS_H
+
 class BattleGround;
+
 class BattleGroundDSScore : public BattleGroundScore
 {
     public:
@@ -25,17 +27,21 @@ class BattleGroundDSScore : public BattleGroundScore
         virtual ~BattleGroundDSScore() {};
         //TODO fix me
 };
+
 class BattleGroundDS : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundDS();
         ~BattleGroundDS();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         void RemovePlayer(Player *plr, uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         bool SetupBattleGround();
diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp
index 5678eeec494..0c7ea66388b 100644
--- a/src/game/BattleGroundEY.cpp
+++ b/src/game/BattleGroundEY.cpp
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "ObjectMgr.h"
 #include "World.h"
 #include "WorldPacket.h"
@@ -28,11 +29,13 @@
 #include "Object.h"
 #include "Player.h"
 #include "Util.h"
+
 // these variables aren't used outside of this file, so declare them only here
 uint32 BG_EY_HonorScoreTicks[BG_HONOR_MODE_NUM] = {
     330, // normal honor
     200  // holiday
 };
+
 BattleGroundEY::BattleGroundEY()
 {
     m_BuffChange = true;
@@ -42,17 +45,21 @@ BattleGroundEY::BattleGroundEY()
     m_Points_Trigger[BLOOD_ELF] = TR_BLOOD_ELF_BUFF;
     m_Points_Trigger[DRAENEI_RUINS] = TR_DRAENEI_RUINS_BUFF;
     m_Points_Trigger[MAGE_TOWER] = TR_MAGE_TOWER_BUFF;
+
     m_StartMessageIds[BG_STARTING_EVENT_FIRST]  = LANG_BG_EY_START_TWO_MINUTES;
     m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_EY_START_ONE_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_BG_EY_START_HALF_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_EY_HAS_BEGUN;
 }
+
 BattleGroundEY::~BattleGroundEY()
 {
 }
+
 void BattleGroundEY::Update(uint32 diff)
 {
     BattleGround::Update(diff);
+
     if (GetStatus() == STATUS_IN_PROGRESS)
     {
         m_PointAddingTimer -= diff;
@@ -64,9 +71,11 @@ void BattleGroundEY::Update(uint32 diff)
             if (m_TeamPointsCount[BG_TEAM_HORDE] > 0)
                 AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]);
         }
+
         if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND)
         {
             m_FlagsTimer -= diff;
+
             if (m_FlagsTimer < 0)
             {
                 m_FlagsTimer = 0;
@@ -76,6 +85,7 @@ void BattleGroundEY::Update(uint32 diff)
                     RespawnFlagAfterDrop();
             }
         }
+
         m_TowerCapCheckTimer -= diff;
         if (m_TowerCapCheckTimer <= 0)
         {
@@ -91,17 +101,21 @@ void BattleGroundEY::Update(uint32 diff)
         }
     }
 }
+
 void BattleGroundEY::StartingEventCloseDoors()
 {
     SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_IMMEDIATELY);
     SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_IMMEDIATELY);
+
     for(uint32 i = BG_EY_OBJECT_A_BANNER_FEL_REALVER_CENTER; i < BG_EY_OBJECT_MAX; ++i)
         SpawnBGObject(i, RESPAWN_ONE_DAY);
 }
+
 void BattleGroundEY::StartingEventOpenDoors()
 {
     SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_ONE_DAY);
     SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_ONE_DAY);
+
     for(uint32 i = BG_EY_OBJECT_N_BANNER_FEL_REALVER_CENTER; i <= BG_EY_OBJECT_FLAG_NETHERSTORM; ++i)
         SpawnBGObject(i, RESPAWN_IMMEDIATELY);
     for(uint32 i = 0; i < EY_POINTS_MAX; ++i)
@@ -111,6 +125,7 @@ void BattleGroundEY::StartingEventOpenDoors()
         SpawnBGObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REALVER + buff + i * 3, RESPAWN_IMMEDIATELY);
     }
 }
+
 void BattleGroundEY::AddPoints(uint32 Team, uint32 Points)
 {
     BattleGroundTeamId team_index = GetTeamIndexByTeamId(Team);
@@ -123,6 +138,7 @@ void BattleGroundEY::AddPoints(uint32 Team, uint32 Points)
     }
     UpdateTeamScore(Team);
 }
+
 void BattleGroundEY::CheckSomeoneJoinedPoint()
 {
     GameObject *obj = NULL;
@@ -159,6 +175,7 @@ void BattleGroundEY::CheckSomeoneJoinedPoint()
         }
     }
 }
+
 void BattleGroundEY::CheckSomeoneLeftPoint()
 {
     //reset current point counts
@@ -200,6 +217,7 @@ void BattleGroundEY::CheckSomeoneLeftPoint()
         }
     }
 }
+
 void BattleGroundEY::UpdatePointStatuses()
 {
     for(uint8 point = 0; point < EY_POINTS_MAX; ++point)
@@ -208,12 +226,14 @@ void BattleGroundEY::UpdatePointStatuses()
             continue;
         //count new point bar status:
         m_PointBarStatus[point] += (m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] < BG_EY_POINT_MAX_CAPTURERS_COUNT) ? m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] : BG_EY_POINT_MAX_CAPTURERS_COUNT;
+
         if (m_PointBarStatus[point] > BG_EY_PROGRESS_BAR_ALI_CONTROLLED)
             //point is fully alliance's
             m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_ALI_CONTROLLED;
         if (m_PointBarStatus[point] < BG_EY_PROGRESS_BAR_HORDE_CONTROLLED)
             //point is fully horde's
             m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_HORDE_CONTROLLED;
+
         uint32 pointOwnerTeamId = 0;
         //find which team should own this point
         if (m_PointBarStatus[point] <= BG_EY_PROGRESS_BAR_NEUTRAL_LOW)
@@ -222,6 +242,7 @@ void BattleGroundEY::UpdatePointStatuses()
             pointOwnerTeamId = ALLIANCE;
         else
             pointOwnerTeamId = EY_POINT_NO_OWNER;
+
         for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i)
         {
             Player *plr = objmgr.GetPlayer(m_PlayersNearPoint[point][i]);
@@ -234,6 +255,7 @@ void BattleGroundEY::UpdatePointStatuses()
                     //point was uncontrolled and player is from team which captured point
                     if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && plr->GetTeam() == pointOwnerTeamId)
                         this->EventTeamCapturedPoint(plr, point);
+
                     //point was under control and player isn't from team which controlled it
                     if (m_PointState[point] == EY_POINT_UNDER_CONTROL && plr->GetTeam() != m_PointOwnedByTeam[point])
                         this->EventTeamLostPoint(plr, point);
@@ -242,6 +264,7 @@ void BattleGroundEY::UpdatePointStatuses()
         }
     }
 }
+
 void BattleGroundEY::UpdateTeamScore(uint32 Team)
 {
     uint32 score = GetTeamScore(Team);
@@ -255,16 +278,19 @@ void BattleGroundEY::UpdateTeamScore(uint32 Team)
         PlaySoundToAll(BG_EY_SOUND_NEAR_VICTORY);
         m_IsInformedNearVictory = true;
     }*/
+
     if (score >= BG_EY_MAX_TEAM_SCORE)
     {
         score = BG_EY_MAX_TEAM_SCORE;
         EndBattleGround(Team);
     }
+
     if (Team == ALLIANCE)
         UpdateWorldState(EY_ALLIANCE_RESOURCES, score);
     else
         UpdateWorldState(EY_HORDE_RESOURCES, score);
 }
+
 void BattleGroundEY::EndBattleGround(uint32 winner)
 {
     //win reward
@@ -275,8 +301,10 @@ void BattleGroundEY::EndBattleGround(uint32 winner)
     //complete map reward
     RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
     RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
+
     BattleGround::EndBattleGround(winner);
 }
+
 void BattleGroundEY::UpdatePointsCount(uint32 Team)
 {
     if (Team == ALLIANCE)
@@ -284,6 +312,7 @@ void BattleGroundEY::UpdatePointsCount(uint32 Team)
     else
         UpdateWorldState(EY_HORDE_BASE, m_TeamPointsCount[BG_TEAM_HORDE]);
 }
+
 void BattleGroundEY::UpdatePointsIcons(uint32 Team, uint32 Point)
 {
     //we MUST firstly send 0, after that we can send 1!!!
@@ -304,14 +333,18 @@ void BattleGroundEY::UpdatePointsIcons(uint32 Team, uint32 Point)
         UpdateWorldState(m_PointsIconStruct[Point].WorldStateControlIndex, 1);
     }
 }
+
 void BattleGroundEY::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map
     BattleGroundEYScore* sc = new BattleGroundEYScore;
+
     m_PlayersNearPoint[EY_POINTS_MAX].push_back(plr->GetGUID());
+
     m_PlayerScores[plr->GetGUID()] = sc;
 }
+
 void BattleGroundEY::RemovePlayer(Player *plr, uint64 guid)
 {
     // sometimes flag aura not removed :(
@@ -335,12 +368,15 @@ void BattleGroundEY::RemovePlayer(Player *plr, uint64 guid)
         }
     }
 }
+
 void BattleGroundEY::HandleAreaTrigger(Player *Source, uint32 Trigger)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     if(!Source->isAlive())                                  //hack code, must be removed later
         return;
+
     switch(Trigger)
     {
         case TR_BLOOD_ELF_POINT:
@@ -380,6 +416,7 @@ void BattleGroundEY::HandleAreaTrigger(Player *Source, uint32 Trigger)
             break;
     }
 }
+
 bool BattleGroundEY::SetupBattleGround()
 {
         // doors
@@ -440,6 +477,7 @@ bool BattleGroundEY::SetupBattleGround()
         sLog.outErrorDb("BatteGroundEY: Failed to spawn some object BattleGround not created!");
         return false;
     }
+
     //buffs
     for (int i = 0; i < EY_POINTS_MAX; ++i)
     {
@@ -455,6 +493,7 @@ bool BattleGroundEY::SetupBattleGround()
             )
             sLog.outError("BattleGroundEY: Cannot spawn buff");
     }
+
     WorldSafeLocsEntry const *sg = NULL;
     sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_ALLIANCE);
     if (!sg || !AddSpiritGuide(EY_SPIRIT_MAIN_ALLIANCE, sg->x, sg->y, sg->z, 3.124139f, ALLIANCE))
@@ -462,18 +501,22 @@ bool BattleGroundEY::SetupBattleGround()
         sLog.outErrorDb("BatteGroundEY: Failed to spawn spirit guide! BattleGround not created!");
         return false;
     }
+
     sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_HORDE);
     if (!sg || !AddSpiritGuide(EY_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, HORDE))
     {
         sLog.outErrorDb("BatteGroundEY: Failed to spawn spirit guide! BattleGround not created!");
         return false;
     }
+
     return true;
 }
+
 void BattleGroundEY::Reset()
 {
     //call parent's class reset
     BattleGround::Reset();
+
     m_TeamScores[BG_TEAM_ALLIANCE] = 0;
     m_TeamScores[BG_TEAM_HORDE] = 0;
     m_TeamPointsCount[BG_TEAM_ALLIANCE] = 0;
@@ -488,6 +531,7 @@ void BattleGroundEY::Reset()
     m_TowerCapCheckTimer = 0;
     bool isBGWeekend = sBattleGroundMgr.IsBGWeekend(GetTypeID());
     m_HonorTics = (isBGWeekend) ? BG_EY_EYWeekendHonorTicks : BG_EY_NotEYWeekendHonorTicks;
+
     for(uint8 i = 0; i < EY_POINTS_MAX; ++i)
     {
         m_PointOwnedByTeam[i] = EY_POINT_NO_OWNER;
@@ -499,37 +543,47 @@ void BattleGroundEY::Reset()
     m_PlayersNearPoint[EY_PLAYERS_OUT_OF_POINTS].clear();
     m_PlayersNearPoint[EY_PLAYERS_OUT_OF_POINTS].reserve(30);
 }
+
 void BattleGroundEY::RespawnFlag(bool send_message)
 {
     if (m_FlagCapturedBgObjectType > 0)
         SpawnBGObject(m_FlagCapturedBgObjectType, RESPAWN_ONE_DAY);
+
     m_FlagCapturedBgObjectType = 0;
     m_FlagState = BG_EY_FLAG_STATE_ON_BASE;
     SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_IMMEDIATELY);
+
     if (send_message)
     {
         SendMessageToAll(LANG_BG_EY_RESETED_FLAG, CHAT_MSG_BG_SYSTEM_NEUTRAL);
         PlaySoundToAll(BG_EY_SOUND_FLAG_RESET);             // flags respawned sound...
     }
+
     UpdateWorldState(NETHERSTORM_FLAG, 1);
 }
+
 void BattleGroundEY::RespawnFlagAfterDrop()
 {
     RespawnFlag(true);
+
     GameObject *obj = HashMapHolder::Find(GetDroppedFlagGUID());
     if (obj)
         obj->Delete();
     else
         sLog.outError("BattleGroundEY: Unknown dropped flag guid: %u",GUID_LOPART(GetDroppedFlagGUID()));
+
     SetDroppedFlagGUID(0);
 }
+
 void BattleGroundEY::HandleKillPlayer(Player *player, Player *killer)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     BattleGround::HandleKillPlayer(player, killer);
     EventPlayerDroppedFlag(player);
 }
+
 void BattleGroundEY::EventPlayerDroppedFlag(Player *Source)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
@@ -543,10 +597,13 @@ void BattleGroundEY::EventPlayerDroppedFlag(Player *Source)
         }
         return;
     }
+
     if (!IsFlagPickedup())
         return;
+
     if (GetFlagPickerGUID() != Source->GetGUID())
         return;
+
     SetFlagPicker(0);
     Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
     m_FlagState = BG_EY_FLAG_STATE_ON_GROUND;
@@ -556,15 +613,18 @@ void BattleGroundEY::EventPlayerDroppedFlag(Player *Source)
     //this does not work correctly :( (it should remove flag carrier name)
     UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_WAIT_RESPAWN);
     UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_WAIT_RESPAWN);
+
     if (Source->GetTeam() == ALLIANCE)
         SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL);
     else
         SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL);
 }
+
 void BattleGroundEY::EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj)
 {
     if (GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedup() || !Source->IsWithinDistInMap(target_obj, 10))
         return;
+
     if (Source->GetTeam() == ALLIANCE)
     {
         UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_ON_PLAYER);
@@ -575,27 +635,34 @@ void BattleGroundEY::EventPlayerClickedOnFlag(Player *Source, GameObject* target
         UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_ON_PLAYER);
         PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_HORDE);
     }
+
     if (m_FlagState == BG_EY_FLAG_STATE_ON_BASE)
         UpdateWorldState(NETHERSTORM_FLAG, 0);
     m_FlagState = BG_EY_FLAG_STATE_ON_PLAYER;
+
     SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_ONE_DAY);
     SetFlagPicker(Source->GetGUID());
     //get flag aura on player
     Source->CastSpell(Source, BG_EY_NETHERSTORM_FLAG_SPELL, true);
     Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
+
     if (Source->GetTeam() == ALLIANCE)
         PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, Source->GetName());
     else
         PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, Source->GetName());
 }
+
 void BattleGroundEY::EventTeamLostPoint(Player *Source, uint32 Point)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     //Natural point
     uint32 Team = m_PointOwnedByTeam[Point];
+
     if (!Team)
         return;
+
     if (Team == ALLIANCE)
     {
         m_TeamPointsCount[BG_TEAM_ALLIANCE]--;
@@ -610,27 +677,36 @@ void BattleGroundEY::EventTeamLostPoint(Player *Source, uint32 Point)
         SpawnBGObject(m_LoosingPointTypes[Point].DespawnObjectTypeHorde + 1, RESPAWN_ONE_DAY);
         SpawnBGObject(m_LoosingPointTypes[Point].DespawnObjectTypeHorde + 2, RESPAWN_ONE_DAY);
     }
+
     SpawnBGObject(m_LoosingPointTypes[Point].SpawnNeutralObjectType, RESPAWN_IMMEDIATELY);
     SpawnBGObject(m_LoosingPointTypes[Point].SpawnNeutralObjectType + 1, RESPAWN_IMMEDIATELY);
     SpawnBGObject(m_LoosingPointTypes[Point].SpawnNeutralObjectType + 2, RESPAWN_IMMEDIATELY);
+
     //buff isn't despawned
+
     m_PointOwnedByTeam[Point] = EY_POINT_NO_OWNER;
     m_PointState[Point] = EY_POINT_NO_OWNER;
+
     if (Team == ALLIANCE)
         SendMessageToAll(m_LoosingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
     else
         SendMessageToAll(m_LoosingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source);
+
     UpdatePointsIcons(Team, Point);
     UpdatePointsCount(Team);
 }
+
 void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     uint32 Team = Source->GetTeam();
+
     SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType, RESPAWN_ONE_DAY);
     SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, RESPAWN_ONE_DAY);
     SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 2, RESPAWN_ONE_DAY);
+
     if (Team == ALLIANCE)
     {
         m_TeamPointsCount[BG_TEAM_ALLIANCE]++;
@@ -645,39 +721,53 @@ void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point)
         SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, RESPAWN_IMMEDIATELY);
         SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, RESPAWN_IMMEDIATELY);
     }
+
     //buff isn't respawned
+
     m_PointOwnedByTeam[Point] = Team;
     m_PointState[Point] = EY_POINT_UNDER_CONTROL;
+
     if (Team == ALLIANCE)
         SendMessageToAll(m_CapturingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
     else
         SendMessageToAll(m_CapturingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source);
+
     if (m_BgCreatures[Point])
         DelCreature(Point);
+
     WorldSafeLocsEntry const *sg = NULL;
     sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveYardId);
     if (!sg || !AddSpiritGuide(Point, sg->x, sg->y, sg->z, 3.124139f, Team))
         sLog.outError("BatteGroundEY: Failed to spawn spirit guide! point: %u, team: %u, graveyard_id: %u",
             Point, Team, m_CapturingPointTypes[Point].GraveYardId);
+
 //    SpawnBGCreature(Point,RESPAWN_IMMEDIATELY);
+
     UpdatePointsIcons(Team, Point);
     UpdatePointsCount(Team);
 }
+
 void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, uint32 BgObjectType)
 {
     if (GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGUID() != Source->GetGUID())
         return;
+
     SetFlagPicker(0);
     m_FlagState = BG_EY_FLAG_STATE_WAIT_RESPAWN;
     Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
+
     Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
+
     if (Source->GetTeam() == ALLIANCE)
         PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE);
     else
         PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_HORDE);
+
     SpawnBGObject(BgObjectType, RESPAWN_IMMEDIATELY);
+
     m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME;
     m_FlagCapturedBgObjectType = BgObjectType;
+
     uint8 team_id = 0;
     if (Source->GetTeam() == ALLIANCE)
     {
@@ -689,15 +779,19 @@ void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, uint32 BgObjectType
         team_id = BG_TEAM_HORDE;
         SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_H, CHAT_MSG_BG_SYSTEM_HORDE, Source);
     }
+
     if (m_TeamPointsCount[team_id] > 0)
         AddPoints(Source->GetTeam(), BG_EY_FlagPoints[m_TeamPointsCount[team_id] - 1]);
+
     UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1);
 }
+
 void BattleGroundEY::UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
 {
     BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
     if(itr == m_PlayerScores.end())                         // player not found
         return;
+
     switch(type)
     {
         case SCORE_FLAG_CAPTURES:                           // flags captured
@@ -708,6 +802,7 @@ void BattleGroundEY::UpdatePlayerScore(Player *Source, uint32 type, uint32 value
             break;
     }
 }
+
 void BattleGroundEY::FillInitialWorldStates(WorldPacket& data)
 {
     data << uint32(EY_HORDE_BASE) << uint32(m_TeamPointsCount[BG_TEAM_HORDE]);
@@ -720,19 +815,33 @@ void BattleGroundEY::FillInitialWorldStates(WorldPacket& data)
     data << uint32(0xab1) << uint32(0x0);
     data << uint32(0xab0) << uint32(0x0);
     data << uint32(0xaaf) << uint32(0x0);
+
     data << uint32(DRAENEI_RUINS_HORDE_CONTROL)     << uint32(m_PointOwnedByTeam[DRAENEI_RUINS] == HORDE && m_PointState[DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL);
+
     data << uint32(DRAENEI_RUINS_ALLIANCE_CONTROL)  << uint32(m_PointOwnedByTeam[DRAENEI_RUINS] == ALLIANCE && m_PointState[DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL);
+
     data << uint32(DRAENEI_RUINS_UNCONTROL)         << uint32(m_PointState[DRAENEI_RUINS] != EY_POINT_UNDER_CONTROL);
+
     data << uint32(MAGE_TOWER_ALLIANCE_CONTROL)     << uint32(m_PointOwnedByTeam[MAGE_TOWER] == ALLIANCE && m_PointState[MAGE_TOWER] == EY_POINT_UNDER_CONTROL);
+
     data << uint32(MAGE_TOWER_HORDE_CONTROL)        << uint32(m_PointOwnedByTeam[MAGE_TOWER] == HORDE && m_PointState[MAGE_TOWER] == EY_POINT_UNDER_CONTROL);
+
     data << uint32(MAGE_TOWER_UNCONTROL)            << uint32(m_PointState[MAGE_TOWER] != EY_POINT_UNDER_CONTROL);
+
     data << uint32(FEL_REAVER_HORDE_CONTROL)        << uint32(m_PointOwnedByTeam[FEL_REALVER] == HORDE && m_PointState[FEL_REALVER] == EY_POINT_UNDER_CONTROL);
+
     data << uint32(FEL_REAVER_ALLIANCE_CONTROL)     << uint32(m_PointOwnedByTeam[FEL_REALVER] == ALLIANCE && m_PointState[FEL_REALVER] == EY_POINT_UNDER_CONTROL);
+
     data << uint32(FEL_REAVER_UNCONTROL)            << uint32(m_PointState[FEL_REALVER] != EY_POINT_UNDER_CONTROL);
+
     data << uint32(BLOOD_ELF_HORDE_CONTROL)         << uint32(m_PointOwnedByTeam[BLOOD_ELF] == HORDE && m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL);
+
     data << uint32(BLOOD_ELF_ALLIANCE_CONTROL)      << uint32(m_PointOwnedByTeam[BLOOD_ELF] == ALLIANCE && m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL);
+
     data << uint32(BLOOD_ELF_UNCONTROL)             << uint32(m_PointState[BLOOD_ELF] != EY_POINT_UNDER_CONTROL);
+
     data << uint32(NETHERSTORM_FLAG)                << uint32(m_FlagState == BG_EY_FLAG_STATE_ON_BASE);
+
     data << uint32(0xad2) << uint32(0x1);
     data << uint32(0xad1) << uint32(0x1);
     data << uint32(0xabe) << uint32(GetTeamScore(HORDE));
@@ -743,31 +852,39 @@ void BattleGroundEY::FillInitialWorldStates(WorldPacket& data)
     data << uint32(0xa9e) << uint32(0x0);
     data << uint32(0xc0d) << uint32(0x17b);
 }
+
 WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(Player* player)
 {
     uint32 g_id = 0;
+
     switch(player->GetTeam())
     {
         case ALLIANCE: g_id = EY_GRAVEYARD_MAIN_ALLIANCE; break;
         case HORDE:    g_id = EY_GRAVEYARD_MAIN_HORDE;    break;
         default:       return NULL;
     }
+
     float distance, nearestDistance;
+
     WorldSafeLocsEntry const* entry = NULL;
     WorldSafeLocsEntry const* nearestEntry = NULL;
     entry = sWorldSafeLocsStore.LookupEntry(g_id);
     nearestEntry = entry;
+
     if (!entry)
     {
         sLog.outError("BattleGroundEY: Not found the main team graveyard. Graveyard system isn't working!");
         return NULL;
     }
+
     float plr_x = player->GetPositionX();
     float plr_y = player->GetPositionY();
     float plr_z = player->GetPositionZ();
 
+
     distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z);
     nearestDistance = distance;
+
     for(uint8 i = 0; i < EY_POINTS_MAX; ++i)
     {
         if (m_PointOwnedByTeam[i]==player->GetTeam() && m_PointState[i]==EY_POINT_UNDER_CONTROL)
@@ -786,13 +903,16 @@ WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(Player* player)
             }
         }
     }
+
     return nearestEntry;
 }
+
 bool BattleGroundEY::IsAllNodesConrolledByTeam(uint32 team) const
 {
     uint32 count = 0;
     for(int i = 0; i < EY_POINTS_MAX; ++i)
         if (m_PointOwnedByTeam[i] == team && m_PointState[i] == EY_POINT_UNDER_CONTROL)
             ++count;
+
     return count == EY_POINTS_MAX;
 }
diff --git a/src/game/BattleGroundEY.h b/src/game/BattleGroundEY.h
index 086c4d79fbd..3385a06bfb0 100644
--- a/src/game/BattleGroundEY.h
+++ b/src/game/BattleGroundEY.h
@@ -17,12 +17,17 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef __BATTLEGROUNDEY_H
 #define __BATTLEGROUNDEY_H
+
 #include "Language.h"
+
 class BattleGround;
+
 #define BG_EY_FLAG_RESPAWN_TIME         (10*IN_MILISECONDS) //10 seconds
 #define BG_EY_FPOINTS_TICK_TIME         (2*IN_MILISECONDS)  //2 seconds
+
 enum BG_EY_WorldStates
 {
     EY_ALLIANCE_RESOURCES           = 2749,
@@ -49,6 +54,7 @@ enum BG_EY_WorldStates
     NETHERSTORM_FLAG_STATE_ALLIANCE = 2769,
     NETHERSTORM_FLAG_STATE_HORDE    = 2770
 };
+
 enum BG_EY_ProgressBarConsts
 {
     BG_EY_POINT_MAX_CAPTURERS_COUNT     = 5,
@@ -62,6 +68,7 @@ enum BG_EY_ProgressBarConsts
     BG_EY_PROGRESS_BAR_NEUTRAL_HIGH     = 70,
     BG_EY_PROGRESS_BAR_ALI_CONTROLLED   = 100
 };
+
 enum BG_EY_Sounds
 {
     //strange ids, but sure about them
@@ -71,11 +78,13 @@ enum BG_EY_Sounds
     BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE  = 8173,
     BG_EY_SOUND_FLAG_RESET              = 8192
 };
+
 enum BG_EY_Spells
 {
     BG_EY_NETHERSTORM_FLAG_SPELL        = 34976,
     BG_EY_PLAYER_DROPPED_FLAG_SPELL     = 34991
 };
+
 enum EYBattleGroundObjectEntry
 {
     BG_OBJECT_A_DOOR_EY_ENTRY           = 184719,           //Alliance door
@@ -91,6 +100,7 @@ enum EYBattleGroundObjectEntry
     BG_OBJECT_HU_TOWER_CAP_EY_ENTRY     = 184082,           //Human Tower Cap Pt
     BG_OBJECT_DR_TOWER_CAP_EY_ENTRY     = 184083            //Draenei Tower Cap Pt
 };
+
 enum EYBattleGroundPointsTrigger
 {
     TR_BLOOD_ELF_POINT        = 4476,
@@ -102,6 +112,7 @@ enum EYBattleGroundPointsTrigger
     TR_MAGE_TOWER_BUFF        = 4570,
     TR_DRAENEI_RUINS_BUFF     = 4571
 };
+
 enum EYBattleGroundGaveyards
 {
     EY_GRAVEYARD_MAIN_ALLIANCE     = 1103,
@@ -111,15 +122,18 @@ enum EYBattleGroundGaveyards
     EY_GRAVEYARD_DRAENEI_RUINS     = 1107,
     EY_GRAVEYARD_MAGE_TOWER        = 1108
 };
+
 enum EYBattleGroundPoints
 {
     FEL_REALVER     = 0,
     BLOOD_ELF       = 1,
     DRAENEI_RUINS   = 2,
     MAGE_TOWER      = 3,
+
     EY_PLAYERS_OUT_OF_POINTS  = 4,
     EY_POINTS_MAX             = 4
 };
+
 enum EYBattleGroundCreaturesTypes
 {
     EY_SPIRIT_FEL_REALVER      = 0,
@@ -128,8 +142,10 @@ enum EYBattleGroundCreaturesTypes
     EY_SPIRIT_MAGE_TOWER       = 3,
     EY_SPIRIT_MAIN_ALLIANCE    = 4,
     EY_SPIRIT_MAIN_HORDE       = 5,
+
     BG_EY_CREATURES_MAX        = 6
 };
+
 enum EYBattleGroundObjectTypes
 {
     BG_EY_OBJECT_DOOR_A                         = 0,
@@ -194,13 +210,16 @@ enum EYBattleGroundObjectTypes
     BG_EY_OBJECT_BERSERKBUFF_MAGE_TOWER         = 58,
     BG_EY_OBJECT_MAX                            = 59
 };
+
 #define BG_EY_NotEYWeekendHonorTicks    330
 #define BG_EY_EYWeekendHonorTicks       200
+
 enum BG_EY_Score
 {
     BG_EY_WARNING_NEAR_VICTORY_SCORE    = 1800,
     BG_EY_MAX_TEAM_SCORE                = 2000
 };
+
 enum BG_EY_FlagState
 {
     BG_EY_FLAG_STATE_ON_BASE      = 0,
@@ -208,12 +227,14 @@ enum BG_EY_FlagState
     BG_EY_FLAG_STATE_ON_PLAYER    = 2,
     BG_EY_FLAG_STATE_ON_GROUND    = 3
 };
+
 enum EYBattleGroundPointState
 {
     EY_POINT_NO_OWNER           = 0,
     EY_POINT_STATE_UNCONTROLLED = 0,
     EY_POINT_UNDER_CONTROL      = 3
 };
+
 struct BattleGroundEYPointIconsStruct
 {
     BattleGroundEYPointIconsStruct(uint32 _WorldStateControlIndex, uint32 _WorldStateAllianceControlledIndex, uint32 _WorldStateHordeControlledIndex)
@@ -222,6 +243,7 @@ struct BattleGroundEYPointIconsStruct
     uint32 WorldStateAllianceControlledIndex;
     uint32 WorldStateHordeControlledIndex;
 };
+
 struct BattleGroundEYLoosingPointStruct
 {
     BattleGroundEYLoosingPointStruct(uint32 _SpawnNeutralObjectType, uint32 _DespawnObjectTypeAlliance, uint32 _MessageIdAlliance, uint32 _DespawnObjectTypeHorde, uint32 _MessageIdHorde)
@@ -229,12 +251,14 @@ struct BattleGroundEYLoosingPointStruct
         DespawnObjectTypeAlliance(_DespawnObjectTypeAlliance), MessageIdAlliance(_MessageIdAlliance),
         DespawnObjectTypeHorde(_DespawnObjectTypeHorde), MessageIdHorde(_MessageIdHorde)
     {}
+
     uint32 SpawnNeutralObjectType;
     uint32 DespawnObjectTypeAlliance;
     uint32 MessageIdAlliance;
     uint32 DespawnObjectTypeHorde;
     uint32 MessageIdHorde;
 };
+
 struct BattleGroundEYCapturingPointStruct
 {
     BattleGroundEYCapturingPointStruct(uint32 _DespawnNeutralObjectType, uint32 _SpawnObjectTypeAlliance, uint32 _MessageIdAlliance, uint32 _SpawnObjectTypeHorde, uint32 _MessageIdHorde, uint32 _GraveYardId)
@@ -243,6 +267,7 @@ struct BattleGroundEYCapturingPointStruct
         SpawnObjectTypeHorde(_SpawnObjectTypeHorde), MessageIdHorde(_MessageIdHorde),
         GraveYardId(_GraveYardId)
     {}
+
     uint32 DespawnNeutralObjectType;
     uint32 SpawnObjectTypeAlliance;
     uint32 MessageIdAlliance;
@@ -250,8 +275,10 @@ struct BattleGroundEYCapturingPointStruct
     uint32 MessageIdHorde;
     uint32 GraveYardId;
 };
+
 const uint8  BG_EY_TickPoints[EY_POINTS_MAX] = {1, 2, 5, 10};
 const uint32 BG_EY_FlagPoints[EY_POINTS_MAX] = {75, 85, 100, 500};
+
 //constant arrays:
 const BattleGroundEYPointIconsStruct m_PointsIconStruct[EY_POINTS_MAX] =
 {
@@ -274,6 +301,7 @@ const BattleGroundEYCapturingPointStruct m_CapturingPointTypes[EY_POINTS_MAX] =
     BattleGroundEYCapturingPointStruct(BG_EY_OBJECT_N_BANNER_DRAENEI_RUINS_CENTER, BG_EY_OBJECT_A_BANNER_DRAENEI_RUINS_CENTER, LANG_BG_EY_HAS_TAKEN_A_D_RUINS, BG_EY_OBJECT_H_BANNER_DRAENEI_RUINS_CENTER, LANG_BG_EY_HAS_TAKEN_H_D_RUINS, EY_GRAVEYARD_DRAENEI_RUINS),
     BattleGroundEYCapturingPointStruct(BG_EY_OBJECT_N_BANNER_MAGE_TOWER_CENTER, BG_EY_OBJECT_A_BANNER_MAGE_TOWER_CENTER, LANG_BG_EY_HAS_TAKEN_A_M_TOWER, BG_EY_OBJECT_H_BANNER_MAGE_TOWER_CENTER, LANG_BG_EY_HAS_TAKEN_H_M_TOWER, EY_GRAVEYARD_MAGE_TOWER)
 };
+
 class BattleGroundEYScore : public BattleGroundScore
 {
     public:
@@ -281,17 +309,21 @@ class BattleGroundEYScore : public BattleGroundScore
         virtual ~BattleGroundEYScore() {};
         uint32 FlagCaptures;
 };
+
 class BattleGroundEY : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundEY();
         ~BattleGroundEY();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         /* BG Flags */
         uint64 GetFlagPickerGUID() const    { return m_FlagKeeper; }
         void SetFlagPicker(uint64 guid)     { m_FlagKeeper = guid; }
@@ -299,6 +331,7 @@ class BattleGroundEY : public BattleGround
         uint8 GetFlagState() const          { return m_FlagState; }
         void RespawnFlag(bool send_message);
         void RespawnFlagAfterDrop();
+
         void RemovePlayer(Player *plr,uint64 guid);
         void HandleBuffUse(uint64 const& buff_guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
@@ -312,9 +345,11 @@ class BattleGroundEY : public BattleGround
         virtual void FillInitialWorldStates(WorldPacket& data);
         void SetDroppedFlagGUID(uint64 guid)       { m_DroppedFlagGUID = guid;}
         uint64 GetDroppedFlagGUID() const          { return m_DroppedFlagGUID;}
+
         /* Battleground Events */
         virtual void EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj);
         virtual void EventPlayerDroppedFlag(Player *Source);
+
         /* achievement req. */
         bool IsAllNodesConrolledByTeam(uint32 team) const;
     private:
@@ -323,30 +358,38 @@ class BattleGroundEY : public BattleGround
         void EventTeamLostPoint(Player *Source, uint32 Point);
         void UpdatePointsCount(uint32 Team);
         void UpdatePointsIcons(uint32 Team, uint32 Point);
+
         /* Point status updating procedures */
         void CheckSomeoneLeftPoint();
         void CheckSomeoneJoinedPoint();
         void UpdatePointStatuses();
+
         /* Scorekeeping */
         uint32 GetTeamScore(uint32 Team) const { return m_TeamScores[GetTeamIndexByTeamId(Team)]; }
         void AddPoints(uint32 Team, uint32 Points);
+
         void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; }
         void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; }
+
         uint32 m_HonorScoreTics[2];
         uint32 m_TeamPointsCount[2];
+
         uint32 m_Points_Trigger[EY_POINTS_MAX];
+
         uint64 m_FlagKeeper;                                // keepers guid
         uint64 m_DroppedFlagGUID;
         uint32 m_FlagCapturedBgObjectType;                  // type that should be despawned when flag is captured
         uint8 m_FlagState;                                  // for checking flag state
         int32 m_FlagsTimer;
         int32 m_TowerCapCheckTimer;
+
         uint32 m_PointOwnedByTeam[EY_POINTS_MAX];
         uint8 m_PointState[EY_POINTS_MAX];
         int32 m_PointBarStatus[EY_POINTS_MAX];
         typedef std::vector PlayersNearPointType;
         PlayersNearPointType m_PlayersNearPoint[EY_POINTS_MAX + 1];
         uint8 m_CurrentPointPlayersCount[2*EY_POINTS_MAX];
+
         int32 m_PointAddingTimer;
         uint32 m_HonorTics;
 };
diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp
index 1e685ec1f3a..3e7c453e300 100644
--- a/src/game/BattleGroundHandler.cpp
+++ b/src/game/BattleGroundHandler.cpp
@@ -17,11 +17,13 @@
  * 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 "ObjectAccessor.h"
 #include "ObjectMgr.h"
 #include "WorldPacket.h"
 #include "WorldSession.h"
+
 #include "ArenaTeam.h"
 #include "BattleGroundMgr.h"
 #include "BattleGroundWS.h"
@@ -32,33 +34,42 @@
 #include "Player.h"
 #include "Object.h"
 #include "Opcodes.h"
+
 void WorldSession::HandleBattlemasterHelloOpcode( WorldPacket & recv_data )
 {
     uint64 guid;
     recv_data >> guid;
     sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)));
+
     Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
     if (!unit)
         return;
+
     if(!unit->isBattleMaster())                             // it's not battlemaster
         return;
+
     // Stop the npc if moving
     unit->StopMoving();
+
     BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(unit->GetEntry());
+
     if (!_player->GetBGAccessByLevel(bgTypeId))
     {
                                                             // temp, must be gossip message...
         SendNotification(LANG_YOUR_BG_LEVEL_REQ_ERROR);
         return;
     }
+
     SendBattlegGroundList(guid, bgTypeId);
 }
+
 void WorldSession::SendBattlegGroundList( uint64 guid, BattleGroundTypeId bgTypeId )
 {
     WorldPacket data;
     sBattleGroundMgr.BuildBattleGroundListPacket(&data, guid, _player, bgTypeId, 0);
     SendPacket( &data );
 }
+
 void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
 {
     uint64 guid;
@@ -67,31 +78,40 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
     uint8 joinAsGroup;
     bool isPremade = false;
     Group * grp;
+
     recv_data >> guid;                                      // battlemaster guid
     recv_data >> bgTypeId_;                                 // battleground type id (DBC id)
     recv_data >> instanceId;                                // instance id, 0 if First Available selected
     recv_data >> joinAsGroup;                               // join as group
+
     if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
     {
         sLog.outError("Battleground: invalid bgtype (%u) received. possible cheater? player guid %u",bgTypeId_,_player->GetGUIDLow());
         return;
     }
+
     BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
+
     sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid)));
+
     // can do this, since it's battleground, not arena
     BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, 0);
+
     // ignore if player is already in BG
     if (_player->InBattleGround())
         return;
+
     // get bg instance or bg template if instance not found
     BattleGround *bg = NULL;
     if (instanceId)
         bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId);
+
     if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
     {
         sLog.outError("Battleground: no available bg / template found");
         return;
     }
+
     // check queueing conditions
     if (!joinAsGroup)
     {
@@ -126,6 +146,7 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
         }
     }
     // if we're here, then the conditions to join a bg are met. We can proceed in joining.
+
     // _player->GetGroup() was already checked, grp is already initialized
     GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, 0, false, isPremade, 0);
     uint32 avgTime = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
@@ -136,7 +157,9 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
         {
             Player *member = itr->getSource();
             if(!member) continue;   // this should never happen
+
             uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);           // add to queue
+
             WorldPacket data;
                                                             // send status packet (in queue)
             sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType);
@@ -152,10 +175,12 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
     {
         // already checked if queueSlot is valid, now just get it
         uint32 queueSlot = _player->AddBattleGroundQueueId(bgQueueTypeId);
+
         WorldPacket data;
                                                             // send status packet (in queue)
         sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType);
         SendPacket(&data);
+
         sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddPlayer(_player, ginfo);
         sLog.outDebug("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,_player->GetGUIDLow(), _player->GetName());
     }
@@ -163,25 +188,31 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
     if (!ginfo->IsInvitedToBGInstanceGUID)
         sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AnnounceWorld(ginfo, _player->GetGUID(), true);
 }
+
 void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv_data*/ )
 {
                                                             // empty opcode
     sLog.outDebug("WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message");
+
     BattleGround *bg = _player->GetBattleGround();
     if(!bg)                                                 // can't be received if player not in battleground
         return;
+
     switch( bg->GetTypeID() )
     {
         case BATTLEGROUND_WS:
             {
                 uint32 count1 = 0;                                  //always constant zero?
                 uint32 count2 = 0;                                  //count of next fields
+
                 Player *ali_plr = objmgr.GetPlayer(((BattleGroundWS*)bg)->GetAllianceFlagPickerGUID());
                 if (ali_plr)
                     ++count2;
+
                 Player *horde_plr = objmgr.GetPlayer(((BattleGroundWS*)bg)->GetHordeFlagPickerGUID());
                 if (horde_plr)
                     ++count2;
+
                 WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4+16*count1+16*count2));
                 data << count1;                                     // alliance flag holders count - obsolete, now always 0
                 /*for(uint8 i = 0; i < count1; ++i)
@@ -203,6 +234,7 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv
                     data << (float)horde_plr->GetPositionX();
                     data << (float)horde_plr->GetPositionY();
                 }
+
                 SendPacket(&data);
             }
             break;
@@ -224,44 +256,57 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv
             break;
     }
 }
+
 void WorldSession::HandlePVPLogDataOpcode( WorldPacket & /*recv_data*/ )
 {
     sLog.outDebug( "WORLD: Recvd MSG_PVP_LOG_DATA Message");
+
     BattleGround *bg = _player->GetBattleGround();
     if (!bg)
         return;
+
     WorldPacket data;
     sBattleGroundMgr.BuildPvpLogDataPacket(&data, bg);
     SendPacket(&data);
+
     sLog.outDebug( "WORLD: Sent MSG_PVP_LOG_DATA Message");
 }
+
 void WorldSession::HandleBattlefieldListOpcode( WorldPacket &recv_data )
 {
     sLog.outDebug( "WORLD: Recvd CMSG_BATTLEFIELD_LIST Message");
+
     uint32 bgTypeId;
     recv_data >> bgTypeId;                                  // id from DBC
+
     uint8 fromWhere;
     recv_data >> fromWhere;                                 // 0 - battlemaster, 1 - UI
+
     BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
     if (!bl)
     {
         sLog.outError("Battleground: invalid bgtype received.");
         return;
     }
+
     WorldPacket data;
     sBattleGroundMgr.BuildBattleGroundListPacket(&data, 0, _player, BattleGroundTypeId(bgTypeId), fromWhere);
     SendPacket( &data );
 }
+
 void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
 {
     sLog.outDebug( "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message");
+
     uint8 type;                                             // arenatype if arena
     uint8 unk2;                                             // unk, can be 0x0 (may be if was invited?) and 0x1
     uint32 instanceId;
     uint32 bgTypeId_;                                       // type id from dbc
     uint16 unk;                                             // 0x1F90 constant?
     uint8 action;                                           // enter battle 0x1, leave queue 0x0
+
     recv_data >> type >> unk2 >> bgTypeId_ >> unk >> action;
+
     if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
     {
         sLog.outError("Battleground: invalid bgtype (%u) received.", bgTypeId_);
@@ -282,10 +327,12 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
                 // if the player is not in queue, continue or no group information - this should never happen
                 if (itrPlayerStatus == qpMap.end() || !itrPlayerStatus->second.GroupInfo)
                     continue;
+
                 BattleGround * bg = NULL;
                 // get possibly needed data from groupinfo
                 uint8 arenatype = itrPlayerStatus->second.GroupInfo->ArenaType;
                 uint8 status = 0;
+
                 if (!itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID)
                 {
                     // not invited to bg, get template
@@ -298,9 +345,11 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
                     bg = sBattleGroundMgr.GetBattleGround(itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID, bgTypeId);
                     status = STATUS_WAIT_JOIN;
                 }
+
                 // if bg not found, then continue, don't invite if already in the instance
                 if (!bg || (_player->InBattleGround() && _player->GetBattleGround() && _player->GetBattleGround()->GetInstanceID() == bg->GetInstanceID()))
                     continue;
+
                 // re - invite player with proper data
                 WorldPacket data;
                 sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, i, status, INVITE_ACCEPT_WAIT_TIME, 0, arenatype);
@@ -309,6 +358,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
         }
         return;
     }
+
     //get GroupQueueInfo from BattleGroundQueue
     BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
     BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, type);
@@ -319,6 +369,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
         sLog.outError("Battleground: itrplayerstatus not found.");
         return;
     }
+
     instanceId = itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID;
     // if action == 1, then instanceId is required
     if (!instanceId && action == 1)
@@ -326,7 +377,9 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
         sLog.outError("Battleground: instance not found.");
         return;
     }
+
     BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId, bgTypeId);
+
     // bg template might and must be used in case of leaving queue, when instance is not created yet
     if (!bg && action == 0)
         bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
@@ -335,6 +388,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
         sLog.outError("Battleground: bg_template not found for type id %u.", bgTypeId);
         return;
     }
+
     if (_player->InBattleGroundQueue())
     {
         //we must use temporary variables, because GroupQueueInfo pointer can be deleted in BattleGroundQueue::RemovePlayer() function!
@@ -343,6 +397,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
         uint32 isRated = itrPlayerStatus->second.GroupInfo->IsRated;
         uint32 rating = itrPlayerStatus->second.GroupInfo->ArenaTeamRating;
         uint32 opponentsRating = itrPlayerStatus->second.GroupInfo->OpponentsTeamRating;
+
         //some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
         if (action == 1 && arenaType == 0)
         {
@@ -370,7 +425,9 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
             case 1:                                         // port to battleground
                 if (!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId))
                     return;                                 // cheating?
+
                 _player->SetBattleGroundEntryPoint();
+
                 // resurrect the player
                 if (!_player->isAlive())
                 {
@@ -382,7 +439,9 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
                 {
                     _player->GetMotionMaster()->MovementExpired();
                     _player->CleanupAfterTaxiFlight();
+
                 }
+
                 sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType());
                 _player->GetSession()->SendPacket(&data);
                 // remove battleground queue status from BGmgr
@@ -391,6 +450,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
                 // also this is required to prevent stuck at old battleground after SetBattleGroundId set to new
                 if (BattleGround *currentBg = _player->GetBattleGround())
                     currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
+
                 // set the destination instance id
                 _player->SetBattleGroundId(bg->GetInstanceID(), bgTypeId);
                 // set the destination team
@@ -431,26 +491,34 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
         }
     }
 }
+
 void WorldSession::HandleLeaveBattlefieldOpcode( WorldPacket & /*recv_data*/ )
 {
     sLog.outDebug( "WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message");
+
     //uint8 unk1, unk2;
     //uint32 bgTypeId;                                        // id from DBC
     //uint16 unk3;
+
     //recv_data >> unk1 >> unk2 >> bgTypeId >> unk3; - no used currently
+
     //if(bgTypeId >= MAX_BATTLEGROUND_TYPES)                  // cheating? but not important in this case
     //    return;
+
     // not allow leave battleground in combat
     if (_player->isInCombat())
         if (BattleGround* bg = _player->GetBattleGround())
             if (bg->GetStatus() != STATUS_WAIT_LEAVE)
                 return;
+
     _player->LeaveBattleground();
 }
+
 void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ )
 {
     // empty opcode
     sLog.outDebug( "WORLD: Battleground status" );
+
     WorldPacket data;
     // we must update all queues here
     BattleGround *bg = NULL;
@@ -503,56 +571,76 @@ void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ )
         }
     }
 }
+
 void WorldSession::HandleAreaSpiritHealerQueryOpcode( WorldPacket & recv_data )
 {
     sLog.outDebug("WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY");
+
     BattleGround *bg = _player->GetBattleGround();
     if (!bg)
         return;
+
     uint64 guid;
     recv_data >> guid;
+
     Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
     if (!unit)
         return;
+
     if(!unit->isSpiritService())                            // it's not spirit service
         return;
+
     sBattleGroundMgr.SendAreaSpiritHealerQueryOpcode(_player, bg, guid);
 }
+
 void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data )
 {
     sLog.outDebug("WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE");
+
     BattleGround *bg = _player->GetBattleGround();
     if (!bg)
         return;
+
     uint64 guid;
     recv_data >> guid;
+
     Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
     if (!unit)
         return;
+
     if(!unit->isSpiritService())                            // it's not spirit service
         return;
+
     bg->AddPlayerToResurrectQueue(guid, _player->GetGUID());
 }
+
 void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
 {
     sLog.outDebug("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
     //recv_data.hexlike();
+
     uint64 guid;                                            // arena Battlemaster guid
     uint8 arenaslot;                                        // 2v2, 3v3 or 5v5
     uint8 asGroup;                                          // asGroup
     uint8 isRated;                                          // isRated
     Group * grp;
+
     recv_data >> guid >> arenaslot >> asGroup >> isRated;
+
     // ignore if we already in BG or BG queue
     if (_player->InBattleGround())
         return;
+
     Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
     if (!unit)
         return;
+
     if(!unit->isBattleMaster())                             // it's not battle master
         return;
+
     uint8 arenatype = 0;
     uint32 arenaRating = 0;
+
     switch(arenaslot)
     {
         case 0:
@@ -568,6 +656,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
             sLog.outError("Unknown arena slot %u at HandleBattlemasterJoinArena()", arenaslot);
             return;
     }
+
     //check existance
     BattleGround* bg = NULL;
     if (!(bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA)))
@@ -575,8 +664,10 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
         sLog.outError("Battleground: template bg (all arenas) not found");
         return;
     }
+
     BattleGroundTypeId bgTypeId = bg->GetTypeID();
     BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype);
+
     // check queueing conditions
     if (!asGroup)
     {
@@ -601,7 +692,9 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
             return;
         }
     }
+
     uint32 ateamId = 0;
+
     if (isRated)
     {
         ateamId = _player->GetArenaTeamId(arenaslot);
@@ -620,15 +713,19 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
         for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
         {
             Player *member = itr->getSource();
+
             // calc avg personal rating
             avg_pers_rating += member->GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaslot*6) + 5);
         }
+
         if (arenatype)
             avg_pers_rating /= arenatype;
+
         // if avg personal rating is more than 150 points below the teams rating, the team will be queued against an opponent matching or similar to the average personal rating
         if (avg_pers_rating + 150 < arenaRating)
             arenaRating = avg_pers_rating;
     }
+
     GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, arenatype, isRated, false, arenaRating, ateamId);
     uint32 avgTime = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
     if (asGroup)
@@ -641,11 +738,14 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
         }
         else
             bg->SetRated(false);
+            
         for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
         {
             Player *member = itr->getSource();
             if(!member) continue;
+
             uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);// add to queue
+
             WorldPacket data;
             // send status packet (in queue)
             sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
@@ -662,6 +762,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
     else
     {
         uint32 queueSlot = _player->AddBattleGroundQueueId(bgQueueTypeId);
+
         WorldPacket data;
         // send status packet (in queue)
         sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
@@ -671,19 +772,24 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
     }
     sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId), arenatype, isRated, arenaRating);
 }
+
 void WorldSession::HandleReportPvPAFK( WorldPacket & recv_data )
 {
     uint64 playerGuid;
     recv_data >> playerGuid;
     Player *reportedPlayer = objmgr.GetPlayer(playerGuid);
+
     if (!reportedPlayer)
     {
         sLog.outDebug("WorldSession::HandleReportPvPAFK: player not found");
         return;
     }
+
     sLog.outDebug("WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName(), reportedPlayer->GetName());
+
     reportedPlayer->ReportedAfkBy(_player);
 }
+
 void WorldSession::SendBattleGroundOrArenaJoinError(uint8 err)
 {
     WorldPacket data;
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index 99339a835a6..f2143de5bdc 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -17,11 +17,13 @@
  * 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 "ObjectMgr.h"
 #include "World.h"
 #include "WorldPacket.h"
 #include "Policies/SingletonImp.h"
+
 #include "ArenaTeam.h"
 #include "BattleGroundMgr.h"
 #include "BattleGroundAV.h"
@@ -43,10 +45,13 @@
 #include "GameEventMgr.h"
 #include "ProgressBar.h"
 #include "SharedDefines.h"
+
 INSTANTIATE_SINGLETON_1( BattleGroundMgr );
+
 /*********************************************************/
 /***            BATTLEGROUND QUEUE SYSTEM              ***/
 /*********************************************************/
+
 BattleGroundQueue::BattleGroundQueue()
 {
     for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
@@ -60,6 +65,7 @@ BattleGroundQueue::BattleGroundQueue()
         }
     }
 }
+
 BattleGroundQueue::~BattleGroundQueue()
 {
     m_QueuedPlayers.clear();
@@ -73,15 +79,18 @@ BattleGroundQueue::~BattleGroundQueue()
         }
     }
 }
+
 /*********************************************************/
 /***      BATTLEGROUND QUEUE SELECTION POOLS           ***/
 /*********************************************************/
+
 // selection pool initialization, used to clean up from prev selection
 void BattleGroundQueue::SelectionPool::Init()
 {
     SelectedGroups.clear();
     PlayerCount = 0;
 }
+
 // remove group info from selection pool
 // returns true when we need to try to add new group to selection pool
 // returns false when selection pool is ok or when we kicked smaller group than we need to kick
@@ -114,6 +123,7 @@ bool BattleGroundQueue::SelectionPool::KickGroup(uint32 size)
     }
     return true;
 }
+
 // add group to selection pool
 // used when building selection pools
 // returns true if we can invite more players, or when we added group to selection pool
@@ -132,13 +142,16 @@ bool BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo *ginfo, uint32 de
         return true;
     return false;
 }
+
 /*********************************************************/
 /***               BATTLEGROUND QUEUES                 ***/
 /*********************************************************/
+
 // add group to bg queue with the given leader and bg specifications
 GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, BattleGroundTypeId BgTypeId, uint8 ArenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 arenateamid)
 {
     BGQueueIdBasedOnLevel queue_id = leader->GetBattleGroundQueueIdFromLevel(BgTypeId);
+
     // create new ginfo
     // cannot use the method like in addplayer, because that could modify an in-queue group's stats
     // (e.g. leader leaving queue then joining as individual again)
@@ -153,7 +166,9 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, BattleGroundTypeId
     ginfo->Team                      = leader->GetTeam();
     ginfo->ArenaTeamRating           = arenaRating;
     ginfo->OpponentsTeamRating       = 0;
+
     ginfo->Players.clear();
+
     //compute index (if group is premade or joined a rated match) to queues
     uint32 index = 0;
     if (!isRated && !isPremade)
@@ -161,10 +176,13 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, BattleGroundTypeId
     if (ginfo->Team == HORDE)
         index++;
     sLog.outDebug("Adding Group to BattleGroundQueue bgTypeId : %u, queue_id : %u, index : %u", BgTypeId, queue_id, index);
+
     m_QueuedGroups[queue_id][index].push_back(ginfo);
+
     // return ginfo, because it is needed to add players to this group info
     return ginfo;
 }
+
 //add player to playermap
 void BattleGroundQueue::AddPlayer(Player *plr, GroupQueueInfo *ginfo)
 {
@@ -172,9 +190,11 @@ void BattleGroundQueue::AddPlayer(Player *plr, GroupQueueInfo *ginfo)
     PlayerQueueInfo& info = m_QueuedPlayers[plr->GetGUID()];
     info.LastOnlineTime             = getMSTime();
     info.GroupInfo                  = ginfo;
+
     // add the pinfo to ginfo's list
     ginfo->Players[plr->GetGUID()]  = &info;
 }
+
 void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id)
 {
     uint32 timeInQueue = getMSTimeDiff(ginfo->JoinTime, getMSTime());
@@ -189,6 +209,7 @@ void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g
         if (ginfo->IsRated)
             team_index = BG_TEAM_HORDE;                     //for rated arenas use BG_TEAM_HORDE
     }
+
     //store pointer to arrayindex of player that was added first
     uint32* lastPlayerAddedPointer = &(m_WaitTimeLastPlayer[team_index][queue_id]);
     //remove his time from sum
@@ -201,6 +222,7 @@ void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g
     (*lastPlayerAddedPointer)++;
     (*lastPlayerAddedPointer) %= COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME;
 }
+
 uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id)
 {
     uint8 team_index = BG_TEAM_ALLIANCE;                    //default set to BG_TEAM_ALLIANCE - or non rated arenas!
@@ -221,12 +243,15 @@ uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BGQueue
         //if there aren't enough values return 0 - not available
         return 0;
 }
+
 //remove player from queue and from group info, if group info is empty then remove it too
 void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCount)
 {
     //Player *plr = objmgr.GetPlayer(guid);
+
     int32 queue_id = -1;                                     // signed for proper for-loop finish
     QueuedPlayersMap::iterator itr;
+
     //remove player from map, if he's there
     itr = m_QueuedPlayers.find(guid);
     if (itr == m_QueuedPlayers.end())
@@ -234,12 +259,14 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
         sLog.outError("BattleGroundQueue: couldn't find player to remove GUID: %u", GUID_LOPART(guid));
         return;
     }
+
     GroupQueueInfo* group = itr->second.GroupInfo;
     GroupsQueueType::iterator group_itr, group_itr_tmp;
     // mostly people with the highest levels are in battlegrounds, thats why
     // we count from MAX_BATTLEGROUND_QUEUES - 1 to 0
     // variable index removes useless searching in other team's queue
     uint32 index = (group->Team == HORDE) ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE;
+
     for (int32 queue_id_tmp = MAX_BATTLEGROUND_QUEUES - 1; queue_id_tmp >= 0 && queue_id == -1; --queue_id_tmp)
     {
         //we must check premade and normal team's queue - because when players from premade are joining bg,
@@ -266,14 +293,17 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
         return;
     }
     sLog.outDebug("BattleGroundQueue: Removing player GUID %u, from queue_id %u", GUID_LOPART(guid), (uint32)queue_id);
+
     // ALL variables are correctly set
     // We can ignore leveling up in queue - it should not cause crash
     // remove player from group
     // if only one player there, remove group
+
     // remove player queue info from group queue info
     std::map::iterator pitr = group->Players.find(guid);
     if (pitr != group->Players.end())
         group->Players.erase(pitr);
+
     // if invited to bg, and should decrease invited count, then do it
     if (decreaseInvitedCount && group->IsInvitedToBGInstanceGUID)
     {
@@ -281,11 +311,14 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
         if (bg)
             bg->DecreaseInvitedCount(group->Team);
     }
+
     // remove player queue info
     m_QueuedPlayers.erase(itr);
+
     //if we left BG queue(not porting) OR if arena team left queue for rated match
     if ((decreaseInvitedCount && !group->ArenaType) || (group->ArenaType && group->IsRated && group->Players.empty()))
         AnnounceWorld(group, guid, false);
+
     //if player leaves queue and he is invited to rated arena match, then he have to loose
     if (group->IsInvitedToBGInstanceGUID && group->IsRated && decreaseInvitedCount)
     {
@@ -301,6 +334,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
             at->SaveToDB();
         }
     }
+
     // remove group queue info if needed
     if (group->Players.empty())
     {
@@ -329,6 +363,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
         RemovePlayer(group->Players.begin()->first, decreaseInvitedCount);
     }
 }
+
 //Announce world message
 void BattleGroundQueue::AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playerGUID, bool isAddedToQueue)
 {
@@ -339,6 +374,7 @@ void BattleGroundQueue::AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playe
             BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(ginfo->BgTypeId);
             if (!bg)
                 return;
+
             char const* bgName = bg->GetName();
             if (isAddedToQueue)
             {
@@ -370,6 +406,7 @@ void BattleGroundQueue::AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playe
             BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(ginfo->BgTypeId);
             if (!bg || !plr)
                 return;
+
             BGQueueIdBasedOnLevel queue_id = plr->GetBattleGroundQueueIdFromLevel(bg->GetTypeID());
             char const* bgName = bg->GetName();
             uint32 MinPlayers = bg->GetMinPlayersPerTeam();
@@ -384,6 +421,7 @@ void BattleGroundQueue::AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playe
             for(itr = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
                 if (!(*itr)->IsInvitedToBGInstanceGUID)
                     qHorde += (*itr)->Players.size();
+
             // Show queue status to player only (when joining queue)
             if (sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
             {
@@ -399,11 +437,13 @@ void BattleGroundQueue::AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playe
         }
     }
 }
+
 bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, uint32 side)
 {
     // set side if needed
     if (side)
         ginfo->Team = side;
+
     if (!ginfo->IsInvitedToBGInstanceGUID)
     {
         // not yet invited
@@ -412,10 +452,13 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
         BattleGroundTypeId bgTypeId = bg->GetTypeID();
         BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, bg->GetArenaType());
         BGQueueIdBasedOnLevel queue_id = bg->GetQueueId();
+
         // set ArenaTeamId for rated matches
         if (bg->isArena() && bg->isRated())
             bg->SetArenaTeamIdForTeam(ginfo->Team, ginfo->ArenaTeamId);
+
         ginfo->RemoveInviteTime = getMSTime() + INVITE_ACCEPT_WAIT_TIME;
+
         // loop through the players
         for(std::map::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)
         {
@@ -424,29 +467,39 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
             // if offline, skip him, this should not happen - player is removed from queue when he logs out
             if (!plr)
                 continue;
+
             // invite the player
             PlayerInvitedToBGUpdateAverageWaitTime(ginfo, queue_id);
             //sBattleGroundMgr.InvitePlayer(plr, bg, ginfo->Team);
+
             // set invited player counters
             bg->IncreaseInvitedCount(ginfo->Team);
+
             plr->SetInviteForBattleGroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID);
+
             // create remind invite events
             BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->RemoveInviteTime);
             plr->m_Events.AddEvent(inviteEvent, plr->m_Events.CalculateTime(INVITATION_REMIND_TIME));
             // create automatic remove events
             BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime);
             plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME));
+
             WorldPacket data;
+
             uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId);
+
             sLog.outDebug("Battleground: invited plr %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.",plr->GetName(),plr->GetGUIDLow(),bg->GetInstanceID(),queueSlot,bg->GetTypeID());
+
             // send status packet
             sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, 0, ginfo->ArenaType);
             plr->GetSession()->SendPacket(&data);
         }
         return true;
     }
+
     return false;
 }
+
 /*
 This function is inviting players to already running battlegrounds
 Invitation type is based on config file
@@ -456,6 +509,7 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BGQueueIdBasedOnLevel
 {
     int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE);
     int32 aliFree   = bg->GetFreeSlotsForTeam(ALLIANCE);
+
     //iterator for iterating through bg queue
     GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE].begin();
     //count of groups in queue - used to stop cycles
@@ -470,9 +524,11 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BGQueueIdBasedOnLevel
     uint32 hordeIndex = 0;
     for (; hordeIndex < hordeCount && m_SelectionPools[BG_TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++)
         ++Horde_itr;
+
     //if ofc like BG queue invitation is set in config, then we are happy
     if (sWorld.getConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == 0)
         return;
+
     /*
     if we reached this code, then we have to solve NP - complete problem called Subset sum problem
     So one solution is to check all possible invitation subgroups, or we can use these conditions:
@@ -480,6 +536,7 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BGQueueIdBasedOnLevel
         that we will invite now whole queue, because only 1 change has been made to queues from the last BattleGroundQueue::Update call
     2. Other thing we should consider is group order in queue
     */
+
     // At first we need to compare free space in bg and our selection pool
     int32 diffAli   = aliFree   - int32(m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount());
     int32 diffHorde = hordeFree - int32(m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount());
@@ -522,6 +579,7 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BGQueueIdBasedOnLevel
         diffHorde = hordeFree - int32(m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount());
     }
 }
+
 // this method checks if premade versus premade battleground is possible
 // then after 30 mins (default) in queue it moves premade group to normal queue
 // it tries to invite as much players as it can - to MaxPlayersPerTeam, because premade groups have more than MinPlayersPerTeam players
@@ -539,6 +597,7 @@ bool BattleGroundQueue::CheckPremadeMatch(BGQueueIdBasedOnLevel queue_id, uint32
         for( horde_group = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].begin(); horde_group != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].end(); ++horde_group)
             if (!(*horde_group)->IsInvitedToBGInstanceGUID)
                 break;
+
         if (ali_group != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].end() && horde_group != m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].end())
         {
             m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*ali_group), MaxPlayersPerTeam);
@@ -580,6 +639,7 @@ bool BattleGroundQueue::CheckPremadeMatch(BGQueueIdBasedOnLevel queue_id, uint32
     //selection pools are not set
     return false;
 }
+
 // this method tries to create battleground or arena with MinPlayersPerTeam against MinPlayersPerTeam
 bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BGQueueIdBasedOnLevel queue_id, uint32 minPlayers, uint32 maxPlayers)
 {
@@ -622,6 +682,7 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BGQueueIdBas
     //return true if there are enough players in selection pools - enable to work .debug bg command correctly
     return m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() >= minPlayers;
 }
+
 // this method will check if we can invite players to same faction skirmish match
 bool BattleGroundQueue::CheckSkirmishForSameFaction(BGQueueIdBasedOnLevel queue_id, uint32 minPlayersPerTeam)
 {
@@ -658,6 +719,7 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BGQueueIdBasedOnLevel queue_
     }
     if (m_SelectionPools[otherTeam].GetPlayerCount() != minPlayersPerTeam)
         return false;
+
     //here we have correct 2 selections and we need to change one teams team and move selection pool teams to other team's queue
     for(GroupsQueueType::iterator itr = m_SelectionPools[otherTeam].SelectedGroups.begin(); itr != m_SelectionPools[otherTeam].SelectedGroups.end(); ++itr)
     {
@@ -679,6 +741,7 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BGQueueIdBasedOnLevel queue_
     }
     return true;
 }
+
 /*
 this method is called when group is inserted, or player / group is removed from BG Queue - there is only one player's status changed, so we don't use while(true) cycles to invite whole queue
 it must be called after fully adding the members of a group to ensure group joining
@@ -692,6 +755,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
         m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
         m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_HORDE].empty() )
         return;
+
     //battleground with free slot for player should be always in the beggining of the queue
     // maybe it would be better to create bgfreeslotqueue for each queue_id_based_on_level
     BGFreeSlotQueueType::iterator itr, next;
@@ -705,16 +769,20 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
         {
             BattleGround* bg = *itr; //we have to store battleground pointer here, because when battleground is full, it is removed from free queue (not yet implemented!!)
             // and iterator is invalid
+
             // clear selection pools
             m_SelectionPools[BG_TEAM_ALLIANCE].Init();
             m_SelectionPools[BG_TEAM_HORDE].Init();
+
             // call a function that does the job for us
             FillPlayersToBG(bg, queue_id);
+
             // now everything is set, invite players
             for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr)
                 InviteGroupToBG((*citr), bg, (*citr)->Team);
             for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++citr)
                 InviteGroupToBG((*citr), bg, (*citr)->Team);
+
             if (!bg->HasFreeSlots())
             {
                 // remove BG from BGFreeSlotQueue
@@ -722,7 +790,9 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
             }
         }
     }
+
     // finished iterating through the bgs with free slots, maybe we need to create a new bg
+
     BattleGround * bg_template = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
     if (!bg_template)
     {
@@ -763,8 +833,10 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
             }*/
         }
     }
+
     m_SelectionPools[BG_TEAM_ALLIANCE].Init();
     m_SelectionPools[BG_TEAM_HORDE].Init();
+
     if (bg_template->isBattleGround())
     {
         //check if there is premade against premade match
@@ -788,6 +860,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
             m_SelectionPools[BG_TEAM_HORDE].Init();
         }
     }
+
     // now check if there are in queues enough players to start new game of (normal battleground, or non-rated arena)
     if (!isRated)
     {
@@ -802,6 +875,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
                 sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId);
                 return;
             }
+
             // invite those selection pools
             for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
                 for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
@@ -837,6 +911,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
             else if (!front1 && !front2)
                 return; //queues are empty
         }
+
         //set rating range
         uint32 arenaMinRating = (arenaRating <= sBattleGroundMgr.GetMaxRatingDifference()) ? 0 : arenaRating - sBattleGroundMgr.GetMaxRatingDifference();
         uint32 arenaMaxRating = arenaRating + sBattleGroundMgr.GetMaxRatingDifference();
@@ -845,9 +920,13 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
         // the discard time is current_time - time_to_discard, teams that joined after that, will have their ratings taken into account
         // else leave the discard time on 0, this way all ratings will be discarded
         uint32 discardTime = getMSTime() - sBattleGroundMgr.GetRatingDiscardTimer();
+
         // we need to find 2 teams which will play next game
+
         GroupsQueueType::iterator itr_team[BG_TEAMS_COUNT];
+
         //optimalization : --- we dont need to use selection_pools - each update we select max 2 groups
+
         for(uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++)
         {
             // take the group that joined first
@@ -900,6 +979,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
                 }
             }
         }
+
         //if we have 2 teams, then start new arena and invite players!
         if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount())
         {
@@ -909,6 +989,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
                 sLog.outError("BattlegroundQueue::Update couldn't create arena instance for rated arena match!");
                 return;
             }
+
             (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamRating;
             sLog.outDebug("setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamId, (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating);
             (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamRating;
@@ -928,26 +1009,33 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
                 m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]);
                 itr_team[BG_TEAM_HORDE] = m_QueuedGroups[queue_id][BG_QUEUE_PREMADE_HORDE].begin();
             }
+
             InviteGroupToBG(*(itr_team[BG_TEAM_ALLIANCE]), arena, ALLIANCE);
             InviteGroupToBG(*(itr_team[BG_TEAM_HORDE]), arena, HORDE);
+
             sLog.outDebug("Starting rated arena match!");
+
             arena->StartBattleGround();
         }
     }
 }
+
 /*********************************************************/
 /***            BATTLEGROUND QUEUE EVENTS              ***/
 /*********************************************************/
+
 bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
 {
     Player* plr = objmgr.GetPlayer( m_PlayerGuid );
     // player logged off (we should do nothing, he is correctly removed from queue in another procedure)
     if (!plr)
         return true;
+
     BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID, m_BgTypeId);
     //if battleground ended and its instance deleted - do nothing
     if (!bg)
         return true;
+
     BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
     uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId);
     if( queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES )        // player is in queue or in battleground
@@ -966,10 +1054,12 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
     }
     return true;                                            //event will be deleted
 }
+
 void BGQueueInviteEvent::Abort(uint64 /*e_time*/)
 {
     //do nothing
 }
+
 /*
     this event has many possibilities when it is executed:
     1. player is in battleground ( he clicked enter on invitation window )
@@ -985,9 +1075,11 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
     if (!plr)
         // player logged off (we should do nothing, he is correctly removed from queue in another procedure)
         return true;
+
     BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID, m_BgTypeId);
     //battleground can be deleted already when we are removing queue info
     //bg pointer can be NULL! so use it carefully!
+
     uint32 queueSlot = plr->GetBattleGroundQueueIndex(m_BgQueueTypeId);
     if( queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES )        // player is in queue, or in Battleground
     {
@@ -999,26 +1091,32 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
             && qMapItr->second.GroupInfo->RemoveInviteTime == m_RemoveTime )
         {
             sLog.outDebug("Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.",plr->GetGUIDLow(),m_BgInstanceGUID);
+
             plr->RemoveBattleGroundQueueId(m_BgQueueTypeId);
             sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId].RemovePlayer(m_PlayerGuid, true);
             //update queues if battleground isn't ended
             if (bg)
                 sBattleGroundMgr.ScheduleQueueUpdate(m_BgQueueTypeId, m_BgTypeId, bg->GetQueueId());
+
             WorldPacket data;
             sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0);
             plr->GetSession()->SendPacket(&data);
         }
     }
+
     //event will be deleted
     return true;
 }
+
 void BGQueueRemoveEvent::Abort(uint64 /*e_time*/)
 {
     //do nothing
 }
+
 /*********************************************************/
 /***            BATTLEGROUND MANAGER                   ***/
 /*********************************************************/
+
 BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTesting(false)
 {
     for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++)
@@ -1026,10 +1124,12 @@ BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTe
     m_NextRatingDiscardUpdate = sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER);
     m_Testing=false;
 }
+
 BattleGroundMgr::~BattleGroundMgr()
 {
     DeleteAllBattleGrounds();
 }
+
 void BattleGroundMgr::DeleteAllBattleGrounds()
 {
     for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++)
@@ -1043,6 +1143,7 @@ void BattleGroundMgr::DeleteAllBattleGrounds()
             delete bg;
         }
     }
+
     // destroy template battlegrounds that listed only in queues (other already terminated)
     for(uint32 bgTypeId = 0; bgTypeId < MAX_BATTLEGROUND_TYPE_ID; ++bgTypeId)
     {
@@ -1051,6 +1152,7 @@ void BattleGroundMgr::DeleteAllBattleGrounds()
             delete BGFreeSlotQueue[bgTypeId].front();
     }
 }
+
 // used to update running battlegrounds, and delete finished ones
 void BattleGroundMgr::Update(uint32 diff)
 {
@@ -1078,6 +1180,7 @@ void BattleGroundMgr::Update(uint32 diff)
             }
         }
     }
+
     // update scheduled queues
     if (!m_QueueUpdateScheduler.empty())
     {
@@ -1095,6 +1198,7 @@ void BattleGroundMgr::Update(uint32 diff)
             m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, queue_id);
         }
     }
+
     // if rating difference counts, maybe force-update queues
     if (sWorld.getConfig(CONFIG_ARENA_MAX_RATING_DIFFERENCE) && sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER))
     {
@@ -1130,9 +1234,11 @@ void BattleGroundMgr::Update(uint32 diff)
             m_AutoDistributionTimeChecker -= diff;
     }
 }
+
 void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGround *bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint8 arenatype)
 {
     // we can be in 3 queues in same time...
+
     if (StatusID == 0 || !bg)
     {
         data->Initialize(SMSG_BATTLEFIELD_STATUS, 4*3);
@@ -1140,6 +1246,7 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGro
         *data << uint64(0);
         return;
     }
+
     data->Initialize(SMSG_BATTLEFIELD_STATUS, (4+1+1+4+2+4+1+4+4+4));
     *data << uint32(QueueSlot);                             // queue id (0...2) - player can be in 3 queues in time
     // uint64 in client
@@ -1188,12 +1295,15 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGro
             *data << uint8(0);
             break;
     }
+
     if (bg->isArena() && (StatusID == STATUS_WAIT_QUEUE))
         *data << uint32(BATTLEGROUND_AA);                   // all arenas   I don't think so.
     else
     *data << uint32(bg->GetTypeID());                   // BG id from DBC
+
     *data << uint16(0x1F90);                                // unk value 8080
     *data << uint32(bg->GetInstanceID());                   // instance id
+
     *data << uint8(bg->isArena());                          // minimap-icon 0=faction 1=arena
 */
     *data << uint32(StatusID);                              // status
@@ -1218,12 +1328,14 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGro
             break;
     }
 }
+
 void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
 {
     uint8 type = (bg->isArena() ? 1 : 0);
                                                             // last check on 3.0.3
     data->Initialize(MSG_PVP_LOG_DATA, (1+1+4+40*bg->GetPlayerScoresSize()));
     *data << uint8(type);                                   // type (battleground=0/arena=1)
+
     if(type)                                                // arena
     {
         // it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H
@@ -1244,6 +1356,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
                 *data << (uint8)0;
         }
     }
+
     if (bg->GetStatus() != STATUS_WAIT_LEAVE)
     {
         *data << uint8(0);                                  // bg not ended
@@ -1253,7 +1366,9 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
         *data << uint8(1);                                  // bg ended
         *data << uint8(bg->GetWinner());                    // who win
     }
+
     *data << (int32)(bg->GetPlayerScoresSize());
+
     for(BattleGround::BattleGroundScoreMap::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr)
     {
         *data << (uint64)itr->first;
@@ -1317,6 +1432,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
         }
     }
 }
+
 void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket *data, BattleGroundTypeId bgTypeId)
 {
     /*bgTypeId is:
@@ -1331,27 +1447,32 @@ void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket *data, Batt
     data->Initialize(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
     *data << uint32(bgTypeId);
 }
+
 void BattleGroundMgr::BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value)
 {
     data->Initialize(SMSG_UPDATE_WORLD_STATE, 4+4);
     *data << uint32(field);
     *data << uint32(value);
 }
+
 void BattleGroundMgr::BuildPlaySoundPacket(WorldPacket *data, uint32 soundid)
 {
     data->Initialize(SMSG_PLAY_SOUND, 4);
     *data << uint32(soundid);
 }
+
 void BattleGroundMgr::BuildPlayerLeftBattleGroundPacket(WorldPacket *data, const uint64& guid)
 {
     data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8);
     *data << uint64(guid);
 }
+
 void BattleGroundMgr::BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Player *plr)
 {
     data->Initialize(SMSG_BATTLEGROUND_PLAYER_JOINED, 8);
     *data << uint64(plr->GetGUID());
 }
+
 BattleGround * BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId)
 {
     //cause at HandleBattleGroundJoinOpcode the clients sends the instanceid he gets from
@@ -1359,8 +1480,10 @@ BattleGround * BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 inst
     BattleGround* bg = GetBattleGroundTemplate(bgTypeId);
     if (!bg)
         return NULL;
+
     if (bg->isArena())
         return GetBattleGround(instanceId, bgTypeId);
+
     for(BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr)
     {
         if (itr->second->GetClientInstanceID() == instanceId)
@@ -1368,6 +1491,7 @@ BattleGround * BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 inst
     }
     return NULL;
 }
+
 BattleGround * BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId)
 {
     if (!InstanceID)
@@ -1387,15 +1511,18 @@ BattleGround * BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundT
     itr = m_BattleGrounds[bgTypeId].find(InstanceID);
     return ( (itr != m_BattleGrounds[bgTypeId].end()) ? itr->second : NULL );
 }
+
 BattleGround * BattleGroundMgr::GetBattleGroundTemplate(BattleGroundTypeId bgTypeId)
 {
     //map is sorted and we can be sure that lowest instance id has only BG template
     return m_BattleGrounds[bgTypeId].empty() ? NULL : m_BattleGrounds[bgTypeId].begin()->second;
 }
+
 uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id)
 {
     if (IsArenaType(bgTypeId))
         return 0;                                           //arenas don't have client-instanceids
+
     // we create here an instanceid, which is just for
     // displaying this to the client and without any other use..
     // the client-instanceIds are unique for each battleground-type
@@ -1412,6 +1539,7 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI
     m_ClientBattleGroundIds[bgTypeId][queue_id].insert(lastId + 1);
     return lastId + 1;
 }
+
 // create a new battleground that will really be used to play
 BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated)
 {
@@ -1422,6 +1550,7 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
         sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId);
         return NULL;
     }
+
     //for arenas there is random map used
     if (bg_template->isArena())
     {
@@ -1435,6 +1564,7 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
             return NULL;
         }
     }
+
     BattleGround *bg = NULL;
     // create a copy of the BG template
     switch(bgTypeId)
@@ -1476,18 +1606,23 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
             //error, but it is handled few lines above
             return 0;
     }
+
     // generate a new instance id
     bg->SetInstanceID(MapManager::Instance().GenerateInstanceId()); // set instance id
     bg->SetClientInstanceID(CreateClientVisibleInstanceId(bgTypeId, queue_id));
+
     // reset the new bg (set status to status_wait_queue from status_none)
     bg->Reset();
+
     // start the joining of the bg
     bg->SetStatus(STATUS_WAIT_JOIN);
     bg->SetQueueId(queue_id);
     bg->SetArenaType(arenaType);
     bg->SetRated(isRated);
+
     return bg;
 }
+
 // used to create the BG templates
 uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO)
 {
@@ -1508,6 +1643,7 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsA
         case BATTLEGROUND_RV: bg = new BattleGroundRV; break;
         default:bg = new BattleGround;   break;             // placeholder for non implemented BG
     }
+
     bg->SetMapId(MapID);
     bg->SetTypeID(bgTypeId);
     bg->SetInstanceID(0);
@@ -1520,11 +1656,14 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsA
     bg->SetTeamStartLoc(ALLIANCE, Team1StartLocX, Team1StartLocY, Team1StartLocZ, Team1StartLocO);
     bg->SetTeamStartLoc(HORDE,    Team2StartLocX, Team2StartLocY, Team2StartLocZ, Team2StartLocO);
     bg->SetLevelRange(LevelMin, LevelMax);
+
     // add bg to update list
     AddBattleGround(bg->GetInstanceID(), bg->GetTypeID(), bg);
+
     // return some not-null value, bgTypeId is good enough for me
     return bgTypeId;
 }
+
 void BattleGroundMgr::CreateInitialBattleGrounds()
 {
     float AStartLoc[4];
@@ -1533,23 +1672,32 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
     BattlemasterListEntry const *bl;
     WorldSafeLocsEntry const *start;
     bool IsArena;
+
     uint32 count = 0;
+
     //                                                0   1                 2                 3      4      5                6              7             8
     QueryResult *result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam,MaxPlayersPerTeam,MinLvl,MaxLvl,AllianceStartLoc,AllianceStartO,HordeStartLoc,HordeStartO FROM battleground_template");
+
     if (!result)
     {
         barGoLink bar(1);
+
         bar.step();
+
         sLog.outString();
         sLog.outErrorDb(">> Loaded 0 battlegrounds. DB table `battleground_template` is empty.");
         return;
     }
+
     barGoLink bar(result->GetRowCount());
+
     do
     {
         Field *fields = result->Fetch();
         bar.step();
+
         uint32 bgTypeID_ = fields[0].GetUInt32();
+
         // can be overwrite by values from DB
         bl = sBattlemasterListStore.LookupEntry(bgTypeID_);
         if (!bl)
@@ -1557,7 +1705,9 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
             sLog.outError("Battleground ID %u not found in BattlemasterList.dbc. Battleground not created.", bgTypeID_);
             continue;
         }
+
         BattleGroundTypeId bgTypeID = BattleGroundTypeId(bgTypeID_);
+
         IsArena = (bl->type == TYPE_ARENA);
         MinPlayersPerTeam = fields[1].GetUInt32();
         MaxPlayersPerTeam = fields[2].GetUInt32();
@@ -1574,7 +1724,9 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
             MinLvl = bl->minlvl;
             MaxLvl = bl->maxlvl;
         }
+
         start1 = fields[5].GetUInt32();
+
         start = sWorldSafeLocsStore.LookupEntry(start1);
         if (start)
         {
@@ -1595,7 +1747,9 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
             sLog.outErrorDb("Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. BG not created.", bgTypeID, start1);
             continue;
         }
+
         start2 = fields[7].GetUInt32();
+
         start = sWorldSafeLocsStore.LookupEntry(start2);
         if (start)
         {
@@ -1616,15 +1770,20 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
             sLog.outErrorDb("Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `HordeStartLoc`. BG not created.", bgTypeID, start2);
             continue;
         }
+
         //sLog.outDetail("Creating battleground %s, %u-%u", bl->name[sWorld.GetDBClang()], MinLvl, MaxLvl);
         if (!CreateBattleGround(bgTypeID, IsArena, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, bl->name[sWorld.GetDefaultDbcLocale()], bl->mapid[0], AStartLoc[0], AStartLoc[1], AStartLoc[2], AStartLoc[3], HStartLoc[0], HStartLoc[1], HStartLoc[2], HStartLoc[3]))
             continue;
+
         ++count;
     } while (result->NextRow());
+
     delete result;
+
     sLog.outString();
     sLog.outString( ">> Loaded %u battlegrounds", count );
 }
+
 void BattleGroundMgr::InitAutomaticArenaPointDistribution()
 {
     if (sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS))
@@ -1645,17 +1804,22 @@ void BattleGroundMgr::InitAutomaticArenaPointDistribution()
         sLog.outDebug("Automatic Arena Point Distribution initialized.");
     }
 }
+
 void BattleGroundMgr::DistributeArenaPoints()
 {
     // used to distribute arena points based on last week's stats
     sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_START);
+
     sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START);
+
     //temporary structure for storing maximum points to add values for all players
     std::map PlayerPoints;
+
     //at first update all points for all team members
     for(ObjectMgr::ArenaTeamMap::iterator team_itr = objmgr.GetArenaTeamMapBegin(); team_itr != objmgr.GetArenaTeamMapEnd(); ++team_itr)
         if (ArenaTeam * at = team_itr->second)
             at->UpdateArenaPointsHelper(PlayerPoints);
+
     //cycle that gives points to all players
     for (std::map::iterator plr_itr = PlayerPoints.begin(); plr_itr != PlayerPoints.end(); ++plr_itr)
     {
@@ -1673,8 +1837,11 @@ void BattleGroundMgr::DistributeArenaPoints()
             std::min(int32(plr_itr->second),int32(sWorld.getConfig(CONFIG_MAX_ARENA_POINTS))));
         }
     }
+
     PlayerPoints.clear();
+
     sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END);
+
     sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START);
     for(ObjectMgr::ArenaTeamMap::iterator titr = objmgr.GetArenaTeamMapBegin(); titr != objmgr.GetArenaTeamMapEnd(); ++titr)
     {
@@ -1685,15 +1852,20 @@ void BattleGroundMgr::DistributeArenaPoints()
             at->NotifyStatsChanged();                      // notify the players of the changes
         }
     }
+
     sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_END);
+
     sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_END);
 }
+
 void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player* plr, BattleGroundTypeId bgTypeId, uint8 fromWhere)
 {
     if (!plr)
         return;
+
     uint32 PlayerLevel = 10;
     PlayerLevel = plr->getLevel();
+
     data->Initialize(SMSG_BATTLEFIELD_LIST);
     *data << uint64(guid);                                  // battlemaster guid
     *data << uint8(fromWhere);                              // from where you joined
@@ -1706,9 +1878,11 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
     else                                                    // battleground
     {
         *data << uint8(0x00);                               // unk, different for each bg type
+
         size_t count_pos = data->wpos();
         uint32 count = 0;
         *data << uint32(0x00);                              // number of bg instances
+
         uint32 queue_id = plr->GetBattleGroundQueueIdFromLevel(bgTypeId);
         for(std::set::iterator itr = m_ClientBattleGroundIds[bgTypeId][queue_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][queue_id].end();++itr)
         {
@@ -1718,6 +1892,7 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
         data->put( count_pos , count);
     }
 }
+
 void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId, BattleGroundTypeId bgTypeId)
 {
     BattleGround *bg = GetBattleGround(instanceId, bgTypeId);
@@ -1729,6 +1904,7 @@ void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId, BattleGr
         if (team==0)
             team = pl->GetTeam();
         bg->GetTeamStartLoc(team, x, y, z, O);
+
         sLog.outDetail("BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", pl->GetName(), mapid, x, y, z, O);
         pl->TeleportTo(mapid, x, y, z, O);
     }
@@ -1737,6 +1913,7 @@ void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId, BattleGr
         sLog.outError("player %u trying to port to non-existent bg instance %u",pl->GetGUIDLow(), instanceId);
     }
 }
+
 void BattleGroundMgr::SendAreaSpiritHealerQueryOpcode(Player *pl, BattleGround *bg, const uint64& guid)
 {
     WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
@@ -1746,6 +1923,7 @@ void BattleGroundMgr::SendAreaSpiritHealerQueryOpcode(Player *pl, BattleGround *
     data << guid << time_;
     pl->GetSession()->SendPacket(&data);
 }
+
 bool BattleGroundMgr::IsArenaType(BattleGroundTypeId bgTypeId)
 {
     return ( bgTypeId == BATTLEGROUND_AA ||
@@ -1753,6 +1931,7 @@ bool BattleGroundMgr::IsArenaType(BattleGroundTypeId bgTypeId)
         bgTypeId == BATTLEGROUND_NA ||
         bgTypeId == BATTLEGROUND_RL );
 }
+
 BattleGroundQueueTypeId BattleGroundMgr::BGQueueTypeId(BattleGroundTypeId bgTypeId, uint8 arenaType)
 {
     switch(bgTypeId)
@@ -1788,6 +1967,7 @@ BattleGroundQueueTypeId BattleGroundMgr::BGQueueTypeId(BattleGroundTypeId bgType
             return BATTLEGROUND_QUEUE_NONE;
     }
 }
+
 BattleGroundTypeId BattleGroundMgr::BGTemplateId(BattleGroundQueueTypeId bgQueueTypeId)
 {
     switch(bgQueueTypeId)
@@ -1810,6 +1990,7 @@ BattleGroundTypeId BattleGroundMgr::BGTemplateId(BattleGroundQueueTypeId bgQueue
             return BattleGroundTypeId(0);                   // used for unknown template (it existed and do nothing)
     }
 }
+
 uint8 BattleGroundMgr::BGArenaType(BattleGroundQueueTypeId bgQueueTypeId)
 {
     switch(bgQueueTypeId)
@@ -1824,6 +2005,7 @@ uint8 BattleGroundMgr::BGArenaType(BattleGroundQueueTypeId bgQueueTypeId)
             return 0;
     }
 }
+
 void BattleGroundMgr::ToggleTesting()
 {
     m_Testing = !m_Testing;
@@ -1832,6 +2014,7 @@ void BattleGroundMgr::ToggleTesting()
     else
         sWorld.SendWorldText(LANG_DEBUG_BG_OFF);
 }
+
 void BattleGroundMgr::ToggleArenaTesting()
 {
     m_ArenaTesting = !m_ArenaTesting;
@@ -1840,6 +2023,7 @@ void BattleGroundMgr::ToggleArenaTesting()
     else
         sWorld.SendWorldText(LANG_DEBUG_ARENA_OFF);
 }
+
 void BattleGroundMgr::SetHolidayWeekends(uint32 mask)
 {
     for(uint32 bgtype = 1; bgtype < MAX_BATTLEGROUND_TYPE_ID; ++bgtype)
@@ -1850,6 +2034,7 @@ void BattleGroundMgr::SetHolidayWeekends(uint32 mask)
         }
     }
 }
+
 void BattleGroundMgr::ScheduleQueueUpdate(BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id)
 {
     //This method must be atomic, TODO add mutex
@@ -1867,6 +2052,7 @@ void BattleGroundMgr::ScheduleQueueUpdate(BattleGroundQueueTypeId bgQueueTypeId,
     if (!found)
         m_QueueUpdateScheduler.push_back(schedule_id);
 }
+
 uint32 BattleGroundMgr::GetMaxRatingDifference() const
 {
     // this is for stupid people who can't use brain and set max rating difference to 0
@@ -1875,33 +2061,44 @@ uint32 BattleGroundMgr::GetMaxRatingDifference() const
         diff = 5000;
     return diff;
 }
+
 uint32 BattleGroundMgr::GetRatingDiscardTimer() const
 {
     return sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER);
 }
+
 uint32 BattleGroundMgr::GetPrematureFinishTime() const
 {
     return sWorld.getConfig(CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER);
 }
+
 void BattleGroundMgr::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();
         if (!sBattlemasterListStore.LookupEntry(bgTypeId))
@@ -1909,9 +2106,13 @@ void BattleGroundMgr::LoadBattleMastersEntry()
             sLog.outErrorDb("Table `battlemaster_entry` contain entry %u for not existed battleground type %u, ignored.",entry,bgTypeId);
             continue;
         }
+
         mBattleMastersMap[entry] = BattleGroundTypeId(bgTypeId);
+
     } while( result->NextRow() );
+
     delete result;
+
     sLog.outString();
     sLog.outString( ">> Loaded %u battlemaster entries", count );
 }
diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h
index 2de067d3639..9100142ebd0 100644
--- a/src/game/BattleGroundMgr.h
+++ b/src/game/BattleGroundMgr.h
@@ -17,23 +17,32 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef __BATTLEGROUNDMGR_H
 #define __BATTLEGROUNDMGR_H
+
 #include "Common.h"
 #include "Policies/Singleton.h"
+
 #include "BattleGround.h"
+
 typedef std::map BattleGroundSet;
+
 //this container can't be deque, because deque doesn't like removing the last element - if you remove it, it invalidates next iterator and crash appears
 typedef std::list BGFreeSlotQueueType;
+
 typedef UNORDERED_MAP BattleMastersMap;
+
 #define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400     // seconds in a day
 #define COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME 10
+
 struct GroupQueueInfo;                                      // type predefinition
 struct PlayerQueueInfo                                      // stores information for players in queue
 {
     uint32  LastOnlineTime;                                 // for tracking and removing offline players from queue after 5 minutes
     GroupQueueInfo * GroupInfo;                             // pointer to the associated groupqueueinfo
 };
+
 struct GroupQueueInfo                                       // stores information about the group in queue (also used when joined as solo!)
 {
     std::map Players;             // player queue info map
@@ -48,6 +57,7 @@ struct GroupQueueInfo                                       // stores informatio
     uint32  ArenaTeamRating;                                // if rated match, inited to the rating of the team
     uint32  OpponentsTeamRating;                            // for rated arena matches
 };
+
 enum BattleGroundQueueGroupTypes
 {
     BG_QUEUE_PREMADE_ALLIANCE   = 0,
@@ -56,13 +66,16 @@ enum BattleGroundQueueGroupTypes
     BG_QUEUE_NORMAL_HORDE       = 3
 };
 #define BG_QUEUE_GROUP_TYPES_COUNT 4
+
 class BattleGround;
 class BattleGroundQueue
 {
     public:
         BattleGroundQueue();
         ~BattleGroundQueue();
+
         void Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType = 0, bool isRated = false, uint32 minRating = 0);
+
         void FillPlayersToBG(BattleGround* bg, BGQueueIdBasedOnLevel queue_id);
         bool CheckPremadeMatch(BGQueueIdBasedOnLevel queue_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
         bool CheckNormalMatch(BattleGround* bg_template, BGQueueIdBasedOnLevel queue_id, uint32 minPlayers, uint32 maxPlayers);
@@ -72,12 +85,16 @@ class BattleGroundQueue
         void RemovePlayer(const uint64& guid, bool decreaseInvitedCount);
         void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id);
         uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id);
+
         void DecreaseGroupLength(uint32 queueId, uint32 AsGroup);
         void AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playerGUID, bool isAddedToQueue);
+
         typedef std::map QueuedPlayersMap;
         QueuedPlayersMap m_QueuedPlayers;
+
         //we need constant add to begin and constant remove / add from the end, therefore deque suits our problem well
         typedef std::list GroupsQueueType;
+
         /*
         This two dimensional array is used to store All queued groups
         First dimension specifies the bgTypeId
@@ -88,6 +105,7 @@ class BattleGroundQueue
              BG_QUEUE_NORMAL_HORDE      is used for normal (or small) horde groups or non-rated arena matches
         */
         GroupsQueueType m_QueuedGroups[MAX_BATTLEGROUND_QUEUES][BG_QUEUE_GROUP_TYPES_COUNT];
+
         // class to select and invite groups to bg
         class SelectionPool
         {
@@ -101,14 +119,18 @@ class BattleGroundQueue
         private:
             uint32 PlayerCount;
         };
+
         //one selection pool for horde, other one for alliance
         SelectionPool m_SelectionPools[BG_TEAMS_COUNT];
+
     private:
+
         bool InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, uint32 side);
         uint32 m_WaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_QUEUES][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME];
         uint32 m_WaitTimeLastPlayer[BG_TEAMS_COUNT][MAX_BATTLEGROUND_QUEUES];
         uint32 m_SumOfWaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_QUEUES];
 };
+
 /*
     This class is used to invite player to BG again, when minute lasts from his first invitation
     it is capable to solve all possibilities
@@ -121,6 +143,7 @@ class BGQueueInviteEvent : public BasicEvent
           {
           };
         virtual ~BGQueueInviteEvent() {};
+
         virtual bool Execute(uint64 e_time, uint32 p_time);
         virtual void Abort(uint64 e_time);
     private:
@@ -129,6 +152,7 @@ class BGQueueInviteEvent : public BasicEvent
         BattleGroundTypeId m_BgTypeId;
         uint32 m_RemoveTime;
 };
+
 /*
     This class is used to remove player from BG queue after 1 minute 20 seconds from first invitation
     We must store removeInvite time in case player left queue and joined and is invited again
@@ -140,7 +164,9 @@ class BGQueueRemoveEvent : public BasicEvent
         BGQueueRemoveEvent(const uint64& pl_guid, uint32 bgInstanceGUID, BattleGroundTypeId BgTypeId, BattleGroundQueueTypeId bgQueueTypeId, uint32 removeTime)
             : m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgTypeId(BgTypeId), m_BgQueueTypeId(bgQueueTypeId)
         {}
+
         virtual ~BGQueueRemoveEvent() {}
+
         virtual bool Execute(uint64 e_time, uint32 p_time);
         virtual void Abort(uint64 e_time);
     private:
@@ -150,6 +176,7 @@ class BGQueueRemoveEvent : public BasicEvent
         BattleGroundTypeId m_BgTypeId;
         BattleGroundQueueTypeId m_BgQueueTypeId;
 };
+
 class BattleGroundMgr
 {
     public:
@@ -157,6 +184,7 @@ class BattleGroundMgr
         BattleGroundMgr();
         ~BattleGroundMgr();
         void Update(uint32 diff);
+
         /* Packet Building */
         void BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Player *plr);
         void BuildPlayerLeftBattleGroundPacket(WorldPacket *data, const uint64& guid);
@@ -167,30 +195,41 @@ class BattleGroundMgr
         void BuildBattleGroundStatusPacket(WorldPacket *data, BattleGround *bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint8 arenatype);
         void BuildPlaySoundPacket(WorldPacket *data, uint32 soundid);
         void SendAreaSpiritHealerQueryOpcode(Player *pl, BattleGround *bg, const uint64& guid);
+
         /* Battlegrounds */
         BattleGround* GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId);
         BattleGround* GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId); //there must be uint32 because MAX_BATTLEGROUND_TYPE_ID means unknown
+
         BattleGround* GetBattleGroundTemplate(BattleGroundTypeId bgTypeId);
         BattleGround* CreateNewBattleGround(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated);
+
         uint32 CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO);
+
         void AddBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId, BattleGround* BG) { m_BattleGrounds[bgTypeId][InstanceID] = BG; };
         void RemoveBattleGround(uint32 instanceID, BattleGroundTypeId bgTypeId) { m_BattleGrounds[bgTypeId].erase(instanceID); }
         uint32 CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id);
+
         void CreateInitialBattleGrounds();
         void DeleteAllBattleGrounds();
+
         void SendToBattleGround(Player *pl, uint32 InstanceID, BattleGroundTypeId bgTypeId);
+
         /* Battleground queues */
         //these queues are instantiated when creating BattlegroundMrg
         BattleGroundQueue m_BattleGroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]; // public, because we need to access them in BG handler code
+
         BGFreeSlotQueueType BGFreeSlotQueue[MAX_BATTLEGROUND_TYPE_ID];
+
         void ScheduleQueueUpdate(BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id);
         uint32 GetMaxRatingDifference() const;
         uint32 GetRatingDiscardTimer()  const;
         uint32 GetPrematureFinishTime() const;
+
         void InitAutomaticArenaPointDistribution();
         void DistributeArenaPoints();
         void ToggleArenaTesting();
         void ToggleTesting();
+
         void SetHolidayWeekends(uint32 mask);
         void LoadBattleMastersEntry();
         BattleGroundTypeId GetBattleMasterBG(uint32 entry) const
@@ -200,16 +239,20 @@ class BattleGroundMgr
                 return itr->second;
             return BATTLEGROUND_WS;
         }
+
         bool isArenaTesting() const { return m_ArenaTesting; }
         bool isTesting() const { return m_Testing; }
+
         static bool IsArenaType(BattleGroundTypeId bgTypeId);
         static bool IsBattleGroundType(BattleGroundTypeId bgTypeId) { return !BattleGroundMgr::IsArenaType(bgTypeId); }
         static BattleGroundQueueTypeId BGQueueTypeId(BattleGroundTypeId bgTypeId, uint8 arenaType);
         static BattleGroundTypeId BGTemplateId(BattleGroundQueueTypeId bgQueueTypeId);
         static uint8 BGArenaType(BattleGroundQueueTypeId bgQueueTypeId);
+
         static bool IsBGWeekend(BattleGroundTypeId bgTypeId);
     private:
         BattleMastersMap    mBattleMastersMap;
+
         /* Battlegrounds */
         BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
         std::vectorm_QueueUpdateScheduler;
@@ -220,6 +263,7 @@ class BattleGroundMgr
         bool   m_ArenaTesting;
         bool   m_Testing;
 };
+
 #define sBattleGroundMgr Trinity::Singleton::Instance()
 #endif
 
diff --git a/src/game/BattleGroundNA.cpp b/src/game/BattleGroundNA.cpp
index b9f85117f1a..92e71c1c283 100644
--- a/src/game/BattleGroundNA.cpp
+++ b/src/game/BattleGroundNA.cpp
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "BattleGround.h"
 #include "BattleGroundNA.h"
 #include "Language.h"
@@ -24,9 +25,11 @@
 #include "ObjectMgr.h"
 #include "Player.h"
 #include "WorldPacket.h"
+
 BattleGroundNA::BattleGroundNA()
 {
     m_BgObjects.resize(BG_NA_OBJECT_MAX);
+
     m_StartDelayTimes[BG_STARTING_EVENT_FIRST]  = BG_START_DELAY_1M;
     m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
     m_StartDelayTimes[BG_STARTING_EVENT_THIRD]  = BG_START_DELAY_15S;
@@ -37,69 +40,90 @@ BattleGroundNA::BattleGroundNA()
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_ARENA_FIFTEEN_SECONDS;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
 }
+
 BattleGroundNA::~BattleGroundNA()
 {
+
 }
+
 void BattleGroundNA::Update(uint32 diff)
 {
     BattleGround::Update(diff);
+
     /*if (GetStatus() == STATUS_IN_PROGRESS)
     {
         // update something
     }*/
 }
+
 void BattleGroundNA::StartingEventCloseDoors()
 {
     for(uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_4; ++i)
         SpawnBGObject(i, RESPAWN_IMMEDIATELY);
 }
+
 void BattleGroundNA::StartingEventOpenDoors()
 {
     for(uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_2; ++i)
         DoorOpen(i);
+
     for(uint32 i = BG_NA_OBJECT_BUFF_1; i <= BG_NA_OBJECT_BUFF_2; ++i)
         SpawnBGObject(i, 60);
 }
+
 void BattleGroundNA::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in constructor
     BattleGroundNAScore* sc = new BattleGroundNAScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
+
     UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE));
 }
+
 void BattleGroundNA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/)
 {
     if (GetStatus() == STATUS_WAIT_LEAVE)
         return;
+
     UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE));
+
     CheckArenaWinConditions();
 }
+
 void BattleGroundNA::HandleKillPlayer(Player *player, Player *killer)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     if (!killer)
     {
         sLog.outError("BattleGroundNA: Killer player not found");
         return;
     }
+
     BattleGround::HandleKillPlayer(player,killer);
+
     UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE));
+
     CheckArenaWinConditions();
 }
+
 bool BattleGroundNA::HandlePlayerUnderMap(Player *player)
 {
     player->TeleportTo(GetMapId(),4055.504395,2919.660645,13.611241,player->GetOrientation(),false);
     return true;
 }
+
 void BattleGroundNA::HandleAreaTrigger(Player *Source, uint32 Trigger)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     //uint32 SpellId = 0;
     //uint64 buff_guid = 0;
     switch(Trigger)
@@ -112,20 +136,24 @@ void BattleGroundNA::HandleAreaTrigger(Player *Source, uint32 Trigger)
             Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
             break;
     }
+
     //if (buff_guid)
     //    HandleTriggerBuff(buff_guid,Source);
 }
+
 void BattleGroundNA::FillInitialWorldStates(WorldPacket &data)
 {
     data << uint32(0xa0f) << uint32(GetAlivePlayersCountByTeam(ALLIANCE));           // 7
     data << uint32(0xa10) << uint32(GetAlivePlayersCountByTeam(HORDE));           // 8
     data << uint32(0xa11) << uint32(1);           // 9
 }
+
 void BattleGroundNA::Reset()
 {
     //call parent's class reset
     BattleGround::Reset();
 }
+
 bool BattleGroundNA::SetupBattleGround()
 {
     // gates
@@ -140,8 +168,10 @@ bool BattleGroundNA::SetupBattleGround()
         sLog.outErrorDb("BatteGroundNA: Failed to spawn some object!");
         return false;
     }
+
     return true;
 }
+
 /*
 20:12:14 id:036668 [S2C] SMSG_INIT_WORLD_STATES (706 = 0x02C2) len: 86
 0000: 2f 02 00 00 72 0e 00 00 00 00 00 00 09 00 11 0a  |  /...r...........
diff --git a/src/game/BattleGroundNA.h b/src/game/BattleGroundNA.h
index 00d2e554d7e..56e2cf373c4 100644
--- a/src/game/BattleGroundNA.h
+++ b/src/game/BattleGroundNA.h
@@ -19,7 +19,9 @@
  */
 #ifndef __BATTLEGROUNDNA_H
 #define __BATTLEGROUNDNA_H
+
 class BattleGround;
+
 enum BattleGroundNAObjectTypes
 {
     BG_NA_OBJECT_DOOR_1         = 0,
@@ -30,6 +32,7 @@ enum BattleGroundNAObjectTypes
     BG_NA_OBJECT_BUFF_2         = 5,
     BG_NA_OBJECT_MAX            = 6
 };
+
 enum BattleGroundNAObjects
 {
     BG_NA_OBJECT_TYPE_DOOR_1    = 183978,
@@ -39,6 +42,7 @@ enum BattleGroundNAObjects
     BG_NA_OBJECT_TYPE_BUFF_1    = 184663,
     BG_NA_OBJECT_TYPE_BUFF_2    = 184664
 };
+
 class BattleGroundNAScore : public BattleGroundScore
 {
     public:
@@ -46,17 +50,21 @@ class BattleGroundNAScore : public BattleGroundScore
         virtual ~BattleGroundNAScore() {};
         //TODO fix me
 };
+
 class BattleGroundNA : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundNA();
         ~BattleGroundNA();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         void RemovePlayer(Player *plr, uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         bool SetupBattleGround();
diff --git a/src/game/BattleGroundRL.cpp b/src/game/BattleGroundRL.cpp
index c4ca4b1b66f..b9f9943bbf2 100644
--- a/src/game/BattleGroundRL.cpp
+++ b/src/game/BattleGroundRL.cpp
@@ -18,6 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+
 #include "BattleGround.h"
 #include "BattleGroundRL.h"
 #include "Language.h"
@@ -25,9 +26,11 @@
 #include "ObjectMgr.h"
 #include "Player.h"
 #include "WorldPacket.h"
+
 BattleGroundRL::BattleGroundRL()
 {
     m_BgObjects.resize(BG_RL_OBJECT_MAX);
+
     m_StartDelayTimes[BG_STARTING_EVENT_FIRST]  = BG_START_DELAY_1M;
     m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
     m_StartDelayTimes[BG_STARTING_EVENT_THIRD]  = BG_START_DELAY_15S;
@@ -38,70 +41,91 @@ BattleGroundRL::BattleGroundRL()
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_ARENA_FIFTEEN_SECONDS;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
 }
+
 BattleGroundRL::~BattleGroundRL()
 {
+
 }
+
 void BattleGroundRL::Update(uint32 diff)
 {
     BattleGround::Update(diff);
+
     /*if (GetStatus() == STATUS_IN_PROGRESS)
     {
         // update something
     }*/
 }
+
 void BattleGroundRL::StartingEventCloseDoors()
 {
     for(uint32 i = BG_RL_OBJECT_DOOR_1; i <= BG_RL_OBJECT_DOOR_2; ++i)
         SpawnBGObject(i, RESPAWN_IMMEDIATELY);
 }
+
 void BattleGroundRL::StartingEventOpenDoors()
 {
     for(uint32 i = BG_RL_OBJECT_DOOR_1; i <= BG_RL_OBJECT_DOOR_2; ++i)
         DoorOpen(i);
+
     for(uint32 i = BG_RL_OBJECT_BUFF_1; i <= BG_RL_OBJECT_BUFF_2; ++i)
         SpawnBGObject(i, 60);
 }
+
 void BattleGroundRL::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in constructor
     BattleGroundRLScore* sc = new BattleGroundRLScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
+
     UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
 }
+
 void BattleGroundRL::RemovePlayer(Player* /*plr*/, uint64 /*guid*/)
 {
     if (GetStatus() == STATUS_WAIT_LEAVE)
         return;
+
     UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
+
     CheckArenaWinConditions();
 }
+
 void BattleGroundRL::HandleKillPlayer(Player *player, Player *killer)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     if (!killer)
     {
         sLog.outError("Killer player not found");
         return;
     }
+
     BattleGround::HandleKillPlayer(player,killer);
+
     UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
     UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
+
     CheckArenaWinConditions();
 }
+
 bool BattleGroundRL::HandlePlayerUnderMap(Player *player)
 {
     player->TeleportTo(GetMapId(),1285.810547,1667.896851,39.957642,player->GetOrientation(),false);
     return true;
 }
+
 void BattleGroundRL::HandleAreaTrigger(Player *Source, uint32 Trigger)
 {
     // this is wrong way to implement these things. On official it done by gameobject spell cast.
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     //uint32 SpellId = 0;
     //uint64 buff_guid = 0;
     switch(Trigger)
@@ -114,20 +138,24 @@ void BattleGroundRL::HandleAreaTrigger(Player *Source, uint32 Trigger)
             Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
             break;
     }
+
     //if (buff_guid)
     //    HandleTriggerBuff(buff_guid,Source);
 }
+
 void BattleGroundRL::FillInitialWorldStates(WorldPacket &data)
 {
     data << uint32(0xbb8) << uint32(GetAlivePlayersCountByTeam(ALLIANCE));           // 7
     data << uint32(0xbb9) << uint32(GetAlivePlayersCountByTeam(HORDE));           // 8
     data << uint32(0xbba) << uint32(1);           // 9
 }
+
 void BattleGroundRL::Reset()
 {
     //call parent's reset
     BattleGround::Reset();
 }
+
 bool BattleGroundRL::SetupBattleGround()
 {
     // gates
@@ -140,8 +168,10 @@ bool BattleGroundRL::SetupBattleGround()
         sLog.outErrorDb("BatteGroundRL: Failed to spawn some object!");
         return false;
     }
+
     return true;
 }
+
 /*
 Packet S->C, id 600, SMSG_INIT_WORLD_STATES (706), len 86
 0000: 3C 02 00 00 80 0F 00 00 00 00 00 00 09 00 BA 0B | <...............
diff --git a/src/game/BattleGroundRL.h b/src/game/BattleGroundRL.h
index 7fb7ef60c2d..772c9dd0879 100644
--- a/src/game/BattleGroundRL.h
+++ b/src/game/BattleGroundRL.h
@@ -19,7 +19,9 @@
  */
 #ifndef __BATTLEGROUNDRL_H
 #define __BATTLEGROUNDRL_H
+
 class BattleGround;
+
 enum BattleGroundRLObjectTypes
 {
     BG_RL_OBJECT_DOOR_1         = 0,
@@ -28,6 +30,7 @@ enum BattleGroundRLObjectTypes
     BG_RL_OBJECT_BUFF_2         = 3,
     BG_RL_OBJECT_MAX            = 4
 };
+
 enum BattleGroundRLObjects
 {
     BG_RL_OBJECT_TYPE_DOOR_1    = 185918,
@@ -35,6 +38,7 @@ enum BattleGroundRLObjects
     BG_RL_OBJECT_TYPE_BUFF_1    = 184663,
     BG_RL_OBJECT_TYPE_BUFF_2    = 184664
 };
+
 class BattleGroundRLScore : public BattleGroundScore
 {
     public:
@@ -42,19 +46,23 @@ class BattleGroundRLScore : public BattleGroundScore
         virtual ~BattleGroundRLScore() {};
         //TODO fix me
 };
+
 class BattleGroundRL : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundRL();
         ~BattleGroundRL();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void Reset();
         virtual void FillInitialWorldStates(WorldPacket &d);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         void RemovePlayer(Player *plr, uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         bool SetupBattleGround();
diff --git a/src/game/BattleGroundRV.cpp b/src/game/BattleGroundRV.cpp
index a0fc8377eaf..54070961018 100644
--- a/src/game/BattleGroundRV.cpp
+++ b/src/game/BattleGroundRV.cpp
@@ -15,12 +15,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "BattleGround.h"
 #include "BattleGroundRV.h"
 #include "Language.h"
 #include "Player.h"
+
 BattleGroundRV::BattleGroundRV()
 {
+
     m_StartDelayTimes[BG_STARTING_EVENT_FIRST]  = BG_START_DELAY_1M;
     m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
     m_StartDelayTimes[BG_STARTING_EVENT_THIRD]  = BG_START_DELAY_15S;
@@ -31,36 +34,47 @@ BattleGroundRV::BattleGroundRV()
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_ARENA_FIFTEEN_SECONDS;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
 }
+
 BattleGroundRV::~BattleGroundRV()
 {
+
 }
+
 void BattleGroundRV::Update(uint32 diff)
 {
     BattleGround::Update(diff);
 }
+
 void BattleGroundRV::StartingEventCloseDoors()
 {
 }
+
 void BattleGroundRV::StartingEventOpenDoors()
 {
 }
+
 void BattleGroundRV::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in constructor
     BattleGroundRVScore* sc = new BattleGroundRVScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
 }
+
 void BattleGroundRV::RemovePlayer(Player * /*plr*/, uint64 /*guid*/)
 {
 }
+
 void BattleGroundRV::HandleKillPlayer(Player* player, Player* killer)
 {
     BattleGround::HandleKillPlayer(player, killer);
 }
+
 void BattleGroundRV::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/)
 {
 }
+
 bool BattleGroundRV::SetupBattleGround()
 {
     return true;
diff --git a/src/game/BattleGroundRV.h b/src/game/BattleGroundRV.h
index 4cfa8940bc3..e3e94baf101 100644
--- a/src/game/BattleGroundRV.h
+++ b/src/game/BattleGroundRV.h
@@ -17,7 +17,9 @@
  */
 #ifndef __BATTLEGROUNDRV_H
 #define __BATTLEGROUNDRV_H
+
 class BattleGround;
+
 class BattleGroundRVScore : public BattleGroundScore
 {
     public:
@@ -25,17 +27,21 @@ class BattleGroundRVScore : public BattleGroundScore
         virtual ~BattleGroundRVScore() {};
         //TODO fix me
 };
+
 class BattleGroundRV : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundRV();
         ~BattleGroundRV();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         void RemovePlayer(Player *plr, uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         bool SetupBattleGround();
diff --git a/src/game/BattleGroundSA.cpp b/src/game/BattleGroundSA.cpp
index ce5688b7706..acf16ad3af0 100644
--- a/src/game/BattleGroundSA.cpp
+++ b/src/game/BattleGroundSA.cpp
@@ -15,10 +15,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "BattleGround.h"
 #include "BattleGroundSA.h"
 #include "Language.h"
 #include "Player.h"
+
 BattleGroundSA::BattleGroundSA()
 {
     //TODO FIX ME!
@@ -27,39 +29,52 @@ BattleGroundSA::BattleGroundSA()
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_BG_WS_START_HALF_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_WS_HAS_BEGUN;
 }
+
 BattleGroundSA::~BattleGroundSA()
 {
+
 }
+
 void BattleGroundSA::Update(uint32 diff)
 {
     BattleGround::Update(diff);
 }
+
 void BattleGroundSA::StartingEventCloseDoors()
 {
 }
+
 void BattleGroundSA::StartingEventOpenDoors()
 {
 }
+
 void BattleGroundSA::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in constructor
     BattleGroundSAScore* sc = new BattleGroundSAScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
 }
+
 void BattleGroundSA::RemovePlayer(Player* /*plr*/,uint64 /*guid*/)
 {
+
 }
+
 void BattleGroundSA::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/)
 {
     // this is wrong way to implement these things. On official it done by gameobject spell cast.
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
 }
+
 void BattleGroundSA::UpdatePlayerScore(Player* Source, uint32 type, uint32 value)
 {
+
     BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
     if(itr == m_PlayerScores.end())                         // player not found...
         return;
+
     BattleGround::UpdatePlayerScore(Source,type,value);
 }
diff --git a/src/game/BattleGroundSA.h b/src/game/BattleGroundSA.h
index 81b87b6e3e7..3ba23d02656 100644
--- a/src/game/BattleGroundSA.h
+++ b/src/game/BattleGroundSA.h
@@ -15,31 +15,40 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef __BATTLEGROUNDSA_H
 #define __BATTLEGROUNDSA_H
+
 class BattleGround;
+
 class BattleGroundSAScore : public BattleGroundScore
 {
     public:
         BattleGroundSAScore() {};
         virtual ~BattleGroundSAScore() {};
 };
+
 class BattleGroundSA : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         BattleGroundSA();
         ~BattleGroundSA();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         void RemovePlayer(Player *plr,uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         //bool SetupBattleGround();
+
         /* Scorekeeping */
         void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
+
     private:
 };
 #endif
diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp
index 5edae297872..ec19308e71f 100644
--- a/src/game/BattleGroundWS.cpp
+++ b/src/game/BattleGroundWS.cpp
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "BattleGround.h"
 #include "BattleGroundWS.h"
 #include "Creature.h"
@@ -28,6 +29,7 @@
 #include "Player.h"
 #include "World.h"
 #include "WorldPacket.h"
+
 // these variables aren't used outside of this file, so declare them only here
 enum BG_WSG_Rewards
 {
@@ -36,34 +38,42 @@ enum BG_WSG_Rewards
     BG_WSG_MAP_COMPLETE,
     BG_WSG_REWARD_NUM
 };
+
 uint32 BG_WSG_Honor[BG_HONOR_MODE_NUM][BG_WSG_REWARD_NUM] = {
     {20,40,40}, // normal honor
     {60,40,80}  // holiday
 };
+
 uint32 BG_WSG_Reputation[BG_HONOR_MODE_NUM][BG_WSG_REWARD_NUM] = {
     {0,35,0}, // normal honor
     {0,45,0}  // holiday
 };
+
 BattleGroundWS::BattleGroundWS()
 {
     m_BgObjects.resize(BG_WS_OBJECT_MAX);
     m_BgCreatures.resize(BG_CREATURES_MAX_WS);
+
     m_StartMessageIds[BG_STARTING_EVENT_FIRST]  = LANG_BG_WS_START_TWO_MINUTES;
     m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_WS_START_ONE_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_THIRD]  = LANG_BG_WS_START_HALF_MINUTE;
     m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_WS_HAS_BEGUN;
 }
+
 BattleGroundWS::~BattleGroundWS()
 {
 }
+
 void BattleGroundWS::Update(uint32 diff)
 {
     BattleGround::Update(diff);
+
     if (GetStatus() == STATUS_IN_PROGRESS)
     {
         if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
         {
             m_FlagsTimer[BG_TEAM_ALLIANCE] -= diff;
+
             if (m_FlagsTimer[BG_TEAM_ALLIANCE] < 0)
             {
                 m_FlagsTimer[BG_TEAM_ALLIANCE] = 0;
@@ -73,6 +83,7 @@ void BattleGroundWS::Update(uint32 diff)
         if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
         {
             m_FlagsDropTimer[BG_TEAM_ALLIANCE] -= diff;
+
             if (m_FlagsDropTimer[BG_TEAM_ALLIANCE] < 0)
             {
                 m_FlagsDropTimer[BG_TEAM_ALLIANCE] = 0;
@@ -83,6 +94,7 @@ void BattleGroundWS::Update(uint32 diff)
         if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
         {
             m_FlagsTimer[BG_TEAM_HORDE] -= diff;
+
             if (m_FlagsTimer[BG_TEAM_HORDE] < 0)
             {
                 m_FlagsTimer[BG_TEAM_HORDE] = 0;
@@ -92,6 +104,7 @@ void BattleGroundWS::Update(uint32 diff)
         if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND)
         {
             m_FlagsDropTimer[BG_TEAM_HORDE] -= diff;
+
             if (m_FlagsDropTimer[BG_TEAM_HORDE] < 0)
             {
                 m_FlagsDropTimer[BG_TEAM_HORDE] = 0;
@@ -132,6 +145,7 @@ void BattleGroundWS::Update(uint32 diff)
         }
     }
 }
+
 void BattleGroundWS::StartingEventCloseDoors()
 {
     for(uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_H_4; ++i)
@@ -142,26 +156,32 @@ void BattleGroundWS::StartingEventCloseDoors()
     for(uint32 i = BG_WS_OBJECT_A_FLAG; i <= BG_WS_OBJECT_BERSERKBUFF_2; ++i)
         SpawnBGObject(i, RESPAWN_ONE_DAY);
 }
+
 void BattleGroundWS::StartingEventOpenDoors()
 {
     for(uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_A_4; ++i)
         DoorOpen(i);
     for(uint32 i = BG_WS_OBJECT_DOOR_H_1; i <= BG_WS_OBJECT_DOOR_H_2; ++i)
         DoorOpen(i);
+
     SpawnBGObject(BG_WS_OBJECT_DOOR_A_5, RESPAWN_ONE_DAY);
     SpawnBGObject(BG_WS_OBJECT_DOOR_A_6, RESPAWN_ONE_DAY);
     SpawnBGObject(BG_WS_OBJECT_DOOR_H_3, RESPAWN_ONE_DAY);
     SpawnBGObject(BG_WS_OBJECT_DOOR_H_4, RESPAWN_ONE_DAY);
+
     for(uint32 i = BG_WS_OBJECT_A_FLAG; i <= BG_WS_OBJECT_BERSERKBUFF_2; ++i)
         SpawnBGObject(i, RESPAWN_IMMEDIATELY);
 }
+
 void BattleGroundWS::AddPlayer(Player *plr)
 {
     BattleGround::AddPlayer(plr);
     //create score and add it to map, default values are set in constructor
     BattleGroundWGScore* sc = new BattleGroundWGScore;
+
     m_PlayerScores[plr->GetGUID()] = sc;
 }
+
 void BattleGroundWS::RespawnFlag(uint32 Team, bool captured)
 {
     if (Team == ALLIANCE)
@@ -174,6 +194,7 @@ void BattleGroundWS::RespawnFlag(uint32 Team, bool captured)
         sLog.outDebug("Respawn Horde flag");
         m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
     }
+
     if (captured)
     {
         //when map_update will be allowed for battlegrounds this code will be useless
@@ -184,10 +205,12 @@ void BattleGroundWS::RespawnFlag(uint32 Team, bool captured)
     }
     m_BothFlagsKept = false;
 }
+
 void BattleGroundWS::RespawnFlagAfterDrop(uint32 team)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     RespawnFlag(team,false);
     if (team == ALLIANCE)
     {
@@ -199,20 +222,26 @@ void BattleGroundWS::RespawnFlagAfterDrop(uint32 team)
         SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_IMMEDIATELY);
         SendMessageToAll(LANG_BG_WS_HORDE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL);
     }
+
     PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED);
+
     GameObject *obj = HashMapHolder::Find(GetDroppedFlagGUID(team));
     if (obj)
         obj->Delete();
     else
         sLog.outError("unknown droped flag bg, guid: %u",GUID_LOPART(GetDroppedFlagGUID(team)));
+
     SetDroppedFlagGUID(0,team);
     m_BothFlagsKept = false;
 }
+
 void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     uint32 winner = 0;
+
     Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
     if (Source->GetTeam() == ALLIANCE)
     {
@@ -252,26 +281,33 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
     }
     //for flag capture is reward 2 honorable kills
     RewardHonorToTeam(GetBonusHonorFromKill(2), Source->GetTeam());
+
     SpawnBGObject(BG_WS_OBJECT_H_FLAG, BG_WS_FLAG_RESPAWN_TIME);
     SpawnBGObject(BG_WS_OBJECT_A_FLAG, BG_WS_FLAG_RESPAWN_TIME);
+
     if (Source->GetTeam() == ALLIANCE)
         SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
     else
         SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, Source);
+
     UpdateFlagState(Source->GetTeam(), 1);                  // flag state none
     UpdateTeamScore(Source->GetTeam());
     // only flag capture should be updated
     UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1);      // +1 flag captures
+
     if (GetTeamScore(ALLIANCE) == BG_WS_MAX_TEAM_SCORE)
         winner = ALLIANCE;
+
     if (GetTeamScore(HORDE) == BG_WS_MAX_TEAM_SCORE)
         winner = HORDE;
+
     if (winner)
     {
         UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 0);
         UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 0);
         UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, 1);
         UpdateWorldState(BG_WS_FLAG_STATE_HORDE, 1);
+
         RewardHonorToTeam(BG_WSG_Honor[m_HonorMode][BG_WSG_WIN], winner);
         EndBattleGround(winner);
     }
@@ -280,6 +316,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
         m_FlagsTimer[GetTeamIndexByTeamId(Source->GetTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME;
     }
 }
+
 void BattleGroundWS::EventPlayerDroppedFlag(Player *Source)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
@@ -308,7 +345,9 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source)
         }
         return;
     }
+
     bool set = false;
+
     if (Source->GetTeam() == ALLIANCE)
     {
         if (!IsHordeFlagPickedup())
@@ -343,10 +382,12 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source)
             set = true;
         }
     }
+
     if (set)
     {
         Source->CastSpell(Source, SPELL_RECENTLY_DROPPED_FLAG, true);
         UpdateFlagState(Source->GetTeam(), 1);
+
         if (Source->GetTeam() == ALLIANCE)
         {
             SendMessageToAll(LANG_BG_WS_DROPPED_HF, CHAT_MSG_BG_SYSTEM_HORDE, Source);
@@ -357,15 +398,19 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source)
             SendMessageToAll(LANG_BG_WS_DROPPED_AF, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
             UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, uint32(-1));
         }
+
         m_FlagsDropTimer[GetTeamIndexByTeamId(Source->GetTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME;
     }
 }
+
 void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     int32 message_id = 0;
     ChatMsg type;
+
     //alliance flag picked up from base
     if(Source->GetTeam() == HORDE && this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE
         && this->m_BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID())
@@ -383,6 +428,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
         if(m_FlagState[1] == BG_WS_FLAG_STATE_ON_PLAYER)
           m_BothFlagsKept = true;
     }
+
     //horde flag picked up from base
     if (Source->GetTeam() == ALLIANCE && this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE
         && this->m_BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID())
@@ -400,6 +446,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
         if(m_FlagState[0] == BG_WS_FLAG_STATE_ON_PLAYER)
           m_BothFlagsKept = true;
     }
+
     //Alliance flag on ground(not in base) (returned or picked up again from ground!)
     if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10))
     {
@@ -433,6 +480,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
         //called in HandleGameObjectUseOpcode:
         //target_obj->Delete();
     }
+
     //Horde flag on ground(not in base) (returned or picked up again)
     if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10))
     {
@@ -466,11 +514,14 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
         //called in HandleGameObjectUseOpcode:
         //target_obj->Delete();
     }
+
     if (!message_id)
         return;
+
     SendMessageToAll(message_id, type, Source);
     Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
 }
+
 void BattleGroundWS::RemovePlayer(Player *plr, uint64 guid)
 {
     // sometimes flag aura not removed :(
@@ -497,6 +548,7 @@ void BattleGroundWS::RemovePlayer(Player *plr, uint64 guid)
             this->EventPlayerDroppedFlag(plr);
     }
 }
+
 void BattleGroundWS::UpdateFlagState(uint32 team, uint32 value)
 {
     if (team == ALLIANCE)
@@ -504,6 +556,7 @@ void BattleGroundWS::UpdateFlagState(uint32 team, uint32 value)
     else
         UpdateWorldState(BG_WS_FLAG_STATE_HORDE, value);
 }
+
 void BattleGroundWS::UpdateTeamScore(uint32 team)
 {
     if (team == ALLIANCE)
@@ -511,11 +564,13 @@ void BattleGroundWS::UpdateTeamScore(uint32 team)
     else
         UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE, GetTeamScore(team));
 }
+
 void BattleGroundWS::HandleAreaTrigger(Player *Source, uint32 Trigger)
 {
     // this is wrong way to implement these things. On official it done by gameobject spell cast.
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     //uint32 SpellId = 0;
     //uint64 buff_guid = 0;
     switch(Trigger)
@@ -558,9 +613,11 @@ void BattleGroundWS::HandleAreaTrigger(Player *Source, uint32 Trigger)
             Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
             break;
     }
+
     //if (buff_guid)
     //    HandleTriggerBuff(buff_guid,Source);
 }
+
 bool BattleGroundWS::SetupBattleGround()
 {
     // flags
@@ -590,25 +647,31 @@ bool BattleGroundWS::SetupBattleGround()
         sLog.outErrorDb("BatteGroundWS: Failed to spawn some object BattleGround not created!");
         return false;
     }
+
     WorldSafeLocsEntry const *sg = sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE);
     if (!sg || !AddSpiritGuide(WS_SPIRIT_MAIN_ALLIANCE, sg->x, sg->y, sg->z, 3.124139f, ALLIANCE))
     {
         sLog.outErrorDb("BatteGroundWS: Failed to spawn Alliance spirit guide! BattleGround not created!");
         return false;
     }
+
     sg = sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_HORDE);
     if (!sg || !AddSpiritGuide(WS_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, HORDE))
     {
         sLog.outErrorDb("BatteGroundWS: Failed to spawn Horde spirit guide! BattleGround not created!");
         return false;
     }
+
     sLog.outDebug("BatteGroundWS: BG objects and spirit guides spawned");
+
     return true;
 }
+
 void BattleGroundWS::Reset()
 {
     //call parent's class reset
     BattleGround::Reset();
+
     m_FlagKeepers[BG_TEAM_ALLIANCE]     = 0;
     m_FlagKeepers[BG_TEAM_HORDE]        = 0;
     m_DroppedFlagGUID[BG_TEAM_ALLIANCE] = 0;
@@ -621,6 +684,7 @@ void BattleGroundWS::Reset()
     m_ReputationCapture = (isBGWeekend) ? 45 : 35;
     m_HonorWinKills = (isBGWeekend) ? 3 : 1;
     m_HonorEndKills = (isBGWeekend) ? 4 : 2;
+
     /* Spirit nodes is static at this BG and then not required deleting at BG reset.
     if (m_BgCreatures[WS_SPIRIT_MAIN_ALLIANCE])
         DelCreature(WS_SPIRIT_MAIN_ALLIANCE);
@@ -628,6 +692,7 @@ void BattleGroundWS::Reset()
         DelCreature(WS_SPIRIT_MAIN_HORDE);
     */
 }
+
 void BattleGroundWS::EndBattleGround(uint32 winner)
 {
     //win reward
@@ -638,20 +703,27 @@ void BattleGroundWS::EndBattleGround(uint32 winner)
     //complete map_end rewards (even if no team wins)
     RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills), ALLIANCE);
     RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills), HORDE);
+
     BattleGround::EndBattleGround(winner);
 }
+
 void BattleGroundWS::HandleKillPlayer(Player *player, Player *killer)
 {
     if (GetStatus() != STATUS_IN_PROGRESS)
         return;
+
     EventPlayerDroppedFlag(player);
+
     BattleGround::HandleKillPlayer(player, killer);
 }
+
 void BattleGroundWS::UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
 {
+
     BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
     if(itr == m_PlayerScores.end())                         // player not found
         return;
+
     switch(type)
     {
         case SCORE_FLAG_CAPTURES:                           // flags captured
@@ -665,6 +737,7 @@ void BattleGroundWS::UpdatePlayerScore(Player *Source, uint32 type, uint32 value
             break;
     }
 }
+
 WorldSafeLocsEntry const* BattleGroundWS::GetClosestGraveYard(Player* player)
 {
     //if status in progress, it returns main graveyards with spiritguides
@@ -687,30 +760,37 @@ WorldSafeLocsEntry const* BattleGroundWS::GetClosestGraveYard(Player* player)
             return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_HORDE);
     }
 }
+
 void BattleGroundWS::FillInitialWorldStates(WorldPacket& data)
 {
     data << uint32(BG_WS_FLAG_CAPTURES_ALLIANCE) << uint32(GetTeamScore(ALLIANCE));
     data << uint32(BG_WS_FLAG_CAPTURES_HORDE) << uint32(GetTeamScore(HORDE));
+
     if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
         data << uint32(BG_WS_FLAG_UNK_ALLIANCE) << uint32(-1);
     else if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER)
         data << uint32(BG_WS_FLAG_UNK_ALLIANCE) << uint32(1);
     else
         data << uint32(BG_WS_FLAG_UNK_ALLIANCE) << uint32(0);
+
     if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND)
         data << uint32(BG_WS_FLAG_UNK_HORDE) << uint32(-1);
     else if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER)
         data << uint32(BG_WS_FLAG_UNK_HORDE) << uint32(1);
     else
         data << uint32(BG_WS_FLAG_UNK_HORDE) << uint32(0);
+
     data << uint32(BG_WS_FLAG_CAPTURES_MAX) << uint32(BG_WS_MAX_TEAM_SCORE);
+
     if (m_FlagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER)
         data << uint32(BG_WS_FLAG_STATE_ALLIANCE) << uint32(2);
     else
         data << uint32(BG_WS_FLAG_STATE_ALLIANCE) << uint32(1);
+
     if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER)
         data << uint32(BG_WS_FLAG_STATE_HORDE) << uint32(2);
     else
         data << uint32(BG_WS_FLAG_STATE_HORDE) << uint32(1);
+
 }
 
diff --git a/src/game/BattleGroundWS.h b/src/game/BattleGroundWS.h
index 0b616af24b1..16631afecdc 100644
--- a/src/game/BattleGroundWS.h
+++ b/src/game/BattleGroundWS.h
@@ -17,9 +17,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef __BATTLEGROUNDWS_H
 #define __BATTLEGROUNDWS_H
+
 #include "BattleGround.h"
+
 enum BG_WS_TimerOrScore
 {
     BG_WS_MAX_TEAM_SCORE    = 3,
@@ -28,6 +31,7 @@ enum BG_WS_TimerOrScore
     BG_WS_SPELL_FORCE_TIME  = 600000,
     BG_WS_SPELL_BRUTAL_TIME = 900000
 };
+
 enum BG_WS_Sound
 {
     BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE  = 8173,
@@ -38,6 +42,7 @@ enum BG_WS_Sound
     BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP = 8174,
     BG_WS_SOUND_FLAGS_RESPAWNED         = 8232
 };
+
 enum BG_WS_SpellId
 {
     BG_WS_SPELL_WARSONG_FLAG            = 23333,
@@ -47,6 +52,7 @@ enum BG_WS_SpellId
     BG_WS_SPELL_FOCUSED_ASSAULT         = 46392,
     BG_WS_SPELL_BRUTAL_ASSAULT          = 46393
 };
+
 enum BG_WS_WorldStates
 {
     BG_WS_FLAG_UNK_ALLIANCE       = 1545,
@@ -58,6 +64,7 @@ enum BG_WS_WorldStates
     BG_WS_FLAG_STATE_HORDE        = 2338,
     BG_WS_FLAG_STATE_ALLIANCE     = 2339
 };
+
 enum BG_WS_ObjectTypes
 {
     BG_WS_OBJECT_DOOR_A_1       = 0,
@@ -80,6 +87,7 @@ enum BG_WS_ObjectTypes
     BG_WS_OBJECT_BERSERKBUFF_2  = 17,
     BG_WS_OBJECT_MAX            = 18
 };
+
 enum BG_WS_ObjectEntry
 {
     BG_OBJECT_DOOR_A_1_WS_ENTRY          = 179918,
@@ -97,6 +105,7 @@ enum BG_WS_ObjectEntry
     BG_OBJECT_A_FLAG_GROUND_WS_ENTRY     = 179785,
     BG_OBJECT_H_FLAG_GROUND_WS_ENTRY     = 179786
 };
+
 enum BG_WS_FlagState
 {
     BG_WS_FLAG_STATE_ON_BASE      = 0,
@@ -104,6 +113,7 @@ enum BG_WS_FlagState
     BG_WS_FLAG_STATE_ON_PLAYER    = 2,
     BG_WS_FLAG_STATE_ON_GROUND    = 3
 };
+
 enum BG_WS_Graveyards
 {
     WS_GRAVEYARD_FLAGROOM_ALLIANCE = 769,
@@ -111,17 +121,21 @@ enum BG_WS_Graveyards
     WS_GRAVEYARD_MAIN_ALLIANCE     = 771,
     WS_GRAVEYARD_MAIN_HORDE        = 772
 };
+
 enum BG_WS_CreatureTypes
 {
     WS_SPIRIT_MAIN_ALLIANCE   = 0,
     WS_SPIRIT_MAIN_HORDE      = 1,
+
     BG_CREATURES_MAX_WS       = 2
 };
+
 enum BG_WS_CarrierDebuffs
 {
     WS_SPELL_FOCUSED_ASSAULT   = 46392,
     WS_SPELL_BRUTAL_ASSAULT    = 46393
 };
+
 class BattleGroundWGScore : public BattleGroundScore
 {
     public:
@@ -130,18 +144,22 @@ class BattleGroundWGScore : public BattleGroundScore
         uint32 FlagCaptures;
         uint32 FlagReturns;
 };
+
 class BattleGroundWS : public BattleGround
 {
     friend class BattleGroundMgr;
+
     public:
         /* Construction */
         BattleGroundWS();
         ~BattleGroundWS();
         void Update(uint32 diff);
+
         /* inherited from BattlegroundClass */
         virtual void AddPlayer(Player *plr);
         virtual void StartingEventCloseDoors();
         virtual void StartingEventOpenDoors();
+
         /* BG Flags */
         uint64 GetAllianceFlagPickerGUID() const    { return m_FlagKeepers[BG_TEAM_ALLIANCE]; }
         uint64 GetHordeFlagPickerGUID() const       { return m_FlagKeepers[BG_TEAM_HORDE]; }
@@ -156,10 +174,12 @@ class BattleGroundWS : public BattleGround
         void RemoveTimedAura(uint32 aura);
         bool IsBrutalTimerDone;
         bool IsForceTimerDone;
+
         /* Battleground Events */
         virtual void EventPlayerDroppedFlag(Player *Source);
         virtual void EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj);
         virtual void EventPlayerCapturedFlag(Player *Source);
+
         void RemovePlayer(Player *plr, uint64 guid);
         void HandleAreaTrigger(Player *Source, uint32 Trigger);
         void HandleKillPlayer(Player *player, Player *killer);
@@ -167,12 +187,14 @@ class BattleGroundWS : public BattleGround
         virtual void Reset();
         void EndBattleGround(uint32 winner);
         virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
+
         void UpdateFlagState(uint32 team, uint32 value);
         void UpdateTeamScore(uint32 team);
         void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
         void SetDroppedFlagGUID(uint64 guid, uint32 TeamID)  { m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)] = guid;}
         uint64 GetDroppedFlagGUID(uint32 TeamID)             { return m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)];}
         virtual void FillInitialWorldStates(WorldPacket& data);
+
         /* Scorekeeping */
         uint32 GetTeamScore(uint32 TeamID) const            { return m_TeamScores[GetTeamIndexByTeamId(TeamID)]; }
         void AddPoint(uint32 TeamID, uint32 Points = 1)     { m_TeamScores[GetTeamIndexByTeamId(TeamID)] += Points; }
@@ -184,6 +206,7 @@ class BattleGroundWS : public BattleGround
         uint8 m_FlagState[2];                               // for checking flag state
         int32 m_FlagsTimer[2];
         int32 m_FlagsDropTimer[2];
+
         uint32 m_ReputationCapture;
         uint32 m_HonorWinKills;
         uint32 m_HonorEndKills;
diff --git a/src/game/Calendar.h b/src/game/Calendar.h
index 41f75c7aa28..7a86afa7db7 100644
--- a/src/game/Calendar.h
+++ b/src/game/Calendar.h
@@ -15,9 +15,12 @@
  * 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_CALENDAR_H
 #define MANGOS_CALENDAR_H
+
 class Calendar
 {
+
 };
 #endif
diff --git a/src/game/CalendarHandler.cpp b/src/game/CalendarHandler.cpp
index 747f2e9f309..93d3b7eae26 100644
--- a/src/game/CalendarHandler.cpp
+++ b/src/game/CalendarHandler.cpp
@@ -15,27 +15,36 @@
  * 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 "WorldPacket.h"
 #include "WorldSession.h"
+
 #include "InstanceSaveMgr.h"
 #include "Log.h"
 #include "Opcodes.h"
 #include "Player.h"
+
 void WorldSession::HandleCalendarGetCalendar(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_GET_CALENDAR");     // empty
+
     time_t cur_time = time(NULL);
+
     WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR,4+4*0+4+4*0+4+4);
+
     // TODO: calendar invite event output
     data << (uint32) 0;                                     //invite node count
     // TODO: calendar event output
     data << (uint32) 0;                                     //event count
+
     data << (uint32) 0;                                     //wtf??
     data << (uint32) secsToTimeBitFields(cur_time);         // current time
+
     uint32 counter = 0;
     size_t p_counter = data.wpos();
     data << uint32(counter);                                // instance save count
+
     for(int i = 0; i < TOTAL_DIFFICULTIES; ++i)
     {
         for (Player::BoundInstancesMap::const_iterator itr = _player->m_boundInstances[i].begin(); itr != _player->m_boundInstances[i].end(); ++itr)
@@ -52,6 +61,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &recv_data)
         }
     }
     data.put(p_counter,counter);
+
     data << (uint32) 1135753200;                            //wtf?? (28.12.2005 12:00)
     data << (uint32) 0;                                     //  unk counter 4
     data << (uint32) 0;                                     // unk counter 5
@@ -59,12 +69,14 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &recv_data)
     //data.hexlike();
     SendPacket(&data);
 }
+
 void WorldSession::HandleCalendarGetEvent(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_GET_EVENT");
     recv_data.hexlike();
     recv_data.read_skip();                          // unk
 }
+
 void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_GUILD_FILTER");
@@ -73,20 +85,24 @@ void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data)
     recv_data.read_skip();                          // unk2
     recv_data.read_skip();                          // unk3
 }
+
 void WorldSession::HandleCalendarArenaTeam(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_ARENA_TEAM");
     recv_data.hexlike();
     recv_data.read_skip();                          // unk
 }
+
 void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_ADD_EVENT");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //std::string unk1, unk2;
     //recv_data >> (std::string)unk1;
     //recv_data >> (std::string)unk2;
+
     //uint8   unk3, unk4;
     //uint32  unk5, unk6, unk7, unk8, unk9, count = 0;
     //recv_data >> (uint8)unk3;
@@ -112,11 +128,13 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data)
     //    }
     //}
 }
+
 void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_UPDATE_EVENT");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> std::string
@@ -129,88 +147,110 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data)
     //recv_data >> uint32
     //recv_data >> uint32
 }
+
 void WorldSession::HandleCalendarRemoveEvent(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_REMOVE_EVENT");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint32
+
 }
+
 void WorldSession::HandleCalendarCopyEvent(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_COPY_EVENT");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint32
+
 }
+
 void WorldSession::HandleCalendarEventInvite(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_EVENT_INVITE");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> std::string
     //recv_data >> uint8
     //recv_data >> uint8
+
 }
+
 void WorldSession::HandleCalendarEventRsvp(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_EVENT_RSVP");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint32
+
 }
+
 void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_EVENT_REMOVE_INVITE");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data.readPackGUID(guid)
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint64
 }
+
 void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_EVENT_STATUS");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data.readPackGUID(guid)
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint32
 }
+
 void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_EVENT_MODERATOR_STATUS");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data.readPackGUID(guid)
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint32
 }
+
 void WorldSession::HandleCalendarComplain(WorldPacket &recv_data)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_COMPLAIN");
     recv_data.hexlike();
     recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam
+
     //recv_data >> uint64
     //recv_data >> uint64
     //recv_data >> uint64
 }
+
 void WorldSession::HandleCalendarGetNumPending(WorldPacket & /*recv_data*/)
 {
     sLog.outDebug("WORLD: CMSG_CALENDAR_GET_NUM_PENDING");  // empty
+
     WorldPacket data(SMSG_CALENDAR_SEND_NUM_PENDING, 4);
     data << uint32(0);                                      // 0 - no pending invites, 1 - some pending invites
     SendPacket(&data);
diff --git a/src/game/Cell.h b/src/game/Cell.h
index 7145df0aacc..9baf4104080 100644
--- a/src/game/Cell.h
+++ b/src/game/Cell.h
@@ -17,14 +17,20 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_CELL_H
 #define TRINITY_CELL_H
+
 #include 
+
 #include "GameSystem/TypeContainer.h"
 #include "GameSystem/TypeContainerVisitor.h"
+
 #include "GridDefines.h"
+
 class Map;
 class WorldObject;
+
 enum District
 {
     UPPER_DISTRICT = 1,
@@ -38,12 +44,15 @@ enum District
     LOWER_RIGHT_DISTRICT = (LOWER_DISTRICT | RIGHT_DISTRICT),
     ALL_DISTRICT = (UPPER_DISTRICT | LOWER_DISTRICT | LEFT_DISTRICT | RIGHT_DISTRICT | CENTER_DISTRICT)
 };
+
 template struct CellLock;
+
 struct TRINITY_DLL_DECL CellArea
 {
     CellArea() : right_offset(0), left_offset(0), upper_offset(0), lower_offset(0) {}
     CellArea(int right, int left, int upper, int lower) : right_offset(right), left_offset(left), upper_offset(upper), lower_offset(lower) {}
     bool operator!() const { return !right_offset && !left_offset && !upper_offset && !lower_offset; }
+ 
     void ResizeBorders(CellPair& begin_cell, CellPair& end_cell) const
     {
         begin_cell << left_offset;
@@ -51,17 +60,20 @@ struct TRINITY_DLL_DECL CellArea
         end_cell >> right_offset;
         end_cell += upper_offset;
     }
+ 
     int right_offset;
     int left_offset;
     int upper_offset;
     int lower_offset;
 };
+ 
 
 struct TRINITY_DLL_DECL Cell
 {
     Cell() { data.All = 0; }
     Cell(const Cell &cell) { data.All = cell.data.All; }
     explicit Cell(CellPair const& p);
+
     void operator|=(Cell &cell)
     {
         data.Part.reserved = 0;
@@ -69,12 +81,14 @@ struct TRINITY_DLL_DECL Cell
         uint32 x, y, old_x, old_y;
         Compute(x, y);
         cell.Compute(old_x, old_y);
+
         if( std::abs(int(x-old_x)) > 1 || std::abs(int(y-old_y)) > 1)
         {
             data.Part.reserved = ALL_DISTRICT;
             cell.data.Part.reserved = ALL_DISTRICT;
             return;
         }
+
         if( x < old_x )
         {
             data.Part.reserved |= LEFT_DISTRICT;
@@ -96,38 +110,45 @@ struct TRINITY_DLL_DECL Cell
             cell.data.Part.reserved |= UPPER_DISTRICT;
         }
     }
+
     void Compute(uint32 &x, uint32 &y) const
     {
         x = data.Part.grid_x*MAX_NUMBER_OF_CELLS + data.Part.cell_x;
         y = data.Part.grid_y*MAX_NUMBER_OF_CELLS + data.Part.cell_y;
     }
+
     bool DiffCell(const Cell &cell) const
     {
         return( data.Part.cell_x != cell.data.Part.cell_x ||
             data.Part.cell_y != cell.data.Part.cell_y );
     }
+
     bool DiffGrid(const Cell &cell) const
     {
         return( data.Part.grid_x != cell.data.Part.grid_x ||
             data.Part.grid_y != cell.data.Part.grid_y );
     }
+
     uint32 CellX() const { return data.Part.cell_x; }
     uint32 CellY() const { return data.Part.cell_y; }
     uint32 GridX() const { return data.Part.grid_x; }
     uint32 GridY() const { return data.Part.grid_y; }
     bool NoCreate() const { return data.Part.nocreate; }
     void SetNoCreate() { data.Part.nocreate = 1; }
+
     CellPair cellPair() const
     {
         return CellPair(
             data.Part.grid_x*MAX_NUMBER_OF_CELLS+data.Part.cell_x,
             data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y);
     }
+
     Cell& operator=(const Cell &cell)
     {
         this->data.All = cell.data.All;
         return *this;
     }
+
     bool operator==(const Cell &cell) const { return (data.All == cell.data.All); }
     bool operator!=(const Cell &cell) const { return !operator==(cell); }
     union
@@ -143,13 +164,17 @@ struct TRINITY_DLL_DECL Cell
         } Part;
         uint32 All;
     } data;
+
     template void Visit(const CellLock &, TypeContainerVisitor &visitor, Map &) const;
     template void Visit(const CellLock &, TypeContainerVisitor &visitor, Map &m, const WorldObject &obj, float radius) const;
     template void Visit(const CellLock &, TypeContainerVisitor &visitor, Map &, float radius, float x_off, float y_off) const;
+ 
     static CellArea CalculateCellArea(const WorldObject &obj, float radius);
+ 
 private:
     template void VisitCircle(const CellLock &, TypeContainerVisitor &, Map &, const CellPair& , const CellPair& ) const;
 };
+
 template
 struct TRINITY_DLL_DECL CellLock
 {
diff --git a/src/game/CellImpl.h b/src/game/CellImpl.h
index 659ffd48eb6..ff2b0343c69 100644
--- a/src/game/CellImpl.h
+++ b/src/game/CellImpl.h
@@ -17,12 +17,16 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_CELLIMPL_H
 #define TRINITY_CELLIMPL_H
+
 #include 
+
 #include "Cell.h"
 #include "Map.h"
 #include "Object.h"
+
 inline Cell::Cell(CellPair const& p)
 {
     data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
@@ -32,6 +36,7 @@ inline Cell::Cell(CellPair const& p)
     data.Part.nocreate = 0;
     data.Part.reserved = 0;
 }
+
 template
 inline void
 Cell::Visit(const CellLock &l, TypeContainerVisitor &visitor, Map &m) const
@@ -39,16 +44,19 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
     const CellPair &standing_cell = l.i_cellPair;
     if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
         return;
+
     uint16 district = (District)this->data.Part.reserved;
     if(district == CENTER_DISTRICT)
     {
         m.Visit(l, visitor);
         return;
     }
+
     // set up the cell range based on the district
     // the overloaded operators handle range checking
     CellPair begin_cell = standing_cell;
     CellPair end_cell = standing_cell;
+
     switch( district )
     {
         case ALL_DISTRICT:
@@ -109,6 +117,7 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
             break;
         }
     }
+
     // loop the cell range
     for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
     {
@@ -122,6 +131,7 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
         }
     }
 }
+
 template
 inline void
 Cell::Visit(const CellLock &l, TypeContainerVisitor &visitor, Map &m, float radius, float x_off, float y_off) const
@@ -129,7 +139,9 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
     const CellPair &standing_cell = l.i_cellPair;
     if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
         return;
+
     int left = 0, right = 0, upper = 0, lower = 0;
+
     // Origin = (CENTER_GRID_CELL_OFFSET, CENTER_GRID_CELL_OFFSET)
     if(CENTER_GRID_CELL_OFFSET - x_off < radius)
         ++right;
@@ -139,17 +151,21 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
         ++upper;
     if(CENTER_GRID_CELL_OFFSET + y_off < radius)
         ++lower;
+
     if(!left && !right && !upper && !lower)
     {
         m.Visit(l, visitor);
         return;
     }
+
     CellPair begin_cell = standing_cell;
     CellPair end_cell = standing_cell;
+
     begin_cell << left; //note: need change << if left > 1
     begin_cell -= lower;
     end_cell >> right;
     end_cell += upper;
+
     // loop the cell range
     for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
     {
@@ -163,16 +179,20 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
         }
     }
 }
+
 inline int CellHelper(const float radius)
 {
     if(radius < 1.0f)
         return 0;
+ 
     return (int)ceilf(radius/SIZE_OF_GRID_CELL);
 }
+ 
 inline CellArea Cell::CalculateCellArea(const WorldObject &obj, float radius)
 {
     if(radius <= 0.0f)
         return CellArea();
+ 
     //we should increase search radius by object's radius, otherwise
     //we could have problems with huge creatures, which won't attack nearest players etc
     radius += obj.GetObjectSize();
@@ -180,18 +200,23 @@ inline CellArea Cell::CalculateCellArea(const WorldObject &obj, float radius)
     //TODO: add more correct/generic method for this task
     const float x_offset = (obj.GetPositionX() - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
     const float y_offset = (obj.GetPositionY() - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
+ 
     const float x_val = floor(x_offset + CENTER_GRID_CELL_ID + 0.5f);
     const float y_val = floor(y_offset + CENTER_GRID_CELL_ID + 0.5f);
+ 
     const float x_off = (x_offset - x_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
     const float y_off = (y_offset - y_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
+ 
     const float tmp_diff = radius - CENTER_GRID_CELL_OFFSET;
     //lets calculate upper/lower/right/left corners for cell search
     int right = CellHelper(tmp_diff + x_off);
     int left = CellHelper(tmp_diff - x_off);
     int upper = CellHelper(tmp_diff + y_off);
     int lower = CellHelper(tmp_diff - y_off);
+ 
     return CellArea(right, left, upper, lower);
 }
+ 
 template
 inline void
 Cell::Visit(const CellLock &l, TypeContainerVisitor &visitor, Map &m, const WorldObject &obj, float radius) const
@@ -199,6 +224,7 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
     const CellPair &standing_cell = l.i_cellPair;
     if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
         return;
+ 
     //no jokes here... Actually placing ASSERT() here was good idea, but
     //we had some problems with DynamicObjects, which pass radius = 0.0f (DB issue?)
     //maybe it is better to just return when radius <= 0.0f?
@@ -210,6 +236,7 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
     //lets limit the upper value for search radius
     if(radius > 333.0f)
         radius = 333.0f;
+ 
     //lets calculate object coord offsets from cell borders.
     CellArea area = Cell::CalculateCellArea(obj, radius);
     //if radius fits inside standing cell
@@ -218,8 +245,10 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
         m.Visit(l, visitor);
         return;
     }
+ 
     CellPair begin_cell = standing_cell;
     CellPair end_cell = standing_cell;
+ 
     area.ResizeBorders(begin_cell, end_cell);
     //visit all cells, found in CalculateCellArea()
     //if radius is known to reach cell area more than 4x4 then we should call optimized VisitCircle
@@ -230,9 +259,11 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
         VisitCircle(l, visitor, m, begin_cell, end_cell);
         return;
     }
+ 
     //ALWAYS visit standing cell first!!! Since we deal with small radiuses
     //it is very essential to call visitor for standing cell firstly...
     m.Visit(l, visitor);
+ 
     // loop the cell range
     for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
     {
@@ -250,6 +281,7 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi
         }
     }
 }
+ 
 template
 inline void
 Cell::VisitCircle(const CellLock &l, TypeContainerVisitor &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const
@@ -259,6 +291,7 @@ Cell::VisitCircle(const CellLock &l, TypeContainerVisitor &l, TypeContainerVisitor &l, TypeContainerVisitordata.Part.nocreate;
             CellLock lock_left(r_zone_left, cell_pair_left);
             m.Visit(lock_left, visitor);
+ 
             //right trapezoid cell visit
             CellPair cell_pair_right(x_end + step, y);
             Cell r_zone_right(cell_pair_right);
diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp
index 5ff403b9484..72e35a6e777 100644
--- a/src/game/Channel.cpp
+++ b/src/game/Channel.cpp
@@ -17,10 +17,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "Channel.h"
 #include "ObjectMgr.h"
 #include "SocialMgr.h"
 #include "World.h"
+
 Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
  : m_name(name), m_announce(true), m_moderate(false), m_channelId(channel_id), m_ownerGUID(0), m_password(""), m_flags(0)
 {
@@ -31,16 +33,20 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
     {
         channel_id = ch->ChannelID;                         // built-in channel
         m_announce = false;                                 // no join/leave announces
+
         m_flags |= CHANNEL_FLAG_GENERAL;                    // for all built-in channels
+
         if(ch->flags & CHANNEL_DBC_FLAG_TRADE)              // for trade channel
             m_flags |= CHANNEL_FLAG_TRADE;
+
         if(ch->flags & CHANNEL_DBC_FLAG_CITY_ONLY2)         // for city only channels
             m_flags |= CHANNEL_FLAG_CITY;
+
         if(ch->flags & CHANNEL_DBC_FLAG_LFG)                // for LFG channel
             m_flags |= CHANNEL_FLAG_LFG;
         else                                                // for all other channels
             m_flags |= CHANNEL_FLAG_NOT_LFG;
-        m_IsSaved = false;
+        m_IsSaved = false;  
     }
     else                                                    // it's custom channel
     {
@@ -56,7 +62,9 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
             m_moderate = fields[3].GetBool();
             m_password  = fields[4].GetString();
             const char* db_BannedList = fields[5].GetString();
+            
             m_IsSaved = true;
+
             if(db_BannedList)
             {
                 Tokens tokens = StrSplit(db_BannedList, " ");
@@ -79,10 +87,11 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
             {
                 sLog.outDebug("New Channel(%s) saved", name.c_str());
                 m_IsSaved = true;
-            }
+            }            
         }
     }
 }
+
 void Channel::Join(uint64 p, const char *pass)
 {
     WorldPacket data;
@@ -95,19 +104,23 @@ void Channel::Join(uint64 p, const char *pass)
         }
         return;
     }
+
     if(IsBanned(p))
     {
         MakeBanned(&data);
         SendToOne(&data, p);
         return;
     }
+
     if(m_password.length() > 0 && strcmp(pass, m_password.c_str()))
     {
         MakeWrongPassword(&data);
         SendToOne(&data, p);
         return;
     }
+
     Player *plr = objmgr.GetPlayer(p);
+
     if(plr)
     {
         if(HasFlag(CHANNEL_FLAG_LFG) &&
@@ -118,28 +131,36 @@ void Channel::Join(uint64 p, const char *pass)
             SendToOne(&data, p);
             return;
         }
+
         if(plr->GetGuildId() && (GetFlags() == 0x38))
             return;
+
         plr->JoinedChannel(this);
     }
+
     if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) ))
     {
         MakeJoined(&data, p);
         SendToAll(&data);
     }
+
     data.clear();
+
     PlayerInfo pinfo;
     pinfo.player = p;
     pinfo.flags = MEMBER_FLAG_NONE;
     players[p] = pinfo;
+
     MakeYouJoined(&data);
     SendToOne(&data, p);
+
     JoinNotify(p);
+
     // if no owner first logged will become
     if(!IsConstant() && !m_ownerGUID)
     {
         SetOwner(p, (players.size() > 1 ? true : false));
-        players[p].SetModerator(true);
+        players[p].SetModerator(true);        
     }
     /*
     else if(!IsConstant() && m_ownerGUID && plr && m_ownerGUID == plr->GetGUID() ))
@@ -148,6 +169,7 @@ void Channel::Join(uint64 p, const char *pass)
         players[p].SetModerator(true);
     }*/
 }
+
 void Channel::Leave(uint64 p, bool send)
 {
     if(!IsOn(p))
@@ -162,6 +184,7 @@ void Channel::Leave(uint64 p, bool send)
     else
     {
         Player *plr = objmgr.GetPlayer(p);
+
         if(send)
         {
             WorldPacket data;
@@ -171,7 +194,9 @@ void Channel::Leave(uint64 p, bool send)
                 plr->LeftChannel(this);
             data.clear();
         }
+
         bool changeowner = players[p].IsOwner();
+
         players.erase(p);
         if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) ))
         {
@@ -179,7 +204,9 @@ void Channel::Leave(uint64 p, bool send)
             MakeLeft(&data, p);
             SendToAll(&data);
         }
+
         LeaveNotify(p);
+
         if(changeowner)
         {
             uint64 newowner = !players.empty() ? players.begin()->second.player : 0;
@@ -188,12 +215,14 @@ void Channel::Leave(uint64 p, bool send)
         }
     }
 }
+
 void Channel::KickOrBan(uint64 good, const char *badname, bool ban)
 {
     AccountTypes sec = SEC_PLAYER;
     Player *gplr = objmgr.GetPlayer(good);
     if(gplr)
         sec = gplr->GetSession()->GetSecurity();
+
     if(!IsOn(good))
     {
         WorldPacket data;
@@ -224,7 +253,9 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban)
         else
         {
             bool changeowner = (m_ownerGUID == bad->GetGUID());
+
             WorldPacket data;
+
             if(ban && !IsBanned(bad->GetGUID()))
             {
                 banned.insert(bad->GetGUID());
@@ -243,14 +274,17 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban)
                     if(CharacterDatabase.PExecute( ss.str( ).c_str( ) ))
                     {
                         sLog.outDebug("Channel(%s) BannedList saved", m_name.c_str());
-                    }
+                    }    
                 }
+
             }
             else
                 MakePlayerKicked(&data, bad->GetGUID(), good);
+
             SendToAll(&data);
             players.erase(bad->GetGUID());
             bad->LeftChannel(this);
+
             if(changeowner)
             {
                 uint64 newowner = !players.empty() ? good : false;
@@ -260,12 +294,14 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban)
         }
     }
 }
+
 void Channel::UnBan(uint64 good, const char *badname)
 {
     uint32 sec = 0;
     Player *gplr = objmgr.GetPlayer(good);
     if(gplr)
         sec = gplr->GetSession()->GetSecurity();
+
     if(!IsOn(good))
     {
         WorldPacket data;
@@ -290,6 +326,7 @@ void Channel::UnBan(uint64 good, const char *badname)
         else
         {
             banned.erase(bad->GetGUID());
+
             WorldPacket data;
             MakePlayerUnbanned(&data, bad->GetGUID(), good);
             SendToAll(&data);
@@ -307,17 +344,19 @@ void Channel::UnBan(uint64 good, const char *badname)
                 if(CharacterDatabase.PExecute( ss.str( ).c_str( ) ))
                 {
                     sLog.outDebug("Channel(%s) BannedList saved", m_name.c_str());
-                }
+                }    
             }
         }
     }
 }
+
 void Channel::Password(uint64 p, const char *pass)
 {
     uint32 sec = 0;
     Player *plr = objmgr.GetPlayer(p);
     if(plr)
         sec = plr->GetSession()->GetSecurity();
+
     if(!IsOn(p))
     {
         WorldPacket data;
@@ -333,6 +372,7 @@ void Channel::Password(uint64 p, const char *pass)
     else
     {
         m_password = pass;
+
         WorldPacket data;
         MakePasswordChanged(&data, p);
         SendToAll(&data);
@@ -343,16 +383,19 @@ void Channel::Password(uint64 p, const char *pass)
             if(CharacterDatabase.PExecute( ss.str( ).c_str( ) ))
             {
                 sLog.outDebug("Channel(%s) password saved", m_name.c_str());
-            }
+            }    
         }
     }
 }
+
 void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
 {
     Player *plr = objmgr.GetPlayer(p);
     if (!plr)
         return;
+
     uint32 sec = plr->GetSession()->GetSecurity();
+
     if(!IsOn(p))
     {
         WorldPacket data;
@@ -375,9 +418,11 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
             SendToOne(&data, p);
             return;
         }
+
         PlayerInfo inf = players[newp->GetGUID()];
         if(p == m_ownerGUID && newp->GetGUID() == m_ownerGUID && mod)
             return;
+
         if(!IsOn(newp->GetGUID()))
         {
             WorldPacket data;
@@ -385,6 +430,7 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
             SendToOne(&data, p);
             return;
         }
+
         // allow make moderator from another team only if both is GMs
         // at this moment this only way to show channel post for GM from another team
         if( (plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) &&
@@ -395,6 +441,7 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
             SendToOne(&data, p);
             return;
         }
+
         if(m_ownerGUID == newp->GetGUID() && m_ownerGUID != p)
         {
             WorldPacket data;
@@ -402,18 +449,22 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
             SendToOne(&data, p);
             return;
         }
+
         if(mod)
             SetModerator(newp->GetGUID(), set);
         else
             SetMute(newp->GetGUID(), set);
     }
 }
+
 void Channel::SetOwner(uint64 p, const char *newname)
 {
     Player *plr = objmgr.GetPlayer(p);
     if (!plr)
         return;
+
     uint32 sec = plr->GetSession()->GetSecurity();
+
     if(!IsOn(p))
     {
         WorldPacket data;
@@ -421,6 +472,7 @@ void Channel::SetOwner(uint64 p, const char *newname)
         SendToOne(&data, p);
         return;
     }
+
     if(sec < SEC_GAMEMASTER && p != m_ownerGUID)
     {
         WorldPacket data;
@@ -428,6 +480,7 @@ void Channel::SetOwner(uint64 p, const char *newname)
         SendToOne(&data, p);
         return;
     }
+
     Player *newp = objmgr.GetPlayer(newname);
     if(newp == NULL || !IsOn(newp->GetGUID()))
     {
@@ -436,6 +489,7 @@ void Channel::SetOwner(uint64 p, const char *newname)
         SendToOne(&data, p);
         return;
     }
+
     if(newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
     {
         WorldPacket data;
@@ -443,9 +497,11 @@ void Channel::SetOwner(uint64 p, const char *newname)
         SendToOne(&data, p);
         return;
     }
+
     players[newp->GetGUID()].SetModerator(true);
     SetOwner(newp->GetGUID());
 }
+
 void Channel::SendWhoOwner(uint64 p)
 {
     if(!IsOn(p))
@@ -461,9 +517,11 @@ void Channel::SendWhoOwner(uint64 p)
         SendToOne(&data, p);
     }
 }
+
 void Channel::List(Player* player)
 {
     uint64 p = player->GetGUID();
+
     if(!IsOn(p))
     {
         WorldPacket data;
@@ -476,13 +534,17 @@ void Channel::List(Player* player)
         data << uint8(1);                                   // channel type?
         data << GetName();                                  // channel name
         data << uint8(GetFlags());                          // channel flags?
+
         size_t pos = data.wpos();
         data << uint32(0);                                  // size of list, placeholder
+
         uint32 gmLevelInWhoList = sWorld.getConfig(CONFIG_GM_LEVEL_IN_WHO_LIST);
+
         uint32 count  = 0;
         for(PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
         {
             Player *plr = objmgr.GetPlayer(i->first);
+
             // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
             // MODERATOR, GAME MASTER, ADMINISTRATOR can see all
             if (plr && (player->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) &&
@@ -493,16 +555,20 @@ void Channel::List(Player* player)
                 ++count;
             }
         }
+
         data.put(pos,count);
+
         SendToOne(&data, p);
     }
 }
+
 void Channel::Announce(uint64 p)
 {
     uint32 sec = 0;
     Player *plr = objmgr.GetPlayer(p);
     if(plr)
         sec = plr->GetSession()->GetSecurity();
+
     if(!IsOn(p))
     {
         WorldPacket data;
@@ -518,6 +584,7 @@ void Channel::Announce(uint64 p)
     else
     {
         m_announce = !m_announce;
+
         WorldPacket data;
         if(m_announce)
             MakeAnnouncementsOn(&data, p);
@@ -531,16 +598,19 @@ void Channel::Announce(uint64 p)
             if(CharacterDatabase.PExecute( ss.str( ).c_str( ) ))
             {
                 sLog.outDebug("Channel(%s) announce saved", m_name.c_str());
-            }
+            }    
         }
+
     }
 }
+
 void Channel::Moderate(uint64 p)
 {
     uint32 sec = 0;
     Player *plr = objmgr.GetPlayer(p);
     if(plr)
         sec = plr->GetSession()->GetSecurity();
+
     if(!IsOn(p))
     {
         WorldPacket data;
@@ -556,6 +626,7 @@ void Channel::Moderate(uint64 p)
     else
     {
         m_moderate = !m_moderate;
+
         WorldPacket data;
         if(m_moderate)
             MakeModerationOn(&data, p);
@@ -569,20 +640,23 @@ void Channel::Moderate(uint64 p)
             if(CharacterDatabase.PExecute( ss.str( ).c_str( ) ))
             {
                 sLog.outDebug("Channel(%s) moderate saved", m_name.c_str());
-            }
+            }    
         }
     }
 }
+
 void Channel::Say(uint64 p, const char *what, uint32 lang)
 {
     if(!what)
         return;
     if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
         lang = LANG_UNIVERSAL;
+
     uint32 sec = 0;
     Player *plr = objmgr.GetPlayer(p);
     if(plr)
         sec = plr->GetSession()->GetSecurity();
+
     if(!IsOn(p))
     {
         WorldPacket data;
@@ -604,6 +678,7 @@ void Channel::Say(uint64 p, const char *what, uint32 lang)
     else
     {
         uint32 messageLength = strlen(what) + 1;
+
         WorldPacket data(SMSG_MESSAGECHAT, 1+4+8+4+m_name.size()+1+8+4+messageLength+1);
         data << (uint8)CHAT_MSG_CHANNEL;
         data << (uint32)lang;
@@ -614,9 +689,11 @@ void Channel::Say(uint64 p, const char *what, uint32 lang)
         data << messageLength;
         data << what;
         data << uint8(plr ? plr->chatTag() : 0);
+
         SendToAll(&data, !players[p].IsModerator() ? p : false);
     }
 }
+
 void Channel::Invite(uint64 p, const char *newname)
 {
     if(!IsOn(p))
@@ -626,6 +703,7 @@ void Channel::Invite(uint64 p, const char *newname)
         SendToOne(&data, p);
         return;
     }
+
     Player *newp = objmgr.GetPlayer(newname);
     if(!newp)
     {
@@ -634,9 +712,11 @@ void Channel::Invite(uint64 p, const char *newname)
         SendToOne(&data, p);
         return;
     }
+
     Player *plr = objmgr.GetPlayer(p);
     if (!plr)
         return;
+
     if (newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
     {
         WorldPacket data;
@@ -644,6 +724,7 @@ void Channel::Invite(uint64 p, const char *newname)
         SendToOne(&data, p);
         return;
     }
+
     if(IsOn(newp->GetGUID()))
     {
         WorldPacket data;
@@ -651,6 +732,7 @@ void Channel::Invite(uint64 p, const char *newname)
         SendToOne(&data, p);
         return;
     }
+
     WorldPacket data;
     if(!newp->GetSocial()->HasIgnore(GUID_LOPART(p)))
     {
@@ -661,6 +743,7 @@ void Channel::Invite(uint64 p, const char *newname)
     MakePlayerInvited(&data, newp->GetName());
     SendToOne(&data, p);
 }
+
 void Channel::SetOwner(uint64 guid, bool exclaim)
 {
     if(m_ownerGUID)
@@ -670,15 +753,18 @@ void Channel::SetOwner(uint64 guid, bool exclaim)
         if(p_itr != players.end())
             p_itr->second.SetOwner(false);
     }
+
     m_ownerGUID = guid;
     if(m_ownerGUID)
     {
         uint8 oldFlag = GetPlayerFlags(m_ownerGUID);
         players[m_ownerGUID].SetModerator(true);
         players[m_ownerGUID].SetOwner(true);
+
         WorldPacket data;
         MakeModeChange(&data, m_ownerGUID, oldFlag);
         SendToAll(&data);
+
         if(exclaim)
         {
             MakeOwnerChanged(&data, m_ownerGUID);
@@ -691,10 +777,12 @@ void Channel::SetOwner(uint64 guid, bool exclaim)
             if(CharacterDatabase.PExecute( ss.str( ).c_str( ) ))
             {
                 sLog.outDebug("Channel(%s) owner saved", m_name.c_str());
-            }
+            }   
         }*/
+
     }
 }
+
 void Channel::SendToAll(WorldPacket *data, uint64 p)
 {
     for(PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
@@ -707,6 +795,7 @@ void Channel::SendToAll(WorldPacket *data, uint64 p)
         }
     }
 }
+
 void Channel::SendToAllButOne(WorldPacket *data, uint64 who)
 {
     for(PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
@@ -719,18 +808,24 @@ void Channel::SendToAllButOne(WorldPacket *data, uint64 who)
         }
     }
 }
+
 void Channel::SendToOne(WorldPacket *data, uint64 who)
 {
     Player *plr = objmgr.GetPlayer(who);
     if(plr)
         plr->GetSession()->SendPacket(data);
 }
+
 void Channel::Voice(uint64 /*guid1*/, uint64 /*guid2*/)
 {
+
 }
+
 void Channel::DeVoice(uint64 /*guid1*/, uint64 /*guid2*/)
 {
+
 }
+
 // done
 void Channel::MakeNotifyPacket(WorldPacket *data, uint8 notify_type)
 {
@@ -738,18 +833,21 @@ void Channel::MakeNotifyPacket(WorldPacket *data, uint8 notify_type)
     *data << uint8(notify_type);
     *data << m_name;
 }
+
 // done 0x00
 void Channel::MakeJoined(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_JOINED_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x01
 void Channel::MakeLeft(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_LEFT_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x02
 void Channel::MakeYouJoined(WorldPacket *data)
 {
@@ -758,6 +856,7 @@ void Channel::MakeYouJoined(WorldPacket *data)
     *data << uint32(GetChannelId());
     *data << uint32(0);
 }
+
 // done 0x03
 void Channel::MakeYouLeft(WorldPacket *data)
 {
@@ -765,53 +864,64 @@ void Channel::MakeYouLeft(WorldPacket *data)
     *data << uint32(GetChannelId());
     *data << uint8(0);                                      // can be 0x00 and 0x01
 }
+
 // done 0x04
 void Channel::MakeWrongPassword(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_WRONG_PASSWORD_NOTICE);
 }
+
 // done 0x05
 void Channel::MakeNotMember(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE);
 }
+
 // done 0x06
 void Channel::MakeNotModerator(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE);
 }
+
 // done 0x07
 void Channel::MakePasswordChanged(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x08
 void Channel::MakeOwnerChanged(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x09
 void Channel::MakePlayerNotFound(WorldPacket *data, const std::string& name)
 {
     MakeNotifyPacket(data, CHAT_PLAYER_NOT_FOUND_NOTICE);
     *data << name;
 }
+
 // done 0x0A
 void Channel::MakeNotOwner(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_NOT_OWNER_NOTICE);
 }
+
 // done 0x0B
 void Channel::MakeChannelOwner(WorldPacket *data)
 {
     std::string name = "";
+
     if(!objmgr.GetPlayerNameByGUID(m_ownerGUID, name) || name.empty())
         name = "PLAYER_NOT_FOUND";
+
     MakeNotifyPacket(data, CHAT_CHANNEL_OWNER_NOTICE);
     *data << ((IsConstant() || !m_ownerGUID) ? "Nobody" : name);
 }
+
 // done 0x0C
 void Channel::MakeModeChange(WorldPacket *data, uint64 guid, uint8 oldflags)
 {
@@ -820,35 +930,41 @@ void Channel::MakeModeChange(WorldPacket *data, uint64 guid, uint8 oldflags)
     *data << uint8(oldflags);
     *data << uint8(GetPlayerFlags(guid));
 }
+
 // done 0x0D
 void Channel::MakeAnnouncementsOn(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x0E
 void Channel::MakeAnnouncementsOff(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x0F
 void Channel::MakeModerationOn(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x10
 void Channel::MakeModerationOff(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x11
 void Channel::MakeMuted(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_MUTED_NOTICE);
 }
+
 // done 0x12
 void Channel::MakePlayerKicked(WorldPacket *data, uint64 bad, uint64 good)
 {
@@ -856,11 +972,13 @@ void Channel::MakePlayerKicked(WorldPacket *data, uint64 bad, uint64 good)
     *data << uint64(bad);
     *data << uint64(good);
 }
+
 // done 0x13
 void Channel::MakeBanned(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_BANNED_NOTICE);
 }
+
 // done 0x14
 void Channel::MakePlayerBanned(WorldPacket *data, uint64 bad, uint64 good)
 {
@@ -868,6 +986,7 @@ void Channel::MakePlayerBanned(WorldPacket *data, uint64 bad, uint64 good)
     *data << uint64(bad);
     *data << uint64(good);
 }
+
 // done 0x15
 void Channel::MakePlayerUnbanned(WorldPacket *data, uint64 bad, uint64 good)
 {
@@ -875,90 +994,107 @@ void Channel::MakePlayerUnbanned(WorldPacket *data, uint64 bad, uint64 good)
     *data << uint64(bad);
     *data << uint64(good);
 }
+
 // done 0x16
 void Channel::MakePlayerNotBanned(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x17
 void Channel::MakePlayerAlreadyMember(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x18
 void Channel::MakeInvite(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_INVITE_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x19
 void Channel::MakeInviteWrongFaction(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_INVITE_WRONG_FACTION_NOTICE);
 }
+
 // done 0x1A
 void Channel::MakeWrongFaction(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_WRONG_FACTION_NOTICE);
 }
+
 // done 0x1B
 void Channel::MakeInvalidName(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_INVALID_NAME_NOTICE);
 }
+
 // done 0x1C
 void Channel::MakeNotModerated(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_NOT_MODERATED_NOTICE);
 }
+
 // done 0x1D
 void Channel::MakePlayerInvited(WorldPacket *data, const std::string& name)
 {
     MakeNotifyPacket(data, CHAT_PLAYER_INVITED_NOTICE);
     *data << name;
 }
+
 // done 0x1E
 void Channel::MakePlayerInviteBanned(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x1F
 void Channel::MakeThrottled(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_THROTTLED_NOTICE);
 }
+
 // done 0x20
 void Channel::MakeNotInArea(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_NOT_IN_AREA_NOTICE);
 }
+
 // done 0x21
 void Channel::MakeNotInLfg(WorldPacket *data)
 {
     MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE);
 }
+
 // done 0x22
 void Channel::MakeVoiceOn(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE);
     *data << uint64(guid);
 }
+
 // done 0x23
 void Channel::MakeVoiceOff(WorldPacket *data, uint64 guid)
 {
     MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE);
     *data << uint64(guid);
 }
+
 void Channel::JoinNotify(uint64 guid)
 {
     WorldPacket data;
+
     if(IsConstant())
         data.Initialize(SMSG_USERLIST_ADD, 8+1+1+4+GetName().size()+1);
     else
         data.Initialize(SMSG_USERLIST_UPDATE, 8+1+1+4+GetName().size()+1);
+
     data << uint64(guid);
     data << uint8(GetPlayerFlags(guid));
     data << uint8(GetFlags());
@@ -966,6 +1102,7 @@ void Channel::JoinNotify(uint64 guid)
     data << GetName();
     SendToAll(&data);
 }
+
 void Channel::LeaveNotify(uint64 guid)
 {
     WorldPacket data(SMSG_USERLIST_REMOVE, 8+1+4+GetName().size()+1);
diff --git a/src/game/Channel.h b/src/game/Channel.h
index b97acd52360..69a1e2f66f6 100644
--- a/src/game/Channel.h
+++ b/src/game/Channel.h
@@ -17,15 +17,20 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef _CHANNEL_H
 #define _CHANNEL_H
+
 #include 
 #include 
 #include 
+
 #include "Common.h"
+
 #include "Opcodes.h"
 #include "Player.h"
 #include "WorldPacket.h"
+
 enum ChatNotify
 {
     CHAT_JOINED_NOTICE                = 0x00,           //+ "%s joined channel.";
@@ -67,6 +72,7 @@ enum ChatNotify
     CHAT_VOICE_ON_NOTICE              = 0x22,           //+ "[%s] Channel voice enabled by %s.";
     CHAT_VOICE_OFF_NOTICE             = 0x23,           //+ "[%s] Channel voice disabled by %s.";
 };
+
 enum ChannelFlags
 {
     CHANNEL_FLAG_NONE       = 0x00,
@@ -84,6 +90,7 @@ enum ChannelFlags
     // GuildRecruitment         0x38 = 0x20 | 0x10 | 0x08
     // LookingForGroup          0x50 = 0x40 | 0x10
 };
+
 enum ChannelDBCFlags
 {
     CHANNEL_DBC_FLAG_NONE       = 0x00000,
@@ -97,6 +104,7 @@ enum ChannelDBCFlags
     CHANNEL_DBC_FLAG_GUILD_REQ  = 0x20000,              // GuildRecruitment
     CHANNEL_DBC_FLAG_LFG        = 0x40000               // LookingForGroup
 };
+
 enum ChannelMemberFlags
 {
     MEMBER_FLAG_NONE        = 0x00,
@@ -109,12 +117,14 @@ enum ChannelMemberFlags
     // 0x40
     // 0x80
 };
+
 class Channel
 {
     struct PlayerInfo
     {
         uint64 player;
         uint8 flags;
+
         bool HasFlag(uint8 flag) { return flags & flag; }
         void SetFlag(uint8 flag) { if(!HasFlag(flag)) flags |= flag; }
         bool IsOwner() { return flags & MEMBER_FLAG_OWNER; }
@@ -136,6 +146,7 @@ class Channel
             else flags &= ~MEMBER_FLAG_MUTED;
         }
     };
+
     typedef     std::map PlayerList;
     PlayerList  players;
     typedef     std::set BannedList;
@@ -148,6 +159,7 @@ class Channel
     uint32      m_channelId;
     uint64      m_ownerGUID;
     bool        m_IsSaved;
+
     private:
         // initial packet data (notify type and channel name)
         void MakeNotifyPacket(WorldPacket *data, uint8 notify_type);
@@ -188,40 +200,49 @@ class Channel
         void MakeNotInLfg(WorldPacket *data);                                   //? 0x21
         void MakeVoiceOn(WorldPacket *data, uint64 guid);                       //+ 0x22
         void MakeVoiceOff(WorldPacket *data, uint64 guid);                      //+ 0x23
+
         void SendToAll(WorldPacket *data, uint64 p = 0);
         void SendToAllButOne(WorldPacket *data, uint64 who);
         void SendToOne(WorldPacket *data, uint64 who);
+
         bool IsOn(uint64 who) const { return players.find(who) != players.end(); }
         bool IsBanned(uint64 guid) const { return banned.find(guid) != banned.end(); }
+
         uint8 GetPlayerFlags(uint64 p) const
         {
             PlayerList::const_iterator p_itr = players.find(p);
             if(p_itr == players.end())
                 return 0;
+
             return p_itr->second.flags;
         }
+
         void SetModerator(uint64 p, bool set)
         {
             if(players[p].IsModerator() != set)
             {
                 uint8 oldFlag = GetPlayerFlags(p);
                 players[p].SetModerator(set);
+
                 WorldPacket data;
                 MakeModeChange(&data, p, oldFlag);
                 SendToAll(&data);
             }
         }
+
         void SetMute(uint64 p, bool set)
         {
             if(players[p].IsMuted() != set)
             {
                 uint8 oldFlag = GetPlayerFlags(p);
                 players[p].SetMuted(set);
+
                 WorldPacket data;
                 MakeModeChange(&data, p, oldFlag);
                 SendToAll(&data);
             }
         }
+
     public:
         uint32 m_Team;
         Channel(const std::string& name, uint32 channel_id, uint32 Team = 0);
@@ -236,6 +257,7 @@ class Channel
         uint32 GetNumPlayers() const { return players.size(); }
         uint8 GetFlags() const { return m_flags; }
         bool HasFlag(uint8 flag) { return m_flags & flag; }
+
         void Join(uint64 p, const char *pass);
         void Leave(uint64 p, bool send = true);
         void KickOrBan(uint64 good, const char *badname, bool ban);
diff --git a/src/game/ChannelHandler.cpp b/src/game/ChannelHandler.cpp
index d50c579cd9b..abf73e0e274 100644
--- a/src/game/ChannelHandler.cpp
+++ b/src/game/ChannelHandler.cpp
@@ -18,19 +18,26 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+
 #include "Policies/SingletonImp.h"
+
 #include "ObjectMgr.h"                                      // for normalizePlayerName
 #include "ChannelMgr.h"
+
 void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
+
     uint32 channel_id;
     uint8 unknown1, unknown2;
     std::string channelname, pass;
+
     recvPacket >> channel_id >> unknown1 >> unknown2;
     recvPacket >> channelname;
+
     if(channelname.empty())
         return;
+
     recvPacket >> pass;
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
     {
@@ -39,16 +46,20 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
             chn->Join(_player->GetGUID(), pass.c_str());
     }
 }
+
 void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
+
     uint32 unk;
     std::string channelname;
     recvPacket >> unk;                                      // channel id?
     recvPacket >> channelname;
+
     if(channelname.empty())
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
     {
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
@@ -56,40 +67,50 @@ void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
         cMgr->LeftChannel(channelname);
     }
 }
+
 void WorldSession::HandleChannelList(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname;
     recvPacket >> channelname;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->List(_player);
 }
+
 void WorldSession::HandleChannelPassword(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname, pass;
     recvPacket >> channelname;
+
     recvPacket >> pass;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->Password(_player->GetGUID(), pass.c_str());
 }
+
 void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname, newp;
     recvPacket >> channelname;
+
     recvPacket >> newp;
+
     if(!normalizePlayerName(newp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->SetOwner(_player->GetGUID(), newp.c_str());
 }
+
 void WorldSession::HandleChannelOwner(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
@@ -100,110 +121,144 @@ void WorldSession::HandleChannelOwner(WorldPacket& recvPacket)
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->SendWhoOwner(_player->GetGUID());
 }
+
 void WorldSession::HandleChannelModerator(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname, otp;
     recvPacket >> channelname;
+
     recvPacket >> otp;
+
     if(!normalizePlayerName(otp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->SetModerator(_player->GetGUID(), otp.c_str());
 }
+
 void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname, otp;
     recvPacket >> channelname;
+
     recvPacket >> otp;
+
     if(!normalizePlayerName(otp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->UnsetModerator(_player->GetGUID(), otp.c_str());
 }
+
 void WorldSession::HandleChannelMute(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname, otp;
     recvPacket >> channelname;
+
     recvPacket >> otp;
+
     if(!normalizePlayerName(otp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->SetMute(_player->GetGUID(), otp.c_str());
 }
+
 void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
+
     std::string channelname, otp;
     recvPacket >> channelname;
+
     recvPacket >> otp;
+
     if(!normalizePlayerName(otp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->UnsetMute(_player->GetGUID(), otp.c_str());
 }
+
 void WorldSession::HandleChannelInvite(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname, otp;
     recvPacket >> channelname;
+
     recvPacket >> otp;
+
     if(!normalizePlayerName(otp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->Invite(_player->GetGUID(), otp.c_str());
 }
+
 void WorldSession::HandleChannelKick(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname, otp;
     recvPacket >> channelname;
+
     recvPacket >> otp;
     if(!normalizePlayerName(otp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->Kick(_player->GetGUID(), otp.c_str());
 }
+
 void WorldSession::HandleChannelBan(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
     std::string channelname, otp;
     recvPacket >> channelname;
+
     recvPacket >> otp;
+
     if(!normalizePlayerName(otp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->Ban(_player->GetGUID(), otp.c_str());
 }
+
 void WorldSession::HandleChannelUnban(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
     //recvPacket.hexlike();
+
     std::string channelname, otp;
     recvPacket >> channelname;
+
     recvPacket >> otp;
+
     if(!normalizePlayerName(otp))
         return;
+
     if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->UnBan(_player->GetGUID(), otp.c_str());
 }
+
 void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
@@ -214,6 +269,7 @@ void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket)
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->Announce(_player->GetGUID());
 }
+
 void WorldSession::HandleChannelModerate(WorldPacket& recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
@@ -224,6 +280,7 @@ void WorldSession::HandleChannelModerate(WorldPacket& recvPacket)
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->Moderate(_player->GetGUID());
 }
+
 void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
@@ -234,6 +291,7 @@ void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket)
         if(Channel *chn = cMgr->GetChannel(channelname, _player))
             chn->List(_player);
 }
+
 void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
@@ -252,6 +310,7 @@ void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket)
         }
     }
 }
+
 void WorldSession::HandleSetChannelWatch(WorldPacket &recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
diff --git a/src/game/ChannelMgr.cpp b/src/game/ChannelMgr.cpp
index 8994d84b23f..09d172155cc 100644
--- a/src/game/ChannelMgr.cpp
+++ b/src/game/ChannelMgr.cpp
@@ -15,27 +15,35 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "ChannelMgr.h"
 #include "Policies/SingletonImp.h"
 #include "World.h"
+
 INSTANTIATE_SINGLETON_1( AllianceChannelMgr );
 INSTANTIATE_SINGLETON_1( HordeChannelMgr );
+
 ChannelMgr* channelMgr(uint32 team)
 {
     if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
         return &MaNGOS::Singleton::Instance();        // cross-faction
+
     if(team == ALLIANCE)
         return &MaNGOS::Singleton::Instance();
     if(team == HORDE)
         return &MaNGOS::Singleton::Instance();
+
     return NULL;
 }
+
 ChannelMgr::~ChannelMgr()
 {
     for(ChannelMap::iterator itr = channels.begin();itr!=channels.end(); ++itr)
         delete itr->second;
+
     channels.clear();
 }
+
 Channel *ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id)
 {
     if (channels.find(name) == channels.end())
@@ -43,11 +51,14 @@ Channel *ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id)
         Channel *nchan = new Channel(name,channel_id, team);
         channels[name] = nchan;
     }
+
     return channels[name];
 }
+
 Channel *ChannelMgr::GetChannel(std::string name, Player *p, bool pkt)
 {
     ChannelMap::const_iterator i = channels.find(name);
+
     if(i == channels.end())
     {
         if(pkt)
@@ -56,23 +67,29 @@ Channel *ChannelMgr::GetChannel(std::string name, Player *p, bool pkt)
             MakeNotOnPacket(&data,name);
             p->GetSession()->SendPacket(&data);
         }
+
         return NULL;
     }
     else
         return i->second;
 }
+
 void ChannelMgr::LeftChannel(std::string name)
 {
     ChannelMap::const_iterator i = channels.find(name);
+
     if(i == channels.end())
         return;
+
     Channel* channel = i->second;
+
     if(channel->GetNumPlayers() == 0 && !channel->IsConstant())
     {
         channels.erase(name);
         delete channel;
     }
 }
+
 void ChannelMgr::MakeNotOnPacket(WorldPacket *data, std::string name)
 {
     data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10));  // we guess size
diff --git a/src/game/ChannelMgr.h b/src/game/ChannelMgr.h
index 5bf07d609b9..f65a8520648 100644
--- a/src/game/ChannelMgr.h
+++ b/src/game/ChannelMgr.h
@@ -19,14 +19,19 @@
  */
 #ifndef MANGOSSERVER_CHANNELMGR_H
 #define MANGOSSERVER_CHANNELMGR_H
+
 #include "Common.h"
 #include "Channel.h"
 #include "Policies/Singleton.h"
+
 #include 
 #include 
+
 #include "Policies/Singleton.h"
+
 #include "Channel.h"
 #include "World.h"
+
 class ChannelMgr
 {
     public:
@@ -34,6 +39,7 @@ class ChannelMgr
         typedef std::map ChannelMap;
         ChannelMgr() {team = 0;}
         ~ChannelMgr();
+
         Channel *GetJoinChannel(std::string name, uint32 channel_id);
         Channel *GetChannel(std::string name, Player *p, bool pkt = true);
         void LeftChannel(std::string name);
@@ -41,8 +47,11 @@ class ChannelMgr
         ChannelMap channels;
         void MakeNotOnPacket(WorldPacket *data, std::string name);
 };
+
 class AllianceChannelMgr : public ChannelMgr {};
 class HordeChannelMgr    : public ChannelMgr {};
+
 ChannelMgr* channelMgr(uint32 team);
+
 #endif
 
diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index e348d3b6f55..e1e6eae86a3 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -17,6 +17,7 @@
  * 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 "ObjectAccessor.h"
 #include "ObjectMgr.h"
@@ -27,6 +28,7 @@
 #include "Auth/md5.h"
 #include "Database/DatabaseEnv.h"
 #include "Database/DatabaseImpl.h"
+
 #include "ArenaTeam.h"
 #include "Chat.h"
 #include "Group.h"
@@ -41,6 +43,7 @@
 #include "UpdateMask.h"
 #include "Util.h"
 #include "ScriptCalls.h"
+
 class LoginQueryHolder : public SqlQueryHolder
 {
     private:
@@ -53,10 +56,13 @@ class LoginQueryHolder : public SqlQueryHolder
         uint32 GetAccountId() const { return m_accountId; }
         bool Initialize();
 };
+
 bool LoginQueryHolder::Initialize()
 {
     SetSize(MAX_PLAYER_LOGIN_QUERY);
+
     bool res = true;
+
     // NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure.
     // !!! NOTE: including unused `zone`,`online`
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM,            "SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, 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, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points, instance_id, speccount, activespec FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
@@ -86,8 +92,10 @@ bool LoginQueryHolder::Initialize()
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGLYPHS,          "SELECT spec, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 FROM character_glyphs WHERE guid='%u'", GUID_LOPART(m_guid));
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADTALENTS,         "SELECT spell, spec FROM character_talent WHERE guid='%u'", GUID_LOPART(m_guid));
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA,     "SELECT type, time, data FROM character_account_data WHERE guid='%u'", GUID_LOPART(m_guid));
+
     return res;
 }
+
 // don't call WorldSession directly
 // it may get deleted before the query callbacks get executed
 // instead pass an account id to this handler
@@ -116,11 +124,15 @@ class CharacterHandler
             session->HandlePlayerLogin((LoginQueryHolder*)holder);
         }
 } chrHandler;
+
 void WorldSession::HandleCharEnum(QueryResult * result)
 {
     WorldPacket data(SMSG_CHAR_ENUM, 100);                  // we guess size
+
     uint8 num = 0;
+
     data << num;
+
     if( result )
     {
         do
@@ -131,11 +143,15 @@ void WorldSession::HandleCharEnum(QueryResult * result)
                 ++num;
         }
         while( result->NextRow() );
+
         delete result;
     }
+
     data.put(0, num);
+
     SendPacket( &data );
 }
+
 void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
 {
     /// get all the data necessary for loading all characters (along with their pets) on the account
@@ -165,25 +181,32 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
         "WHERE characters.account = '%u' ORDER BY characters.guid",
         PET_SAVE_AS_CURRENT,GetAccountId());
 }
+
 void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
 {
     std::string name;
     uint8 race_,class_;
+
     recv_data >> name;
+
     recv_data >> race_;
     recv_data >> class_;
+
     WorldPacket data(SMSG_CHAR_CREATE, 1);                  // returned with diff.values in all cases
+
     if(GetSecurity() == SEC_PLAYER)
     {
         if(uint32 mask = sWorld.getConfig(CONFIG_CHARACTERS_CREATING_DISABLED))
         {
             bool disabled = false;
+
             uint32 team = Player::TeamForRace(race_);
             switch(team)
             {
                 case ALLIANCE: disabled = mask & (1<<0); break;
                 case HORDE:    disabled = mask & (1<<1); break;
             }
+
             if(disabled)
             {
                 data << (uint8)CHAR_CREATE_DISABLED;
@@ -192,8 +215,10 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
             }
         }
     }
+
     ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_);
     ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_);
+
     if( !classEntry || !raceEntry )
     {
         data << (uint8)CHAR_CREATE_FAILED;
@@ -201,6 +226,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         sLog.outError("Class: %u or Race %u not found in DBC (Wrong DBC files?) or Cheater?", class_, race_);
         return;
     }
+
     // prevent character creating Expansion race without Expansion account
     if (raceEntry->addon > Expansion())
     {
@@ -209,6 +235,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         SendPacket( &data );
         return;
     }
+
     // prevent character creating Expansion class without Expansion account
     if (classEntry->addon > Expansion())
     {
@@ -217,6 +244,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         SendPacket( &data );
         return;
     }
+
     // prevent character creating with invalid name
     if (!normalizePlayerName(name))
     {
@@ -225,6 +253,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         sLog.outError("Account:[%d] but tried to Create character with empty [name] ",GetAccountId());
         return;
     }
+
     // check name limitations
     uint8 res = ObjectMgr::CheckPlayerName(name,true);
     if (res != CHAR_NAME_SUCCESS)
@@ -233,24 +262,28 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         SendPacket( &data );
         return;
     }
+
     if (GetSecurity() == SEC_PLAYER && objmgr.IsReservedName(name))
     {
         data << (uint8)CHAR_NAME_RESERVED;
         SendPacket( &data );
         return;
     }
+
     if (objmgr.GetPlayerGUIDByName(name))
     {
         data << (uint8)CHAR_CREATE_NAME_IN_USE;
         SendPacket( &data );
         return;
     }
+
     QueryResult *resultacct = loginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%d'", GetAccountId());
     if (resultacct)
     {
         Field *fields=resultacct->Fetch();
         uint32 acctcharcount = fields[0].GetUInt32();
         delete resultacct;
+
         if (acctcharcount >= sWorld.getConfig(CONFIG_CHARACTERS_PER_ACCOUNT))
         {
             data << (uint8)CHAR_CREATE_ACCOUNT_LIMIT;
@@ -258,6 +291,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
             return;
         }
     }
+
     QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%d'", GetAccountId());
     uint8 charcount = 0;
     if ( result )
@@ -265,6 +299,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         Field *fields=result->Fetch();
         charcount = fields[0].GetUInt8();
         delete result;
+
         if (charcount >= sWorld.getConfig(CONFIG_CHARACTERS_PER_REALM))
         {
             data << (uint8)CHAR_CREATE_SERVER_LIMIT;
@@ -272,6 +307,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
             return;
         }
     }
+
     // speedup check for heroic class disabled case
     uint32 heroic_free_slots = sWorld.getConfig(CONFIG_HEROIC_CHARACTERS_PER_REALM);
     if(heroic_free_slots==0 && GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
@@ -280,6 +316,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         SendPacket( &data );
         return;
     }
+
     // speedup check for heroic class disabled case
     uint32 req_level_for_heroic = sWorld.getConfig(CONFIG_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING);
     if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && req_level_for_heroic > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
@@ -288,11 +325,15 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         SendPacket( &data );
         return;
     }
+
     bool AllowTwoSideAccounts = !sWorld.IsPvPRealm() || sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ACCOUNTS) || GetSecurity() > SEC_PLAYER;
     uint32 skipCinematics = sWorld.getConfig(CONFIG_SKIP_CINEMATICS);
+
     bool have_same_race = false;
+
     // if 0 then allowed creating without any characters
     bool have_req_level_for_heroic = (req_level_for_heroic==0);
+
     if(!AllowTwoSideAccounts || skipCinematics == 1 || class_ == CLASS_DEATH_KNIGHT)
     {
         QueryResult *result2 = CharacterDatabase.PQuery("SELECT level,race,class FROM characters WHERE account = '%u' %s",
@@ -300,8 +341,10 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
         if(result2)
         {
             uint32 team_= Player::TeamForRace(race_);
+
             Field* field = result2->Fetch();
             uint8 acc_race  = field[1].GetUInt32();
+
             if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
             {
                 uint8 acc_class = field[2].GetUInt32();
@@ -309,6 +352,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
                 {
                     if(heroic_free_slots > 0)
                         --heroic_free_slots;
+
                     if(heroic_free_slots==0)
                     {
                         data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
@@ -316,6 +360,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
                         return;
                     }
                 }
+
                 if(!have_req_level_for_heroic)
                 {
                     uint32 acc_level = field[0].GetUInt32();
@@ -323,6 +368,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
                         have_req_level_for_heroic = true;
                 }
             }
+
             // need to check team only for first character
             // TODO: what to if account already has characters of both races?
             if (!AllowTwoSideAccounts)
@@ -330,6 +376,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
                 uint32 acc_team=0;
                 if(acc_race > 0)
                     acc_team = Player::TeamForRace(acc_race);
+
                 if(acc_team != team_)
                 {
                     data << (uint8)CHAR_CREATE_PVP_TEAMS_VIOLATION;
@@ -338,16 +385,20 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
                     return;
                 }
             }
+
             // search same race for cinematic or same class if need
             // TODO: check if cinematic already shown? (already logged in?; cinematic field)
             while ((skipCinematics == 1 && !have_same_race) || class_ == CLASS_DEATH_KNIGHT)
             {
                 if(!result2->NextRow())
                     break;
+
                 field = result2->Fetch();
                 acc_race = field[1].GetUInt32();
+
                 if(!have_same_race)
                     have_same_race = race_ == acc_race;
+
                 if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
                 {
                     uint8 acc_class = field[2].GetUInt32();
@@ -355,6 +406,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
                     {
                         if(heroic_free_slots > 0)
                             --heroic_free_slots;
+
                         if(heroic_free_slots==0)
                         {
                             data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
@@ -362,6 +414,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
                             return;
                         }
                     }
+
                     if(!have_req_level_for_heroic)
                     {
                         uint32 acc_level = field[0].GetUInt32();
@@ -373,12 +426,14 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
             delete result2;
         }
     }
+
     if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && !have_req_level_for_heroic)
     {
         data << (uint8)CHAR_CREATE_LEVEL_REQUIREMENT;
         SendPacket( &data );
         return;
     }
+
     // extract other data required for player creating
     uint8 gender, skin, face, hairStyle, hairColor, facialHair, outfitId;
     recv_data >> gender;
@@ -388,44 +443,58 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
     recv_data >> hairColor;
     recv_data >> facialHair;
     recv_data >> outfitId;
+    
     if(recv_data.rpos() < recv_data.wpos())
     {
         uint8 unk;
         recv_data >> unk;
         sLog.outDebug("Character creation %s (account %u) has unhandled tail data: [%u]", name.c_str(), GetAccountId(), unk);
     }
+
     Player * pNewChar = new Player(this);
     if(!pNewChar->Create( objmgr.GenerateLowGuid(HIGHGUID_PLAYER), name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId ))
     {
         // Player not create (race/class problem?)
         delete pNewChar;
+
         data << (uint8)CHAR_CREATE_ERROR;
         SendPacket( &data );
+
         return;
     }
+
     if ((have_same_race && skipCinematics == 1) || skipCinematics == 2)
         pNewChar->setCinematic(1);                          // not show intro
+
     // Player created, save it now
     pNewChar->SaveToDB();
     charcount+=1;
+
     loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", GetAccountId(), realmID);
     loginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)",  charcount, GetAccountId(), realmID);
+
     delete pNewChar;                                        // created only to call SaveToDB()
+
     data << (uint8)CHAR_CREATE_SUCCESS;
     SendPacket( &data );
+
     std::string IP_str = GetRemoteAddress();
     sLog.outDetail("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());
 }
+
 void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
 {
     uint64 guid;
     recv_data >> guid;
+
     // can't delete loaded character
     if(objmgr.GetPlayer(guid))
         return;
+
     uint32 accountId = 0;
     std::string name;
+
     // is guild leader
     if(objmgr.GetGuildByLeader(guid))
     {
@@ -434,6 +503,7 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
         SendPacket( &data );
         return;
     }
+
     // is arena team captain
     if(objmgr.GetArenaTeamByCaptain(guid))
     {
@@ -442,6 +512,7 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
         SendPacket( &data );
         return;
     }
+
     QueryResult *result = CharacterDatabase.PQuery("SELECT account,name FROM characters WHERE guid='%u'", GUID_LOPART(guid));
     if(result)
     {
@@ -450,22 +521,28 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
         name = fields[1].GetCppString();
         delete result;
     }
+
     // prevent deleting other players' characters using cheating tools
     if(accountId != GetAccountId())
         return;
+
     std::string IP_str = GetRemoteAddress();
     sLog.outDetail("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));
+
     if(sLog.IsOutCharDump())                                // optimize GetPlayerDump call
     {
         std::string dump = PlayerDumpWriter().GetDump(GUID_LOPART(guid));
         sLog.outCharDump(dump.c_str(),GetAccountId(),GUID_LOPART(guid),name.c_str());
     }
+
     Player::DeleteFromDB(guid, GetAccountId());
+
     WorldPacket data(SMSG_CHAR_DELETE, 1);
     data << (uint8)CHAR_DELETE_SUCCESS;
     SendPacket( &data );
 }
+
 void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
 {
     if(PlayerLoading() || GetPlayer() != NULL)
@@ -473,10 +550,14 @@ void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
         sLog.outError("Player tryes to login again, AccountId = %d",GetAccountId());
         return;
     }
+
     m_playerLoading = true;
     uint64 playerGuid = 0;
+
     DEBUG_LOG( "WORLD: Recvd Player Logon Message" );
+
     recv_data >> playerGuid;
+
     LoginQueryHolder *holder = new LoginQueryHolder(GetAccountId(), playerGuid);
     if(!holder->Initialize())
     {
@@ -484,14 +565,18 @@ void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
         m_playerLoading = false;
         return;
     }
+
     CharacterDatabase.DelayQueryHolder(&chrHandler, &CharacterHandler::HandlePlayerLoginCallback, holder);
 }
+
 void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
 {
     uint64 playerGuid = holder->GetGuid();
+
     Player* pCurrChar = new Player(this);
      // for send server info and strings (config)
     ChatHandler chH = ChatHandler(pCurrChar);
+
     // "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
     if(!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
     {
@@ -501,9 +586,13 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
         m_playerLoading = false;
         return;
     }
+
     pCurrChar->GetMotionMaster()->Initialize();
+
     SetPlayer(pCurrChar);
+
     pCurrChar->SendDungeonDifficulty(false);
+
     WorldPacket data( SMSG_LOGIN_VERIFY_WORLD, 20 );
     data << pCurrChar->GetMapId();
     data << pCurrChar->GetPositionX();
@@ -511,20 +600,25 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
     data << pCurrChar->GetPositionZ();
     data << pCurrChar->GetOrientation();
     SendPacket(&data);
+
     // load player specific part before send times
     LoadAccountData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA),PER_CHARACTER_CACHE_MASK);
     SendAccountDataTimes();
+
     data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2);         // added in 2.2.0
     data << uint8(2);                                       // unknown value
     data << uint8(0);                                       // enable(1)/disable(0) voice chat interface in client
     SendPacket(&data);
+
     // Send MOTD
     {
         data.Initialize(SMSG_MOTD, 50);                     // new in 2.0.1
         data << (uint32)0;
+
         uint32 linecount=0;
         std::string str_motd = sWorld.GetMotd();
         std::string::size_type pos, nextpos;
+
         pos = 0;
         while ( (nextpos= str_motd.find('@',pos)) != std::string::npos )
         {
@@ -535,25 +629,33 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
             }
             pos = nextpos+1;
         }
+
         if (posGetGUIDLow());
     QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
+
     if(resultGuild)
     {
         Field *fields = resultGuild->Fetch();
@@ -566,6 +668,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
         pCurrChar->SetInGuild(0);
         pCurrChar->SetRank(0);
     }
+
     if(pCurrChar->GetGuildId() != 0)
     {
         Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
@@ -577,6 +680,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
             data << guild->GetMOTD();
             SendPacket(&data);
             DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
+
             data.Initialize(SMSG_GUILD_EVENT, (5+10));      // we guess size
             data<<(uint8)GE_SIGNED_ON;
             data<<(uint8)1;
@@ -584,6 +688,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
             data<GetGUID();
             guild->BroadcastPacket(&data);
             DEBUG_LOG( "WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)" );
+
             // Increment online members of the guild
             guild->IncOnlineMemberCount();
         }
@@ -594,24 +699,30 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
             pCurrChar->SetInGuild(0);
         }
     }
+
     if(!pCurrChar->isAlive())
         pCurrChar->SendCorpseReclaimDelay(true);
+
     pCurrChar->SendInitialPacketsBeforeAddToMap();
+
     //Show cinematic at the first time that player login
     if( !pCurrChar->getCinematic() )
     {
         pCurrChar->setCinematic(1);
+
         if(ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass()))
         {
             if (cEntry->CinematicSequence)
                 pCurrChar->SendCinematicStart(cEntry->CinematicSequence);
             else if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace()))
                 pCurrChar->SendCinematicStart(rEntry->CinematicSequence);
+
             // send new char string if not empty
             if (!sWorld.GetNewCharString().empty())
                 chH.PSendSysMessage(sWorld.GetNewCharString().c_str());
         }
     }
+
     if (!pCurrChar->GetMap()->Add(pCurrChar))
     {
         AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId());
@@ -620,22 +731,29 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
         else
             pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation());
     }
+
     ObjectAccessor::Instance().AddObject(pCurrChar);
     //sLog.outDebug("Player %s added to Map.",pCurrChar->GetName());
+
     pCurrChar->SendInitialPacketsAfterAddToMap();
+
     CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow());
     loginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = '%u'", GetAccountId());
     pCurrChar->SetInGameTime( getMSTime() );
+
     // announce group about member online (must be after add to player list to receive announce to self)
     if(Group *group = pCurrChar->GetGroup())
     {
         //pCurrChar->groupInfo.group->SendInit(this); // useless
         group->SendUpdate();
     }
+
     // friend status
     sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true);
+
     // Place character in world (and load zone) before some object loading
     pCurrChar->LoadCorpse();
+
     // setting Ghost+speed if dead
     if (pCurrChar->m_deathState != ALIVE)
     {
@@ -643,57 +761,78 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
         if(pCurrChar->getRace() == RACE_NIGHTELF)
             pCurrChar->CastSpell(pCurrChar, SPELL_ID_NE_GHOST, true, 0);// 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)
         pCurrChar->CastSpell(pCurrChar, SPELL_ID_GHOST, true, 0);     // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?)
+
         pCurrChar->SetMovement(MOVE_WATER_WALK);
     }
+
     pCurrChar->ContinueTaxiFlight();
+
     // reset for all pets before pet loading
     if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
         Pet::resetTalentsForAllPetsOf(pCurrChar);
+
     // Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned)
     pCurrChar->LoadPet();
+
     // Set FFA PvP for non GM in non-rest mode
     if(sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING) )
         pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
+
     if(pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
         pCurrChar->SetContestedPvP();
+
     // Apply at_login requests
     if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
     {
         pCurrChar->resetSpells();
         SendNotification(LANG_RESET_SPELLS);
     }
+
     if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
     {
         pCurrChar->resetTalents(true);
         pCurrChar->SendTalentsInfoData(false);              // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state
         SendNotification(LANG_RESET_TALENTS);
     }
+
     // show time before shutdown if shutdown planned.
     if(sWorld.IsShutdowning())
         sWorld.ShutdownMsg(true,pCurrChar);
+
     if(sWorld.getConfig(CONFIG_ALL_TAXI_PATHS))
         pCurrChar->SetTaxiCheater(true);
+
     if(pCurrChar->isGameMaster())
         SendNotification(LANG_GM_ON);
+
     std::string IP_str = GetRemoteAddress();
     sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid:%u)",
         GetAccountId(),IP_str.c_str(),pCurrChar->GetName() ,pCurrChar->GetGUIDLow());
+
     if(!pCurrChar->IsStandState() && !pCurrChar->hasUnitState(UNIT_STAT_STUNNED))
         pCurrChar->SetStandState(UNIT_STAND_STATE_STAND);
+
     m_playerLoading = false;
+
     //Hook for OnLogin Event
     Script->OnLogin(pCurrChar);
+
     delete holder;
 }
+
 void WorldSession::HandleSetFactionAtWar( WorldPacket & recv_data )
 {
     DEBUG_LOG( "WORLD: Received CMSG_SET_FACTION_ATWAR" );
+
     uint32 repListID;
     uint8  flag;
+
     recv_data >> repListID;
     recv_data >> flag;
+
     GetPlayer()->GetReputationMgr().SetAtWar(repListID,flag);
 }
+
 //I think this function is never used :/ I dunno, but i guess this opcode not exists
 void WorldSession::HandleSetFactionCheat( WorldPacket & /*recv_data*/ )
 {
@@ -701,9 +840,12 @@ void WorldSession::HandleSetFactionCheat( WorldPacket & /*recv_data*/ )
     /*
         uint32 FactionID;
         uint32 Standing;
+
         recv_data >> FactionID;
         recv_data >> Standing;
+
         std::list::iterator itr;
+
         for(itr = GetPlayer()->factions.begin(); itr != GetPlayer()->factions.end(); ++itr)
         {
             if(itr->ReputationListID == FactionID)
@@ -716,15 +858,19 @@ void WorldSession::HandleSetFactionCheat( WorldPacket & /*recv_data*/ )
     */
     GetPlayer()->GetReputationMgr().SendStates();
 }
+
 void WorldSession::HandleMeetingStoneInfo( WorldPacket & /*recv_data*/ )
 {
     DEBUG_LOG( "WORLD: Received CMSG_MEETING_STONE_INFO" );
+
     SendLfgUpdate(0, 0, 0);
 }
+
 void WorldSession::HandleTutorialFlag( WorldPacket & recv_data )
 {
     uint32 iFlag;
     recv_data >> iFlag;
+
     uint32 wInt = (iFlag / 32);
     if (wInt >= 8)
     {
@@ -732,21 +878,26 @@ void WorldSession::HandleTutorialFlag( WorldPacket & recv_data )
         return;
     }
     uint32 rInt = (iFlag % 32);
+
     uint32 tutflag = GetTutorialInt( wInt );
     tutflag |= (1 << rInt);
     SetTutorialInt( wInt, tutflag );
+
     //sLog.outDebug("Received Tutorial Flag Set {%u}.", iFlag);
 }
+
 void WorldSession::HandleTutorialClear( WorldPacket & /*recv_data*/ )
 {
     for (int i = 0; i < 8; ++i)
         SetTutorialInt( i, 0xFFFFFFFF );
 }
+
 void WorldSession::HandleTutorialReset( WorldPacket & /*recv_data*/ )
 {
     for (int i = 0; i < 8; ++i)
         SetTutorialInt( i, 0x00000000 );
 }
+
 void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data)
 {
     DEBUG_LOG("WORLD: Received CMSG_SET_WATCHED_FACTION");
@@ -754,30 +905,37 @@ void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data)
     recv_data >> fact;
     GetPlayer()->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fact);
 }
+
 void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data)
 {
     DEBUG_LOG("WORLD: Received CMSG_SET_FACTION_INACTIVE");
     uint32 replistid;
     uint8 inactive;
     recv_data >> replistid >> inactive;
+
     _player->GetReputationMgr().SetInactive(replistid, inactive);
 }
+
 void WorldSession::HandleShowingHelmOpcode( WorldPacket & /*recv_data*/ )
 {
     DEBUG_LOG("CMSG_SHOWING_HELM for %s", _player->GetName());
     _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);
 }
+
 void WorldSession::HandleShowingCloakOpcode( WorldPacket & /*recv_data*/ )
 {
     DEBUG_LOG("CMSG_SHOWING_CLOAK for %s", _player->GetName());
     _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK);
 }
+
 void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
 {
     uint64 guid;
     std::string newname;
+
     recv_data >> guid;
     recv_data >> newname;
+
     // prevent character rename to invalid name
     if (!normalizePlayerName(newname))
     {
@@ -786,6 +944,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
         SendPacket( &data );
         return;
     }
+
     uint8 res = ObjectMgr::CheckPlayerName(newname,true);
     if (res != CHAR_NAME_SUCCESS)
     {
@@ -794,6 +953,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
         SendPacket( &data );
         return;
     }
+
     // check name limitations
     if (GetSecurity() == SEC_PLAYER && objmgr.IsReservedName(newname))
     {
@@ -802,8 +962,10 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
         SendPacket( &data );
         return;
     }
+
     std::string escaped_newname = newname;
     CharacterDatabase.escape_string(escaped_newname);
+
     // make sure that the character belongs to the current account, that rename at login is enabled
     // and that there is no character with the desired new name
     CharacterDatabase.AsyncPQuery(&WorldSession::HandleChangePlayerNameOpcodeCallBack,
@@ -812,6 +974,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
         GUID_LOPART(guid), GetAccountId(), AT_LOGIN_RENAME, AT_LOGIN_RENAME, escaped_newname.c_str()
     );
 }
+
 void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uint32 accountId, std::string newname)
 {
     WorldSession * session = sWorld.FindSession(accountId);
@@ -820,6 +983,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin
         if(result) delete result;
         return;
     }
+
     if (!result)
     {
         WorldPacket data(SMSG_CHAR_RENAME, 1);
@@ -827,23 +991,31 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin
         session->SendPacket( &data );
         return;
     }
+
     uint32 guidLow = result->Fetch()[0].GetUInt32();
     uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
     std::string oldname = result->Fetch()[1].GetCppString();
+
     delete result;
+
     CharacterDatabase.PExecute("UPDATE characters set name = '%s', at_login = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_RENAME), guidLow);
     CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid ='%u'", guidLow);
+
     sLog.outChar("Account: %d (IP: %s) Character:[%s] (guid:%u) Changed name to: %s", session->GetAccountId(), session->GetRemoteAddress().c_str(), oldname.c_str(), guidLow, newname.c_str());
+
     WorldPacket data(SMSG_CHAR_RENAME, 1+8+(newname.size()+1));
     data << uint8(RESPONSE_SUCCESS);
     data << uint64(guid);
     data << newname;
     session->SendPacket(&data);
 }
+
 void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
 {
     uint64 guid;
+
     recv_data >> guid;
+
     // not accept declined names for unsupported languages
     std::string name;
     if(!objmgr.GetPlayerNameByGUID(guid, name))
@@ -854,6 +1026,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
         SendPacket(&data);
         return;
     }
+
     std::wstring wname;
     if(!Utf8toWStr(name, wname))
     {
@@ -863,6 +1036,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
         SendPacket(&data);
         return;
     }
+
     if(!isCyrillicCharacter(wname[0]))                      // name already stored as only single alphabet using
     {
         WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
@@ -871,9 +1045,12 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
         SendPacket(&data);
         return;
     }
+
     std::string name2;
     DeclinedName declinedname;
+
     recv_data >> name2;
+
     if(name2 != name)                                       // character have different name
     {
         WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
@@ -882,6 +1059,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
         SendPacket(&data);
         return;
     }
+
     for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
     {
         recv_data >> declinedname.name[i];
@@ -894,6 +1072,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
             return;
         }
     }
+
     if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname))
     {
         WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
@@ -902,30 +1081,41 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
         SendPacket(&data);
         return;
     }
+
     for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
         CharacterDatabase.escape_string(declinedname.name[i]);
+
     CharacterDatabase.BeginTransaction();
     CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid));
     CharacterDatabase.PExecute("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')",
         GUID_LOPART(guid), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
     CharacterDatabase.CommitTransaction();
+
     WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
     data << uint32(0);                                      // OK
     data << uint64(guid);
     SendPacket(&data);
 }
+
 void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
 {
     sLog.outDebug("CMSG_ALTER_APPEARANCE");
+
     uint32 Hair, Color, FacialHair;
     recv_data >> Hair >> Color >> FacialHair;
+
     BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair);
+
     if(!bs_hair || bs_hair->type != 0 || bs_hair->race != _player->getRace() || bs_hair->gender != _player->getGender())
         return;
+
     BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(FacialHair);
+
     if(!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender())
         return;
+
     uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id);
+
     // 0 - ok
     // 1,3 - not enough money
     // 2 - you have to seat on barber chair
@@ -942,23 +1132,30 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
         data << uint32(0);                                  // ok
         SendPacket(&data);
     }
+
     _player->ModifyMoney(-int32(Cost));                     // it isn't free
     _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, Cost);
+
     _player->SetByteValue(PLAYER_BYTES, 2, uint8(bs_hair->hair_id));
     _player->SetByteValue(PLAYER_BYTES, 3, uint8(Color));
     _player->SetByteValue(PLAYER_BYTES_2, 0, uint8(bs_facialHair->hair_id));
+
     _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, 1);
+
     _player->SetStandState(0);                              // stand up
 }
+
 void WorldSession::HandleRemoveGlyph( WorldPacket & recv_data )
 {
     uint32 slot;
     recv_data >> slot;
+
     if(slot >= MAX_GLYPH_SLOT_INDEX)
     {
         sLog.outDebug("Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot);
         return;
     }
+
     if(uint32 glyph = _player->GetGlyph(slot))
     {
         if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph))
@@ -969,14 +1166,18 @@ void WorldSession::HandleRemoveGlyph( WorldPacket & recv_data )
         }
     }
 }
+
 void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
 {
     uint64 guid;
     std::string newname;
+
     recv_data >> guid;
     recv_data >> newname;
+
     uint8 gender, skin, face, hairStyle, hairColor, facialHair;
     recv_data >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face;
+
     QueryResult *result = CharacterDatabase.PQuery("SELECT at_login FROM characters WHERE guid ='%u'", GUID_LOPART(guid));
     if (!result)
     {
@@ -985,9 +1186,11 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
         SendPacket( &data );
         return;
     }
+
     Field *fields = result->Fetch();
     uint32 at_loginFlags = fields[0].GetUInt32();
     delete result;
+
     if (!(at_loginFlags & AT_LOGIN_CUSTOMIZE))
     {
         WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
@@ -995,6 +1198,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
         SendPacket( &data );
         return;
     }
+
     // prevent character rename to invalid name
     if (!normalizePlayerName(newname))
     {
@@ -1003,6 +1207,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
         SendPacket( &data );
         return;
     }
+
     uint8 res = ObjectMgr::CheckPlayerName(newname,true);
     if (res != CHAR_NAME_SUCCESS)
     {
@@ -1011,6 +1216,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
         SendPacket( &data );
         return;
     }
+
     // check name limitations
     if (GetSecurity() == SEC_PLAYER && objmgr.IsReservedName(newname))
     {
@@ -1019,6 +1225,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
         SendPacket( &data );
         return;
     }
+
     // character with this name already exist
     if (uint64 newguid = objmgr.GetPlayerGUIDByName(newname))
     {
@@ -1030,6 +1237,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
             return;
         }
     }
+
     CharacterDatabase.escape_string(newname);
     if(QueryResult *result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid ='%u'", GUID_LOPART(guid)))
     {
@@ -1040,6 +1248,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
     Player::Customize(guid, gender, skin, face, hairStyle, hairColor, facialHair);
     CharacterDatabase.PExecute("UPDATE characters set name = '%s', at_login = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_CUSTOMIZE), GUID_LOPART(guid));
     CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid ='%u'", GUID_LOPART(guid));
+
     WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1+8+(newname.size()+1)+6);
     data << uint8(RESPONSE_SUCCESS);
     data << uint64(guid);
@@ -1052,66 +1261,90 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
     data << uint8(facialHair);
     SendPacket(&data);
 }
+
 void WorldSession::HandleEquipmentSetSave(WorldPacket &recv_data)
 {
     sLog.outDebug("CMSG_EQUIPMENT_SET_SAVE");
+
     uint64 setGuid;
     if(!recv_data.readPackGUID(setGuid))
         return;
+
     uint32 index;
     recv_data >> index;
     if(index >= MAX_EQUIPMENT_SET_INDEX)                    // client set slots amount
         return;
+
     std::string name;
     recv_data >> name;
+
     std::string iconName;
     recv_data >> iconName;
+
     EquipmentSet eqSet;
+
     eqSet.Guid      = setGuid;
     eqSet.Name      = name;
     eqSet.IconName  = iconName;
     eqSet.state     = EQUIPMENT_SET_NEW;
+
     for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
     {
         uint64 itemGuid;
         if(!recv_data.readPackGUID(itemGuid))
             return;
+
         Item *item = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
+
         if(!item && itemGuid)                               // cheating check 1
             return;
+
         if(item && item->GetGUID() != itemGuid)             // cheating check 2
             return;
+
         eqSet.Items[i] = GUID_LOPART(itemGuid);
     }
+
     _player->SetEquipmentSet(index, eqSet);
 }
+
 void WorldSession::HandleEquipmentSetDelete(WorldPacket &recv_data)
 {
     sLog.outDebug("CMSG_EQUIPMENT_SET_DELETE");
+
     uint64 setGuid;
     if(!recv_data.readPackGUID(setGuid))
         return;
+
     _player->DeleteEquipmentSet(setGuid);
 }
+
 void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data)
 {
     sLog.outDebug("CMSG_EQUIPMENT_SET_USE");
     recv_data.hexlike();
+
     for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
     {
         uint64 itemGuid;
         if(!recv_data.readPackGUID(itemGuid))
             return;
+
         uint8 srcbag, srcslot;
         recv_data >> srcbag >> srcslot;
+
         sLog.outDebug("Item " UI64FMTD ": srcbag %u, srcslot %u", itemGuid, srcbag, srcslot);
+
         Item *item = _player->GetItemByGuid(itemGuid);
+
         uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);
+
         if(!item)
         {
             Item *uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
             if(!uItem)
                 continue;
+
             ItemPosCountVec sDest;
             uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, sDest, uItem, false );
             if(msg == EQUIP_ERR_OK)
@@ -1121,48 +1354,61 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data)
             }
             else
                 _player->SendEquipError(msg, uItem, NULL);
+
             continue;
         }
+
         if(item->GetPos() == dstpos)
             continue;
+
         _player->SwapItem(item->GetPos(), dstpos);
     }
+
     WorldPacket data(SMSG_EQUIPMENT_SET_USE_RESULT, 1);
     data << uint8(0);                                       // 4 - equipment swap failed - inventory is full
     SendPacket(&data);
 }
+
 void WorldSession::HandleOnPVPKill(Player *killed)
 {
     Script->OnPVPKill(GetPlayer(), killed);
 }
+
 bool WorldSession::HandleOnPlayerChat(const char *text)
 {
     return Script->OnPlayerChat(GetPlayer(), text);
 }
+
 uint32 WorldSession::HandleOnGetXP(uint32 amount)
 {
     return Script->OnGetXP(GetPlayer(), amount);
 }
+
 int32 WorldSession::HandleOnGetMoney(int32 amount)
 {
     return Script->OnGetMoney(GetPlayer(), amount);
 }
+
 void WorldSession::HandleOnAreaChange(AreaTableEntry const *pArea)
 {
     Script->OnAreaChange(GetPlayer(), pArea);
 }
+
 bool WorldSession::HandleOnItemClick(Item *pItem)
 {
     return Script->OnItemClick(GetPlayer(), pItem);
 }
+
 bool WorldSession::HandleOnItemOpen(Item *pItem)
 {
     return Script->OnItemOpen(GetPlayer(), pItem);
 }
+
 bool WorldSession::HandleOnGoClick(GameObject *pGameObject)
 {
     return Script->OnGoClick(GetPlayer(), pGameObject);
 }
+
 void WorldSession::HandleOnCreatureKill(Creature *pCreature)
 {
     Script->OnCreatureKill(GetPlayer(), pCreature);
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index bb8d71e4a3c..32233aae5a9 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -17,12 +17,14 @@
  * 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 "ObjectMgr.h"
 #include "World.h"
 #include "WorldPacket.h"
 #include "WorldSession.h"
 #include "Database/DatabaseEnv.h"
+
 #include "AccountMgr.h"
 #include "CellImpl.h"
 #include "Chat.h"
@@ -34,6 +36,7 @@
 #include "UpdateMask.h"
 #include "SpellMgr.h"
 #include "ScriptCalls.h"
+
 // Supported shift-links (client generated and server side)
 // |color|Hachievement:achievement_id:player_guid:0:0:0:0:0:0:0:0|h[name]|h|r
 //                                                                        - client, item icon shift click, not used in server currently
@@ -56,7 +59,9 @@
 // |color|Htaxinode:id|h[name]|h|r
 // |color|Htele:id|h[name]|h|r
 // |color|Htrade:spell_id,cur_value,max_value,unk3int,unk3str|h[name]|h|r - client, spellbook profession icon shift-click
+
 bool ChatHandler::load_command_table = true;
+
 ChatCommand * ChatHandler::getCommandTable()
 {
     static ChatCommand accountSetCommandTable[] =
@@ -66,6 +71,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "password",       SEC_CONSOLE,        true,  &ChatHandler::HandleAccountSetPasswordCommand,  "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand accountCommandTable[] =
     {
         { "addon",          SEC_PLAYER,         false, &ChatHandler::HandleAccountAddonCommand,        "", NULL },
@@ -78,6 +84,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "",               SEC_PLAYER,         false, &ChatHandler::HandleAccountCommand,             "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand banCommandTable[] =
     {
         { "account",        SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleBanAccountCommand,          "", NULL },
@@ -85,6 +92,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "ip",             SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleBanIPCommand,               "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand baninfoCommandTable[] =
     {
         { "account",        SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleBanInfoAccountCommand,      "", NULL },
@@ -92,6 +100,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "ip",             SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleBanInfoIPCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand banlistCommandTable[] =
     {
         { "account",        SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleBanListAccountCommand,      "", NULL },
@@ -99,6 +108,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "ip",             SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleBanListIPCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand castCommandTable[] =
     {
         { "back",           SEC_ADMINISTRATOR,  false, &ChatHandler::HandleCastBackCommand,            "", NULL },
@@ -108,6 +118,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "",               SEC_ADMINISTRATOR,  false, &ChatHandler::HandleCastCommand,                "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand characterCommandTable[] =
     {
         { "customize",      SEC_GAMEMASTER,     true,  &ChatHandler::HandleCharacterCustomizeCommand,  "", NULL },
@@ -117,6 +128,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "reputation",     SEC_GAMEMASTER,     true,  &ChatHandler::HandleCharacterReputationCommand, "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand debugPlayCommandTable[] =
     {
         { "cinematic",      SEC_MODERATOR,      false, &ChatHandler::HandleDebugPlayCinematicCommand,       "", NULL },
@@ -124,6 +136,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "sound",          SEC_MODERATOR,      false, &ChatHandler::HandleDebugPlaySoundCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                                "", NULL }
     };
+
     static ChatCommand debugSendCommandTable[] =
     {
         { "buyerror",       SEC_ADMINISTRATOR,  false, &ChatHandler::HandleDebugSendBuyErrorCommand,        "", NULL },
@@ -140,6 +153,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "spellfail",      SEC_ADMINISTRATOR,  false, &ChatHandler::HandleDebugSendSpellFailCommand,       "", NULL },
         { NULL,             0,                  false, NULL,                                                "", NULL }
     };
+
     static ChatCommand debugCommandTable[] =
     {
         { "setbit",         SEC_ADMINISTRATOR,  false, &ChatHandler::HandleDebugSet32Bit,                   "", NULL },
@@ -165,6 +179,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "itemexpire",     SEC_ADMINISTRATOR,  false, &ChatHandler::HandleDebugItemExpireCommand,          "", NULL },
         { NULL,             0,                  false, NULL,                                                "", NULL }
     };
+
     static ChatCommand eventCommandTable[] =
     {
         { "activelist",     SEC_GAMEMASTER,     true,  &ChatHandler::HandleEventActiveListCommand,     "", NULL },
@@ -173,6 +188,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "",               SEC_GAMEMASTER,     true,  &ChatHandler::HandleEventInfoCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand gmCommandTable[] =
     {
         { "chat",           SEC_MODERATOR,      false, &ChatHandler::HandleGMChatCommand,              "", NULL },
@@ -183,6 +199,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "",               SEC_MODERATOR,      false, &ChatHandler::HandleGMCommand,                  "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand goCommandTable[] =
     {
         { "creature",       SEC_MODERATOR,      false, &ChatHandler::HandleGoCreatureCommand,          "", NULL },
@@ -195,9 +212,12 @@ ChatCommand * ChatHandler::getCommandTable()
         { "xy",             SEC_MODERATOR,      false, &ChatHandler::HandleGoXYCommand,                "", NULL },
         { "xyz",            SEC_MODERATOR,      false, &ChatHandler::HandleGoXYZCommand,               "", NULL },
         { "",               SEC_MODERATOR,      false, &ChatHandler::HandleGoXYZCommand,               "", NULL },
+
         { "ticket",         SEC_MODERATOR,      false, &ChatHandler::HandleGoTicketCommand,            "", NULL },
+
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand gobjectCommandTable[] =
     {
         { "activate",       SEC_GAMEMASTER,     false, &ChatHandler::HandleActivateObjectCommand,      "", NULL },
@@ -212,6 +232,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "turn",           SEC_GAMEMASTER,     false, &ChatHandler::HandleGameObjectTurnCommand,      "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand groupCommandTable[] =
     {
         { "leader",         SEC_ADMINISTRATOR,     false,  &ChatHandler::HandleGroupLeaderCommand,         "", NULL },
@@ -219,6 +240,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "remove",         SEC_ADMINISTRATOR,     false,  &ChatHandler::HandleGroupRemoveCommand,         "", NULL },
         { NULL,             0,                     false, NULL,                                           "", NULL }
     };
+
     static ChatCommand guildCommandTable[] =
     {
         { "create",         SEC_GAMEMASTER,     true,  &ChatHandler::HandleGuildCreateCommand,         "", NULL },
@@ -228,6 +250,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "rank",           SEC_GAMEMASTER,     true,  &ChatHandler::HandleGuildRankCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand honorCommandTable[] =
     {
         { "add",            SEC_GAMEMASTER,     false, &ChatHandler::HandleHonorAddCommand,            "", NULL },
@@ -235,6 +258,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "update",         SEC_GAMEMASTER,     false, &ChatHandler::HandleHonorUpdateCommand,         "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand instanceCommandTable[] =
     {
         { "listbinds",      SEC_ADMINISTRATOR,  false, &ChatHandler::HandleInstanceListBindsCommand,   "", NULL },
@@ -243,6 +267,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "savedata",       SEC_ADMINISTRATOR,  false, &ChatHandler::HandleInstanceSaveDataCommand,    "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand learnCommandTable[] =
     {
         { "all",            SEC_ADMINISTRATOR,  false, &ChatHandler::HandleLearnAllCommand,            "", NULL },
@@ -258,6 +283,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "",               SEC_ADMINISTRATOR,  false, &ChatHandler::HandleLearnCommand,               "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand listCommandTable[] =
     {
         { "creature",       SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleListCreatureCommand,        "", NULL },
@@ -266,6 +292,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "auras",          SEC_ADMINISTRATOR,  false, &ChatHandler::HandleListAurasCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand lookupPlayerCommandTable[] =
     {
         { "ip",             SEC_GAMEMASTER,     true,  &ChatHandler::HandleLookupPlayerIpCommand,       "", NULL },
@@ -273,6 +300,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "email",          SEC_GAMEMASTER,     true,  &ChatHandler::HandleLookupPlayerEmailCommand,    "", NULL },
         { NULL,             0,                  false, NULL,                                            "", NULL }
     };
+
     static ChatCommand lookupCommandTable[] =
     {
         { "area",           SEC_MODERATOR,      true,  &ChatHandler::HandleLookupAreaCommand,          "", NULL },
@@ -291,6 +319,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "map",            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleLookupMapCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand modifyCommandTable[] =
     {
         { "hp",             SEC_MODERATOR,      false, &ChatHandler::HandleModifyHPCommand,            "", NULL },
@@ -321,6 +350,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "gender",         SEC_GAMEMASTER,     false, &ChatHandler::HandleModifyGenderCommand,        "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand npcCommandTable[] =
     {
         { "add",            SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcAddCommand,              "", NULL },
@@ -352,13 +382,16 @@ ChatCommand * ChatHandler::getCommandTable()
         { "setdeathstate",  SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcSetDeathStateCommand,    "", NULL },
         { "addformation",   SEC_MODERATOR,      false, &ChatHandler::HandleNpcAddFormationCommand,     "", NULL },
         { "setlink",        SEC_MODERATOR,      false, &ChatHandler::HandleNpcSetLinkCommand,          "", NULL },
+
         //{ TODO: fix or remove this commands
         { "addweapon",      SEC_ADMINISTRATOR,  false, &ChatHandler::HandleNpcAddWeaponCommand,        "", NULL },
         { "name",           SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcNameCommand,             "", NULL },
         { "subname",        SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcSubNameCommand,          "", NULL },
         //}
+
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand petCommandTable[] =
     {
         { "create",         SEC_GAMEMASTER,     false, &ChatHandler::HandleCreatePetCommand,           "", NULL },
@@ -367,12 +400,14 @@ ChatCommand * ChatHandler::getCommandTable()
         { "tp",             SEC_GAMEMASTER,     false, &ChatHandler::HandlePetTpCommand,               "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand pdumpCommandTable[] =
     {
         { "load",           SEC_ADMINISTRATOR,  true,  &ChatHandler::HandlePDumpLoadCommand,           "", NULL },
         { "write",          SEC_ADMINISTRATOR,  true,  &ChatHandler::HandlePDumpWriteCommand,          "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand questCommandTable[] =
     {
         { "add",            SEC_ADMINISTRATOR,  false, &ChatHandler::HandleQuestAdd,                   "", NULL },
@@ -380,6 +415,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "remove",         SEC_ADMINISTRATOR,  false, &ChatHandler::HandleQuestRemove,                "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand reloadCommandTable[] =
     {
         { "all",            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleReloadAllCommand,           "", NULL },
@@ -393,7 +429,9 @@ ChatCommand * ChatHandler::getCommandTable()
         { "all_quest",      SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleReloadAllQuestCommand,      "", NULL },
         { "all_scripts",    SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleReloadAllScriptsCommand,    "", NULL },
         { "all_spell",      SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleReloadAllSpellCommand,      "", NULL },
+
         { "config",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleReloadConfigCommand,        "", NULL },
+
         { "access_requirement",          SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadAccessRequirementCommand,       "", NULL },
         { "achievement_criteria_data",   SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadAchievementCriteriaDataCommand, "", NULL },
         { "achievement_reward",          SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadAchievementRewardCommand,       "", NULL },
@@ -469,8 +507,10 @@ ChatCommand * ChatHandler::getCommandTable()
         { "auctions",                    SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadAuctionsCommand,                "", NULL },
         { "waypoint_scripts",            SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadWpScriptsCommand,               "", NULL },
         { "gm_tickets",                  SEC_ADMINISTRATOR, true,  &ChatHandler::HandleGMTicketReloadCommand,                "", NULL },
+
         { NULL,                          0,                 false, NULL,                                                     "", NULL }
     };
+
     static ChatCommand resetCommandTable[] =
     {
         { "achievements",   SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleResetAchievementsCommand,   "", NULL },
@@ -482,6 +522,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "all",            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleResetAllCommand,            "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand sendCommandTable[] =
     {
         { "items",          SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleSendItemsCommand,           "", NULL },
@@ -490,30 +531,35 @@ ChatCommand * ChatHandler::getCommandTable()
         { "money",          SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleSendMoneyCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand serverIdleRestartCommandTable[] =
     {
         { "cancel",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
         { ""   ,            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerIdleRestartCommand,   "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand serverIdleShutdownCommandTable[] =
     {
         { "cancel",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
         { ""   ,            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerIdleShutDownCommand,  "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand serverRestartCommandTable[] =
     {
         { "cancel",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
         { ""   ,            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerRestartCommand,       "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand serverShutdownCommandTable[] =
     {
         { "cancel",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
         { ""   ,            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCommand,      "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand serverSetCommandTable[] =
     {
         { "difftime",       SEC_CONSOLE,        true,  &ChatHandler::HandleServerSetDiffTimeCommand,   "", NULL },
@@ -523,6 +569,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "closed",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerSetClosedCommand,     "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand serverCommandTable[] =
     {
         { "corpses",        SEC_GAMEMASTER,     true,  &ChatHandler::HandleServerCorpsesCommand,       "", NULL },
@@ -537,6 +584,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "set",            SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverSetCommandTable },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand teleCommandTable[] =
     {
         { "add",            SEC_ADMINISTRATOR,  false, &ChatHandler::HandleTeleAddCommand,             "", NULL },
@@ -546,6 +594,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "",               SEC_MODERATOR,      false, &ChatHandler::HandleTeleCommand,                "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand unbanCommandTable[] =
     {
         { "account",        SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleUnBanAccountCommand,      "", NULL },
@@ -553,6 +602,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "ip",             SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleUnBanIPCommand,           "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand wpCommandTable[] =
     {
         { "show",           SEC_GAMEMASTER,     false, &ChatHandler::HandleWpShowCommand,              "", NULL },
@@ -563,6 +613,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "unload",         SEC_GAMEMASTER,     false, &ChatHandler::HandleWpUnLoadPathCommand,        "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     static ChatCommand ticketCommandTable[] =
     {
         { "list",           SEC_MODERATOR,      false, &ChatHandler::HandleGMTicketListCommand,             "", NULL },
@@ -577,6 +628,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "comment",        SEC_MODERATOR,      false, &ChatHandler::HandleGMTicketCommentCommand,          "", NULL },
         { NULL,             0,                  false, NULL,                                                "", NULL }
     };
+
     static ChatCommand commandTable[] =
     {
         { "account",        SEC_PLAYER,         true,  NULL,                                           "", accountCommandTable  },
@@ -602,10 +654,12 @@ ChatCommand * ChatHandler::getCommandTable()
         { "reset",          SEC_ADMINISTRATOR,  true,  NULL,                                           "", resetCommandTable    },
         { "instance",       SEC_ADMINISTRATOR,  true,  NULL,                                           "", instanceCommandTable },
         { "server",         SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverCommandTable   },
+
         { "pet",            SEC_GAMEMASTER,     false, NULL,                                           "", petCommandTable },
         { "loadpath",       SEC_ADMINISTRATOR,  false, &ChatHandler::HandleReloadAllPaths,             "", NULL },
         { "ahbotoptions",   SEC_GAMEMASTER,     true,  &ChatHandler::HandleAHBotOptionsCommand,        "", NULL },
         { "ticket",         SEC_MODERATOR,      false,  NULL,                                          "", ticketCommandTable },
+
         { "aura",           SEC_ADMINISTRATOR,  false, &ChatHandler::HandleAuraCommand,                "", NULL },
         { "unaura",         SEC_ADMINISTRATOR,  false, &ChatHandler::HandleUnAuraCommand,              "", NULL },
         { "nameannounce",   SEC_MODERATOR,      false, &ChatHandler::HandleNameAnnounceCommand,        "", NULL },
@@ -666,19 +720,24 @@ ChatCommand * ChatHandler::getCommandTable()
         { "flusharenapoints",SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand,    "", NULL },
         { "repairitems",    SEC_GAMEMASTER,     true,  &ChatHandler::HandleRepairitemsCommand,         "", NULL },
         { "waterwalk",      SEC_GAMEMASTER,     false, &ChatHandler::HandleWaterwalkCommand,           "", NULL },
+
         { "freeze",         SEC_ADMINISTRATOR,  false, &ChatHandler::HandleFreezeCommand,              "", NULL },
         { "unfreeze",       SEC_ADMINISTRATOR,  false, &ChatHandler::HandleUnFreezeCommand,            "", NULL },
         { "listfreeze",     SEC_ADMINISTRATOR,  false, &ChatHandler::HandleListFreezeCommand,          "", NULL },
+
         { "possess",        SEC_ADMINISTRATOR,  false, &ChatHandler::HandlePossessCommand,             "", NULL },
         { "unpossess",      SEC_ADMINISTRATOR,  false, &ChatHandler::HandleUnPossessCommand,           "", NULL },
         { "bindsight",      SEC_ADMINISTRATOR,  false, &ChatHandler::HandleBindSightCommand,           "", NULL },
         { "unbindsight",    SEC_ADMINISTRATOR,  false, &ChatHandler::HandleUnbindSightCommand,         "", NULL },
         { "playall",        SEC_ADMINISTRATOR,  false, &ChatHandler::HandlePlayAllCommand,             "", NULL },
+
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };
+
     if (load_command_table)
     {
         load_command_table = false;
+
         QueryResult *result = WorldDatabase.Query("SELECT name,security,help FROM command");
         if (result)
         {
@@ -686,61 +745,77 @@ ChatCommand * ChatHandler::getCommandTable()
             {
                 Field *fields = result->Fetch();
                 std::string name = fields[0].GetCppString();
+
                 SetDataForCommandInTable(commandTable, name.c_str(), fields[1].GetUInt16(), fields[2].GetCppString(), name);
+
             } while(result->NextRow());
             delete result;
         }
     }
+
     return commandTable;
 }
+
 const char *ChatHandler::GetTrinityString(int32 entry) const
 {
     return m_session->GetTrinityString(entry);
 }
+
 bool ChatHandler::isAvailable(ChatCommand const& cmd) const
 {
     // check security level only for simple  command (without child commands)
     return m_session->GetSecurity() >= cmd.SecurityLevel;
 }
+
 bool ChatHandler::HasLowerSecurity(Player* target, uint64 guid, bool strong)
 {
     WorldSession* target_session = NULL;
     uint32 target_account = 0;
+
     if (target)
         target_session = target->GetSession();
     else if (guid)
         target_account = objmgr.GetPlayerAccountIdByGUID(guid);
+
     if (!target_session && !target_account)
     {
         SendSysMessage(LANG_PLAYER_NOT_FOUND);
         SetSentErrorMessage(true);
         return true;
     }
+
     return HasLowerSecurityAccount(target_session,target_account,strong);
 }
+
 bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_account, bool strong)
 {
     uint32 target_sec;
+
     // allow everything from console and RA console
     if (!m_session)
         return false;
+
     // ignore only for non-players for non strong checks (when allow apply command at least to same sec level)
     if (m_session->GetSecurity() > SEC_PLAYER && !strong && !sWorld.getConfig(CONFIG_GM_LOWER_SECURITY))
         return false;
+
     if (target)
         target_sec = target->GetSecurity();
     else if (target_account)
         target_sec = accmgr.GetSecurity(target_account);
     else
         return true;                                        // caller must report error for (target==NULL && target_account==0)
+
     if (m_session->GetSecurity() < target_sec || (strong && m_session->GetSecurity() <= target_sec))
     {
         SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
         SetSentErrorMessage(true);
         return true;
     }
+
     return false;
 }
+
 bool ChatHandler::hasStringAbbr(const char* name, const char* part)
 {
     // non "" command
@@ -749,6 +824,7 @@ bool ChatHandler::hasStringAbbr(const char* name, const char* part)
         // "" part from non-"" command
         if (!*part)
             return false;
+
         for (;;)
         {
             if (!*part)
@@ -761,42 +837,54 @@ bool ChatHandler::hasStringAbbr(const char* name, const char* part)
         }
     }
     // allow with any for ""
+
     return true;
 }
+
 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)
 {
     // Chat output
     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::SendGlobalGMSysMessage(const char *str)
 {
     // Chat output
     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);
@@ -804,10 +892,12 @@ void ChatHandler::SendGlobalGMSysMessage(const char *str)
      }
     free(buf);
 }
+
 void ChatHandler::SendSysMessage(int32 entry)
 {
     SendSysMessage(GetTrinityString(entry));
 }
+
 void ChatHandler::PSendSysMessage(int32 entry, ...)
 {
     const char *format = GetTrinityString(entry);
@@ -818,6 +908,7 @@ void ChatHandler::PSendSysMessage(int32 entry, ...)
     va_end(ap);
     SendSysMessage(str);
 }
+
 void ChatHandler::PSendSysMessage(const char *format, ...)
 {
     va_list ap;
@@ -827,20 +918,25 @@ void ChatHandler::PSendSysMessage(const char *format, ...)
     va_end(ap);
     SendSysMessage(str);
 }
+
 bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, const std::string& fullcmd)
 {
     char const* oldtext = text;
     std::string cmd = "";
+
     while (*text != ' ' && *text != '\0')
     {
         cmd += *text;
         ++text;
     }
+
     while (*text == ' ') ++text;
+
     for (uint32 i = 0; table[i].Name != NULL; ++i)
     {
         if (!hasStringAbbr(table[i].Name, cmd.c_str()))
             continue;
+
         // select subcommand from child commands list
         if (table[i].ChildCommands != NULL)
         {
@@ -850,13 +946,17 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
                     SendSysMessage(LANG_NO_SUBCMD);
                 else
                     SendSysMessage(LANG_CMD_SYNTAX);
+
                 ShowHelpForCommand(table[i].ChildCommands,text);
             }
+
             return true;
         }
+
         // must be available and have handler
         if (!table[i].Handler || !isAvailable(table[i]))
             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))
@@ -882,24 +982,31 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
             else
                 SendSysMessage(LANG_CMD_SYNTAX);
         }
+
         return true;
     }
+
     return false;
 }
+
 bool ChatHandler::SetDataForCommandInTable(ChatCommand *table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand)
 {
     std::string cmd = "";
+
     while (*text != ' ' && *text != '\0')
     {
         cmd += *text;
         ++text;
     }
+
     while (*text == ' ') ++text;
+
     for (uint32 i = 0; table[i].Name != NULL; i++)
     {
         // for data fill use full explicit command names
         if (table[i].Name != cmd)
             continue;
+
         // select subcommand from child commands list (including "")
         if (table[i].ChildCommands != NULL)
         {
@@ -907,6 +1014,7 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand *table, const char* text,
                 return true;
             else if (*text)
                 return false;
+
             // fail with "" subcommands, then use normal level up command instead
         }
         // expected subcommand by full name DB content
@@ -915,12 +1023,15 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand *table, const char* text,
             sLog.outErrorDb("Table `command` have unexpected subcommand '%s' in command '%s', skip.",text,fullcommand.c_str());
             return false;
         }
+
         if (table[i].SecurityLevel != security)
             sLog.outDetail("Table `command` overwrite for command '%s' default security (%u) by %u",fullcommand.c_str(),table[i].SecurityLevel,security);
+
         table[i].SecurityLevel = security;
         table[i].Help          = help;
         return true;
     }
+
     // in case "" command let process by caller
     if (!cmd.empty())
     {
@@ -929,31 +1040,40 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand *table, const char* text,
         else
             sLog.outErrorDb("Table `command` have not existed subcommand '%s' in command '%s', skip.",cmd.c_str(),fullcommand.c_str());
     }
+
     return false;
 }
+
 int ChatHandler::ParseCommands(const char* text)
 {
     ASSERT(text);
     ASSERT(*text);
+
     std::string fullcmd = text;
+
     if (m_session && !m_session->HandleOnPlayerChat(text))
         return 0;
+
     /// chat case (.command or !command format)
     if (m_session)
     {
         if (text[0] != '!' && text[0] != '.')
             return 0;
     }
+
     /// ignore single . and ! in line
     if (strlen(text) < 2)
         return 0;
     // original `text` can't be used. It content destroyed in command code processing.
+
     /// ignore messages staring from many dots.
     if ((text[0] == '.' && text[1] == '.') || (text[0] == '!' && text[1] == '!'))
         return 0;
+
     /// skip first . or ! (in console allowed use command with . and ! and without its)
     if (text[0] == '!' || text[0] == '.')
         ++text;
+
     if (!ExecuteCommandInTable(getCommandTable(), text, fullcmd))
     {
         if (m_session && m_session->GetSecurity() == SEC_PLAYER)
@@ -962,9 +1082,11 @@ int ChatHandler::ParseCommands(const char* text)
     }
     return 1;
 }
+
 bool ChatHandler::isValidChatMessage(const char* message)
 {
 /*
+
 valid examples:
 |cffa335ee|Hitem:812:0:0:0:0:0:0:0:70|h[Glowing Brightwood Staff]|h|r
 |cff808080|Hquest:2278:47|h[The Platinum Discs]|h|r
@@ -974,26 +1096,34 @@ valid examples:
 |cffffd000|Henchant:3919|h[Engineering: Rough Dynamite]|h|r
 |cffffff00|Hachievement:546:0000000000000001:0:0:0:-1:0:0:0:0|h[Safe Deposit]|h|r
 |cff66bbff|Hglyph:21:762|h[Glyph of Bladestorm]|h|r
+
 | will be escaped to ||
 */
+
     if (strlen(message) > 255)
         return false;
+
     const char validSequence[6] = "cHhhr";
     const char* validSequenceIterator = validSequence;
+
     // more simple checks
     if (sWorld.getConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) < 3)
     {
         const std::string validCommands = "cHhr|";
+
         while(*message)
         {
             // find next pipe command
             message = strchr(message, '|');
+
             if (!message)
                 return true;
+
             ++message;
             char commandChar = *message;
             if (validCommands.find(commandChar) == std::string::npos)
                 return false;
+
             ++message;
             // validate sequence
             if (sWorld.getConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) == 2)
@@ -1011,13 +1141,17 @@ valid examples:
         }
         return true;
     }
+
     std::istringstream reader(message);
     char buffer[256];
+
     uint32 color;
+
     ItemPrototype const* linkedItem;
     Quest const* linkedQuest;
     SpellEntry const *linkedSpell;
     AchievementEntry const* linkedAchievement;
+
     while(!reader.eof())
     {
         if (validSequence == validSequenceIterator)
@@ -1026,6 +1160,7 @@ valid examples:
             linkedQuest = NULL;
             linkedSpell = NULL;
             linkedAchievement = NULL;
+
             reader.ignore(255, '|');
         }
         else if (reader.get() != '|')
@@ -1035,6 +1170,7 @@ valid examples:
 #endif
             return false;
         }
+
         // pipe has always to be followed by at least one char
         if (reader.peek() == '\0')
         {
@@ -1043,11 +1179,14 @@ valid examples:
 #endif
             return false;
         }
+
         // no further pipe commands
         if (reader.eof())
             break;
+
         char commandChar;
         reader >> commandChar;
+
         // | in normal messages is escaped by ||
         if (commandChar != '|')
         {
@@ -1074,6 +1213,7 @@ valid examples:
 #endif
             return false;
         }
+
         switch (commandChar)
         {
             case 'c':
@@ -1090,6 +1230,7 @@ valid examples:
 #endif
                         return false;
                     }
+
                     color <<= 4;
                     // check for hex char
                     if (c >= '0' && c <='9')
@@ -1111,10 +1252,12 @@ valid examples:
             case 'H':
                 // read chars up to colon  = link type
                 reader.getline(buffer, 256, ':');
+
                 if (strcmp(buffer, "item") == 0)
                 {
                     // read item entry
                     reader.getline(buffer, 256, ':');
+
                     linkedItem= objmgr.GetItemPrototype(atoi(buffer));
                     if (!linkedItem)
                     {
@@ -1123,6 +1266,7 @@ valid examples:
 #endif
                         return false;
                     }
+
                     if (color != ItemQualityColors[linkedItem->Quality])
                     {
 #ifdef MANGOS_DEBUG
@@ -1131,7 +1275,9 @@ valid examples:
 #endif
                         return false;
                     }
+
                     char c = reader.peek();
+
                     // ignore enchants etc.
                     while((c >='0' && c <='9') || c==':')
                     {
@@ -1152,7 +1298,9 @@ valid examples:
                         questid += c-'0';
                         c = reader.peek();
                     }
+
                     linkedQuest = objmgr.GetQuestTemplate(questid);
+
                     if (!linkedQuest)
                     {
 #ifdef MANOGS_DEBUG
@@ -1172,11 +1320,13 @@ valid examples:
                 {
                     if (color != CHAT_LINK_COLOR_TRADE)
                         return false;
+
                     // read spell entry
                     reader.getline(buffer, 256, ':');
                     linkedSpell = sSpellStore.LookupEntry(atoi(buffer));
                     if (!linkedSpell)
                         return false;
+
                     char c = reader.peek();
                     // base64 encoded stuff
                     while(c !='|' && c!='\0')
@@ -1190,14 +1340,17 @@ valid examples:
                     // talent links are always supposed to be blue
                     if (color != CHAT_LINK_COLOR_TALENT)
                         return false;
+
                     // read talent entry
                     reader.getline(buffer, 256, ':');
                     TalentEntry const *talentInfo = sTalentStore.LookupEntry(atoi(buffer));
                     if (!talentInfo)
                         return false;
+
                     linkedSpell = sSpellStore.LookupEntry(talentInfo->RankID[0]);
                     if (!linkedSpell)
                         return false;
+
                     char c = reader.peek();
                     // skillpoints? whatever, drop it
                     while(c !='|' && c!='\0')
@@ -1210,6 +1363,7 @@ valid examples:
                 {
                     if (color != CHAT_LINK_COLOR_SPELL)
                         return false;
+
                     uint32 spellid = 0;
                     // read spell entry
                     char c = reader.peek();
@@ -1228,6 +1382,7 @@ valid examples:
                 {
                     if (color != CHAT_LINK_COLOR_ENCHANT)
                         return false;
+
                     uint32 spellid = 0;
                     // read spell entry
                     char c = reader.peek();
@@ -1249,8 +1404,10 @@ valid examples:
                     reader.getline(buffer, 256, ':');
                     uint32 achievementId = atoi(buffer);
                     linkedAchievement = sAchievementStore.LookupEntry(achievementId);
+
                     if (!linkedAchievement)
                         return false;
+
                     char c = reader.peek();
                     // skip progress
                     while(c !='|' && c!='\0')
@@ -1263,6 +1420,7 @@ valid examples:
                 {
                     if (color != CHAT_LINK_COLOR_GLYPH)
                         return false;
+
                     // first id is slot, drop it
                     reader.getline(buffer, 256, ':');
                     uint32 glyphId = 0;
@@ -1277,7 +1435,9 @@ valid examples:
                     GlyphPropertiesEntry const* glyph = sGlyphPropertiesStore.LookupEntry(glyphId);
                     if (!glyph)
                         return false;
+
                     linkedSpell = sSpellStore.LookupEntry(glyph->SpellId);
+
                     if (!linkedSpell)
                         return false;
                 }
@@ -1302,6 +1462,7 @@ valid examples:
                         return false;
                     }
                     reader.getline(buffer, 256, ']');
+
                     // verify the link name
                     if (linkedSpell)
                     {
@@ -1314,16 +1475,20 @@ valid examples:
                             {
                                 return false;
                             }
+
                             SkillLineAbilityEntry const *skillInfo = bounds.first->second;
+
                             if (!skillInfo)
                             {
                                 return false;
                             }
+
                             SkillLineEntry const *skillLine = sSkillLineStore.LookupEntry(skillInfo->skillId);
                             if (!skillLine)
                             {
                                 return false;
                             }
+
                             for (uint8 i=0; iname[i]);
@@ -1353,6 +1518,7 @@ valid examples:
                         if (linkedQuest->GetTitle() != buffer)
                         {
                             QuestLocale const *ql = objmgr.GetQuestLocale(linkedQuest->GetQuestId());
+
                             if (!ql)
                             {
 #ifdef MANOGS_DEBUG
@@ -1360,6 +1526,7 @@ valid examples:
 #endif
                                 return false;
                             }
+
                             bool foundName = false;
                             for (uint8 i=0; iTitle.size(); i++)
                             {
@@ -1383,6 +1550,7 @@ valid examples:
                         if (strcmp(linkedItem->Name1, buffer) != 0)
                         {
                             ItemLocale const *il = objmgr.GetItemLocale(linkedItem->ItemId);
+
                             if (!il)
                             {
 #ifdef MANGOS_DEBUG
@@ -1390,6 +1558,7 @@ valid examples:
 #endif
                                 return false;
                             }
+
                             bool foundName = false;
                             for (uint8 i=0; iName.size(); ++i)
                             {
@@ -1439,6 +1608,7 @@ valid examples:
                 return false;
         }
     }
+
     // check if every opened sequence was also closed properly
 #ifdef MANGOS_DEBUG
     if (validSequence != validSequenceIterator)
@@ -1446,6 +1616,7 @@ valid examples:
 #endif
     return validSequence == validSequenceIterator;
 }
+
 bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd)
 {
     std::string list;
@@ -1454,19 +1625,25 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd, ch
         // must be available (ignore handler existence for show command with possibe avalable subcomands
         if (!isAvailable(table[i]))
             continue;
+
         /// for empty subcmd show all available
         if (*subcmd && !hasStringAbbr(table[i].Name, subcmd))
             continue;
+
         if (m_session)
             list += "\n    ";
         else
             list += "\n\r    ";
+
         list += table[i].Name;
+
         if (table[i].ChildCommands)
             list += " ...";
     }
+
     if (list.empty())
         return false;
+
     if (table==getCommandTable())
     {
         SendSysMessage(LANG_AVIABLE_CMD);
@@ -1474,8 +1651,10 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd, ch
     }
     else
         PSendSysMessage(LANG_SUBCMDS_LIST,cmd,list.c_str());
+
     return true;
 }
+
 bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
 {
     if (*cmd)
@@ -1485,20 +1664,26 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
             // must be available (ignore handler existence for show command with possibe avalable subcomands
             if (!isAvailable(table[i]))
                 continue;
+
             if (!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();
         }
     }
@@ -1509,28 +1694,36 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
             // must be available (ignore handler existence for show command with possibe avalable subcomands
             if (!isAvailable(table[i]))
                 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:
@@ -1580,13 +1773,16 @@ void ChatHandler::FillMessageData(WorldPacket *data, WorldSession* session, uint
                 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;
@@ -1595,116 +1791,153 @@ void ChatHandler::FillMessageData(WorldPacket *data, WorldSession* session, uint
     else
         *data << uint8(0);
 }
+
 Player * ChatHandler::getSelectedPlayer()
 {
     if (!m_session)
         return NULL;
+
     uint64 guid  = m_session->GetPlayer()->GetSelection();
+
     if (guid == 0)
         return m_session->GetPlayer();
+
     return objmgr.GetPlayer(guid);
 }
+
 Unit* ChatHandler::getSelectedUnit()
 {
     if (!m_session)
         return NULL;
+
     uint64 guid = m_session->GetPlayer()->GetSelection();
+
     if (guid == 0)
         return m_session->GetPlayer();
+
     return ObjectAccessor::GetUnit(*m_session->GetPlayer(),guid);
 }
+
 WorldObject *ChatHandler::getSelectedObject()
 {
     if (!m_session)
         return NULL;
+
     uint64 guid = m_session->GetPlayer()->GetSelection();
+
     if (guid == 0)
         return GetNearbyGameObject();
+
     return ObjectAccessor::GetUnit(*m_session->GetPlayer(),guid);
 }
+
 Creature* ChatHandler::getSelectedCreature()
 {
     if (!m_session)
         return NULL;
+
     return ObjectAccessor::GetCreatureOrPetOrVehicle(*m_session->GetPlayer(),m_session->GetPlayer()->GetSelection());
 }
+
 char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
 {
     // skip empty
     if (!text)
         return NULL;
+
     // skip spaces
     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 return 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 spaces
     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
     // or
     // [name] Shift-click form |linkType:key|h[name]|h|r
+
     char* tail;
+
     if (text[1]=='c')
     {
         char* check = strtok(text, "|");                    // skip color
         if (!check)
             return NULL;                                    // end of data
+
         tail = strtok(NULL, "");                            // tail
     }
     else
         tail = text+1;                                      // skip first |
+
     char* cLinkType = strtok(tail, ":");                    // 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)
@@ -1712,10 +1945,12 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes,
             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;
@@ -1725,25 +1960,34 @@ char const *fmtstring(char const *format, ...)
     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::GetNearbyGameObject()
 {
     if (!m_session)
         return NULL;
+
     Player* pl = m_session->GetPlayer();
     GameObject* obj = NULL;
     Trinity::NearestGameObjectCheck check(*pl);
@@ -1751,26 +1995,34 @@ GameObject* ChatHandler::GetNearbyGameObject()
     pl->VisitNearbyGridObject(999, searcher);
     return obj;
 }
+
 GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry)
 {
     if (!m_session)
         return NULL;
+
     Player* pl = m_session->GetPlayer();
+
     GameObject* obj = pl->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT));
+
     if (!obj && objmgr.GetGOData(lowguid))                   // guid is DB guid of object
     {
         // search near player then
         CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY()));
         Cell cell(p);
         cell.data.Part.reserved = ALL_DISTRICT;
+
         MaNGOS::GameObjectWithDbGUIDCheck go_check(*pl,lowguid);
         MaNGOS::GameObjectSearcher checker(pl,obj,go_check);
+
         TypeContainerVisitor, GridTypeMapContainer > object_checker(checker);
         CellLock cell_lock(cell, p);
         cell_lock->Visit(cell_lock, object_checker, *pl->GetMap());
     }
+
     return obj;
 }
+
 enum SpellLinkType
 {
     SPELL_LINK_SPELL   = 0,
@@ -1779,6 +2031,7 @@ enum SpellLinkType
     SPELL_LINK_TRADE   = 3,
     SPELL_LINK_GLYPH   = 4
 };
+
 static char const* const spellKeys[] =
 {
     "Hspell",                                               // normal spell
@@ -1788,6 +2041,7 @@ static char const* const spellKeys[] =
     "Hglyph",                                               // glyph
     0
 };
+
 uint32 ChatHandler::extractSpellIdFromLink(char* text)
 {
     // number or [name] Shift-click form |color|Henchant:recipe_spell_id|h[prof_name: recipe_name]|h|r
@@ -1800,7 +2054,9 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
     char* idS = extractKeyFromLink(text,spellKeys,&type,¶m1_str);
     if (!idS)
         return 0;
+
     uint32 id = (uint32)atol(idS);
+
     switch(type)
     {
         case SPELL_LINK_SPELL:
@@ -1811,11 +2067,14 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
             TalentEntry const* talentEntry = sTalentStore.LookupEntry(id);
             if (!talentEntry)
                 return 0;
+
             int32 rank = param1_str ? (uint32)atol(param1_str) : 0;
             if (rank >= MAX_TALENT_RANK)
                 return 0;
+
             if (rank < 0)
                 rank = 0;
+
             return talentEntry->RankID[rank];
         }
         case SPELL_LINK_ENCHANT:
@@ -1824,33 +2083,41 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
         case SPELL_LINK_GLYPH:
         {
             uint32 glyph_prop_id = param1_str ? (uint32)atol(param1_str) : 0;
+
             GlyphPropertiesEntry const* glyphPropEntry = sGlyphPropertiesStore.LookupEntry(glyph_prop_id);
             if (!glyphPropEntry)
                 return 0;
+
             return glyphPropEntry->SpellId;
         }
     }
+
     // unknown type?
     return 0;
 }
+
 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);
 }
+
 enum GuidLinkType
 {
     SPELL_LINK_PLAYER     = 0,                              // must be first for selection in not link case
     SPELL_LINK_CREATURE   = 1,
     SPELL_LINK_GAMEOBJECT = 2
 };
+
 static char const* const guidKeys[] =
 {
     "Hplayer",
@@ -1858,15 +2125,18 @@ static char const* const guidKeys[] =
     "Hgameobject",
     0
 };
+
 uint64 ChatHandler::extractGuidFromLink(char* text)
 {
     int type = 0;
+
     // |color|Hcreature:creature_guid|h[name]|h|r
     // |color|Hgameobject:go_guid|h[name]|h|r
     // |color|Hplayer:name|h[name]|h|r
     char* idS = extractKeyFromLink(text,guidKeys,&type);
     if (!idS)
         return 0;
+
     switch(type)
     {
         case SPELL_LINK_PLAYER:
@@ -1874,15 +2144,19 @@ uint64 ChatHandler::extractGuidFromLink(char* text)
             std::string name = idS;
             if (!normalizePlayerName(name))
                 return 0;
+
             if (Player* player = objmgr.GetPlayer(name.c_str()))
                 return player->GetGUID();
+
             if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
                 return guid;
+
             return 0;
         }
         case SPELL_LINK_CREATURE:
         {
             uint32 lowguid = (uint32)atol(idS);
+
             if (CreatureData const* data = objmgr.GetCreatureData(lowguid))
                 return MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT);
             else
@@ -1891,26 +2165,32 @@ uint64 ChatHandler::extractGuidFromLink(char* text)
         case SPELL_LINK_GAMEOBJECT:
         {
             uint32 lowguid = (uint32)atol(idS);
+
             if (GameObjectData const* data = objmgr.GetGOData(lowguid))
                 return MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_GAMEOBJECT);
             else
                 return 0;
         }
     }
+
     // unknown type?
     return 0;
 }
+
 std::string ChatHandler::extractPlayerNameFromLink(char* text)
 {
     // |color|Hplayer:name|h[name]|h|r
     char* name_str = extractKeyFromLink(text,"Hplayer");
     if (!name_str)
         return "";
+
     std::string name = name_str;
     if (!normalizePlayerName(name))
         return "";
+
     return name;
 }
+
 bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* player_guid /*=NULL*/,std::string* player_name /*= NULL*/)
 {
     if (args && *args)
@@ -1922,15 +2202,20 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe
             SetSentErrorMessage(true);
             return false;
         }
+
         Player* pl = objmgr.GetPlayer(name.c_str());
+
         // if allowed player pointer
         if (player)
             *player = pl;
+
         // if need guid value from DB (in name case for check player existence)
         uint64 guid = !pl && (player_guid || player_name) ? objmgr.GetPlayerGUIDByName(name) : 0;
+
         // if allowed player guid (if no then only online players allowed)
         if (player_guid)
             *player_guid = pl ? pl->GetGUID() : guid;
+
         if (player_name)
             *player_name = pl || guid ? name : "";
     }
@@ -1943,9 +2228,11 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe
         // if allowed player guid (if no then only online players allowed)
         if (player_guid)
             *player_guid = pl ? pl->GetGUID() : 0;
+
         if (player_name)
             *player_name = pl ? pl->GetName() : "";
     }
+
     // some from req. data must be provided (note: name is empty if player not exist)
     if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
     {
@@ -1953,26 +2240,33 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe
         SetSentErrorMessage(true);
         return false;
     }
+
     return true;
 }
+
 void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
 {
     char* p1 = strtok(args, " ");
     char* p2 = strtok(NULL, " ");
+
     if (!p2)
     {
         p2 = p1;
         p1 = NULL;
     }
+
     if (arg1)
         *arg1 = p1;
+
     if (arg2)
         *arg2 = p2;
 }
+
 char* ChatHandler::extractQuotedArg(char* args)
 {
     if (!*args)
         return NULL;
+
     if (*args=='"')
         return strtok(args+1, "\"");
     else
@@ -1983,45 +2277,55 @@ char* ChatHandler::extractQuotedArg(char* args)
         return strtok(NULL, "\"");
     }
 }
+
 bool ChatHandler::needReportToTarget(Player* chr) const
 {
     Player* pl = m_session->GetPlayer();
     return pl != chr && pl->IsVisibleGloballyFor(chr);
 }
+
 LocaleConstant ChatHandler::GetSessionDbcLocale() const
 {
     return m_session->GetSessionDbcLocale();
 }
+
 int ChatHandler::GetSessionDbLocaleIndex() const
 {
     return m_session->GetSessionDbLocaleIndex();
 }
+
 const char *CliHandler::GetMangosString(int32 entry) const
 {
     return objmgr.GetTrinityStringForDBCLocale(entry);
 }
+
 bool CliHandler::isAvailable(ChatCommand const& cmd) const
 {
     // skip non-console commands in console case
     return cmd.AllowConsole;
 }
+
 void CliHandler::SendSysMessage(const char *str)
 {
     m_print(str);
     m_print("\r\n");
 }
+
 std::string CliHandler::GetNameLink() const
 {
     return GetTrinityString(LANG_CONSOLE_COMMAND);
 }
+
 bool CliHandler::needReportToTarget(Player* /*chr*/) const
 {
     return true;
 }
+
 bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, Group* &group, uint64 &guid, bool offline)
 {
     plr  = NULL;
     guid = 0;
+
     if (cname)
     {
         std::string name = cname;
@@ -2033,11 +2337,13 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, G
                 SetSentErrorMessage(true);
                 return false;
             }
+
             plr = objmgr.GetPlayer(name.c_str());
             if (offline)
                 guid = objmgr.GetPlayerGUIDByName(name.c_str());
         }
     }
+
     if (plr)
     {
         group = plr->GetGroup();
@@ -2050,17 +2356,21 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, G
             plr = getSelectedPlayer();
         else
             plr = m_session->GetPlayer();
+
         if (!guid || !offline)
             guid  = plr->GetGUID();
         group = plr->GetGroup();
     }
+
     return true;
 }
+
 LocaleConstant CliHandler::GetSessionDbcLocale() const
 {
     return sWorld.GetDefaultDbcLocale();
 }
+
 int CliHandler::GetSessionDbLocaleIndex() const
 {
     return objmgr.GetDBCLocaleIndex();
-}
+}
\ No newline at end of file
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 35e39ad8b08..1518cb6d45e 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -17,15 +17,19 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef TRINITYCORE_CHAT_H
 #define TRINITYCORE_CHAT_H
+
 #include "SharedDefines.h"
+
 class ChatHandler;
 class WorldSession;
 class Creature;
 class Player;
 class Unit;
 struct GameTele;
+
 class ChatCommand
 {
     public:
@@ -36,50 +40,66 @@ class ChatCommand
         std::string        Help;
         ChatCommand *      ChildCommands;
 };
+
 class TRINITY_DLL_SPEC 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; }
+
         // function with different implementation for chat/console
         virtual const char *GetMangosString(int32 entry) const;
         virtual void SendSysMessage(  const char *str);
+
         void SendSysMessage(          int32     entry);
         void PSendSysMessage(         const char *format, ...) ATTR_PRINTF(2,3);
         void PSendSysMessage(         int32     entry, ...  );
         std::string PGetParseString(int32 entry, ...);
+
         int ParseCommands(const char* text);
+
         static ChatCommand* getCommandTable();
+
         bool isValidChatMessage(const char* msg);
         void SendGlobalSysMessage(const char *str);
     protected:
         explicit ChatHandler() : m_session(NULL) {}      // for CLI subclass
+
         bool hasStringAbbr(const char* name, const char* part);
+
         // function with different implementation for chat/console
         virtual bool isAvailable(ChatCommand const& cmd) const;
         virtual std::string GetNameLink() const { return GetNameLink(m_session->GetPlayer()); }
         virtual bool needReportToTarget(Player* chr) const;
         virtual LocaleConstant GetSessionDbcLocale() const;
         virtual int GetSessionDbLocaleIndex() const;
+
         bool HasLowerSecurity(Player* target, uint64 guid, bool strong = false);
         bool HasLowerSecurityAccount(WorldSession* target, uint32 account, bool strong = false);
 
+      
         void SendGlobalGMSysMessage(const char *str);
+
         static bool SetDataForCommandInTable(ChatCommand *table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand );
         bool ExecuteCommandInTable(ChatCommand *table, const char* text, const std::string& fullcommand);
         bool ShowHelpForCommand(ChatCommand *table, const char* cmd);
         bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd);
+
         bool HandleAccountCommand(const char* args);
         bool HandleAccountAddonCommand(const char* args);
         bool HandleAccountCreateCommand(const char* args);
@@ -90,11 +110,13 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleAccountSetAddonCommand(const char* args);
         bool HandleAccountSetGmLevelCommand(const char* args);
         bool HandleAccountSetPasswordCommand(const char* args);
+
         bool HandleAHBotOptionsCommand(const char * args);
         bool HandleNameAnnounceCommand(const char* args);
         bool HandleGMNameAnnounceCommand(const char* args);
         bool HandleGMAnnounceCommand(const char* args);
         bool HandleGMNotifyCommand(const char* args);
+
         bool HandleBanAccountCommand(const char* args);
         bool HandleBanCharacterCommand(const char* args);
         bool HandleBanIPCommand(const char* args);
@@ -104,16 +126,19 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleBanListAccountCommand(const char* args);
         bool HandleBanListCharacterCommand(const char* args);
         bool HandleBanListIPCommand(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 HandleCharacterCustomizeCommand(const char * args);
         bool HandleCharacterDeleteCommand(const char* args);
         bool HandleCharacterLevelCommand(const char* args);
         bool HandleCharacterRenameCommand(const char * args);
         bool HandleCharacterReputationCommand(const char* args);
+
         bool HandleDebugAnimCommand(const char* args);
         bool HandleDebugArenaCommand(const char * args);
         bool HandleDebugBattlegroundCommand(const char * args);
@@ -131,6 +156,7 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleDebugSpellCheckCommand(const char* args);
         bool HandleDebugUpdateCommand(const char* args);
         bool HandleDebugUpdateWorldStateCommand(const char* args);
+
         bool HandleDebugSet32Bit(const char* args);
         bool HandleDebugThreatList(const char * args);
         bool HandleDebugHostilRefList(const char * args);
@@ -138,9 +164,11 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleUnPossessCommand(const char* args);
         bool HandleBindSightCommand(const char* args);
         bool HandleUnbindSightCommand(const char* args);
+
         bool HandleDebugPlayCinematicCommand(const char* args);
         bool HandleDebugPlayMovieCommand(const char* args);
         bool HandleDebugPlaySoundCommand(const char* args);
+
         bool HandleDebugSendBuyErrorCommand(const char* args);
         bool HandleDebugSendChannelNotifyCommand(const char* args);
         bool HandleDebugSendChatMsgCommand(const char* args);
@@ -153,10 +181,12 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleDebugSendSellErrorCommand(const char* args);
         bool HandleDebugSendSetPhaseShiftCommand(const char * args);
         bool HandleDebugSendSpellFailCommand(const char* args);
+
         bool HandleEventActiveListCommand(const char* args);
         bool HandleEventStartCommand(const char* args);
         bool HandleEventStopCommand(const char* args);
         bool HandleEventInfoCommand(const char* args);
+
         bool HandleGameObjectAddCommand(const char* args);
         bool HandleGameObjectDeleteCommand(const char* args);
         bool HandleGameObjectMoveCommand(const char* args);
@@ -165,12 +195,14 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleGameObjectStateCommand(const char* args);
         bool HandleGameObjectTargetCommand(const char* args);
         bool HandleGameObjectTurnCommand(const char* args);
+
         bool HandleGMCommand(const char* args);
         bool HandleGMChatCommand(const char* args);
         bool HandleGMFlyCommand(const char* args);
         bool HandleGMListFullCommand(const char* args);
         bool HandleGMListIngameCommand(const char* args);
         bool HandleGMVisibleCommand(const char* args);
+
         bool HandleGoCommand(const char* args);
         bool HandleGoCreatureCommand(const char* args);
         bool HandleGoGraveyardCommand(const char* args);
@@ -181,19 +213,24 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleGoXYCommand(const char* args);
         bool HandleGoXYZCommand(const char* args);
         bool HandleGoZoneXYCommand(const char* args);
+
         bool HandleGoTicketCommand(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 HandleHonorAddCommand(const char* args);
         bool HandleHonorAddKillCommand(const char* args);
         bool HandleHonorUpdateCommand(const char* args);
+
         bool HandleInstanceListBindsCommand(const char* args);
         bool HandleInstanceUnbindCommand(const char* args);
         bool HandleInstanceStatsCommand(const char* args);
         bool HandleInstanceSaveDataCommand(const char * args);
+
         bool HandleLearnCommand(const char* args);
         bool HandleLearnAllCommand(const char* args);
         bool HandleLearnAllGMCommand(const char* args);
@@ -205,10 +242,12 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleLearnAllMyPetTalentsCommand(const char* args);
         bool HandleLearnAllMySpellsCommand(const char* args);
         bool HandleLearnAllMyTalentsCommand(const char* args);
+
         bool HandleListAurasCommand(const char * args);
         bool HandleListCreatureCommand(const char* args);
         bool HandleListItemCommand(const char* args);
         bool HandleListObjectCommand(const char* args);
+
         bool HandleLookupAreaCommand(const char* args);
         bool HandleLookupCreatureCommand(const char* args);
         bool HandleLookupEventCommand(const char* args);
@@ -225,6 +264,7 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleLookupTaxiNodeCommand(const char * args);
         bool HandleLookupTeleCommand(const char * args);
         bool HandleLookupMapCommand(const char* args);
+
         bool HandleModifyKnownTitlesCommand(const char* args);
         bool HandleModifyHPCommand(const char* args);
         bool HandleModifyManaCommand(const char* args);
@@ -248,6 +288,7 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleModifyArenaCommand(const char* args);
         bool HandleModifyPhaseCommand(const char* args);
         bool HandleModifyGenderCommand(const char* args);
+
         //-----------------------Npc Commands-----------------------
         bool HandleNpcAddCommand(const char* args);
         bool HandleNpcAddMoveCommand(const char* args);
@@ -277,16 +318,20 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleNpcYellCommand(const char* args);
         bool HandleNpcAddFormationCommand(const char* args);
         bool HandleNpcSetLinkCommand(const char* args);
+
         //TODO: NpcCommands that needs to be fixed :
         bool HandleNpcAddWeaponCommand(const char* args);
         bool HandleNpcNameCommand(const char* args);
         bool HandleNpcSubNameCommand(const char* args);
         //----------------------------------------------------------
+
         bool HandlePDumpLoadCommand(const char *args);
         bool HandlePDumpWriteCommand(const char *args);
+
         bool HandleQuestAdd(const char * args);
         bool HandleQuestRemove(const char * args);
         bool HandleQuestComplete(const char * args);
+
         bool HandleReloadAllCommand(const char* args);
         bool HandleReloadAllAchievementCommand(const char* args);
         bool HandleReloadAllAreaCommand(const char* args);
@@ -298,7 +343,9 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleReloadAllEventAICommand(const char* args);
         bool HandleReloadAllSpellCommand(const char* args);
         bool HandleReloadAllLocalesCommand(const char* args);
+
         bool HandleReloadConfigCommand(const char* args);
+
         bool HandleReloadAccessRequirementCommand(const char* args);
         bool HandleReloadAchievementCriteriaDataCommand(const char* args);
         bool HandleReloadAchievementRewardCommand(const char* args);
@@ -373,6 +420,7 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleReloadSpellDisabledCommand(const char* args);
         bool HandleReloadAuctionsCommand(const char* args);
         bool HandleReloadWpScriptsCommand(const char* args);
+
         bool HandleResetAchievementsCommand(const char * args);
         bool HandleResetAllCommand(const char * args);
         bool HandleResetHonorCommand(const char * args);
@@ -380,10 +428,12 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleResetSpellsCommand(const char * args);
         bool HandleResetStatsCommand(const char * args);
         bool HandleResetTalentsCommand(const char * args);
+
         bool HandleSendItemsCommand(const char* args);
         bool HandleSendMailCommand(const char* args);
         bool HandleSendMessageCommand(const char * args);
         bool HandleSendMoneyCommand(const char* args);
+
         bool HandleServerCorpsesCommand(const char* args);
         bool HandleServerExitCommand(const char* args);
         bool HandleServerIdleRestartCommand(const char* args);
@@ -397,16 +447,20 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleServerShutDownCommand(const char* args);
         bool HandleServerShutDownCancelCommand(const char* args);
         bool HandleServerSetClosedCommand(const char* args);
+
         bool HandleServerSetLogFileLevelCommand(const char* args);
         bool HandleServerSetDiffTimeCommand(const char* args);
+
         bool HandleTeleCommand(const char * args);
         bool HandleTeleAddCommand(const char * args);
         bool HandleTeleDelCommand(const char * args);
         bool HandleTeleGroupCommand(const char* args);
         bool HandleTeleNameCommand(const char* args);
+
         bool HandleUnBanAccountCommand(const char* args);
         bool HandleUnBanCharacterCommand(const char* args);
         bool HandleUnBanIPCommand(const char* args);
+
         bool HandleWpAddCommand(const char* args);
         bool HandleWpLoadPathCommand(const char* args);
         bool HandleWpUnLoadPathCommand(const char* args);
@@ -414,11 +468,13 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleWpEventCommand(const char* args);
         bool HandleWpShowCommand(const char* args);
         bool HandleReloadAllPaths(const char *args);
+
         bool HandleHelpCommand(const char* args);
         bool HandleCommandsCommand(const char* args);
         bool HandleStartCommand(const char* args);
         bool HandleDismountCommand(const char* args);
         bool HandleSaveCommand(const char* args);
+
         bool HandleNamegoCommand(const char* args);
         bool HandleGonameCommand(const char* args);
         bool HandleGroupgoCommand(const char* args);
@@ -429,7 +485,9 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleTaxiCheatCommand(const char* args);
         bool HandleWhispersCommand(const char* args);
         bool HandleModifyDrunkCommand(const char* args);
+
         bool HandleLoadScriptsCommand(const char* args);
+
         bool HandleGUIDCommand(const char* args);
         bool HandleItemMoveCommand(const char* args);
         bool HandleDeMorphCommand(const char* args);
@@ -440,6 +498,7 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleFreezeCommand(const char *args);
         bool HandleUnFreezeCommand(const char *args);
         bool HandleListFreezeCommand(const char* args);
+
         bool HandleCooldownCommand(const char* args);
         bool HandleUnLearnCommand(const char* args);
         bool HandleGetDistanceCommand(const char* args);
@@ -466,12 +525,15 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandlePetUnlearnCommand(const char* args);
         bool HandlePetLearnCommand(const char* args);
         bool HandleCreatePetCommand(const char* args);
+
         bool HandleGroupLeaderCommand(const char* args);
         bool HandleGroupDisbandCommand(const char* args);
         bool HandleGroupRemoveCommand(const char* args);
+
         bool HandleBankCommand(const char* args);
         bool HandleChangeWeather(const char* args);
         bool HandleKickPlayerCommand(const char * args);
+
         // GM ticket command handlers
         bool HandleGMTicketListCommand(const char* args);
         bool HandleGMTicketListOnlineCommand(const char* args);
@@ -484,33 +546,44 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleGMTicketCommentCommand(const char* args);
         bool HandleGMTicketDeleteByIdCommand(const char* args);
         bool HandleGMTicketReloadCommand(const char*);
+
         bool HandleMaxSkillCommand(const char* args);
         bool HandleSetSkillCommand(const char* args);
         bool HandleRespawnCommand(const char* args);
         bool HandleComeToMeCommand(const char *args);
         bool HandleCombatStopCommand(const char *args);
+
         /*bool HandleCharDeleteCommand(const char *args);
         bool HandleSendMessageCommand(const char * args);*/
+
         bool HandleFlushArenaPointsCommand(const char *args);
         bool HandlePlayAllCommand(const char* args);
         bool HandleRepairitemsCommand(const char* args);
+
         bool HandleTempGameObjectCommand(const char* args);
         bool HandleTempAddSpwCommand(const char* args);
+
         //! Development Commands
+
         /*bool HandleQuestAdd(const char * args);
         bool HandleQuestRemove(const char * args);
         bool HandleQuestComplete(const char * args);*/
+
         //bool HandleSet32Bit(const char* args);
         bool HandleSaveAllCommand(const char* args);
+
         Player*   getSelectedPlayer();
         Creature* getSelectedCreature();
         Unit*     getSelectedUnit();
         WorldObject* getSelectedObject();
+
         char*     extractKeyFromLink(char* text, char const* linkType, char** something1 = NULL);
         char*     extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = NULL);
+
         // if args have single value then it return in arg2 and arg1 == NULL
         void      extractOptFirstArg(char* args, char** arg1, char** arg2);
         char*     extractQuotedArg(char* args);
+
         uint32    extractSpellIdFromLink(char* text);
         uint64    extractGuidFromLink(char* text);
         GameTele const* extractGameTeleFromLink(char* text);
@@ -518,10 +591,13 @@ class TRINITY_DLL_SPEC ChatHandler
         std::string extractPlayerNameFromLink(char* text);
         // select by arg (name/link) or in-game selection online/offline player
         bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
+
         std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
         std::string GetNameLink(Player* chr) const { return playerLink(chr->GetName()); }
+
         GameObject* GetNearbyGameObject();
         GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry);
+
         // Utility methods for commands
         bool LookupPlayerSearchCommand(QueryResult* result, int32 limit);
         bool HandleBanListHelper(QueryResult* result);
@@ -530,18 +606,22 @@ class TRINITY_DLL_SPEC ChatHandler
         bool HandleUnBanHelper(BanMode mode,char const* args);
         void HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel);
         void HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id);
+
         void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
     private:
         WorldSession * m_session;                           // != NULL for chat command call and NULL for CLI command
+
         // common global flag
         static bool load_command_table;
         bool sentErrorMessage;
 };
+
 class CliHandler : public ChatHandler
 {
     public:
         typedef void Print(char const*);
         explicit CliHandler(Print* zprint) : m_print(zprint) {}
+
         // overwrite functions
         const char *GetTrinityString(int32 entry) const;
         bool isAvailable(ChatCommand const& cmd) const;
@@ -550,9 +630,12 @@ class CliHandler : public ChatHandler
         bool needReportToTarget(Player* chr) const;
         LocaleConstant GetSessionDbcLocale() const;
         int GetSessionDbLocaleIndex() const;
+
     private:
         Print* m_print;
 };
+
 char const *fmtstring( char const *format, ... );
+
 #endif
 
diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp
index 11b57618d21..e5aaab05c9d 100644
--- a/src/game/ChatHandler.cpp
+++ b/src/game/ChatHandler.cpp
@@ -17,6 +17,7 @@
  * 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 "ObjectAccessor.h"
 #include "ObjectMgr.h"
@@ -24,6 +25,7 @@
 #include "WorldPacket.h"
 #include "WorldSession.h"
 #include "Database/DatabaseEnv.h"
+
 #include "CellImpl.h"
 #include "Chat.h"
 #include "ChannelMgr.h"
@@ -37,6 +39,7 @@
 #include "ScriptCalls.h"
 #include "SpellAuras.h"
 #include "Util.h"
+
 bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg, uint32 lang)
 {
     if (lang != LANG_ADDON)
@@ -44,6 +47,7 @@ bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg
         // strip invisible characters for non-addon messages
         if(sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING))
             stripLineInvisibleChars(msg);
+
         if (sWorld.getConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) && GetSecurity() < SEC_MODERATOR
                 && !ChatHandler(this).isValidChatMessage(msg.c_str()))
         {
@@ -54,20 +58,26 @@ bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg
             return false;
         }
     }
+
     return true;
 }
+
 void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
 {
     uint32 type;
     uint32 lang;
+
     recv_data >> type;
     recv_data >> lang;
+
     if(type >= MAX_CHAT_MSG_TYPE)
     {
         sLog.outError("CHAT: Wrong message type received: %u", type);
         return;
     }
+
     //sLog.outDebug("CHAT: packet received. type %u, lang %u", type, lang );
+
     // prevent talking at unknown language (cheating)
     LanguageDesc const* langDesc = GetLanguageDescByID(lang);
     if(!langDesc)
@@ -94,20 +104,24 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
             return;
         }
     }
+
     if(lang == LANG_ADDON)
     {
         if(sWorld.getConfig(CONFIG_CHATLOG_ADDON))
         {
             std::string msg = "";
             recv_data >> msg;
+
             if(msg.empty())
             {
                 sLog.outDebug("Player %s send empty addon msg", GetPlayer()->GetName());
                 return;
             }
+
             sLog.outChat("[ADDON] Player %s sends: %s",
                 GetPlayer()->GetName(), msg.c_str());
         }
+
         // Disabled addon channel?
         if(!sWorld.getConfig(CONFIG_ADDON_CHANNEL))
             return;
@@ -143,27 +157,33 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
                         break;
                 }
             }
+
             // but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
             Unit::AuraEffectList const& ModLangAuras = _player->GetAurasByType(SPELL_AURA_MOD_LANGUAGE);
             if(!ModLangAuras.empty())
                 lang = ModLangAuras.front()->GetMiscValue();
         }
+
         if (!_player->CanSpeak())
         {
             std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
             SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str());
             return;
         }
+
         if (type != CHAT_MSG_AFK && type != CHAT_MSG_DND)
             GetPlayer()->UpdateSpeakTime();
     }
+
     if (GetPlayer()->HasAura(1852) && type != CHAT_MSG_WHISPER)
     {
         std::string msg="";
         recv_data >> msg;
+
         SendNotification(GetTrinityString(LANG_GM_SILENCE), GetPlayer()->GetName());
         return;
     }
+
     switch(type)
     {
         case CHAT_MSG_SAY:
@@ -172,14 +192,19 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
         {
             std::string msg = "";
             recv_data >> msg;
+
             if(msg.empty())
                 break;
+
             if (ChatHandler(this).ParseCommands(msg.c_str()) > 0)
                 break;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             if(type == CHAT_MSG_SAY)
                 GetPlayer()->Say(msg, lang);
             else if(type == CHAT_MSG_EMOTE)
@@ -187,15 +212,19 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
             else if(type == CHAT_MSG_YELL)
                 GetPlayer()->Yell(msg, lang);
         } break;
+
         case CHAT_MSG_WHISPER:
         {
             std::string to, msg;
             recv_data >> to;
             recv_data >> msg;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             if(!normalizePlayerName(to))
             {
                 WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, (to.size()+1));
@@ -203,6 +232,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
                 SendPacket(&data);
                 break;
             }
+
             Player *player = objmgr.GetPlayer(to.c_str());
             uint32 tSecurity = GetSecurity();
             uint32 pSecurity = player ? player->GetSession()->GetSecurity() : SEC_PLAYER;
@@ -213,6 +243,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
                 SendPacket(&data);
                 return;
             }
+
             if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT) && tSecurity == SEC_PLAYER && pSecurity == SEC_PLAYER )
             {
                 uint32 sidea = GetPlayer()->GetTeam();
@@ -225,33 +256,43 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
                     return;
                 }
             }
+
             if (GetPlayer()->HasAura(1852) && !player->isGameMaster())
             {
                 SendNotification(GetTrinityString(LANG_GM_SILENCE), GetPlayer()->GetName());
                 return;
             }
+
             GetPlayer()->Whisper(msg, lang,player->GetGUID());
         } break;
+
         case CHAT_MSG_PARTY:
         {
             std::string msg = "";
             recv_data >> msg;
+
             if(msg.empty())
                 break;
+
             if (ChatHandler(this).ParseCommands(msg.c_str()) > 0)
                 break;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             // if player is in battleground, he cannot say to battleground members by /p
             Group *group = GetPlayer()->GetOriginalGroup();
             // so if player hasn't OriginalGroup and his player->GetGroup() is BG raid, then return
             if( !group && (!(group = GetPlayer()->GetGroup()) || group->isBGGroup()) )
                 return;
+
             WorldPacket data;
             ChatHandler::FillMessageData(&data, this, CHAT_MSG_PARTY, lang, NULL, 0, msg.c_str(),NULL);
             group->BroadcastPacket(&data, false, group->GetMemberGroup(GetPlayer()->GetGUID()));
+
             if(sWorld.getConfig(CONFIG_CHATLOG_PARTY))
                 sLog.outChat("[PARTY] Player %s tells group with leader %s: %s",
                     GetPlayer()->GetName(), group->GetLeaderName(), msg.c_str());
@@ -261,19 +302,25 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
         {
             std::string msg = "";
             recv_data >> msg;
+
             if(msg.empty())
                 break;
+
             if (ChatHandler(this).ParseCommands(msg.c_str()) > 0)
                 break;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             if (GetPlayer()->GetGuildId())
             {
                 Guild *guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
                 if (guild)
                     guild->BroadcastToGuild(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
+
                 if(lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHATLOG_GUILD))
                 {
                     sLog.outChat("[GUILD] Player %s tells guild %s: %s",
@@ -285,25 +332,32 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
                         GetPlayer()->GetName(), guild->GetName().c_str(), msg.c_str());
                 }
             }
+
             break;
         }
         case CHAT_MSG_OFFICER:
         {
             std::string msg = "";
             recv_data >> msg;
+
             if(msg.empty())
                 break;
+
             if (ChatHandler(this).ParseCommands(msg.c_str()) > 0)
                 break;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             if (GetPlayer()->GetGuildId())
             {
                 Guild *guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
                 if (guild)
                     guild->BroadcastToOfficers(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
+
                 if(sWorld.getConfig(CONFIG_CHATLOG_GUILD))
                     sLog.outChat("[OFFICER] Player %s tells guild %s officers: %s",
                         GetPlayer()->GetName(), guild->GetName().c_str(), msg.c_str());
@@ -314,22 +368,29 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
         {
             std::string msg="";
             recv_data >> msg;
+
             if(msg.empty())
                 break;
+
             if (ChatHandler(this).ParseCommands(msg.c_str()) > 0)
                 break;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             // if player is in battleground, he cannot say to battleground members by /ra
             Group *group = GetPlayer()->GetOriginalGroup();
             // so if player hasn't OriginalGroup and his player->GetGroup() is BG raid or his group isn't raid, then return
             if ((!group && !(group = GetPlayer()->GetGroup())) || group->isBGGroup() || !group->isRaidGroup())
                 return;
+
             WorldPacket data;
             ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID, lang, "", 0, msg.c_str(),NULL);
             group->BroadcastPacket(&data, false);
+
             if(sWorld.getConfig(CONFIG_CHATLOG_RAID))
                 sLog.outChat("[RAID] Player %s tells raid with leader %s: %s",
                     GetPlayer()->GetName(), group->GetLeaderName(), msg.c_str());
@@ -338,21 +399,28 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
         {
             std::string msg="";
             recv_data >> msg;
+
             if(msg.empty())
                 break;
+
             if (ChatHandler(this).ParseCommands(msg.c_str()) > 0)
                 break;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             // if player is in battleground, he cannot say to battleground members by /ra
             Group *group = GetPlayer()->GetOriginalGroup();
             if( !group && !(group = GetPlayer()->GetGroup()) || group->isBGGroup() || !group->isRaidGroup() || !group->IsLeader(GetPlayer()->GetGUID()))
                 return;
+
             WorldPacket data;
             ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_LEADER, lang, "", 0, msg.c_str(),NULL);
             group->BroadcastPacket(&data, false);
+
             if(sWorld.getConfig(CONFIG_CHATLOG_RAID))
                 sLog.outChat("[RAID] Leader player %s tells raid: %s",
                     GetPlayer()->GetName(), msg.c_str());
@@ -361,74 +429,97 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
         {
             std::string msg="";
             recv_data >> msg;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             Group *group = GetPlayer()->GetGroup();
             if(!group || !group->isRaidGroup() || !(group->IsLeader(GetPlayer()->GetGUID()) || group->IsAssistant(GetPlayer()->GetGUID())) || group->isBGGroup())
                 return;
+
             WorldPacket data;
             //in battleground, raid warning is sent only to players in battleground - code is ok
             ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_WARNING, lang, "", 0, msg.c_str(),NULL);
             group->BroadcastPacket(&data, false);
+
             if(sWorld.getConfig(CONFIG_CHATLOG_RAID))
                 sLog.outChat("[RAID] Leader player %s warns raid with: %s",
                     GetPlayer()->GetName(), msg.c_str());
         } break;
+
         case CHAT_MSG_BATTLEGROUND:
         {
             std::string msg="";
             recv_data >> msg;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             //battleground raid is always in Player->GetGroup(), never in GetOriginalGroup()
             Group *group = GetPlayer()->GetGroup();
             if(!group || !group->isBGGroup())
                 return;
+
             WorldPacket data;
             ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND, lang, "", 0, msg.c_str(),NULL);
             group->BroadcastPacket(&data, false);
+
             if(sWorld.getConfig(CONFIG_CHATLOG_BGROUND))
                 sLog.outChat("[BATTLEGROUND] Player %s tells battleground with leader %s: %s",
                     GetPlayer()->GetName(), group->GetLeaderName(), msg.c_str());
         } break;
+
         case CHAT_MSG_BATTLEGROUND_LEADER:
         {
             std::string msg="";
             recv_data >> msg;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             //battleground raid is always in Player->GetGroup(), never in GetOriginalGroup()
             Group *group = GetPlayer()->GetGroup();
             if(!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetGUID()))
                 return;
+
             WorldPacket data;
             ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND_LEADER, lang, "", 0, msg.c_str(),NULL);
             group->BroadcastPacket(&data, false);
+
             if(sWorld.getConfig(CONFIG_CHATLOG_BGROUND))
                 sLog.outChat("[RAID] Leader player %s tells battleground: %s",
                     GetPlayer()->GetName(), msg.c_str());
         } break;
+
         case CHAT_MSG_CHANNEL:
         {
             std::string channel = "", msg = "";
             recv_data >> channel;
+
             recv_data >> msg;
+
             if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
                 return;
+
             if(msg.empty())
                 break;
+
             if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
             {
                 Channel *chn = cMgr->GetChannel(channel,_player);
                 if(chn)
                 {
                     chn->Say(_player->GetGUID(),msg.c_str(),lang);
+
                     if((chn->HasFlag(CHANNEL_FLAG_TRADE) ||
                         chn->HasFlag(CHANNEL_FLAG_GENERAL) ||
                         chn->HasFlag(CHANNEL_FLAG_CITY) ||
@@ -442,10 +533,12 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
                 }
             }
         } break;
+
         case CHAT_MSG_AFK:
         {
             std::string msg;
             recv_data >> msg;
+
             if((msg.empty() || !_player->isAFK()) && !_player->isInCombat() )
             {
                 if(!_player->isAFK())
@@ -459,10 +552,12 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
                     _player->ToggleDND();
             }
         } break;
+
         case CHAT_MSG_DND:
         {
             std::string msg;
             recv_data >> msg;
+
             if(msg.empty() || !_player->isDND())
             {
                 if(!_player->isDND())
@@ -476,19 +571,23 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
                     _player->ToggleAFK();
             }
         } break;
+
         default:
             sLog.outError("CHAT: unknown message type %u, lang: %u", type, lang);
             break;
     }
 }
+
 void WorldSession::HandleEmoteOpcode( WorldPacket & recv_data )
 {
     if(!GetPlayer()->isAlive())
         return;
+
     uint32 emote;
     recv_data >> emote;
     GetPlayer()->HandleEmoteCommand(emote);
 }
+
 namespace MaNGOS
 {
     class EmoteChatBuilder
@@ -496,10 +595,12 @@ namespace MaNGOS
         public:
             EmoteChatBuilder(Player const& pl, uint32 text_emote, uint32 emote_num, Unit const* target)
                 : i_player(pl), i_text_emote(text_emote), i_emote_num(emote_num), i_target(target) {}
+
             void operator()(WorldPacket& data, int32 loc_idx)
             {
                 char const* nam = i_target ? i_target->GetNameForLocaleIdx(loc_idx) : NULL;
                 uint32 namlen = (nam ? strlen(nam) : 0) + 1;
+
                 data.Initialize(SMSG_TEXT_EMOTE, (20+namlen));
                 data << i_player.GetGUID();
                 data << (uint32)i_text_emote;
@@ -510,6 +611,7 @@ namespace MaNGOS
                 else
                     data << (uint8)0x00;
             }
+
         private:
             Player const& i_player;
             uint32        i_text_emote;
@@ -517,25 +619,32 @@ namespace MaNGOS
             Unit const*   i_target;
     };
 }                                                           // namespace MaNGOS
+
 void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
 {
     if(!GetPlayer()->isAlive())
         return;
+
     if (!GetPlayer()->CanSpeak())
     {
         std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
         SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str());
         return;
     }
+
     uint32 text_emote, emoteNum;
     uint64 guid;
+
     recv_data >> text_emote;
     recv_data >> emoteNum;
     recv_data >> guid;
+
     EmotesTextEntry const *em = sEmotesTextStore.LookupEntry(text_emote);
     if (!em)
         return;
+
     uint32 emote_anim = em->textid;
+
     switch(emote_anim)
     {
         case EMOTE_STATE_SLEEP:
@@ -547,36 +656,47 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
             GetPlayer()->HandleEmoteCommand(emote_anim);
             break;
     }
+
     Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
+
     CellPair p = MaNGOS::ComputeCellPair(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
+
     Cell cell(p);
     cell.data.Part.reserved = ALL_DISTRICT;
     cell.SetNoCreate();
+
     MaNGOS::EmoteChatBuilder emote_builder(*GetPlayer(), text_emote, emoteNum, unit);
     MaNGOS::LocalizedPacketDo emote_do(emote_builder);
     MaNGOS::PlayerDistWorker > emote_worker(GetPlayer(),sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),emote_do);
     TypeContainerVisitor >, WorldTypeMapContainer > message(emote_worker);
     CellLock cell_lock(cell, p);
     cell_lock->Visit(cell_lock, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
+
     GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit);
+
     //Send scripted event call
     if (unit && unit->GetTypeId()==TYPEID_UNIT && ((Creature*)unit)->AI())
         ((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(),text_emote);
 }
+
 void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data )
 {
     uint64 iguid;
     uint8 unk;
     //sLog.outDebug("WORLD: Received CMSG_CHAT_IGNORED");
+
     recv_data >> iguid;
     recv_data >> unk;                                       // probably related to spam reporting
+
     Player *player = objmgr.GetPlayer(iguid);
     if(!player || !player->GetSession())
         return;
+
     WorldPacket data;
     ChatHandler::FillMessageData(&data, this, CHAT_MSG_IGNORED, LANG_UNIVERSAL, NULL, GetPlayer()->GetGUID(), GetPlayer()->GetName(),NULL);
     player->GetSession()->SendPacket(&data);
 }
+
 void WorldSession::HandleChannelDeclineInvite(WorldPacket &recvPacket)
 {
     sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
diff --git a/src/game/CombatAI.cpp b/src/game/CombatAI.cpp
index 00d06b9ec33..b18e6dd7532 100644
--- a/src/game/CombatAI.cpp
+++ b/src/game/CombatAI.cpp
@@ -17,51 +17,64 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #include "CombatAI.h"
 #include "SpellMgr.h"
+
 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;
 }
+
 void AggressorAI::UpdateAI(const uint32 /*diff*/)
 {
     if(!UpdateVictim())
         return;
+
     DoMeleeAttackIfReady();
 }
+
 // some day we will delete these useless things
 int CombatAI::Permissible(const Creature *creature)
 {
     return PERMIT_BASE_NO;
 }
+
 int ArchorAI::Permissible(const Creature *creature)
 {
     return PERMIT_BASE_NO;
 }
+
 int TurretAI::Permissible(const Creature *creature)
 {
     return PERMIT_BASE_NO;
 }
+
 void CombatAI::InitializeAI()
 {
     for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
         if(me->m_spells[i] && GetSpellStore()->LookupEntry(me->m_spells[i]))
             spells.push_back(me->m_spells[i]);
+
     CreatureAI::InitializeAI();
 }
+
 void CombatAI::Reset()
 {
     events.Reset();
 }
+
 void CombatAI::JustDied(Unit *killer)
 {
     for(SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
         if(AISpellInfo[*i].condition == AICOND_DIE)
             me->CastSpell(killer, *i, true);
 }
+
 void CombatAI::EnterCombat(Unit *who)
 {
     for(SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
@@ -72,13 +85,17 @@ void CombatAI::EnterCombat(Unit *who)
             events.ScheduleEvent(*i, AISpellInfo[*i].cooldown + rand()%AISpellInfo[*i].cooldown);
     }
 }
+
 void CombatAI::UpdateAI(const uint32 diff)
 {
     if(!UpdateVictim())
         return;
+
     events.Update(diff);
+
     if(me->hasUnitState(UNIT_STAT_CASTING))
         return;
+
     if(uint32 spellId = events.ExecuteEvent())
     {
         DoCast(spellId);
@@ -88,12 +105,15 @@ void CombatAI::UpdateAI(const uint32 diff)
         DoMeleeAttackIfReady();
 }
 
+
 /////////////////
 //CasterAI
 /////////////////
+
 void CasterAI::InitializeAI()
 {
     CombatAI::InitializeAI();
+
     float m_attackDist = 30.0f;
     for(SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr)
         if (AISpellInfo[*itr].condition == AICOND_COMBAT && m_attackDist > GetAISpellInfo(*itr)->maxRange)
@@ -101,10 +121,12 @@ void CasterAI::InitializeAI()
     if (m_attackDist == 30.0f)
         m_attackDist = MELEE_RANGE;
 }
+
 void CasterAI::EnterCombat(Unit *who)
 {
     if (spells.empty())
         return;
+
     uint32 spell = rand()%spells.size();
     uint32 count = 0;
     for(SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr, ++count)
@@ -123,13 +145,17 @@ void CasterAI::EnterCombat(Unit *who)
         }
     }
 }
+
 void CasterAI::UpdateAI(const uint32 diff)
 {
     if(!UpdateVictim())
         return;
+
     events.Update(diff);
+
     if(me->hasUnitState(UNIT_STAT_CASTING))
         return;
+
     if(uint32 spellId = events.ExecuteEvent())
     {
         DoCast(spellId);
@@ -138,9 +164,11 @@ void CasterAI::UpdateAI(const uint32 diff)
     }
 }
 
+
 //////////////
 //ArchorAI
 //////////////
+
 ArchorAI::ArchorAI(Creature *c) : CreatureAI(c)
 {
     ASSERT(me->m_spells[0]);
@@ -150,10 +178,12 @@ ArchorAI::ArchorAI(Creature *c) : CreatureAI(c)
     me->m_CombatDistance = GetSpellMaxRange(me->m_spells[0], false);
     me->m_SightDistance = me->m_CombatDistance;
 }
+
 void ArchorAI::AttackStart(Unit *who)
 {
     if(!who)
         return;
+
     if(me->IsWithinCombatRange(who, m_minRange))
     {
         if(me->Attack(who, true) && !who->IsFlying())
@@ -164,22 +194,27 @@ void ArchorAI::AttackStart(Unit *who)
         if(me->Attack(who, false) && !who->IsFlying())
             me->GetMotionMaster()->MoveChase(who, me->m_CombatDistance);
     }
+
     if(who->IsFlying())
         me->GetMotionMaster()->MoveIdle();
 }
+
 void ArchorAI::UpdateAI(const uint32 diff)
 {
     if(!UpdateVictim())
         return;
+
     if(!me->IsWithinCombatRange(me->getVictim(), m_minRange))
         DoSpellAttackIfReady(me->m_spells[0]);
     else
         DoMeleeAttackIfReady();
 }
 
+
 //////////////
 //TurretAI
 //////////////
+
 TurretAI::TurretAI(Creature *c) : CreatureAI(c)
 {
     ASSERT(me->m_spells[0]);
@@ -187,6 +222,7 @@ TurretAI::TurretAI(Creature *c) : CreatureAI(c)
     me->m_CombatDistance = GetSpellMaxRange(me->m_spells[0], false);
     me->m_SightDistance = me->m_CombatDistance;
 }
+
 bool TurretAI::CanAIAttack(const Unit *who) const
 {
     // TODO: use one function to replace it
@@ -195,16 +231,20 @@ bool TurretAI::CanAIAttack(const Unit *who) const
         return false;
     return true;
 }
+
 void TurretAI::AttackStart(Unit *who)
 {
     if(who)
         me->Attack(who, false);
 }
+
 void TurretAI::UpdateAI(const uint32 diff)
 {
     if(!UpdateVictim())
         return;
+
     DoSpellAttackIfReady(me->m_spells[0]);
+
     //if(!DoSpellAttackIfReady(me->m_spells[0]))
         //if(HostilReference *ref = me->getThreatManager().getCurrentVictim())
             //ref->removeReference();
diff --git a/src/game/CombatAI.h b/src/game/CombatAI.h
index d63ee424bf5..5ded95601ae 100644
--- a/src/game/CombatAI.h
+++ b/src/game/CombatAI.h
@@ -17,23 +17,31 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_COMBATAI_H
 #define TRINITY_COMBATAI_H
+
 #include "CreatureAI.h"
 #include "CreatureAIImpl.h"
+
 class Creature;
+
 class TRINITY_DLL_DECL AggressorAI : public CreatureAI
 {
     public:
         explicit AggressorAI(Creature *c) : CreatureAI(c) {}
+
         void UpdateAI(const uint32);
         static int Permissible(const Creature *);
 };
+
 typedef std::vector SpellVct;
+
 class TRINITY_DLL_SPEC CombatAI : public CreatureAI
 {
     public:
         explicit CombatAI(Creature *c) : CreatureAI(c) {}
+
         void InitializeAI();
         void Reset();
         void EnterCombat(Unit* who);
@@ -44,6 +52,7 @@ class TRINITY_DLL_SPEC CombatAI : public CreatureAI
         EventMap events;
         SpellVct spells;
 };
+
 class TRINITY_DLL_SPEC CasterAI : public CombatAI
 {
     public:
@@ -55,16 +64,19 @@ class TRINITY_DLL_SPEC CasterAI : public CombatAI
     private:
         float m_attackDist;
 };
+
 struct TRINITY_DLL_SPEC ArchorAI : public CreatureAI
 {
     public:
         explicit ArchorAI(Creature *c);
         void AttackStart(Unit *who);
         void UpdateAI(const uint32 diff);
+
         static int Permissible(const Creature *);
     protected:
         float m_minRange;
 };
+
 struct TRINITY_DLL_SPEC TurretAI : public CreatureAI
 {
     public:
@@ -72,8 +84,10 @@ struct TRINITY_DLL_SPEC TurretAI : public CreatureAI
         bool CanAIAttack(const Unit *who) const;
         void AttackStart(Unit *who);
         void UpdateAI(const uint32 diff);
+
         static int Permissible(const Creature *);
     protected:
         float m_minRange;
 };
+
 #endif
diff --git a/src/game/CombatHandler.cpp b/src/game/CombatHandler.cpp
index 80ca6ba3532..095986303f8 100644
--- a/src/game/CombatHandler.cpp
+++ b/src/game/CombatHandler.cpp
@@ -17,6 +17,7 @@
  * 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 "WorldPacket.h"
@@ -24,47 +25,61 @@
 #include "ObjectAccessor.h"
 #include "CreatureAI.h"
 #include "ObjectDefines.h"
+
 void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
 {
     uint64 guid;
     recv_data >> guid;
+
     DEBUG_LOG( "WORLD: Recvd CMSG_ATTACKSWING Message guidlow:%u guidhigh:%u", GUID_LOPART(guid), GUID_HIPART(guid) );
+
     Unit *pEnemy = ObjectAccessor::GetUnit(*_player, guid);
+
     if(!pEnemy)
     {
         if(!IS_UNIT_GUID(guid))
             sLog.outError("WORLD: Object %u (TypeID: %u) isn't player, pet or creature",GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)));
         else
             sLog.outError( "WORLD: Enemy %s %u not found",GetLogNameForGuid(guid),GUID_LOPART(guid));
+
         // stop attack state at client
         SendAttackStop(NULL);
         return;
     }
+
     if(!_player->canAttack(pEnemy))
     {
         sLog.outError( "WORLD: Enemy %s %u is friendly",(IS_PLAYER_GUID(guid) ? "player" : "creature"),GUID_LOPART(guid));
+
         // stop attack state at client
         SendAttackStop(pEnemy);
         return;
     }
+
     _player->Attack(pEnemy,true);
 }
+
 void WorldSession::HandleAttackStopOpcode( WorldPacket & /*recv_data*/ )
 {
     GetPlayer()->AttackStop();
 }
+
 void WorldSession::HandleSetSheathedOpcode( WorldPacket & recv_data )
 {
     uint32 sheathed;
     recv_data >> sheathed;
+
     //sLog.outDebug( "WORLD: Recvd CMSG_SETSHEATHED Message guidlow:%u value1:%u", GetPlayer()->GetGUIDLow(), sheathed );
+
     if(sheathed >= MAX_SHEATH_STATE)
     {
         sLog.outError("Unknown sheath state %u ??",sheathed);
         return;
     }
+
     GetPlayer()->SetSheath(SheathState(sheathed));
 }
+
 void WorldSession::SendAttackStop(Unit const* enemy)
 {
     WorldPacket data( SMSG_ATTACKSTOP, (4+20) );            // we guess size
diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp
index 76531d35f01..23477c6e62f 100644
--- a/src/game/ConfusedMovementGenerator.cpp
+++ b/src/game/ConfusedMovementGenerator.cpp
@@ -17,16 +17,19 @@
  * 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 "MapManager.h"
 #include "Opcodes.h"
 #include "ConfusedMovementGenerator.h"
 #include "DestinationHolderImp.h"
 #include "VMapFactory.h"
+
 #ifdef MAP_BASED_RAND_GEN
 #define rand_norm() unit.rand_norm()
 #define urand(a,b) unit.urand(a,b)
 #endif
+
 template
 void
 ConfusedMovementGenerator::Initialize(T &unit)
@@ -36,26 +39,35 @@ ConfusedMovementGenerator::Initialize(T &unit)
     x = unit.GetPositionX();
     y = unit.GetPositionY();
     z = unit.GetPositionZ();
+
     Map const* map = unit.GetBaseMap();
+
     i_nextMove = 1;
+
     bool is_water_ok, is_land_ok;
     _InitSpecific(unit, is_water_ok, is_land_ok);
+
     VMAP::IVMapManager *vMaps = VMAP::VMapFactory::createOrGetVMapManager();
+
     for(unsigned int idx=0; idx < MAX_CONF_WAYPOINTS+1; ++idx)
     {
         const float wanderX=wander_distance*rand_norm() - wander_distance/2;
         const float wanderY=wander_distance*rand_norm() - wander_distance/2;
-        const bool isInLoS = vMaps->isInLineOfSight(unit.GetMapId(), x, y, z + 2.0f, i_waypoints[idx][0], i_waypoints[idx][1], z + 2.0f);
+
+        const bool isInLoS = vMaps->isInLineOfSight(unit.GetMapId(), x, y, z + 2.0f, i_waypoints[idx][0], i_waypoints[idx][1], z + 2.0f); 
         if (!isInLoS)
         {
-            i_waypoints[idx][0] = x;
+            i_waypoints[idx][0] = x; 
             i_waypoints[idx][1] = y;
         }
+
         i_waypoints[idx][0] = x + wanderX;
         i_waypoints[idx][1] = y + wanderY;
+
         // prevent invalid coordinates generation
         Trinity::NormalizeMapCoord(i_waypoints[idx][0]);
         Trinity::NormalizeMapCoord(i_waypoints[idx][1]);
+
         bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1],z);
         // if generated wrong path just ignore
         if ((is_water && !is_water_ok) || (!is_water && !is_land_ok))
@@ -63,9 +75,11 @@ ConfusedMovementGenerator::Initialize(T &unit)
             i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x;
             i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y;
         }
+
         unit.UpdateGroundPositionZ(i_waypoints[idx][0],i_waypoints[idx][1],z);
         i_waypoints[idx][2] =  z;
     }
+
     unit.SetUInt64Value(UNIT_FIELD_TARGET, 0);
     unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
     unit.CastStop();
@@ -73,6 +87,7 @@ ConfusedMovementGenerator::Initialize(T &unit)
     unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
     unit.addUnitState(UNIT_STAT_CONFUSED);
 }
+
 template<>
 void
 ConfusedMovementGenerator::_InitSpecific(Creature &creature, bool &is_water_ok, bool &is_land_ok)
@@ -80,6 +95,7 @@ ConfusedMovementGenerator::_InitSpecific(Creature &creature, bool &is_
     is_water_ok = creature.canSwim();
     is_land_ok  = creature.canWalk();
 }
+
 template<>
 void
 ConfusedMovementGenerator::_InitSpecific(Player &, bool &is_water_ok, bool &is_land_ok)
@@ -87,6 +103,7 @@ ConfusedMovementGenerator::_InitSpecific(Player &, bool &is_water_ok, bo
     is_water_ok = true;
     is_land_ok  = true;
 }
+
 template
 void
 ConfusedMovementGenerator::Reset(T &unit)
@@ -96,14 +113,17 @@ ConfusedMovementGenerator::Reset(T &unit)
     i_destinationHolder.ResetUpdate();
     unit.StopMoving();
 }
+
 template
 bool
 ConfusedMovementGenerator::Update(T &unit, const uint32 &diff)
 {
     if(!&unit)
         return true;
+
     if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED))
         return true;
+
     if( i_nextMoveTime.Passed() )
     {
         // currently moving, update location
@@ -114,6 +134,7 @@ ConfusedMovementGenerator::Update(T &unit, const uint32 &diff)
             {
                 // arrived, stop and wait a bit
                 unit.clearUnitState(UNIT_STAT_MOVE);
+
                 i_nextMove = urand(1,MAX_CONF_WAYPOINTS);
                 i_nextMoveTime.Reset(urand(0, 1500-1));     // TODO: check the minimum reset time, should be probably higher
             }
@@ -136,6 +157,7 @@ ConfusedMovementGenerator::Update(T &unit, const uint32 &diff)
     }
     return true;
 }
+
 template
 void
 ConfusedMovementGenerator::Finalize(T &unit)
@@ -145,6 +167,7 @@ ConfusedMovementGenerator::Finalize(T &unit)
     if(unit.GetTypeId() == TYPEID_UNIT && unit.getVictim())
         unit.SetUInt64Value(UNIT_FIELD_TARGET, unit.getVictim()->GetGUID());
 }
+
 template void ConfusedMovementGenerator::Initialize(Player &player);
 template void ConfusedMovementGenerator::Initialize(Creature &creature);
 template void ConfusedMovementGenerator::Finalize(Player &player);
diff --git a/src/game/ConfusedMovementGenerator.h b/src/game/ConfusedMovementGenerator.h
index 0675ea49e4c..ad47b13cb39 100644
--- a/src/game/ConfusedMovementGenerator.h
+++ b/src/game/ConfusedMovementGenerator.h
@@ -17,28 +17,35 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_CONFUSEDGENERATOR_H
 #define TRINITY_CONFUSEDGENERATOR_H
+
 #include "MovementGenerator.h"
 #include "DestinationHolder.h"
 #include "Traveller.h"
+
 #define MAX_CONF_WAYPOINTS 24
+
 template
 class TRINITY_DLL_SPEC ConfusedMovementGenerator
 : public MovementGeneratorMedium< T, ConfusedMovementGenerator >
 {
     public:
         explicit ConfusedMovementGenerator() : i_nextMoveTime(0) {}
+
         void Initialize(T &);
         void Finalize(T &);
         void Reset(T &);
         bool Update(T &, const uint32 &);
+
         bool GetDestination(float &x, float &y, float &z) const
         {
             if(i_destinationHolder.HasArrived()) return false;
             i_destinationHolder.GetDestination(x,y,z);
             return true;
         }
+
         MovementGeneratorType GetMovementGeneratorType() { return CONFUSED_MOTION_TYPE; }
     private:
         void _InitSpecific(T &, bool &, bool &);
diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp
index 350e314152d..16e52ef46aa 100644
--- a/src/game/Corpse.cpp
+++ b/src/game/Corpse.cpp
@@ -17,6 +17,7 @@
  * 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 "Corpse.h"
 #include "Player.h"
@@ -26,65 +27,87 @@
 #include "Opcodes.h"
 #include "GossipDef.h"
 #include "World.h"
+
 Corpse::Corpse(CorpseType type) : WorldObject()
 , m_type(type)
 {
     m_objectType |= TYPEMASK_CORPSE;
     m_objectTypeId = TYPEID_CORPSE;
+
     m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION);
+
     m_valuesCount = CORPSE_END;
+
     m_time = time(NULL);
+
     lootForBody = false;
+
     if(type != CORPSE_BONES)
         m_isWorldObject = true;
 }
+
 Corpse::~Corpse()
 {
 }
+
 void Corpse::AddToWorld()
 {
     ///- Register the corpse for guid lookup
     if(!IsInWorld())
         ObjectAccessor::Instance().AddObject(this);
+
     Object::AddToWorld();
 }
+
 void Corpse::RemoveFromWorld()
 {
     ///- Remove the corpse from the accessor
     if(IsInWorld())
         ObjectAccessor::Instance().RemoveObject(this);
+
     Object::RemoveFromWorld();
 }
+
 bool Corpse::Create( uint32 guidlow, Map *map )
 {
     SetMap(map);
     Object::_Create(guidlow, 0, HIGHGUID_CORPSE);
     return true;
 }
+
 bool Corpse::Create( uint32 guidlow, Player *owner)
 {
     ASSERT(owner);
+
     Relocate(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ(), owner->GetOrientation());
+
     if(!IsPositionValid())
     {
         sLog.outError("Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
             guidlow, owner->GetName(), owner->GetPositionX(), owner->GetPositionY());
         return false;
     }
+
     //we need to assign owner's map for corpse
     //in other way we will get a crash in Corpse::SaveToDB()
     SetMap(owner->GetMap());
+
     WorldObject::_Create(guidlow, HIGHGUID_CORPSE, owner->GetPhaseMask());
+
     SetFloatValue( OBJECT_FIELD_SCALE_X, 1 );
     SetUInt64Value( CORPSE_FIELD_OWNER, owner->GetGUID() );
+
     m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY());
+
     return true;
 }
+
 void Corpse::SaveToDB()
 {
     // prevent DB data inconsistence problems and duplicates
     CharacterDatabase.BeginTransaction();
     DeleteFromDB();
+
     std::ostringstream ss;
     ss  << "INSERT INTO corpse (guid,player,position_x,position_y,position_z,orientation,zone,map,data,time,corpse_type,instance,phaseMask) VALUES ("
         << GetGUIDLow() << ", "
@@ -105,17 +128,21 @@ void Corpse::SaveToDB()
     CharacterDatabase.Execute( ss.str().c_str() );
     CharacterDatabase.CommitTransaction();
 }
+
 void Corpse::DeleteBonesFromWorld()
 {
     assert(GetType() == CORPSE_BONES);
     Corpse* corpse = ObjectAccessor::GetCorpse(*this, GetGUID());
+
     if (!corpse)
     {
         sLog.outError("Bones %u not found in world.", GetGUIDLow());
         return;
     }
+
     AddObjectToRemoveList();
 }
+
 void Corpse::DeleteFromDB()
 {
     if(GetType() == CORPSE_BONES)
@@ -125,6 +152,7 @@ void Corpse::DeleteFromDB()
         // all corpses (not bones)
         CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%d' AND corpse_type <> '0'",  GUID_LOPART(GetOwnerGUID()));
 }
+
 /*
 bool Corpse::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId)
 {
@@ -132,22 +160,29 @@ bool Corpse::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId)
     if (!external)
         //                                        0          1          2          3           4   5    6    7           8        9
         result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,data,time,corpse_type,instance,phaseMask FROM corpse WHERE guid = '%u'",guid);
+
     if( !result )
     {
         sLog.outError("Corpse (GUID: %u) not found in table `corpse`, can't load. ",guid);
         return false;
     }
+
     Field *fields = result->Fetch();
+
     if(!LoadFromDB(guid, fields))
     {
         if (!external)
             delete result;
+
         return false;
     }
+
     if (!external)
         delete result;
+
     return true;
 }*/
+
 bool Corpse::LoadFromDB(uint32 guid, Field *fields)
 {
     //                                          0          1          2          3           4   5    6    7           8        9
@@ -157,39 +192,52 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
     float positionZ = fields[2].GetFloat();
     float ort       = fields[3].GetFloat();
     uint32 mapid    = fields[4].GetUInt32();
+
     Object::_Create(guid, 0, HIGHGUID_CORPSE);
+
     if(!LoadValues( fields[5].GetString() ))
     {
         sLog.outError("Corpse #%d have broken data in `data` field. Can't be loaded.",guid);
         return false;
     }
+
     m_time = time_t(fields[6].GetUInt64());
     m_type = CorpseType(fields[7].GetUInt32());
+
     if(m_type >= MAX_CORPSE_TYPE)
     {
         sLog.outError("Corpse (guidlow %d, owner %d) have wrong corpse type, not load.",GetGUIDLow(),GUID_LOPART(GetOwnerGUID()));
         return false;
     }
+
     if(m_type != CORPSE_BONES)
         m_isWorldObject = true;
+
     uint32 instanceid  = fields[8].GetUInt32();
+
     uint32 phaseMask   = fields[9].GetUInt32();
+
     // overwrite possible wrong/corrupted guid
     SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE));
+
     // place
     SetLocationInstanceId(instanceid);
     SetLocationMapId(mapid);
     SetPhaseMask(phaseMask, false);
     Relocate(positionX, positionY, positionZ, ort);
+
     if(!IsPositionValid())
     {
         sLog.outError("Corpse (guidlow %d, owner %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
             GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), GetPositionX(), GetPositionY());
         return false;
     }
+
     m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY());
+
     return true;
 }
+
 bool Corpse::isVisibleForInState(Player const* u, bool inVisibleList) const
 {
     return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u->m_seer, World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
diff --git a/src/game/Corpse.h b/src/game/Corpse.h
index ca9a16d8ced..e0374a03470 100644
--- a/src/game/Corpse.h
+++ b/src/game/Corpse.h
@@ -17,12 +17,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITYCORE_CORPSE_H
 #define TRINITYCORE_CORPSE_H
+
 #include "Object.h"
 #include "Database/DatabaseEnv.h"
 #include "GridDefines.h"
 #include "LootMgr.h"
+
 enum CorpseType
 {
     CORPSE_BONES             = 0,
@@ -30,8 +33,10 @@ enum CorpseType
     CORPSE_RESURRECTABLE_PVP = 2
 };
 #define MAX_CORPSE_TYPE        3
+
 // Value equal client resurrection dialog show radius.
 #define CORPSE_RECLAIM_RADIUS 39
+
 enum CorpseFlags
 {
     CORPSE_FLAG_NONE        = 0x00,
@@ -42,38 +47,51 @@ enum CorpseFlags
     CORPSE_FLAG_HIDE_CLOAK  = 0x10,
     CORPSE_FLAG_LOOTABLE    = 0x20
 };
+
 class Corpse : public WorldObject
 {
     public:
         explicit Corpse( CorpseType type = CORPSE_BONES );
         ~Corpse( );
+
         void AddToWorld();
         void RemoveFromWorld();
+
         bool Create( uint32 guidlow, Map *map );
         bool Create( uint32 guidlow, Player *owner );
+
         void SaveToDB();
         //bool LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId);
         bool LoadFromDB(uint32 guid, Field *fields);
+
         void DeleteBonesFromWorld();
         void DeleteFromDB();
+
         uint64 const& GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
+
         time_t const& GetGhostTime() const { return m_time; }
         void ResetGhostTime() { m_time = time(NULL); }
         CorpseType GetType() const { return m_type; }
+
         GridPair const& GetGrid() const { return m_grid; }
         void SetGrid(GridPair const& grid) { m_grid = grid; }
+
         bool isVisibleForInState(Player const* u, bool inVisibleList) const;
+
         Loot loot;                                          // remove insignia ONLY at BG
         Player* lootRecipient;
         bool lootForBody;
+
         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) { MonsterTextEmote(textId,TargetGuid); }
         void Whisper(int32 textId,uint64 receiver) { MonsterWhisper(textId,receiver); }
         void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
+
         GridReference &GetGridRef() { return m_gridRef; }
     private:
         GridReference m_gridRef;
+
         CorpseType m_type;
         time_t m_time;
         GridPair m_grid;                                    // gride for corpse position for fast search
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 63c9d34d157..a3a2e5c1690 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -17,6 +17,7 @@
  * 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"
@@ -48,13 +49,16 @@
 #include "Vehicle.h"
 // apply implementation of the singletons
 #include "Policies/SingletonImp.h"
+
 TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
 {
     TrainerSpellMap::const_iterator itr = spellList.find(spell_id);
     if (itr != spellList.end())
         return &itr->second;
+
     return NULL;
 }
+
 bool VendorItemData::RemoveItem( uint32 item_id )
 {
     for(VendorItemList::iterator i = m_items.begin(); i != m_items.end(); ++i )
@@ -67,6 +71,7 @@ bool VendorItemData::RemoveItem( uint32 item_id )
     }
     return false;
 }
+
 size_t VendorItemData::FindItemSlot(uint32 item_id) const
 {
     for(size_t i = 0; i < m_items.size(); ++i )
@@ -74,6 +79,7 @@ size_t VendorItemData::FindItemSlot(uint32 item_id) const
             return i;
     return m_items.size();
 }
+
 VendorItem const* VendorItemData::FindItem(uint32 item_id) const
 {
     for(VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i )
@@ -81,16 +87,20 @@ VendorItem const* VendorItemData::FindItem(uint32 item_id) const
             return *i;
     return NULL;
 }
+
 uint32 CreatureInfo::GetRandomValidModelId() const
 {
     uint8 c = 0;
     uint32 modelIDs[4];
+
     if (Modelid1) modelIDs[c++] = Modelid1;
     if (Modelid2) modelIDs[c++] = Modelid2;
     if (Modelid3) modelIDs[c++] = Modelid3;
     if (Modelid4) modelIDs[c++] = Modelid4;
+
     return ((c>0) ? modelIDs[urand(0,c-1)] : 0);
 }
+
 uint32 CreatureInfo::GetFirstValidModelId() const
 {
     if(Modelid1) return Modelid1;
@@ -99,6 +109,7 @@ uint32 CreatureInfo::GetFirstValidModelId() const
     if(Modelid4) return Modelid4;
     return 0;
 }
+
 bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
 {
     if(Unit* victim = Unit::GetUnit(m_owner, m_victim))
@@ -107,6 +118,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
         {
             Creature* assistant = Unit::GetCreature(m_owner, *m_assistants.begin());
             m_assistants.pop_front();
+
             if (assistant && assistant->CanAssistTo(&m_owner, victim))
             {
                 assistant->SetNoCallAssistance(true);
@@ -118,6 +130,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
     }
     return true;
 }
+
 Creature::Creature() :
 Unit(),
 lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
@@ -132,27 +145,34 @@ m_creatureInfo(NULL), m_reactState(REACT_AGGRESSIVE), m_formation(NULL)
 {
     m_regenTimer = 200;
     m_valuesCount = UNIT_END;
+
     for(uint8 i =0; iInstall();
     }
 }
+
 void Creature::RemoveFromWorld()
 {
     if(IsInWorld())
@@ -180,6 +201,7 @@ void Creature::RemoveFromWorld()
         ObjectAccessor::Instance().RemoveObject(this);
     }
 }
+
 void Creature::DisappearAndDie()
 {
     DestroyForNearbyPlayers();
@@ -189,21 +211,26 @@ void Creature::DisappearAndDie()
         setDeathState(JUST_DIED);
     RemoveCorpse();
 }
+
 void Creature::SearchFormation()
 {
     if(isSummon())
         return;
+
     uint32 lowguid = GetDBTableGUIDLow();
     if(!lowguid)
         return;
+
     CreatureGroupInfoType::iterator frmdata = CreatureGroupMap.find(lowguid);
     if(frmdata != CreatureGroupMap.end())
         formation_mgr.AddCreatureToGroup(frmdata->second->leaderGUID, this);
 }
+
 void Creature::RemoveCorpse()
 {
     if ((getDeathState()!=CORPSE && !m_isDeadByDefault) || (getDeathState()!=ALIVE && m_isDeadByDefault))
         return;
+
     m_deathTimer = 0;
     setDeathState(DEAD);
     ObjectAccessor::UpdateObjectVisibility(this);
@@ -211,12 +238,15 @@ void Creature::RemoveCorpse()
     uint32 respawnDelay = m_respawnDelay;
     if (AI())
         AI()->CorpseRemoved(respawnDelay);
+
     m_respawnTime = time(NULL) + m_respawnDelay;
+
     float x,y,z,o;
     GetRespawnCoord(x, y, z, &o);
     SetHomePosition(x,y,z,o);
     GetMap()->CreatureRelocation(this,x,y,z,o);
 }
+
 /**
  * change the entry of creature until respawn
  */
@@ -228,6 +258,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
         sLog.outErrorDb("Creature::UpdateEntry creature entry %u does not exist.", Entry);
         return false;
     }
+
     // get heroic mode entry
     uint32 actualEntry = Entry;
     CreatureInfo const *cinfo = normalInfo;
@@ -244,18 +275,23 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
             }
         }
     }
+
     SetEntry(Entry);                                        // normal entry always
     m_creatureInfo = cinfo;                                 // map mode related always
+
     // equal to player Race field, but creature does not have race
     SetByteValue(UNIT_FIELD_BYTES_0, 0, 0);
+
     // known valid are: CLASS_WARRIOR,CLASS_PALADIN,CLASS_ROGUE,CLASS_MAGE
     SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class));
+
     // Cancel load if no model defined
     if (!(cinfo->GetFirstValidModelId()))
     {
         sLog.outErrorDb("Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ",Entry);
         return false;
     }
+
     uint32 display_id = objmgr.ChooseDisplayId(0, GetCreatureInfo(), data);
     CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id);
     if (!minfo)                                             // Cancel load if no model defined
@@ -263,10 +299,13 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
         sLog.outErrorDb("Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ",Entry);
         return false;
     }
+
     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
@@ -276,44 +315,61 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
     {                                                       // 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;
+
     for(uint8 i=0; i < CREATURE_MAX_SPELLS; ++i)
         m_spells[i] = GetCreatureInfo()->spells[i];
+
     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
     SetSheath(SHEATH_STATE_MELEE);
+
     SelectLevel(GetCreatureInfo());
     if (team == HORDE)
         setFaction(GetCreatureInfo()->faction_H);
     else
         setFaction(GetCreatureInfo()->faction_A);
+
     if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT)
         SetUInt32Value(UNIT_NPC_FLAGS,GetCreatureInfo()->npcflag | gameeventmgr.GetNPCFlag(this));
     else
         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()->unit_flags);
     SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags);
+
     RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
+
     SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));
     SetModifierValue(UNIT_MOD_ARMOR,             BASE_VALUE, float(GetCreatureInfo()->armor));
     SetModifierValue(UNIT_MOD_RESISTANCE_HOLY,   BASE_VALUE, float(GetCreatureInfo()->resistance1));
@@ -322,8 +378,10 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
     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
     {
@@ -333,9 +391,11 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
                 (factionEntry->team == ALLIANCE || factionEntry->team == HORDE) )
                 SetPvP(true);
     }
+
     // HACK: trigger creature is always not selectable
     if(isTrigger())
         SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
     if(isTotem() || isTrigger()
         || GetCreatureType() == CREATURE_TYPE_CRITTER)
         SetReactState(REACT_PASSIVE);
@@ -343,21 +403,26 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
         SetReactState(REACT_DEFENSIVE);*/
     else
         SetReactState(REACT_AGGRESSIVE);
+
     if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_TAUNT)
     {
         ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
         ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true);
     }
+
     if(GetCreatureInfo()->InhabitType & INHABIT_AIR)
         AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE + MOVEMENTFLAG_FLYING);
+
     return true;
 }
+
 void Creature::Update(uint32 diff)
 {
     if(m_GlobalCooldown <= diff)
         m_GlobalCooldown = 0;
     else
         m_GlobalCooldown -= diff;
+
     switch( m_deathState )
     {
         case JUST_ALIVED:
@@ -394,6 +459,7 @@ void Creature::Update(uint32 diff)
         {
             if (m_isDeadByDefault)
                 break;
+
             if( m_deathTimer <= diff )
             {
                 RemoveCorpse();
@@ -403,6 +469,7 @@ void Creature::Update(uint32 diff)
             {
                 // for delayed spells
                 m_Events.Update( diff );
+
                 m_deathTimer -= diff;
                 if (m_groupLootTimer && lootingGroupLeaderGUID)
                 {
@@ -420,6 +487,7 @@ void Creature::Update(uint32 diff)
                     }
                 }
             }
+
             break;
         }
         case ALIVE:
@@ -436,11 +504,14 @@ void Creature::Update(uint32 diff)
                     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 creature is charmed, switch to charmed AI
             if(NeedChangeAI)
             {
@@ -448,6 +519,7 @@ void Creature::Update(uint32 diff)
                 NeedChangeAI = false;
                 IsAIEnabled = true;
             }
+
             if(!IsInEvadeMode() && IsAIEnabled)
             {
                 // do not allow the AI to be changed during update
@@ -455,10 +527,12 @@ void Creature::Update(uint32 diff)
                 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)
@@ -466,16 +540,20 @@ void Creature::Update(uint32 diff)
                 else
                     m_regenTimer -= diff;
             }
+
             if (m_regenTimer != 0)
                break;
+
             bool bIsPolymorphed = IsPolymorphed();
             bool bInCombat = isInCombat() && (!getVictim() ||                                        // if isInCombat() is true and this has no victim
                              !getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() ||                // or the victim/owner/charmer is not a player
                              !getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()->isGameMaster()); // or the victim/owner/charmer is not a GameMaster
-            /*if(m_regenTimer <= diff)
+
+            /*if(m_regenTimer <= diff) 
             {*/
             if(!bInCombat || bIsPolymorphed) // regenerate health if not in combat or if polymorphed
                 RegenerateHealth();
+
             if(getPowerType() == POWER_ENERGY)
             {
                 if(!IsVehicle() || GetVehicleKit()->GetVehicleInfo()->m_powerType != POWER_PYRITE)
@@ -483,9 +561,10 @@ void Creature::Update(uint32 diff)
             }
             else
                 RegenerateMana();
+
             /*if(!bIsPolymorphed) // only increase the timer if not polymorphed
                     m_regenTimer += 2000 - diff;
-            }
+            }   
             else
                 if(!bIsPolymorphed) // if polymorphed, skip the timer
                     m_regenTimer -= diff;*/
@@ -498,13 +577,17 @@ void Creature::Update(uint32 diff)
             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())
     {
@@ -512,27 +595,35 @@ void Creature::RegenerateMana()
         {
             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 controlled 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
@@ -540,27 +631,35 @@ void Creature::RegenerateHealth()
     }
     else
         addvalue = maxValue/3;
+
     ModifyHealth(addvalue);
 }
+
 void Creature::DoFleeToGetAssistance()
 {
     if (!getVictim())
         return;
+
     if(HasAuraType(SPELL_AURA_PREVENTS_FLEEING))
         return;
+
     float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS);
     if (radius >0)
     {
         Creature* pCreature = NULL;
+
         CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
         Cell cell(p);
         cell.data.Part.reserved = ALL_DISTRICT;
         cell.SetNoCreate();
         MaNGOS::NearestAssistCreatureInCreatureRangeCheck u_check(this, getVictim(), radius);
         MaNGOS::CreatureLastSearcher searcher(this, pCreature, u_check);
+
         TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher);
+
         CellLock cell_lock(cell, p);
         cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, radius);
+
         SetNoSearchAssistance(true);
         if(!pCreature)
             //SetFeared(true, getVictim()->GetGUID(), 0 ,sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY));
@@ -570,6 +669,7 @@ void Creature::DoFleeToGetAssistance()
             GetMotionMaster()->MoveSeekAssistance(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ());
     }
 }
+
 bool Creature::AIM_Initialize(CreatureAI* ai)
 {
     // make sure nothing can change the AI during AI update
@@ -578,20 +678,24 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
         sLog.outDebug("AIM_Initialize: failed to init, locked.");
         return false;
     }
+
     UnitAI *oldAI = i_AI;
+
     Motion_Initialize();
+    
     i_AI = ai ? ai : FactorySelector::selectAI(this);
     if(oldAI) delete oldAI;
     IsAIEnabled = true;
     i_AI->InitializeAI();
     return true;
 }
+
 void Creature::Motion_Initialize()
 {
     if(!m_formation)
         i_motionMaster.Initialize();
     else if(m_formation->getLeader() == this)
-    {
+    {    
         m_formation->FormationReset(false);
         i_motionMaster.Initialize();
     }
@@ -600,19 +704,24 @@ void Creature::Motion_Initialize()
     else
         i_motionMaster.Initialize();
 }
+
 bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, uint32 team, float x, float y, float z, float ang, const CreatureData *data)
 {
     ASSERT(map);
     SetMap(map);
     SetPhaseMask(phaseMask,false);
+
     Relocate(x, y, z, ang);
+
     if(!IsPositionValid())
     {
         sLog.outError("Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,Entry,x,y);
         return false;
     }
+
     //oX = x;     oY = y;    dX = x;    dY = y;    m_moveTime = 0;    m_startMove = 0;
     const bool bResult = CreateFromProto(guidlow, Entry, vehId, team, data);
+
     if (bResult)
     {
         switch (GetCreatureInfo()->rank)
@@ -638,6 +747,7 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry,
         if (minfo && !isTotem())                               // Cancel load if no model defined or if totem
         {
             uint32 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);
@@ -645,17 +755,21 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry,
     }
     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:
@@ -727,13 +841,16 @@ bool Creature::isCanTrainingOf(Player* pPlayer, bool msg) const
     }
     return true;
 }
+
 bool Creature::isCanInteractWithBattleMaster(Player* pPlayer, bool msg) const
 {
     if(!isBattleMaster())
         return false;
+
     BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry());
     if(!msg)
         return pPlayer->GetBGAccessByLevel(bgTypeId);
+
     if(!pPlayer->GetBGAccessByLevel(bgTypeId))
     {
         pPlayer->PlayerTalkClass->ClearMenus();
@@ -756,22 +873,27 @@ bool Creature::isCanInteractWithBattleMaster(Player* pPlayer, bool msg) const
     }
     return true;
 }
+
 bool Creature::isCanTrainingAndResetTalentsOf(Player* pPlayer) const
 {
     return pPlayer->getLevel() >= 10
         && GetCreatureInfo()->trainer_type == TRAINER_TYPE_CLASS
         && pPlayer->getClass() == GetCreatureInfo()->trainer_class;
 }
+
 void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
 {
     //Prevent gossip from NPCs that are possessed.
     Unit* Charmed = Unit::GetCharmer();
     if (Charmed)
         return;
+
     PlayerMenu* pm=pPlayer->PlayerTalkClass;
     pm->ClearMenus();
+
     // lazy loading single time at use
     LoadGossipOptions();
+
     for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); ++i )
     {
         GossipOption* gso=&*i;
@@ -854,6 +976,7 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
                         break;
                 }
             }
+
             //note for future dev: should have database fields for BoxMessage & BoxMoney
             if(!gso->OptionText.empty() && cantalking)
             {
@@ -875,6 +998,7 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
             }
         }
     }
+
     ///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())
     {
@@ -888,30 +1012,38 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
         }
     }
 }
+
 void Creature::sendPreparedGossip(Player* player)
 {
     if(!player)
         return;
+
     if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT) // if world event npc then
         gameeventmgr.HandleWorldEventGossip(player, this);      // update world state with progress
+
     // in case no gossip flag and quest menu not empty, open quest menu (client expect gossip menu with this flag)
     if (!HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_GOSSIP) && !player->PlayerTalkClass->GetQuestMenu().Empty())
     {
         player->SendPreparedQuest(GetGUID());
         return;
     }
+
     // in case non empty gossip menu (that not included quests list size) show it
     // (quest entries from quest menu will 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 );
     if(!gossip)
     {
@@ -920,6 +1052,7 @@ void Creature::OnGossipSelect(Player* player, uint32 option)
         if(!gossip)
             return;
     }
+
     switch (gossip->Action)
     {
         case GOSSIP_OPTION_GOSSIP:
@@ -927,6 +1060,7 @@ void Creature::OnGossipSelect(Player* player, uint32 option)
             uint32 textid = GetGossipTextId(action, zoneid);
             if (textid == 0)
                 textid=GetNpcTextId();
+
             player->PlayerTalkClass->CloseGossip();
             player->PlayerTalkClass->SendTalking(textid);
             break;
@@ -968,10 +1102,12 @@ void Creature::OnGossipSelect(Player* player, uint32 option)
                 else
                 {
                     player->ModifyMoney(-10000000);
+
                     // Cast spells that teach dual spec
                     // Both are also ImplicitTarget self and must be cast by player
                     player->CastSpell(player,63680,true,NULL,NULL,player->GetGUID());
                     player->CastSpell(player,63624,true,NULL,NULL,player->GetGUID());
+
                     // Should show another Gossip text with "Congratulations..."
                     player->PlayerTalkClass->CloseGossip();
                 }
@@ -1018,7 +1154,9 @@ void Creature::OnGossipSelect(Player* player, uint32 option)
             OnPoiSelect( player, gossip );
             break;
     }
+
 }
+
 void Creature::OnPoiSelect(Player* player, GossipOption const *gossip)
 {
     if(gossip->GossipId==GOSSIP_GUARD_SPELLTRAINER || gossip->GossipId==GOSSIP_GUARD_SKILLTRAINER)
@@ -1046,28 +1184,38 @@ void Creature::OnPoiSelect(Player* player, GossipOption const *gossip)
         // 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()
 {
     // don't cache / use cache in case it's a world event announcer
     if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT)
         if(uint32 textid = gameeventmgr.GetNpcTextId(m_DBTableGuid))
             return textid;
+
     if (!m_DBTableGuid)
         return DEFAULT_GOSSIP_MESSAGE;
+
     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 )
@@ -1077,22 +1225,28 @@ GossipOption const* Creature::GetGossipOption( uint32 id ) const
     }
     return NULL;
 }
+
 void Creature::ResetGossipOptions()
 {
     m_gossipOptionLoaded = false;
     m_goptions.clear();
 }
+
 void Creature::LoadGossipOptions()
 {
     if(m_gossipOptionLoaded)
         return;
+
     uint32 npcflags=GetUInt32Value(UNIT_NPC_FLAGS);
+
     CacheNpcOptionList const& noList = objmgr.GetNpcOptions ();
     for (CacheNpcOptionList::const_iterator i = noList.begin (); i != noList.end (); ++i)
         if(i->NpcFlag & npcflags)
             addGossipOption(*i);
+
     m_gossipOptionLoaded = true;
 }
+
 void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type)
 {
     /*    uint32 timeElap = getMSTime();
@@ -1106,23 +1260,28 @@ void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint3
             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, 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;
@@ -1130,12 +1289,15 @@ void Creature::SetLootRecipient(Unit *unit)
         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
@@ -1146,15 +1308,19 @@ void Creature::SaveToDB()
         sLog.outError("Creature::SaveToDB failed, cannot get creature data!");
         return;
     }
+
     SaveToDB(GetMapId(), data->spawnMask,GetPhaseMask());
 }
+
 void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
 {
     // update in loaded data
     if (!m_DBTableGuid)
         m_DBTableGuid = GetGUIDLow();
     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)
@@ -1163,6 +1329,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
             displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
             displayId = 0;
     }
+
     // data->guid = guid don't must be update at save
     data.id = GetEntry();
     data.mapid = mapid;
@@ -1184,9 +1351,12 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
     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 << ","
@@ -1207,46 +1377,64 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
         << 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);
     ResetPlayerDamageReq();
+
     // 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);
+
     // TODO: set UNIT_FIELD_POWER*, for some creature class case (energy, etc)
+
     SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, health);
     SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, mana);
 
+
     //damage
     float damagemod = 1.0f;//_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
@@ -1265,6 +1453,7 @@ float Creature::_GetHealthMod(int32 Rank)
             return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP);
     }
 }
+
 float Creature::_GetDamageMod(int32 Rank)
 {
     switch (Rank)                                           // define rates for each elite rank
@@ -1283,6 +1472,7 @@ float Creature::_GetDamageMod(int32 Rank)
             return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE);
     }
 }
+
 float Creature::GetSpellDamageMod(int32 Rank)
 {
     switch (Rank)                                           // define rates for each elite rank
@@ -1301,6 +1491,7 @@ float Creature::GetSpellDamageMod(int32 Rank)
             return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
     }
 }
+
 bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, uint32 team, const CreatureData *data)
 {
     SetZoneScript();
@@ -1310,41 +1501,56 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, uint3
         if(!Entry)
             return false;
     }
+
     CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry);
     if(!cinfo)
     {
         sLog.outErrorDb("Creature entry %u does not exist.", Entry);
         return false;
     }
+
     SetOriginalEntry(Entry);
+
     if(!vehId)
         vehId = cinfo->VehicleId;
+
     if(vehId && !CreateVehicleKit(vehId))
         vehId = 0;
+
     Object::_Create(guidlow, Entry, vehId ? HIGHGUID_VEHICLE : HIGHGUID_UNIT);
+
     if(!UpdateEntry(Entry, team, data))
         return false;
+
     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;
     }
+
     m_DBTableGuid = guid;
     if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT);
+
     uint16 team = 0;
     if(!Create(guid,map,data->phaseMask,data->id,0,team,data->posX,data->posY,data->posZ,data->orientation,data))
         return false;
+
     //We should set first home position, because then AI calls home movement
     SetHomePosition(data->posX,data->posY,data->posZ,data->orientation);
+
     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)                          // respawn on Update
     {
@@ -1356,6 +1562,7 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
                 Relocate(data->posX,data->posY,tz);
         }
     }
+
     uint32 curhealth = data->curhealth;
     if(curhealth)
     {
@@ -1363,13 +1570,18 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
         if(curhealth < 1)
             curhealth = 1;
     }
+
     SetHealth(m_deathState == ALIVE ? curhealth : 0);
     SetPower(POWER_MANA,data->curmana);
+
     // checked at creature_template loading
     m_defaultMovementType = MovementGeneratorType(data->movementType);
+
     m_creatureData = data;
+
     return true;
 }
+
 void Creature::LoadEquipment(uint32 equip_entry, bool force)
 {
     if(equip_entry == 0)
@@ -1382,13 +1594,16 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force)
         }
         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_ID + i, einfo->equipentry[i]);
 }
+
 bool Creature::hasQuest(uint32 quest_id) const
 {
     QuestRelations const& qr = objmgr.mCreatureQuestRelations;
@@ -1399,6 +1614,7 @@ bool Creature::hasQuest(uint32 quest_id) const
     }
     return false;
 }
+
 bool Creature::hasInvolvedQuest(uint32 quest_id) const
 {
     QuestRelations const& qr = objmgr.mCreatureQuestInvolvedRelations;
@@ -1409,6 +1625,7 @@ bool Creature::hasInvolvedQuest(uint32 quest_id) const
     }
     return false;
 }
+
 void Creature::DeleteFromDB()
 {
     if (!m_DBTableGuid)
@@ -1416,8 +1633,10 @@ void Creature::DeleteFromDB()
         sLog.outDebug("Trying to delete not saved creature!");
         return;
     }
+
     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);
@@ -1425,31 +1644,40 @@ void Creature::DeleteFromDB()
     WorldDatabase.PExecuteLog("DELETE FROM game_event_model_equip WHERE guid = '%u'", m_DBTableGuid);
     WorldDatabase.CommitTransaction();
 }
+
 bool Creature::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bool is3dDistance) const
 {
     // not in world
     if(!IsInWorld() || !u->IsInWorld())
         return false;
+
     // all dead creatures/players not visible for any creatures
     if(!u->isAlive() || !isAlive())
         return false;
+
     // Always can see self
     if (u == this)
         return true;
+
     // phased visibility (both must phased in same way)
     if(!InSamePhase(u))
         return false;
+
     // always seen by owner
     if(GetGUID() == u->GetCharmerOrOwnerGUID())
         return true;
+
     if(u->GetVisibility() == VISIBILITY_OFF) //GM
         return false;
+
     // invisible aura
     if((m_invisibilityMask || u->m_invisibilityMask) && !canDetectInvisibilityOf(u))
         return false;
+
     // 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(u->GetVisibility() == VISIBILITY_GROUP_STEALTH)
     {
@@ -1457,86 +1685,113 @@ bool Creature::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bo
         if(!detect || !canDetectStealthOf(u, GetDistance(u)))
             return false;
     }
+
     // Now check is target visible with LoS
     //return u->IsWithinLOS(GetPositionX(),GetPositionY(),GetPositionZ());
     return true;
 }
+
 bool Creature::canStartAttack(Unit const* who, bool force) const
 {
     if(isCivilian())
         return false;
+    
     if(!canFly() && (GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE + m_CombatDistance))
         //|| who->IsControlledByPlayer() && who->IsFlying()))
         // we cannot check flying for other creatures, too much map/vmap calculation
         // TODO: should switch to range attack
         return false;
+
     if(!force)
     {
         if(!_IsTargetAcceptable(who))
             return false;
+
         if(who->isInCombat())
             if(Unit *victim = who->getAttackerForHelper())
                 if(IsWithinDistInMap(victim, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS)))
                     force = true;
+
         if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who) + m_CombatDistance)))
             return false;
     }
+
     if(!canCreatureAttack(who, force))
         return false;
+
     return IsWithinLOSInMap(who);
 }
+
 float Creature::GetAttackDistance(Unit const* pl) const
 {
     float aggroRate = sWorld.getRate(RATE_CREATURE_AGGRO);
     if(aggroRate==0)
         return 0.0f;
+
     uint32 playerlevel   = pl->getLevelForTarget(this);
     uint32 creaturelevel = getLevelForTarget(pl);
+
     int32 leveldif       = int32(playerlevel) - int32(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 varies 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*IN_MILISECONDS;
+
         // always save boss respawn time at death to prevent crash cheating
         if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY) || isWorldBoss())
             SaveRespawnTime();
     }
     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, UNIT_NPC_FLAG_NONE);
+
         setActive(false);
+
         if(!isPet() && GetCreatureInfo()->SkinLootId)
             if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) )
                 SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
+
         SetNoSearchAssistance(false);
+    
         //Dismiss group if is leader
         if(m_formation && m_formation->getLeader() == this)
             m_formation->FormationReset(true);
+
         if ((canFly() || IsFlying()) && FallGround())
             return;
+
         Unit::setDeathState(CORPSE);
     }
     else if(s == JUST_ALIVED)
@@ -1561,23 +1816,28 @@ void Creature::setDeathState(DeathState s)
         Unit::setDeathState(ALIVE);
     }
 }
+
 bool Creature::FallGround()
 {
     // Let's abort after we called this function one time
     if (getDeathState() == DEAD_FALLING)
         return false;
+
     float x, y, z;
     GetPosition(x, y, z);
     float ground_Z = GetMap()->GetVmapHeight(x, y, z, true);
     if (fabs(ground_Z - z) < 0.1f)
         return false;
+
     GetMotionMaster()->MoveFall(ground_Z, EVENT_FALL_GROUND);
     Unit::setDeathState(DEAD_FALLING);
     return true;
 }
+
 void Creature::Respawn(bool force)
 {
     DestroyForNearbyPlayers();
+
     if(force)
     {
         if(isAlive())
@@ -1585,19 +1845,25 @@ void Creature::Respawn(bool force)
         else if(getDeathState() != CORPSE)
             setDeathState(CORPSE);
     }
+
     RemoveCorpse();
+
     if(getDeathState()==DEAD)
     {
         if (m_DBTableGuid)
             objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0);
+
         DEBUG_LOG("Respawning...");
         m_respawnTime = 0;
         lootForPickPocketed = false;
         lootForBody         = false;
+
         if(m_originalEntry != GetEntry())
             UpdateEntry(m_originalEntry);
+
         CreatureInfo const *cinfo = GetCreatureInfo();
         SelectLevel(cinfo);
+
         if (m_isDeadByDefault)
         {
             setDeathState(JUST_DIED);
@@ -1608,46 +1874,59 @@ void Creature::Respawn(bool force)
         }
         else
             setDeathState( JUST_ALIVED );
+
         CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(GetNativeDisplayId());
         if (minfo)                                             // Cancel load if no model defined
         {
             uint32 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);
         }
+
         //Call AI respawn virtual function
         AI()->JustRespawned();
+
         uint16 poolid = poolhandler.IsPartOfAPool(GetGUIDLow(), GetTypeId());
         if (poolid)
             poolhandler.UpdatePool(poolid, GetGUIDLow(), GetTypeId());
     }
+
     SetToNotify();
 }
+
 void Creature::ForcedDespawn()
 {
     setDeathState(JUST_DIED);
     RemoveCorpse();
     SetHealth(0);                                           // just for nice GM-mode view
 }
+
 bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo)
 {
     if (!spellInfo)
         return false;
+
     if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))
         return true;
+
     return Unit::IsImmunedToSpell(spellInfo);
 }
+
 bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const
 {
     if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->EffectMechanic[index] - 1)))
         return true;
+
     return Unit::IsImmunedToSpellEffect(spellInfo, index);
 }
+
 SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
 {
     if(!pVictim)
         return NULL;
+
     for(uint32 i=0; i < CREATURE_MAX_SPELLS; ++i)
     {
         if(!m_spells[i])
@@ -1658,6 +1937,7 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
             sLog.outError("WORLD: unknown spell id %i", m_spells[i]);
             continue;
         }
+
         bool bcontinue = true;
         for(uint32 j=0;j<3;j++)
         {
@@ -1672,6 +1952,7 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
             }
         }
         if(bcontinue) continue;
+
         if(spellInfo->manaCost > GetPower(POWER_MANA))
             continue;
         SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
@@ -1690,10 +1971,12 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
     }
     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])
@@ -1704,6 +1987,7 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
             sLog.outError("WORLD: unknown spell id %i", m_spells[i]);
             continue;
         }
+
         bool bcontinue = true;
         for(uint32 j=0;j<3;j++)
         {
@@ -1714,6 +1998,7 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
             }
         }
         if(bcontinue) continue;
+
         if(spellInfo->manaCost > GetPower(POWER_MANA))
             continue;
         SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
@@ -1732,14 +2017,17 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
     }
     return NULL;
 }
+
 bool Creature::IsVisibleInGridForPlayer(Player const* pl) const
 {
     // gamemaster in GM mode see all, including ghosts
     if(pl->isGameMaster())
         return true;
+
     // Trigger shouldn't be visible for players
     if(isTrigger())
         return false;
+
     // Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0
     if(pl->isAlive() || pl->GetDeathTimer() > 0)
     {
@@ -1747,6 +2035,7 @@ bool Creature::IsVisibleInGridForPlayer(Player const* pl) const
             return false;
         return (isAlive() || m_deathTimer > 0 || (m_isDeadByDefault && m_deathState==CORPSE));
     }
+
     // Dead player see live creatures near own corpse
     if(isAlive())
     {
@@ -1758,50 +2047,66 @@ bool Creature::IsVisibleInGridForPlayer(Player const* pl) const
                 return true;
         }
     }
+
     // Dead player see Spirit Healer or Spirit Guide
     if(isSpiritService())
         return true;
+
     // and not see any other
     return false;
 }
+
 Unit* Creature::SelectNearestTarget(float dist) const
 {
     CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
     Cell cell(p);
     cell.data.Part.reserved = ALL_DISTRICT;
     cell.SetNoCreate();
+
     Unit *target = NULL;
+
     {
         Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist);
         Trinity::UnitLastSearcher searcher(this, target, 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, *GetMap(), *this, ATTACK_DISTANCE);
         cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE);
     }
+
     return target;
 }
+
 void Creature::CallAssistance()
 {
     if( !m_AlreadyCallAssistance && getVictim() && !isPet() && !isCharmed())
     {
         SetNoCallAssistance(true);
+
         float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS);
+
         if(radius > 0)
         {
             std::list assistList;
+
             {
                 CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
                 Cell cell(p);
                 cell.data.Part.reserved = ALL_DISTRICT;
                 cell.SetNoCreate();
+
                 MaNGOS::AnyAssistCreatureInRangeCheck u_check(this, getVictim(), radius);
                 MaNGOS::CreatureListSearcher searcher(this, assistList, u_check);
+
                 TypeContainerVisitor, GridTypeMapContainer >  grid_creature_searcher(searcher);
+
                 CellLock cell_lock(cell, p);
                 cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, radius);
             }
+
             if (!assistList.empty())
             {
                 AssistDelayEvent *e = new AssistDelayEvent(getVictim()->GetGUID(), *this);
@@ -1816,37 +2121,48 @@ void Creature::CallAssistance()
         }
     }
 }
+
 void Creature::CallForHelp(float fRadius)
 {
     if (fRadius <= 0.0f || !getVictim() || isPet() || isCharmed())
         return;
+
     CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
     Cell cell(p);
     cell.data.Part.reserved = ALL_DISTRICT;
     cell.SetNoCreate();
+
     MaNGOS::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), fRadius);
     MaNGOS::CreatureWorker worker(this, u_do);
+
     TypeContainerVisitor, GridTypeMapContainer >  grid_creature_searcher(worker);
+
     CellLock cell_lock(cell, p);
     cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, fRadius);
 }
+
 bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
 {
     // is it true?
     if(!HasReactState(REACT_AGGRESSIVE))
         return false;
+
     // we don't need help from zombies :)
     if (!isAlive())
         return false;
+
     // we don't need help from non-combatant ;)
     if (isCivilian())
         return false;
+
     // skip fighting creature
     if (isInCombat())
         return false;
+
     // only free creature
     if (GetCharmerOrOwnerGUID())
         return false;
+
     // only from same creature faction
     if (checkfaction)
     {
@@ -1858,61 +2174,80 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /
         if (!IsFriendlyTo(u))
             return false;
     }
+
     // skip non hostile to caster enemy creatures
     if (!IsHostileTo(enemy))
         return false;
+
     return true;
 }
+
 // use this function to avoid having hostile creatures attack
 // friendlies and other mobs they shouldn't attack
 bool Creature::_IsTargetAcceptable(const Unit *target) const
 {
     const Unit *myVictim = getAttackerForHelper();
+
     // if I'm already fighting target, the target is acceptable
     if (myVictim == target || target->getVictim() == this)
         return true;
+
     // if I'm hostile towards the target, the target is acceptable
     if (IsHostileTo(target))
         return true;
+
     const Unit *targetVictim = target->getAttackerForHelper();
+
     // if the target does not have a victim, the target is not acceptable
     if (!targetVictim)
         return false;
+
     // if the target's victim is friendly, and the target is neutral, the target is acceptable
     if (IsFriendlyTo(targetVictim) && !IsFriendlyTo(target))
         return true;
+
     // if the target's victim is not friendly, or the target is friendly, the target is not acceptable
     return false;
 }
+
 void Creature::SaveRespawnTime()
 {
     if(isSummon() || !m_DBTableGuid || m_creatureData && !m_creatureData->dbData)
         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/IN_MILISECONDS);
 }
-// this should not be called by petAI or
+
+// this should not be called by petAI or 
 bool Creature::canCreatureAttack(Unit const *pVictim, bool force) const
 {
     if(!pVictim->IsInMap(this))
         return false;
+
     if(!canAttack(pVictim, force))
         return false;
+
     if(!pVictim->isInAccessiblePlaceFor(this))
         return false;
+
     if(IsAIEnabled && !AI()->CanAIAttack(pVictim))
         return false;
+
     if(sMapStore.LookupEntry(GetMapId())->IsDungeon())
         return true;
+
     //Use AttackDistance in distance check if threat radius is lower. This prevents creature bounce in and out of combat every update tick.
     float dist = std::max(GetAttackDistance(pVictim), (float)sWorld.getConfig(CONFIG_THREAT_RADIUS)) + m_CombatDistance;
+
     if(Unit *unit = GetCharmerOrOwner())
         return pVictim->IsWithinDist(unit, dist);
     else
         return pVictim->IsInDist(&m_homePosition, dist);
 }
+
 CreatureDataAddon const* Creature::GetCreatureAddon() const
 {
     if (m_DBTableGuid)
@@ -1920,35 +2255,42 @@ 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->bytes1 != 0)
     {
         // 0 StandState
         // 1 FreeTalentPoints   Pet only, so always 0 for default creature
         // 2 StandFlags
         // 3 StandMiscFlags
+
         SetByteValue(UNIT_FIELD_BYTES_1, 0, uint8(cainfo->bytes1 & 0xFF));
         //SetByteValue(UNIT_FIELD_BYTES_1, 1, uint8((cainfo->bytes1 >> 8) & 0xFF));
         SetByteValue(UNIT_FIELD_BYTES_1, 1, 0);
         SetByteValue(UNIT_FIELD_BYTES_1, 2, uint8((cainfo->bytes1 >> 16) & 0xFF));
         SetByteValue(UNIT_FIELD_BYTES_1, 3, uint8((cainfo->bytes1 >> 24) & 0xFF));
     }
+
     if (cainfo->bytes2 != 0)
     {
         // 0 SheathState
         // 1 Bytes2Flags
         // 2 UnitRename         Pet only, so always 0 for default creature
         // 3 ShapeshiftForm     Must be determined/set by shapeshift spell/aura
+
         SetByteValue(UNIT_FIELD_BYTES_2, 0, uint8(cainfo->bytes2 & 0xFF));
         SetByteValue(UNIT_FIELD_BYTES_2, 1, uint8((cainfo->bytes2 >> 8) & 0xFF));
         //SetByteValue(UNIT_FIELD_BYTES_2, 2, uint8((cainfo->bytes2 >> 16) & 0xFF));
@@ -1956,15 +2298,20 @@ bool Creature::LoadCreaturesAddon(bool reload)
         //SetByteValue(UNIT_FIELD_BYTES_2, 3, uint8((cainfo->bytes2 >> 24) & 0xFF));
         SetByteValue(UNIT_FIELD_BYTES_2, 3, 0);
     }
+
     if (cainfo->emote != 0)
         SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote);
+
     if (cainfo->move_flags != 0)
         SetUnitMovementFlags(cainfo->move_flags);
+
     if (cainfo->move_flags & (MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING))
         sLog.outErrorDb("Creature (GUID: %u Entry: %u) has improper `moveflags` value in `creature_template_addon`. Use `InhabitType` = 4 (Flying) in `creature_template`, not MOVEMENTFLAG_FLY_MODE or MOVEMENTFLAG_FLYING in `creature_template_addon`.",GetGUIDLow(),GetEntry());
+
     //Load Path
     if (cainfo->path_id != 0)
         m_path_id = cainfo->path_id;
+
     if(cainfo->auras)
     {
         for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura)
@@ -1975,27 +2322,33 @@ bool Creature::LoadCreaturesAddon(bool reload)
                 sLog.outErrorDb("Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id);
                 continue;
             }
+
             // skip already applied aura
             if(HasAuraEffect(cAura->spell_id,cAura->effect_idx))
             {
                 if(!reload)
                     sLog.outErrorDb("Creature (GUID: %u Entry: %u) has duplicate aura (spell %u effect %u) in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id,cAura->effect_idx);
+
                 continue;
             }
+
             AddAuraEffect(AdditionalSpellInfo, cAura->effect_idx, this, this);
             sLog.outDebug("Spell: %u with Aura %u added to creature (GUID: %u Entry: %u)", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[cAura->effect_idx],GetGUIDLow(),GetEntry());
         }
     }
     return true;
 }
+
 /// Send a message to LocalDefense channel for players opposition team in the zone
 void Creature::SendZoneUnderAttackMessage(Player* attacker)
 {
     uint32 enemy_team = attacker->GetTeam();
+
     WorldPacket data(SMSG_ZONE_UNDER_ATTACK,4);
     data << (uint32)GetAreaId();
     sWorld.SendGlobalMessage(&data,NULL,(enemy_team==ALLIANCE ? HORDE : ALLIANCE));
 }
+
 void Creature::SetInCombatWithZone()
 {
     if (!CanHaveThreatList())
@@ -2003,21 +2356,27 @@ void Creature::SetInCombatWithZone()
         sLog.outError("Creature entry %u call SetInCombatWithZone but creature cannot have threat list.", GetEntry());
         return;
     }
+
     Map* pMap = GetMap();
+
     if (!pMap->IsDungeon())
     {
         sLog.outError("Creature entry %u call SetInCombatWithZone for map (id: %u) that isn't an instance.", GetEntry(), pMap->GetId());
         return;
     }
+
     Map::PlayerList const &PlList = pMap->GetPlayers();
+
     if (PlList.isEmpty())
         return;
+
     for(Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
     {
         if (Player* pPlayer = i->getSource())
         {
             if (pPlayer->isGameMaster())
                 continue;
+
             if (pPlayer->isAlive())
             {
                 pPlayer->SetInCombatWith(this);
@@ -2026,44 +2385,56 @@ void Creature::SetInCombatWithZone()
         }
     }
 }
+
 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(Player *modOwner = GetSpellModOwner())
         modOwner->ApplySpellMod(spellid, SPELLMOD_COOLDOWN, cooldown);
+   
     if(cooldown)
         _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/IN_MILISECONDS);
+
     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 / IN_MILISECONDS)) > 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::HasSpell(uint32 spellID) const
 {
     uint8 i;
@@ -2072,6 +2443,7 @@ bool Creature::HasSpell(uint32 spellID) const
             break;
     return i < CREATURE_MAX_SPELLS;                         //broke before end of iteration of known spells
 }
+
 time_t Creature::GetRespawnTimeEx() const
 {
     time_t now = time(NULL);
@@ -2082,6 +2454,7 @@ time_t Creature::GetRespawnTimeEx() const
     else
         return now;
 }
+
 void Creature::GetRespawnCoord( float &x, float &y, float &z, float* ori, float* dist ) const
 {
     if (m_DBTableGuid)
@@ -2095,9 +2468,11 @@ void Creature::GetRespawnCoord( float &x, float &y, float &z, float* ori, float*
                 *ori = data->orientation;
             if(dist)
                 *dist = data->spawndist;
+
             return;
         }
     }
+
     x = GetPositionX();
     y = GetPositionY();
     z = GetPositionZ();
@@ -2106,27 +2481,33 @@ void Creature::GetRespawnCoord( float &x, float &y, float &z, float* ori, float*
     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 * IN_MILISECONDS) * 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;
@@ -2134,81 +2515,104 @@ uint32 Creature::getLevelForTarget( Unit const* target ) const
         return 255;
     return level;
 }
+
 std::string Creature::GetAIName() const
 {
     return ObjectMgr::GetCreatureTemplate(GetEntry())->AIName;
 }
+
 std::string Creature::GetScriptName() const
 {
     return objmgr.GetScriptName(GetScriptId());
 }
+
 uint32 Creature::GetScriptId() const
 {
     return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID;
 }
+
 VendorItemData const* Creature::GetVendorItems() const
 {
     return objmgr.GetNpcVendorItemList(GetEntry());
 }
+
 uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
 {
     if(!vItem->maxcount)
         return vItem->maxcount;
+
     VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
     for(; itr != m_vendorItemCounts.end(); ++itr)
         if(itr->itemId==vItem->item)
             break;
+
     if(itr == m_vendorItemCounts.end())
         return vItem->maxcount;
+
     VendorItemCount* vCount = &*itr;
+
     time_t ptime = time(NULL);
+
     if( vCount->lastIncrementTime + vItem->incrtime <= ptime )
     {
         ItemPrototype const* pProto = objmgr.GetItemPrototype(vItem->item);
+
         uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
         if((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount )
         {
             m_vendorItemCounts.erase(itr);
             return vItem->maxcount;
         }
+
         vCount->count += diff * pProto->BuyCount;
         vCount->lastIncrementTime = ptime;
     }
+
     return vCount->count;
 }
+
 uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count)
 {
     if(!vItem->maxcount)
         return 0;
+
     VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
     for(; itr != m_vendorItemCounts.end(); ++itr)
         if(itr->itemId==vItem->item)
             break;
+
     if(itr == m_vendorItemCounts.end())
     {
         uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0;
         m_vendorItemCounts.push_back(VendorItemCount(vItem->item,new_count));
         return new_count;
     }
+
     VendorItemCount* vCount = &*itr;
+
     time_t ptime = time(NULL);
+
     if( vCount->lastIncrementTime + vItem->incrtime <= ptime )
     {
         ItemPrototype const* pProto = objmgr.GetItemPrototype(vItem->item);
+
         uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
         if((vCount->count + diff * pProto->BuyCount) < vItem->maxcount )
             vCount->count += diff * pProto->BuyCount;
         else
             vCount->count = vItem->maxcount;
     }
+
     vCount->count = vCount->count > used_count ? vCount->count-used_count : 0;
     vCount->lastIncrementTime = ptime;
     return vCount->count;
 }
+
 TrainerSpellData const* Creature::GetTrainerSpells() const
 {
     return objmgr.GetNpcTrainerSpells(GetEntry());
 }
+
 // overwrite WorldObject function for proper name localization
 const char* Creature::GetNameForLocaleIdx(int32 loc_idx) const
 {
@@ -2221,21 +2625,27 @@ const char* Creature::GetNameForLocaleIdx(int32 loc_idx) const
                 return cl->Name[loc_idx].c_str();
         }
     }
+
     return GetName();
 }
+
 const CreatureData* Creature::GetLinkedRespawnCreatureData() const
 {
     if(!m_DBTableGuid) // only hard-spawned creatures from DB can have a linked master
         return NULL;
+
     if(uint32 targetGuid = objmgr.GetLinkedRespawnGuid(m_DBTableGuid))
         return objmgr.GetCreatureData(targetGuid);
+
     return NULL;
 }
+
 // returns master's remaining respawn time if any
 time_t Creature::GetLinkedCreatureRespawnTime() const
 {
     if(!m_DBTableGuid) // only hard-spawned creatures from DB can have a linked master
         return 0;
+
     if(uint32 targetGuid = objmgr.GetLinkedRespawnGuid(m_DBTableGuid))
     {
         Map* targetMap = NULL;
@@ -2249,6 +2659,7 @@ time_t Creature::GetLinkedCreatureRespawnTime() const
         if(targetMap)
             return objmgr.GetCreatureRespawnTime(targetGuid,targetMap->GetInstanceId());
     }
+
     return 0;
 }
 
diff --git a/src/game/Creature.h b/src/game/Creature.h
index f66d485d183..5fbe4a07a28 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -17,8 +17,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef TRINITYCORE_CREATURE_H
 #define TRINITYCORE_CREATURE_H
+
 #include "Common.h"
 #include "Unit.h"
 #include "UpdateMask.h"
@@ -26,13 +28,17 @@
 #include "LootMgr.h"
 #include "Database/DatabaseEnv.h"
 #include "Cell.h"
+
 #include 
+
 struct SpellEntry;
+
 class CreatureAI;
 class Quest;
 class Player;
 class WorldSession;
 class CreatureGroup;
+
 enum Gossip_Option
 {
     GOSSIP_OPTION_NONE              = 0,                    //UNIT_NPC_FLAG_NONE              = 0,
@@ -56,6 +62,7 @@ enum Gossip_Option
     GOSSIP_OPTION_LEARNDUALSPEC     = 18,                   //UNIT_NPC_FLAG_TRAINER (bonus option for GOSSIP_OPTION_TRAINER)
     GOSSIP_OPTION_OUTDOORPVP        = 19                    //added by code (option for outdoor pvp creatures)
 };
+
 enum Gossip_Guard
 {
     GOSSIP_GUARD_BANK               = 32,
@@ -70,6 +77,7 @@ enum Gossip_Guard
     GOSSIP_GUARD_SPELLTRAINER       = 41,
     GOSSIP_GUARD_SKILLTRAINER       = 42
 };
+
 enum Gossip_Guard_Spell
 {
     GOSSIP_GUARD_SPELL_WARRIOR      = 64,
@@ -84,6 +92,7 @@ enum Gossip_Guard_Spell
     GOSSIP_GUARD_SPELL_UNKNOWN2     = 73,
     GOSSIP_GUARD_SPELL_DRUID        = 74
 };
+
 enum Gossip_Guard_Skill
 {
     GOSSIP_GUARD_SKILL_ALCHEMY      = 80,
@@ -99,6 +108,7 @@ enum Gossip_Guard_Skill
     GOSSIP_GUARD_SKILL_TAILORING    = 90,
     GOSSIP_GUARD_SKILL_ENGINERING   = 91
 };
+
 enum GossipOptionIcon
 {
     GOSSIP_ICON_CHAT                = 0,                    //white chat bubble
@@ -113,6 +123,7 @@ enum GossipOptionIcon
     GOSSIP_ICON_BATTLE              = 9,                    //two swords
     GOSSIP_ICON_DOT                 = 10                    //yellow dot
 };
+
 struct GossipOption
 {
     uint32 Id;
@@ -125,6 +136,7 @@ struct GossipOption
     std::string OptionText;
     std::string BoxText;
 };
+
 enum CreatureFlagsExtra
 {
     CREATURE_FLAG_EXTRA_INSTANCE_BIND   = 0x00000001,       // creature kill bind instance with killer and killer's group
@@ -141,13 +153,16 @@ enum CreatureFlagsExtra
     CREATURE_FLAG_EXTRA_NO_CRIT         = 0x00020000,       // creature can't do critical strikes
     CREATURE_FLAG_EXTRA_NO_SKILLGAIN    = 0x00040000,       // creature won't increase weapon skills
 };
+
 // 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
+
 #define MAX_KILL_CREDIT 2
+
 // from `creature_template` table
 struct CreatureInfo
 {
@@ -223,6 +238,7 @@ struct CreatureInfo
     uint32  ScriptID;
     uint32  GetRandomValidModelId() const;
     uint32  GetFirstValidModelId() const;
+
     // helpers
     SkillType GetRequiredLootSkill() const
     {
@@ -235,33 +251,40 @@ struct CreatureInfo
         else
             return SKILL_SKINNING;                          // normal case
     }
+
     bool isTameable(bool exotic) const
     {
         if(type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE)==0)
             return false;
+
         // if can tame exotic then can tame any temable
         return exotic || (type_flags & CREATURE_TYPEFLAGS_EXOTIC)==0;
     }
 };
+
 struct CreatureLocale
 {
     std::vector Name;
     std::vector SubName;
 };
+
 struct NpcOptionLocale
 {
     std::vector OptionText;
     std::vector BoxText;
 };
+
 struct PointOfInterestLocale
 {
     std::vector IconName;
 };
+
 struct EquipmentInfo
 {
     uint32  entry;
     uint32  equipentry[3];
 };
+
 // from `creature` table
 struct CreatureData
 {
@@ -285,11 +308,13 @@ struct CreatureData
     uint8 spawnMask;
     bool dbData;
 };
+
 struct CreatureDataAddonAura
 {
     uint32 spell_id;
     uint8 effect_idx;
 };
+
 // from `creature_addon` table
 struct CreatureDataAddon
 {
@@ -302,6 +327,7 @@ struct CreatureDataAddon
     uint32 move_flags;
     CreatureDataAddonAura const* auras;                     // loaded as char* "spell1 eff1 spell2 eff2 ... "
 };
+
 struct CreatureModelInfo
 {
     uint32 modelid;
@@ -310,6 +336,7 @@ struct CreatureModelInfo
     uint8 gender;
     uint32 modelid_other_gender;
 };
+
 enum InhabitTypeValues
 {
     INHABIT_GROUND = 1,
@@ -317,6 +344,7 @@ enum InhabitTypeValues
     INHABIT_AIR    = 4,
     INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR
 };
+
 // Enums used by StringTextData::Type (CreatureEventAI)
 enum ChatType
 {
@@ -328,6 +356,7 @@ enum ChatType
     CHAT_TYPE_BOSS_WHISPER      = 5,
     CHAT_TYPE_ZONE_YELL         = 6
 };
+
 //Selection method used by SelectTarget (CreatureEventAI)
 enum AttackingTarget
 {
@@ -340,26 +369,31 @@ enum AttackingTarget
     ATTACKING_TARGET_BOTTOMAGGRO_PLAYER,                    //Selects targets from bottom aggro to top (player only)
     */
 };
+
 // 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
+
 // Vendors
 struct VendorItem
 {
     VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
         : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
+
     uint32 item;
     uint32 maxcount;                                        // 0 for infinity item amount
     uint32 incrtime;                                        // time for restore items amount if maxcount != 0
     uint32 ExtendedCost;
 };
 typedef std::vector VendorItemList;
+
 struct VendorItemData
 {
     VendorItemList m_items;
+
     VendorItem* GetItem(uint32 slot) const
     {
         if(slot>=m_items.size()) return NULL;
@@ -374,6 +408,7 @@ struct VendorItemData
     bool RemoveItem( uint32 item_id );
     VendorItem const* FindItem(uint32 item_id) const;
     size_t FindItemSlot(uint32 item_id) const;
+
     void Clear()
     {
         for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
@@ -381,62 +416,84 @@ struct VendorItemData
         m_items.clear();
     }
 };
+
 struct VendorItemCount
 {
     explicit VendorItemCount(uint32 _item, uint32 _count)
         : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
+
     uint32 itemId;
     uint32 count;
     time_t lastIncrementTime;
 };
+
 typedef std::list VendorItemCounts;
+
 struct TrainerSpell
 {
     TrainerSpell() : spell(0), spellCost(0), reqSkill(0), reqSkillValue(0), reqLevel(0), learnedSpell(0) {}
+
     TrainerSpell(uint32 _spell, uint32 _spellCost, uint32 _reqSkill, uint32 _reqSkillValue, uint32 _reqLevel, uint32 _learnedspell)
         : spell(_spell), spellCost(_spellCost), reqSkill(_reqSkill), reqSkillValue(_reqSkillValue), reqLevel(_reqLevel), learnedSpell(_learnedspell)
     {}
+
     uint32 spell;
     uint32 spellCost;
     uint32 reqSkill;
     uint32 reqSkillValue;
     uint32 reqLevel;
     uint32 learnedSpell;
+
     // helpers
     bool IsCastable() const { return learnedSpell != spell; }
 };
+
 typedef UNORDERED_MAP TrainerSpellMap;
+
 struct TrainerSpellData
 {
     TrainerSpellData() : trainerType(0) {}
+
     TrainerSpellMap 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.
     TrainerSpell const* Find(uint32 spell_id) const;
     void Clear() { spellList.clear(); }
 };
+
 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 150                                // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY
+
 class TRINITY_DLL_SPEC Creature : public Unit
 {
     public:
+
         explicit Creature();
         virtual ~Creature();
+
         void AddToWorld();
         void RemoveFromWorld();
+
         void DisappearAndDie();
+
         bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, uint32 team, float x, float y, float z, float ang, 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 GetCreatureInfo()->equipmentId; }
+
         void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
         bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
         bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
@@ -460,33 +517,45 @@ class TRINITY_DLL_SPEC Creature : public Unit
         {
             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 { return hasUnitState(UNIT_STAT_EVADE); }
+
         bool AIM_Initialize(CreatureAI* ai = NULL);
         void Motion_Initialize();
+
         void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
         CreatureAI * AI() const { return (CreatureAI*)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();
@@ -498,56 +567,72 @@ class TRINITY_DLL_SPEC Creature : public Unit
         void UpdateDamagePhysical(WeaponAttackType attType);
         uint32 GetCurrentEquipmentId() { return m_equipmentId; }
         float GetSpellDamageMod(int32 Rank);
+
         VendorItemData const* GetVendorItems() const;
         uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
         uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
+
         TrainerSpellData const* GetTrainerSpells() const;
+
         CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
         CreatureData const *GetCreatureData() const { return m_creatureData; }
         CreatureDataAddon const* GetCreatureAddon() const;
+
         std::string GetAIName() const;
         std::string GetScriptName() const;
         uint32 GetScriptId() const;
+
         void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 );
         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();
         void ResetGossipOptions();
         GossipOption const* GetGossipOption( uint32 id ) const;
         void addGossipOption(GossipOption const& gso) { m_goptions.push_back(gso); }
+
         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 YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
+
         // overwrite WorldObject function for proper name localization
         const char* GetNameForLocaleIdx(int32 locale_idx) const;
+
         void setDeathState(DeathState s);                   // overwrite virtual Unit::setDeathState
         bool FallGround();
+
         bool LoadFromDB(uint32 guid, Map *map);
         void SaveToDB();
                                                             // overwrited in Pet
         virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
         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;
+
         bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
         bool canStartAttack(Unit const* u, bool force) const;
         float GetAttackDistance(Unit const* pl) const;
+
         Unit* SelectNearestTarget(float dist = 0) const;
         void DoFleeToGetAssistance();
         void CallForHelp(float fRadius);
@@ -557,33 +642,47 @@ class TRINITY_DLL_SPEC Creature : public Unit
         bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
         bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
         bool _IsTargetAcceptable(const Unit* target) const;
+
         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 const* pl) const;
+
         void RemoveCorpse();
         bool isDeadByDefault() const { return m_isDeadByDefault; };
+
         void ForcedDespawn();
+
         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(bool force = false);
         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; }
+
         // Linked Creature Respawning System
         time_t GetLinkedCreatureRespawnTime() const;
         const CreatureData* GetLinkedRespawnCreatureData() const;
+
         uint32 m_groupLootTimer;                            // (msecs)timer used for group loot
         uint64 lootingGroupLeaderGUID;                      // used to find group which is looting corpse
+
         void SendZoneUnderAttackMessage(Player* attacker);
+
         void SetInCombatWithZone();
+
         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; }
@@ -594,19 +693,26 @@ class TRINITY_DLL_SPEC Creature : public Unit
             else
                 return m_charmInfo->GetCharmSpell(pos)->GetAction();
         }
+
         void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
         void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos);}
         void GetHomePosition(float &x, float &y, float &z, float &ori) { m_homePosition.GetPosition(x, y, z, ori); }
+
         uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
+
         uint32 GetWaypointPath(){return m_path_id;}
         void LoadPath(uint32 pathid) { m_path_id = pathid; }
+
         uint32 GetCurrentWaypointID(){return m_waypointID;}
         void UpdateWaypointID(uint32 wpID){m_waypointID = wpID;}
+
         void SearchFormation();
         CreatureGroup *GetFormation() {return m_formation;}
         void SetFormation(CreatureGroup *formation) {m_formation = formation;}
+
         Unit *SelectVictim();
         void SetDeadByDefault (bool death_state) {m_isDeadByDefault = death_state;}
+
         void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
         bool IsReputationGainDisabled() { return DisableReputationGain; }
         bool IsDamageEnoughForLootingAndReward() { return m_PlayerDamageReq == 0; }
@@ -617,26 +723,36 @@ class TRINITY_DLL_SPEC Creature : public Unit
         }
         void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; }
         uint32 m_PlayerDamageReq;
+
         void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
+
         static float _GetDamageMod(int32 Rank);
+
         float m_SightDistance, m_CombatDistance;
     protected:
         bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, uint32 team, const CreatureData *data = NULL);
         bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
+
         // vendor items
         VendorItemCounts m_vendorItemCounts;
+
         void _RealtimeSetCreatureInfo();
+
         static float _GetHealthMod(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;
+
         ReactStates m_reactState;                           // for AI, not charmInfo
         void RegenerateMana();
         void RegenerateHealth();
@@ -645,36 +761,48 @@ class TRINITY_DLL_SPEC Creature : public Unit
         Cell m_currentCell;                                 // store current cell where creature listed
         uint32 m_DBTableGuid;                               ///< For new or temporary creatures is 0 for saved it is lowguid
         uint32 m_equipmentId;
+
         bool m_AlreadyCallAssistance;
         bool m_AlreadySearchedAssistance;
         bool m_regenHealth;
         bool m_AI_locked;
         bool m_isDeadByDefault;
+
         SpellSchoolMask m_meleeDamageSchoolMask;
         uint32 m_originalEntry;
+
         Position m_homePosition;
+
         bool DisableReputationGain;
+
         CreatureInfo const* m_creatureInfo;                 // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
         CreatureData const* m_creatureData;
+
     private:
         //WaypointMovementGenerator vars
         uint32 m_waypointID;
         uint32 m_path_id;
+
         //Formation var
         CreatureGroup *m_formation;
+
         GridReference m_gridRef;
 };
+
 class AssistDelayEvent : public BasicEvent
 {
     public:
         AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
+
         bool Execute(uint64 e_time, uint32 p_time);
         void AddAssistant(const uint64& guid) { m_assistants.push_back(guid); }
     private:
         AssistDelayEvent();
+
         uint64            m_victim;
         std::list m_assistants;
         Unit&             m_owner;
 };
+
 #endif
 
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index 6727575e920..27fe428efd1 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -17,12 +17,14 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "CreatureAI.h"
 #include "CreatureAIImpl.h"
 #include "Creature.h"
 #include "World.h"
 #include "SpellMgr.h"
 #include "Vehicle.h"
+
 //Disable CreatureAI when charmed
 void CreatureAI::OnCharmed(bool apply)
 {
@@ -30,20 +32,25 @@ void CreatureAI::OnCharmed(bool apply)
     me->NeedChangeAI = true;
     me->IsAIEnabled = false;
 }
+
 AISpellInfoType * UnitAI::AISpellInfo;
 TRINITY_DLL_SPEC AISpellInfoType * GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; }
+
 void CreatureAI::DoZoneInCombat(Creature* creature)
 {
     if (!creature)
         creature = me;
+
     if(!creature->CanHaveThreatList())
         return;
+
     Map *map = creature->GetMap();
     if (!map->IsDungeon())                                  //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated
     {
         sLog.outError("DoZoneInCombat call for map that isn't an instance (creature entry = %d)", creature->GetTypeId() == TYPEID_UNIT ? ((Creature*)creature)->GetEntry() : 0);
         return;
     }
+
     if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim())
     {
         if(Unit *target = creature->SelectNearestTarget(50))
@@ -60,26 +67,32 @@ void CreatureAI::DoZoneInCombat(Creature* creature)
             }
         }
     }
+
     if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim())
     {
         sLog.outError("DoZoneInCombat called for creature that has empty threat list (creature entry = %u)", creature->GetEntry());
         return;
     }
+
     Map::PlayerList const &PlList = map->GetPlayers();
+
     if(PlList.isEmpty())
         return;
+
     for(Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
     {
         if(Player* pPlayer = i->getSource())
         {
             if(pPlayer->isGameMaster())
                 continue;
+
             if(pPlayer->isAlive())
             {
                 creature->SetInCombatWith(pPlayer);
                 pPlayer->SetInCombatWith(creature);
                 creature->AddThreat(pPlayer, 0.0f);
             }
+
             /* Causes certain things to never leave the threat list (Priest Lightwell, etc):
             for(Unit::ControlList::const_iterator itr = pPlayer->m_Controlled.begin(); itr != pPlayer->m_Controlled.end(); ++itr)
             {
@@ -90,12 +103,15 @@ void CreatureAI::DoZoneInCombat(Creature* creature)
         }
     }
 }
+
 void CreatureAI::MoveInLineOfSight(Unit *who)
 {
     if(me->getVictim())
         return;
+        
     if (me->GetTypeId() == CREATURE_TYPE_NON_COMBAT_PET) // non-combat pets should just stand there and look good;)
         return;
+
     if(me->canStartAttack(who, false))
         AttackStart(who);
     //else if(who->getVictim() && me->IsFriendlyTo(who)
@@ -103,6 +119,7 @@ void CreatureAI::MoveInLineOfSight(Unit *who)
     //    && me->canStartAttack(who->getVictim(), true)) // TODO: if we use true, it will not attack it when it arrives
     //    me->GetMotionMaster()->MoveChase(who->getVictim());
 }
+
 void CreatureAI::SelectNearestTarget(Unit *who)
 {
     if(me->getVictim() && me->GetDistanceOrder(who, me->getVictim()) && me->canAttack(who))
@@ -111,11 +128,14 @@ void CreatureAI::SelectNearestTarget(Unit *who)
         me->AddThreat(who, 1000000.0f);
     }
 }
+
 void CreatureAI::EnterEvadeMode()
 {
     if(!_EnterEvadeMode())
         return;
+
     sLog.outDebug("Creature %u enters evade mode.", me->GetEntry());
+
     if(!me->GetVehicle()) // otherwise me will be in evade mode forever
     {
         if(Unit *owner = me->GetCharmerOrOwner())
@@ -126,10 +146,13 @@ void CreatureAI::EnterEvadeMode()
         else
             me->GetMotionMaster()->MoveTargetedHome();
     }
+
     Reset();
+
     if(me->IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
         me->GetVehicleKit()->Reset();
 }
+
 /*void CreatureAI::AttackedBy( Unit* attacker )
 {
     if(!m_creature->getVictim())
diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h
index 98a145b79e0..556e9be14e0 100644
--- a/src/game/CreatureAI.h
+++ b/src/game/CreatureAI.h
@@ -17,29 +17,38 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_CREATUREAI_H
 #define TRINITY_CREATUREAI_H
+
 #include "UnitAI.h"
 #include "Common.h"
+
 class WorldObject;
 class Unit;
 class Creature;
 class Player;
 struct SpellEntry;
+
 #define TIME_INTERVAL_LOOK   5000
 #define VISIBILITY_RANGE    10000
+
 //Spell targets used by SelectSpell
 enum SelectTargetType
 {
     SELECT_TARGET_DONTCARE = 0,                             //All target types allowed
+
     SELECT_TARGET_SELF,                                     //Only Self casting
+
     SELECT_TARGET_SINGLE_ENEMY,                             //Only Single Enemy
     SELECT_TARGET_AOE_ENEMY,                                //Only AoE Enemy
     SELECT_TARGET_ANY_ENEMY,                                //AoE or Single Enemy
+
     SELECT_TARGET_SINGLE_FRIEND,                            //Only Single Friend
     SELECT_TARGET_AOE_FRIEND,                               //Only AoE Friend
     SELECT_TARGET_ANY_FRIEND,                               //AoE or Single Friend
 };
+
 //Spell Effects used by SelectSpell
 enum SelectEffect
 {
@@ -48,84 +57,123 @@ enum SelectEffect
     SELECT_EFFECT_HEALING,                                  //Spell does healing
     SELECT_EFFECT_AURA,                                     //Spell applies an aura
 };
+
 enum SCEquip
 {
     EQUIP_NO_CHANGE = -1,
     EQUIP_UNEQUIP   = 0
 };
+
 class TRINITY_DLL_SPEC CreatureAI : public UnitAI
 {
     protected:
         Creature * const me;
         Creature * const m_creature;
+
         bool UpdateVictim();
         bool UpdateVictimWithGaze();
         bool UpdateCombatState();
+
         void SelectNearestTarget(Unit *who);
+
         void SetGazeOn(Unit *target);
+
         Creature *DoSummon(uint32 uiEntry, const Position &pos, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
         Creature *DoSummon(uint32 uiEntry, WorldObject *obj, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
         Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
+
     public:
         explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_creature(c) {}
+
         virtual ~CreatureAI() {}
+
         ///== Reactions At =================================
+
         // Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter
         virtual void MoveInLineOfSight(Unit *);
+
         // Called for reaction at stopping attack at no attackers or targets
         virtual void EnterEvadeMode();
+
         // Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
         virtual void EnterCombat(Unit* /*enemy*/) {}
+
         // Called at any Damage from any attacker (before damage apply)
         // Note: it for recalculation damage or special reaction at damage
         // for attack reaction use AttackedBy called for not DOT damage in Unit::DealDamage also
         virtual void DamageTaken(Unit *done_by, uint32 & /*damage*/) {}
+
         // Called when the creature is killed
         virtual void JustDied(Unit *) {}
+
         // Called when the creature kills a unit
         virtual void KilledUnit(Unit *) {}
+
         // Called when the creature summon successfully other creature
         virtual void JustSummoned(Creature* ) {}
         virtual void IsSummonedBy(Unit *summoner) {}
+
         virtual void SummonedCreatureDespawn(Creature* /*unit*/) {}
+
         // Called when hit by a spell
         virtual void SpellHit(Unit*, const SpellEntry*) {}
+
         // Called when spell hits a target
         virtual void SpellHitTarget(Unit* target, const SpellEntry*) {}
+
         // Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
         //virtual void AttackedBy(Unit* attacker);
         virtual bool IsEscorted() {return false;}
+
         // Called when creature is spawned or respawned (for reseting variables)
         virtual void JustRespawned() { Reset(); }
+
         // Called at waypoint reached or point movement finished
         virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
+
         void OnCharmed(bool apply);
+
         //virtual void SpellClick(Player *player) {}
+
         // Called at reaching home after evade
         virtual void JustReachedHome() {}
+
         void DoZoneInCombat(Creature* pUnit = NULL);
-        // Called at text emote receive from player
+
+        // Called at text emote receive from player 
         virtual void ReceiveEmote(Player* pPlayer, uint32 text_emote) {}
+
         ///== Triggered Actions Requested ==================
+
         // Called when creature attack expected (if creature can and no have current victim)
         // Note: for reaction at hostile action must be called AttackedBy function.
         //virtual void AttackStart(Unit *) {}
+
         // Called at World update tick
         //virtual void UpdateAI(const uint32 diff ) {}
+
         ///== State checks =================================
+
         // Is unit visible for MoveInLineOfSight
         //virtual bool IsVisible(Unit *) const { return false; }
+
         // called when the corpse of this creature gets removed
         virtual void CorpseRemoved(uint32 & /*respawnDelay*/) {}
+
         // Called when victim entered water and creature can not enter water
         //virtual bool canReachByRangeAttack(Unit*) { return false; }
+
         ///== Fields =======================================
+
         // Pointer to controlled by AI creature
         //Creature* const m_creature;
+
         virtual void PassengerBoarded(Unit *who, int8 seatId, bool apply) {}
+
     protected:
         bool _EnterEvadeMode();
 };
+
 enum Permitions
 {
     PERMIT_BASE_NO                 = -1,
@@ -135,4 +183,5 @@ enum Permitions
     PERMIT_BASE_FACTION_SPECIFIC   = 400,
     PERMIT_BASE_SPECIAL            = 800
 };
+
 #endif
diff --git a/src/game/CreatureAIFactory.h b/src/game/CreatureAIFactory.h
index a2396fc5117..d546c2b1720 100644
--- a/src/game/CreatureAIFactory.h
+++ b/src/game/CreatureAIFactory.h
@@ -19,20 +19,26 @@
  */
 #ifndef TRINITY_CREATUREAIFACTORY_H
 #define TRINITY_CREATUREAIFACTORY_H
+
 //#include "Policies/Singleton.h"
 #include "Dynamic/ObjectRegistry.h"
 #include "Dynamic/FactoryHolder.h"
+
 struct SelectableAI : public FactoryHolder, public Permissible
 {
     SelectableAI(const char *id) : FactoryHolder(id) {}
 };
+
 template
 struct CreatureAIFactory : public SelectableAI
 {
     CreatureAIFactory(const char *name) : SelectableAI(name) {}
+
     CreatureAI* Create(void *) const;
+
     int Permit(const Creature *c) const { return REAL_AI::Permissible(c); }
 };
+
 template
 inline CreatureAI*
 CreatureAIFactory::Create(void *data) const
@@ -40,6 +46,7 @@ CreatureAIFactory::Create(void *data) const
     Creature* creature = reinterpret_cast(data);
     return (new REAL_AI(creature));
 }
+
 typedef FactoryHolder CreatureAICreator;
 typedef FactoryHolder::FactoryHolderRegistry CreatureAIRegistry;
 typedef FactoryHolder::FactoryHolderRepository CreatureAIRepository;
diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h
index 4fddcc6392d..89d5bbc2a9e 100644
--- a/src/game/CreatureAIImpl.h
+++ b/src/game/CreatureAIImpl.h
@@ -17,17 +17,21 @@
  */
 #ifndef CREATUREAIIMPL_H
 #define CREATUREAIIMPL_H
+
 #include "Common.h"
 #include "Platform/Define.h"
 #include "TemporarySummon.h"
 #include "CreatureAI.h"
+
 #define HEROIC(n,h) (HeroicMode ? h : n)
+
 template
 inline
 const T& RAND(const T& v1, const T& v2)
 {
     return (rand()%2) ? v1 : v2;
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3)
@@ -40,6 +44,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3)
         case 2: return v3;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4)
@@ -53,6 +58,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4)
         case 3: return v4;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5)
@@ -67,6 +73,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5)
         case 4: return v5;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6)
@@ -82,6 +89,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 5: return v6;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7)
@@ -98,6 +106,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 6: return v7;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8)
@@ -115,6 +124,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 7: return v8;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
@@ -134,6 +144,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 8: return v9;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
@@ -154,6 +165,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 9: return v10;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
@@ -175,6 +187,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 10: return v11;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
@@ -197,6 +210,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 11: return v12;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
@@ -220,6 +234,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 12: return v13;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
@@ -244,6 +259,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 13: return v14;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
@@ -269,6 +285,7 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 14: return v15;
     }
 }
+
 template
 inline
 const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
@@ -295,20 +312,26 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
         case 15: return v16;
     }
 }
+
 class EventMap : private std::map
 {
     private:
         uint32 m_time, m_phase;
     public:
         explicit EventMap() : m_phase(0), m_time(0) {}
+
         uint32 GetTimer() const { return m_time; }
+
         void Reset() { clear(); m_time = 0; m_phase = 0; }
+
         void Update(uint32 time) { m_time += time; }
+
         void SetPhase(uint32 phase)
         {
             if(phase && phase < 9)
                 m_phase = (1 << (phase + 24));
         }
+
         void ScheduleEvent(uint32 eventId, uint32 time, uint32 gcd = 0, uint32 phase = 0)
         {
             time += m_time;
@@ -324,11 +347,13 @@ class EventMap : private std::map
             }
             insert(std::make_pair(time, eventId));
         }
+
         void RescheduleEvent(uint32 eventId, uint32 time, uint32 gcd = 0, uint32 phase = 0)
         {
             CancelEvent(eventId);
             ScheduleEvent(eventId, time, gcd, phase);
         }
+
         void RepeatEvent(uint32 time)
         {
             if(empty())
@@ -344,10 +369,12 @@ class EventMap : private std::map
             }
             insert(std::make_pair(time, eventId));
         }
+
         void PopEvent()
         {
             erase(begin());
         }
+
         uint32 ExecuteEvent()
         {
             while(!empty())
@@ -365,6 +392,7 @@ class EventMap : private std::map
             }
             return 0;
         }
+
         uint32 GetEvent()
         {
             while(!empty())
@@ -380,6 +408,7 @@ class EventMap : private std::map
             }
             return 0;
         }
+
         void DelayEvents(uint32 time, uint32 gcd)
         {
             time += m_time;
@@ -397,6 +426,7 @@ class EventMap : private std::map
                     ++itr;
             }
         }
+
         void CancelEvent(uint32 eventId)
         {
             for(iterator itr = begin(); itr != end();)
@@ -407,6 +437,7 @@ class EventMap : private std::map
                     ++itr;
             }
         }
+
         void CancelEventsByGCD(uint32 gcd)
         {
             for(iterator itr = begin(); itr != end();)
@@ -418,6 +449,7 @@ class EventMap : private std::map
             }
         }
 };
+
 enum AITarget
 {
     AITARGET_SELF,
@@ -427,13 +459,16 @@ enum AITarget
     AITARGET_BUFF,
     AITARGET_DEBUFF,
 };
+
 enum AICondition
 {
     AICOND_AGGRO,
     AICOND_COMBAT,
     AICOND_DIE,
 };
+
 #define AI_DEFAULT_COOLDOWN 5000
+
 struct AISpellInfoType
 {
     AISpellInfoType() : target(AITARGET_SELF), condition(AICOND_COMBAT)
@@ -444,8 +479,10 @@ struct AISpellInfoType
     uint32 realCooldown;
     float maxRange;
 };
+
 TRINITY_DLL_SPEC AISpellInfoType * GetAISpellInfo(uint32 i);
 
+
 inline void CreatureAI::SetGazeOn(Unit *target)
 {
     if(me->canAttack(target))
@@ -454,10 +491,12 @@ inline void CreatureAI::SetGazeOn(Unit *target)
         me->SetReactState(REACT_PASSIVE);
     }
 }
+
 inline bool CreatureAI::UpdateVictimWithGaze()
 {
     if(!me->isInCombat())
         return false;
+
     if(me->HasReactState(REACT_PASSIVE))
     {
         if(me->getVictim())
@@ -465,14 +504,17 @@ inline bool CreatureAI::UpdateVictimWithGaze()
         else
             me->SetReactState(REACT_AGGRESSIVE);
     }
+
     if(Unit *victim = me->SelectVictim())
         AttackStart(victim);
     return me->getVictim();
 }
+
 inline bool CreatureAI::UpdateCombatState()
 {
     if(!me->isInCombat())
         return false;
+
     if(!me->HasReactState(REACT_PASSIVE))
     {
         if(Unit *victim = me->SelectVictim())
@@ -484,12 +526,15 @@ inline bool CreatureAI::UpdateCombatState()
         EnterEvadeMode();
         return false;
     }
+
     return true;
 }
+
 inline bool CreatureAI::UpdateVictim()
 {
     if(!me->isInCombat())
         return false;
+
     if(!me->HasReactState(REACT_PASSIVE))
     {
         if(Unit *victim = me->SelectVictim())
@@ -501,8 +546,10 @@ inline bool CreatureAI::UpdateVictim()
         EnterEvadeMode();
         return false;
     }
+
     return true;
 }
+
 /*
 inline bool CreatureAI::UpdateVictim()
 {
@@ -513,10 +560,12 @@ inline bool CreatureAI::UpdateVictim()
     return me->getVictim();
 }
 */
+
 inline bool CreatureAI::_EnterEvadeMode()
 {
     if(!me->isAlive())
         return false;
+
     // sometimes bosses stuck in combat?
     me->RemoveAllAuras();
     me->DeleteThreatList();
@@ -524,36 +573,46 @@ inline bool CreatureAI::_EnterEvadeMode()
     me->LoadCreaturesAddon();
     me->SetLootRecipient(NULL);
     me->ResetPlayerDamageReq();
+    
     if(me->IsInEvadeMode())
         return false;
+
     return true;
 }
+
 inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
 {
     if(!victim || me->hasUnitState(UNIT_STAT_CASTING) && !triggered)
         return;
+
     me->CastSpell(victim, spellId, triggered);
 }
+
 inline void UnitAI::DoCastVictim(uint32 spellId, bool triggered)
 {
     me->CastSpell(me->getVictim(), spellId, triggered);
 }
+
 inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
 {
     if(!triggered && me->hasUnitState(UNIT_STAT_CASTING))
         return;
+
     me->CastSpell((Unit*)NULL, spellId, triggered);
 }
+
 inline Creature *CreatureAI::DoSummon(uint32 uiEntry, const Position &pos, uint32 uiDespawntime, TempSummonType uiType)
 {
     return me->SummonCreature(uiEntry, pos, uiType, uiDespawntime);
 }
+
 inline Creature *CreatureAI::DoSummon(uint32 uiEntry, WorldObject* obj, float fRadius, uint32 uiDespawntime, TempSummonType uiType)
 {
     Position pos;
     obj->GetRandomNearPosition(pos, fRadius);
     return me->SummonCreature(uiEntry, pos, uiType, uiDespawntime);
 }
+
 inline Creature *CreatureAI::DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float _fZ, float fRadius, uint32 uiDespawntime, TempSummonType uiType)
 {
     Position pos;
@@ -561,5 +620,6 @@ inline Creature *CreatureAI::DoSummonFlyer(uint32 uiEntry, WorldObject *obj, flo
     pos.m_positionZ += _fZ;
     return me->SummonCreature(uiEntry, pos, uiType, uiDespawntime);
 }
+
 #endif
 
diff --git a/src/game/CreatureAIRegistry.cpp b/src/game/CreatureAIRegistry.cpp
index 900f89da3b4..67c1f857a56 100644
--- a/src/game/CreatureAIRegistry.cpp
+++ b/src/game/CreatureAIRegistry.cpp
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "PassiveAI.h"
 #include "ReactorAI.h"
 #include "CombatAI.h"
@@ -29,6 +30,7 @@
 #include "CreatureAIRegistry.h"
 #include "WaypointMovementGenerator.h"
 #include "CreatureAIFactory.h"
+
 //#include "CreatureAIImpl.h"
 namespace AIRegistry
 {
@@ -47,6 +49,7 @@ namespace AIRegistry
         (new CreatureAIFactory("ArchorAI"))->RegisterSelf();
         (new CreatureAIFactory("TurretAI"))->RegisterSelf();
         (new CreatureAIFactory("EventAI"))->RegisterSelf();
+
         (new MovementGeneratorFactory >(RANDOM_MOTION_TYPE))->RegisterSelf();
         (new MovementGeneratorFactory >(WAYPOINT_MOTION_TYPE))->RegisterSelf();
     }
diff --git a/src/game/CreatureAIRegistry.h b/src/game/CreatureAIRegistry.h
index c75167d74af..2b92a096731 100644
--- a/src/game/CreatureAIRegistry.h
+++ b/src/game/CreatureAIRegistry.h
@@ -17,8 +17,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_CREATUREAIREGISTRY_H
 #define TRINITY_CREATUREAIREGISTRY_H
+
 namespace AIRegistry
 {
     void Initialize(void);
diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp
index 2f7bd0ff211..9f2828bf776 100644
--- a/src/game/CreatureAISelector.cpp
+++ b/src/game/CreatureAISelector.cpp
@@ -17,6 +17,7 @@
  * 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 "CreatureAISelector.h"
 #include "PassiveAI.h"
@@ -26,24 +27,30 @@
 #include "Pet.h"
 #include "TemporarySummon.h"
 #include "CreatureAIFactory.h"
+
 INSTANTIATE_SINGLETON_1(CreatureAIRegistry);
 INSTANTIATE_SINGLETON_1(MovementGeneratorRegistry);
+
 namespace FactorySelector
 {
     CreatureAI* selectAI(Creature *creature)
     {
         const CreatureAICreator *ai_factory = NULL;
         CreatureAIRegistry &ai_registry(CreatureAIRepository::Instance());
+
         if(creature->isPet())
             ai_factory = ai_registry.GetRegistryItem("PetAI");
+
         //scriptname in db
         if(!ai_factory)
             if(CreatureAI* scriptedAI = Script->GetAI(creature))
                 return scriptedAI;
+
         // AIname in db
         std::string ainame=creature->GetAIName();
         if(!ai_factory && !ainame.empty())
             ai_factory = ai_registry.GetRegistryItem( ainame.c_str() );
+
         // select by NPC flags
         if(!ai_factory)
         {
@@ -67,6 +74,7 @@ namespace FactorySelector
             else if(creature->GetCreatureType() == CREATURE_TYPE_CRITTER && !creature->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
                 ai_factory = ai_registry.GetRegistryItem("CritterAI");
         }
+
         if(!ai_factory)
         {
             for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
@@ -78,6 +86,7 @@ namespace FactorySelector
                 }
             }
         }
+
         // select by permit check
         if(!ai_factory)
         {
@@ -97,16 +106,20 @@ namespace FactorySelector
                 }
             }
         }
+
         // 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(creature) : 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;
@@ -125,7 +138,9 @@ namespace FactorySelector
             }
             }
         }*/
+
         return ( mv_factory == NULL ? NULL : mv_factory->Create(creature) );
+
     }
 }
 
diff --git a/src/game/CreatureAISelector.h b/src/game/CreatureAISelector.h
index e7e980518dd..436233b5b21 100644
--- a/src/game/CreatureAISelector.h
+++ b/src/game/CreatureAISelector.h
@@ -17,11 +17,14 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+
 #ifndef TRINITY_CREATUREAISELECTOR_H
 #define TRINITY_CREATUREAISELECTOR_H
+
 class CreatureAI;
 class Creature;
 class MovementGenerator;
+
 namespace FactorySelector
 {
     CreatureAI* selectAI(Creature *);
diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp
index 9a6e907f33b..b2f5dc354d2 100644
--- a/src/game/CreatureEventAI.cpp
+++ b/src/game/CreatureEventAI.cpp
@@ -17,6 +17,7 @@
  * 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 "CreatureEventAI.h"
 #include "CreatureEventAIMgr.h"
@@ -31,6 +32,7 @@
 #include "InstanceData.h"
 #include "SpellMgr.h"
 #include "CreatureAIImpl.h"
+
 bool CreatureEventAIHolder::UpdateRepeatTimer( Creature* creature, uint32 repeatMin, uint32 repeatMax )
 {
     if (repeatMin == repeatMax)
@@ -43,14 +45,17 @@ bool CreatureEventAIHolder::UpdateRepeatTimer( Creature* creature, uint32 repeat
         Enabled = false;
         return false;
     }
+
     return true;
 }
+
 int CreatureEventAI::Permissible(const Creature *creature)
 {
     if( creature->GetAIName() == "EventAI" )
         return PERMIT_BASE_SPECIAL;
     return PERMIT_BASE_NO;
 }
+
 CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
 {
     // Need make copy for filter unneeded steps and safe in case table reload
@@ -60,6 +65,7 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
         std::vector::const_iterator i;
         for (i = (*CreatureEvents).second.begin(); i != (*CreatureEvents).second.end(); ++i)
         {
+
             //Debug check
             #ifndef TRINITY_DEBUG
             if ((*i).event_flags & EFLAG_DEBUG_ONLY)
@@ -83,13 +89,16 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
     }
     else
         sLog.outError("CreatureEventAI: EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry());
+
     bEmptyList = CreatureEventAIList.empty();
     Phase = 0;
     CombatMovementEnabled = true;
     MeleeEnabled = true;
     AttackDistance = 0.0f;
     AttackAngle = 0.0f;
+
     InvinceabilityHpLevel = 0;
+
     //Handle Spawned Events
     if (!bEmptyList)
     {
@@ -98,26 +107,32 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
                 ProcessEvent(*i);
     }
 }
+
 bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker)
 {
     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;
+
     CreatureEventAI_Event const& event = pHolder.Event;
+
     //Check event conditions based on the event type, also reset events
     switch (event.event_type)
     {
         case EVENT_T_TIMER:
             if (!m_creature->isInCombat())
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.timer.repeatMin,event.timer.repeatMax);
             break;
         case EVENT_T_TIMER_OOC:
             if (m_creature->isInCombat())
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.timer.repeatMin,event.timer.repeatMax);
             break;
@@ -125,9 +140,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
         {
             if (!m_creature->isInCombat() || !m_creature->GetMaxHealth())
                 return false;
+
             uint32 perc = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth();
+
             if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax);
             break;
@@ -136,9 +154,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
         {
             if (!m_creature->isInCombat() || !m_creature->GetMaxPower(POWER_MANA))
                 return false;
+
             uint32 perc = (m_creature->GetPower(POWER_MANA)*100) / m_creature->GetMaxPower(POWER_MANA);
+
             if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax);
             break;
@@ -154,6 +175,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
             break;
         case EVENT_T_SPELLHIT:
             //Spell hit is special case, param1 and param2 handled within CreatureEventAI::SpellHit
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.spell_hit.repeatMin,event.spell_hit.repeatMax);
             break;
@@ -171,9 +193,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
         {
             if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth())
                 return false;
+
             uint32 perc = (m_creature->getVictim()->GetHealth()*100) / m_creature->getVictim()->GetMaxHealth();
+
             if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax);
             break;
@@ -181,6 +206,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
         case EVENT_T_TARGET_CASTING:
             if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true))
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.target_casting.repeatMin,event.target_casting.repeatMax);
             break;
@@ -188,10 +214,13 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
         {
             if (!m_creature->isInCombat())
                 return false;
+
             Unit* pUnit = DoSelectLowestHpFriendly(event.friendly_hp.radius, event.friendly_hp.hpDeficit);
             if (!pUnit)
                 return false;
+
             pActionInvoker = pUnit;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.friendly_hp.repeatMin,event.friendly_hp.repeatMax);
             break;
@@ -200,13 +229,17 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
         {
             if (!m_creature->isInCombat())
                 return false;
+
             std::list pList;
             DoFindFriendlyCC(pList, event.friendly_is_cc.radius);
+
             //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
             pHolder.UpdateRepeatTimer(m_creature,event.friendly_is_cc.repeatMin,event.friendly_is_cc.repeatMax);
             break;
@@ -215,11 +248,14 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
         {
             std::list pList;
             DoFindFriendlyMissingBuff(pList, event.friendly_buff.radius, event.friendly_buff.spellId);
+
             //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
             pHolder.UpdateRepeatTimer(m_creature,event.friendly_buff.repeatMin,event.friendly_buff.repeatMax);
             break;
@@ -229,9 +265,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
             //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 (((Creature*)pActionInvoker)->GetEntry() != event.summon_unit.creatureId)
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.summon_unit.repeatMin,event.summon_unit.repeatMax);
             break;
@@ -240,9 +278,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
         {
             if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxPower(POWER_MANA))
                 return false;
+
             uint32 perc = (m_creature->getVictim()->GetPower(POWER_MANA)*100) / m_creature->getVictim()->GetMaxPower(POWER_MANA);
+
             if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax);
             break;
@@ -257,6 +298,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
             Aura* aura = m_creature->GetAura(event.buffed.spellId,0);
             if(!aura || aura->GetStackAmount() < event.buffed.amount)
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax);
             break;
@@ -266,11 +308,13 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
             //Prevent event from occuring on no unit
             if (!pActionInvoker)
                 return false;
+
             //Note: checked only aura for effect 0, if need check aura for effect 1/2 then
             // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx)
             Aura* aura = pActionInvoker->GetAura(event.buffed.spellId,0);
             if(!aura || aura->GetStackAmount() < event.buffed.amount)
                 return false;
+
             //Repeat Timers
             pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax);
             break;
@@ -279,19 +323,25 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
             sLog.outErrorDb("CreatureEventAI: 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;
+
     //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;
+
     //Process actions
     for (uint32 j = 0; j < MAX_ACTIONS; j++)
         ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker);
+
     return true;
 }
+
 void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker)
 {
     switch (action.type)
@@ -300,16 +350,20 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
         {
             if (!action.text.TextId1)
                 return;
+
             int32 temp = 0;
+
             if (action.text.TextId2 && action.text.TextId3)
                 temp = RAND(action.text.TextId1,action.text.TextId2,action.text.TextId3);
             else if (action.text.TextId2 && urand(0,1))
                 temp = action.text.TextId2;
             else
                 temp = action.text.TextId1;
+
             if (temp)
             {
                 Unit* target = NULL;
+
                 if (pActionInvoker)
                 {
                     if (pActionInvoker->GetTypeId() == TYPEID_PLAYER)
@@ -327,6 +381,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
                             if (owner->GetTypeId() == TYPEID_PLAYER)
                                 target = owner;
                 }
+
                 DoScriptText(temp, m_creature, target);
             }
             break;
@@ -391,21 +446,27 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
         {
             Unit* target = GetTargetByType(action.cast.target, pActionInvoker);
             Unit* caster = m_creature;
+
             if (!target)
                 return;
+
             if (action.cast.castFlags & CAST_FORCE_TARGET_SELF)
                 caster = target;
+
             //Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered
             bool canCast = !caster->IsNonMeleeSpellCasted(false) || (action.cast.castFlags & (CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS));
+
             // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them
             if(action.cast.castFlags & CAST_AURA_NOT_PRESENT)
             {
                 if(target->HasAura(action.cast.spellId))
                     return;
             }
+
             if (canCast)
             {
                 const SpellEntry* tSpell = GetSpellStore()->LookupEntry(action.cast.spellId);
+
                 //Verify that spell exists
                 if (tSpell)
                 {
@@ -420,17 +481,21 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
                             {
                                 AttackDistance = 0.0f;
                                 AttackAngle = 0.0f;
+
                                 m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle);
                             }
                         }
+
                     }
                     else
                     {
                         //Interrupt any previous spell
                         if (caster->IsNonMeleeSpellCasted(false) && action.cast.castFlags & CAST_INTURRUPT_PREVIOUS)
                             caster->InterruptNonMeleeSpells(false);
+
                         caster->CastSpell(target, action.cast.spellId, (action.cast.castFlags & CAST_TRIGGERED));
                     }
+
                 }
                 else
                     sLog.outErrorDb("CreatureEventAI: event %d creature %d attempt to cast spell that doesn't exist %d", EventId, m_creature->GetEntry(), action.cast.spellId);
@@ -440,11 +505,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
         case ACTION_T_SUMMON:
         {
             Unit* target = GetTargetByType(action.summon.target, pActionInvoker);
+
             Creature* pCreature = NULL;
+
             if (action.summon.duration)
                 pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration);
             else
                 pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
+
             if (!pCreature)
                 sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry());
             else if (action.summon.target != TARGET_T_SELF && target)
@@ -476,11 +544,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
         case ACTION_T_SET_UNIT_FIELD:
         {
             Unit* target = GetTargetByType(action.set_unit_field.target, pActionInvoker);
+
             // not allow modify important for integrity object fields
             if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END)
                 return;
+
             if (target)
                 target->SetUInt32Value(action.set_unit_field.field, action.set_unit_field.value);
+
             break;
         }
         case ACTION_T_SET_UNIT_FLAG:
@@ -498,13 +569,16 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
             // ignore no affect case
             if(CombatMovementEnabled==(action.combat_movement.state!=0))
                 return;
+
             CombatMovementEnabled = action.combat_movement.state != 0;
+
             //Allow movement (create new targeted movement gen only if idle)
             if (CombatMovementEnabled)
             {
                 if(action.combat_movement.melee && m_creature->isInCombat())
                     if(Unit* victim = m_creature->getVictim())
                         m_creature->SendMeleeAttackStart(victim);
+
                 m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle);
             }
             else
@@ -512,6 +586,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
                 if(action.combat_movement.melee && m_creature->isInCombat())
                     if(Unit* victim = m_creature->getVictim())
                         m_creature->SendMeleeAttackStop(victim);
+
                 m_creature->GetMotionMaster()->MoveIdle();
             }
             break;
@@ -533,6 +608,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
             }
             else
                 Phase = new_phase;
+
             break;
         }
         case ACTION_T_EVADE:
@@ -565,6 +641,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
         case ACTION_T_RANGED_MOVEMENT:
             AttackDistance = (float)action.ranged_movement.distance;
             AttackAngle = action.ranged_movement.angle/180.0f*M_PI;
+
             if (CombatMovementEnabled)
             {
                 m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle);
@@ -582,21 +659,25 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
         case ACTION_T_SUMMON_ID:
         {
             Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker);
+
             CreatureEventAI_Summon_Map::const_iterator i = CreatureEAI_Mgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId);
             if (i == CreatureEAI_Mgr.GetCreatureEventAISummonMap().end())
             {
                 sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, EventId, m_creature->GetEntry());
                 return;
             }
+
             Creature* pCreature = NULL;
             if ((*i).second.SpawnTimeSecs)
                 pCreature = m_creature->SummonCreature(action.summon_id.creatureId, (*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(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
+
             if (!pCreature)
                 sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry());
             else if (action.summon_id.target != TARGET_T_SELF && target)
                 pCreature->AI()->AttackStart(target);
+
             break;
         }
         case ACTION_T_KILLED_MONSTER:
@@ -619,6 +700,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
                 sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", EventId, m_creature->GetEntry());
                 return;
             }
+
             pInst->SetData(action.set_inst_data.field, action.set_inst_data.value);
             break;
         }
@@ -630,26 +712,31 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
                 sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry());
                 return;
             }
+
             InstanceData* pInst = (InstanceData*)m_creature->GetInstanceData();
             if (!pInst)
             {
                 sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", EventId, m_creature->GetEntry());
                 return;
             }
+
             pInst->SetData64(action.set_inst_data64.field, target->GetGUID());
             break;
         }
         case ACTION_T_UPDATE_TEMPLATE:
             if (m_creature->GetEntry() == action.update_template.creatureId)
             {
+
                 sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, m_creature->GetEntry());
                 return;
             }
+
             m_creature->UpdateEntry(action.update_template.creatureId, action.update_template.team ? HORDE : ALLIANCE);
             break;
         case ACTION_T_DIE:
             if (m_creature->isDead())
             {
+
                 sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry());
                 return;
             }
@@ -666,6 +753,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
             break;
         }
         break;
+
         // TRINITY ONLY
         case ACTION_T_SET_ACTIVE:
             me->setActive(action.raw.param1 ? true : false);
@@ -679,6 +767,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
         case ACTION_T_SUMMON_GO:
         {
             GameObject* pObject = NULL;
+
             float x,y,z;
             m_creature->GetPosition(x,y,z);
             pObject = m_creature->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2);
@@ -688,6 +777,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
             }
             break;
         }
+
         case ACTION_T_SET_SHEATH:
         {
             m_creature->SetSheath(SheathState(action.set_sheath.sheath));
@@ -708,22 +798,28 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
         }
     }
 }
+
 void CreatureEventAI::JustRespawned()
 {
     Reset();
+
     if (bEmptyList)
         return;
+
     //Handle Spawned Events
     for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
         if (SpawnedEventConditionsCheck((*i).Event))
             ProcessEvent(*i);
 }
+
 void CreatureEventAI::Reset()
 {
     EventUpdateTime = EVENT_UPDATE_TIME;
     EventDiff = 0;
+
     if (bEmptyList)
         return;
+
     //Reset all events to enabled
     for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
     {
@@ -745,9 +841,11 @@ void CreatureEventAI::Reset()
         }
     }
 }
+
 void CreatureEventAI::JustReachedHome()
 {
     m_creature->LoadCreaturesAddon();
+
     if (!bEmptyList)
     {
         for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
@@ -756,13 +854,17 @@ void CreatureEventAI::JustReachedHome()
                 ProcessEvent(*i);
         }
     }
+
     Reset();
 }
+
 void CreatureEventAI::EnterEvadeMode()
 {
     CreatureAI::EnterEvadeMode();
+
     if (bEmptyList)
         return;
+
     //Handle Evade events
     for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
     {
@@ -770,40 +872,49 @@ void CreatureEventAI::EnterEvadeMode()
             ProcessEvent(*i);
     }
 }
+
 void CreatureEventAI::JustDied(Unit* killer)
 {
     Reset();
+
     if (bEmptyList)
         return;
+
     //Handle Evade events
     for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
     {
         if ((*i).Event.event_type == EVENT_T_DEATH)
             ProcessEvent(*i, killer);
     }
+
     // reset phase after any death state events
     Phase = 0;
 }
+
 void CreatureEventAI::KilledUnit(Unit* victim)
 {
     if (bEmptyList || victim->GetTypeId() != TYPEID_PLAYER)
         return;
+
     for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
     {
         if ((*i).Event.event_type == EVENT_T_KILL)
             ProcessEvent(*i, victim);
     }
 }
+
 void CreatureEventAI::JustSummoned(Creature* pUnit)
 {
     if (bEmptyList || !pUnit)
         return;
+
     for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
     {
         if ((*i).Event.event_type == EVENT_T_SUMMONED_UNIT)
             ProcessEvent(*i, pUnit);
     }
 }
+
 void CreatureEventAI::EnterCombat(Unit *enemy)
 {
     //Check for on combat start events
@@ -831,13 +942,16 @@ void CreatureEventAI::EnterCombat(Unit *enemy)
             }
         }
     }
+
     EventUpdateTime = EVENT_UPDATE_TIME;
     EventDiff = 0;
 }
+
 void CreatureEventAI::AttackStart(Unit *who)
 {
     if (!who)
         return;
+
     if (m_creature->Attack(who, MeleeEnabled))
     {
         if (CombatMovementEnabled)
@@ -850,10 +964,12 @@ void CreatureEventAI::AttackStart(Unit *who)
         }
     }
 }
+
 void CreatureEventAI::MoveInLineOfSight(Unit *who)
 {
     if(me->getVictim())
         return;
+
     //Check for OOC LOS Event
     if (!bEmptyList)
     {
@@ -863,6 +979,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
             {
                 //can trigger if closer than fMaxAllowedRange
                 float fMaxAllowedRange = (*itr).Event.ooc_los.maxRange;
+
                 //if range is ok and we are actually in LOS
                 if (m_creature->IsWithinDistInMap(who, fMaxAllowedRange) && m_creature->IsWithinLOSInMap(who))
                 {
@@ -874,12 +991,16 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
             }
         }
     }
+
     CreatureAI::MoveInLineOfSight(who);
 }
+
 void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
 {
+
     if (bEmptyList)
         return;
+
     for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
         if ((*i).Event.event_type == EVENT_T_SPELLHIT)
             //If spell id matches (or no spell id) & if spell school matches (or no spell school)
@@ -887,16 +1008,19 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
                 if (pSpell->SchoolMask & (*i).Event.spell_hit.schoolMask)
                     ProcessEvent(*i, pUnit);
 }
+
 void CreatureEventAI::UpdateAI(const uint32 diff)
 {
     //Check if we are in combat (also updates calls threat update code)
     bool Combat = UpdateVictim();
+
     if (!bEmptyList)
     {
         //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 time based events
             for (std::list::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
             {
@@ -908,11 +1032,13 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
                         //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;
                 }
+
                 //Events that are updated every EVENT_UPDATE_TIME
                 switch ((*i).Event.event_type)
                 {
@@ -936,6 +1062,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
                         break;
                 }
             }
+
             EventDiff = 0;
             EventUpdateTime = EVENT_UPDATE_TIME;
         }
@@ -945,18 +1072,22 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
             EventUpdateTime -= diff;
         }
     }
+
     //Melee Auto-Attack
     if (Combat && MeleeEnabled)
         DoMeleeAttackIfReady();
 }
+
 inline Unit* CreatureEventAI::SelectUnit(AttackingTarget 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 ATTACKING_TARGET_RANDOM:
@@ -977,6 +1108,7 @@ inline Unit* CreatureEventAI::SelectUnit(AttackingTarget target, uint32 position
     }
     return NULL;
 }
+
 inline uint32 CreatureEventAI::GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3)
 {
     switch (rnd % 3)
@@ -987,6 +1119,7 @@ inline uint32 CreatureEventAI::GetRandActionParam(uint32 rnd, uint32 param1, uin
     }
     return 0;
 }
+
 inline int32 CreatureEventAI::GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3)
 {
     switch (rnd % 3)
@@ -997,6 +1130,7 @@ inline int32 CreatureEventAI::GetRandActionParam(uint32 rnd, int32 param1, int32
     }
     return 0;
 }
+
 inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoker)
 {
     switch (Target)
@@ -1019,50 +1153,65 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke
             return NULL;
     };
 }
+
 Unit* CreatureEventAI::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;
+
     MaNGOS::MostHPMissingInRange u_check(m_creature, range, MinHPDiff);
     MaNGOS::UnitLastSearcher searcher(m_creature, 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(), *m_creature, range);
     return pUnit;
 }
+
 void CreatureEventAI::DoFindFriendlyCC(std::list& _list, float range)
 {
     CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
     Cell cell(p);
     cell.data.Part.reserved = ALL_DISTRICT;
     cell.SetNoCreate();
+
     MaNGOS::FriendlyCCedInRange u_check(m_creature, range);
     MaNGOS::CreatureListSearcher searcher(m_creature, _list, u_check);
+
     TypeContainerVisitor, GridTypeMapContainer >  grid_creature_searcher(searcher);
+
     CellLock cell_lock(cell, p);
     cell_lock->Visit(cell_lock, grid_creature_searcher, *m_creature->GetMap());
 }
+
 void CreatureEventAI::DoFindFriendlyMissingBuff(std::list& _list, 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();
+
     MaNGOS::FriendlyMissingBuffInRange u_check(m_creature, range, spellid);
     MaNGOS::CreatureListSearcher searcher(m_creature, _list, u_check);
+
     TypeContainerVisitor, GridTypeMapContainer >  grid_creature_searcher(searcher);
+
     CellLock cell_lock(cell, p);
     cell_lock->Visit(cell_lock, grid_creature_searcher, *m_creature->GetMap());
 }
+
 //*********************************
 //*** Functions used globally ***
+
 void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target)
 {
     if (!pSource)
@@ -1070,18 +1219,23 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
         sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i, invalid Source pointer.",textEntry);
         return;
     }
+
     if (textEntry >= 0)
     {
         sLog.outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.",pSource->GetEntry(),pSource->GetTypeId(),pSource->GetGUIDLow(),textEntry);
         return;
     }
+
     CreatureEventAI_TextMap::const_iterator i = CreatureEAI_Mgr.GetCreatureEventAITextMap().find(textEntry);
+
     if (i == CreatureEAI_Mgr.GetCreatureEventAITextMap().end())
     {
         sLog.outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.",pSource->GetEntry(),pSource->GetTypeId(),pSource->GetGUIDLow(),textEntry);
         return;
     }
+
     sLog.outDebug("CreatureEventAI: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",textEntry,(*i).second.SoundId,(*i).second.Type,(*i).second.Language,(*i).second.Emote);
+
     if((*i).second.SoundId)
     {
         if (GetSoundEntriesStore()->LookupEntry((*i).second.SoundId))
@@ -1089,6 +1243,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
         else
             sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.",textEntry,(*i).second.SoundId);
     }
+
     if((*i).second.Emote)
     {
         if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER)
@@ -1098,6 +1253,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
         else
             sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).",textEntry,pSource->GetTypeId());
     }
+
     switch((*i).second.Type)
     {
         case CHAT_TYPE_SAY:
@@ -1129,37 +1285,48 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
             break;
     }
 }
+
 bool CreatureEventAI::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 && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
         return false;
+
     //Check for power
     if (!Triggered && me->GetPower((Powers)Spell->powerType) < CalculatePowerCost(Spell, me, GetSpellSchoolMask(Spell)))
         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->IsInRange(Target,TempRange->minRangeHostile,TempRange->maxRangeHostile))
         return false;
+
     return true;
 }
+
 void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
 {
     if (bEmptyList)
         return;
+
     for (std::list::iterator itr = CreatureEventAIList.begin(); itr != CreatureEventAIList.end(); ++itr)
     {
         if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE)
         {
             if ((*itr).Event.receive_emote.emoteId != text_emote)
                 return;
+
             PlayerCondition pcon((*itr).Event.receive_emote.condition,(*itr).Event.receive_emote.conditionValue1,(*itr).Event.receive_emote.conditionValue2);
             if (pcon.Meets(pPlayer))
             {
@@ -1169,6 +1336,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
         }
     }
 }
+
 void CreatureEventAI::DamageTaken( Unit* done_by, uint32& damage )
 {
     if(InvinceabilityHpLevel > 0 && m_creature->GetHealth() < InvinceabilityHpLevel+damage)
@@ -1179,10 +1347,12 @@ void CreatureEventAI::DamageTaken( Unit* done_by, uint32& damage )
             damage = m_creature->GetHealth() - InvinceabilityHpLevel;
     }
 }
+
 bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event)
 {
     if(event.event_type != EVENT_T_SPAWNED)
         return false;
+
     switch (event.spawned.condition)
     {
         case SPAWNED_EVENT_ALWAY:
@@ -1201,5 +1371,6 @@ bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& e
         default:
             break;
     }
+
     return false;
 }
diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h
index b26dfe2e055..7882e7542ec 100644
--- a/src/game/CreatureEventAI.h
+++ b/src/game/CreatureEventAI.h
@@ -15,17 +15,22 @@
  * 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_CREATURE_EAI_H
 #define MANGOS_CREATURE_EAI_H
+
 #include "Common.h"
 #include "Creature.h"
 #include "CreatureAI.h"
 #include "Unit.h"
+
 class Player;
 class WorldObject;
+
 #define EVENT_UPDATE_TIME               500
 #define MAX_ACTIONS                     3
 #define MAX_PHASE                       32
+
 enum EventAI_Type
 {
     EVENT_T_TIMER                   = 0,                    // InitialMin, InitialMax, RepeatMin, RepeatMax
@@ -53,8 +58,10 @@ enum EventAI_Type
     EVENT_T_RECEIVE_EMOTE           = 22,                   // EmoteId, Condition, CondValue1, CondValue2
     EVENT_T_BUFFED                  = 23,                   // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max
     EVENT_T_TARGET_BUFFED           = 24,                   // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max
+
     EVENT_T_END,
 };
+
 enum EventAI_ActionType
 {
     ACTION_T_NONE                       = 0,                // No action
@@ -98,35 +105,44 @@ enum EventAI_ActionType
     ACTION_T_ZONE_COMBAT_PULSE          = 38,               // No Params
     ACTION_T_CALL_FOR_HELP              = 39,               // Radius
     ACTION_T_SET_SHEATH                 = 40,               // Sheath (0-passive,1-melee,2-ranged)
+
     ACTION_T_SET_ACTIVE                 = 101,  //Apply
     ACTION_T_SET_AGGRESSIVE             = 102,  //Apply
     ACTION_T_ATTACK_START_PULSE         = 103,  //Distance
     ACTION_T_SUMMON_GO                  = 104,  //GameObjectID, DespawnTime in ms
+
     ACTION_T_FORCE_DESPAWN              = 41,               // No Params
     ACTION_T_END = 105,
     ACTION_T_SET_INVINCIBILITY_HP_LEVEL = 42,               // MinHpValue, format(0-flat,1-percent from max health)
 };
+
 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
@@ -136,6 +152,7 @@ enum CastFlags
     CAST_FORCE_TARGET_SELF      = 0x10,                     //Forces the target to cast this spell on itself
     CAST_AURA_NOT_PRESENT       = 0x20,                     //Only casts the spell if the target does not have an aura from the spell
 };
+
 enum EventFlags
 {
     EFLAG_REPEATABLE            = 0x01,                     //Event repeats
@@ -147,12 +164,14 @@ enum EventFlags
     EFLAG_RESERVED_6            = 0x40,
     EFLAG_DEBUG_ONLY            = 0x80,                     //Event only occurs in debug build
 };
+
 enum SpawnedEventMode
 {
     SPAWNED_EVENT_ALWAY = 0,
     SPAWNED_EVENT_MAP   = 1,
     SPAWNED_EVENT_ZONE  = 2
 };
+
 // String text additional data, used in (CreatureEventAI)
 struct StringTextData
 {
@@ -163,6 +182,7 @@ struct StringTextData
 };
 // Text Maps
 typedef UNORDERED_MAP CreatureEventAI_TextMap;
+
 struct CreatureEventAI_Action
 {
     EventAI_ActionType type: 16;
@@ -375,14 +395,19 @@ struct CreatureEventAI_Action
         } raw;
     };
 };
+
 struct CreatureEventAI_Event
 {
     uint32 event_id;
+
     uint32 creature_id;
+
     uint32 event_inverse_phase_mask;
+
     EventAI_Type event_type : 16;
     uint8 event_chance : 8;
     uint8 event_flags  : 8;
+
     union
     {
         // EVENT_T_TIMER                                    = 0
@@ -501,6 +526,7 @@ struct CreatureEventAI_Event
             uint32 repeatMin;
             uint32 repeatMax;
         } buffed;
+
         // RAW
         struct
         {
@@ -510,32 +536,41 @@ struct CreatureEventAI_Event
             uint32 param4;
         } raw;
     };
+
     CreatureEventAI_Action action[MAX_ACTIONS];
 };
 //Event_Map
 typedef UNORDERED_MAP > CreatureEventAI_Event_Map;
+
 struct CreatureEventAI_Summon
 {
     uint32 id;
+
     float position_x;
     float position_y;
     float position_z;
     float orientation;
     uint32 SpawnTimeSecs;
 };
+
 //EventSummon_Map
 typedef UNORDERED_MAP CreatureEventAI_Summon_Map;
+
 struct CreatureEventAIHolder
 {
     CreatureEventAIHolder(CreatureEventAI_Event p) : Event(p), Time(0), Enabled(true){}
+
     CreatureEventAI_Event Event;
     uint32 Time;
     bool Enabled;
+
     // helper
     bool UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax);
 };
+
 class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI
 {
+
     public:
         explicit CreatureEventAI(Creature *c);
         ~CreatureEventAI()
@@ -557,23 +592,29 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI
         void UpdateAI(const uint32 diff);
         void ReceiveEmote(Player* pPlayer, uint32 text_emote);
         static int Permissible(const Creature *);
+
         bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL);
         void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker);
         inline uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3);
         inline int32 GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3);
         inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker);
         inline Unit* SelectUnit(AttackingTarget target, uint32 position);
+
         void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target);
         bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered);
+
         bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event);
+
         Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff);
         void DoFindFriendlyMissingBuff(std::list& _list, float range, uint32 spellid);
         void DoFindFriendlyCC(std::list& _list, float range);
+
                                                             //Holder for events (stores enabled, time, and eventid)
         std::list CreatureEventAIList;
         uint32 EventUpdateTime;                             //Time between event updates
         uint32 EventDiff;                                   //Time between the last event call
         bool bEmptyList;
+
         //Variables used by Events themselves
         uint8 Phase;                                        // Current phase, max 32 phases
         bool CombatMovementEnabled;                         // If we allow targeted movment gen (movement twoards top threat)
diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp
index 18c4ca97de4..5325edff4a9 100644
--- a/src/game/CreatureEventAIMgr.cpp
+++ b/src/game/CreatureEventAIMgr.cpp
@@ -15,6 +15,7 @@
  * 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"
@@ -25,61 +26,77 @@
 #include "Policies/SingletonImp.h"
 #include "ObjectDefines.h"
 #include "GridDefines.h"
+
 INSTANTIATE_SINGLETON_1(CreatureEventAIMgr);
+
 // -------------------
 void CreatureEventAIMgr::LoadCreatureEventAI_Texts()
 {
     // Drop Existing Text Map, only done once and we are ready to add data from multiple sources.
     m_CreatureEventAI_TextMap.clear();
+
     // Load EventAI Text
     objmgr.LoadTrinityStrings(WorldDatabase,"creature_ai_texts",MIN_CREATURE_AI_TEXT_STRING_ID,MAX_CREATURE_AI_TEXT_STRING_ID);
+
     // Gather Additional data from EventAI Texts
     QueryResult *result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM creature_ai_texts");
+
     sLog.outString("Loading EventAI Texts additional data...");
     if (result)
     {
         barGoLink bar(result->GetRowCount());
         uint32 count = 0;
+
         do
         {
             bar.step();
             Field* fields = result->Fetch();
             StringTextData temp;
+
             int32 i             = fields[0].GetInt32();
             temp.SoundId        = fields[1].GetInt32();
             temp.Type           = fields[2].GetInt32();
             temp.Language       = fields[3].GetInt32();
             temp.Emote          = fields[4].GetInt32();
+
             // range negative
             if (i > MIN_CREATURE_AI_TEXT_STRING_ID || i <= MAX_CREATURE_AI_TEXT_STRING_ID)
             {
                 sLog.outErrorDb("CreatureEventAI:  Entry %i in table `creature_ai_texts` is not in valid range(%d-%d)",i,MIN_CREATURE_AI_TEXT_STRING_ID,MAX_CREATURE_AI_TEXT_STRING_ID);
                 continue;
             }
+
             // range negative (don't must be happen, loaded from same table)
             if (!objmgr.GetTrinityStringLocale(i))
             {
                 sLog.outErrorDb("CreatureEventAI:  Entry %i in table `creature_ai_texts` not found",i);
                 continue;
             }
+
             if (temp.SoundId)
             {
                 if (!sSoundEntriesStore.LookupEntry(temp.SoundId))
                     sLog.outErrorDb("CreatureEventAI:  Entry %i in table `creature_ai_texts` has Sound %u but sound does not exist.",i,temp.SoundId);
             }
+
             if (!GetLanguageDescByID(temp.Language))
                 sLog.outErrorDb("CreatureEventAI:  Entry %i in table `creature_ai_texts` using Language %u but Language does not exist.",i,temp.Language);
+
             if (temp.Type > CHAT_TYPE_ZONE_YELL)
                 sLog.outErrorDb("CreatureEventAI:  Entry %i in table `creature_ai_texts` has Type %u but this Chat Type does not exist.",i,temp.Type);
+
             if (temp.Emote)
             {
                 if (!sEmotesStore.LookupEntry(temp.Emote))
                     sLog.outErrorDb("CreatureEventAI:  Entry %i in table `creature_ai_texts` has Emote %u but emote does not exist.",i,temp.Emote);
             }
+
             m_CreatureEventAI_TextMap[i] = temp;
             ++count;
         } while (result->NextRow());
+
         delete result;
+
         sLog.outString();
         sLog.outString(">> Loaded %u additional CreatureEventAI Texts data.", count);
     }
@@ -90,39 +107,50 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts()
         sLog.outString();
         sLog.outString(">> Loaded 0 additional CreatureEventAI Texts data. DB table `creature_ai_texts` is empty.");
     }
+
 }
+
 // -------------------
 void CreatureEventAIMgr::LoadCreatureEventAI_Summons()
 {
+
     //Drop Existing EventSummon Map
     m_CreatureEventAI_Summon_Map.clear();
+
     // Gather additional data for EventAI
     QueryResult *result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM creature_ai_summons");
     if (result)
     {
         barGoLink bar(result->GetRowCount());
         uint32 Count = 0;
+
         do
         {
             bar.step();
             Field *fields = result->Fetch();
+
             CreatureEventAI_Summon temp;
+
             uint32 i = fields[0].GetUInt32();
             temp.position_x = fields[1].GetFloat();
             temp.position_y = fields[2].GetFloat();
             temp.position_z = fields[3].GetFloat();
             temp.orientation = fields[4].GetFloat();
             temp.SpawnTimeSecs = fields[5].GetUInt32();
+
             if(!MaNGOS::IsValidMapCoord(temp.position_x,temp.position_y,temp.position_z,temp.orientation))
             {
                 sLog.outErrorDb("CreatureEventAI:  Summon id %u have wrong coordinates (%f,%f,%f,%f), skipping.", i,temp.position_x,temp.position_y,temp.position_z,temp.orientation);
                 continue;
             }
+
             //Add to map
             m_CreatureEventAI_Summon_Map[i] = temp;
             ++Count;
         } while (result->NextRow());
+
         delete result;
+
         sLog.outString();
         sLog.outString(">> Loaded %u CreatureEventAI summon definitions", Count);
     }
@@ -133,12 +161,15 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons()
         sLog.outString();
         sLog.outString(">> Loaded 0 CreatureEventAI Summon definitions. DB table `creature_ai_summons` is empty.");
     }
+
 }
+
 // -------------------
 void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
 {
     //Drop Existing EventAI List
     m_CreatureEventAI_Event_Map.clear();
+
     // Gather event data
     QueryResult *result = WorldDatabase.Query("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, "
         "event_param1, event_param2, event_param3, event_param4, "
@@ -150,15 +181,19 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
     {
         barGoLink bar(result->GetRowCount());
         uint32 Count = 0;
+
         do
         {
             bar.step();
             Field *fields = result->Fetch();
+
             CreatureEventAI_Event temp;
             temp.event_id = EventAI_Type(fields[0].GetUInt32());
             uint32 i = temp.event_id;
+
             temp.creature_id = fields[1].GetUInt32();
             uint32 creature_id = temp.creature_id;
+
             uint32 e_type = fields[2].GetUInt32();
             //Report any errors in event
             if (e_type >= EVENT_T_END)
@@ -167,6 +202,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                 continue;
             }
             temp.event_type = EventAI_Type(e_type);
+
             temp.event_inverse_phase_mask = fields[3].GetUInt32();
             temp.event_chance = fields[4].GetUInt8();
             temp.event_flags  = fields[5].GetUInt8();
@@ -174,12 +210,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
             temp.raw.param2 = fields[7].GetUInt32();
             temp.raw.param3 = fields[8].GetUInt32();
             temp.raw.param4 = fields[9].GetUInt32();
+
             //Creature does not exist in database
             if (!sCreatureStorage.LookupEntry(temp.creature_id))
             {
                 sLog.outErrorDb("CreatureEventAI:  Event %u has script for non-existing creature entry (%u), skipping.", i, temp.creature_id);
                 continue;
             }
+
             //No chance of this event occuring
             if (temp.event_chance == 0)
                 sLog.outErrorDb("CreatureEventAI:  Event %u has 0 percent chance. Event will never trigger!", i);
@@ -189,6 +227,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                 sLog.outErrorDb("CreatureEventAI:  Creature %u are using event %u with more than 100 percent chance. Adjusting to 100 percent.", temp.creature_id, i);
                 temp.event_chance = 100;
             }
+
             //Individual event checks
             switch (temp.event_type)
             {
@@ -205,8 +244,10 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                 case EVENT_T_TARGET_MANA:
                     if (temp.percent_range.percentMax > 100)
                         sLog.outErrorDb("CreatureEventAI:  Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i);
+
                     if (temp.percent_range.percentMax <= temp.percent_range.percentMin)
                         sLog.outErrorDb("CreatureEventAI:  Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i);
+
                     if (temp.event_flags & EFLAG_REPEATABLE && !temp.percent_range.repeatMin && !temp.percent_range.repeatMax)
                     {
                         sLog.outErrorDb("CreatureEventAI:  Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but cannot be repeatable without timers. Removing EFLAG_REPEATABLE for event %u.", temp.creature_id, i);
@@ -222,11 +263,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                             sLog.outErrorDb("CreatureEventAI:  Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i);
                             continue;
                         }
+
                         if ((temp.spell_hit.schoolMask & pSpell->SchoolMask) != pSpell->SchoolMask)
                             sLog.outErrorDb("CreatureEventAI:  Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i);
                     }
+
                     if (!temp.spell_hit.schoolMask)
                         sLog.outErrorDb("CreatureEventAI:  Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i);
+
                     if (temp.spell_hit.repeatMax < temp.spell_hit.repeatMin)
                         sLog.outErrorDb("CreatureEventAI:  Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
                     break;
@@ -297,6 +341,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                         sLog.outErrorDb("CreatureEventAI:  Creature %u are using event(%u) with not existed qyest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId);
                     sLog.outErrorDb("CreatureEventAI: Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i);
                     continue;
+
                 case EVENT_T_AGGRO:
                 case EVENT_T_DEATH:
                 case EVENT_T_EVADE:
@@ -307,8 +352,10 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                         sLog.outErrorDb("CreatureEventAI:  Creature %u has EFLAG_REPEATABLE set. Event can never be repeatable. Removing flag for event %u.", temp.creature_id, i);
                         temp.event_flags &= ~EFLAG_REPEATABLE;
                     }
+
                     break;
                 }
+
                 case EVENT_T_RECEIVE_EMOTE:
                 {
                     if (!sEmotesTextStore.LookupEntry(temp.receive_emote.emoteId))
@@ -316,18 +363,22 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                         sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param1 (EmoteTextId: %u) are not valid.",temp.creature_id, i, temp.receive_emote.emoteId);
                         continue;
                     }
+
                     if (!PlayerCondition::IsValid(ConditionType(temp.receive_emote.condition), temp.receive_emote.conditionValue1, temp.receive_emote.conditionValue2))
                     {
                         sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param2 (Condition: %u) are not valid.",temp.creature_id, i, temp.receive_emote.condition);
                         continue;
                     }
+
                     if (!(temp.event_flags & EFLAG_REPEATABLE))
                     {
                         sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: EFLAG_REPEATABLE not set. Event must always be repeatable. Flag applied.", temp.creature_id, i);
                         temp.event_flags |= EFLAG_REPEATABLE;
                     }
+
                     break;
                 }
+
                 case EVENT_T_BUFFED:
                 case EVENT_T_TARGET_BUFFED:
                 {
@@ -341,10 +392,12 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                         sLog.outErrorDb("CreatureEventAI:  Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
                     break;
                 }
+
                 default:
                     sLog.outErrorDb("CreatureEventAI: Creature %u using not checked at load event (%u) in event %u. Need check code update?", temp.creature_id, temp.event_id, i);
                     break;
             }
+
             for (uint32 j = 0; j < MAX_ACTIONS; j++)
             {
                 uint16 action_type = fields[10+(j*4)].GetUInt16();
@@ -354,11 +407,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                     temp.action[j].type = ACTION_T_NONE;
                     continue;
                 }
+
                 CreatureEventAI_Action& action = temp.action[j];
+
                 action.type = EventAI_ActionType(action_type);
                 action.raw.param1 = fields[11+(j*4)].GetUInt32();
                 action.raw.param2 = fields[12+(j*4)].GetUInt32();
                 action.raw.param3 = fields[13+(j*4)].GetUInt32();
+
                 //Report any errors in actions
                 switch (action.type)
                 {
@@ -375,6 +431,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                         {
                             if (m_CreatureEventAI_TextMap.find(action.text.TextId2) == m_CreatureEventAI_TextMap.end())
                                 sLog.outErrorDb("CreatureEventAI:  Event %u Action %u param2 refrences non-existing entry in texts table.", i, j+1);
+
                             if (!action.text.TextId1)
                                 sLog.outErrorDb("CreatureEventAI:  Event %u Action %u has param2, but param1 is not set. Required for randomized text.", i, j+1);
                         }
@@ -382,6 +439,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                         {
                             if (m_CreatureEventAI_TextMap.find(action.text.TextId3) == m_CreatureEventAI_TextMap.end())
                                 sLog.outErrorDb("CreatureEventAI:  Event %u Action %u param3 refrences non-existing entry in texts table.", i, j+1);
+
                             if (!action.text.TextId1 || !action.text.TextId2)
                                 sLog.outErrorDb("CreatureEventAI:  Event %u Action %u has param3, but param1 and/or param2 is not set. Required for randomized text.", i, j+1);
                         }
@@ -402,6 +460,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                                 sLog.outErrorDb("CreatureEventAI:  Event %u Action %u uses non-existant Creature entry %u.", i, j+1, action.morph.creatureId);
                                 action.morph.creatureId = 0;
                             }
+
                             if (action.morph.modelId)
                             {
                                 if (action.morph.creatureId)
@@ -457,9 +516,11 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                             }
                         }
                         */
+
                         //Cast is always triggered if target is forced to cast on self
                         if (action.cast.castFlags & CAST_FORCE_TARGET_SELF)
                             action.cast.castFlags |= CAST_TRIGGERED;
+
                         if (action.cast.target >= TARGET_T_END)
                             sLog.outErrorDb("CreatureEventAI:  Event %u Action %u uses incorrect Target type", i, j+1);
                         break;
@@ -467,6 +528,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                     case ACTION_T_SUMMON:
                         if (!sCreatureStorage.LookupEntry(action.summon.creatureId))
                             sLog.outErrorDb("CreatureEventAI:  Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.summon.creatureId);
+
                         if (action.summon.target >= TARGET_T_END)
                             sLog.outErrorDb("CreatureEventAI:  Event %u Action %u uses incorrect Target type", i, j+1);
                         break;
@@ -488,8 +550,10 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                         }
                         else
                             sLog.outErrorDb("CreatureEventAI:  Event %u Action %u uses non-existent Quest entry %u.", i, j+1, action.quest_event.questId);
+
                         if (action.quest_event.target >= TARGET_T_END)
                             sLog.outErrorDb("CreatureEventAI:  Event %u Action %u uses incorrect Target type", i, j+1);
+
                         break;
                     case ACTION_T_CAST_EVENT:
                         if (!sCreatureStorage.LookupEntry(action.cast_event.creatureId))
@@ -618,24 +682,29 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                     case ACTION_T_RANGED_MOVEMENT:          //Distance, Angle
                     case ACTION_T_CALL_FOR_HELP:            //Distance
                         break;
+
                     case ACTION_T_RANDOM_SAY:
                     case ACTION_T_RANDOM_YELL:
                     case ACTION_T_RANDOM_TEXTEMOTE:
                         sLog.outErrorDb("CreatureEventAI:  Event %u Action %u currently unused ACTION type. Did you forget to update database?", i, j+1);
                         break;
+
                     case ACTION_T_SET_ACTIVE:
                     case ACTION_T_SET_AGGRESSIVE:
                     case ACTION_T_ATTACK_START_PULSE:
                     case ACTION_T_SUMMON_GO:
                         break;
+
                     default:
                         sLog.outErrorDb("CreatureEventAI:  Event %u Action %u have currently not checked at load action type (%u). Need check code update?", i, j+1, temp.action[j].type);
                         break;
                 }
             }
+
             //Add to list
             m_CreatureEventAI_Event_Map[creature_id].push_back(temp);
             ++Count;
+
             if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(temp.creature_id))
             {
                 if(!cInfo->AIName || !cInfo->AIName[0])
@@ -653,9 +722,11 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
                 {
                     //sLog.outErrorDb("CreatureEventAI: Creature Entry %u has EventAI script but it also has C++ script. EventAI script will be overriden.", cInfo->Entry);
                 }
-            }
+            }            
         } while (result->NextRow());
+
         delete result;
+
         sLog.outString();
         sLog.outString(">> Loaded %u CreatureEventAI scripts", Count);
     }
diff --git a/src/game/CreatureEventAIMgr.h b/src/game/CreatureEventAIMgr.h
index 821cdb35c6a..b4672460cc6 100644
--- a/src/game/CreatureEventAIMgr.h
+++ b/src/game/CreatureEventAIMgr.h
@@ -15,25 +15,32 @@
  * 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_CREATURE_EAI_MGR_H
 #define MANGOS_CREATURE_EAI_MGR_H
+
 #include "Common.h"
 #include "CreatureEventAI.h"
+
 class CreatureEventAIMgr
 {
     public:
         CreatureEventAIMgr(){};
         ~CreatureEventAIMgr(){};
+
         void LoadCreatureEventAI_Texts();
         void LoadCreatureEventAI_Summons();
         void LoadCreatureEventAI_Scripts();
+
         CreatureEventAI_Event_Map  const& GetCreatureEventAIMap()       const { return m_CreatureEventAI_Event_Map; }
         CreatureEventAI_Summon_Map const& GetCreatureEventAISummonMap() const { return m_CreatureEventAI_Summon_Map; }
         CreatureEventAI_TextMap    const& GetCreatureEventAITextMap()   const { return m_CreatureEventAI_TextMap; }
+
     private:
         CreatureEventAI_Event_Map  m_CreatureEventAI_Event_Map;
         CreatureEventAI_Summon_Map m_CreatureEventAI_Summon_Map;
         CreatureEventAI_TextMap    m_CreatureEventAI_TextMap;
 };
+
 #define CreatureEAI_Mgr MaNGOS::Singleton::Instance()
 #endif
diff --git a/src/game/CreatureGroups.cpp b/src/game/CreatureGroups.cpp
index c0816f36804..97610754e69 100644
--- a/src/game/CreatureGroups.cpp
+++ b/src/game/CreatureGroups.cpp
@@ -17,21 +17,28 @@
  * 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 "CreatureGroups.h"
 #include "ObjectMgr.h"
 #include "ProgressBar.h"
 #include "Policies/SingletonImp.h"
 #include "CreatureAI.h"
+
 #define MAX_DESYNC 5.0f
+
 INSTANTIATE_SINGLETON_1(CreatureGroupManager);
+
 CreatureGroupInfoType   CreatureGroupMap;
+
 void CreatureGroupManager::AddCreatureToGroup(uint32 groupId, Creature *member)
 {
     Map *map = member->FindMap();
     if(!map)
         return;
+
     CreatureGroupHolderType::iterator itr = map->CreatureGroupHolder.find(groupId);
+
     //Add member to an existing group
     if(itr != map->CreatureGroupHolder.end())
     {
@@ -47,47 +54,58 @@ void CreatureGroupManager::AddCreatureToGroup(uint32 groupId, Creature *member)
         group->AddMember(member);
     }
 }
+
 void CreatureGroupManager::RemoveCreatureFromGroup(CreatureGroup *group, Creature *member)
 {
     sLog.outDebug("Deleting member pointer to GUID: %u from group %u", group->GetId(), member->GetDBTableGUIDLow());
     group->RemoveMember(member);
+
     if(group->isEmpty())
     {
         Map *map = member->FindMap();
         if(!map)
             return;
+
         sLog.outDebug("Deleting group with InstanceID %u", member->GetInstanceId());
         map->CreatureGroupHolder.erase(group->GetId());
         delete group;
     }
 }
+
 void CreatureGroupManager::LoadCreatureFormations()
 {
     //Clear existing map
     CreatureGroupMap.clear();
+
     //Check Integrity of the table
     QueryResult *result = WorldDatabase.PQuery("SELECT MAX(leaderGUID) FROM creature_formations");
+
     if(!result)
     {
         sLog.outErrorDb(" ...an error occured while loading the table creature_formations ( maybe it doesn't exist ?)\n");
         return;
     }
     delete result;
+
     //Get group data
     result = WorldDatabase.PQuery("SELECT leaderGUID, memberGUID, dist, angle, groupAI FROM creature_formations ORDER BY leaderGUID");
+
     if(!result)
     {
         sLog.outErrorDb("The table creature_formations is empty or corrupted");
         return;
     }
+
     uint32 total_records = result->GetRowCount();
     barGoLink bar( total_records);
     Field *fields;
+
     FormationInfo *group_member;
     //Loading data...
     do
     {
         fields = result->Fetch();
+
         bar.step();
         //Load group member data
         group_member                        = new FormationInfo;
@@ -105,6 +123,7 @@ void CreatureGroupManager::LoadCreatureFormations()
             group_member->follow_dist       = 0;
             group_member->follow_angle      = 0;
         }
+
         // check data correctness
         {
             QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE guid = %u", group_member->leaderGUID);
@@ -113,6 +132,7 @@ void CreatureGroupManager::LoadCreatureFormations()
                 sLog.outErrorDb("creature_formations table leader guid %u incorrect (not exist)", group_member->leaderGUID);
                 continue;
             }
+
             result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE guid = %u", memberGUID);
             if(!result)
             {
@@ -120,56 +140,71 @@ void CreatureGroupManager::LoadCreatureFormations()
                 continue;
             }
         }
+
         CreatureGroupMap[memberGUID] = group_member;
-    }
+    } 
     while(result->NextRow()) ;
+
     sLog.outString();
     sLog.outString( ">> Loaded %u creatures in formations", total_records );
     sLog.outString();
     //Free some heap
     delete result;
 }
+
 void CreatureGroup::AddMember(Creature *member)
 {
     sLog.outDebug("CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUIDLow());
+
     //Check if it is a leader
     if(member->GetDBTableGUIDLow() == m_groupID)
     {
         sLog.outDebug("Unit GUID: %u is formation leader. Adding group.", member->GetGUIDLow());
         m_leader = member;
     }
+
     m_members[member] = CreatureGroupMap.find(member->GetDBTableGUIDLow())->second;
     member->SetFormation(this);
 }
+
 void CreatureGroup::RemoveMember(Creature *member)
 {
     if(m_leader == member)
         m_leader = NULL;
+
     m_members.erase(member);
     member->SetFormation(NULL);
 }
+
 void CreatureGroup::MemberAttackStart(Creature *member, Unit *target)
 {
     uint8 groupAI = CreatureGroupMap[member->GetDBTableGUIDLow()]->groupAI;
     if(!groupAI)
         return;
+
     if(groupAI == 1 && member != m_leader)
         return;
+
     for(CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
     {
         sLog.outDebug("GROUP ATTACK: group instance id %u calls member instid %u", m_leader->GetInstanceId(), member->GetInstanceId());
         //sLog.outDebug("AI:%u:Group member found: %u, attacked by %s.", groupAI, itr->second->GetGUIDLow(), member->getVictim()->GetName());
+
         //Skip one check
         if(itr->first == member)
             continue;
+
         if(!itr->first->isAlive())
             continue;
+
         if(itr->first->getVictim())
             continue;
+
         if(itr->first->canAttack(target))
             itr->first->AI()->AttackStart(target);
     }
 }
+
 void CreatureGroup::FormationReset(bool dismiss)
 {
     for(CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
@@ -185,28 +220,37 @@ void CreatureGroup::FormationReset(bool dismiss)
     }
     m_Formed = !dismiss;
 }
+
 void CreatureGroup::LeaderMoveTo(float x, float y, float z)
 {
     if(!m_leader)
         return;
+
     float pathangle    = atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x);
+
     for(CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
     {
         Creature *member = itr->first;
         if(member == m_leader || !member->isAlive() || member->getVictim())
             continue;
+
         float angle = itr->second->follow_angle;
-        float dist = itr->second->follow_dist;
+        float dist = itr->second->follow_dist;    
+
         float dx = x + cos(angle + pathangle) * dist;
         float dy = y + sin(angle + pathangle) * dist;
         float dz = z;
+
         Trinity::NormalizeMapCoord(dx);
         Trinity::NormalizeMapCoord(dy);
+
         member->UpdateGroundPositionZ(dx, dy, dz);
+
         if(member->IsWithinDist(m_leader, dist + MAX_DESYNC))
             member->SetUnitMovementFlags(m_leader->GetUnitMovementFlags());
         else
             member->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+
         member->GetMotionMaster()->MovePoint(0, dx, dy, dz);
         member->SetHomePosition(dx, dy, dz, pathangle);
     }
diff --git a/src/game/CreatureGroups.h b/src/game/CreatureGroups.h
index 1cdbc5c3695..cc3eacfe185 100644
--- a/src/game/CreatureGroups.h
+++ b/src/game/CreatureGroups.h
@@ -1,4 +1,4 @@
-/*
+/* 
  * Copyright (C) 2005-2009 MaNGOS 
  *
  * Copyright (C) 2008-2009 Trinity 
@@ -17,17 +17,22 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #ifndef _FORMATIONS_H
 #define _FORMATIONS_H
+
 #include "Common.h"
+
 class CreatureGroup;
+
 struct FormationInfo
 {
     uint32 leaderGUID;
-    float follow_dist;
-    float follow_angle;
+    float follow_dist; 
+    float follow_angle; 
     uint8 groupAI;
 };
+
 class CreatureGroupManager
 {
     public:
@@ -35,29 +40,39 @@ class CreatureGroupManager
         void RemoveCreatureFromGroup(CreatureGroup *group, Creature *creature);
         void LoadCreatureFormations();
 };
+
 typedef UNORDERED_MAP   CreatureGroupInfoType;
+
 extern CreatureGroupInfoType    CreatureGroupMap;
+
 class CreatureGroup
 {
     private:
         Creature *m_leader; //Important do not forget sometimes to work with pointers instead synonims :D:D
         typedef std::map  CreatureGroupMemberType;
         CreatureGroupMemberType m_members;
+
         uint32 m_groupID;
         bool m_Formed;
+
     public:
         //Group cannot be created empty
         explicit CreatureGroup(uint32 id) : m_groupID(id), m_leader(NULL), m_Formed(false) {}
         ~CreatureGroup() { sLog.outDebug("Destroying group"); }
+        
         Creature* getLeader() const { return m_leader; }
         uint32 GetId() const { return m_groupID; }
         bool isEmpty() const { return m_members.empty(); }
         bool isFormed() const { return m_Formed; }
+
         void AddMember(Creature *member);
         void RemoveMember(Creature *member);
         void FormationReset(bool dismiss);
+
         void LeaderMoveTo(float x, float y, float z);
         void MemberAttackStart(Creature* member, Unit *target);
 };
+
 #define formation_mgr Trinity::Singleton::Instance()
+
 #endif
diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h
index 21d23dca840..a0e030bf7cb 100644
--- a/src/game/DBCEnums.h
+++ b/src/game/DBCEnums.h
@@ -15,29 +15,36 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
 #ifndef DBCENUMS_H
 #define DBCENUMS_H
+
 // Client expected level limitation, like as used in DBC item max levels for "until max player level"
 // use as default max player level, must be fit max level for used client
 // also see MAX_LEVEL and STRONG_MAX_LEVEL define
 #define DEFAULT_MAX_LEVEL 80
+
 // client supported max level for player/pets/etc. Avoid overflow or client stability affected.
 // also see GT_MAX_LEVEL define
 #define MAX_LEVEL    100
+
 // Server side limitation. Base at used code requirements.
 // also see MAX_LEVEL and GT_MAX_LEVEL define
 #define STRONG_MAX_LEVEL 255
+
 enum AreaTeams
 {
     AREATEAM_NONE  = 0,
     AREATEAM_ALLY  = 2,
     AREATEAM_HORDE = 4
 };
+
 enum AchievementFactionFlags
 {
     ACHIEVEMENT_FACTION_FLAG_HORDE    = 0x00000000,
     ACHIEVEMENT_FACTION_FLAG_ALLIANCE = 0x00000001,
 };
+
 enum AchievementFlags
 {
     ACHIEVEMENT_FLAG_COUNTER           = 0x00000001,        // Just count statistic (never stop and complete)
@@ -51,6 +58,7 @@ enum AchievementFlags
     ACHIEVEMENT_FLAG_REALM_FIRST_REACH = 0x00000100,        //
     ACHIEVEMENT_FLAG_REALM_FIRST_KILL  = 0x00000200,        //
 };
+
 enum AchievementCriteriaCondition
 {
     ACHIEVEMENT_CRITERIA_CONDITION_NONE      = 0,
@@ -61,6 +69,7 @@ enum AchievementCriteriaCondition
     ACHIEVEMENT_CRITERIA_CONDITION_UNK2      = 9,           // unk
     ACHIEVEMENT_CRITERIA_CONDITION_UNK3      = 13,          // unk
 };
+
 enum AchievementCriteriaCompletionFlags
 {
     ACHIEVEMENT_CRITERIA_FLAG_SHOW_PROGRESS_BAR = 0x00000001,         // Show progress as bar
@@ -70,11 +79,13 @@ enum AchievementCriteriaCompletionFlags
     ACHIEVEMENT_CRITERIA_FLAG_UNK5              = 0x00000010,         // not used
     ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER     = 0x00000020,         // Displays counter as money
 };
+
 enum AchievementCriteriaGroupFlags
 {
     // you mustn't be in a group while fulfilling this achievement
     ACHIEVEMENT_CRITERIA_GROUP_NOT_IN_GROUP = 2,
 };
+
 enum AchievementCriteriaTypes
 {
     ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE = 0,
@@ -188,6 +199,7 @@ enum AchievementCriteriaTypes
     // 0..114 => 115 criteria types total
     ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 115,
 };
+
 enum AreaFlags
 {
     AREA_FLAG_SNOW             = 0x00000001,                // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring)
@@ -219,10 +231,12 @@ enum AreaFlags
     AREA_FLAG_UNK10            = 0x04000000,                // unknown
     AREA_FLAG_OUTDOOR_PVP2     = 0x08000000                 // Wintergrasp and it's subzones
 };
+
 enum FactionTemplateFlags
 {
     FACTION_TEMPLATE_FLAG_CONTESTED_GUARD   =   0x00001000, // faction will attack players that were involved in PvP combats
 };
+
 enum FactionMasks
 {
     FACTION_MASK_PLAYER   = 1,                              // any player
@@ -231,6 +245,7 @@ enum FactionMasks
     FACTION_MASK_MONSTER  = 8                               // aggressive creature from monster team
     // if none flags set then non-aggressive creature
 };
+
 enum MapTypes
 {
     MAP_COMMON          = 0,
@@ -239,11 +254,13 @@ enum MapTypes
     MAP_BATTLEGROUND    = 3,
     MAP_ARENA           = 4
 };
+
 enum AbilytyLearnType
 {
     ABILITY_LEARNED_ON_GET_PROFESSION_SKILL     = 1,
     ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL  = 2
 };
+
 enum ItemEnchantmentType
 {
     ITEM_ENCHANTMENT_TYPE_NONE             = 0,
@@ -256,6 +273,7 @@ enum ItemEnchantmentType
     ITEM_ENCHANTMENT_TYPE_USE_SPELL        = 7,
     ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET = 8
 };
+
 enum TotemCategoryType
 {
     TOTEM_CATEGORY_TYPE_KNIFE   = 1,
@@ -266,6 +284,7 @@ enum TotemCategoryType
     TOTEM_CATEGORY_TYPE_HAMMER  = 23,
     TOTEM_CATEGORY_TYPE_SPANNER = 24
 };
+
 // SummonProperties.dbc, col 1
 enum SummonPropGroup
 {
@@ -275,6 +294,7 @@ enum SummonPropGroup
     SUMMON_PROP_GROUP_CONTROLLABLE   = 3,                   // 13 spells in 3.0.3, mostly controllable
     SUMMON_PROP_GROUP_UNKNOWN3       = 4                    // 86 spells in 3.0.3, taxi/mounts
 };
+
 // SummonProperties.dbc, col 3
 enum SummonPropType
 {
@@ -291,6 +311,7 @@ enum SummonPropType
     SUMMON_PROP_TYPE_DRAKE_VEH       = 10,                  // summon drake (vehicle), 3 spells
     SUMMON_PROP_TYPE_LIGHTWELL       = 11                   // summon lightwell, 6 spells in 3.0.3
 };
+
 // SummonProperties.dbc, col 5
 enum SummonPropFlags
 {
@@ -310,5 +331,6 @@ enum SummonPropFlags
     SUMMON_PROP_FLAG_UNK13           = 0x1000,              // 8 spells in 3.0.3, siege vehicle
     SUMMON_PROP_FLAG_UNK14           = 0x2000,              // 2 spells in 3.0.3, escort?
 };
+
 #endif
 
diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp
index fa117a169c0..5dae4cb6e17 100644
--- a/src/game/DBCStores.cpp
+++ b/src/game/DBCStores.cpp
@@ -17,21 +17,27 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include "DBCStores.h"
 #include "Policies/SingletonImp.h"
 #include "Log.h"
 #include "ProgressBar.h"
 #include "SharedDefines.h"
 #include "SpellMgr.h"
+
 #include "DBCfmt.h"
+
 #include 
+
 typedef std::map AreaFlagByAreaID;
 typedef std::map AreaFlagByMapID;
+
 DBCStorage  sAreaStore(AreaTableEntryfmt);
 DBCStorage  sAreaGroupStore(AreaGroupEntryfmt);
 DBCStorage  sAreaPOIStore(AreaPOIEntryfmt);
 static AreaFlagByAreaID sAreaFlagByAreaID;
 static AreaFlagByMapID  sAreaFlagByMapID;                   // for instances without generated *.map files
+
 DBCStorage  sAchievementStore(Achievementfmt);
 DBCStorage  sAchievementCriteriaStore(AchievementCriteriafmt);
 DBCStorage  sAreaTriggerStore(AreaTriggerEntryfmt);
@@ -50,18 +56,23 @@ DBCStorage  sCreatureFamilyStore(CreatureFamilyfmt);
 DBCStorage  sCreatureSpellDataStore(CreatureSpellDatafmt);
 DBCStorage  sCreatureTypeStore(CreatureTypefmt);
 DBCStorage  sCurrencyTypesStore(CurrencyTypesfmt);
+
 DBCStorage  sDurabilityQualityStore(DurabilityQualityfmt);
 DBCStorage  sDurabilityCostsStore(DurabilityCostsfmt);
+
 DBCStorage  sEmotesStore(EmotesEntryfmt);
 DBCStorage  sEmotesTextStore(EmotesTextEntryfmt);
+
 typedef std::map FactionTeamMap;
 static FactionTeamMap sFactionTeamMap;
 DBCStorage  sFactionStore(FactionEntryfmt);
 DBCStorage  sFactionTemplateStore(FactionTemplateEntryfmt);
+
 DBCStorage  sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt);
 DBCStorage  sGemPropertiesStore(GemPropertiesEntryfmt);
 DBCStorage  sGlyphPropertiesStore(GlyphPropertiesfmt);
 DBCStorage  sGlyphSlotStore(GlyphSlotfmt);
+
 DBCStorage     sGtBarberShopCostBaseStore(GtBarberShopCostBasefmt);
 DBCStorage          sGtCombatRatingsStore(GtCombatRatingsfmt);
 DBCStorage  sGtChanceToMeleeCritBaseStore(GtChanceToMeleeCritBasefmt);
@@ -72,7 +83,9 @@ DBCStorage             sGtOCTRegenHPStore(GtOCTRegenHPfmt);
 //DBCStorage             sGtOCTRegenMPStore(GtOCTRegenMPfmt);  -- not used currently
 DBCStorage          sGtRegenHPPerSptStore(GtRegenHPPerSptfmt);
 DBCStorage          sGtRegenMPPerSptStore(GtRegenMPPerSptfmt);
+
 DBCStorage                 sHolidaysStore(Holidaysfmt);
+
 DBCStorage                     sItemStore(Itemfmt);
 DBCStorage            sItemBagFamilyStore(ItemBagFamilyfmt);
 //DBCStorage  sItemCondExtCostsStore(ItemCondExtCostsEntryfmt);
@@ -82,22 +95,30 @@ DBCStorage  sItemLimitCategoryStore(ItemLimitCategoryEnt
 DBCStorage  sItemRandomPropertiesStore(ItemRandomPropertiesfmt);
 DBCStorage  sItemRandomSuffixStore(ItemRandomSuffixfmt);
 DBCStorage  sItemSetStore(ItemSetEntryfmt);
+
 DBCStorage  sLockStore(LockEntryfmt);
+
 DBCStorage  sMailTemplateStore(MailTemplateEntryfmt);
 DBCStorage  sMapStore(MapEntryfmt);
 DBCStorage  sMovieStore(MovieEntryfmt);
+
 DBCStorage  sQuestSortStore(QuestSortEntryfmt);
+
 DBCStorage  sRandomPropertiesPointsStore(RandomPropertiesPointsfmt);
 DBCStorage  sScalingStatDistributionStore(ScalingStatDistributionfmt);
 DBCStorage  sScalingStatValuesStore(ScalingStatValuesfmt);
+
 DBCStorage  sSkillLineStore(SkillLinefmt);
 DBCStorage  sSkillLineAbilityStore(SkillLineAbilityfmt);
+
 DBCStorage  sSoundEntriesStore(SoundEntriesfmt);
+
 DBCStorage  sSpellItemEnchantmentStore(SpellItemEnchantmentfmt);
 DBCStorage  sSpellItemEnchantmentConditionStore(SpellItemEnchantmentConditionfmt);
 DBCStorage  sSpellStore(SpellEntryfmt);
 SpellCategoryStore sSpellCategoryStore;
 PetFamilySpellsStore sPetFamilySpellsStore;
+
 DBCStorage  sSpellCastTimesStore(SpellCastTimefmt);
 DBCStorage  sSpellDurationStore(SpellDurationfmt);
 DBCStorage  sSpellFocusObjectStore(SpellFocusObjectfmt);
@@ -110,16 +131,21 @@ DBCStorage  sSummonPropertiesStore(SummonPropertiesfmt);
 DBCStorage  sTalentStore(TalentEntryfmt);
 TalentSpellPosMap sTalentSpellPosMap;
 DBCStorage  sTalentTabStore(TalentTabEntryfmt);
+
 // store absolute bit position for first rank for talent inspect
 static uint32 sTalentTabPages[12/*MAX_CLASSES*/][3];
+
 DBCStorage  sTaxiNodesStore(TaxiNodesEntryfmt);
 TaxiMask sTaxiNodesMask;
 TaxiMask sOldContinentsNodesMask;
+
 // DBC used only for initialization sTaxiPathSetBySource at startup.
 TaxiPathSetBySource sTaxiPathSetBySource;
 DBCStorage  sTaxiPathStore(TaxiPathEntryfmt);
+
 // DBC used only for initialization sTaxiPathSetBySource at startup.
 TaxiPathNodesByPath sTaxiPathNodesByPath;
+
 static DBCStorage  sTaxiPathNodeStore(TaxiPathNodeEntryfmt);
 DBCStorage  sTotemCategoryStore(TotemCategoryEntryfmt);
 DBCStorage  sVehicleStore(VehicleEntryfmt);
@@ -127,22 +153,28 @@ DBCStorage  sVehicleSeatStore(VehicleSeatEntryfmt);
 DBCStorage   sWorldMapAreaStore(WorldMapAreaEntryfmt);
 DBCStorage  sWorldMapOverlayStore(WorldMapOverlayEntryfmt);
 DBCStorage  sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
+
 typedef std::list StoreProblemList;
+
 static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& filename)
 {
     sLog.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename.c_str(),fsize,rsize);
+
     // assert must fail after function call
     return false;
 }
+
 template
 inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage& storage, const std::string& dbc_path, const std::string& filename, const std::string * custom_entries = NULL, const std::string * idname = NULL)
 {
     // compatibility format and C++ structure sizes
     assert(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename));
+
     std::string dbc_filename = dbc_path + filename;
     SqlDbc * sql = NULL;
     if (custom_entries)
         sql = new SqlDbc(&filename,custom_entries, idname,storage.GetFormat());
+
     if(storage.Load(dbc_filename.c_str(), sql))
     {
         bar.step();
@@ -150,6 +182,7 @@ inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList
         {
             if(!(availableDbcLocales & (1 << i)))
                 continue;
+
             std::string dbc_filename_loc = dbc_path + localeNames[i] + "/" + filename;
             if(!storage.LoadStringsFrom(dbc_filename_loc.c_str()))
                 availableDbcLocales &= ~(1<DBC records
             sAreaFlagByAreaID.insert(AreaFlagByAreaID::value_type(uint16(area->ID),area->exploreFlag));
+
             // fill MapId->DBC records ( skip sub zones and continents )
             if(area->zone==0 && area->mapid != 0 && area->mapid != 1 && area->mapid != 530 && area->mapid != 571 )
                 sAreaFlagByMapID.insert(AreaFlagByMapID::value_type(area->mapid,area->exploreFlag));
         }
     }
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementStore,         dbcPath,"Achievement.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementCriteriaStore, dbcPath,"Achievement_Criteria.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaTriggerStore,         dbcPath,"AreaTrigger.dbc");
@@ -202,6 +243,7 @@ void LoadDBCStores(const std::string& dataPath)
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBattlemasterListStore,    dbcPath,"BattlemasterList.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBarberShopStyleStore,     dbcPath,"BarberShopStyle.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharStartOutfitStore,     dbcPath,"CharStartOutfit.dbc");
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharTitlesStore,          dbcPath,"CharTitles.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChatChannelsStore,        dbcPath,"ChatChannels.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrClassesStore,          dbcPath,"ChrClasses.dbc");
@@ -226,6 +268,7 @@ void LoadDBCStores(const std::string& dataPath)
             flist.push_back(i);
         }
     }
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionTemplateStore,     dbcPath,"FactionTemplate.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGameObjectDisplayInfoStore, dbcPath,"GameObjectDisplayInfo.dbc");
     for(uint32 i = 0; i < sGameObjectDisplayInfoStore.GetNumRows(); ++i)
@@ -240,15 +283,20 @@ void LoadDBCStores(const std::string& dataPath)
                 std::swap(*(float*)(&info->maxZ), *(float*)(&info->minZ));
         }
     }
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGemPropertiesStore,       dbcPath,"GemProperties.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGlyphPropertiesStore,     dbcPath,"GlyphProperties.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGlyphSlotStore,           dbcPath,"GlyphSlot.dbc");
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtBarberShopCostBaseStore,dbcPath,"gtBarberShopCostBase.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtCombatRatingsStore,     dbcPath,"gtCombatRatings.dbc");
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToMeleeCritBaseStore, dbcPath,"gtChanceToMeleeCritBase.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToMeleeCritStore, dbcPath,"gtChanceToMeleeCrit.dbc");
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritBaseStore, dbcPath,"gtChanceToSpellCritBase.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritStore, dbcPath,"gtChanceToSpellCrit.dbc");
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenHPStore,        dbcPath,"gtOCTRegenHP.dbc");
     //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore,        dbcPath,"gtOCTRegenMP.dbc");       -- not used currently
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenHPPerSptStore,     dbcPath,"gtRegenHPPerSpt.dbc");
@@ -281,12 +329,16 @@ void LoadDBCStores(const std::string& dataPath)
         if(spell && spell->Category)
             sSpellCategoryStore[spell->Category].insert(i);
     }
+
     for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
     {
         SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
+
         if(!skillLine)
             continue;
+
         SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId);
+
         if(spellInfo && IsPassiveSpell(spellInfo->Id))
         {
             for (uint32 i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i)
@@ -294,16 +346,20 @@ void LoadDBCStores(const std::string& dataPath)
                 CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i);
                 if(!cFamily)
                     continue;
+
                 if(skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
                     continue;
                 if(spellInfo->spellLevel)
                     continue;
+
                 if(skillLine->learnOnGetSkill != ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL)
                     continue;
+
                 sPetFamilySpellsStore[i].insert(spellInfo->Id);
             }
         }
     }
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellCastTimesStore,      dbcPath,"SpellCastTimes.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDurationStore,       dbcPath,"SpellDuration.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore,    dbcPath,"SpellFocusObject.dbc");
@@ -316,6 +372,7 @@ void LoadDBCStores(const std::string& dataPath)
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sStableSlotPricesStore,    dbcPath,"StableSlotPrices.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSummonPropertiesStore,    dbcPath,"SummonProperties.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentStore,              dbcPath,"Talent.dbc");
+
     // create talent spells set
     for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i)
     {
@@ -325,7 +382,9 @@ void LoadDBCStores(const std::string& dataPath)
             if(talentInfo->RankID[j])
                 sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i,j);
     }
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentTabStore,           dbcPath,"TalentTab.dbc");
+
     // prepare fast data access to bit pos of talent ranks for use at inspecting
     {
         // now have all max ranks (and then bit amount used for store talent ranks in inspect)
@@ -334,21 +393,27 @@ void LoadDBCStores(const std::string& dataPath)
             TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentTabId );
             if(!talentTabInfo)
                 continue;
+
             // prevent memory corruption; otherwise cls will become 12 below
             if ((talentTabInfo->ClassMask & CLASSMASK_ALL_PLAYABLE)==0)
                 continue;
+
             // store class talent tab pages
             uint32 cls = 1;
             for(uint32 m=1;!(m & talentTabInfo->ClassMask) && cls < MAX_CLASSES;m <<=1, ++cls) {}
+
             sTalentTabPages[cls][talentTabInfo->tabpage]=talentTabId;
         }
     }
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiNodesStore,           dbcPath,"TaxiNodes.dbc");
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathStore,            dbcPath,"TaxiPath.dbc");
     for(uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i)
         if(TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i))
             sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID,entry->price);
     uint32 pathCount = sTaxiPathStore.GetNumRows();
+
     //## TaxiPathNode.dbc ## Loaded only for initialization different structures
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathNodeStore,        dbcPath,"TaxiPathNode.dbc");
     // Calculate path nodes count
@@ -369,6 +434,7 @@ void LoadDBCStores(const std::string& dataPath)
         if(TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
             sTaxiPathNodesByPath[entry->path][entry->index] = TaxiPathNode(entry->mapid,entry->x,entry->y,entry->z,entry->actionFlag,entry->delay);
     sTaxiPathNodeStore.Clear();
+
     // Initialize global taxinodes mask
     // include existed nodes that have at least single not spell base (scripted) path
     {
@@ -378,6 +444,7 @@ void LoadDBCStores(const std::string& dataPath)
                 for(int j=0; j < 3; ++j)
                     if(sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/)
                         spellPaths.insert(sInfo->EffectMiscValue[j]);
+
         memset(sTaxiNodesMask,0,sizeof(sTaxiNodesMask));
         memset(sOldContinentsNodesMask,0,sizeof(sTaxiNodesMask));
         for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
@@ -385,6 +452,7 @@ void LoadDBCStores(const std::string& dataPath)
             TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
             if(!node)
                 continue;
+
             TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(i);
             if(src_i!=sTaxiPathSetBySource.end() && !src_i->second.empty())
             {
@@ -398,24 +466,29 @@ void LoadDBCStores(const std::string& dataPath)
                         break;
                     }
                 }
+
                 if(!ok)
                     continue;
             }
+
             // valid taxi network node
             uint8  field   = (uint8)((i - 1) / 32);
             uint32 submask = 1<<((i-1)%32);
             sTaxiNodesMask[field] |= submask;
+
             // old continent node (+ nodes virtually at old continents, check explicitly to avoid loading map files for zone info)
             if (node->map_id < 2 || i == 82 || i == 83 || i == 93 || i == 94)
                 sOldContinentsNodesMask[field] |= submask;
         }
     }
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTotemCategoryStore,       dbcPath,"TotemCategory.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleStore,             dbcPath,"Vehicle.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore,         dbcPath,"VehicleSeat.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore,        dbcPath,"WorldMapArea.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapOverlayStore,     dbcPath,"WorldMapOverlay.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore,       dbcPath,"WorldSafeLocs.dbc");
+
     // error checks
     if(bad_dbc_files.size() >= DBCFilesCount )
     {
@@ -427,9 +500,11 @@ void LoadDBCStores(const std::string& dataPath)
         std::string str;
         for(std::list::iterator i = bad_dbc_files.begin(); i != bad_dbc_files.end(); ++i)
             str += *i + "\n";
+
         sLog.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s",(uint32)bad_dbc_files.size(),DBCFilesCount,str.c_str());
         exit(1);
     }
+
     // Check loaded DBC files proper version
     if( !sSpellStore.LookupEntry(66530)            ||       // last added spell in 3.1.3
         !sMapStore.LookupEntry(624)                ||       // last map added in 3.1.3
@@ -442,9 +517,11 @@ void LoadDBCStores(const std::string& dataPath)
         sLog.outError("\nYou have _outdated_ DBC files. Please extract correct versions from current using client.");
         exit(1);
     }
+
     sLog.outString();
     sLog.outString( ">> Initialized %d data stores", DBCFilesCount );
 }
+
 SimpleFactionsList const* GetFactionTeamList(uint32 faction, bool &isTeamMember)
 {
     for(FactionTeamMap::const_iterator itr = sFactionTeamMap.begin(); itr != sFactionTeamMap.end(); ++itr)
@@ -465,6 +542,7 @@ SimpleFactionsList const* GetFactionTeamList(uint32 faction, bool &isTeamMember)
     }
     return NULL;
 }
+
 char* GetPetName(uint32 petfamily, uint32 dbclang)
 {
     if(!petfamily)
@@ -474,41 +552,53 @@ char* GetPetName(uint32 petfamily, uint32 dbclang)
         return NULL;
     return pet_family->Name[dbclang]?pet_family->Name[dbclang]:NULL;
 }
+
 TalentSpellPos const* GetTalentSpellPos(uint32 spellId)
 {
     TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId);
     if(itr==sTalentSpellPosMap.end())
         return NULL;
+
     return &itr->second;
 }
+
 uint32 GetTalentSpellCost(uint32 spellId)
 {
     if(TalentSpellPos const* pos = GetTalentSpellPos(spellId))
         return pos->rank+1;
+
     return 0;
 }
+
 int32 GetAreaFlagByAreaID(uint32 area_id)
 {
     AreaFlagByAreaID::iterator i = sAreaFlagByAreaID.find(area_id);
     if(i == sAreaFlagByAreaID.end())
         return -1;
+
     return i->second;
 }
+
 AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id)
 {
     int32 areaflag = GetAreaFlagByAreaID(area_id);
     if(areaflag < 0)
         return NULL;
+
     return sAreaStore.LookupEntry(areaflag );
 }
+
 AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id)
 {
     if(area_flag)
         return sAreaStore.LookupEntry(area_flag);
+
     if(MapEntry const* mapEntry = sMapStore.LookupEntry(map_id))
         return GetAreaEntryByAreaID(mapEntry->linked_zone);
+
     return NULL;
 }
+
 uint32 GetAreaFlagByMapId(uint32 mapid)
 {
     AreaFlagByMapID::iterator i = sAreaFlagByMapID.find(mapid);
@@ -517,22 +607,28 @@ uint32 GetAreaFlagByMapId(uint32 mapid)
     else
         return i->second;
 }
+
 uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId)
 {
     if(mapid != 530 && mapid != 571)                        // speed for most cases
         return mapid;
+
     if(WorldMapAreaEntry const* wma = sWorldMapAreaStore.LookupEntry(zoneId))
         return wma->virtual_map_id >= 0 ? wma->virtual_map_id : wma->map_id;
+
     return mapid;
 }
+
 ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId)
 {
     mapid = GetVirtualMapForMapAndZone(mapid,zoneId);
     if(mapid < 2)
         return CONTENT_1_60;
+
     MapEntry const* mapEntry = sMapStore.LookupEntry(mapid);
     if(!mapEntry)
         return CONTENT_1_60;
+
     switch(mapEntry->Expansion())
     {
         default: return CONTENT_1_60;
@@ -540,6 +636,7 @@ ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId)
         case 2:  return CONTENT_71_80;
     }
 }
+
 ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
 {
     // not sorted, numbering index from 0
@@ -551,46 +648,58 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
     }
     return NULL;
 }
+
 bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
 {
     if(requiredTotemCategoryId==0)
         return true;
     if(itemTotemCategoryId==0)
         return false;
+
     TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId);
     if(!itemEntry)
         return false;
     TotemCategoryEntry const* reqEntry = sTotemCategoryStore.LookupEntry(requiredTotemCategoryId);
     if(!reqEntry)
         return false;
+
     if(itemEntry->categoryType!=reqEntry->categoryType)
         return false;
+
     return (itemEntry->categoryMask & reqEntry->categoryMask)==reqEntry->categoryMask;
 }
+
 void Zone2MapCoordinates(float& x,float& y,uint32 zone)
 {
     WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone);
+
     // if not listed then map coordinates (instance)
     if(!maEntry)
         return;
+
     std::swap(x,y);                                         // at client map coords swapped
     x = x*((maEntry->x2-maEntry->x1)/100)+maEntry->x1;
     y = y*((maEntry->y2-maEntry->y1)/100)+maEntry->y1;      // client y coord from top to down
 }
+
 void Map2ZoneCoordinates(float& x,float& y,uint32 zone)
 {
     WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone);
+
     // if not listed then map coordinates (instance)
     if(!maEntry)
         return;
+
     x = (x-maEntry->x1)/((maEntry->x2-maEntry->x1)/100);
     y = (y-maEntry->y1)/((maEntry->y2-maEntry->y1)/100);    // client y coord from top to down
     std::swap(x,y);                                         // client have map coords swapped
 }
+
 uint32 const* GetTalentTabPages(uint32 cls)
 {
     return sTalentTabPages[cls];
 }
+
 // script support functions
 TRINITY_DLL_SPEC DBCStorage   const* GetSoundEntriesStore()   { return &sSoundEntriesStore;   }
 TRINITY_DLL_SPEC DBCStorage          const* GetSpellStore()          { return &sSpellStore;          }
diff --git a/src/game/DBCStores.h b/src/game/DBCStores.h
index 90ac6dd97c8..4fd5b6bcb59 100644
--- a/src/game/DBCStores.h
+++ b/src/game/DBCStores.h
@@ -15,22 +15,30 @@
  * 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_DBCSTORES_H
 #define MANGOS_DBCSTORES_H
+
 #include "Common.h"
 #include "Database/DBCStore.h"
 #include "DBCStructure.h"
+
 #include 
+
 typedef std::list SimpleFactionsList;
+
 SimpleFactionsList const* GetFactionTeamList(uint32 faction, bool &isTeamMember);
 char* GetPetName(uint32 petfamily, uint32 dbclang);
 uint32 GetTalentSpellCost(uint32 spellId);
 TalentSpellPos const* GetTalentSpellPos(uint32 spellId);
+
 int32 GetAreaFlagByAreaID(uint32 area_id);                  // -1 if not found
 AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id);
 AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id);
 uint32 GetAreaFlagByMapId(uint32 mapid);
+
 uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId);
+
 enum ContentLevels
 {
     CONTENT_1_60 = 0,
@@ -38,11 +46,16 @@ enum ContentLevels
     CONTENT_71_80
 };
 ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId);
+
 ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id);
+
 bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId);
+
 void Zone2MapCoordinates(float& x,float& y,uint32 zone);
 void Map2ZoneCoordinates(float& x,float& y,uint32 zone);
+
 uint32 const* /*[3]*/ GetTalentTabPages(uint32 cls);
+
 extern DBCStorage              sAchievementStore;
 extern DBCStorage      sAchievementCriteriaStore;
 extern DBCStorage                sAreaStore;// recommend access using functions
@@ -74,6 +87,7 @@ extern DBCStorage    sGameObjectDisplayInfoStore;
 extern DBCStorage            sGemPropertiesStore;
 extern DBCStorage          sGlyphPropertiesStore;
 extern DBCStorage                sGlyphSlotStore;
+
 extern DBCStorage     sGtBarberShopCostBaseStore;
 extern DBCStorage          sGtCombatRatingsStore;
 extern DBCStorage  sGtChanceToMeleeCritBaseStore;
@@ -132,7 +146,9 @@ extern DBCStorage              sVehicleSeatStore;
 //extern DBCStorage            sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates
 extern DBCStorage          sWorldMapOverlayStore;
 extern DBCStorage            sWorldSafeLocsStore;
+
 void LoadDBCStores(const std::string& dataPath);
+
 // script support functions
 TRINITY_DLL_SPEC DBCStorage           const* GetSoundEntriesStore();
 TRINITY_DLL_SPEC DBCStorage                  const* GetSpellStore();
diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h
index 98f4dfd3744..7e459c61e8b 100644
--- a/src/game/DBCStructure.h
+++ b/src/game/DBCStructure.h
@@ -17,21 +17,27 @@
  * 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_DBCSTRUCTURE_H
 #define MANGOS_DBCSTRUCTURE_H
+
 #include "DBCEnums.h"
 #include "Platform/Define.h"
 #include "Util.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
+
 struct AchievementEntry
 {
     uint32    ID;                                           // 0
@@ -52,6 +58,7 @@ struct AchievementEntry
     uint32 count;                                           // 60 - need this count of completed criterias (own or referenced achievement criterias)
     uint32 refAchievement;                                  // 61 - referenced achievement (counting of all completed criterias)
 };
+
 struct AchievementCategoryEntry
 {
     uint32    ID;                                           // 0
@@ -60,6 +67,7 @@ struct AchievementCategoryEntry
     //uint32 name_flags;                                    // 18
     //uint32    sortOrder;                                  // 19
 };
+
 struct AchievementCriteriaEntry
 {
     uint32  ID;                                             // 0
@@ -74,6 +82,7 @@ struct AchievementCriteriaEntry
             uint32  creatureID;                             // 3
             uint32  creatureCount;                          // 4
         } kill_creature;
+
         // ACHIEVEMENT_CRITERIA_TYPE_WIN_BG                 = 1
         struct
         {
@@ -84,89 +93,105 @@ struct AchievementCriteriaEntry
             uint32  additionalRequirement2_type;            // 7 additional requirement 2 type
             uint32  additionalRequirement2_value;           // 8 additional requirement 1 value
         } win_bg;
+
         // ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL            = 5
         struct
         {
             uint32  unused;                                 // 3
             uint32  level;                                  // 4
         } reach_level;
+
         // ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL      = 7
         struct
         {
             uint32  skillID;                                // 3
             uint32  skillLevel;                             // 4
         } reach_skill_level;
+
         // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT   = 8
         struct
         {
             uint32  linkedAchievement;                      // 3
         } complete_achievement;
+
         // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT   = 9
         struct
         {
             uint32  unused;                                 // 3
             uint32  totalQuestCount;                        // 4
         } complete_quest_count;
+
         // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY = 10
         struct
         {
             uint32  unused;                                 // 3
             uint32  numberOfDays;                           // 4
         } complete_daily_quest_daily;
+
         // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE = 11
         struct
         {
             uint32  zoneID;                                 // 3
             uint32  questCount;                             // 4
         } complete_quests_in_zone;
+
         // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST   = 14
         struct
         {
             uint32  unused;                                 // 3
             uint32  questCount;                             // 4
         } complete_daily_quest;
+
         // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND  = 15
         struct
         {
             uint32  mapID;                                  // 3
         } complete_battleground;
+
         // ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP           = 16
         struct
         {
             uint32  mapID;                                  // 3
         } death_at_map;
+
         // ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON       = 18
         struct
         {
             uint32  manLimit;                               // 3
         } death_in_dungeon;
+
         // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID          = 19
         struct
         {
             uint32  groupSize;                              // 3 can be 5, 10 or 25
         } complete_raid;
+
         // ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE     = 20
         struct
         {
             uint32  creatureEntry;                          // 3
         } killed_by_creature;
+
         // ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING     = 24
         struct
         {
             uint32  unused;                                 // 3
             uint32  fallHeight;                             // 4
         } fall_without_dying;
+
         // ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM            = 26
         struct
         {
             uint32 type;                                    // 3, see enum EnviromentalDamage
         } death_from;
+
         // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST         = 27
         struct
         {
             uint32  questID;                                // 3
             uint32  questCount;                             // 4
         } complete_quest;
+
         // ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET        = 28
         // ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2       = 69
         struct
@@ -174,6 +199,7 @@ struct AchievementCriteriaEntry
             uint32  spellID;                                // 3
             uint32  spellCount;                             // 4
         } be_spell_target;
+
         // ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL             = 29
         // ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2            = 110
         struct
@@ -181,33 +207,39 @@ struct AchievementCriteriaEntry
             uint32  spellID;                                // 3
             uint32  castCount;                              // 4
         } cast_spell;
+
         // ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA = 31
         struct
         {
             uint32  areaID;                                 // 3 Reference to AreaTable.dbc
             uint32  killCount;                              // 4
         } honorable_kill_at_area;
+
         // ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA              = 32
         struct
         {
             uint32  mapID;                                  // 3 Reference to Map.dbc
         } win_arena;
+
         // ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA             = 33
         struct
         {
             uint32  mapID;                                  // 3 Reference to Map.dbc
         } play_arena;
+
         // ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL            = 34
         struct
         {
             uint32  spellID;                                // 3 Reference to Map.dbc
         } learn_spell;
+
         // ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM               = 36
         struct
         {
             uint32  itemID;                                 // 3
             uint32  itemCount;                              // 4
         } own_item;
+
         // ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA        = 37
         struct
         {
@@ -215,77 +247,90 @@ struct AchievementCriteriaEntry
             uint32  count;                                  // 4
             uint32  flag;                                   // 5 4=in a row
         } win_rated_arena;
+
         // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING    = 38
         struct
         {
             uint32  teamtype;                               // 3 {2,3,5}
         } highest_team_rating;
+
         // ACHIEVEMENT_CRITERIA_TYPE_REACH_TEAM_RATING      = 39
         struct
         {
             uint32  teamtype;                               // 3 {2,3,5}
             uint32  teamrating;                             // 4
         } reach_team_rating;
+
         // ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL      = 40
         struct
         {
             uint32  skillID;                                // 3
             uint32  skillLevel;                             // 4 apprentice=1, journeyman=2, expert=3, artisan=4, master=5, grand master=6
         } learn_skill_level;
+
         // ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM               = 41
         struct
         {
             uint32  itemID;                                 // 3
             uint32  itemCount;                              // 4
         } use_item;
+
         // ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM              = 42
         struct
         {
             uint32  itemID;                                 // 3
             uint32  itemCount;                              // 4
         } loot_item;
+
         // ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA           = 43
         struct
         {
             // TODO: This rank is _NOT_ the index from AreaTable.dbc
             uint32  areaReference;                          // 3
         } explore_area;
+
         // ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK               = 44
         struct
         {
             // TODO: This rank is _NOT_ the index from CharTitles.dbc
             uint32  rank;                                   // 3
         } own_rank;
+
         // ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT          = 45
         struct
         {
             uint32  unused;                                 // 3
             uint32  numberOfSlots;                          // 4
         } buy_bank_slot;
+
         // ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION        = 46
         struct
         {
             uint32  factionID;                              // 3
             uint32  reputationAmount;                       // 4 Total reputation amount, so 42000 = exalted
         } gain_reputation;
+
         // ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION= 47
         struct
         {
             uint32  unused;                                 // 3
             uint32  numberOfExaltedFactions;                // 4
         } gain_exalted_reputation;
+
         // ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP      = 48
         struct
         {
             uint32 unused;                                  // 3
             uint32 numberOfVisits;                          // 4
         } visit_barber;
+
         // ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM        = 49
         // TODO: where is the required itemlevel stored?
         struct
         {
             uint32  itemSlot;                               // 3
         } equip_epic_item;
+
         // ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT      = 50
         struct
         {
@@ -298,18 +343,21 @@ struct AchievementCriteriaEntry
             uint32  rollValue;                              // 3
             uint32  count;                                  // 4
         } roll_greed_on_loot;
+
         // ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS               = 52
         struct
         {
             uint32  classID;                                // 3
             uint32  count;                                  // 4
         } hk_class;
+
         // ACHIEVEMENT_CRITERIA_TYPE_HK_RACE                = 53
         struct
         {
             uint32  raceID;                                 // 3
             uint32  count;                                  // 4
         } hk_race;
+
         // ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE               = 54
         // TODO: where is the information about the target stored?
         struct
@@ -327,12 +375,14 @@ struct AchievementCriteriaEntry
             uint32  flag;                                   // 5 =3 for battleground healing
             uint32  mapid;                                  // 6
         } healing_done;
+
         // ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM             = 57
         struct
         {
             uint32  itemID;                                 // 3
             uint32  count;                                  // 4
         } equip_item;
+
         // ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD= 62
         struct
         {
@@ -340,18 +390,21 @@ struct AchievementCriteriaEntry
             uint32  goldInCopper;                           // 4
         } quest_reward_money;
 
+
         // ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY             = 67
         struct
         {
             uint32  unused;                                 // 3
             uint32  goldInCopper;                           // 4
         } loot_money;
+
         // ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT         = 68
         struct
         {
             uint32  goEntry;                                // 3
             uint32  useCount;                               // 4
         } use_gameobject;
+
         // ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL       = 70
         // TODO: are those special criteria stored in the dbc or do we have to add another sql table?
         struct
@@ -359,62 +412,73 @@ struct AchievementCriteriaEntry
             uint32  unused;                                 // 3
             uint32  killCount;                              // 4
         } special_pvp_kill;
+
         // ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT     = 72
         struct
         {
             uint32  goEntry;                                // 3
             uint32  lootCount;                              // 4
         } fish_in_gameobject;
+
         // ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS = 75
         struct
         {
             uint32  skillLine;                              // 3
             uint32  spellCount;                             // 4
         } learn_skillline_spell;
+
         // ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL               = 76
         struct
         {
             uint32  unused;                                 // 3
             uint32  duelCount;                              // 4
         } win_duel;
+
         // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER          = 96
         struct
         {
             uint32  powerType;                              // 3 mana=0, 1=rage, 3=energy, 6=runic power
         } highest_power;
+
         // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT           = 97
         struct
         {
             uint32  statType;                               // 3 4=spirit, 3=int, 2=stamina, 1=agi, 0=strength
         } highest_stat;
+
         // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER     = 98
         struct
         {
             uint32  spellSchool;                            // 3
         } highest_spellpower;
+
         // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING         = 100
         struct
         {
             uint32  ratingType;                             // 3
         } highest_rating;
+
         // ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE              = 109
         struct
         {
             uint32  lootType;                               // 3 3=fishing, 2=pickpocket, 4=disentchant
             uint32  lootTypeCount;                          // 4
         } loot_type;
+
         // ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE       = 112
         struct
         {
             uint32  skillLine;                              // 3
             uint32  spellCount;                             // 4
         } learn_skill_line;
+
         // ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL    = 113
         struct
         {
             uint32  unused;                                 // 3
             uint32  killCount;                              // 4
         } honorable_kill;
+
         struct
         {
             uint32  field3;                                 // 3 main requirement
@@ -435,6 +499,7 @@ struct AchievementCriteriaEntry
     uint32  timeLimit;                                      // 29 time limit in seconds
     //uint32 showOrder;                                     // 30 show order
 };
+
 struct AreaTableEntry
 {
     uint32  ID;                                             // 0
@@ -447,6 +512,7 @@ struct AreaTableEntry
     char*   area_name[16];                                  // 11-26
                                                             // 27, string flags, unused
     uint32  team;                                           // 28
+
     // helpers
     bool IsSanctuary() const
     {
@@ -455,12 +521,14 @@ struct AreaTableEntry
         return (flags & AREA_FLAG_SANCTUARY);
     }
 };
+
 struct AreaGroupEntry
 {
     uint32  AreaGroupId;                                    // 0
     uint32  AreaId[6];                                      // 1-6
     uint32  nextGroup;                                      // 7 index of next group
 };
+
 struct AreaPOIEntry
 {
     uint32 id;              //0
@@ -478,6 +546,7 @@ struct AreaPOIEntry
     uint32 worldState;      //52
     //uint32 val2;          //53
 };
+
 struct AreaTriggerEntry
 {
     uint32  id;                                             // 0        m_ID
@@ -491,6 +560,7 @@ struct AreaTriggerEntry
     float   box_z;                                          // 8        m_box_heigh
     float   box_orientation;                                // 9        m_box_yaw
 };
+
 struct AuctionHouseEntry
 {
     uint32    houseId;                                      // 0 index
@@ -500,11 +570,13 @@ struct AuctionHouseEntry
     //char*     name[16];                                   // 4-19
                                                             // 20 string flag, unused
 };
+
 struct BankBagSlotPricesEntry
 {
     uint32  ID;
     uint32  price;
 };
+
 struct BarberShopStyleEntry
 {
     uint32  Id;                                             // 0
@@ -518,6 +590,7 @@ struct BarberShopStyleEntry
     uint32  gender;                                         // 38 0 -> male, 1 -> female
     uint32  hair_id;                                        // 39 real ID to hair/facial hair
 };
+
 struct BattlemasterListEntry
 {
     uint32  id;                                             // 0
@@ -534,7 +607,9 @@ struct BattlemasterListEntry
                                                             // 33 unused
     //uint32 unk;                                           // 34 new 3.1
 };
+
 #define MAX_OUTFIT_ITEMS 24
+
 struct CharStartOutfitEntry
 {
     //uint32 Id;                                            // 0
@@ -546,6 +621,7 @@ struct CharStartOutfitEntry
     //uint32 Unknown2;                                      // 39
     //uint32 Unknown3;                                      // 40
 };
+
 struct CharTitlesEntry
 {
     uint32  ID;                                             // 0, title ids, for example in Quest::GetCharTitleId()
@@ -556,6 +632,7 @@ struct CharTitlesEntry
                                                             // 35 string flag, unused
     uint32  bit_index;                                      // 36 used in PLAYER_CHOSEN_TITLE and 1<