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

Commit

Permalink
0.6.0
Browse files Browse the repository at this point in the history
- Redid logo
- Decrustified some chunkdata stuff
- Added view distance resizing
- Added a lazy meshing option
- Optimized chunk requests
- Added natural lighting
- Made the random number algorithm slightly more random
- Changed lighting from 12-bit RGB (R4G4B4) to 15-bit RGB (R5G5B5)
- Changed bedrock texture
- Increased world height to 512
- Added cave culling
- Improve config loading
  • Loading branch information
PQCraft committed Feb 12, 2023
1 parent 3cf2f17 commit 452ca34
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 28 deletions.
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
- Next version: 0.6.0

### NEED TO DO:
- Decrustify doGame
- Implement server chunk cache/pool
- Add back block placement
- Implement world saves in `src/server/saves.(c|h)`
- Flesh out UI
- More UI elements (buttons, text boxes, etc)
Expand Down Expand Up @@ -38,7 +40,7 @@
- Make updateChunks() use a message list

### IN-PROGRESS:
- Translate blocks into a standard uin64_t when transferring over the network (bitfields are unreliable)
- Translate blocks into a standard uint64_t when transferring over the network (bitfields are unreliable)
- Redoing worldgen
- Add physics in `src/physics/`
- Use ticks https://gafferongames.com/post/fix_your_timestep/ and add interpolation
Expand All @@ -57,3 +59,4 @@
- Changed bedrock texture
- Increased world height to 512
- Added cave culling
- Improve config loading
107 changes: 107 additions & 0 deletions extras/docs/default config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[Renderer]
compositing = true
resolution = 1024x768
fullScreenRes =
vSync = true
fullScreen = false
FOV = 85
nearPlane = 0.05
farPlane = 2500
lazyMesher = false

[Game]
viewDist = 8
loopDelay = 1000

[Player]
name = Player
skin =

[Input]
xSen = 1
ySen = 1
rawMouse = true

[GLFW Keybinds]
move.forward = k,b,87;\0,\0,0
move.backward = k,b,83;\0,\0,0
move.left = k,b,65;\0,\0,0
move.right = k,b,68;\0,\0,0
move.lookUp = m,m,1;\0,\0,0
move.lookDown = \0,\0,0;\0,\0,0
move.lookLeft = \0,\0,0;\0,\0,0
move.lookRight = m,m,0;\0,\0,0
multi.place = m,b,0;\0,\0,0
multi.destroy = m,b,1;\0,\0,0
multi.pick = m,b,2;\0,\0,0
multi.zoom = k,b,90;\0,\0,0
multi.jump = k,b,32;\0,\0,0
multi.crouch = k,b,340;k,b,344
multi.run = k,b,341;k,b,345
multi.playerlist = k,b,258;\0,\0,0
multi.debug = k,b,293;\0,\0,0
single.escape = k,b,256;\0,\0,0
single.inventory = k,b,73;\0,\0,0
single.invSlot0 = k,b,49;\0,\0,0
single.invSlot1 = k,b,50;\0,\0,0
single.invSlot2 = k,b,51;\0,\0,0
single.invSlot3 = k,b,52;\0,\0,0
single.invSlot4 = k,b,53;\0,\0,0
single.invSlot5 = k,b,54;\0,\0,0
single.invSlot6 = k,b,55;\0,\0,0
single.invSlot7 = k,b,56;\0,\0,0
single.invSlot8 = k,b,57;\0,\0,0
single.invSlot9 = k,b,48;\0,\0,0
single.invNext = k,b,93;m,w,1
single.invPrev = k,b,91;m,w,-1
single.invShiftUp = k,b,61;\0,\0,0
single.invShiftDown = k,b,45;\0,\0,0
single.rotBlockX = k,b,82;\0,\0,0
single.rotBlockY = k,b,70;\0,\0,0
single.rotBlockZ = k,b,67;\0,\0,0
single.chat = k,b,84;\0,\0,0
single.command = k,b,47;\0,\0,0
single.fullscreen = k,b,300;\0,\0,0
single.debug = k,b,292;\0,\0,0

