Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile fixes for POSIX/MSYS2 Unix-like systems lua5.4 SDL1/2 GL=1/2/3 #314

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
*.sh
*.o
projectx*
libs*
unix*
mingw*
data
configs
logs
pilots
savegame
*.dll
gmon.out
configs/*.txt
logs/*.txt
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "data"]
path = data
url = https://github.com/ForsakenX/forsaken-data
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ CC=gcc
ifeq ($(M32),1)
FLAGS+= -m32
endif
FLAGS+= -std=gnu99 -pipe -fcommon
CFLAGS=$(FLAGS) -Wall -Wextra
FLAGS+= -std=gnu2x -pipe -fcommon
CFLAGS=$(FLAGS) -Wall -Wextra -Wno-unused-result -Wno-unused-variable -Wno-unused
LDFLAGS=$(FLAGS)

# right now non debug build would probably crash anyway
Expand Down Expand Up @@ -63,8 +63,8 @@ endif
# ProjectX Specific
#

# some systems use lua5.1
LUA=$(shell pkg-config lua && echo lua || echo lua5.1)
# some systems use lua5.4
LUA=lua5.4
MACOSX=$(shell uname -a | grep -qi darwin && echo 1 || echo 0)

# which version of sdl do you want to ask pkgconfig for ?
Expand All @@ -76,13 +76,13 @@ else
endif

# which version of GL do you want to use ?
GL=1

$(if $(shell test "$(GL)" -ge 3 -a "$(SDL)" -lt 2 && echo fail), \
$(error "GL >= 3 only supported with SDL >= 2"))
GL=3

# library headers
CFLAGS+= `pkg-config --cflags $(SDL_) $(LUA) $(LUA)-socket libenet libpng zlib openal`
CFLAGS+= `pkg-config --cflags $(SDL_)`
CFLAGS+= `pkg-config --cflags $(LUA)`
CFLAGS+= `pkg-config --cflags libenet`
CFLAGS+= `pkg-config --cflags libpng zlib openal`
ifeq ($(MACOSX),1)
CFLAGS += -DMACOSX
endif
Expand All @@ -95,7 +95,9 @@ ifeq ($(STATIC),1)
LIB+= -Wl,-dn
PKG_CFG_OPTS= --static
endif
LIB+= `pkg-config $(PKG_CFG_OPTS) --libs $(LUA) $(LUA)-socket libenet libpng zlib openal` -lm
LIBDIR=`pkg-config --variable=libdir $(LUA)`
LIB+= `pkg-config $(PKG_CFG_OPTS) --libs $(LUA) libenet libpng zlib openal`
LIB+= -L$(LIBDIR)/lua/5.4/ $(LIBDIR)/lua/5.4/mime/core.so $(LIBDIR)/lua/5.4/socket/core.so -lm
ifeq ($(STATIC),1)
LIB+= -Wl,-dy
endif
Expand All @@ -122,7 +124,7 @@ ifneq ($(MINGW),1)
endif

# ProjectX-specific includes
CFLAGS += -I.
CFLAGS += -Isrc

# ProjectX-specific macros
ifeq ($(DXMOUSE),1)
Expand All @@ -148,9 +150,9 @@ ifeq ($(INPUT_DISABLED),1)
endif


INC=$(wildcard *.h)
SRC=$(wildcard *.c)
OBJ=$(patsubst %.c,%.o,$(SRC))
INC=$(wildcard src/*.h)
SRC=$(wildcard src/*.c)
OBJ=$(patsubst src/%.c,src/%.o,$(SRC))

# allows user to override settings
ADD_FLAGS=
Expand Down
26 changes: 0 additions & 26 deletions ProjectX-vs10.README.txt

This file was deleted.

30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,33 @@
This repo holds the community port of Forsaken!

Check out the [Wiki](https://github.com/ForsakenX/forsaken/wiki) for more information.

## Dependencies

- [OpenGL](https://opengl.org)
- [OpenAL](https://www.openal.org)
- [SDL-1.2](https://github.com/libsdl-org/SDL-1.2)
- [SDL](https://github.com/libsdl-org/SDL)
- [lua5.4](https://www.lua.org/)
- [luasocket](https://github.com/lunarmodules/luasocket)
- [enet](https://github.com/lsalzman/enet/)

## Build

POSIX/MSYS2:
```sh
cd forsaken
make SDL=1 GL=3
```

## Run

Edit `forsaken.sh` and replace `/usr/lib64` with your `$PREFIX/$libdir/lua/5.4`

```sh
cd forsaken
./forsaken.sh
```

## Known bugs
- SDL2 controls not working
Empty file added configs/.keep
Empty file.
1 change: 1 addition & 0 deletions data
Submodule data added at 52ed2e
2 changes: 2 additions & 0 deletions forsaken.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
LD_PRELOAD=/usr/lib64/lua/5.4/mime/core.so:/usr/lib64/lua/5.4/socket/core.so ./projectx
Empty file added logs/.keep
Empty file.
Empty file modified net_test/chat/client.c
100755 → 100644
Empty file.
Empty file modified net_test/chat/test.sh
100755 → 100644
Empty file.
Empty file modified net_test/smasher/smasher.c
100755 → 100644
Empty file.
Empty file added pilots/.keep
Empty file.
4 changes: 2 additions & 2 deletions scripts/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ function config_path(name)
end

function config_load(name)
local cfg = {}
local cfg = setmetatable( { }, { __index = _G } )
local path = config_path(name)
touch_file(path)
setfenv(load_file(path), cfg)()
load_file(path, "t", cfg)()
for key, value in pairs(cfg) do
config[key] = value
end
Expand Down
7 changes: 6 additions & 1 deletion scripts/games.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ local assert = assert
local pcall = pcall
local loadstring = loadstring

module("games")
local select = select

local _M = {}
if module then -- heuristic for exporting a global package table
games = _M -- luacheck: ignore
end

local url = "http://fly.thruhere.net/status/games.json"

Expand Down
1 change: 1 addition & 0 deletions scripts/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ function load_file(name)
local f,m = loadfile(name)
return assert(loadfile(name))
end

56 changes: 41 additions & 15 deletions scripts/ltn12.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@
-- LTN12 - Filters, sources, sinks and pumps.
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: ltn12.lua,v 1.31 2006/04/03 04:45:42 diego Exp $
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
-- Declare module
-----------------------------------------------------------------------------
local string = require("string")
local table = require("table")
local unpack = unpack or table.unpack
local base = _G
module("ltn12")
local select = select

filter = {}
source = {}
sink = {}
pump = {}
local _M = {}
if module then -- heuristic for exporting a global package table
ltn12 = _M -- luacheck: ignore
end
local filter,source,sink,pump = {},{},{},{}

_M.filter = filter
_M.source = source
_M.sink = sink
_M.pump = pump

-- 2048 seems to be better in windows...
BLOCKSIZE = 2048
_VERSION = "LTN12 1.0.1"
_M.BLOCKSIZE = 2048
_M._VERSION = "LTN12 1.0.3"

-----------------------------------------------------------------------------
-- Filter stuff
Expand All @@ -38,7 +44,8 @@ end
-- chains a bunch of filters together
-- (thanks to Wim Couwenberg)
function filter.chain(...)
local n = table.getn(arg)
local arg = {...}
local n = select('#',...)
local top, index = 1, 1
local retry = ""
return function(chunk)
Expand Down Expand Up @@ -89,7 +96,7 @@ end
function source.file(handle, io_err)
if handle then
return function()
local chunk = handle:read(BLOCKSIZE)
local chunk = handle:read(_M.BLOCKSIZE)
if not chunk then handle:close() end
return chunk
end
Expand All @@ -112,14 +119,24 @@ function source.string(s)
if s then
local i = 1
return function()
local chunk = string.sub(s, i, i+BLOCKSIZE-1)
i = i + BLOCKSIZE
local chunk = string.sub(s, i, i+_M.BLOCKSIZE-1)
i = i + _M.BLOCKSIZE
if chunk ~= "" then return chunk
else return nil end
end
else return source.empty() end
end

-- creates table source
function source.table(t)
base.assert('table' == type(t))
local i = 0
return function()
i = i + 1
return t[i]
end
end

-- creates rewindable source
function source.rewind(src)
base.assert(src)
Expand All @@ -135,7 +152,9 @@ function source.rewind(src)
end
end

function source.chain(src, f)
-- chains a source with one or several filter(s)
function source.chain(src, f, ...)
if ... then f=filter.chain(f, ...) end
base.assert(src and f)
local last_in, last_out = "", ""
local state = "feeding"
Expand Down Expand Up @@ -186,6 +205,7 @@ end
-- other, as if they were concatenated
-- (thanks to Wim Couwenberg)
function source.cat(...)
local arg = {...}
local src = table.remove(arg, 1)
return function()
while src do
Expand Down Expand Up @@ -249,8 +269,13 @@ function sink.error(err)
end
end

-- chains a sink with a filter
function sink.chain(f, snk)
-- chains a sink with one or several filter(s)
function sink.chain(f, snk, ...)
if ... then
local args = { f, snk, ... }
snk = table.remove(args, #args)
f = filter.chain(unpack(args))
end
base.assert(f and snk)
return function(chunk, err)
if chunk ~= "" then
Expand Down Expand Up @@ -290,3 +315,4 @@ function pump.all(src, snk, step)
end
end

return _M
Loading
Loading