about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-17 01:41:11 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-17 01:41:11 +0000
commit22360b5d795164df0c7a80a88f5b7cb1c230e6f0 (patch)
treedf7a55964ebd5a054689ed53ad7b1c56b4284314 /src/game/client
parent412958bae395c50892ce390b84e309ce827e9b13 (diff)
downloadzcatch-22360b5d795164df0c7a80a88f5b7cb1c230e6f0.tar.gz
zcatch-22360b5d795164df0c7a80a88f5b7cb1c230e6f0.zip
blood color depending on skin fixed
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/gc_client.cpp2
-rw-r--r--src/game/client/gc_client.h2
-rw-r--r--src/game/client/gc_console.cpp2
-rw-r--r--src/game/client/gc_effects.cpp19
-rw-r--r--src/game/client/gc_menu.cpp9
-rw-r--r--src/game/client/gc_skin.cpp38
-rw-r--r--src/game/client/gc_skin.h1
7 files changed, 54 insertions, 19 deletions
diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp
index 238404d0..b1c1b54e 100644
--- a/src/game/client/gc_client.cpp
+++ b/src/game/client/gc_client.cpp
@@ -296,7 +296,7 @@ void process_events(int snaptype)
 		else if(item.type == NETEVENTTYPE_DEATH)
 		{
 			NETEVENT_DEATH *ev = (NETEVENT_DEATH *)data;
-			effect_playerdeath(vec2(ev->x, ev->y));
+			effect_playerdeath(vec2(ev->x, ev->y), ev->cid);
 		}
 		else if(item.type == NETEVENTTYPE_SOUND_WORLD)
 		{
diff --git a/src/game/client/gc_client.h b/src/game/client/gc_client.h
index 55a880ed..7ba8a32a 100644
--- a/src/game/client/gc_client.h
+++ b/src/game/client/gc_client.h
@@ -147,7 +147,7 @@ void effect_explosion(vec2 pos);
 void effect_air_jump(vec2 pos);
 void effect_damage_indicator(vec2 pos, vec2 dir);
 void effect_playerspawn(vec2 pos);
-void effect_playerdeath(vec2 pos);
+void effect_playerdeath(vec2 pos, int cid);
 void effect_powerupshine(vec2 pos, vec2 size);
 
 // particles
diff --git a/src/game/client/gc_console.cpp b/src/game/client/gc_console.cpp
index d0714009..37e50948 100644
--- a/src/game/client/gc_console.cpp
+++ b/src/game/client/gc_console.cpp
@@ -72,7 +72,7 @@ public:
 	
 	void handle_event(INPUT_EVENT e)
 	{
-		if (!(e.ch >= 0 && e.ch < 32))
+		if (e.ch >= 32)
 		{
 			if (input_len < sizeof(input) - 1)
 			{
diff --git a/src/game/client/gc_effects.cpp b/src/game/client/gc_effects.cpp
index 094392e5..1f2c0b63 100644
--- a/src/game/client/gc_effects.cpp
+++ b/src/game/client/gc_effects.cpp
@@ -1,5 +1,6 @@
 #include <engine/e_client_interface.h>
 #include "gc_client.h"
+#include "gc_skin.h"
 #include "../generated/gc_data.h"
 
 static bool add_50hz = false;
@@ -123,8 +124,20 @@ void effect_playerspawn(vec2 pos)
 	}
 }
 
-void effect_playerdeath(vec2 pos)
+void effect_playerdeath(vec2 pos, int cid)
 {
+	vec3 blood_color(1.0f,1.0f,1.0f);
+
+	if(cid >= 0)	
+	{
+		const skin *s = skin_get(client_datas[cid].skin_id);
+		if(s)
+		{
+			dbg_msg("", "good blood color!");
+			blood_color = s->blood_color;
+		}
+	}
+	
 	for(int i = 0; i < 64; i++)
 	{
 		particle p;
@@ -139,9 +152,9 @@ void effect_playerdeath(vec2 pos)
 		p.rotspeed = (frandom()-0.5f) * pi;
 		p.gravity = 800.0f;
 		p.friction = 0.8f;
-		p.color = mix(vec4(0.75f,0.2f,0.2f,0.75f), vec4(0.5f,0.1f,0.1f,0.75f), frandom());
+		vec3 c = blood_color * (0.75f + frandom()*0.25f);
+		p.color = vec4(c.r, c.g, c.b, 0.75f);
 		particle_add(PARTGROUP_GENERAL, &p);
-		
 	}
 }
 
diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp
index 6ee03e17..82c17ab1 100644
--- a/src/game/client/gc_menu.cpp
+++ b/src/game/client/gc_menu.cpp
@@ -1321,6 +1321,15 @@ static void menu2_render_settings_player(RECT main_view)
 		ui_hsplit_t(&icon, 5.0f, 0, &icon); // some margin from the top
 		render_tee(&state, &info, 0, vec2(1, 0), vec2(icon.x+icon.w/2, icon.y+icon.h/2));
 		
+		if(config.debug)
+		{
+			gfx_texture_set(-1);
+			gfx_quads_begin();
+			gfx_setcolor(s->blood_color.r, s->blood_color.g, s->blood_color.b, 1.0f);
+			gfx_quads_drawTL(icon.x, icon.y, 12, 12);
+			gfx_quads_end();
+		}
+		
 		ui_hsplit_t(&list, 50, &button, &list);
 	}
 }
