Merge branch 'master' of github.com:Bithack/principia

This commit is contained in:
Emil Romanus 2022-08-10 12:42:29 +02:00
commit 81b7d86815
22 changed files with 1157 additions and 1008 deletions

View file

@ -62,29 +62,31 @@ $ ./go
Principia will launch if everything was successful. Note that the compilation might take up to 10 minutes depending on your system.
## Building on Linux (Debian)
## Building on Linux
Install dependencies:
Install dependencies (example is for Debian-based packages):
$ sudo apt-get install automake libgtk2.0-dev libgl-dev libxss-dev libxxf86vm-dev libasound2-dev libudev-dev valgrind
$ sudo apt-get install automake libgtk2.0-dev libgl-dev libxss-dev libxxf86vm-dev libasound2-dev libudev-dev valgrind
Navigate to the build-linux directory and start the building process:
$ cd build-linux;
$ cd build-linux;
$ ./autogen.sh
$ ./configure
$ ./go
$ ./autogen.sh
If everything goes well, Principia will start by default unless `--silent` is passed to the `go` script.
$ ./configure
### Packaging for Linux
When building Principia for packaging, you would want to use the following command to replace the above. It will clean the source tree, build a release version and not automatically run Principia.
$ ./go
./go --clean --release --silent
If everything goes well, Principia will start but then freeze at the loading screen due some uninitialize directories. Terminate Principia by replying 'y' in the gdb prompt in the terminal, then in the same terminal, go up a directory and launch it from the parent directory instead:
$ cd ..
$ build-linux/apparatus2
Right now Principia needs to be installed with its executable next to the data directories. Putting all of that in `/opt/principia/` and symlinking `/usr/bin/principia` => `/opt/principia/principia` should do for now.
(this bug will be fixed in short)
The `build-linux` directory contains desktop files and an usable icon, which can be installed into `/usr/share/applications/` and `/usr/share/pixmaps` respectively. `principia-url-handler.desktop` is for handling principia:// protocol links and is confirmed to work on at least Firefox and Chromium.
## Building for Android (on Linux)

View file

@ -1 +0,0 @@
../data-pc

1
build-linux/data-pc Symbolic link
View file

@ -0,0 +1 @@
../data-pc/

View file

@ -1 +0,0 @@
../data-shared

1
build-linux/data-shared Symbolic link
View file

@ -0,0 +1 @@
../data-shared/

View file

@ -148,10 +148,8 @@ if [ "$run" -eq "1" ]; then
elif [ "$debug" -eq "4" ]; then # --leak
valgrind --suppressions=./valgrind.supp --tool=memcheck --leak-check=full --show-possibly-lost=yes --track-origins=yes ./apparatus2
elif [ "$debug" -eq "1" ]; then
cd ../
gdb -ex run -ex quit build-linux/apparatus2
gdb -ex run -ex quit ./apparatus2
else
cd ../
build-linux/apparatus2
./apparatus2
fi
fi

View file

@ -1,5 +0,0 @@
#!/bin/sh
gconftool-2 -t string -s /desktop/gnome/url-handlers/principia/command "`pwd`/principia %s"
gconftool-2 -s /desktop/gnome/url-handlers/principia/needs_terminal false -t bool
gconftool-2 -t bool -s /desktop/gnome/url-handlers/principia/enabled true

0
build-screenshot-linux/autogen.sh Normal file → Executable file
View file

View file

@ -1 +0,0 @@
../data-pc

View file

@ -0,0 +1 @@
../data-pc/

View file

@ -1 +0,0 @@
../data-shared

View file

@ -0,0 +1 @@
../data-shared/

0
build-screenshot-linux/go Normal file → Executable file
View file

View file

@ -0,0 +1,3 @@
Additional dependencies for building the installer:
$ pacman -S mingw-w64-x86_64-nsis

View file

