[Tux4kids-commits] [SCM] tuxhistory - Educational history game branch, master, updated. 032631279d8c7eddad718867621328f68b609863
julio (none)
julio at julio-desktop.
Mon Aug 9 08:17:11 UTC 2010
The following commit has been merged in the master branch:
commit 032631279d8c7eddad718867621328f68b609863
Author: julio <julio at julio-desktop.(none)>
Date: Mon Aug 9 03:16:28 2010 -0500
Gold and Stone resources added.
diff --git a/data/images/others/Makefile.am b/data/images/others/Makefile.am
index 52337c4..ff6b8ea 100644
--- a/data/images/others/Makefile.am
+++ b/data/images/others/Makefile.am
@@ -10,4 +10,6 @@ go.png \
novisible.png \
explored.png \
used_forest.png \
+gold.png \
+stone.png \
wrong.png
diff --git a/data/images/others/gold.png b/data/images/others/gold.png
new file mode 100644
index 0000000..6f5cd20
Binary files /dev/null and b/data/images/others/gold.png differ
diff --git a/data/maps/map.xml b/data/maps/map.xml
index 3ee387e..2af727d 100644
--- a/data/maps/map.xml
+++ b/data/maps/map.xml
@@ -1665,7 +1665,7 @@
<tilde>
<height>1</height>
<terrain>SWAMP</terrain>
- <object></object>
+ <object player=0>REC_GOLD_1</object>
<unit></unit>
<building></building>
</tilde>
@@ -1801,7 +1801,7 @@
<tilde>
<height>1</height>
<terrain>GRASSLAND</terrain>
- <object></object>
+ <object player=0>REC_STONE_1</object>
<unit></unit>
<building></building>
</tilde>
diff --git a/data/objects/objects.xml b/data/objects/objects.xml
index 420aea8..787260d 100644
--- a/data/objects/objects.xml
+++ b/data/objects/objects.xml
@@ -7,6 +7,7 @@
<rname>"Mixed Forest"</rname>
<description>Cut this trees and get 375 woods</description>
<live>375</live>
+ <vision>1</vision>
</object>
<object>
<type>FOREST</type>
@@ -14,6 +15,7 @@
<rname>Tropical forest</rname>
<description>Cut this trees and get 350 woods</description>
<live>350</live>
+ <vision>1</vision>
</object>
<object>
<type>FOREST</type>
@@ -21,6 +23,7 @@
<rname>Scrub Forest</rname>
<description>Cut this trees and get 250 woods</description>
<live>250</live>
+ <vision>1</vision>
</object>
<object>
<type>FOREST</type>
@@ -28,6 +31,7 @@
<rname>Conifer Forest</rname>
<description>Cut this trees and get 400 woods</description>
<live>400</live>
+ <vision>1</vision>
</object>
<object>
<type>FOREST</type>
@@ -35,8 +39,25 @@
<rname>Rain Forest</rname>
<description>Cut this trees and get 300 woods</description>
<live>300</live>
+ <vision>1</vision>
</object>
<object>
+ <type>GOLD</type>
+ <name>REC_GOLD_1</name>
+ <rname>Gold</rname>
+ <description>Get 450 gold</description>
+ <live>450</live>
+ <vision>1</vision>
+ </object>
+ <object>
+ <type>STONE</type>
+ <name>REC_STONE_1</name>
+ <rname>Stone</rname>
+ <description>Get 450 Stone</description>
+ <live>450</live>
+ <vision>1</vision>
+ </object>
+ <object>
<type>UNIT</type>
<name>VILLAGER_MILKMAID</name>
<rname>Vilager</rname>
diff --git a/src/ai.c b/src/ai.c
index 71a6bcc..040da39 100644
--- a/src/ai.c
+++ b/src/ai.c
@@ -306,6 +306,26 @@ int ai_modify_state(int player, th_obj *object, int state)
printf("Not a valid player to modify objects state!");
return 0;
}
+static int ai_kill_object(list_node *node)
+{
+ list_node *iter_node;
+ iter_node = list_nodes;
+ do{
+
+ if(&(iter_node->obj) == node->obj.state.target_obj)
+ {
+ node->obj.state.target_obj = NULL;
+ node->obj.state.target_point.x = 0;
+ node->obj.state.target_point.y = 0;
+ }
+ iter_node = iter_node->next;
+ }while(iter_node);
+
+ list_remove(&node);
+ printf("Exito removiendo\n");
+ return 1;
+}
+
static int ai_is_tile_free(th_point point)
{
return 0;
@@ -342,11 +362,16 @@ static th_point ai_find_closest_center(th_point point)
do{
if(node->obj.name_enum == VILLAGE_CENTER)
{
- if( HDIST(point.x, point.y, node->obj.x, node->obj.y) <
+ if(lowest.x == -1 && lowest.y ==-1)
+ {
+ lowest.x = node->obj.x;
+ lowest.y = node->obj.y;
+ }
+ else if( HDIST(point.x, point.y, node->obj.x, node->obj.y) <
HDIST(point.x, point.y, lowest.x, lowest.y))
{
- lowest.x = node->obj.x;
- lowest.y = node->obj.y;
+ lowest.x = node->obj.x;
+ lowest.y = node->obj.y;
}
}
node = node->next;
@@ -415,6 +440,10 @@ int ai_state_update(list_node *node)
node->obj.state.path_flag = 1;
}
node->obj.state.flag = 0;
+ if(node->obj.state.state == DIE)
+ {
+ ai_kill_object(node);
+ }
}
if(node->obj.state.agains_flag)
{
@@ -509,11 +538,20 @@ int ai_state_update(list_node *node)
{
tmp_point.x = node->obj.x;
tmp_point.y = node->obj.y;
+ printf("Finish collecting at: (%d,%d)\n", tmp_point.x, tmp_point.y);
point = ai_find_closest_center(tmp_point);
- printf("Closest center al (%d, %d)\n", point.x, point.y);
- rts_goto(&(node->obj), point);
- node = node->next;
- continue;
+ if(point.x != -1 && point.y != -1)
+ {
+ printf("Closest center al (%d, %d)\n", point.x, point.y);
+ rts_goto(&(node->obj), point);
+ node = node->next;
+ continue;
+ }
+ else
+ {
+ printf("No town center in map!\n");
+ ai_modify_state(node->obj.player, &(node->obj), INACTIVE);
+ }
}
}
}
@@ -573,6 +611,9 @@ int ai_state_update(list_node *node)
}
}
}
+ if(node->obj.actual_live <= 0)
+ ai_modify_state(node->obj.player, &(node->obj), DIE);
+
node = node->next;
}while(node != NULL);
}
diff --git a/src/fileops.h b/src/fileops.h
index 5eef3bc..a679fe9 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -375,6 +375,8 @@ enum{
FOREST_RAIN,
FOREST_BROADLEAF,
FOREST_USED,
+ REC_GOLD_1,
+ REC_STONE_1,
VILLAGER_MILKMAID,
HOUSE,
HUT,
diff --git a/src/fileops_media.c b/src/fileops_media.c
index 1a03cfd..8ed135b 100644
--- a/src/fileops_media.c
+++ b/src/fileops_media.c
@@ -309,6 +309,8 @@ int load_image_data()
"forest/rain.png",
"forest/broadleaf.png",
"others/used_forest.png",
+ "others/gold.png",
+ "others/stone.png",
"units/milkmaid.png",
"buildings/villagehouse.png",
"buildings/hut.png",
diff --git a/src/llist.c b/src/llist.c
index 8e66e03..01c7808 100644
--- a/src/llist.c
+++ b/src/llist.c
@@ -32,6 +32,12 @@ list_node *list_add(list_node **ptr, th_obj obj)
node->next = *ptr;
*ptr = node;
node->obj = obj;
+ node->prev = NULL;
+
+ if(object_counter != 0)
+ node->next->prev = node;
+
+ (*ptr)->obj.id = object_counter;
object_counter++;
@@ -40,10 +46,15 @@ list_node *list_add(list_node **ptr, th_obj obj)
void list_remove(list_node** ptr)
{
+ list_node *node;
+ list_node *tmp;
if(ptr != NULL && *ptr != NULL)
{
- list_node *node = *ptr;
+ node = *ptr;
+ tmp = (*ptr)->prev;
*ptr = (*ptr)->next;
+ (*ptr)->prev = tmp;
+ tmp->next = *ptr;
free(node);
}
}
diff --git a/src/llist.h b/src/llist.h
index cd85dfc..e9e1d5f 100644
--- a/src/llist.h
+++ b/src/llist.h
@@ -18,6 +18,7 @@
typedef struct list_node{
struct list_node *next;
+ struct list_node *prev;
th_obj obj;
}list_node;
diff --git a/src/objects.c b/src/objects.c
index 88481ad..ac5cd7f 100644
--- a/src/objects.c
+++ b/src/objects.c
@@ -28,6 +28,8 @@ static int init_obj_hash(void)
hashtable_add(obj_table_hash, "HOUSE", HOUSE);
hashtable_add(obj_table_hash, "HUT", HUT);
hashtable_add(obj_table_hash, "VILLAGE_CENTER", VILLAGE_CENTER);
+ hashtable_add(obj_table_hash, "REC_GOLD_1", REC_GOLD_1);
+ hashtable_add(obj_table_hash, "REC_STONE_1", REC_STONE_1);
hashtable_add(obj_table_hash, "FOREST", FOREST);
hashtable_add(obj_table_hash, "GOLD", GOLD);
--
tuxhistory - Educational history game
More information about the Tux4kids-commits
mailing list