diff --git a/src/chunk.c b/src/chunk.c
index 0b854e7..8682bcf 100644
--- a/src/chunk.c
+++ b/src/chunk.c
@@ -202,19 +202,6 @@ void chunk_draw_shadow_volume(float* data, int max) {
glEnd();*/
}
-//see this for details: https://github.com/infogulch/pyspades/blob/protocol075/pyspades/vxl_c.cpp#L380
-float sunblock(int x, int y, int z) {
- int dec = 18;
- int i = 127;
-
- while(dec && y<64) {
- if((map_get(x,++y,--z)&0xFFFFFFFF)!=0xFFFFFFFF)
- i -= dec;
- dec -= 2;
- }
- return (float)i/127.0F;
-}
-
void* chunk_generate(void* data) {
struct chunk_worker* worker = (struct chunk_worker*)data;
@@ -1358,7 +1345,7 @@ void chunk_generate_naive(struct chunk_worker* worker) {
unsigned char r = (col&0xFF);
unsigned char g = ((col>>8)&0xFF);
unsigned char b = ((col>>16)&0xFF);
- float shade = sunblock(x,y,z);
+ float shade = map_sunblock(x,y,z);
r *= shade;
g *= shade;
b *= shade;
@@ -1377,7 +1364,7 @@ void chunk_generate_naive(struct chunk_worker* worker) {
CHECK_ALLOCATION_ERROR(worker->color_data)
}
size++;
-
+
#ifdef OPENGL_ES
for(int l=0;l<6;l++) {
#else
@@ -1531,7 +1518,7 @@ void chunk_generate_naive(struct chunk_worker* worker) {
worker->vertex_data[chunk_vertex_index++] = x;
worker->vertex_data[chunk_vertex_index++] = y;
worker->vertex_data[chunk_vertex_index++] = z;
-
+
worker->vertex_data[chunk_vertex_index++] = x;
worker->vertex_data[chunk_vertex_index++] = y+1;
worker->vertex_data[chunk_vertex_index++] = z+1;
diff --git a/src/common.h b/src/common.h
index f22007c..97e7310 100644
--- a/src/common.h
+++ b/src/common.h
@@ -17,9 +17,9 @@
along with BetterSpades. If not, see .
*/
-#define BETTERSPADES_VERSION "v0.1.2"
+#define BETTERSPADES_VERSION "v0.1.3"
-#define BETTERSPADES_PATCH 2
+#define BETTERSPADES_PATCH 3
#define BETTERSPADES_MINOR 1
#define BETTERSPADES_MAJOR 0
diff --git a/src/hud.c b/src/hud.c
index 100bbea..6c49bb8 100644
--- a/src/hud.c
+++ b/src/hud.c
@@ -403,11 +403,6 @@ static void hud_ingame_render(float scalex, float scalef) {
}
}
glColor3f(1.0F,1.0F,1.0F);
-
- if(window_time()-local_player_last_damage_timer<=0.5F || 1) {
- float ang = -camera_rot_x-atan2(camera_z-local_player_last_damage_z,camera_x-local_player_last_damage_x);
- texture_draw_rotated(&texture_indicator,settings.window_width/2.0F,settings.window_height/2.0F,200,200,ang);
- }
}
if(camera_mode==CAMERAMODE_FPS) {
@@ -594,7 +589,7 @@ static void hud_ingame_render(float scalex, float scalef) {
if(camera_mode!=CAMERAMODE_SELECTION) {
glColor3f(1.0F,1.0F,1.0F);
//large
- if(chat_input_mode==CHAT_NO_INPUT && window_key_down(WINDOW_KEY_MAP)) {
+ if(window_key_down(WINDOW_KEY_MAP)) {
float minimap_x = (settings.window_width-(map_size_x+1)*scalef)/2.0F;
float minimap_y = ((600-map_size_z-1)/2.0F+map_size_z+1)*scalef;
@@ -677,17 +672,14 @@ static void hud_ingame_render(float scalex, float scalef) {
glColor3f(1.0F,1.0F,1.0F);
} else {
//minimized, top right
- float view_x = min(max(camera_x-64.0F,0.0F),map_size_x+1-128.0F);
- float view_z = min(max(camera_z-64.0F,0.0F),map_size_z+1-128.0F);
+ float view_x = camera_x-64.0F;//min(max(camera_x-64.0F,0.0F),map_size_x+1-128.0F);
+ float view_z = camera_z-64.0F;//min(max(camera_z-64.0F,0.0F),map_size_z+1-128.0F);
glColor3ub(0,0,0);
texture_draw_empty(settings.window_width-144*scalef,586*scalef,130*scalef,130*scalef);
glColor3f(1.0F,1.0F,1.0F);
- glEnable(GL_SCISSOR_TEST);
- glScissor(settings.window_width-143*scalef,585*scalef-128*scalef,128*scalef,128*scalef);
- texture_draw(&texture_minimap,settings.window_width-(143+(int)view_x)*scalef,(585+(int)view_z)*scalef,512*scalef,512*scalef);
- glDisable(GL_SCISSOR_TEST);
+ texture_draw_sector(&texture_minimap,settings.window_width-143*scalef,585*scalef,128*scalef,128*scalef,(camera_x-64.0F)/512.0F,(camera_z-64.0F)/512.0F,0.25F,0.25F);
for(int k=0;ktoggle)
- window_pressed_keys[key] = !window_pressed_keys[key];
- else
- window_pressed_keys[key] = 1;
- }
- if(action==WINDOW_RELEASE && !config_key(key)->toggle)
- window_pressed_keys[key] = 0;
+ if(config_key(key)->toggle) {
+ if(chat_input_mode==CHAT_NO_INPUT) {
+ window_pressed_keys[key] = !window_pressed_keys[key];
+ }
+ } else {
+ window_pressed_keys[key] = 1;
+ }
+ }
+ if(action==WINDOW_RELEASE && !config_key(key)->toggle)
+ window_pressed_keys[key] = 0;
#ifdef USE_GLFW
if(key==WINDOW_KEY_FULLSCREEN && action==GLFW_PRESS) { //switch between fullscreen
diff --git a/src/map.c b/src/map.c
index 30008a9..d0d8c53 100644
--- a/src/map.c
+++ b/src/map.c
@@ -569,6 +569,19 @@ void map_update_physics(int x, int y, int z) {
map_update_physics_sub(x,y+1,z);
}
+//see this for details: https://github.com/infogulch/pyspades/blob/protocol075/pyspades/vxl_c.cpp#L380
+float map_sunblock(int x, int y, int z) {
+ int dec = 18;
+ int i = 127;
+
+ while(dec && y<64) {
+ if((map_get(x,++y,--z)&0xFFFFFFFF)!=0xFFFFFFFF)
+ i -= dec;
+ dec -= 2;
+ }
+ return (float)i/127.0F;
+}
+
unsigned long long map_get(int x, int y, int z) {
if(x<0 || y<0 || z<0 || x>=map_size_x || y>=map_size_y || z>=map_size_z)
return 0xFFFFFFFF;
diff --git a/src/map.h b/src/map.h
index 492c633..c3ddece 100644
--- a/src/map.h
+++ b/src/map.h
@@ -41,6 +41,7 @@ int map_object_visible(float* loc);
int map_damage(int x, int y, int z, int damage);
void map_damaged_voxels_render();
void map_update_physics(int x, int y, int z);
+float map_sunblock(int x, int y, int z);
unsigned long long map_get(int x, int y, int z);
unsigned long long map_get_unblocked(int x, int y, int z);
void map_set(int x, int y, int z, unsigned long long color);
diff --git a/src/model.c b/src/model.c
index 98a0720..6d6f357 100644
--- a/src/model.c
+++ b/src/model.c
@@ -187,6 +187,16 @@ void kv6_rebuild(struct kv6_t* kv6) {
}
}
+void kv6_calclight(int x, int y, int z) {
+ float f = 1.0F;
+ if(x>=0 && y>=0 && z>=0)
+ f = map_sunblock(x,y,z);
+ float lambient[4] = {0.5F*f,0.5F*f,0.5F*f,1.0F};
+ float ldiffuse[4] = {0.5F*f,0.5F*f,0.5F*f,1.0F};
+ glLightfv(GL_LIGHT0,GL_AMBIENT,lambient);
+ glLightfv(GL_LIGHT0,GL_DIFFUSE,ldiffuse);
+}
+
static int kv6_program = -1;
void kv6_render(struct kv6_t* kv6, unsigned char team) {
if(!kv6->has_display_list) {
@@ -532,7 +542,7 @@ void kv6_render(struct kv6_t* kv6, unsigned char team) {
" float d = clamp(dot(N,L),0.0,1.0)*0.5+0.5;\n" \
" gl_FrontColor = mix(vec4(d,d,d,1.0)*gl_Color,vec4(fog,1.0),min(dist/128.0,1.0));\n" \
" gl_PointSize = size/gl_Position.w;\n" \
- "}\n");
+ "}\n",NULL);
}
}
diff --git a/src/model.h b/src/model.h
index 6dd850f..7fcd902 100644
--- a/src/model.h
+++ b/src/model.h
@@ -63,6 +63,7 @@ extern struct kv6_t model_semi_casing;
extern struct kv6_t model_smg_casing;
extern struct kv6_t model_shotgun_casing;
+void kv6_calclight(int x, int y, int z);
char kv6_intersection(struct kv6_t* kv6, Ray* r);
void kv6_rebuild_all(void);
void kv6_rebuild(struct kv6_t* kv6);
diff --git a/src/player.c b/src/player.c
index f5917ad..69da152 100644
--- a/src/player.c
+++ b/src/player.c
@@ -398,6 +398,9 @@ static float foot_function(struct Player* p) {
}
int player_render(struct Player* p, int id, Ray* ray, char render) {
+ if(render)
+ kv6_calclight(p->pos.x,p->pos.y,p->pos.z);
+
if(camera_mode==CAMERAMODE_SPECTATOR && p->team!=TEAM_SPECTATOR) {
int old_state = glx_fog;
if(old_state)