31 lines
1.9 KiB
Python
31 lines
1.9 KiB
Python
"""The existing reveal/hide command must change the selected player's full bitfield."""
|
|
from pathlib import Path
|
|
import subprocess,tempfile
|
|
root=Path(__file__).resolve().parents[2];s=(root/'src/server/scripts/Commands/cs_cheat.cpp').read_text()
|
|
a=s.index(' static bool HandleExploreCheatCommand(');b=s.index('\n};',a)
|
|
code=r'''
|
|
#include <cstdlib>
|
|
#include <string>
|
|
#include <cassert>
|
|
using uint8=unsigned char;
|
|
constexpr int PLAYER_EXPLORED_ZONES_SIZE=156,PLAYER_EXPLORED_ZONES_1=0;
|
|
constexpr int LANG_NO_CHAR_SELECTED=0,LANG_YOU_SET_EXPLORE_ALL=1,LANG_YOURS_EXPLORE_SET_ALL=2,LANG_YOU_SET_EXPLORE_NOTHING=3,LANG_YOURS_EXPLORE_SET_NOTHING=4;
|
|
struct Session{};
|
|
struct Player{unsigned zones[156]{};Session session;Session*GetSession(){return &session;}void SetUInt32Value(int i,unsigned v){zones[i]=v;}};
|
|
struct ChatHandler{Player*target=nullptr;explicit ChatHandler(Session*){}ChatHandler()=default;
|
|
Player*getSelectedPlayer(){return target;}void SendSysMessage(int){}void SetSentErrorMessage(bool){}
|
|
bool needReportToTarget(Player*){return false;}std::string GetNameLink(Player* =nullptr){return "Tester";}
|
|
template<class...T>void PSendSysMessage(T const&...){} };
|
|
'''+s[a:b]+r'''
|
|
int main(){Player selected,caller;ChatHandler handler;handler.target=&selected;
|
|
assert(HandleExploreCheatCommand(&handler,"1"));for(auto bit:selected.zones)assert(bit==0xFFFFFFFFu);for(auto bit:caller.zones)assert(bit==0);
|
|
assert(HandleExploreCheatCommand(&handler,"0"));for(auto bit:selected.zones)assert(bit==0);
|
|
assert(!HandleExploreCheatCommand(&handler,""));handler.target=nullptr;assert(!HandleExploreCheatCommand(&handler,"1"));
|
|
}
|
|
'''
|
|
with tempfile.TemporaryDirectory()as d:
|
|
p=Path(d);(p/'test.cpp').write_text(code)
|
|
subprocess.run(['c++','-std=c++17',str(p/'test.cpp'),'-o',str(p/'test')],check=True)
|
|
subprocess.run([str(p/'test')],check=True)
|
|
print('Native cheat explore reveals/clears every zone field on selected player; caller stays unchanged.')
|