mirror of
https://github.com/love2d/love.git
synced 2026-08-12 00:20:52 +02:00
Added base64 support for FileData, and inlined all resources in boot.lua/graphics.lua as base64. Also removed old reshax stuff.
This commit is contained in:
@@ -1 +0,0 @@
|
||||
res/knoll1.png res/love.png res/planet.png res/star1.png res/Vera.ttf
|
||||
@@ -1,24 +0,0 @@
|
||||
TARGET = reshax-5million
|
||||
BINDIR = .
|
||||
OBJDIR = obj
|
||||
SRCDIR = src
|
||||
EXEC = $(BINDIR)/$(TARGET)
|
||||
OBJ = $(OBJDIR)/main.o
|
||||
|
||||
CPP = g++
|
||||
CFLAGS = -s -O2 -Wall
|
||||
LDFLAGS =
|
||||
|
||||
default: $(EXEC)
|
||||
|
||||
$(EXEC): $(OBJ)
|
||||
$(CPP) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
||||
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
|
||||
$(CPP) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ)
|
||||
|
||||
cleanall: clean
|
||||
rm -f $(EXEC)
|
||||
@@ -1,157 +0,0 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
std::ofstream resources_cpp, resources_h;
|
||||
std::stringstream resources_array;
|
||||
|
||||
void load(std::string file);
|
||||
void write(std::string file, int size, char *data);
|
||||
|
||||
|
||||
const char * love_header = ""
|
||||
"/**\n"
|
||||
"* Copyright (c) 2006-2010 LOVE Development Team\n"
|
||||
"* \n"
|
||||
"* This software is provided 'as-is', without any express or implied\n"
|
||||
"* warranty. In no event will the authors be held liable for any damages\n"
|
||||
"* arising from the use of this software.\n"
|
||||
"* \n"
|
||||
"* Permission is granted to anyone to use this software for any purpose,\n"
|
||||
"* including commercial applications, and to alter it and redistribute it\n"
|
||||
"* freely, subject to the following restrictions:\n"
|
||||
"* \n"
|
||||
"* 1. The origin of this software must not be misrepresented; you must not\n"
|
||||
"* claim that you wrote the original software. If you use this software\n"
|
||||
"* in a product, an acknowledgment in the product documentation would be\n"
|
||||
"* appreciated but is not required.\n"
|
||||
"* 2. Altered source versions must be plainly marked as such, and must not be\n"
|
||||
"* misrepresented as being the original software.\n"
|
||||
"* 3. This notice may not be removed or altered from any source distribution.\n"
|
||||
"**/\n\n";
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1)
|
||||
{
|
||||
resources_h.open("resources.h");
|
||||
resources_h
|
||||
<< love_header
|
||||
<< "#ifndef LOVE_RESOURCES_H\n"
|
||||
<< "#define LOVE_RESOURCES_H\n\n"
|
||||
<< "namespace love\n"
|
||||
<< "{\n"
|
||||
<< "\tstruct Resource\n"
|
||||
<< "\t{\n"
|
||||
<< "\t\tconst char * name;\n"
|
||||
<< "\t\tvoid * data;\n"
|
||||
<< "\t\tunsigned int size;\n"
|
||||
<< "\t};\n"
|
||||
<< "\n"
|
||||
<< "\textern const Resource resources[];\n"
|
||||
<< "\n";
|
||||
resources_cpp.open("resources.cpp");
|
||||
resources_cpp
|
||||
<< love_header
|
||||
<< "#include \"resources.h\"\n\n"
|
||||
<< "namespace love\n"
|
||||
<< "{\n";
|
||||
|
||||
resources_array << "\n\tconst Resource resources[] = {\n";
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
// use boost::filesystem to list all the files (in v2 maybe)
|
||||
load(argv[i]);
|
||||
}
|
||||
|
||||
resources_array << "\t\t{0,0,0}\n\t};\n\n";
|
||||
|
||||
resources_cpp << resources_array.str();
|
||||
resources_cpp << "} // love\n";
|
||||
resources_cpp.close();
|
||||
resources_h
|
||||
<< "}\n\n"
|
||||
<< "#endif // LOVE_RESOURCES_H \n";
|
||||
resources_h.close();
|
||||
}
|
||||
|
||||
else
|
||||
printf("ResHax-5Million v1.0a\n- now empowered by rubber piggies\n\nUsage: reshax-5million [file1] [file2] [and so on...]\n");
|
||||
}
|
||||
|
||||
void load(string file)
|
||||
{
|
||||
ifstream fs (file.c_str(), fstream::in | fstream::binary | fstream::ate);
|
||||
if (fs.is_open() && fs.good())
|
||||
{
|
||||
printf("Haxing %s", file.c_str());
|
||||
|
||||
int size = (int)fs.tellg();
|
||||
char * buff = new char[size];
|
||||
fs.seekg(0, ios::beg);
|
||||
fs.read(buff, size);
|
||||
#ifndef WIN32
|
||||
struct stat fstat;
|
||||
stat(file.c_str(), &fstat);
|
||||
if (!S_ISDIR(fstat.st_mode))
|
||||
write(file, size, buff);
|
||||
else
|
||||
printf(" FAIL cuz DIR\n");
|
||||
#else
|
||||
write(file, size, buff);
|
||||
#endif
|
||||
fs.close();
|
||||
delete [] buff;
|
||||
}
|
||||
else
|
||||
printf("Hax does not liek '%s'\n", file.c_str());
|
||||
}
|
||||
|
||||
void write(string file, int size, char *data)
|
||||
{
|
||||
char buffer[8];
|
||||
//size--;
|
||||
|
||||
// removes directory from file path
|
||||
size_t found;
|
||||
found = file.find_last_of('/');
|
||||
if (found != string::npos)
|
||||
file = file.substr(found + 1);
|
||||
|
||||
string var (file);
|
||||
// replaces dashes and dots (in UNIX only)
|
||||
//#ifndef WIN32
|
||||
found = var.find_first_of(" !\"#$%&'()*+,-.@[]", 0);
|
||||
while (found != string::npos)
|
||||
{
|
||||
var[found] = '_';
|
||||
found = var.find_first_of(" !\"#$%&'()*+,-.@[]", found);
|
||||
}
|
||||
//#endif
|
||||
|
||||
// Lowercase plz.
|
||||
for (unsigned int i=0;i<strlen(var.c_str());i++)
|
||||
if (var[i] >= 0x41 && var[i] <= 0x5A)
|
||||
var[i] = var[i] + 0x20;
|
||||
|
||||
resources_cpp << "\tconst char " << var << "_data[] = {";
|
||||
for (int i = 0; i < size - 1; i++)
|
||||
{
|
||||
sprintf(buffer, "%d,", data[i]);
|
||||
resources_cpp << buffer;
|
||||
if (i != 0 && i % 30 == 0)
|
||||
resources_cpp << "\n\t";
|
||||
}
|
||||
sprintf(buffer, "%d};\n\n", data[size]);
|
||||
resources_cpp << buffer;
|
||||
resources_array << "\t\t{\"_" << var << "\", (void*)" << var << "_data, " << size << "},\n";
|
||||
printf(" is haxed\n");
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual C++ Express 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reshax", "reshax.vcproj", "{B47E7C85-A0CF-4A14-BBB0-EA64BDDA9981}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B47E7C85-A0CF-4A14-BBB0-EA64BDDA9981}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B47E7C85-A0CF-4A14-BBB0-EA64BDDA9981}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B47E7C85-A0CF-4A14-BBB0-EA64BDDA9981}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B47E7C85-A0CF-4A14-BBB0-EA64BDDA9981}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,193 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="reshax"
|
||||
ProjectGUID="{B47E7C85-A0CF-4A14-BBB0-EA64BDDA9981}"
|
||||
RootNamespace="reshax"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\reshax.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 385 B |
@@ -11,6 +11,7 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\common\b64.cpp" />
|
||||
<ClCompile Include="..\..\src\common\Exception.cpp" />
|
||||
<ClCompile Include="..\..\src\common\Matrix.cpp" />
|
||||
<ClCompile Include="..\..\src\common\MemoryData.cpp" />
|
||||
@@ -69,6 +70,7 @@
|
||||
<ClCompile Include="..\..\src\modules\graphics\Graphics.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\Image.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\Font.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\Framebuffer.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\GLee.c" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\Glyph.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\Graphics.cpp" />
|
||||
@@ -77,6 +79,7 @@
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\Quad.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\SpriteBatch.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\wrap_Font.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\wrap_Framebuffer.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\wrap_Glyph.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\wrap_Graphics.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\wrap_Image.cpp" />
|
||||
@@ -177,9 +180,9 @@
|
||||
<ClCompile Include="..\..\src\modules\thread\sdl\wrap_Thread.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\timer\sdl\Timer.cpp" />
|
||||
<ClCompile Include="..\..\src\modules\timer\sdl\wrap_Timer.cpp" />
|
||||
<ClCompile Include="..\..\src\resources\resources.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\common\b64.h" />
|
||||
<ClInclude Include="..\..\src\common\config.h" />
|
||||
<ClInclude Include="..\..\src\common\Data.h" />
|
||||
<ClInclude Include="..\..\src\common\EnumMap.h" />
|
||||
@@ -232,6 +235,7 @@
|
||||
<ClInclude Include="..\..\src\modules\graphics\Graphics.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\Image.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\Font.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\Framebuffer.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\GLee.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\Glyph.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\Graphics.h" />
|
||||
@@ -240,6 +244,7 @@
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\Quad.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\SpriteBatch.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\wrap_Font.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\wrap_Framebuffer.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\wrap_Glyph.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\wrap_Graphics.h" />
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\wrap_Image.h" />
|
||||
@@ -299,7 +304,6 @@
|
||||
<ClInclude Include="..\..\src\modules\thread\ThreadModule.h" />
|
||||
<ClInclude Include="..\..\src\modules\timer\sdl\Timer.h" />
|
||||
<ClInclude Include="..\..\src\modules\timer\sdl\wrap_Timer.h" />
|
||||
<ClInclude Include="..\..\src\resources\resources.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{AED6D87B-9F81-49D0-8C6B-1C9F64421ECC}</ProjectGuid>
|
||||
|
||||
@@ -94,9 +94,6 @@
|
||||
<Filter Include="luasocket\libluasocket">
|
||||
<UniqueIdentifier>{d8b037d0-25fe-47df-bdbb-a85bd556231c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="resources">
|
||||
<UniqueIdentifier>{a2ca62d5-8dab-4f93-bbe8-75ff3c787936}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="common">
|
||||
<UniqueIdentifier>{f4054111-5d0f-40d9-90a9-da5da444bc50}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -565,9 +562,6 @@
|
||||
<ClCompile Include="..\..\src\libraries\luasocket\libluasocket\timeout.c">
|
||||
<Filter>luasocket\libluasocket</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\resources\resources.cpp">
|
||||
<Filter>resources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\common\Exception.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
@@ -595,6 +589,15 @@
|
||||
<ClCompile Include="..\..\src\common\wrap_Data.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\common\b64.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\Framebuffer.cpp">
|
||||
<Filter>modules\graphics\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\modules\graphics\opengl\wrap_Framebuffer.cpp">
|
||||
<Filter>modules\graphics\opengl</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\modules\audio\Audio.h">
|
||||
@@ -903,9 +906,6 @@
|
||||
<ClInclude Include="..\..\src\libraries\luasocket\luasocket.h">
|
||||
<Filter>luasocket</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\resources\resources.h">
|
||||
<Filter>resources</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\common\config.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
@@ -957,5 +957,14 @@
|
||||
<ClInclude Include="..\..\src\common\wrap_Data.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\common\b64.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\Framebuffer.h">
|
||||
<Filter>modules\graphics\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\modules\graphics\opengl\wrap_Framebuffer.h">
|
||||
<Filter>modules\graphics\opengl</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2010 LOVE Development Team
|
||||
*
|
||||
* 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
|
||||
* appreciated but is not required.
|
||||
* 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.
|
||||
**/
|
||||
|
||||
#include "b64.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
|
||||
|
||||
void b64_decode_block(char in[4], char out[3])
|
||||
{
|
||||
out[0] = (char)(in[0] << 2 | in[1] >> 4);
|
||||
out[1] = (char)(in[1] << 4 | in[2] >> 2);
|
||||
out[2] = (char)(((in[2] << 6) & 0xc0) | in[3]);
|
||||
}
|
||||
|
||||
char * b64_decode(const char * src, int slen, int & size)
|
||||
{
|
||||
size = (slen / 4) * 3;
|
||||
|
||||
char * dst = new char[size];
|
||||
char * d = dst;
|
||||
|
||||
char in[4], out[3], v;
|
||||
int i, len, pos = 0;
|
||||
|
||||
while(pos <= slen)
|
||||
{
|
||||
for(len = 0, i = 0; i < 4 && pos <= slen; i++ )
|
||||
{
|
||||
v = 0;
|
||||
|
||||
while(pos <= slen && v == 0 )
|
||||
{
|
||||
v = src[pos++];
|
||||
v = (char)((v < 43 || v > 122) ? 0 : cd64[v - 43]);
|
||||
if(v)
|
||||
v = (char)((v == '$') ? 0 : v - 61);
|
||||
}
|
||||
|
||||
if(pos <= slen)
|
||||
{
|
||||
len++;
|
||||
if(v)
|
||||
in[i] = (char)(v - 1);
|
||||
}
|
||||
else
|
||||
in[i] = 0;
|
||||
}
|
||||
|
||||
if(len) {
|
||||
b64_decode_block(in, out);
|
||||
for(i = 0; i < len - 1; i++)
|
||||
*(d++) = out[i];
|
||||
}
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
} // love
|
||||
@@ -18,20 +18,22 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_RESOURCES_H
|
||||
#define LOVE_RESOURCES_H
|
||||
#include "config.h"
|
||||
|
||||
#ifndef LOVE_B64_H
|
||||
#define LOVE_B64_H
|
||||
|
||||
namespace love
|
||||
{
|
||||
struct Resource
|
||||
{
|
||||
const char * name;
|
||||
void * data;
|
||||
unsigned int size;
|
||||
};
|
||||
/**
|
||||
* Decode base64 encoded data.
|
||||
*
|
||||
* @param src The string containing the base64 data.
|
||||
* @param slen The length of the string.
|
||||
* @param size The size of the binary data is stored here.
|
||||
* @return A chunk of memory containing the binary data (allocated with new[]).
|
||||
*/
|
||||
char * b64_decode(const char * src, int slen, int & size);
|
||||
} // love
|
||||
|
||||
extern const Resource resources[];
|
||||
|
||||
}
|
||||
|
||||
#endif // LOVE_RESOURCES_H
|
||||
#endif // LOVE_B64_H
|
||||
@@ -63,9 +63,6 @@
|
||||
|
||||
#endif // LOVE_BUILD_EXE
|
||||
|
||||
// Resources
|
||||
#include "resources/resources.h"
|
||||
|
||||
#ifdef LOVE_BUILD_STANDALONE
|
||||
|
||||
static const luaL_Reg modules[] = {
|
||||
@@ -120,14 +117,6 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
|
||||
|
||||
lua_setfield(L, -2, "_version_compat");
|
||||
|
||||
|
||||
// Resources.
|
||||
for(const love::Resource * r = love::resources; r->name != 0; r++)
|
||||
{
|
||||
love::luax_newtype(L, "Data", love::DATA_T, new love::MemoryData((void*)r->data, r->size));
|
||||
lua_setfield(L, -2, r->name);
|
||||
}
|
||||
|
||||
lua_pop(L, 1); // love
|
||||
|
||||
#ifdef LOVE_BUILD_STANDALONE
|
||||
@@ -241,7 +230,6 @@ int w__openConsole(lua_State * L)
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
|
||||
#ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
|
||||
int hack_argc = 0;
|
||||
char ** hack_argv = 0;
|
||||
@@ -311,7 +299,6 @@ int main(int argc, char ** argv)
|
||||
delete [] hack_argv;
|
||||
}
|
||||
#endif // LOVE_LEGENDARY_UTF8_ARGV_HACK
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,5 +59,23 @@ namespace filesystem
|
||||
return extension;
|
||||
}
|
||||
|
||||
bool FileData::getConstant(const char * in, Decoder & out)
|
||||
{
|
||||
return decoders.find(in, out);
|
||||
}
|
||||
|
||||
bool FileData::getConstant(Decoder in, const char *& out)
|
||||
{
|
||||
return decoders.find(in, out);
|
||||
}
|
||||
|
||||
StringMap<FileData::Decoder, FileData::DECODE_MAX_ENUM>::Entry FileData::decoderEntries[] =
|
||||
{
|
||||
{"file", FileData::FILE},
|
||||
{"base64", FileData::BASE64},
|
||||
};
|
||||
|
||||
StringMap<FileData::Decoder, FileData::DECODE_MAX_ENUM> FileData::decoders(FileData::decoderEntries, sizeof(FileData::decoderEntries));
|
||||
|
||||
} // filesystem
|
||||
} // love
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
// LOVE
|
||||
#include <string>
|
||||
#include <common/Data.h>
|
||||
#include <common/StringMap.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -47,6 +48,13 @@ namespace filesystem
|
||||
|
||||
public:
|
||||
|
||||
enum Decoder
|
||||
{
|
||||
FILE,
|
||||
BASE64,
|
||||
DECODE_MAX_ENUM
|
||||
}; // Decoder
|
||||
|
||||
FileData(int size, const std::string & filename);
|
||||
|
||||
virtual ~FileData();
|
||||
@@ -58,6 +66,14 @@ namespace filesystem
|
||||
const std::string & getFilename() const;
|
||||
const std::string & getExtension() const;
|
||||
|
||||
static bool getConstant(const char * in, Decoder & out);
|
||||
static bool getConstant(Decoder in, const char *& out);
|
||||
|
||||
private:
|
||||
|
||||
static StringMap<Decoder, DECODE_MAX_ENUM>::Entry decoderEntries[];
|
||||
static StringMap<Decoder, DECODE_MAX_ENUM> decoders;
|
||||
|
||||
}; // FileData
|
||||
|
||||
} // filesystem
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <common/config.h>
|
||||
|
||||
#include <common/utf8.h>
|
||||
#include <common/b64.h>
|
||||
|
||||
#include "Filesystem.h"
|
||||
|
||||
@@ -146,12 +147,26 @@ namespace physfs
|
||||
{
|
||||
FileData * fd = new FileData(size, std::string(filename));
|
||||
|
||||
// Copy the data into
|
||||
// Copy the data into FileData.
|
||||
memcpy(fd->getData(), data, size);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
FileData * Filesystem::newFileData(const char * b64, const char * filename)
|
||||
{
|
||||
int size = strlen(b64);
|
||||
int outsize = 0;
|
||||
char * dst = b64_decode(b64, size, outsize);
|
||||
FileData * fd = new FileData(outsize, std::string(filename));
|
||||
|
||||
// Copy the data into FileData.
|
||||
memcpy(fd->getData(), dst, outsize);
|
||||
delete [] dst;
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
const char * Filesystem::getWorkingDirectory()
|
||||
{
|
||||
if(cwd.empty())
|
||||
|
||||
@@ -142,6 +142,12 @@ namespace physfs
|
||||
**/
|
||||
FileData * newFileData(void * data, int size, const char * filename);
|
||||
|
||||
/**
|
||||
* Creates a new FileData object from base64 data.
|
||||
* @param b64 The base64 data.
|
||||
**/
|
||||
FileData * newFileData(const char * b64, const char * filename);
|
||||
|
||||
/**
|
||||
* Gets the current working directory.
|
||||
**/
|
||||
|
||||
@@ -98,8 +98,26 @@ namespace physfs
|
||||
size_t length = 0;
|
||||
const char * str = lua_tolstring(L, 1, &length);
|
||||
const char * filename = lua_tostring(L, 2);
|
||||
const char * decstr = lua_isstring(L, 3) ? lua_tostring(L, 3) : 0;
|
||||
|
||||
FileData * t = instance->newFileData((void*)str, (int)length, filename);
|
||||
FileData::Decoder decoder = FileData::FILE;
|
||||
|
||||
if(decstr)
|
||||
FileData::getConstant(decstr, decoder);
|
||||
|
||||
FileData * t = 0;
|
||||
|
||||
switch(decoder)
|
||||
{
|
||||
case FileData::FILE:
|
||||
t = instance->newFileData((void*)str, (int)length, filename);
|
||||
break;
|
||||
case FileData::BASE64:
|
||||
t = instance->newFileData(str, filename);
|
||||
break;
|
||||
default:
|
||||
return luaL_error(L, "Unrecognized FileData decoder: %s", decstr);
|
||||
}
|
||||
|
||||
luax_newtype(L, "FileData", FILESYSTEM_FILE_DATA_T, (void*)t);
|
||||
return 1;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1253
-26
File diff suppressed because it is too large
Load Diff
+6084
-51
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user