@ -0,0 +1,8 @@
make clean
./go --release
rm release/*
mkdir release
cp principia.exe release/
./mingw-bundledlls release/principia.exe --copy
makensis principia_install
mv principia-setup.exe release/

View file

@ -1,7 +0,0 @@
rm sha1_test
touch sha1_test
rm principia-setup.exe
touch ../src/tms/backends/windows/main.cc
./go --release
makensis principia_install
openssl sha1 principia.exe p-$UNIQUE.exe >> sha1_test

View file

@ -0,0 +1,150 @@
#!/usr/bin/env python3
# The MIT License (MIT)
#
# Copyright (c) 2015 Martin Preisler
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import subprocess
import os.path
import argparse
import shutil
# The mingw path matches where Fedora 21 installs mingw32; this is the default
# fallback if no other search path is specified in $MINGW_BUNDLEDLLS_SEARCH_PATH
DEFAULT_PATH_PREFIXES = [
"", "/usr/bin", "/usr/i686-w64-mingw32/sys-root/mingw/bin", "/mingw64/bin",
"/usr/i686-w64-mingw32/sys-root/mingw/lib",
"C:\\msys64\\mingw64\\bin"
]
env_path_prefixes = os.environ.get('MINGW_BUNDLEDLLS_SEARCH_PATH', None)
if env_path_prefixes is not None:
path_prefixes = [path for path in env_path_prefixes.split(os.pathsep) if path]
else:
path_prefixes = DEFAULT_PATH_PREFIXES
# This blacklist may need extending
blacklist = [
"advapi32.dll", "kernel32.dll", "msvcrt.dll", "ole32.dll", "user32.dll",
"ws2_32.dll", "comdlg32.dll", "gdi32.dll", "imm32.dll", "oleaut32.dll",
"shell32.dll", "winmm.dll", "winspool.drv", "wldap32.dll",
"ntdll.dll", "d3d9.dll", "mpr.dll", "crypt32.dll", "dnsapi.dll",
"shlwapi.dll", "version.dll", "iphlpapi.dll", "msimg32.dll", "setupapi.dll",
"opengl32.dll", "dwmapi.dll", "uxtheme.dll", "secur32.dll", "gdiplus.dll",
"usp10.dll", "comctl32.dll", "wsock32.dll", "netapi32.dll", "userenv.dll",
"avicap32.dll", "avrt.dll", "psapi.dll", "mswsock.dll", "glu32.dll",
"bcrypt.dll", "rpcrt4.dll", "hid.dll",
# directx 3d 11
"d3d11.dll", "dxgi.dll"
]
def find_full_path(filename, path_prefixes):
for path_prefix in path_prefixes:
path = os.path.join(path_prefix, filename)
path_low = os.path.join(path_prefix, filename.lower())
if os.path.exists(path):
return path
if os.path.exists(path_low):
return path_low
else:
raise RuntimeError(
"Can't find " + filename + ". If it is an inbuilt Windows DLL, "
"please add it to the blacklist variable in the script and send "
"a pull request!"
)
def gather_deps(path, path_prefixes, seen):
ret = [path]
output = subprocess.check_output(["objdump", "-p", path]).decode(
"utf-8", "replace").split("\n")
for line in output:
if not line.startswith("\tDLL Name: "):
continue
dep = line.split("DLL Name: ")[1].strip()
ldep = dep.lower()
if ldep in blacklist:
continue
if ldep in seen:
continue
dep_path = find_full_path(dep, path_prefixes)
seen.add(ldep)
subdeps = gather_deps(dep_path, path_prefixes, seen)
ret.extend(subdeps)
return ret
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"exe_file",
help="EXE or DLL file that you need to bundle dependencies for"
)
parser.add_argument(
"--copy",
action="store_true",
help="In addition to printing out the dependencies, also copy them next to the exe_file"
)
parser.add_argument(
"--upx",
action="store_true",
help="Only valid if --copy is provided. Run UPX on all the DLLs and EXE."
)
args = parser.parse_args()
if args.upx and not args.copy:
raise RuntimeError("Can't run UPX if --copy hasn't been provided.")
all_deps = set(gather_deps(args.exe_file, path_prefixes, set()))
all_deps.remove(args.exe_file)
print("\n".join(all_deps))
if args.copy:
print("Copying enabled, will now copy all dependencies next to the exe_file.\n")
parent_dir = os.path.dirname(os.path.abspath(args.exe_file))
for dep in all_deps:
target = os.path.join(parent_dir, os.path.basename(dep))
try:
print("Copying '%s' to '%s'" % (dep, target))
shutil.copy(dep, parent_dir)
except shutil.SameFileError:
print("Dependency '%s' was already in target directory, "
"skipping..." % (dep))
if args.upx:
subprocess.call(["upx", target])
if __name__ == "__main__":
main()

View file

@ -2,10 +2,10 @@
!define MUI_ICON "icon.ico"
!define /ifndef VER_MAJOR 1
!define /ifndef VER_MINOR 4
!define /ifndef VER_MINOR 6
!define /ifndef VER_BUILD 0
!define /ifndef VER_REVISION 1404
!define /ifndef VER_REVISION 1600
!define /ifndef VERSION 'beta-windows'
@ -23,7 +23,7 @@ RequestExecutionLevel admin
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_LICENSE "..\COPYING"
!insertmacro MUI_PAGE_LICENSE "..\LICENSE.md"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
@ -47,8 +47,8 @@ Section "Core Files (required)" SecCore
SetOutPath "$INSTDIR"
File principia.exe
File *.dll
File "release\principia.exe"
File "release\*.dll"
SetOutPath "$INSTDIR\data-pc"
File /r /x *.sw* "..\data-pc\bg"

View file

@ -25,7 +25,7 @@ Oil used for faster running speed.
Oil used for jumping higher.
-----
7:Armour oil
Oil that adds armor.
Oil that adds armor.
-----
8:Zapper
Useful tool used for mining and various other things.
@ -37,7 +37,7 @@ Can be used on:
* Ores to gather minerals
-----
9:Miner upgrade
Currently unused (BETA)
Item with the model of an Oil item, but completely blue. Can be absorbed by the robot by putting it close with the builder, but it does nothing.
-----
10:Rocket Launcher
Strong rocket launcher. Be careful with this bad boy.
@ -107,7 +107,7 @@ Rocket used by the rocket launcher.
Bring this item to a repair station to equip it.
-----
27:Mega Buster
Chargeable weapon for stronger bullets.
Chargeable weapon for stronger bullets.
-----
28:Mega Buster Solar Bullet
Solar bullet used by the mega buster.
@ -220,3 +220,27 @@ A tool that uses vacuum to suck in, compress and store an item.
This useful tool allows you to move several items at once to e.g a repair station.
-----
52:King's crown
Pretty snazzy crown.
Bring this item to a repair station to equip it.
-----
53:Dummy head
Dummy head, nothing much else.
Bring this item to a repair station to equip it.
-----
54:Jester hat
Ooh, Jester hat!
Bring this item to a repair station to equip it.
-----
55:Training sword
A melee sword made out of wood. Not very strong, but it does the job.
-----
57:War hammer
Big hammer! Great for bonking robots with.
-----
71:Pickaxe
It's a pickaxe... You can't mine with. Hit someone in the head with it.
-----

File diff suppressed because it is too large Load diff

View file

@ -99,6 +99,7 @@ static volatile int loading_counter = 0;
static int fl_fetch_time = 0;
static uint32_t _play_id;
static char _community_host[512] = {0}; /* Temporary input host from principia:// url, not to be confused with P.community_host */
static uint32_t _play_type;
static bool _play_lock;
static volatile bool _play_downloading = false;
@ -577,6 +578,32 @@ tproject_set_args(int argc, char **argv)
s+=12;
/* extract the host */
_community_host[0] = '\0';
for (n=0; n<511; n++) {
if (*(s+n) == '/' || *(s+n) == '\0') {
break;
}
}
strncpy(_community_host, s, n);
s += n;
if (*s == '\0') {
break;
}
s ++;
/* backwards compatibility, if the "host" equals any of the reserved words below we default to the
* currently signed-in community host instead and backset the pointer */
if (strcmp(_community_host, "play") == 0 ||
strcmp(_community_host, "sandbox") == 0 ||
strcmp(_community_host, "edit") == 0) {
s -= strlen(_community_host) + 1;
strcpy(_community_host, P.community_host);
}
if (strncmp(s, "play/", 5) == 0) {
s+=5;
@ -643,7 +670,7 @@ tproject_set_args(int argc, char **argv)
void
tproject_window_size_changed(void)
{
if (!settings["window_maximized"]->v.b) {
if (!settings["window_maximized"]->v.b && settings["autosave_screensize"]->v.b) {
settings["window_width"]->v.i = _tms.window_width;
settings["window_height"]->v.i = _tms.window_height;
}
@ -2109,10 +2136,11 @@ _download_level(void *p)
}
}
const char *host = strlen(_community_host) > 0 ? _community_host : P.community_host;
char url[1024];
snprintf(url, 1023, "https://%s/" COMMUNITY_SECRET "/%s.php?i=%d&h=%u",
P.community_host,
host,
_play_download_for_pkg ? "xxxxx" : (type == LEVEL_DB ? "x":(derive == true ? "xxx" : "xxxxxx")),
_play_id, r);
//tms_infof("url: %s", url);

View file

@ -70,6 +70,9 @@ _settings::init()
this->add("window_height", S_INT32, _tms.window_height);
this->add("window_maximized", S_BOOL, 0);
// False for now to allow for resetting the screensize if resizing somehow breaks it.
this->add("autosave_screensize",S_BOOL, false);
#if defined(TMS_BACKEND_IOS)
this->add("shadow_quality", S_UINT8, is_shitty ? 0 : 1);
#else

View file

@ -3534,6 +3534,11 @@ struct table_setting_row settings_interface_rows[] = {
"A restart is required for this change to take effect",
"uiscale",
setting_row_type::create_hscale(0.25, 2.0, 0.05),
},{
"Autosave screen size",
"Save the screen size when resizing the window.",
"autosave_screensize",
setting_row_type::create_checkbox()
}, {
"Display object ID",
"Display ID of object on selection (bottom-left corner).",

View file

@ -6,6 +6,8 @@
#include <sys/types.h>
#include <pwd.h>
#include <cxxabi.h>
#include <unistd.h>
#include <libgen.h>
#include <tms/core/project.h>
#include <tms/core/event.h>
@ -46,8 +48,8 @@ int _pipe_listener(void *p)
ssize_t sz;
while (1) {
tms_infof("attempting to open principia.run O_RDONLY");
while ((pipe_h = open("principia.run", O_RDONLY)) == -1) {
tms_infof("attempting to open /tmp/principia.run O_RDONLY");
while ((pipe_h = open("/tmp/principia.run", O_RDONLY)) == -1) {
if (errno != EINTR)
return 1;
}
@ -57,7 +59,7 @@ int _pipe_listener(void *p)
if (sz > 0) {
buf[sz] = '\0';
_args[1] = buf;
_args[1] = buf;
tproject_set_args(2, _args);
}
}
@ -78,7 +80,7 @@ main(int argc, char **argv)
SDL_Event ev;
int done = 0;
int status = mkfifo("principia.run", S_IWUSR | S_IRUSR);
int status = mkfifo("/tmp/principia.run", S_IWUSR | S_IRUSR);
int skip_pipe = 0;
if (status == 0) {
@ -89,9 +91,9 @@ main(int argc, char **argv)
skip_pipe = 1;
}
}
if (!skip_pipe) {
if ((pipe_h = open("principia.run", O_WRONLY | O_NONBLOCK)) == -1) {
if ((pipe_h = open("/tmp/principia.run", O_WRONLY | O_NONBLOCK)) == -1) {
if (errno != ENXIO) {
skip_pipe = 1;
tms_infof("error: %s", strerror(errno));
@ -116,6 +118,12 @@ main(int argc, char **argv)
SDL_CreateThread(_pipe_listener, "_pipe_listener", 0);
}
char buf[512];
readlink("/proc/self/exe", buf, 511);
dirname(buf);
tms_infof("chdirring to %s", buf);
chdir(buf);
char path[512];
const char *storage = tbackend_get_storage_path();
static const char *dirs[] = {
@ -200,7 +208,6 @@ main(int argc, char **argv)
switch (ev.window.event) {
case SDL_WINDOWEVENT_RESIZED:
{
#ifdef DEBUG
tms_infof("Window %d resized to %dx%d",
ev.window.windowID, ev.window.data1,
ev.window.data2);
@ -218,7 +225,6 @@ main(int argc, char **argv)
SDL_SetWindowSize(_window, _tms.window_width, _tms.window_height);
tproject_window_size_changed();
#endif
}
break;
}
@ -529,8 +535,15 @@ tbackend_init_surface()
_tms.yppcm = 107.f/2.54f * 1.5f;
#endif
uint32_t flags = 0;
flags |= SDL_WINDOW_OPENGL;
flags |= SDL_WINDOW_SHOWN;
flags |= SDL_WINDOW_RESIZABLE;
tms_progressf("Creating window... ");
_window = SDL_CreateWindow("Principia", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, _tms.window_width, _tms.window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
_window = SDL_CreateWindow("Principia", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, _tms.window_width, _tms.window_height, flags);
if (_window == NULL) {
tms_progressf("ERROR: %s\n", SDL_GetError());
exit(1);

View file

@ -1 +0,0 @@
../

View file

@ -0,0 +1 @@
../

View file

@ -307,7 +307,6 @@ WinMain(HINSTANCE hi, HINSTANCE hp, LPSTR cl, int cs)
break;
case SDL_WINDOWEVENT_RESIZED:
{
#ifdef DEBUG
tms_infof("Window %d resized to %dx%d",
ev.window.windowID, ev.window.data1,
ev.window.data2);
@ -323,7 +322,6 @@ WinMain(HINSTANCE hi, HINSTANCE hp, LPSTR cl, int cs)
SDL_SetWindowSize(_window, _tms.window_width, _tms.window_height);
tproject_window_size_changed();
#endif
}
break;
case SDL_WINDOWEVENT_MINIMIZED:
@ -523,9 +521,8 @@ tbackend_init_surface()
flags |= SDL_WINDOW_OPENGL;
flags |= SDL_WINDOW_SHOWN;
#ifdef DEBUG
flags |= SDL_WINDOW_RESIZABLE;
#endif
#ifdef RECORDING
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
#endif