[escape-from-the-masters-lair] push by DarkOppr...@gmail.com - Added highscores. on 2011-04-18 09:59 GMT

1 view
Skip to first unread message

escape-from-th...@googlecode.com

unread,
Apr 18, 2011, 6:01:10 AM4/18/11
to escape-from-th...@googlegroups.com
Revision: dfe045b134da
Author: Kevin Wells <DarkOp...@gmail.com>
Date: Mon Apr 18 02:59:47 2011
Log: Added highscores.
http://code.google.com/p/escape-from-the-masters-lair/source/detail?r=dfe045b134da

Added:
/highscore.cpp
/highscore.h
Modified:
/Development/To Do.rtf
/Escape from the Master's Lair.cbp
/Escape from the Master's Lair.layout
/Escape from the Master's Lair.layout.save
/player.h
/player_scores.cpp
/player_windows.cpp
/update.cpp
/version.h

=======================================
--- /dev/null
+++ /highscore.cpp Mon Apr 18 02:59:47 2011
@@ -0,0 +1,11 @@
+/* Copyright (c) 2011 Kevin Wells */
+/* Escape from the Master's Lair may be freely redistributed. See license
for details. */
+
+#include "highscore.h"
+
+using namespace std;
+
+Highscore::Highscore(){
+ score=0;
+ score_string="";
+}
=======================================
--- /dev/null
+++ /highscore.h Mon Apr 18 02:59:47 2011
@@ -0,0 +1,20 @@
+/* Copyright (c) 2011 Kevin Wells */
+/* Escape from the Master's Lair may be freely redistributed. See license
for details. */
+
+#ifndef highscore_h
+#define highscore_h
+
+#include <string>
+
+class Highscore{
+ private:
+ public:
+
+ unsigned int score;
+
+ std::string score_string;
+
+ Highscore();
+};
+
+#endif
=======================================
--- /Development/To Do.rtf Sun Apr 17 02:37:44 2011
+++ /Development/To Do.rtf Mon Apr 18 02:59:47 2011
@@ -1,11 +1,11 @@
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
-{\*\generator Msftedit
5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl240\slmult1\lang1033\f0\fs22
-Expand the equipping/unequipping/item command related messages.\par
--Implement an action taking multiple turns.\par
--Implement drinking from fountains.\par
+{\*\generator Msftedit
5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl240\slmult1\lang1033\f0\fs22
-Implement an action taking multiple turns.\par
-Allow creatures to drop equipped items with one command.\par
--Add the highscores list.\par
+-Expand the equipping/unequipping/item command related messages.\par
+-Implement drinking from fountains.\par
+\strike -Add the highscores list.\strike0\par
-Handle anything left in the code in comments.\lang9\par
--Make sure everything displays nicely with different resolutions.\par
+\strike -Make sure everything displays nicely with different
resolutions.\strike0\par
-Add random character selection stuff to game startup.\par
\par
AFTER BRANCH:\par
=======================================
--- /Escape from the Master's Lair.cbp Sun Apr 17 01:59:21 2011
+++ /Escape from the Master's Lair.cbp Mon Apr 18 02:59:47 2011
@@ -145,6 +145,8 @@
<Unit filename="game_window.h" />
<Unit filename="grammar.cpp" />
<Unit filename="grammar.h" />
+ <Unit filename="highscore.cpp" />
+ <Unit filename="highscore.h" />
<Unit filename="image.cpp" />
<Unit filename="image.h" />
<Unit filename="image_data.h" />
=======================================
--- /Escape from the Master's Lair.layout Sun Apr 17 02:37:44 2011
+++ /Escape from the Master's Lair.layout Mon Apr 18 02:59:47 2011
@@ -121,6 +121,12 @@
<File name="grammar.h" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="347" topLine="0" />
</File>
+ <File name="highscore.cpp" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="225" topLine="0" />
+ </File>
+ <File name="highscore.h" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="193" topLine="0" />
+ </File>
<File name="image.cpp" open="0" top="0" tabpos="1" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="308" topLine="0" />
</File>
@@ -209,19 +215,19 @@
<Cursor1 position="132" topLine="0" />
</File>
<File name="player.cpp" open="0" top="0" tabpos="6" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="972" topLine="48" />
+ <Cursor1 position="27636" topLine="602" />
</File>
<File name="player.h" open="0" top="0" tabpos="7" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="5158" topLine="163" />
+ <Cursor1 position="1247" topLine="43" />
</File>
<File name="player_scores.cpp" open="0" top="0" tabpos="5" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="5136" topLine="156" />
+ <Cursor1 position="2834" topLine="77" />
</File>
<File name="player_starting_values.h" open="0" top="0" tabpos="0"
split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="196" topLine="0" />
</File>
- <File name="player_windows.cpp" open="1" top="0" tabpos="1" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="43104" topLine="1163" />
+ <File name="player_windows.cpp" open="0" top="0" tabpos="1" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="43004" topLine="1157" />
</File>
<File name="quit.cpp" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="963" topLine="21" />
@@ -247,7 +253,7 @@
<File name="random_number_generator.h" open="0" top="0" tabpos="0"
split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="236" topLine="0" />
</File>
- <File name="render.cpp" open="1" top="0" tabpos="3" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="render.cpp" open="0" top="0" tabpos="3" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="11885" topLine="384" />
</File>
<File name="render.h" open="0" top="0" tabpos="5" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
@@ -266,7 +272,7 @@
<Cursor1 position="242" topLine="0" />
</File>
<File name="templates.cpp" open="0" top="0" tabpos="2" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="6792" topLine="42" />
+ <Cursor1 position="18289" topLine="135" />
</File>
<File name="templates.h" open="0" top="0" tabpos="1" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="2465" topLine="70" />
@@ -295,8 +301,8 @@
<File name="tooltip.h" open="0" top="0" tabpos="15" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="132" topLine="0" />
</File>
- <File name="update.cpp" open="1" top="1" tabpos="2" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="5434" topLine="136" />
+ <File name="update.cpp" open="0" top="0" tabpos="2" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="18564" topLine="405" />
</File>
<File name="update.h" open="0" top="0" tabpos="11" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="249" topLine="0" />
=======================================
--- /Escape from the Master's Lair.layout.save Sat Apr 16 21:44:48 2011
+++ /Escape from the Master's Lair.layout.save Mon Apr 18 02:59:47 2011
@@ -8,7 +8,7 @@
<Cursor1 position="364" topLine="0" />
</File>
<File name="ai.h" open="0" top="0" tabpos="4" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="36" topLine="0" />
+ <Cursor1 position="347" topLine="0" />
</File>
<File name="ai_keys.h" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="707" topLine="13" />
@@ -38,10 +38,10 @@
<Cursor1 position="325" topLine="0" />
</File>
<File name="creature.cpp" open="0" top="0" tabpos="4" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="999" topLine="24" />
+ <Cursor1 position="756" topLine="18" />
</File>
<File name="creature.h" open="0" top="0" tabpos="4" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="3704" topLine="109" />
+ <Cursor1 position="2035" topLine="63" />
</File>
<File name="creature_alchemy.cpp" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="3400" topLine="48" />
@@ -50,7 +50,7 @@
<Cursor1 position="620" topLine="6" />
</File>
<File name="creature_combat.cpp" open="0" top="0" tabpos="7" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="3034" topLine="64" />
+ <Cursor1 position="312" topLine="0" />
</File>
<File name="creature_commands.cpp" open="0" top="0" tabpos="7" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="5518" topLine="144" />
@@ -65,16 +65,16 @@
<Cursor1 position="2518" topLine="56" />
</File>
<File name="creature_save_load.cpp" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="3482" topLine="150" />
+ <Cursor1 position="776" topLine="18" />
</File>
<File name="creature_skills.cpp" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="4380" topLine="126" />
+ <Cursor1 position="2009" topLine="97" />
</File>
<File name="dungeon.h" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="140" topLine="0" />
+ <Cursor1 position="198" topLine="0" />
</File>
<File name="dungeon_generation.cpp" open="0" top="0" tabpos="6" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="31279" topLine="798" />
+ <Cursor1 position="31579" topLine="805" />
</File>
<File name="dungeon_location.cpp" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="235" topLine="0" />
@@ -88,8 +88,8 @@
<File name="effect.h" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="132" topLine="0" />
</File>
- <File name="enumerations.h" open="1" top="0" tabpos="1" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="4831" topLine="276" />
+ <File name="enumerations.h" open="0" top="0" tabpos="1" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="835" topLine="36" />
</File>
<File name="font.cpp" open="0" top="0" tabpos="5" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="1745" topLine="48" />
@@ -104,7 +104,7 @@
<Cursor1 position="818" topLine="29" />
</File>
<File name="game.cpp" open="0" top="0" tabpos="3" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="2207" topLine="80" />
+ <Cursor1 position="5012" topLine="191" />
</File>
<File name="game.h" open="0" top="0" tabpos="4" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="1777" topLine="60" />
@@ -115,6 +115,18 @@
<File name="game_window.h" open="0" top="0" tabpos="3" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="514" topLine="0" />
</File>
+ <File name="grammar.cpp" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="798" topLine="18" />
+ </File>
+ <File name="grammar.h" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="347" topLine="0" />
+ </File>
+ <File name="highscore.cpp" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="225" topLine="0" />
+ </File>
+ <File name="highscore.h" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="193" topLine="0" />
+ </File>
<File name="image.cpp" open="0" top="0" tabpos="1" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="308" topLine="0" />
</File>
@@ -134,16 +146,16 @@
<Cursor1 position="6386" topLine="6" />
</File>
<File name="item_combat.cpp" open="0" top="0" tabpos="1" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="10469" topLine="79" />
+ <Cursor1 position="358" topLine="0" />
</File>
<File name="item_save_load.cpp" open="0" top="0" tabpos="14" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="3653" topLine="162" />
</File>
<File name="item_template.cpp" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="232" topLine="0" />
+ <Cursor1 position="255" topLine="0" />
</File>
<File name="item_template.h" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="296" topLine="0" />
+ <Cursor1 position="460" topLine="0" />
</File>
<File name="level.cpp" open="0" top="0" tabpos="6" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="2385" topLine="185" />
@@ -164,7 +176,7 @@
<Cursor1 position="198" topLine="0" />
</File>
<File name="material_properties.cpp" open="0" top="0" tabpos="1"
split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="390" topLine="12" />
+ <Cursor1 position="2245" topLine="54" />
</File>
<File name="material_properties.h" open="0" top="0" tabpos="0" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="476" topLine="3" />
@@ -179,13 +191,13 @@
<Cursor1 position="255" topLine="0" />
</File>
<File name="monster.cpp" open="0" top="0" tabpos="3" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="2427" topLine="60" />
+ <Cursor1 position="424" topLine="30" />
</File>
<File name="monster.h" open="0" top="0" tabpos="3" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="313" topLine="31" />
</File>
- <File name="monster_ai.cpp" open="1" top="1" tabpos="1" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="2389" topLine="60" />
+ <File name="monster_ai.cpp" open="0" top="0" tabpos="4" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="1896" topLine="52" />
</File>
<File name="monster_ai_states.cpp" open="0" top="0" tabpos="2" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="1747" topLine="33" />
@@ -203,19 +215,19 @@
<Cursor1 position="132" topLine="0" />
</File>
<File name="player.cpp" open="0" top="0" tabpos="6" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="5081" topLine="179" />
+ <Cursor1 position="27636" topLine="602" />
</File>
<File name="player.h" open="0" top="0" tabpos="7" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="3010" topLine="97" />
+ <Cursor1 position="1247" topLine="43" />
</File>
<File name="player_scores.cpp" open="0" top="0" tabpos="5" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="3462" topLine="112" />
+ <Cursor1 position="2834" topLine="77" />
</File>
- <File name="player_starting_gold.h" open="0" top="0" tabpos="1" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="180" topLine="0" />
+ <File name="player_starting_values.h" open="0" top="0" tabpos="0"
split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="196" topLine="0" />
</File>
<File name="player_windows.cpp" open="0" top="0" tabpos="1" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="39449" topLine="1090" />
+ <Cursor1 position="43004" topLine="1157" />
</File>
<File name="quit.cpp" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="963" topLine="21" />
@@ -223,11 +235,11 @@
<File name="quit.h" open="0" top="0" tabpos="0" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="132" topLine="0" />
</File>
- <File name="race.cpp" open="1" top="0" tabpos="5" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="312" topLine="0" />
+ <File name="race.cpp" open="0" top="0" tabpos="2" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="339" topLine="0" />
</File>
- <File name="race.h" open="1" top="0" tabpos="6" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="356" topLine="0" />
+ <File name="race.h" open="0" top="0" tabpos="3" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="666" topLine="9" />
</File>
<File name="random_chance.cpp" open="0" top="0" tabpos="2" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="4101" topLine="164" />
@@ -241,8 +253,8 @@
<File name="random_number_generator.h" open="0" top="0" tabpos="0"
split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="236" topLine="0" />
</File>
- <File name="render.cpp" open="0" top="0" tabpos="4" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="2853" topLine="72" />
+ <File name="render.cpp" open="0" top="0" tabpos="3" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="11885" topLine="384" />
</File>
<File name="render.h" open="0" top="0" tabpos="5" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="648" topLine="16" />
@@ -260,13 +272,13 @@
<Cursor1 position="242" topLine="0" />
</File>
<File name="templates.cpp" open="0" top="0" tabpos="2" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="25599" topLine="420" />
+ <Cursor1 position="18289" topLine="135" />
</File>
<File name="templates.h" open="0" top="0" tabpos="1" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="207" topLine="0" />
+ <Cursor1 position="2465" topLine="70" />
</File>
<File name="templates_strings.cpp" open="0" top="0" tabpos="6" split="0"
active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="7031" topLine="288" />
+ <Cursor1 position="6855" topLine="288" />
</File>
<File name="tile.cpp" open="0" top="0" tabpos="5" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="3899" topLine="96" />
@@ -289,8 +301,8 @@
<File name="tooltip.h" open="0" top="0" tabpos="15" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="132" topLine="0" />
</File>
- <File name="update.cpp" open="0" top="0" tabpos="1" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor1 position="20220" topLine="441" />
+ <File name="update.cpp" open="0" top="0" tabpos="2" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor1 position="18564" topLine="405" />
</File>
<File name="update.h" open="0" top="0" tabpos="11" split="0" active="1"
splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="249" topLine="0" />
=======================================
--- /player.h Sun Apr 17 01:59:21 2011
+++ /player.h Mon Apr 18 02:59:47 2011
@@ -178,6 +178,9 @@

//Saves an entry to the game log for this game.
void save_game_log_entry(short cause_of_death,std::string
killer="",std::string killer_item="",std::string
killer_article="",std::string killer_item_article="");
+
+ //Checks the highscores list, and adds this game if it made it.
+ void save_highscore(std::string score_string);
};

#endif
=======================================
--- /player_scores.cpp Sun Apr 17 01:59:21 2011
+++ /player_scores.cpp Mon Apr 18 02:59:47 2011
@@ -5,6 +5,7 @@
#include "version.h"
#include "dungeon_location.h"
#include "dungeon.h"
+#include "highscore.h"

#include <fstream>
#include <ctime>
@@ -14,9 +15,116 @@
using namespace std;
using namespace boost::algorithm;

+void Player::save_highscore(string score_string){
+ //Load the highscores.
+
+ vector<Highscore> highscores;
+
+ ifstream load("highscores",ifstream::in);
+
+ if(load!=NULL){
+ //As long as we haven't reached the end of the file.
+ while(!load.eof()){
+ string line="";
+
+ //Grab the next line of the file.
+ getline(load,line);
+
+ //Clear initial whitespace from the line.
+ trim(line);
+
+ //If the line begins a highscore entry.
+ if(icontains(line,"<highscore>")){
+ highscores.push_back(Highscore());
+
+ //As long as we haven't reached the end of the file.
+ while(!load.eof()){
+ //Grab the next line of the file.
+ getline(load,line);
+
+ //Clear initial whitespace from the line.
+ trim(line);
+
+ //Score.
+ if(icontains(line,"<score>")){
+ line.erase(0,7);
+
+
highscores[highscores.size()-1].score=atoi(line.c_str());
+ }
+ //Score string.
+ else if(icontains(line,"<score string>")){
+ line.erase(0,14);
+
+ highscores[highscores.size()-1].score_string=line;
+
+ break;
+ }
+ }
+ }
+ }
+
+ load.close();
+ load.clear();
+ }
+ else{
+ fprintf(stderr,"Error loading highscores file.\n");
+ }
+
+ for(int i=0;i<highscores.size();i++){
+ replace_all(highscores[i].score_string,"<NEWLINE>","\n");
+ }
+
+ bool score_inserted=false;
+
+ //Look through all of the highscores.
+ for(int i=0;i<highscores.size();i++){
+ //If the new score is higher than this highscore.
+ if(score>highscores[i].score){
+ highscores.insert(highscores.begin()+i,Highscore());
+ highscores[i].score=score;
+ highscores[i].score_string=score_string;
+ score_inserted=true;
+ break;
+ }
+ }
+
+ if(!score_inserted){
+ highscores.push_back(Highscore());
+ highscores[highscores.size()-1].score=score;
+ highscores[highscores.size()-1].score_string=score_string;
+ }
+
+ //Trim the highscores list to 10 entries.
+ while(highscores.size()>10){
+ highscores.erase(highscores.end());
+ }
+
+ for(int i=0;i<highscores.size();i++){
+ replace_all(highscores[i].score_string,"\n","<NEWLINE>");
+ }
+
+ ofstream save("highscores",ifstream::out);
+
+ if(save!=NULL){
+ for(int i=0;i<highscores.size();i++){
+ save<<"<highscore>\n";
+ save<<"<score>";
+ save<<highscores[i].score;
+ save<<"\n<score string>";
+ save<<highscores[i].score_string;
+ save<<"\n</highscore>\n";
+ }
+ }
+ else{
+ fprintf(stderr,"Error saving highscores file.\n");
+ }
+}
+
void Player::save_game_log_entry(short cause_of_death,string killer,string
killer_item,string killer_article,string killer_item_article){
ofstream save_log("game_log",ifstream::app);

+ stringstream score_string("");
+
if(save_log!=NULL){
time_t now;
struct tm *tm_now;
@@ -117,28 +225,28 @@
score*=2;
}

- save_log<<"name:"<<name<<"\n";
-
save_log<<"version:"<<AutoVersion::MAJOR<<"."<<AutoVersion::MINOR<<"\n";
- save_log<<"score:"<<score<<"\n";
- save_log<<"dungeon level:"<<current_level+1<<"\n";
- save_log<<"highest dungeon level:"<<max_level+1<<"\n";
- save_log<<"experience level:"<<experience_level<<"\n";
-
save_log<<"health:"<<return_health()<<"/"<<return_health_max()<<"\n";
- ///save_log<<"mana:"<<return_mana()<<"/"<<return_mana_max()<<"\n";
- save_log<<"deaths:"<<deaths<<"\n";
- save_log<<"game start:"<<start_date<<" at "<<start_time<<"\n";
- save_log<<"game end:"<<end_date<<" at "<<end_time<<"\n";
- save_log<<"class:"<<class_name<<"\n";
- save_log<<"race:"<<race_name<<"\n";
+ score_string<<"name:"<<name<<"\n";
+
score_string<<"version:"<<AutoVersion::MAJOR<<"."<<AutoVersion::MINOR<<"\n";
+ score_string<<"score:"<<score<<"\n";
+ score_string<<"dungeon level:"<<current_level+1<<"\n";
+ score_string<<"highest dungeon level:"<<max_level+1<<"\n";
+ score_string<<"experience level:"<<experience_level<<"\n";
+
score_string<<"health:"<<return_health()<<"/"<<return_health_max()<<"\n";
+
///score_string<<"mana:"<<return_mana()<<"/"<<return_mana_max()<<"\n";
+ score_string<<"deaths:"<<deaths<<"\n";
+ score_string<<"game start:"<<start_date<<" at "<<start_time<<"\n";
+ score_string<<"game end:"<<end_date<<" at "<<end_time<<"\n";
+ score_string<<"class:"<<class_name<<"\n";
+ score_string<<"race:"<<race_name<<"\n";

/**if(gender==GENDER_MALE){
- save_log<<"gender:male"<<"\n";
+ score_string<<"gender:male"<<"\n";
}
else if(gender==GENDER_FEMALE){
- save_log<<"gender:female"<<"\n";
+ score_string<<"gender:female"<<"\n";
}
else if(gender==GENDER_NEUTRAL){
- save_log<<"gender:neutral"<<"\n";
+ score_string<<"gender:neutral"<<"\n";
}*/

if(cause_of_death==CAUSE_OF_DEATH_MELEE){
@@ -182,18 +290,20 @@

//If the player died.
if(cause_of_death!=CAUSE_OF_DEATH_NONE){
- save_log<<death_message<<"\n";
+ score_string<<death_message<<"\n";
}
//If the player escaped but did not win.
else if(cause_of_death==CAUSE_OF_DEATH_NONE && !won){
- save_log<<"Escaped from the Lair."<<"\n";
+ score_string<<"Escaped from the Lair."<<"\n";
}
//If the player escaped and won.
else if(cause_of_death==CAUSE_OF_DEATH_NONE && won){
- save_log<<"Escaped from the Lair with "<<runestones<<"
Runestones."<<"\n";
+ score_string<<"Escaped from the Lair with "<<runestones<<"
Runestones."<<"\n";
}

- save_log<<"\n\n";
+ score_string<<"\n\n";
+
+ save_log<<score_string.str();

save_log.close();
save_log.clear();
@@ -201,4 +311,6 @@
else{
fprintf(stderr,"Error saving game log entry.\n");
}
-}
+
+ save_highscore(score_string.str());
+}
=======================================
--- /player_windows.cpp Sun Apr 17 02:37:44 2011
+++ /player_windows.cpp Mon Apr 18 02:59:47 2011
@@ -1167,7 +1167,7 @@
font_small.show(170,45,msg,font_color);

ss.clear();ss.str("");ss<<"Adventurer Reclamations
Department";msg=ss.str();
- font_small.show(500,45,msg,font_color);
+ font_small.show(player.option_screen_width-300,45,msg,font_color);

ss.clear();ss.str("");ss<<"Death Certificate";msg=ss.str();

font.show((option_screen_width-msg.length()*font.spacing_x)/2.0,80,msg,font_color);
=======================================
--- /update.cpp Sun Apr 17 02:37:44 2011
+++ /update.cpp Mon Apr 18 02:59:47 2011
@@ -245,11 +245,11 @@
//Render chat stuff:


render_rectangle(0,player.option_screen_height-122,player.option_screen_width,122,1.0,COLOR_GRAY);
-
render_rectangle(2,player.option_screen_height-120,796,118,1.0,COLOR_BLACK);
+
render_rectangle(2,player.option_screen_height-120,player.option_screen_width-4,118,1.0,COLOR_BLACK);

if(player.chat_mode){
-
render_rectangle(2,player.option_screen_height-font_small.spacing_y-6,796,font.spacing_y-4,1.0,COLOR_GRAY);
-
render_rectangle(4,player.option_screen_height-font_small.spacing_y-4,792,font.spacing_y-8,1.0,COLOR_BLACK);
+
render_rectangle(2,player.option_screen_height-font_small.spacing_y-6,player.option_screen_width-4,font.spacing_y-4,1.0,COLOR_GRAY);
+
render_rectangle(4,player.option_screen_height-font_small.spacing_y-4,player.option_screen_width-8,font.spacing_y-8,1.0,COLOR_BLACK);
}

double opacity=1.0;
@@ -294,13 +294,6 @@

font_small.show(4,chat_input_height,"> "+string_input_chat.str1,COLOR_WHITE,1.0);

font_small.show(17+font_small.spacing_x*string_input_chat.str1.length(),chat_input_height,"\x7F",COLOR_WHITE,player.cursor_opacity*0.1);
}
-
- //Display the framerate and milliseconds per frame.
- /**if(player.option_fps){
-
ss.clear();ss.str("");ss<<"FPS: ";ss<<frame_rate;ss<<"\xA";msg=ss.str();
- ss.clear();ss.str("");ss<<"MS Per
Frame: ";ss<<ms_per_frame;msg+=ss.str();
- font_small.show(624,0,msg,COLOR_RED);
- }*/

if(player.option_dev && player.chat_mode){
render_rectangle(0,0,275,225,0.75,COLOR_BLACK);
@@ -419,8 +412,8 @@

int size_last_msg=0;

-
render_rectangle(0,player.option_screen_height-174,800,54,1.0,COLOR_GRAY);
-
render_rectangle(2,player.option_screen_height-172,796,50,1.0,COLOR_BLACK);
+
render_rectangle(0,player.option_screen_height-174,player.option_screen_width,54,1.0,COLOR_GRAY);
+
render_rectangle(2,player.option_screen_height-172,player.option_screen_width-4,50,1.0,COLOR_BLACK);

ss.clear();ss.str("");ss<<player.name;ss<<"
the ";ss<<player.race_name;ss<<" ";ss<<player.class_name;msg=ss.str();

font_small.show(5,player.option_screen_height-170,msg,COLOR_WHITE);
=======================================
--- /version.h Sun Apr 17 02:37:44 2011
+++ /version.h Mon Apr 18 02:59:47 2011
@@ -16,17 +16,17 @@
//Standard Version Type
static const long MAJOR = 0;
static const long MINOR = 2;
- static const long BUILD = 2867;
- static const long REVISION = 15916;
+ static const long BUILD = 2893;
+ static const long REVISION = 16068;

//Miscellaneous Version Types
- static const long BUILDS_COUNT = 6616;
- #define RC_FILEVERSION 0,2,2867,15916
- #define RC_FILEVERSION_STRING "0, 2, 2867, 15916\0"
- static const char FULLVERSION_STRING[] = "0.2.2867.15916";
+ static const long BUILDS_COUNT = 6678;
+ #define RC_FILEVERSION 0,2,2893,16068
+ #define RC_FILEVERSION_STRING "0, 2, 2893, 16068\0"
+ static const char FULLVERSION_STRING[] = "0.2.2893.16068";

//These values are to keep track of your versioning state, don't modify
them.
- static const long BUILD_HISTORY = 7;
+ static const long BUILD_HISTORY = 33;


}

Reply all
Reply to author
Forward
0 new messages