diff --git a/src/game/client/gc_skin.cpp b/src/game/client/gc_skin.cpp
index e3ed8b7c..7198665f 100644
--- a/src/game/client/gc_skin.cpp
+++ b/src/game/client/gc_skin.cpp
@@ -1,6 +1,7 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 #include <string.h>
 #include <stdio.h>
+#include <math.h>
 #include <engine/e_system.h>
 #include <engine/e_client_interface.h>
 #include "gc_skin.h"
@@ -33,8 +34,28 @@ static void skinscan(const char *name, int is_dir, void *user)
 	
 	skins[num_skins].org_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data, info.format);
 	
-	// create colorless version
+	int body_size = 96; // body size
 	unsigned char *d = (unsigned char *)info.data;
+	int pitch = info.width*4;
+
+	// dig out blood color
+	{
+		int colors[3] = {0};
+		for(int y = 0; y < body_size; y++)
+			for(int x = 0; x < body_size; x++)
+			{
+				if(d[y*pitch+x*4+3] > 128)
+				{
+					colors[0] += d[y*pitch+x*4+0];
+					colors[1] += d[y*pitch+x*4+1];
+					colors[2] += d[y*pitch+x*4+2];
+				}
+			}
+			
+		skins[num_skins].blood_color = normalize(vec3(colors[0], colors[1], colors[2]));
+	}
+	
+	// create colorless version
 	int step = info.format == IMG_RGBA ? 4 : 3;
 	
 	for(int i = 0; i < info.width*info.height; i++)
@@ -44,20 +65,11 @@ static void skinscan(const char *name, int is_dir, void *user)
 		d[i*step+1] = v;
 		d[i*step+2] = v;
 	}
+
 	
 	if(1)
 	{
-		int bs = 96; // body size
-		int pitch = info.width*4;
 		int freq[256] = {0};
-
-		for(int y = 0; y < bs; y++)
-			for(int x = 0; x < bs; x++)
-			{
-				if(d[y*pitch+x*4+3] > 128)
-					freq[d[y*pitch+x*4]]++;
-			}
-				
 		int org_weight = 0;
 		int new_weight = 192;
 		for(int i = 1; i < 256; i++)
@@ -68,8 +80,8 @@ static void skinscan(const char *name, int is_dir, void *user)
 
 		int inv_org_weight = 255-org_weight;
 		int inv_new_weight = 255-new_weight;
-		for(int y = 0; y < bs; y++)
-			for(int x = 0; x < bs; x++)
+		for(int y = 0; y < body_size; y++)
+			for(int x = 0; x < body_size; x++)
 			{
 				int v = d[y*pitch+x*4];
 				if(v <= org_weight)
diff --git a/src/game/client/gc_skin.h b/src/game/client/gc_skin.h
index 3742d04e..d3840302 100644
--- a/src/game/client/gc_skin.h
+++ b/src/game/client/gc_skin.h
@@ -8,6 +8,7 @@ typedef struct
 	int color_texture;
 	char name[31];
 	char term[1];
+	vec3 blood_color;
 } skin;
 
 vec4 skin_get_color(int v);