This commit is contained in:
watrabi
2025-09-18 17:55:52 -04:00
commit 977f1ff4b8
15030 changed files with 17324420 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="NoOpt|ARM">
<Configuration>NoOpt</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="NoOpt|Win32">
<Configuration>NoOpt</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{BB0AF3CB-A723-4948-BC84-F9960876C5CE}</ProjectGuid>
<RootNamespace>CoreScriptConverter2</RootNamespace>
<SccProjectName>Perforce Project</SccProjectName>
<SccLocalPath>..</SccLocalPath>
<SccProvider>MSSCCI:Perforce SCM</SccProvider>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NoOpt|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NoOpt|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="..\CustomBuildRules.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='NoOpt|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='NoOpt|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NoOpt|Win32'">
<OutDir>tool\win32</OutDir>
<TargetName>rsc</TargetName>
<PublishDLLDependencyBeforeTargets>Midl</PublishDLLDependencyBeforeTargets>
<PublishDLLDependencyAfterTargets>CustomBuild</PublishDLLDependencyAfterTargets>
<IntDir>obj\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NoOpt|ARM'">
<TargetName>rsc</TargetName>
<PublishDLLDependencyBeforeTargets>Midl</PublishDLLDependencyBeforeTargets>
<PublishDLLDependencyAfterTargets>CustomBuild</PublishDLLDependencyAfterTargets>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='NoOpt|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(CONTRIB_PATH)\SDL2\include;$(CONTRIB_PATH)\boost_1_56_0\include;..\App.BulletPhysics;..\App\include;..\Base\include;..\Network\include;..\Log\include;..\Rendering\GfxBase\include;..\Rendering\g3d\include;..\Rendering\RbxG3D\include;..\ClientShared;..\fmod\api\inc;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_NOOPT;NDEBUG;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>zlib.lib;fmod_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>.\libraries;..\TBB_4_1\lib;..\fmod\win32\lib;.\Mesa-7.8.1\lib;$(CONTRIB_PATH)\SDK\Lib;$(CONTRIB_PATH)\VMProtectWin;$(CONTRIB_PATH)\windows\x86\zlib\zlib-1.2.8\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PublishDLLDependency />
<PreBuildEvent>
<Command>p4 edit tool/win32/*</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='NoOpt|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(CONTRIB_PATH)\SDL2\include;$(CONTRIB_PATH)\boost_1_56_0\include;..\App.BulletPhysics;..\App\include;..\Base\include;..\Network\include;..\Log\include;..\Rendering\GfxBase\include;..\Rendering\g3d\include;..\Rendering\RbxG3D\include;..\ClientShared;..\fmod\api\inc;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_NOOPT;NDEBUG;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>zlib.lib;fmod_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>.\libraries;..\TBB_4_1\lib;..\fmod\win32\lib;.\Mesa-7.8.1\lib;$(CONTRIB_PATH)\SDK\Lib;$(CONTRIB_PATH)\VMProtectWin;$(CONTRIB_PATH)\windows\x86\zlib\zlib-1.2.8\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PublishDLLDependency />
<PreBuildEvent>
<Command>p4 edit tool/win32/*</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\App\script\LuaVMServer.cpp" />
<ClCompile Include="..\ClientShared\DataModelEmptySerialize.cpp" />
<ClCompile Include="cscmain.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\App\App.vcxproj">
<Project>{63db8347-940b-4a05-8975-6a6545c315dc}</Project>
<Private>false</Private>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
<ProjectReference Include="..\Base\Base.vcxproj">
<Project>{3025c00a-7746-469b-a279-96127c72abee}</Project>
</ProjectReference>
<ProjectReference Include="..\boostlibs\boost.static.vcxproj">
<Project>{5423bfb6-d3eb-4b00-a82b-38001eb8745f}</Project>
</ProjectReference>
<ProjectReference Include="..\Log\Log.vcxproj">
<Project>{9980f6c3-b64d-4775-8793-bb6dde31ce82}</Project>
</ProjectReference>
<ProjectReference Include="..\Network\Network.vcxproj">
<Project>{9b9eb5c6-15d1-4765-bcc7-8a42f2c9f6cc}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\CustomBuildRules.targets" />
</ImportGroup>
<ItemGroup>
<PublishDLLDependency Include="..\fmod\win32\fmod.dll" />
<PublishDLLDependency Include="..\VMProtect\VMProtectSDK32.dll" />
</ItemGroup>
</Project>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="cscmain.cpp" />
<ClCompile Include="..\App\script\LuaVMServer.cpp" />
<ClCompile Include="..\ClientShared\DataModelEmptySerialize.cpp" />
</ItemGroup>
<ItemGroup>
<PublishDLLDependency Include="..\VMProtect\VMProtectSDK32.dll">
<Filter>Libraries</Filter>
</PublishDLLDependency>
<PublishDLLDependency Include="..\fmod\win32\fmod.dll">
<Filter>Libraries</Filter>
</PublishDLLDependency>
</ItemGroup>
<ItemGroup>
<Filter Include="Libraries">
<UniqueIdentifier>{59c6af56-0d1e-4fac-a7e3-08fb073263f4}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
+313
View File
@@ -0,0 +1,313 @@
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdarg.h>
#include <boost/filesystem.hpp>
#include <vector>
#include <map>
#include <sstream>
#include <algorithm>
#include "script/LuaVM.h"
#include "util/Utilities.h" // for rot13
#ifdef _MSC_VER
#define ASSERT(X) ((void) ( (X) || ( fprintf(stderr, "%s(%d): ASSERTION FAILED: %s\n", __FILE__, __LINE__, #X), __debugbreak(), 1 ) ) )
#else
#define ASSERT(X)
#endif
using namespace std;
using namespace boost::filesystem;
struct filedesc
{
string name;
path file;
bool module;
};
//3456 |<--80
const char* usage =
"Roblox Script Compiler - compiles and encrypts local core scripts."
""
"Usage:\n"
"\n"
"rsc [option]\n"
"\n"
"Options:\n"
" --help - this help message\n"
" --helpcfg - config file help\n"
" --verbose - print .lua files and name mappings to stdout\n"
" --rscloc - changes the location to look for rsc.config file\n"
"\n"
"When run, rsc requires a config file named rsc.config to be present in the\n"
"current directory. The config file specifies paths and additional options for\n"
"the script compilation process.\n"
;
const char* cfghelp =
"rsc.config file reference\n"
"\n"
"The syntax is key=value. Preceding and trailing whitespace chars are ignored.\n"
"All relative paths assume the location of rsc.config as the base path.\n"
"Comment lines must start with '#'.\n"
"Required settings:\n"
"\n"
"source - path to look for Lua scripts.\n"
"output - output path/name (e.g. ../App/script/LuaGenCS.inl)\n"
"\n"
"Optional settings:\n"
"source1, ... source9 - additional paths to look for Lua scripts\n"
;
map<string,string> config;
int verbose = 0;
//////////////////////////////////////////////////////////////////////////
static int fatal(const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "FATAL: ");
vfprintf(stderr, fmt, ap);
va_end(ap);
exit(1);
return 1;
}
template< class Map >
static inline typename Map::mapped_type* mapget(const Map& m, const typename Map::key_type& k)
{
typename Map::const_iterator it = m.find(k);
if( it == m.end() ) return 0;
return const_cast<typename Map::mapped_type*>(&it->second);
}
static void rdconfig(const char* cfgfile, char** argv)
{
config.clear();
FILE* vf = fopen(cfgfile, "rt");
vf || fatal( "could not open '%s'. Run 'rsc --help' for help.\n", cfgfile, argv[0]);
char str[2000];
char* k, *v, *q;
int line = 1;
// parses "key=value", trims the whitespace, so that " key = value " is still ok
while (true)
{
if (!fgets(str, sizeof(str), vf))
break;
for (k = str; *k && strchr(" \n\t", *k); ++k) {} // ignore the whitespace
if (!*k || *k == '#') { continue; } // empty line, whitespace or comment
for (q = k; isalnum(*q) || *q == '_'; ++q ) {} // find where key ends
while( *q && *q != '=' ) { *q++ = 0; } // find the '='
*q == '=' || fatal("%s(%d): '=' expected.\n", cfgfile, line);
*q = 0; // kill the '=' sign, because who cares
strlen(k) || fatal("%s(%d): option name expected before '='.\n", cfgfile, line);
for (v = q + 1; *v && strchr(" \t", *v); ++v) {} // find where the value starts
q = v + strlen(v) - 1; // end of the line
while ( q > v && strchr(" \n\t", *q ) ) { *q-- = 0; } // trim from the end
// at this point, k points to key, v points to value
config.insert( map<string, string>::value_type(k,v) ).second || fatal("%s(%d): duplicate entry for '%s'", cfgfile, line, k);
line++;
}
fclose(vf);
}
void rdfile(string* result, const path& filepath)
{
ASSERT(result);
#if _MSC_VER
FILE* vf = _wfopen(filepath.native().c_str(), L"rb");
#else
FILE* vf = fopen(filepath.native().c_str(), "rb");
#endif
vf || fatal("could not open '%s'\n", filepath.native().c_str() );
// no better portable way to get file size
fseek(vf, 0, SEEK_END);
long size = ftell(vf);
fseek(vf, 0, SEEK_SET);
result->resize(size);
fread( (char*)result->data(), 1, size, vf);
fclose(vf);
}
void buildFileList( vector<filedesc>& files, path dir, path parent = path() )
{
for( boost::filesystem::directory_iterator it(dir), e; it != e; ++it )
{
directory_entry& dirent = *it;
const path& filepath = dirent.path();
file_status st = dirent.status();
if (st.type() == regular_file)
if (filepath.extension() == ".lua")
{
path name = parent / filepath.filename();
filedesc d;
d.name = name.replace_extension().string();
std::replace( d.name.begin(), d.name.end(), '\\', '/');
d.file = filepath;
d.module = d.name.find("Libraries") == 0;
if(d.module)
d.name = d.name.substr( 8 ); // remove the "Modules/" from the name, because that's how it's supposed to be
files.push_back(d);
if (verbose)
{
printf( " %s: %s\n", d.name.c_str(), filepath.native().c_str() );
}
}
if (dirent.status().type() == directory_file)
{
if( dirent.path().filename() != ".git" )
buildFileList(files, dirent.path(), parent / dirent.path().filename() );
}
}
}
char* hexa(unsigned char ch)
{
static const char sym[] = "0123456789abcdef";
static char buf[8];
buf[0] = '0';
buf[1] = 'x';
buf[2] = sym[ (ch>>4) & 0xf ];
buf[3] = sym[ (ch ) & 0xf ];
buf[4] = 0;
return buf;
}
void printBuffer( ostream& os, const string& name, const string& data)
{
os << "static const unsigned char "<<name<<"[] = {";
for( int j=0, e = data.size(); j<e; ++j )
{
if ( !(j%32) )
os<<"\n ";
os<<hexa(data[j])<<", ";
}
os << "\n };\n\n";
}
int main(int argc, char** argv)
{
std::string rscloc = "rsc.config";
for( int j=1; j<argc; ++j )
{
if (!strcmp(argv[j], "--help"))
return fprintf( stderr, "%s\n", usage), 0;
else if (!strcmp(argv[j], "--helpcfg"))
return fprintf( stderr, "%s\n", cfghelp), 0;
else if (!strcmp(argv[j], "--verbose"))
verbose = 1;
else if(!strcmp(argv[j], "--rscloc"))
{
if (j + 1 < argc)
{
rscloc = argv[j + 1];
j++;
}
}
else
fatal("command-line: bad option '%s', use --help for info.\n", argv[j]);
}
rdconfig(rscloc.c_str(), argv);
if (verbose)
{
for (auto a = config.begin(); a != config.end(); ++a)
{
printf("'%s'='%s'\n", a->first.c_str(), a->second.c_str());
}
}
mapget(config, "source") || fatal("missing 'source' in rsc.config\n");
mapget(config, "output") || fatal("missing 'output' in rsc.config\n");
path rsclocPath(rscloc.c_str());
vector<filedesc> files;
path source = rsclocPath.parent_path() / config["source"];
buildFileList(files, source);
for(int j=1; j<9; ++j)
{
char keyname[44];
sprintf( keyname, "source%d", j );
if( string* dir = mapget(config, string(keyname)) )
{
path p = rsclocPath.parent_path() / *dir;
buildFileList(files, p );
}
}
// got all the files, go ahead and compile
if(1)
{
stringstream arrays, scripts, modules; // 3 main sections
scripts << "static const CoreScriptBytecode gCoreScripts[] = {\n";
modules << "static const CoreScriptBytecode gCoreModuleScripts[] = {\n";
for( unsigned j=0; j<files.size(); ++j)
{
string source;
filedesc& fd = files[j];
rdfile( &source, fd.file);
std::string bytecode = LuaVM::compileCore(source);
string encname = fd.name;
string arrayName = RBX::format( "a%04u", j);
encname = RBX::rot13(encname);
printBuffer(arrays, arrayName, bytecode);
(fd.module ? modules : scripts) << " { \"" << encname << "\", " << arrayName << ", " << bytecode.size() << " },\n";
printf(".");
}
printf("\n");
scripts << "};\n\n";
modules << "};\n\n";
printf("\n");
path outputFile = rsclocPath.parent_path() / config["output"];
ofstream output(outputFile.c_str());
output << arrays.str() << scripts.str() << modules.str();
if( output.rdstate() & output.failbit )
fatal( "could not write to '%s'", outputFile.c_str() );
}
}
+9
View File
@@ -0,0 +1,9 @@
# configuration file template for the script compiler
# make a copy this file, name it 'rsc.config', then modify it to point to your local files
#
# Run rsc --helpcfg for more info
#
output = ..\App\script\LuaGenCS.inl
source = <path-to-scripts>
source1 = <path-to-more-scripts>
@@ -0,0 +1,29 @@
#!/bin/bash
echo "Running CoreScriptConverter"
cd "$1"
./CoreScriptConverter --rscloc "../rsc.config" --verbose
cd "$1/../../../App/script/"
if [[ -e "LuaGenCS.inl" ]];
then
file1=$(md5 -q LuaGenCSNew.inl)
file2=$(md5 -q LuaGenCS.inl)
echo $file1
echo $file2
if [ $file1 == $file2 ]
then
echo "No CoreScript changes detected"
rm "LuaGenCSNew.inl"
else
echo "CoreScript changes detected, will require linking"
rm "LuaGenCS.inl"
mv "LuaGenCSNew.inl" "LuaGenCS.inl"
fi
else
echo "CoreScript changes detected, will require linking"
mv "LuaGenCSNew.inl" "LuaGenCS.inl"
fi
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
# configuration file template for the script compiler
# make a copy this file, name it 'rsc.config', then modify it to point to your local files
#
# Run rsc --helpcfg for more info
#
output = ../../App/script/LuaGenCSNew.inl
source = ../../content/scripts
+9
View File
@@ -0,0 +1,9 @@
# configuration file template for the script compiler
# make a copy this file, name it 'rsc.config', then modify it to point to your local files
#
# Run rsc --helpcfg for more info
#
output = ../../App/script/LuaGenCSNew.inl
source = ../../content/scripts
source2 = ../../PlatformContent/durango/scripts/ui