Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
0.4.3
Browse files Browse the repository at this point in the history
- Fixed some Makefile issues
- Makefile improvements
- Fixed some windowing bugs
- Added server event timers
- Server now displays more info when starting/stopping
- Renderer stops before server
- Changed config file from ~/.cavecube/cavecube.cfg to ~/.cavecube/config.cfg
- Changed local folder from %AppData%\cavecube\ to %AppData%\.cavecube\ on Windows
- More folders are created in the local folder
  • Loading branch information
PQCraft committed Oct 8, 2022
1 parent ee33518 commit e17399e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 49 deletions.
11 changes: 10 additions & 1 deletion src/common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ bool rm(char* path) {
}

bool md(char* path) {
switch (isFile(path)) {
case 0:;
return true;
break;
case 1:;
fprintf(stderr, "'%s' is not a directory\n", path);
return false;
break;
}
char tmp[MAX_PATH];
char *ptr = NULL;
size_t len;
Expand All @@ -192,7 +201,7 @@ bool md(char* path) {
for (ptr = tmp + 1; *ptr; ++ptr) {
if (*ptr == '/' || *ptr == PATHSEP) {
*ptr = 0;
if (mkdir(tmp)) return false;
mkdir(tmp);
*ptr = PATHSEP;
}
}
Expand Down
90 changes: 42 additions & 48 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,56 +119,9 @@ int main(int _argc, char** _argv) {
#endif
argc = _argc;
argv = _argv;
maindir = strdup(pathfilename(execpath()));
startdir = realpath(".", NULL);
MAIN_STRPATH(startdir);
#ifndef SERVER
{
#ifndef _WIN32
char* tmpdir = getenv("HOME");
char* tmpdn = ".cavecube";
#else
char* tmpdir = getenv("AppData");
char* tmpdn = "cavecube";
#endif
if (!altchdir(tmpdir)) return 1;
switch (isFile(tmpdn)) {
case -1:;
mkdir(tmpdn);
break;
case 1:;
fprintf(stderr, "'%s' is not a directory\n", tmpdn);
return 1;
break;
}
if (!altchdir(tmpdn)) return 1;
localdir = realpath(".", NULL);
MAIN_STRPATH(localdir);
}
strcpy(configpath, localdir);
strcat(configpath, "config.cfg");
bool chconfig = false;
#else
strcpy(configpath, "ccserver.cfg");
#endif
#if DBGLVL(1)
printf("Main directory: {%s}\n", maindir);
printf("Start directory: {%s}\n", startdir);
#ifndef SERVER
printf("Local directory: {%s}\n", localdir);
#endif
#endif
if (!altchdir(maindir)) return 1;
signal(SIGINT, sigh);
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
#else
signal(SIGSEGV, sigsegvh);
#endif
int cores = getCoreCt();
if (cores < 1) cores = 1;
#ifndef SERVER
int gametype = -1;
bool chconfig = false;
bool servopt = false;
struct {
char* world;
Expand Down Expand Up @@ -303,6 +256,47 @@ int main(int _argc, char** _argv) {
return 1;
}
}
maindir = strdup(pathfilename(execpath()));
startdir = realpath(".", NULL);
MAIN_STRPATH(startdir);
#ifndef SERVER
{
#ifndef _WIN32
char* tmpdir = getenv("HOME");
#else
char* tmpdir = getenv("AppData");
#endif
char tmpdn[MAX_PATH] = "";
strcpy(tmpdn, tmpdir);
strcat(tmpdn, "/.cavecube");
if (!md(tmpdn)) return 1;
if (!altchdir(tmpdn)) return 1;
if (!md("worlds")) return 1;
if (!md("resources")) return 1;
localdir = realpath(".", NULL);
MAIN_STRPATH(localdir);
}
strcpy(configpath, localdir);
strcat(configpath, "config.cfg");
#else
strcpy(configpath, "ccserver.cfg");
#endif
#if DBGLVL(1)
printf("Main directory: {%s}\n", maindir);
printf("Start directory: {%s}\n", startdir);
#ifndef SERVER
printf("Local directory: {%s}\n", localdir);
#endif
#endif
if (!altchdir(maindir)) return 1;
signal(SIGINT, sigh);
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
#else
signal(SIGSEGV, sigsegvh);
#endif
int cores = getCoreCt();
if (cores < 1) cores = 1;
#if DBGLVL(1)
printf("Config path: {%s}\n", configpath);
#endif
Expand Down
1 change: 1 addition & 0 deletions src/server/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define PRIsock PRIu64
#define SOCKINVAL(s) ((s) == INVALID_SOCKET)
#define SOCKERR(x) ((x) == SOCKET_ERROR)
#define in_addr_t uint32_t
static WSADATA wsadata;
static WORD wsaver = MAKEWORD(2, 2);
static bool wsainit = false;
Expand Down

0 comments on commit e17399e

Please sign in to comment.