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
hitpoints=58
movement_type=smallfoot
movement=5
movement=6
experience=220
level=3
alignment=neutral

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null
cost=28
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]
name=tentacles
type=impact

View File

@ -3,13 +3,14 @@ name=Duelist
image=human-duelist.png
hitpoints=44
movement_type=elusivefoot
movement=6
movement=7
experience=120
level=2
alignment=neutral
advanceto=null
cost=40
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]
name=rapier
type=blade

View File

@ -3,7 +3,7 @@ name=Dwarvish Berserker
image=dwarf-fighter.png
hitpoints=48
movement_type=mountainfoot
movement=5
movement=6
experience=500
level=3
alignment=neutral
@ -11,6 +11,7 @@ advanceto=null
cost=100
ability=leadership
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]
name=battle axe
type=blade

View File

@ -3,7 +3,7 @@ name=Dwarvish Lord
image=dwarf-warrior.png
hitpoints=80
movement_type=mountainfoot
movement=5
movement=8
experience=500
level=3
alignment=neutral
@ -11,6 +11,7 @@ advanceto=null
cost=100
ability=leadership
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]
name=battle axe
type=blade

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=Duelist
cost=18
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]
name=rapier
type=blade

View File

@ -11,6 +11,7 @@ advanceto=null
cost=100
ability=leadership
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]
name=sword
type=blade

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null
cost=50
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]
name=claws
type=pierce

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null
cost=54
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]
name=claws
type=pierce

View File

@ -3,13 +3,14 @@ name=Halbardier
image=human-halbardier.png
hitpoints=52
movement_type=smallfoot
movement=5
movement=6
experience=60
level=2
alignment=neutral
advanceto=Royal Guard
cost=22
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]
name=halbard
type=pierce

View File

@ -11,6 +11,7 @@ advanceto=general
cost=35
ability=leadership
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]
name=sword
type=blade

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null
cost=30
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]
name=sword
type=blade

View File

@ -11,6 +11,7 @@ alignment=chaotic
advanceto=null
cost=60
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]
name=club
type=impact

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null
cost=11
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]
name=trident
type=pierce

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null
cost=30
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]
name=sword
type=blade

View File

@ -10,7 +10,7 @@ alignment=chaotic
advanceto=Orcish Crossbow
cost=15
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]
name=bow
type=pierce

View File

@ -10,7 +10,7 @@ alignment=chaotic
advanceto=null
cost=24
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]
name=crossbow
type=pierce

View File

@ -10,27 +10,17 @@ alignment=chaotic
advanceto=Orcish Warrior
cost=12
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]
name=sword
type=blade
range=short
damage=9
number=2
[frame]
begin=-100
end=100
image=orcish-grunt-attack.png
[/frame]
[sound]
time=-250
sound=sword-swish.wav
[/sound]
[sound]
time=-150
sound=groan.wav
sound_miss=null
[/sound]
[/attack]
[/unit]

View File

@ -10,7 +10,7 @@ alignment=chaotic
advanceto=Orcish Warlord
cost=22
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]
name=sword
type=blade

View File

@ -11,6 +11,7 @@ advanceto=null
cost=110
ability=leadership
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]
name=sword
type=blade

View File

@ -3,13 +3,14 @@ name=Royal Guard
image=human-royalguard.png
hitpoints=60
movement_type=smallfoot
movement=5
movement=7
experience=500
level=3
alignment=neutral
advanceto=null
cost=35
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]
name=sword
type=blade

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=null
cost=16
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]
name=sword
type=blade

View File

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

View File

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

View File

@ -10,6 +10,7 @@ alignment=neutral
advanceto=Halbardier
cost=15
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]
name=sword
type=blade

View File

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

View File

@ -12,6 +12,7 @@
*/
#include <algorithm>
#include <cassert>
#include <cctype>
#include <fstream>
#include <iostream>
#include <stack>
@ -444,7 +445,7 @@ void config::read(const std::string& data,
} else if(c == '\n' && !in_quotes) {
state = IN_ELEMENT;
elements.top()->values.insert(
std::pair<std::string,std::string>(var,value));
std::pair<std::string,std::string>(var,strip(value)));
var = "";
value = "";
} else {
@ -512,6 +513,14 @@ std::vector<std::string> config::split(const std::string& val)
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)
{
const std::vector<std::string>& vals = split(values);

View File

@ -56,6 +56,7 @@ struct config
std::map<std::string,std::vector<config*> > children;
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);
void clear();

View File

@ -707,6 +707,8 @@ int show_dialog(display& disp, SDL_Surface* image,
bool first_time = true;
for(;;) {
pump_events();
int 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;

View File

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