[SDL2 Keybinds]
move.forward = k,b,26;\0,\0,0
move.backward = k,b,22;\0,\0,0
move.left = k,b,4;\0,\0,0
move.right = k,b,7;\0,\0,0
move.lookUp = m,m,1;\0,\0,0
move.lookDown = \0,\0,0;\0,\0,0
move.lookLeft = \0,\0,0;\0,\0,0
move.lookRight = m,m,0;\0,\0,0
multi.place = m,b,1;\0,\0,0
multi.destroy = m,b,4;\0,\0,0
multi.pick = m,b,2;\0,\0,0
multi.zoom = k,b,29;\0,\0,0
multi.jump = k,b,44;\0,\0,0
multi.crouch = k,b,225;k,b,229
multi.run = k,b,224;k,b,228
multi.playerlist = k,b,43;\0,\0,0
multi.debug = k,b,61;\0,\0,0
single.escape = k,b,41;\0,\0,0
single.inventory = k,b,12;\0,\0,0
single.invSlot0 = k,b,30;\0,\0,0
single.invSlot1 = k,b,31;\0,\0,0
single.invSlot2 = k,b,32;\0,\0,0
single.invSlot3 = k,b,33;\0,\0,0
single.invSlot4 = k,b,34;\0,\0,0
single.invSlot5 = k,b,35;\0,\0,0
single.invSlot6 = k,b,36;\0,\0,0
single.invSlot7 = k,b,37;\0,\0,0
single.invSlot8 = k,b,38;\0,\0,0
single.invSlot9 = k,b,39;\0,\0,0
single.invNext = k,b,48;m,w,1
single.invPrev = k,b,47;m,w,-1
single.invShiftUp = k,b,46;\0,\0,0
single.invShiftDown = k,b,45;\0,\0,0
single.rotBlockX = k,b,21;\0,\0,0
single.rotBlockY = k,b,9;\0,\0,0
single.rotBlockZ = k,b,6;\0,\0,0
single.chat = k,b,23;\0,\0,0
single.command = k,b,56;\0,\0,0
single.fullscreen = k,b,68;\0,\0,0
single.debug = k,b,60;\0,\0,0
6 changes: 3 additions & 3 deletions resources/base/game/data/blocks/14/1.inf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=Light
id=on
texa=.0
light_r=8
light_g=8
light_b=7
light_r=0.75
light_g=0.75
light_b=0.67
4 changes: 2 additions & 2 deletions resources/base/game/data/blocks/15/3.inf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Photonium Ore
id=photonium
texa=.0
light_r=1
light_g=2
light_r=0.1
light_g=0.1
2 changes: 1 addition & 1 deletion resources/base/game/data/blocks/15/6.inf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name=Powerite Ore
id=powerite
texa=.0
light_g=4
light_g=0.2
6 changes: 3 additions & 3 deletions resources/base/game/data/blocks/17/1.inf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ tex4=$.0
tex5=.0
animation5=5
animationdiv=15
light_r=5
light_g=4
light_b=2
light_r=0.5
light_g=0.33
light_b=0.25
Binary file removed resources/base/game/models/block/default.bmd
Binary file not shown.
Binary file removed resources/base/game/models/block/default.bmd.old
Binary file not shown.
13 changes: 10 additions & 3 deletions src/common/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ void declareConfigKey(struct config* cfg, char* sect, char* key, char* val, bool
memset(&cfg->sectdata[secti].keydata[keyi], 0, sizeof(*cfg->sectdata[secti].keydata));
cfg->sectdata[secti].keydata[keyi].name = strdup(key);
cfg->sectdata[secti].keydata[keyi].value = strdup(val);
cfg->changed = true;
if (overwrite) {
cfg->sectdata[secti].keydata[keyi].changed = true;
cfg->sectdata[secti].changed = true;
cfg->changed = true;
}
} else if (overwrite) {
#if DBGLVL(1)
printf("Rewriting key {%s} in section {%s} with old value {%s} with new value {%s}...\n", key, sect, cfg->sectdata[secti].keydata[keyi].value, val);
#endif
free(cfg->sectdata[secti].keydata[keyi].value);
cfg->sectdata[secti].keydata[keyi].value = strdup(val);
cfg->sectdata[secti].keydata[keyi].changed = true;
cfg->sectdata[secti].changed = true;
cfg->changed = true;
}
}
Expand Down Expand Up @@ -283,6 +289,7 @@ struct config* openConfig(char* path) {

static force_inline void writeKeys(struct config* cfg, int i, FILE* outfile) {
for (int j = 0; j < cfg->sectdata[i].keys; ++j) {
if (!cfg->sectdata[i].keydata[j].changed) continue;
fputs(cfg->sectdata[i].keydata[j].name, outfile);
fputs(" = ", outfile);
bool q = false;
Expand Down Expand Up @@ -367,12 +374,12 @@ bool writeConfig(struct config* cfg, char* name) {
}
bool first = true;
for (int i = 0; i < cfg->sects; ++i) {
if (!cfg->sectdata[i].keys || *cfg->sectdata[i].name) continue;
if (!cfg->sectdata[i].keys || *cfg->sectdata[i].name || !cfg->sectdata[i].changed) continue;
writeKeys(cfg, i, outfile);
first = false;
}
for (int i = 0; i < cfg->sects; ++i) {
if (!cfg->sectdata[i].keys || !*cfg->sectdata[i].name) continue;
if (!cfg->sectdata[i].keys || !*cfg->sectdata[i].name || !cfg->sectdata[i].changed) continue;
if (first) {first = false;} else {fputc('\n', outfile);}
fputc('[', outfile);
fputs(cfg->sectdata[i].name, outfile);
Expand Down
2 changes: 2 additions & 0 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
struct config_key {
char* name;
char* value;
bool changed;
};

struct config_sect {
char* name;
int keys;
struct config_key* keydata;
bool changed;
};

struct config {
Expand Down
6 changes: 3 additions & 3 deletions src/game/blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ void initBlocks() {
}
}
blockinf[i].data[j].anidiv = atoi(getInfoVarStatic((char*)varcfg->data, "animationdiv", "1", 16));
blockinf[i].data[j].light_r = atoi(getInfoVarStatic((char*)varcfg->data, "light_r", "0", 16));
blockinf[i].data[j].light_g = atoi(getInfoVarStatic((char*)varcfg->data, "light_g", "0", 16));
blockinf[i].data[j].light_b = atoi(getInfoVarStatic((char*)varcfg->data, "light_b", "0", 16));
blockinf[i].data[j].light_r = atof(getInfoVarStatic((char*)varcfg->data, "light_r", "0", 16));
blockinf[i].data[j].light_g = atof(getInfoVarStatic((char*)varcfg->data, "light_g", "0", 16));
blockinf[i].data[j].light_b = atof(getInfoVarStatic((char*)varcfg->data, "light_b", "0", 16));
blockinf[i].data[j].backfaces = getBool(getInfoVarStatic((char*)varcfg->data, "backfaces", "false", 16));
freeResource(varcfg);
#if DBGLVL(1)
Expand Down
6 changes: 3 additions & 3 deletions src/game/blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ struct blockinfo_data {
uint16_t texoff[6];
uint8_t anict[6];
uint8_t anidiv;
uint8_t light_r:4;
uint8_t light_g:4;
uint8_t light_b:4;
float light_r;
float light_g;
float light_b;
bool backfaces;
};

Expand Down
17 changes: 14 additions & 3 deletions src/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,26 @@ static void handleServer(int msg, void* _data) {
//printf("Recieved [%d] from server\n", msg);
switch (msg) {
case SERVER_PONG:; {
printf("Server ponged\n");
//printf("Server ponged\n");
ping = true;
} break;
case SERVER_COMPATINFO:; {
struct server_data_compatinfo* data = _data;
printf("Server version is %s %d.%d.%d\n", data->server_str, data->ver_major, data->ver_minor, data->ver_patch);
if (data->flags & SERVER_FLAG_NOAUTH) puts("- No authentication required");
if (data->flags & SERVER_FLAG_PASSWD) puts("- Password protected");
compat = (!strcasecmp(data->server_str, PROG_NAME) && data->ver_major == VER_MAJOR && data->ver_minor == VER_MINOR && data->ver_patch == VER_PATCH) ? 1 : -1;
if (strcasecmp(data->server_str, PROG_NAME)) {
printf("Incompatible game (%s (server) != %s (client))\n", data->server_str, PROG_NAME);
compat = -1;
} else if (data->ver_major != VER_MAJOR || data->ver_minor != VER_MINOR || data->ver_patch != VER_PATCH) {
printf("Incompatible game version (%d.%d.%d (server) != %d.%d.%d (client))\n",
data->ver_major, data->ver_minor, data->ver_patch,
VER_MAJOR, VER_MINOR, VER_PATCH
);
compat = -1;
} else {
compat = 1;
}
} break;
case SERVER_UPDATECHUNK:; {
struct server_data_updatechunk* data = _data;
Expand Down Expand Up @@ -213,7 +224,7 @@ bool doGame(char* addr, int port) {
microwait(100000);
}
if (compat < 0) {
fputs("Server version mismatch\n", stderr);
fputs("Server compatibility error\n", stderr);
return false;
}
if (quitRequest) return false;
Expand Down
4 changes: 2 additions & 2 deletions src/main/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define MAIN_VERSION_H

#define VER_MAJOR 0
#define VER_MINOR 5
#define VER_PATCH 5
#define VER_MINOR 6
#define VER_PATCH 0

#define _STR(x) #x
#define STR(x) _STR(x)
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,7 @@ bool startRenderer() {
}
#endif

#if DBGLVL(1)
GLint range[2];
glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range);
printf("GL_ALIASED_LINE_WIDTH_RANGE: [%d, %d]\n", range[0], range[1]);
Expand All @@ -2083,6 +2084,7 @@ bool startRenderer() {
GLint texunits;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &texunits);
printf("GL_MAX_TEXTURE_IMAGE_UNITS: [%d]\n", texunits);
#endif

#if defined(USEGLES)
char* hdrpath = "engine/shaders/headers/OpenGL ES/header.glsl";
Expand Down
8 changes: 4 additions & 4 deletions src/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,10 @@ int startServer(char* addr, int port, int mcli, char* world) {
#if DBGLVL(1)
puts(" Initializing noise...");
#endif
uint32_t rand = getRandDWord(1);
printf("rand: [%u]\n", rand);
setRandSeed(0, rand);
//setRandSeed(0, 119952304);
//uint32_t rand = getRandDWord(1);
//printf("rand: [%u]\n", rand);
//setRandSeed(0, rand);
setRandSeed(0, 13541306);
initNoiseTable(0);
initWorldgen();
#if DBGLVL(1)
Expand Down

0 comments on commit 452ca34

Please sign in to comment.