Move Lua modules; remove goodform
parent
521ec24a95
commit
46082b5d01
|
@ -1,6 +1,3 @@
|
|||
[submodule "assets/lua/lds"]
|
||||
path = assets/lua/lds
|
||||
url = https://github.com/neomantra/lds.git
|
||||
[submodule "ext/StackTracePlus"]
|
||||
path = ext/StackTracePlus
|
||||
url = https://github.com/ignacio/StackTracePlus.git
|
||||
|
@ -19,3 +16,12 @@
|
|||
[submodule "ext/threads"]
|
||||
path = ext/threads
|
||||
url = https://github.com/torch/threads.git
|
||||
[submodule "assets/lua/modules/bitser"]
|
||||
path = assets/lua/modules/bitser
|
||||
url = https://github.com/gvx/bitser.git
|
||||
[submodule "assets/lua/modules/cdata"]
|
||||
path = assets/lua/modules/cdata
|
||||
url = https://github.com/excessive/cdata.git
|
||||
[submodule "assets/lua/modules/lds"]
|
||||
path = assets/lua/modules/lds
|
||||
url = https://github.com/neomantra/lds.git
|
||||
|
|
|
@ -69,12 +69,6 @@ find_package(OpenGL REQUIRED)
|
|||
find_package(PkgConfig REQUIRED)
|
||||
find_package(LuaJIT REQUIRED)
|
||||
|
||||
find_package(goodform REQUIRED)
|
||||
if(NOT goodform_FOUND)
|
||||
message(FATAL_ERROR "Bundled goodform not found. Have you checked out submodules?
|
||||
git submodule update --init")
|
||||
endif()
|
||||
|
||||
find_package(Optional REQUIRED)
|
||||
|
||||
pkg_search_module(GLFW REQUIRED glfw3)
|
||||
|
@ -90,7 +84,6 @@ include_directories(BEFORE
|
|||
${LIBSODIUM_INCLUDE_DIRS}
|
||||
${SQLITE3_INCLUDE_DIRS}
|
||||
${OPENAL_INCLUDE_DIR}
|
||||
${GOODFORM_INCLUDE_DIR}
|
||||
${OPTIONAL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
|
@ -160,7 +153,6 @@ target_link_libraries(diggler
|
|||
${LIBSODIUM_LIBRARIES}
|
||||
${SQLITE3_LIBRARIES}
|
||||
${OPENAL_LIBRARY}
|
||||
${GOODFORM_LIBRARY}
|
||||
pthread
|
||||
)
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ end
|
|||
|
||||
|
||||
package.loaded['diggler'] = diggler
|
||||
package.loaded['lds'] = require('lds')
|
||||
--package.loaded['lds'] = require('lds')
|
||||
|
||||
local function setoverlay(tab, orig)
|
||||
local mt = getmetatable(tab) or {}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
local b64 = dofile('base64/mime_base64.lua')
|
||||
|
||||
return {
|
||||
encode = b64.base64_encode,
|
||||
decode = b64.base64_decode
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
--- MIME BASE64 Encoding and Decoding Routines
|
||||
-- Copyright 2013 Jeff Solinsky
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
|
||||
local escape = {}
|
||||
|
||||
local ffi = require'ffi'
|
||||
local bit = require'bit'
|
||||
local rshift = bit.rshift
|
||||
local lshift = bit.lshift
|
||||
local bor = bit.bor
|
||||
local band = bit.band
|
||||
local floor = math.floor
|
||||
|
||||
local mime64chars = ffi.new("uint8_t[64]",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
|
||||
local mime64lookup = ffi.new("uint8_t[256]")
|
||||
ffi.fill(mime64lookup, 256, 0xFF)
|
||||
for i=0,63 do
|
||||
mime64lookup[mime64chars[i]]=i
|
||||
end
|
||||
|
||||
local u8arr= ffi.typeof'uint8_t[?]'
|
||||
local u8ptr=ffi.typeof'uint8_t*'
|
||||
|
||||
--- Base64 decode a string or a FFI char *.
|
||||
-- @param str (String or char*) Bytearray to decode.
|
||||
-- @param sz (Number) Length of string to decode, optional if str is a Lua string
|
||||
-- @return (String) Decoded string.
|
||||
function escape.base64_decode(str, sz)
|
||||
if (type(str)=="string") and (sz == nil) then sz=#str end
|
||||
local m64, b1 -- value 0 to 63, partial byte
|
||||
local bin_arr=ffi.new(u8arr, floor(bit.rshift(sz*3,2)))
|
||||
local mptr = ffi.cast(u8ptr,bin_arr) -- position in binary mime64 output array
|
||||
local bptr = ffi.cast(u8ptr,str)
|
||||
local i = 0
|
||||
while true do
|
||||
repeat
|
||||
if i >= sz then goto done end
|
||||
m64 = mime64lookup[bptr[i]]
|
||||
i=i+1
|
||||
until m64 ~= 0xFF -- skip non-mime characters like newlines
|
||||
b1=lshift(m64, 2)
|
||||
repeat
|
||||
if i >= sz then goto done end
|
||||
m64 = mime64lookup[bptr[i]]
|
||||
i=i+1
|
||||
until m64 ~= 0xFF -- skip non-mime characters like newlines
|
||||
mptr[0] = bor(b1,rshift(m64, 4)); mptr=mptr+1
|
||||
b1 = lshift(m64,4)
|
||||
repeat
|
||||
if i >= sz then goto done end
|
||||
m64 = mime64lookup[bptr[i]]
|
||||
i=i+1
|
||||
until m64 ~= 0xFF -- skip non-mime characters like newlines
|
||||
mptr[0] = bor(b1,rshift(m64, 2)); mptr=mptr+1
|
||||
b1 = lshift(m64,6)
|
||||
repeat
|
||||
if i >= sz then goto done end
|
||||
m64 = mime64lookup[bptr[i]]
|
||||
i=i+1
|
||||
until m64 ~= 0xFF -- skip non-mime characters like newlines
|
||||
mptr[0] = bor(b1, m64); mptr=mptr+1
|
||||
end
|
||||
::done::
|
||||
return ffi.string(bin_arr, (mptr-bin_arr))
|
||||
end
|
||||
|
||||
|
||||
local mime64shorts=ffi.new('uint16_t[4096]')
|
||||
for i=0,63 do
|
||||
for j=0,63 do
|
||||
local v
|
||||
if ffi.abi("le") then
|
||||
v=mime64chars[j]*256+mime64chars[i]
|
||||
else
|
||||
v=mime64chars[i]*256+mime64chars[j]
|
||||
end
|
||||
mime64shorts[i*64+j]=v
|
||||
end
|
||||
end
|
||||
|
||||
local u16arr = ffi.typeof"uint16_t[?]"
|
||||
local crlf16 = ffi.new("uint16_t[1]")
|
||||
if ffi.abi("le") then
|
||||
crlf16[0] = (0x0A*256)+0x0D
|
||||
else
|
||||
crlf16[0] = (0x0D*256)+0x0A
|
||||
end
|
||||
local eq=string.byte('=')
|
||||
--- Base64 encode binary data of a string or a FFI char *.
|
||||
-- @param str (String or char*) Bytearray to encode.
|
||||
-- @param sz (Number) Length of string to encode, optional if str is a Lua string
|
||||
-- @return (String) Encoded base64 string.
|
||||
function escape.base64_encode(str, sz)
|
||||
if (type(str)=="string") and (sz == nil) then sz=#str end
|
||||
local outlen = floor(sz*2/3)
|
||||
outlen = outlen + floor(outlen/19)+3
|
||||
local m64arr=ffi.new(u16arr,outlen)
|
||||
local l,p,v=0,0
|
||||
local bptr = ffi.cast(u8ptr,str)
|
||||
local c = 38 -- put a new line after every 76 characters
|
||||
local i,k=0,0
|
||||
::while_3bytes::
|
||||
if i+3>sz then goto break3 end
|
||||
v=bor(lshift(bptr[i],16),lshift(bptr[i+1],8),bptr[i+2])
|
||||
i=i+3
|
||||
::encode_last3::
|
||||
if c==k then
|
||||
m64arr[k]=crlf16[0]
|
||||
k=k+1
|
||||
c=k+38 -- 76 /2 = 38
|
||||
end
|
||||
m64arr[k]=mime64shorts[rshift(v,12)]
|
||||
m64arr[k+1]=mime64shorts[band(v,4095)]
|
||||
k=k+2
|
||||
goto while_3bytes
|
||||
::break3::
|
||||
if l>0 then
|
||||
-- Add trailing equal sign padding
|
||||
if l==1 then
|
||||
-- 1 byte encoded needs two trailing equal signs
|
||||
m64arr[k-1]=bor(lshift(eq,8),eq)
|
||||
else
|
||||
-- 2 bytes encoded needs one trailing equal sign
|
||||
(ffi.cast(u8ptr,m64arr))[lshift(k,1)-1]=eq
|
||||
end
|
||||
else
|
||||
l=sz-i -- get remaining len (1 or 2 bytes)
|
||||
if l>0 then
|
||||
v= lshift(bptr[i],16)
|
||||
if l==2 then v=bor(v,lshift(bptr[i+1],8)) end
|
||||
goto encode_last3
|
||||
end
|
||||
end
|
||||
return ffi.string(m64arr,lshift(k,1))
|
||||
end
|
||||
|
||||
return escape
|
|
@ -0,0 +1 @@
|
|||
Subproject commit e7480da28e507bed62e93ca7b5a1239cfb14d016
|
|
@ -0,0 +1 @@
|
|||
Subproject commit a05da803f659c57e9ce80045e358ada1897fddc0
|
|
@ -1,18 +0,0 @@
|
|||
set(GOODFORM_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/goodform")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D'htonll(x)=((1==htonl(1))?(x):((uint64_t)htonl((x)&0xFFFFFFFF)<<32)|htonl((x)>>32))' -D'ntohll(x)=((1==ntohl(1))?(x):((uint64_t)ntohl((x)&0xFFFFFFFF)<<32)|ntohl((x)>>32))'")
|
||||
|
||||
add_subdirectory("${GOODFORM_ROOT_DIR}")
|
||||
|
||||
set(GOODFORM_INCLUDE_DIR "${GOODFORM_ROOT_DIR}/include")
|
||||
if(NOT EXISTS "${GOODFORM_INCLUDE_DIR}")
|
||||
set(GOODFORM_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
set(GOODFORM_LIBRARY goodform-static)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(goodform
|
||||
REQUIRED_VARS GOODFORM_INCLUDE_DIR GOODFORM_LIBRARY)
|
||||
|
||||
mark_as_advanced(GOODFORM_INCLUDE_DIR GOODFORM_LIBRARY)
|
|
@ -1,24 +0,0 @@
|
|||
print("Yo, " .. CurrentMod.id .. " blocks.lua here")
|
||||
|
||||
local grassBlock = {
|
||||
appearance = {
|
||||
variabilty = {'static'},
|
||||
textures = {
|
||||
grass = {
|
||||
path = 'self:/tex/grass.png',
|
||||
['repeat'] = {
|
||||
xdiv = 8,
|
||||
ydiv = 8
|
||||
}
|
||||
}
|
||||
},
|
||||
look = {
|
||||
type = 'cube',
|
||||
sides = {
|
||||
all = 'grass'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
diggler.registerBlock('grass', grassBlock)
|
|
@ -1 +0,0 @@
|
|||
block.test.name=Test block
|
|
@ -1,44 +0,0 @@
|
|||
local D = require('diggler')
|
||||
|
||||
local TestMod = {
|
||||
uuid = "BWtAgKUjcW+H+CUQcOW3/Q",
|
||||
id = "TestMod",
|
||||
name = "Test Mod",
|
||||
version = 1,
|
||||
versionStr = "1.0.0",
|
||||
description = "A mod to test Lua scripting ability",
|
||||
tags = {"test"},
|
||||
authors = {"ElementW"},
|
||||
license = {
|
||||
name = "GPLv3",
|
||||
descUrl = "https://www.gnu.org/licenses/gpl-3.0.html",
|
||||
fulltextUrl = "https://www.gnu.org/licenses/gpl-3.0.txt"
|
||||
},
|
||||
deps = {},
|
||||
optdeps = {},
|
||||
|
||||
clientside = true,
|
||||
serverside = true,
|
||||
|
||||
interfaces = {
|
||||
provides = {
|
||||
"diggler.isBlockUseless"
|
||||
},
|
||||
uses = {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function TestMod.init()
|
||||
print("Hey i'm " .. CurrentMod.id)
|
||||
dofile(CurrentModPath .. '/blocks.lua')
|
||||
end
|
||||
|
||||
function TestMod.deinit()
|
||||
print("Bye")
|
||||
end
|
||||
|
||||
print(D.mods)
|
||||
|
||||
return TestMod
|
Binary file not shown.
Before Width: | Height: | Size: 678 KiB |
Binary file not shown.
Before Width: | Height: | Size: 708 B |
|
@ -1,8 +1,6 @@
|
|||
#ifndef DIGGLER_IO_STREAM_HPP
|
||||
#define DIGGLER_IO_STREAM_HPP
|
||||
|
||||
#include <goodform/io.hpp>
|
||||
|
||||
#include "../Platform.hpp"
|
||||
|
||||
namespace Diggler {
|
||||
|
@ -54,7 +52,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class InStream : public virtual Stream, public goodform::istream {
|
||||
class InStream : public virtual Stream {
|
||||
public:
|
||||
virtual std::string readString();
|
||||
virtual std::u32string readString32();
|
||||
|
@ -71,15 +69,6 @@ public:
|
|||
virtual double readDouble();
|
||||
virtual void readData(void *data, SizeT len) = 0;
|
||||
virtual void skip(SizeT len);
|
||||
|
||||
// goodform::msgpack compatibility
|
||||
bool good() {
|
||||
return not eos();
|
||||
}
|
||||
goodform::istream& read(char *data, size_t size) {
|
||||
readData(data, static_cast<SizeT>(size));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class InSeekableStream : public virtual InStream, public virtual SeekableStream {
|
||||
|
@ -89,7 +78,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class OutStream : public virtual Stream, public goodform::ostream {
|
||||
class OutStream : public virtual Stream {
|
||||
public:
|
||||
virtual void writeString(const std::string &str);
|
||||
virtual void writeString32(const std::u32string &str);
|
||||
|
@ -105,15 +94,6 @@ public:
|
|||
virtual void writeFloat(float f);
|
||||
virtual void writeDouble(double d);
|
||||
virtual void writeData(const void *data, SizeT len) = 0;
|
||||
|
||||
// goodform::msgpack compatibility
|
||||
bool good() {
|
||||
return true;
|
||||
}
|
||||
goodform::ostream& write(const char *data, size_t size) {
|
||||
writeData(data, static_cast<SizeT>(size));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class OutSeekableStream : public virtual OutStream, public virtual SeekableStream {
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include <goodform/variant.hpp>
|
||||
|
||||
#include "../Platform.hpp"
|
||||
#include "../platform/PreprocUtils.hpp"
|
||||
#include "../crypto/DiffieHellman.hpp"
|
||||
|
@ -115,7 +113,6 @@ public:
|
|||
|
||||
glm::vec3 readVec3();
|
||||
glm::ivec3 readIVec3();
|
||||
void readMsgpack(goodform::variant&);
|
||||
|
||||
Channels getChannel() const;
|
||||
};
|
||||
|
@ -156,8 +153,6 @@ public:
|
|||
writeI32(vec.y);
|
||||
writeI32(vec.z);
|
||||
}
|
||||
|
||||
void writeMsgpack(const goodform::variant&);
|
||||
};
|
||||
|
||||
class Exception : public std::exception {
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "MsgType.hpp"
|
||||
|
||||
#include <goodform/variant.hpp>
|
||||
|
||||
#include "../../content/Content.hpp"
|
||||
#include "../../World.hpp"
|
||||
|
||||
|
@ -28,7 +26,7 @@ struct BlockUpdateNotify : public MsgType {
|
|||
glm::ivec3 pos;
|
||||
BlockId id;
|
||||
BlockData data;
|
||||
goodform::variant extdata;
|
||||
//goodform::variant extdata;
|
||||
LightData light;
|
||||
enum Cause : uint8 {
|
||||
Unspecified = 0,
|
||||
|
@ -47,7 +45,7 @@ struct BlockUpdatePlace : public MsgType {
|
|||
glm::ivec3 pos;
|
||||
BlockId id;
|
||||
BlockData data;
|
||||
goodform::variant extdata;
|
||||
//goodform::variant extdata;
|
||||
|
||||
void writeToMsg(OutMessage&) const override;
|
||||
void readFromMsg(InMessage&) override;
|
||||
|
|
Loading…
Reference in New Issue