Skip to content
Browse files

made cleanup of file structure. added some scripting issues to improv…

…e debbuging, rebuilt Ccharacter class
  • Loading branch information...
1 parent bebed15 commit c98b1c1cea65e207740a26e4eb4a61bbcaeb0990 Daniel (dmilith) Dettlaff committed Aug 28, 2008
View
1 CleanAll
@@ -4,6 +4,7 @@ rm -f *.os
rm -f *.o
rm -f *.so
rm -f test_*
+rm -f main
cd tests/
rm -f test_*
echo "Done."
View
8 Debug
@@ -15,13 +15,21 @@ else
fi
if [ -z "$*" ]; then
+ if [ ! -x "./main" ]; then
+ echo "Couldn't find executable to debug."
+ exit 1
+ fi
echo "Param not given! Debugging main."
if [ -z "$insight" ]; then
gdb ./main
else
insight ./main
fi
else
+ if [ ! -x "$*" ]; then
+ echo "Couldn't find executable to debug."
+ exit 1
+ fi
echo "Debugging $*"
if [ -z "$insight" ]; then
gdb ./$*
View
26 DebugValgrind
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+if [ -z "$1" ]; then
+ param="main"
+else
+ param="$1"
+fi
+
+if [ ! -x "$param" ]; then
+ echo "Nothing to debug! ( no executable nor param given )"
+ exit 1
+fi
+
+valgrind \
+-v \
+--tool=memcheck \
+--log-file=test_world-valgrind-`date +%F_%R`.log \
+--leak-check=yes \
+--error-limit=no \
+--demangle=yes \
+--num-callers=20 \
+--track-fds=yes \
+--trace-children=yes \
+--show-reachable=yes \
+./"$param" "$@"
+
View
0 MakeAll → MakeAllLibs
File renamed without changes.
View
16 tests/Compile_all → MakeAllTests
@@ -1,15 +1,27 @@
#! /bin/bash
+if [ -e "libhl-sha.so" ]; then
+
+cd tests/
+
echo "Serialization tests.."
g++ serialization_test.cpp -ggdb -O0 -L.. -lhl-sha -lboost_serialization -lcoordinates -litem -lsoul -lcoordinates -lcharacter -o test_serialization
echo "sha-1 generation/ thread tests.."
g++ sha1_speed_test_with_threads.cpp -ggdb -O0 -L.. -lhl-sha -o test_sha1_speed_threads -lboost_thread -lncurses
g++ sha1_speed_test_without_threads.cpp -ggdb -O0 -L.. -lhl-sha -o test_sha1_speed_no_threads -lboost_thread -lncurses
+echo "Thread tests.."
+g++ thread_group_test.cpp -ggdb -O0 -L.. -lhl-sha -lboost_thread -o test_thread_group
+
echo "Thread synchronization tests.."
g++ synchronization_test.cpp -ggdb -O0 -L.. -lhl-sha -lboost_thread -o test_thread_synchronization
g++ synchronization_test_2.cpp -ggdb -O0 -L.. -lboost_thread -o test_thread_synchronization_2
-echo "Compiling test_podglad_pracy_watkow ..."
-g++ test_podglad_pracy_watkow.cpp -ggdb -O0 -L.. -lhl-sha -lncurses -o test_podglad_pracy_watkow -lboost_thread
+echo "Ncurses thread monitor tests.."
+g++ ncurses_thread_monitor_test.cpp -ggdb -O0 -L.. -lhl-sha -lncurses -o test_ncurses_thread_monitor -lboost_thread
+
+else
+ echo "Please compile libraries first!"
+ exit
+fi
View
12 Sconstruct
@@ -22,10 +22,10 @@ release.SharedLibrary('soul', 'soul.cpp')
release.SharedLibrary('theritory', 'theritory.cpp')
release.SharedLibrary('world', 'world.cpp')
release.SharedLibrary('job', 'job.cpp')
-release.Program('main' , 'main2.cpp',
- LIBS=[ 'boost_thread', 'boost_filesystem', 'hl-sha', 'boost_serialization',
- 'job', 'character', 'coordinates',
- 'item', 'map', 'place', 'soul', 'theritory',
- 'world'],
+#release.Program('main' , 'main2.cpp',
+# LIBS=[ 'boost_thread', 'boost_filesystem', 'hl-sha', 'boost_serialization',
+# 'job', 'character', 'coordinates',
+# 'item', 'map', 'place', 'soul', 'theritory',
+# 'world'],
#, 'ruby' ],
- LIBPATH=[ '.', '/usr/local/lib', '/usr/lib' ])
+# LIBPATH=[ '.', '/usr/local/lib', '/usr/lib' ])
View
17 Valgrind_test
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-# --trace-malloc=yes \
-
-valgrind \
- -v \
- --tool=memcheck \
- --log-file=test_world-valgrind-`date +%F_%R`.log \
- --leak-check=yes \
- --error-limit=no \
- --demangle=yes \
- --num-callers=20 \
- --track-fds=yes \
- --trace-children=yes \
- --show-reachable=yes \
- ./world "$@"
-
View
210 character.cpp
@@ -19,8 +19,7 @@ Ccharacter::Ccharacter( std::string new_name ) {
for ( int i = 0; i < 250; ++i ) {
private_box[ i ] = NULL;
}
- base_health = ( ( race * 100 ) + ( rand() % 10 ) ) + 100;
- health = base_health + ( rand() % 125 ) - 75;
+ health = ( rand() % 125 ) - 75;
dead = false;
intelligence = ( ( rand() % 50 ) - ( race * 20 ) ) + 100 ;
age = 10;
@@ -40,8 +39,7 @@ Ccharacter::Ccharacter( Eraces born_race, std::string new_name ) {
for ( int i = 0; i < 250; ++i ) {
private_box[ i ] = NULL;
}
- base_health = ( ( race * 100 ) + ( rand() % 10 ) ) + 100;
- health = base_health + ( rand() % 125 ) - 75 ;
+ health = ( rand() % 125 ) - 75 ;
dead = false;
intelligence = ( ( rand() % 50 ) - ( race * 20 ) ) + 100 ;
age = 10 + ( rand() % 75 ); // it's poor to be old ;}
@@ -71,20 +69,15 @@ Ccharacter::Ccharacter( Eraces born_race, std::string new_name ) {
mind_strength = 100; //cechy postaci
break;
}
-
-} //obiekt npc'a/ postaci gracza/ potwora
+}
+
Ccharacter::~Ccharacter() {
-/* for ( int i = 0; i < 50; ++i ) {
- items[ i ] = NULL;
- }
- for ( int i = 0; i < 250; ++i ) {
- private_box[ i ] = NULL;
- }
- */
}
-void Ccharacter::kill() {
+
+void
+Ccharacter::kill() {
#ifdef DEBUG
std::cout << "Killed.";
std::cout.flush();
@@ -94,3 +87,192 @@ void Ccharacter::kill() {
// let character to stay in this world as living dead ;}
}
+
+int32_t
+Ccharacter::get_health() {
+ return health;
+}
+
+
+std::string
+Ccharacter::get_name() {
+ return name;
+}
+
+
+uint32_t
+Ccharacter::get_intelligence() {
+ return intelligence;
+}
+
+
+uint32_t
+Ccharacter::get_strength() {
+ return strength;
+}
+
+
+uint32_t
+Ccharacter::get_dexterity() {
+ return dexterity;
+}
+
+
+int32_t
+Ccharacter::get_mind_strength() {
+ return mind_strength;
+}
+
+
+int64_t
+Ccharacter::get_gold() {
+ return gold;
+}
+
+
+uint32_t
+Ccharacter::get_age() {
+ return age;
+}
+
+
+int16_t
+Ccharacter::get_luck() {
+ return luck;
+}
+
+
+Ccoordinates
+Ccharacter::get_position() {
+ return position;
+}
+
+
+void
+Ccharacter::set_position( Ccoordinates position_ ) {
+ position = position_;
+}
+
+
+Csoul*
+Ccharacter::get_soul() {
+ return soul;
+}
+
+
+void
+Ccharacter::set_soul( Csoul* soul_ ) {
+ soul = soul_;
+}
+
+
+Eraces
+Ccharacter::get_race() {
+ return race;
+}
+
+
+// TODO complete item getting/ putting
+Citem
+Ccharacter::get_item( uint8_t item_number_ ) {
+}
+
+
+void
+Ccharacter::throw_item( Citem* item_ ) { // player is throwing away an item
+
+}
+
+
+void
+Ccharacter::gain_item( Citem* item_ ) { // player is taking an item
+}
+
+
+void
+Ccharacter::gain_health( int32_t damage_ ) { // get hurt or get heal
+ health += damage_;
+}
+
+
+void
+Ccharacter::gain_gold( int64_t gold_amount_ ) { // could be negative
+ gold += gold_amount_;
+}
+
+
+void
+Ccharacter::gain_dexterity( int64_t dexterity_ ) {
+ dexterity += dexterity_;
+}
+
+void
+Ccharacter::gain_strength( int64_t strength_ ) {
+ strength += strength_;
+}
+
+
+void
+Ccharacter::gain_intelligence( int64_t intelligence_ ) {
+ intelligence += intelligence_;
+}
+
+
+void
+Ccharacter::gain_luck( int16_t luck_ ) {
+ luck += luck_;
+}
+
+
+bool
+Ccharacter::is_dead() {
+ return dead;
+}
+
+
+int32_t
+Ccharacter::get_combat_ability() {
+ return combat_ability;
+}
+
+
+int32_t
+Ccharacter::get_armor() {
+ return armor;
+}
+
+
+void
+Ccharacter::gain_armor( int32_t armor_ ) {
+ armor += armor_;
+}
+
+
+int32_t
+Ccharacter::get_speed() {
+ return speed;
+}
+
+
+void
+Ccharacter::gain_speed( int32_t speed_ ) {
+ speed += speed_;
+}
+
+void
+Ccharacter::set_age( int16_t age_ ) {
+ age = age_;
+}
+
+
+int32_t
+Ccharacter::get_max_load() {
+ return max_load;
+}
+
+
+void
+Ccharacter::set_max_load( int32_t max_load_ ) {
+ max_load = max_load_;
+}
+
View
82 character.h
@@ -32,33 +32,75 @@ enum Eraces {
grizzly = 4,
cave_troll = 25
- // ... dla kazdego przeciez klasy nie bede robil bo sie za*.*ie
};
class Ccharacter {
-public:
- Ccharacter( std::string new_name = "Zbigniew Zolc" ); //domyslnie tworzony jest czlowiek
- Ccharacter( Eraces born_race, std::string new_name = "Zbigniew Zolc" ); //podajemy rase postaci
- ~Ccharacter();
- bool dead;
- void kill();
- std::string name; //imie/nazwa postaci
- int64_t
- base_health,
+private:
+ bool dead; // is character alive?
+ std::string name; // character's name
+ Csoul* soul; // player's soul, when NULL then it's npc
+ Eraces race;
+ Citem* items[50];
+ Citem* private_box[250];
+ uint64_t gold;
+ uint32_t age;
+ int16_t luck; // luck could be negative
+
+protected:
+ int32_t
health,
intelligence,
strength,
dexterity,
- mind_strength;//cechy postaci
- uint64_t gold;
- uint32_t age; // wiek postaci
- int16_t luck; //szczescie moze byc -
- Ccoordinates position; //pozycja postaci w swiecie
- Csoul soul; // aktualna dusza :}
- Eraces race;
- Citem* items[50];
- Citem* private_box[250];
-}; //obiekt npc'a/ postaci gracza/ potwora
+ mind_strength, // character attributes
+ combat_ability, // const => born ability
+ speed, // const => born ability
+ armor,
+ max_load;
+ Ccoordinates position; // character's position
+
+public:
+ Ccharacter( std::string new_name = "A man" ); //domyslnie tworzony jest czlowiek
+ Ccharacter( Eraces born_race, std::string new_name = "A man" ); //podajemy rase postaci
+ ~Ccharacter();
+
+ void kill();
+ int32_t get_health();
+ std::string get_name();
+ uint32_t get_intelligence();
+ uint32_t get_strength();
+ uint32_t get_dexterity();
+ int32_t get_mind_strength();
+ int64_t get_gold();
+ uint32_t get_age();
+ int32_t get_max_load();
+ int16_t get_luck();
+ int32_t get_combat_ability();
+ int32_t get_armor();
+ int32_t get_speed();
+ Ccoordinates get_position();
+ Csoul* get_soul();
+ Eraces get_race();
+ Citem get_item( uint8_t item_number_ );
+
+ void gain_speed( int32_t speed_ );
+ void set_age( int16_t age_ );
+ void set_soul( Csoul* soul_ );
+ void set_max_load( int32_t max_load_ );
+ void gain_armor( int32_t armor_ );
+ void gain_health( int32_t damage_ ); // get hurt or get heal
+ void gain_gold( int64_t gold_amount_ ); // could be negative
+ void gain_item( Citem* item_ ); // player is taking an item
+ void throw_item( Citem* item_ ); // player is throwing away an item
+ void gain_dexterity( int64_t dexterity_ );
+ void gain_strength( int64_t strength_ );
+ void gain_intelligence( int64_t intelligence_ );
+ void gain_luck( int16_t luck_ );
+ void set_position( Ccoordinates position_ );
+ bool is_dead();
+
+}; // player/ npc/ character
#endif //_CCHARACTER_H_
+
View
11 crealis.kpf
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Komodo Project File - DO NOT EDIT -->
-<project id="8cb9c3ff-8e71-433e-9447-85457cc4bb50" kpf_version="4" name="crealis.kpf">
-<preference-set idref="8cb9c3ff-8e71-433e-9447-85457cc4bb50">
- <string id="import_exclude_matches">*.world;compile.log;test_*;crealis;*.o;world;.git*;*.so;*.os;*.out;.gitignore;.sconsign.dblite;*.*~;*.bak;*.tmp;CVS;.#*;*.pyo;*.pyc;.svn;*%*;tmp*.html;.DS_Store</string>
- <string id="import_include_matches"></string>
- <boolean id="import_live">1</boolean>
- <boolean id="import_recursive">1</boolean>
- <string id="import_type">useFolders</string>
-</preference-set>
-</project>
View
52 docs/uml.umbrello
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<XMI verified="false" xmi.version="1.2" timestamp="2008-08-27T20:11:41" xmlns:UML="http://schema.omg.org/spec/UML/1.3" >
+<XMI verified="false" xmi.version="1.2" timestamp="2008-08-28T17:05:38" xmlns:UML="http://schema.omg.org/spec/UML/1.3" >
<XMI.header>
<XMI.documentation>
<XMI.exporter>umbrello uml modeller http://uml.sf.net</XMI.exporter>
@@ -36,7 +36,6 @@
<UML:Class visibility="public" isSpecification="false" namespace="Logical View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="tCe2e1u8P0ch" name="Ccharacter" >
<UML:Classifier.feature>
<UML:Attribute visibility="private" isSpecification="false" xmi.id="xtBzawXAp821" type="rQ8DQ6s5nyk0" name="health" />
- <UML:Attribute visibility="private" isSpecification="false" xmi.id="i8GVFIUxK8jJ" type="rQ8DQ6s5nyk0" name="base_health" />
<UML:Attribute visibility="private" isSpecification="false" xmi.id="Go2jcUQI52pp" type="G56YHg2flODS" name="race" />
<UML:Attribute visibility="private" isSpecification="false" xmi.id="5UW5B8acOdeD" type="rQ8DQ6s5nyk0" name="inteligence" />
<UML:Attribute visibility="private" isSpecification="false" xmi.id="pdNhMwHMQiZ6" type="rQ8DQ6s5nyk0" name="strength" />
@@ -51,6 +50,8 @@
<UML:Attribute visibility="private" isSpecification="false" xmi.id="trPQi3K1Yfkz" type="0cBO9TiucYtf" name="position" />
<UML:Attribute visibility="private" isSpecification="false" xmi.id="3N2oXPv5SVzz" type="k91L3LzJfBBj" name="soul" />
<UML:Attribute visibility="private" isSpecification="false" xmi.id="6u6DSAjMtzDM" type="zN3LjlYu80JL" name="name" />
+ <UML:Attribute visibility="private" isSpecification="false" xmi.id="tz6t8ycOFCh3" type="rQ8DQ6s5nyk0" name="combat_ability" />
+ <UML:Attribute visibility="private" isSpecification="false" xmi.id="T4RYHUeNEFzM" type="rQ8DQ6s5nyk0" name="armor" />
<UML:Operation visibility="public" isSpecification="false" isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="I7WsaR7Ph2AE" name="kill" />
</UML:Classifier.feature>
</UML:Class>
@@ -145,18 +146,18 @@
</UML:Namespace.ownedElement>
<XMI.extension xmi.extender="umbrello" >
<diagrams>
- <diagram showopsig="1" linecolor="#ff0000" snapx="10" showattribassocs="1" snapy="10" linewidth="0" showattsig="1" showpackage="1" showstereotype="1" name="class diagram" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" canvasheight="686" canvaswidth="1125" localid="" snapcsgrid="0" showgrid="1" showops="1" usefillcolor="1" fillcolor="#ffff00" zoom="100" xmi.id="r0GYrJUA6CB2" documentation="" showscope="1" snapgrid="1" showatts="1" type="1" >
+ <diagram showopsig="1" linecolor="#ff0000" snapx="10" showattribassocs="1" snapy="10" linewidth="0" showattsig="1" showpackage="1" showstereotype="1" name="class diagram" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" canvasheight="686" canvaswidth="1122" localid="" snapcsgrid="0" showgrid="1" showops="1" usefillcolor="1" fillcolor="#ffff00" zoom="100" xmi.id="r0GYrJUA6CB2" documentation="" showscope="1" snapgrid="1" showatts="1" type="1" >
<widgets>
- <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="320" showattsigs="601" showstereotype="1" y="180" showattributes="1" font="DejaVu Sans,9,-1,5,75,0,0,0,0,0" width="171" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="tCe2e1u8P0ch" showscope="1" height="288" showopsigs="601" />
+ <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="320" showattsigs="601" showstereotype="1" y="180" showattributes="1" font="DejaVu Sans,9,-1,5,75,0,0,0,0,0" width="171" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="tCe2e1u8P0ch" showscope="1" height="304" showopsigs="601" />
<enumwidget width="124" showstereotype="1" x="590" y="30" usesdiagramusefillcolor="0" usesdiagramfillcolor="0" isinstance="0" fillcolor="#ffff00" height="176" linecolor="#ff0000" xmi.id="G56YHg2flODS" showpackage="1" usefillcolor="1" linewidth="none" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" />
<classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="10" showattsigs="601" showstereotype="1" y="500" showattributes="1" font="DejaVu Sans,9,-1,5,50,0,0,0,0,0" width="181" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="0cBO9TiucYtf" showscope="1" height="56" showopsigs="601" />
- <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="320" showattsigs="601" showstereotype="1" y="520" showattributes="1" font="DejaVu Sans,9,-1,5,75,0,0,0,0,0" width="171" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="k91L3LzJfBBj" showscope="1" height="136" showopsigs="601" />
- <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="130" showattsigs="601" showstereotype="1" y="20" showattributes="1" font="DejaVu Sans,9,-1,0,75,0,0,0,0,0" width="135" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="4YkJy1ztGeMJ" showscope="1" height="88" showopsigs="601" />
+ <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="320" showattsigs="601" showstereotype="1" y="520" showattributes="1" font="DejaVu Sans,9,-1,5,50,0,0,0,0,0" width="171" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="k91L3LzJfBBj" showscope="1" height="136" showopsigs="601" />
+ <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="130" showattsigs="601" showstereotype="1" y="20" showattributes="1" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" width="135" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="4YkJy1ztGeMJ" showscope="1" height="88" showopsigs="601" />
<enumwidget width="106" showstereotype="1" x="650" y="400" usesdiagramusefillcolor="0" usesdiagramfillcolor="0" isinstance="0" fillcolor="#ffff00" height="160" linecolor="#ff0000" xmi.id="MhkOSNApyEbI" showpackage="1" usefillcolor="1" linewidth="none" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" />
<enumwidget width="111" showstereotype="1" x="40" y="200" usesdiagramusefillcolor="0" usesdiagramfillcolor="0" isinstance="0" fillcolor="#ffff00" height="144" linecolor="#ff0000" xmi.id="C5NImQHPYgAi" showpackage="1" usefillcolor="1" linewidth="none" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" />
<enumwidget width="122" showstereotype="1" x="830" y="30" usesdiagramusefillcolor="0" usesdiagramfillcolor="0" isinstance="0" fillcolor="#ffff00" height="160" linecolor="#ff0000" xmi.id="sJSQ0uZ8hFV5" showpackage="1" usefillcolor="1" linewidth="none" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" />
- <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="810" showattsigs="601" showstereotype="1" y="310" showattributes="1" font="DejaVu Sans,9,-1,5,75,0,0,0,0,0" width="149" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="ZBCH8BoTCJXm" showscope="1" height="112" showopsigs="601" />
- <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="820" showattsigs="601" showstereotype="1" y="610" showattributes="1" font="DejaVu Sans,9,-1,5,75,0,0,0,0,0" width="136" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="JSrn4FxrF26n" showscope="1" height="72" showopsigs="601" />
+ <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="810" showattsigs="601" showstereotype="1" y="310" showattributes="1" font="DejaVu Sans,9,-1,5,50,0,0,0,0,0" width="149" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="ZBCH8BoTCJXm" showscope="1" height="112" showopsigs="601" />
+ <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="820" showattsigs="601" showstereotype="1" y="610" showattributes="1" font="DejaVu Sans,9,-1,5,50,0,0,0,0,0" width="136" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="JSrn4FxrF26n" showscope="1" height="72" showopsigs="601" />
</widgets>
<messages/>
<associations>
@@ -166,82 +167,82 @@
<endpoint endx="590" endy="190" />
<point x="530" y="190" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="550" showstereotype="1" y="190" text="race" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="40" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="wULp5vsugHb2" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="550" showstereotype="1" y="190" text="race" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="40" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="E4hTqMhUS5eM" height="20" />
</assocwidget>
<assocwidget indexa="2" indexb="1" visibilityA="0" widgetaid="tCe2e1u8P0ch" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="3" xmi.id="trPQi3K1Yfkz" changeabilityB="900" widgetbid="0cBO9TiucYtf" totalcountb="2" type="510" linewidth="none" >
<linepath>
- <startpoint startx="320" starty="470" />
+ <startpoint startx="320" starty="480" />
<endpoint endx="190" endy="500" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="200" showstereotype="1" y="480" text="position" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="62" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="I0h9y9YiBdO9" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="200" showstereotype="1" y="476" text="position" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="62" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="8Khc36Dk8FkD" height="20" />
</assocwidget>
<assocwidget indexa="1" indexb="1" visibilityA="0" widgetaid="tCe2e1u8P0ch" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="2" xmi.id="3N2oXPv5SVzz" changeabilityB="900" widgetbid="k91L3LzJfBBj" totalcountb="2" type="510" linewidth="none" >
<linepath>
- <startpoint startx="450" starty="470" />
+ <startpoint startx="450" starty="480" />
<endpoint endx="450" endy="520" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="410" showstereotype="1" y="500" text="soul" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="38" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="7Jhau5boavdd" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="410" showstereotype="1" y="500" text="soul" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="38" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="Rvayd6Lp82Ix" height="20" />
</assocwidget>
<assocwidget indexa="1" indexb="1" visibilityA="0" widgetaid="tCe2e1u8P0ch" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="2" xmi.id="84mZhMPfwGNO" changeabilityB="900" widgetbid="4YkJy1ztGeMJ" totalcountb="2" type="510" linewidth="none" >
<linepath>
<startpoint startx="410" starty="180" />
<endpoint endx="270" endy="60" />
<point x="410" y="60" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="290" showstereotype="1" y="60" text="private_box" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="83" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="oWXSl6U17C83" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="290" showstereotype="1" y="60" text="private_box" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="83" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="MyRp15B9NqlO" height="20" />
</assocwidget>
<assocwidget indexa="1" indexb="2" visibilityA="0" widgetaid="tCe2e1u8P0ch" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="3" xmi.id="8bmzFJX4Rfcq" changeabilityB="900" widgetbid="4YkJy1ztGeMJ" totalcountb="3" type="510" linewidth="none" >
<linepath>
<startpoint startx="320" starty="180" />
<endpoint endx="270" endy="110" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="270" showstereotype="1" y="110" text="items" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="46" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="JhlUK9dPQI0I" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="270" showstereotype="1" y="110" text="items" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="46" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="uy82BqEcmoaP" height="20" />
</assocwidget>
<assocwidget indexa="1" indexb="1" visibilityA="0" widgetaid="k91L3LzJfBBj" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="3" xmi.id="ZcDcRm9d3KTw" changeabilityB="900" widgetbid="MhkOSNApyEbI" totalcountb="2" type="510" linewidth="none" >
<linepath>
<startpoint startx="490" starty="550" />
<endpoint endx="650" endy="550" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="580" showstereotype="1" y="550" text="alignment" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="74" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="NZ6vUjZGF4jy" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="580" showstereotype="1" y="550" text="alignment" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="74" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="swC1wVwJRN6S" height="20" />
</assocwidget>
<assocwidget indexa="1" indexb="1" visibilityA="0" widgetaid="4YkJy1ztGeMJ" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="3" xmi.id="21wO7KOIdvc3" changeabilityB="900" widgetbid="C5NImQHPYgAi" totalcountb="2" type="510" linewidth="none" >
<linepath>
<startpoint startx="150" starty="110" />
<endpoint endx="150" endy="200" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="60" showstereotype="1" y="180" text="size_of_item" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="86" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="BB0GN8Jen466" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="60" showstereotype="1" y="180" text="size_of_item" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="86" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="QFZo5KCzHJzQ" height="20" />
</assocwidget>
- <assocwidget indexa="2" indexb="1" visibilityA="0" widgetaid="ZBCH8BoTCJXm" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="2" xmi.id="cIWbsVTzPbio" changeabilityB="900" widgetbid="sJSQ0uZ8hFV5" totalcountb="2" type="510" linewidth="none" >
+ <assocwidget indexa="1" indexb="1" visibilityA="0" widgetaid="ZBCH8BoTCJXm" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="2" xmi.id="cIWbsVTzPbio" changeabilityB="900" widgetbid="sJSQ0uZ8hFV5" totalcountb="2" type="510" linewidth="none" >
<linepath>
<startpoint startx="830" starty="310" />
<endpoint endx="830" endy="190" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="790" showstereotype="1" y="190" text="type" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="39" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="BjTZzTrL1xGV" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="790" showstereotype="1" y="190" text="type" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="39" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="9D1v1bIsVVrQ" height="20" />
</assocwidget>
<assocwidget indexa="1" indexb="2" visibilityA="0" widgetaid="ZBCH8BoTCJXm" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="2" xmi.id="XEl9uZUkkrZP" changeabilityB="900" widgetbid="tCe2e1u8P0ch" totalcountb="3" type="510" linewidth="none" >
<linepath>
<startpoint startx="810" starty="370" />
<endpoint endx="490" endy="370" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="490" showstereotype="1" y="370" text="actors[]" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="62" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="gnmusTs1esH0" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="490" showstereotype="1" y="370" text="actors[]" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="62" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="0nhPAnra0QM5" height="20" />
</assocwidget>
<assocwidget indexa="2" indexb="1" visibilityA="0" widgetaid="k91L3LzJfBBj" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="3" xmi.id="faklhwVMsCIf" changeabilityB="900" widgetbid="JSrn4FxrF26n" totalcountb="2" type="510" linewidth="none" >
<linepath>
<startpoint startx="490" starty="620" />
<endpoint endx="820" endy="620" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="760" showstereotype="1" y="624" text="spells[]" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="58" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="zaekclqnSKKS" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="760" showstereotype="1" y="620" text="spells[]" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="58" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="iX2xq1OzFPvE" height="20" />
</assocwidget>
<assocwidget indexa="1" indexb="1" visibilityA="0" widgetaid="k91L3LzJfBBj" visibilityB="0" linecolor="none" changeabilityA="900" totalcounta="2" xmi.id="bWMnMSCjoMGA" changeabilityB="900" widgetbid="0cBO9TiucYtf" totalcountb="2" type="510" linewidth="none" >
<linepath>
<startpoint startx="320" starty="530" />
<endpoint endx="190" endy="530" />
</linepath>
- <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="190" showstereotype="1" y="530" text="position" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="62" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="lBnm81Gop0ih" height="20" />
+ <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="190" showstereotype="1" y="530" text="position" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" pretext="-" role="710" width="62" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="yB6SgvseiZ3q" height="20" />
</assocwidget>
</associations>
</diagram>
- <diagram showopsig="1" linecolor="#ff0000" snapx="10" showattribassocs="1" snapy="10" linewidth="0" showattsig="1" showpackage="1" showstereotype="1" name="fight activity diagram" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" canvasheight="665" canvaswidth="1142" localid="" snapcsgrid="0" showgrid="1" showops="1" usefillcolor="1" fillcolor="#ffff00" zoom="100" xmi.id="yuoGMsXnflaJ" documentation="" showscope="1" snapgrid="1" showatts="1" type="6" >
+ <diagram showopsig="1" linecolor="#ff0000" snapx="10" showattribassocs="1" snapy="10" linewidth="0" showattsig="1" showpackage="1" showstereotype="1" name="fight activity diagram" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" canvasheight="652" canvaswidth="1137" localid="" snapcsgrid="0" showgrid="1" showops="1" usefillcolor="1" fillcolor="#ffff00" zoom="100" xmi.id="yuoGMsXnflaJ" documentation="" showscope="1" snapgrid="1" showatts="1" type="6" >
<widgets>
<activitywidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="310" showstereotype="1" y="60" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" width="20" isinstance="0" usefillcolor="1" fillcolor="none" activityname="" xmi.id="yseFoY33suad" postcondition="" documentation="" activitytype="0" height="20" precondition="" />
<activitywidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="310" showstereotype="1" y="510" font="DejaVu Sans,9,-1,0,50,0,0,0,0,0" width="19" isinstance="0" usefillcolor="1" fillcolor="none" activityname="" xmi.id="XJEo9Ene6bR0" postcondition="" documentation="" activitytype="2" height="19" precondition="" />
@@ -325,7 +326,7 @@
</UML:Model>
</XMI.content>
<XMI.extensions xmi.extender="umbrello" >
- <docsettings viewid="yuoGMsXnflaJ" uniqueid="47cDNUQq0OOs" documentation="" />
+ <docsettings viewid="r0GYrJUA6CB2" uniqueid="T4RYHUeNEFzM" documentation="" />
<listview>
<listitem open="1" type="800" label="Views" >
<listitem open="1" type="801" id="Logical View" >
@@ -341,7 +342,6 @@
</listitem>
<listitem open="1" type="813" id="tCe2e1u8P0ch" >
<listitem open="0" type="814" id="xtBzawXAp821" />
- <listitem open="0" type="814" id="i8GVFIUxK8jJ" />
<listitem open="0" type="814" id="Go2jcUQI52pp" />
<listitem open="0" type="814" id="5UW5B8acOdeD" />
<listitem open="0" type="814" id="pdNhMwHMQiZ6" />
@@ -356,6 +356,8 @@
<listitem open="0" type="814" id="trPQi3K1Yfkz" />
<listitem open="0" type="814" id="3N2oXPv5SVzz" />
<listitem open="0" type="814" id="6u6DSAjMtzDM" />
+ <listitem open="0" type="814" id="tz6t8ycOFCh3" />
+ <listitem open="0" type="814" id="T4RYHUeNEFzM" />
<listitem open="0" type="815" id="I7WsaR7Ph2AE" />
</listitem>
<listitem open="1" type="813" id="0cBO9TiucYtf" >
View
29 job.cpp
@@ -22,7 +22,8 @@ Job::~Job() {
actors[ 1 ] = NULL;
}
-void Job::run() {
+void
+Job::run() {
#ifdef DEBUG
std::cout << "R";
std::cout.flush();
@@ -32,7 +33,7 @@ void Job::run() {
case action_IDLE:
#ifdef DEBUG
std::cout << "I:" << action_IDLE;
- std::cout << this->actors[ 0 ]->name << ":" << this->actors[ 0 ]->health; // self only
+ std::cout << this->actors[ 0 ]->get_name << ":" << this->actors[ 0 ]->health; // self only
std::cout.flush();
#endif
break;
@@ -53,56 +54,56 @@ void Job::run() {
// std::cout.flush();
#endif
//if ( this->actors[ 1 ] == ) break; // attack with no target? always must be attacker and someone to attack to
- if ( this->actors[ 0 ]->health <= 0 ) {
+ if ( this->actors[ 0 ]->get_health() <= 0 ) {
#ifdef DEBUG
std::cout << "A(0)h:0 ";
std::cout.flush();
#endif
break;
}
- if ( this->actors[ 0 ]->health <= 0 ) {
+ if ( this->actors[ 0 ]->get_health() <= 0 ) {
#ifdef DEBUG
std::cout << "A(1)h:0 ";
std::cout.flush();
#endif
break;
}
- if ( this->actors[ 0 ]->dead ) {
+ if ( this->actors[ 0 ]->is_dead() ) {
#ifdef DEBUG
std::cout << "#KDD, "; // killing a dead
- std::cout << this->actors[ 0 ]->name << ":" << this->actors[ 0 ]->health; // self only
+ std::cout << this->actors[ 0 ]->get_name() << ":" << this->actors[ 0 ]->get_health(); // self only
std::cout.flush();
#endif
break;
}
- if ( this->actors[ 1 ]->dead ) {
+ if ( this->actors[ 1 ]->is_dead() ) {
#ifdef DEBUG
std::cout << "#KDD, "; // killing a dead
- std::cout << this->actors[ 1 ]->name << ":" << this->actors[ 1 ]->health; // self only
+ std::cout << this->actors[ 1 ]->get_name() << ":" << this->actors[ 1 ]->get_health(); // self only
std::cout.flush();
#endif
break;
}
- this->actors[ 0 ]->health -= 1; // first is always attacking player
- this->actors[ 1 ]->health -= this->actors[ 0 ]->strength; // always attacking at least one target
- if ( this->actors[ 0 ]->health <= 0 ) {
+ this->actors[ 0 ]->gain_health( -1 ); // first is always attacking player, and every attack costs 1hp
+ this->actors[ 1 ]->gain_health( this->actors[ 0 ]->get_strength() ); // always attacking at least one target
+ if ( this->actors[ 0 ]->get_health() <= 0 ) {
this->actors[ 0 ]->kill();
#ifdef DEBUG
std::cout << "DEAD0";
std::cout.flush();
#endif
}
- if ( this->actors[ 1 ]->health <= 0 ) {
+ if ( this->actors[ 1 ]->get_health() <= 0 ) {
this->actors[ 1 ]->kill();
#ifdef DEBUG
std::cout << "DEAD1";
std::cout.flush();
#endif
}
#ifdef DEBUG
- std::cout << " A=>" << this->actors[ 0 ]->health << ", "; // << std::endl;
- std::cout << " B=>" << this->actors[ 1 ]->health << ", "; // << std::endl;
+ std::cout << " A=>" << this->actors[ 0 ]->get_health() << ", "; // << std::endl;
+ std::cout << " B=>" << this->actors[ 1 ]->get_health() << ", "; // << std::endl;
std::cout.flush();
#endif
View
8 main.h → serialized.h
@@ -1,5 +1,5 @@
-#ifndef _MAIN_H
-#define _MAIN_H
+#ifndef _SERIALIZED_H
+#define _SERIALIZED_H
#include <iostream>
#include <fstream>
@@ -11,7 +11,6 @@
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/filesystem/operations.hpp>
-#include <signal.h>
#include "job.h"
#include "config.h"
@@ -72,8 +71,9 @@ namespace serialization {
template<class Archive>
void serialize(Archive & ar, Ccharacter & ch, const unsigned int version) {
- ar & ch.base_health;
ar & ch.dead;
+ ar & ch.armor;
+ ar & ch.combat_ability;
ar & ch.health;
ar & ch.intelligence;
ar & ch.strength;
View
17 tests/Valgrind_test
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-# --trace-malloc=yes \
-
-valgrind \
- -v \
- --tool=memcheck \
- --log-file=test_serialization2-valgrind-`date +%F_%R`.log \
- --leak-check=yes \
- --error-limit=no \
- --demangle=yes \
- --num-callers=20 \
- --track-fds=yes \
- --trace-children=yes \
- --show-reachable=yes \
- ./test_thread_synchronization_2 "$@"
-
View
20 main2.cpp → tests/fight_test.cpp
@@ -31,7 +31,7 @@ load_world( Cworld world, std::string filename ) {
int
main() {
Ccharacter* characters = new Ccharacter[ 100 ];
- characters[ 0 ].health = 0;
+ //characters[ 0 ].get_health() = 0;
uint64_t timer = 0;
boost::asio::io_service io;
@@ -40,25 +40,25 @@ main() {
for ( int i = 0; i < 50000; i++ ) {
//set bright red ANSI color in console
printf("%c[%d;%d;%dm", 0x1B, BRIGHT, RED, BG_BLACK);
- cout << "(A#):" << characters[ 0 ].health << "-";
- characters[ 0 ].health += 1;
- cout << characters[ 0 ].health;
+ cout << "(A#):" << characters[ 0 ].get_health() << "-";
+ characters[ 0 ].gain_health( -1 );
+ cout << characters[ 0 ].get_health();
//reset ANSI code to default:
printf("%c[%dm", 0x1B, 0);
cout << flush;
}
for ( int i = 0; i < 50000; i++ ) {
printf("%c[%d;%d;%dm", 0x1B, BRIGHT, GREEN, BG_BLACK);
- cout << "(B#):" << characters[ 0 ].health<< "-";;
- characters[ 0 ].health += 1;
- cout << characters[ 0 ].health;
+ cout << "(B#):" << characters[ 0 ].get_health() << "-";;
+ characters[ 0 ].gain_health( 1 );
+ cout << characters[ 0 ].get_health();
printf("%c[%dm", 0x1B, 0);
cout << flush;
}
for ( int i = 0; i < 50000; i++ ) {
- cout << "(C#):" << characters[ 0 ].health<< "-";;
- characters[ 0 ].health += 1;
- cout << characters[ 0 ].health << flush;
+ cout << "(C#):" << characters[ 0 ].get_health() << "-";;
+ characters[ 0 ].gain_health( 1 );
+ cout << characters[ 0 ].get_health() << flush;
}
delete[] characters;
View
0 main.cpp → tests/fight_test_1.cpp
File renamed without changes.
View
0 tests/test_podglad_pracy_watkow.cpp → tests/ncurses_thread_monitor_test.cpp
File renamed without changes.
View
90 tests/serialization_test.cpp
@@ -23,58 +23,9 @@
#include "../item.h"
#include "../character.h"
#include "../world.h"
+//
+//#include "../serialized.h"
-namespace boost {
-namespace serialization {
- template<class Archive>
- void serialize(Archive & ar, Cworld & world, const unsigned int version) {
- ar & world.x_theritory_size;
- ar & world.y_theritory_size;
- ar & world.gravity; //grawitacja
- ar & world.name;
- ar & world.cl_version; //wersja swiata. od tego zaleza ew niekompatybilnosci
- } // namespace serialization
-
- template<class Archive>
- void serialize(Archive & ar, Citem & item, const unsigned int version) {
- ar & item.weight;
- ar & item.size_of_item;
- } // namespace serialization
-
- template<class Archive>
- void serialize(Archive & ar, Ccoordinates & pos, const unsigned int version) {
- ar & pos.position;
- ar & pos.parent_positions;
- } // namespace serialization
-
- template<class Archive>
- void serialize(Archive & ar, Csoul & soul, const unsigned int version) {
- ar & soul.mind_strength;
- ar & soul.mana;
- ar & soul.alignment;
- ar & soul.soul_exist; // czy istnieje dusza czy nie
- } // namespace serialization
-
- template<class Archive>
- void serialize(Archive & ar, Ccharacter & ch, const unsigned int version) {
- ar & ch.base_health;
- ar & ch.dead;
- ar & ch.health;
- ar & ch.intelligence;
- ar & ch.strength;
- ar & ch.dexterity;
- ar & ch.mind_strength;//cechy postaci
- ar & ch.age; // wiek postaci
- ar & ch.luck; //szczescie moze byc -
- ar & ch.soul;
- ar & ch.gold;
- ar & ch.position;
- ar & ch.items;
- ar & ch.private_box;
- ar & ch.race;
- } // namespace serialization
- } // namespace boost
-}
int main() {
// create and open a character archive for output
@@ -103,46 +54,47 @@ int main() {
// create class instance
Ccharacter g;
Ccoordinates position;
- g.position = position;
+ g.set_position( position );
Citem item;
- Csoul soul;
+ Csoul* soul = new Csoul();
item.weight = 5;
- soul.mana = 666;
- g.age = 12;
- g.gold = 0;
- g.soul = soul;
- g.items[0] = &item;
+ soul->mana = 666;
+ g.set_age( 12 );
+ g.gain_gold( 10000 );
+ g.set_soul( soul );
+ //g.items[0] = &item;
item.weight = 7;
- g.private_box[0] = &item;
+ //g.private_box[0] = &item;
// std::cout << g.items.size();
// save data to archive
{
- boost::archive::binary_oarchive oa( ofs, 1 );
+ // boost::archive::binary_oarchive oa( ofs, 1 );
// write class instance to archive
- oa << g;
+ // oa << g;
// archive and stream closed when destructors are called
}
// ... some time later restore the class instance to its orginal state
- Ccharacter newg;
+ // Ccharacter newg;
{
// create and open an archive for input
- std::ifstream ifs("test_character_serialized");
- boost::archive::binary_iarchive ia( ifs, 1 );
+ // std::ifstream ifs("test_character_serialized");
+ // boost::archive::binary_iarchive ia( ifs, 1 );
//boost::archive::text_iarchive ia( ofs );
// read class state from archive
- ia >> newg;
- std::cout << "x: " << newg.soul.mana << std::endl;
- std::cout << "y: " << newg.gold << std::endl;
- std::cout << "z: " << newg.items[0]->weight << std::endl;
- std::cout << "p: " << newg.private_box[0]->weight << std::endl;
+ // ia >> newg;
+ std::cout << "x: " << g.get_soul()->mana << std::endl;
+ std::cout << "y: " << g.get_gold() << std::endl;
+ //std::cout << "z: " << newg.items[0]->weight << std::endl;
+ //std::cout << "p: " << newg.private_box[0]->weight << std::endl;
for ( int i = 0; i < 6; ++i ) {
std::cout << i << ": " << position.parent_positions[ i ] << std::endl;
}
// newg.items.begin();
// archive and stream closed when destructors are called
}
+ delete soul;
return 0;
}
View
25 tests/thread_group_test.cpp
@@ -0,0 +1,25 @@
+// Copyright (C) 2001-2003
+// William E. Kempf
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/thread/thread.hpp>
+#include <iostream>
+
+int count = 0;
+boost::mutex mutex;
+
+void increment_count()
+{
+ boost::mutex::scoped_lock lock(mutex);
+ std::cout << "count = " << ++count << std::endl;
+}
+
+int main(int argc, char* argv[])
+{
+ boost::thread_group threads;
+ for (int i = 0; i < 10; ++i)
+ threads.create_thread(&increment_count);
+ threads.join_all();
+}

0 comments on commit c98b1c1

Please sign in to comment.
Something went wrong with that request. Please try again.