Show
Ignore:
Timestamp:
11/21/08 08:47:55 (17 years ago)
Author:
yumileroy
Message:

*DB script table stucture change. Source Mangos. Also fix some bugs. Hopefully this rev will make program usable again.

Original author: megamage
Date: 2008-11-20 10:43:20-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Level3.cpp

    r235 r260  
    136136    HandleReloadSpellScriptsCommand("a"); 
    137137    SendGlobalSysMessage("DB tables `*_scripts` reloaded."); 
     138    HandleReloadDbScriptStringCommand("a"); 
    138139    return true; 
    139140} 
     
    599600        SendGlobalSysMessage("DB table `spell_scripts` reloaded."); 
    600601 
     602    return true; 
     603} 
     604 
     605bool ChatHandler::HandleReloadDbScriptStringCommand(const char* arg) 
     606{ 
     607    sLog.outString( "Re-Loading Script strings from `db_script_string`..."); 
     608    objmgr.LoadDbScriptStrings(); 
     609    SendGlobalSysMessage("DB table `db_script_string` reloaded."); 
    601610    return true; 
    602611} 
     
    17681777        // search highest talent rank 
    17691778        uint32 spellid = 0; 
    1770         for(int rank = 4; rank >= 0; --rank) 
     1779        int rank = 4; 
     1780        for(; rank >= 0; --rank) 
    17711781        { 
    17721782            if(talentInfo->RankID[rank]!=0) 
     
    46464656} 
    46474657 
    4648 bool ChatHandler::HandleShutDownCommand(const char* args) 
     4658bool ChatHandler::HandleServerShutDownCancelCommand(const char* args) 
     4659{ 
     4660    sWorld.ShutdownCancel(); 
     4661    return true; 
     4662} 
     4663 
     4664bool ChatHandler::HandleServerShutDownCommand(const char* args) 
    46494665{ 
    46504666    if(!*args) 
    46514667        return false; 
    46524668 
    4653     if(std::string(args)=="cancel") 
    4654     { 
    4655         sWorld.ShutdownCancel(); 
     4669    char* time_str = strtok ((char*) args, " "); 
     4670    char* exitcode_str = strtok (NULL, ""); 
     4671 
     4672    int32 time = atoi (time_str); 
     4673 
     4674    ///- Prevent interpret wrong arg value as 0 secs shutdown time 
     4675    if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 
     4676        return false; 
     4677 
     4678    if (exitcode_str) 
     4679    { 
     4680        int32 exitcode = atoi (exitcode_str); 
     4681 
     4682        // Handle atoi() errors 
     4683        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 
     4684            return false; 
     4685 
     4686        // Exit code should be in range of 0-125, 126-255 is used 
     4687        // in many shells for their own return codes and code > 255 
     4688        // is not supported in many others 
     4689        if (exitcode < 0 || exitcode > 125) 
     4690            return false; 
     4691 
     4692        sWorld.ShutdownServ (time, 0, exitcode); 
    46564693    } 
    46574694    else 
    4658     { 
    4659         int32 time = atoi(args); 
    4660  
    4661         ///- Prevent interpret wrong arg value as 0 secs shutdown time 
    4662         if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 
     4695        sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE); 
     4696    return true; 
     4697} 
     4698 
     4699bool ChatHandler::HandleServerRestartCommand(const char* args) 
     4700{ 
     4701    if(!*args) 
     4702        return false; 
     4703 
     4704    char* time_str = strtok ((char*) args, " "); 
     4705    char* exitcode_str = strtok (NULL, ""); 
     4706 
     4707    int32 time = atoi (time_str); 
     4708 
     4709    ///- Prevent interpret wrong arg value as 0 secs shutdown time 
     4710    if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 
     4711        return false; 
     4712 
     4713    if (exitcode_str) 
     4714    { 
     4715        int32 exitcode = atoi (exitcode_str); 
     4716 
     4717        // Handle atoi() errors 
     4718        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 
    46634719            return false; 
    46644720 
    4665         sWorld.ShutdownServ(time); 
    4666     } 
    4667     return true; 
    4668 } 
    4669  
    4670 bool ChatHandler::HandleRestartCommand(const char* args) 
     4721        // Exit code should be in range of 0-125, 126-255 is used 
     4722        // in many shells for their own return codes and code > 255 
     4723        // is not supported in many others 
     4724        if (exitcode < 0 || exitcode > 125) 
     4725            return false; 
     4726 
     4727        sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART, exitcode); 
     4728    } 
     4729    else 
     4730        sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE); 
     4731    return true; 
     4732} 
     4733 
     4734bool ChatHandler::HandleServerIdleRestartCommand(const char* args) 
    46714735{ 
    46724736    if(!*args) 
    46734737        return false; 
    46744738 
    4675     if(std::string(args)=="cancel") 
    4676     { 
    4677         sWorld.ShutdownCancel(); 
     4739    char* time_str = strtok ((char*) args, " "); 
     4740    char* exitcode_str = strtok (NULL, ""); 
     4741 
     4742    int32 time = atoi (time_str); 
     4743 
     4744    ///- Prevent interpret wrong arg value as 0 secs shutdown time 
     4745    if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 
     4746        return false; 
     4747 
     4748    if (exitcode_str) 
     4749    { 
     4750        int32 exitcode = atoi (exitcode_str); 
     4751 
     4752        // Handle atoi() errors 
     4753        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 
     4754            return false; 
     4755 
     4756        // Exit code should be in range of 0-125, 126-255 is used 
     4757        // in many shells for their own return codes and code > 255 
     4758        // is not supported in many others 
     4759        if (exitcode < 0 || exitcode > 125) 
     4760            return false; 
     4761 
     4762        sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode); 
    46784763    } 
    46794764    else 
    4680     { 
    4681         int32 time = atoi(args); 
    4682  
    4683         ///- Prevent interpret wrong arg value as 0 secs shutdown time 
    4684         if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 
     4765        sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE,RESTART_EXIT_CODE); 
     4766    return true; 
     4767} 
     4768 
     4769bool ChatHandler::HandleServerIdleShutDownCommand(const char* args) 
     4770{ 
     4771    if(!*args) 
     4772        return false; 
     4773 
     4774    char* time_str = strtok ((char*) args, " "); 
     4775    char* exitcode_str = strtok (NULL, ""); 
     4776 
     4777    int32 time = atoi (time_str); 
     4778 
     4779    ///- Prevent interpret wrong arg value as 0 secs shutdown time 
     4780    if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 
     4781        return false; 
     4782 
     4783    if (exitcode_str) 
     4784    { 
     4785        int32 exitcode = atoi (exitcode_str); 
     4786 
     4787        // Handle atoi() errors 
     4788        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 
    46854789            return false; 
    46864790 
    4687         sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART); 
    4688     } 
    4689     return true; 
    4690 } 
    4691  
    4692 bool ChatHandler::HandleIdleRestartCommand(const char* args) 
    4693 { 
    4694     if(!*args) 
    4695         return false; 
    4696  
    4697     if(std::string(args)=="cancel") 
    4698     { 
    4699         sWorld.ShutdownCancel(); 
     4791        // Exit code should be in range of 0-125, 126-255 is used 
     4792        // in many shells for their own return codes and code > 255 
     4793        // is not supported in many others 
     4794        if (exitcode < 0 || exitcode > 125) 
     4795            return false; 
     4796 
     4797        sWorld.ShutdownServ (time, SHUTDOWN_MASK_IDLE, exitcode); 
    47004798    } 
    47014799    else 
    4702     { 
    4703         int32 time = atoi(args); 
    4704  
    4705         ///- Prevent interpret wrong arg value as 0 secs shutdown time 
    4706         if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 
    4707             return false; 
    4708  
    4709         sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE); 
    4710     } 
    4711     return true; 
    4712 } 
    4713  
    4714 bool ChatHandler::HandleIdleShutDownCommand(const char* args) 
    4715 { 
    4716     if(!*args) 
    4717         return false; 
    4718  
    4719     if(std::string(args)=="cancel") 
    4720     { 
    4721         sWorld.ShutdownCancel(); 
    4722     } 
    4723     else 
    4724     { 
    4725         int32 time = atoi(args); 
    4726  
    4727         ///- Prevent interpret wrong arg value as 0 secs shutdown time 
    4728         if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 
    4729             return false; 
    4730  
    4731         sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); 
    4732     } 
     4800        sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE); 
    47334801    return true; 
    47344802}