Raised This Month: $32 Target: $400
 8% 

[L4D1 & L4D2] Restart Without Changelevel


Post New Thread Reply   
 
Thread Tools Display Modes
Author
iaNanaNana
Member
Join Date: Sep 2020
Location: Two-dimensional
Plugin ID:
7763
Plugin Version:
1.6
Plugin Category:
All
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    36 
    Plugin Description:
    Restart round but don't changelevel
    Old 08-23-2021 , 00:24   [L4D1 & L4D2] Restart Without Changelevel
    Reply With Quote #1

    According to many people thought the restart scenario from vote will restart the current level, but original is not, so this plugin came out.
    Make restart scenario from vote no longer change map to first map of scenario.


    Required Extension : SourceScramble

    Required Plugin : Left 4 DHooks Direct


    Thanks:
    • Forgetest - Technical support and help me find the win sigs and offset
    • Psyk0tik - Technical support

    Cvar:
    PHP Code:
    l4d_vote_restart_round "1" // Turn on/off the restart game from vote to restart current level. 
    Changes:
    Code:
    1.6	  - 2024/2/8
    	  - Reset current round team score after restarted
    	  - Fixed the wrong offset of "CDirector::m_iRoundNumber". Thanks to Forgetest for technical support.
    
    1.5.2 - 2023/5/25
    	  - Updated L4D2 offsets and signatures.
    
    1.5.1 - 2023/5/10
    	  - Fixed L4D_GetGameModeType() work problem in L4D1. Thanks to HarryPotter for reporting and provide solution.
    
    1.5 - 2023/4/25
    	- Reduce unnecessary code.
    	- Function CDirector::EndScenario instead CDirector::Restart
    	- Added restart reason number. #usage: sm_restart <L4D2_RestartReason> || empty for auto
    	- Fixed broken win signatures.
    
    1.4.1 - 2022/12/8
    	- Fixed crash the server after call the restart vote. Thanks to gabuch2 for reporting.
    	- Fixed invalid Win signatures.
    
    1.4 - 2022/12/7
    	- Added Versus Support :  Restart current round without loading map, it can restore to the score before the start of current round.
    	- Added admin command (GENERIC) "sm_restart" : Restart current round/level immediately
    	- CRestartGameIssue::ExecuteCommand instead RestartScenarioFromVote
    	- Fixed may crash on Win server. Thanks to Silvers for reporting.
    
    1.2
    	- Added l4d1 support. Thanks to Beatles for suggestion.
    	- Reduce unnecessary code.
    	
    1.1
    	- Fixed plugin conflict with left4dhooks while in windows server. Thanks to HarryPotter for reporting.
    	- Fixed wrong detour setting cause crash the windows server. Thanks to Psyk0tik for technical support.
    
    1.0
    	- Initial release

    Last edited by iaNanaNana; 02-08-2024 at 03:03. Reason: Update
    iaNanaNana is offline
    KRUTIK
    Senior Member
    Join Date: Feb 2019
    Location: Мос
    Old 08-23-2021 , 14:07   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #2

    There is already such a plugin.
    https://forums.alliedmods.net/showthread.php?t=99276
    KRUTIK is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 08-23-2021 , 15:00   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #3

    Quote:
    Originally Posted by KRUTIK View Post
    The plugin you linked is for recovering the last played map when the server crashes or restarts for any reason. This plugin prevents the server from starting on the first map of a campaign when restarting the campaign. They are completely different from each other.
    __________________
    Psyk0tik is offline
    HarryPotter
    Veteran Member
    Join Date: Sep 2017
    Location: Taiwan, Asia
    Old 08-24-2021 , 09:40   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #4

    conflict with left4dhooks
    PHP Code:
    L 08/24/2021 21:39:25: [left4dhooks.smxFailed to find signatureRestartScenarioFromVote 
    and my windows server crashes when call vote
    __________________

    Last edited by HarryPotter; 08-24-2021 at 09:57.
    HarryPotter is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 08-24-2021 , 10:28   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #5

    Quote:
    Originally Posted by HarryPotter View Post
    conflict with left4dhooks
    PHP Code:
    L 08/24/2021 21:39:25: [left4dhooks.smxFailed to find signatureRestartScenarioFromVote 
    That's not something that can be fixed by only one plugin. The first few bytes are replaced with a jump instruction when detouring a function, so both this plugin and Left 4 DHooks will have to use a signature that wildcards the first few bytes. That is the only way to make both plugins "compatible" with each other.

    @iaNanaNana, you can use my signatures since you are detouring both functions:
    PHP Code:
    /**
     * CDirector::Restart()
     *
     * How to find on Windows:
     * 1. Search for the "Reloading original map %s\n" or "Staying on original map %s\n" string.
     * 2. The string can only be found in this function.
     **/
    "CDirector::Restart"
    {
        
    "library"    "server"
        "linux"        "@_ZN9CDirector7RestartEv"
        "windows"    "\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\xA1\xD8\x2A\x2A\x2A\x33\x2A\x89\x2A\x2A\xA1\x90\x2A\x2A\x2A\x8B\x2A\x2A\x53\x56\x57\x8B"
                
    /* ? ? ? ? ? ? ? ? ? A1 D8 ? ? ? 33 ? 89 ? ? A1 90 ? ? ? 8B ? ? 53 56 57 8B */
    }

    /**
     * CDirector::RestartScenarioFromVote(char const*)
     *
     * How to find on Windows:
     * 1. Search for the "RestartScenarioFromVote - changing to map %s\n" string.
     * 2. The string can only be found in this function.
     **/
    "CDirector::RestartScenarioFromVote"
    {
        
    "library"    "server"
        "linux"        "@_ZN9CDirector23RestartScenarioFromVoteEPKc"
        "windows"    "\x2A\x2A\x2A\x2A\x2A\x2A\x8B\x0D\x2A\x2A\x2A\x2A\x57\x85\x2A\x74\x2A\x6A"
                
    /* ? ? ? ? ? ? 8B 0D ? ? ? ? 57 85 ? 74 ? 6A */

    __________________

    Last edited by Psyk0tik; 08-24-2021 at 10:34.
    Psyk0tik is offline
    iaNanaNana
    Member
    Join Date: Sep 2020
    Location: Two-dimensional
    Old 08-24-2021 , 22:48   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #6

    Quote:
    Originally Posted by Psyk0tik View Post
    That's not something that can be fixed by only one plugin. The first few bytes are replaced with a jump instruction when detouring a function, so both this plugin and Left 4 DHooks will have to use a signature that wildcards the first few bytes. That is the only way to make both plugins "compatible" with each other.

    @iaNanaNana, you can use my signatures since you are detouring both functions:
    PHP Code:
    /**
     * CDirector::Restart()
     *
     * How to find on Windows:
     * 1. Search for the "Reloading original map %s\n" or "Staying on original map %s\n" string.
     * 2. The string can only be found in this function.
     **/
    "CDirector::Restart"
    {
        
    "library"    "server"
        "linux"        "@_ZN9CDirector7RestartEv"
        "windows"    "\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\xA1\xD8\x2A\x2A\x2A\x33\x2A\x89\x2A\x2A\xA1\x90\x2A\x2A\x2A\x8B\x2A\x2A\x53\x56\x57\x8B"
                
    /* ? ? ? ? ? ? ? ? ? A1 D8 ? ? ? 33 ? 89 ? ? A1 90 ? ? ? 8B ? ? 53 56 57 8B */
    }

    /**
     * CDirector::RestartScenarioFromVote(char const*)
     *
     * How to find on Windows:
     * 1. Search for the "RestartScenarioFromVote - changing to map %s\n" string.
     * 2. The string can only be found in this function.
     **/
    "CDirector::RestartScenarioFromVote"
    {
        
    "library"    "server"
        "linux"        "@_ZN9CDirector23RestartScenarioFromVoteEPKc"
        "windows"    "\x2A\x2A\x2A\x2A\x2A\x2A\x8B\x0D\x2A\x2A\x2A\x2A\x57\x85\x2A\x74\x2A\x6A"
                
    /* ? ? ? ? ? ? 8B 0D ? ? ? ? 57 85 ? 74 ? 6A */

    It's work! but still crash the windows server if use with left4dhooks, I try find another way

    Last edited by iaNanaNana; 08-24-2021 at 22:49.
    iaNanaNana is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 08-25-2021 , 04:42   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #7

    Quote:
    Originally Posted by iaNanaNana View Post
    It's work! but still crash the windows server if use with left4dhooks, I try find another way
    It's crashing because your detour setup for "CDirector::RestartScenarioFromVote" is wrong. The signatures I provided have nothing to do with the crash.

    Your detour should be setup this way (already confirmed to be working on Windows):
    PHP Code:
    "RestartScenarioFromVote"
    {
        
    "signature"        "RestartScenarioFromVote"
        "callconv"        "thiscall"
        "return"        "void"
        "this"            "address"
        "arguments"
        
    {
            
    "map"
            
    {
                
    "type"        "charptr"
            
    }
        }

    Your detour callbacks should be setup like this (also confirmed to be working on Windows):
    PHP Code:
    public MRESReturn DH_OnRestart(Address pThis)
    {
        
    StoreToAddress(pThis+view_as<Address>(452), 1NumberType_Int8)
    }

    public 
    MRESReturn DH_OnRestartFromVote(Address pThisDHookParam hParams)
    {
        
    hRestartGame.SetInt(1)
        return 
    MRES_Supercede

    When setting up detours, you have to go by the actual prototype of the function. The Pseudo-code provided by IDA isn't always accurate.

    Your current setup would make the actual function look like this:
    Code:
    CDirector::RestartScenarioFromVote(void)
    When it should be like this:
    Code:
    CDirector::RestartScenarioFromVote(const char*)
    __________________
    Psyk0tik is offline
    iaNanaNana
    Member
    Join Date: Sep 2020
    Location: Two-dimensional
    Old 08-25-2021 , 05:33   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #8

    Quote:
    Originally Posted by HarryPotter View Post
    conflict with left4dhooks
    PHP Code:
    L 08/24/2021 21:39:25: [left4dhooks.smxFailed to find signatureRestartScenarioFromVote 
    and my windows server crashes when call vote
    Updated.

    Last edited by iaNanaNana; 08-25-2021 at 05:38.
    iaNanaNana is offline
    iaNanaNana
    Member
    Join Date: Sep 2020
    Location: Two-dimensional
    Old 08-25-2021 , 05:36   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #9

    Quote:
    Originally Posted by Psyk0tik View Post
    It's crashing because your detour setup for "CDirector::RestartScenarioFromVote" is wrong. The signatures I provided have nothing to do with the crash.

    Your detour should be setup this way (already confirmed to be working on Windows):
    PHP Code:
    "RestartScenarioFromVote"
    {
        
    "signature"        "RestartScenarioFromVote"
        "callconv"        "thiscall"
        "return"        "void"
        "this"            "address"
        "arguments"
        
    {
            
    "map"
            
    {
                
    "type"        "charptr"
            
    }
        }

    Your detour callbacks should be setup like this (also confirmed to be working on Windows):
    PHP Code:
    public MRESReturn DH_OnRestart(Address pThis)
    {
        
    StoreToAddress(pThis+view_as<Address>(452), 1NumberType_Int8)
    }

    public 
    MRESReturn DH_OnRestartFromVote(Address pThisDHookParam hParams)
    {
        
    hRestartGame.SetInt(1)
        return 
    MRES_Supercede

    When setting up detours, you have to go by the actual prototype of the function. The Pseudo-code provided by IDA isn't always accurate.

    Your current setup would make the actual function look like this:
    Code:
    CDirector::RestartScenarioFromVote(void)
    When it should be like this:
    Code:
    CDirector::RestartScenarioFromVote(const char*)
    I see, It's work fine now, very big thanks for your help
    iaNanaNana is offline
    HarryPotter
    Veteran Member
    Join Date: Sep 2017
    Location: Taiwan, Asia
    Old 08-25-2021 , 08:31   Re: [L4D2] Restart Without Changelevel
    Reply With Quote #10

    plugin is working now,
    although it still has error
    PHP Code:
    L 08/25/2021 20:30:39: [left4dhooks.smxFailed to find signatureRestartScenarioFromVote 
    __________________
    HarryPotter is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 01:34.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode