Fixed bug with ctrl-s to save inserting an 's' into the textbox.

Made it so that strings will be stripped of whitespace at the ends
when loading config files. Added in Caranha's new unit descriptions.
This commit is contained in:
Dave White 2003-09-23 10:17:25 +00:00
parent 768f113544
commit 62b4528345
30 changed files with 45 additions and 25 deletions

View File

@ -3,7 +3,7 @@ name=Arch Mage
image=arch-mage.png image=arch-mage.png
hitpoints=58 hitpoints=58
movement_type=smallfoot movement_type=smallfoot
movement=5 movement=6
experience=220 experience=220
level=3 level=3
alignment=neutral alignment=neutral

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null advanceto=null
cost=28 cost=28
usage=fighter usage=fighter
unit_description="Cuttle Fish are giantic creatures of the seas. They can grab their opponents with strong tentacles, or spit a poisonous black ink from a distance. The best way to survive an encounter with these monsters is to remain ashore."
[attack] [attack]
name=tentacles name=tentacles
type=impact type=impact

View File

@ -3,13 +3,14 @@ name=Duelist
image=human-duelist.png image=human-duelist.png
hitpoints=44 hitpoints=44
movement_type=elusivefoot movement_type=elusivefoot
movement=6 movement=7
experience=120 experience=120
level=2 level=2
alignment=neutral alignment=neutral
advanceto=null advanceto=null
cost=40 cost=40
usage=mixed fighter usage=mixed fighter
unit_description="The Duelist is a master on the art of swordplay. His skills with the rapier allow him to attack and parry with only one hand, while wielding a pistol in his other hand to hit distant foes."
[attack] [attack]
name=rapier name=rapier
type=blade type=blade

View File

@ -3,7 +3,7 @@ name=Dwarvish Berserker
image=dwarf-fighter.png image=dwarf-fighter.png
hitpoints=48 hitpoints=48
movement_type=mountainfoot movement_type=mountainfoot
movement=5 movement=6
experience=500 experience=500
level=3 level=3
alignment=neutral alignment=neutral
@ -11,6 +11,7 @@ advanceto=null
cost=100 cost=100
ability=leadership ability=leadership
usage=fighter usage=fighter
unit_description="The dwarves are an ancient race of powerful fighters. Their berserker can wield a battle axe in a deadly manner, or throw himself into a mad frenzy that forgoes all defense to double his attack power, or even throw knives to hit his enemies from a distance. Besides all that, the mighty presence of the dwarvish berserker inspires the troops of lower level around him, giving them a boost in their attacks."
[attack] [attack]
name=battle axe name=battle axe
type=blade type=blade

View File

@ -3,7 +3,7 @@ name=Dwarvish Lord
image=dwarf-warrior.png image=dwarf-warrior.png
hitpoints=80 hitpoints=80
movement_type=mountainfoot movement_type=mountainfoot
movement=5 movement=8
experience=500 experience=500
level=3 level=3
alignment=neutral alignment=neutral
@ -11,6 +11,7 @@ advanceto=null
cost=100 cost=100
ability=leadership ability=leadership
usage=fighter usage=fighter
unit_description="The dwarvish lord is the king under the mountains. His skill with the battle axe is unparalled, and he is able to even hit enemies that are far away from him. His prowesses inspires units of lower level around him, making them fight better."
[attack] [attack]
name=battle axe name=battle axe
type=blade type=blade

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=Duelist advanceto=Duelist
cost=18 cost=18
usage=fighter usage=fighter
unit_description="Fencers are trained in the fine arts of the swordplay. While their rapier is a light weapon, they can use it quick and deadly. Wielding a dagger in their offhand, they can also parry all kinds of attacks quite deftly."
[attack] [attack]
name=rapier name=rapier
type=blade type=blade

View File

@ -11,6 +11,7 @@ advanceto=null
cost=100 cost=100
ability=leadership ability=leadership
usage=fighter usage=fighter
unit_description="The great leaders of the human armies, generals are responsible for the protection of large and/or important areas in the human kingdoms. The generals can coordinate the attacks of level 1 and 2 units, increasing their fighting efficiency."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null advanceto=null
cost=50 cost=50
usage=scout usage=scout
unit_description="Half lion, half bird, these majestic creatures dominate the skies of the world. Wary of other intelligent races, they should not be disturbed without a good reason."
[attack] [attack]
name=claws name=claws
type=pierce type=pierce

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null advanceto=null
cost=54 cost=54
usage=scout usage=scout
unit_description="Only a few of the already nature-loving elves are able to make a friendship bond with the mighty gryphons. Those who do can ride these flying beasts, discovering the whole new world of the skies."
[attack] [attack]
name=claws name=claws
type=pierce type=pierce

View File

@ -3,13 +3,14 @@ name=Halbardier
image=human-halbardier.png image=human-halbardier.png
hitpoints=52 hitpoints=52
movement_type=smallfoot movement_type=smallfoot
movement=5 movement=6
experience=60 experience=60
level=2 level=2
alignment=neutral alignment=neutral
advanceto=Royal Guard advanceto=Royal Guard
cost=22 cost=22
usage=fighter usage=fighter
unit_description="The best among the swordsmen are choosen to become halberdiers. Thought a little slower then the sword, their weapon can strike deadly blows."
[attack] [attack]
name=halbard name=halbard
type=pierce type=pierce

View File

@ -11,6 +11,7 @@ advanceto=general
cost=35 cost=35
ability=leadership ability=leadership
usage=fighter usage=fighter
unit_description="Able at swords and crossbows, the lieutenant leads small groups of human soldiers, coordinating their attacks and increasing the fighting ability of those of lower rank around him."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null advanceto=null
cost=30 cost=30
usage=scout usage=scout
unit_description="Ogres are giant, stupid humanoids that usually live alone in the wilderness. While they can be easily outran or outsmarted, their strenght is not to be underestimated."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -11,6 +11,7 @@ alignment=chaotic
advanceto=null advanceto=null
cost=60 cost=60
usage=scout usage=scout
unit_description="Mountain Trolls are distant relatives to the regular trolls found among the orcish raiding bands. There are even more dangerous than their already strong cousins but, luckly, usually do not venture very far from their rocky lairs."
[attack] [attack]
name=club name=club
type=impact type=impact

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null advanceto=null
cost=11 cost=11
usage=fighter usage=fighter
unit_description="The naga, like the merman, are inhabitants of the seas. While they are smaller and nimbler than their counterparts, they share their distaste for dry land."
[attack] [attack]
name=trident name=trident
type=pierce type=pierce

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null advanceto=null
cost=30 cost=30
usage=fighter usage=fighter
unit_description="Ogres are giant, stupid humanoids that usually live alone in the wilderness. While they can be easily outran or outsmarted, their strenght is not to be underestimated."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -10,7 +10,7 @@ alignment=chaotic
advanceto=Orcish Crossbow advanceto=Orcish Crossbow
cost=15 cost=15
usage=archer usage=archer
unit_desc="The Archer is considered by many orcs to be a lesser caste of warrior, for attacking his enemies from a distance. Howerver, since most orcs won't learn how to handle a bow, he is an indispensable part of the orcish army." unit_description="The Archer is considered by many orcs to be a lesser caste of warrior, for attacking his enemies from a distance. Howerver, since most orcs won't learn how to handle a bow, he is an indispensable part of the orcish army."
[attack] [attack]
name=bow name=bow
type=pierce type=pierce

View File

@ -10,7 +10,7 @@ alignment=chaotic
advanceto=null advanceto=null
cost=24 cost=24
usage=archer usage=archer
unit_description="The orcish crossbow tries to compensate his lack of skill with the raw power of his weapon. While he is not as effective as the elvish marksmen in long range combat, he is quite sturdier and can handle himself a little better in close quarters." unit_description="The orcish crossbow tries to compensate his lack of skill with the raw power of his weapon. While he is not as effective as the elvish marksmen in long range combat, he is sturdier and can handle himself a little better in close combat."
[attack] [attack]
name=crossbow name=crossbow
type=pierce type=pierce

View File

@ -10,27 +10,17 @@ alignment=chaotic
advanceto=Orcish Warrior advanceto=Orcish Warrior
cost=12 cost=12
usage=fighter usage=fighter
desc_unit="The Orcish Grunt makes the base of the orcish forces. Although slower than human or elven fighters, the grunt can deliver much more powerful blows, and take more hits before falling." unit_description="The Orcish Grunt makes the base of the orcish forces. Although slower than human or elven fighters, the grunt can deliver much more powerful blows, and take more hits before falling."
[attack] [attack]
name=sword name=sword
type=blade type=blade
range=short range=short
damage=9 damage=9
number=2 number=2
[frame] [frame]
begin=-100 begin=-100
end=100 end=100
image=orcish-grunt-attack.png image=orcish-grunt-attack.png
[/frame] [/frame]
[sound]
time=-250
sound=sword-swish.wav
[/sound]
[sound]
time=-150
sound=groan.wav
sound_miss=null
[/sound]
[/attack] [/attack]
[/unit] [/unit]

View File

@ -10,7 +10,7 @@ alignment=chaotic
advanceto=Orcish Warlord advanceto=Orcish Warlord
cost=22 cost=22
usage=fighter usage=fighter
unit_desc="Having mastered the art of dual sword fighting, the Orcish Warrior is highly respected among the orcs, and highly feared by his foes. His only weakness is the inability to wield bows." unit_description="Having mastered the art of dual sword fighting, the Orcish Warrior is highly respected among the orcs, and highly feared by his foes. His only weakness is the inability to wield bows."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -11,6 +11,7 @@ advanceto=null
cost=110 cost=110
ability=leadership ability=leadership
usage=fighter usage=fighter
unit_description="A noble at birth, the princess has learned swordplay with the greatest generals, and battle tatics with the greatest sages, making her both a great combatant and leader. All the units of lower level around the princess will fight better due to her shining presence."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -3,13 +3,14 @@ name=Royal Guard
image=human-royalguard.png image=human-royalguard.png
hitpoints=60 hitpoints=60
movement_type=smallfoot movement_type=smallfoot
movement=5 movement=7
experience=500 experience=500
level=3 level=3
alignment=neutral alignment=neutral
advanceto=null advanceto=null
cost=35 cost=35
usage=fighter usage=fighter
unit_description="Members of the Royal Guard are hand picked among the strongest and sturdiest of the army. The loyalty deploys them whenever only on critical situations and, so far, they have always succeeded in the job at hand."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null advanceto=null
cost=16 cost=16
usage=scout usage=scout
unit_description="Using the lightest of armour and the fastest of horses, scouts are employed by most human armies to find out what dangers lie ahead."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -10,6 +10,7 @@ alignment=chaotic
advanceto=null advanceto=null
cost=80 cost=80
usage=fighter usage=fighter
unit_description="The Sea Serpent is a gigantic monster, capable of capsizing boats by itself."
[attack] [attack]
name=fangs name=fangs
type=pierce type=pierce

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null advanceto=null
cost=50 cost=50
usage=scout usage=scout
unit_description="Shhhh! The gryphon is sleeping! You'd better not wake it up!"
[attack] [attack]
name=claws name=claws
type=pierce type=pierce

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=Halbardier advanceto=Halbardier
cost=15 cost=15
usage=fighter usage=fighter
unit_description="The swordsman is the base of the human armies. These young soldiers are given basic training and put in the front lines to face the bulk of the battle."
[attack] [attack]
name=sword name=sword
type=blade type=blade

View File

@ -14,7 +14,7 @@ unit_description="Trolls are strong, brutal humanoid monsters that have the amaz
usage=fighter usage=fighter
[attack] [attack]
name=club name=club
type=impact type=impact
range=short range=short
damage=14 damage=14
number=2 number=2

View File

@ -12,6 +12,7 @@
*/ */
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cctype>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <stack> #include <stack>
@ -444,7 +445,7 @@ void config::read(const std::string& data,
} else if(c == '\n' && !in_quotes) { } else if(c == '\n' && !in_quotes) {
state = IN_ELEMENT; state = IN_ELEMENT;
elements.top()->values.insert( elements.top()->values.insert(
std::pair<std::string,std::string>(var,value)); std::pair<std::string,std::string>(var,strip(value)));
var = ""; var = "";
value = ""; value = "";
} else { } else {
@ -512,6 +513,14 @@ std::vector<std::string> config::split(const std::string& val)
return res; return res;
} }
std::string& config::strip(std::string& str)
{
str.erase(str.begin(),std::find_if(str.begin(),str.end(),isgraph));
str.erase(std::find_if(str.rbegin(),str.rend(),isgraph).base(),str.end());
return str;
}
bool config::has_value(const std::string& values, const std::string& val) bool config::has_value(const std::string& values, const std::string& val)
{ {
const std::vector<std::string>& vals = split(values); const std::vector<std::string>& vals = split(values);

View File

@ -56,6 +56,7 @@ struct config
std::map<std::string,std::vector<config*> > children; std::map<std::string,std::vector<config*> > children;
static std::vector<std::string> split(const std::string& val); static std::vector<std::string> split(const std::string& val);
static std::string& strip(std::string& str);
static bool has_value(const std::string& values, const std::string& val); static bool has_value(const std::string& values, const std::string& val);
void clear(); void clear();

View File

@ -707,6 +707,8 @@ int show_dialog(display& disp, SDL_Surface* image,
bool first_time = true; bool first_time = true;
for(;;) { for(;;) {
pump_events();
int mousex, mousey; int mousex, mousey;
const int mouse_flags = SDL_GetMouseState(&mousex,&mousey); const int mouse_flags = SDL_GetMouseState(&mousex,&mousey);
@ -814,8 +816,6 @@ int show_dialog(display& disp, SDL_Surface* image,
} }
} }
} }
pump_events();
} }
return -1; return -1;

View File

@ -29,7 +29,7 @@ textbox::textbox(display& disp, int width, const std::string& text)
lastDelete_(false), lastBackspace_(false) lastDelete_(false), lastBackspace_(false)
{ {
std::fill(previousKeyState_, std::fill(previousKeyState_,
previousKeyState_+CHAR_LENGTH,false); previousKeyState_+CHAR_LENGTH,true);
static const SDL_Rect area = {0,0,1024,768}; static const SDL_Rect area = {0,0,1024,768};
height_ = font::draw_text(NULL,area,font_size,font::NORMAL_COLOUR, height_ = font::draw_text(NULL,area,font_size,font::NORMAL_COLOUR,
"ABCD",0,0).h; "ABCD",0,0).h;