]> git.localhorst.tv Git - l2e.git/blob - src/main.cpp
e657f57b7320366e55e2cef5cfbc407dae819262
[l2e.git] / src / main.cpp
1 /*
2  * main.cpp
3  *
4  *  Created on: Aug 1, 2012
5  *      Author: holy
6  */
7
8 #include "app/Application.h"
9 #include "app/Input.h"
10 #include "battle/BattleState.h"
11 #include "battle/Hero.h"
12 #include "battle/Monster.h"
13 #include "battle/PartyLayout.h"
14 #include "battle/Resources.h"
15 #include "battle/Stats.h"
16 #include "common/Ikari.h"
17 #include "common/Inventory.h"
18 #include "common/Item.h"
19 #include "common/Spell.h"
20 #include "geometry/Vector.h"
21 #include "graphics/ComplexAnimation.h"
22 #include "graphics/Font.h"
23 #include "graphics/Frame.h"
24 #include "graphics/Gauge.h"
25 #include "graphics/Menu.h"
26 #include "graphics/SimpleAnimation.h"
27 #include "graphics/Sprite.h"
28 #include "loader/Interpreter.h"
29 #include "loader/ParsedSource.h"
30 #include "loader/Parser.h"
31 #include "sdl/InitImage.h"
32 #include "sdl/InitScreen.h"
33 #include "sdl/InitSDL.h"
34
35 #include <cstdlib>
36 #include <ctime>
37 #include <exception>
38 #include <iostream>
39 #include <SDL.h>
40 #include <SDL_image.h>
41
42 using app::Application;
43 using app::Input;
44 using battle::BattleState;
45 using battle::Hero;
46 using battle::Monster;
47 using battle::PartyLayout;
48 using battle::Stats;
49 using common::Ikari;
50 using common::Inventory;
51 using common::Item;
52 using common::Spell;
53 using geometry::Vector;
54 using graphics::ComplexAnimation;
55 using graphics::Font;
56 using graphics::Frame;
57 using graphics::Gauge;
58 using graphics::Menu;
59 using graphics::SimpleAnimation;
60 using graphics::Sprite;
61 using loader::Interpreter;
62 using loader::ParsedSource;
63 using loader::Parser;
64 using sdl::InitImage;
65 using sdl::InitScreen;
66 using sdl::InitSDL;
67
68 using std::cerr;
69 using std::cout;
70 using std::endl;
71 using std::exception;
72
73 int main(int argc, char **argv) {
74         const int width = 800;
75         const int height = 480;
76
77         const int framerate = 33;
78
79 //      std::srand(std::time(0));
80
81         try {
82                 InitSDL sdl;
83                 InitImage image(IMG_INIT_PNG);
84
85                 ParsedSource source;
86                 Parser parser("test-data/test.l2s", source);
87                 parser.Parse();
88                 Interpreter intp(source);
89                 intp.ReadSource();
90
91                 InitScreen screen(width, height);
92
93                 // temporary test data
94                 SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
95                 PartyLayout monstersLayout(*intp.GetPartyLayout("monstersLayout"));
96                 PartyLayout heroesLayout(*intp.GetPartyLayout("heroesLayout"));
97
98                 Monster monster(*intp.GetMonster("lizard"));
99                 Hero maxim(*intp.GetHero("maxim"));
100                 Hero selan(*intp.GetHero("selan"));
101                 Hero guy(*intp.GetHero("guy"));
102                 Hero dekar(*intp.GetHero("dekar"));
103
104                 battle::Resources battleRes;
105
106                 battleRes.swapCursor = intp.GetSprite("swapCursor");
107                 battleRes.attackIcons = intp.GetSprite("attackIcons");
108                 battleRes.attackChoiceIcons = intp.GetSprite("attackChoiceIcons");
109                 battleRes.moveIcons = intp.GetSprite("moveIcons");
110                 battleRes.titleFrame = intp.GetFrame("titleFrame");
111                 battleRes.titleFont = intp.GetFont("largeFont");
112                 battleRes.numberAnimationPrototype = intp.GetAnimation("numberAnimationPrototype");
113                 battleRes.bigNumberSprite = intp.GetSprite("bigNumbers");
114                 battleRes.greenNumberSprite = intp.GetSprite("bigGreenNumbers");
115
116                 battleRes.heroTagLabels = intp.GetSprite("heroTagLabels");
117                 battleRes.levelLabelCol = 0;
118                 battleRes.levelLabelRow = 0;
119                 battleRes.healthLabelCol = 0;
120                 battleRes.healthLabelRow = 1;
121                 battleRes.manaLabelCol = 0;
122                 battleRes.manaLabelRow = 2;
123                 battleRes.moveLabelCol = 0;
124                 battleRes.moveLabelRow = 3;
125                 battleRes.ikariLabelCol = 0;
126                 battleRes.ikariLabelRow = 4;
127
128                 battleRes.heroTagFont = intp.GetFont("heroTagFont");
129                 battleRes.heroTagFrame = intp.GetFrame("heroTagFrame");
130                 battleRes.activeHeroTagFrame = intp.GetFrame("activeHeroTagFrame");
131                 battleRes.smallHeroTagFrame = intp.GetFrame("smallHeroTagFrame");
132                 battleRes.lastSmallHeroTagFrame = intp.GetFrame("lastSmallHeroTagFrame");
133                 battleRes.heroesBgColor = SDL_MapRGB(screen.Screen()->format, 0x18, 0x28, 0x31);
134
135                 battleRes.healthGauge = intp.GetGauge("healthGauge");
136                 battleRes.manaGauge = intp.GetGauge("manaGauge");
137                 battleRes.ikariGauge = intp.GetGauge("ikariGauge");
138
139                 battleRes.selectFrame = intp.GetFrame("selectFrame");
140                 battleRes.normalFont = intp.GetFont("normalFont");
141                 battleRes.disabledFont = intp.GetFont("disabledFont");
142                 battleRes.menuCursor = intp.GetSprite("handCursor");
143
144                 battleRes.weaponTargetCursor = intp.GetSprite("weaponTargetCursor");
145                 battleRes.magicTargetCursor = intp.GetSprite("magicTargetCursor");
146                 battleRes.itemTargetCursor = intp.GetSprite("itemTargetCursor");
147
148                 Spell resetSpell;
149                 resetSpell.SetName("Reset");
150                 maxim.AddSpell(&resetSpell);
151                 Spell strongSpell;
152                 strongSpell.SetName("Strong");
153                 strongSpell.SetCost(3);
154                 strongSpell.SetUsableInBattle();
155                 strongSpell.GetTargetingMode().TargetMultipleAllies();
156                 maxim.AddSpell(&strongSpell);
157                 selan.AddSpell(&strongSpell);
158                 Spell strongerSpell;
159                 strongerSpell.SetName("Stronger");
160                 strongerSpell.SetCost(8);
161                 strongerSpell.SetUsableInBattle();
162                 strongerSpell.GetTargetingMode().TargetMultipleAllies();
163                 maxim.AddSpell(&strongerSpell);
164                 selan.AddSpell(&strongerSpell);
165                 Spell championSpell;
166                 championSpell.SetName("Champion");
167                 championSpell.SetCost(16);
168                 championSpell.SetUsableInBattle();
169                 championSpell.GetTargetingMode().TargetMultipleAllies();
170                 maxim.AddSpell(&championSpell);
171                 selan.AddSpell(&championSpell);
172                 Spell rallySpell;
173                 rallySpell.SetName("Rally");
174                 rallySpell.SetCost(10);
175                 rallySpell.SetUsableInBattle();
176                 rallySpell.GetTargetingMode().TargetMultipleAllies();
177                 maxim.AddSpell(&rallySpell);
178                 selan.AddSpell(&rallySpell);
179                 Spell escapeSpell;
180                 escapeSpell.SetName("Escape");
181                 escapeSpell.SetCost(8);
182                 selan.AddSpell(&escapeSpell);
183                 Spell valorSpell;
184                 valorSpell.SetName("Valor");
185                 valorSpell.SetCost(30);
186                 valorSpell.SetUsableInBattle();
187                 valorSpell.GetTargetingMode().TargetMultipleAllies();
188                 maxim.AddSpell(&valorSpell);
189                 selan.AddSpell(&valorSpell);
190
191                 battleRes.spellMenuHeadline = "Please choose a spell.";
192                 battleRes.spellMenuPrototype = Menu<const Spell *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 9, 6, 8, 0, 2, 32, 2, ':');
193
194                 SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
195                 Sprite potionIcon(itemIcons, 16, 16);
196                 Sprite ballIcon(itemIcons, 16, 16, 0, 16);
197                 Sprite crankIcon(itemIcons, 16, 16, 0, 32);
198                 Sprite spearIcon(itemIcons, 16, 16, 0, 48);
199                 Sprite swordIcon(itemIcons, 16, 16, 0, 64);
200                 Sprite axIcon(itemIcons, 16, 16, 0, 80);
201                 Sprite rodIcon(itemIcons, 16, 16, 0, 96);
202                 Sprite armorIcon(itemIcons, 16, 16, 0, 112);
203                 Sprite shieldIcon(itemIcons, 16, 16, 0, 128);
204                 Sprite helmetIcon(itemIcons, 16, 16, 0, 144);
205                 Sprite ringIcon(itemIcons, 16, 16, 0, 160);
206                 Sprite jewelIcon(itemIcons, 16, 16, 0, 176);
207
208                 battleRes.weaponMenuIcon = &swordIcon;
209                 battleRes.armorMenuIcon = &armorIcon;
210                 battleRes.shieldMenuIcon = &shieldIcon;
211                 battleRes.helmetMenuIcon = &helmetIcon;
212                 battleRes.ringMenuIcon = &ringIcon;
213                 battleRes.jewelMenuIcon = &jewelIcon;
214
215                 Inventory inventory;
216                 Item antidote;
217                 antidote.SetName("Antidote");
218                 antidote.SetMenuIcon(&potionIcon);
219                 antidote.SetUsableInBattle();
220                 antidote.GetTargetingMode().TargetSingleAlly();
221                 inventory.Add(&antidote, 9);
222                 Item magicJar;
223                 magicJar.SetName("Magic jar");
224                 magicJar.SetMenuIcon(&potionIcon);
225                 magicJar.SetUsableInBattle();
226                 magicJar.GetTargetingMode().TargetSingleAlly();
227                 inventory.Add(&magicJar, 4);
228                 Item hiPotion;
229                 hiPotion.SetName("Hi-Potion");
230                 hiPotion.SetMenuIcon(&potionIcon);
231                 hiPotion.SetUsableInBattle();
232                 hiPotion.GetTargetingMode().TargetSingleAlly();
233                 inventory.Add(&hiPotion, 4);
234                 Item powerPotion;
235                 powerPotion.SetName("Power potion");
236                 powerPotion.SetMenuIcon(&potionIcon);
237                 inventory.Add(&powerPotion, 4);
238                 Item escape;
239                 escape.SetName("Escape");
240                 inventory.Add(&escape, 2);
241                 Item sleepBall;
242                 sleepBall.SetName("Sleep ball");
243                 sleepBall.SetMenuIcon(&ballIcon);
244                 sleepBall.SetUsableInBattle();
245                 sleepBall.GetTargetingMode().TargetSingleEnemy();
246                 inventory.Add(&sleepBall, 1);
247                 Item multiBall;
248                 multiBall.SetName("Multi-ball!");
249                 multiBall.SetMenuIcon(&ballIcon);
250                 multiBall.SetUsableInBattle();
251                 multiBall.GetTargetingMode().TargetMultipleEnemies();
252                 inventory.Add(&multiBall, 1);
253                 Item figgoru;
254                 figgoru.SetName("Figgoru");
255                 figgoru.SetMenuIcon(&crankIcon);
256                 figgoru.GetTargetingMode().TargetAllEnemies();
257                 inventory.Add(&figgoru, 1);
258                 battleRes.inventory = &inventory;
259
260                 battleRes.itemMenuHeadline = "Please choose an item.";
261                 battleRes.itemMenuPrototype = Menu<const common::Item *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 15, 6, 8, 16, 1, 32, 2, ':');
262
263                 SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
264                 Sprite swordAttackSprite(swordAttackImg, 96, 96);
265                 SimpleAnimation swordAttackAnimation(&swordAttackSprite, 2 * framerate, 4);
266
267                 Item zircoSword;
268                 zircoSword.SetName("Zirco sword");
269                 zircoSword.SetMenuIcon(&swordIcon);
270                 zircoSword.GetTargetingMode().TargetSingleEnemy();
271                 Ikari firestorm;
272                 firestorm.SetName("Firestorm");
273                 firestorm.SetCost(224);
274                 firestorm.GetTargetingMode().TargetAllEnemies();
275                 firestorm.SetPhysical();
276                 zircoSword.SetIkari(&firestorm);
277                 zircoSword.SetAttackAnimation(&swordAttackAnimation);
278                 maxim.SetWeapon(&zircoSword);
279                 Item zirconArmor;
280                 zirconArmor.SetName("Zircon armor");
281                 zirconArmor.SetMenuIcon(&armorIcon);
282                 Ikari magicCure;
283                 magicCure.SetName("Magic cure");
284                 magicCure.SetCost(128);
285                 magicCure.GetTargetingMode().TargetSingleAlly();
286                 magicCure.SetMagical();
287                 zirconArmor.SetIkari(&magicCure);
288                 maxim.SetArmor(&zirconArmor);
289                 Item holyShield;
290                 holyShield.SetName("Holy shield");
291                 holyShield.SetMenuIcon(&shieldIcon);
292                 Ikari lightGuard;
293                 lightGuard.SetName("Light guard");
294                 lightGuard.SetCost(128);
295                 lightGuard.GetTargetingMode().TargetAllAllies(); // actually only targets self
296                 lightGuard.SetMagical();
297                 holyShield.SetIkari(&lightGuard);
298                 maxim.SetShield(&holyShield);
299                 Item legendHelm;
300                 legendHelm.SetName("Legend helm");
301                 legendHelm.SetMenuIcon(&helmetIcon);
302                 Ikari boomerang;
303                 boomerang.SetName("Boomerang");
304                 boomerang.SetCost(164);
305                 boomerang.GetTargetingMode().TargetAllAllies(); // actually only targets self
306                 boomerang.SetMagical();
307                 legendHelm.SetIkari(&boomerang);
308                 maxim.SetHelmet(&legendHelm);
309                 Item sProRing;
310                 sProRing.SetName("S-pro ring");
311                 sProRing.SetMenuIcon(&ringIcon);
312                 Ikari courage;
313                 courage.SetName("Courage");
314                 courage.SetCost(64);
315                 courage.GetTargetingMode().TargetMultipleAllies();
316                 courage.SetMagical();
317                 sProRing.SetIkari(&courage);
318                 maxim.SetRing(&sProRing);
319                 Item evilJewel;
320                 evilJewel.SetName("Evil jewel");
321                 evilJewel.SetMenuIcon(&jewelIcon);
322                 Ikari gloomy;
323                 gloomy.SetName("Gloomy");
324                 gloomy.SetCost(164);
325                 gloomy.GetTargetingMode().TargetAllEnemies();
326                 gloomy.SetMagical();
327                 evilJewel.SetIkari(&gloomy);
328                 maxim.SetJewel(&evilJewel);
329
330                 Item zircoWhip;
331                 zircoWhip.SetName("Zirco whip");
332                 zircoWhip.SetMenuIcon(&rodIcon);
333                 zircoWhip.GetTargetingMode().TargetSingleEnemy();
334                 Ikari thundershriek;
335                 thundershriek.SetName("Thundershriek");
336                 thundershriek.SetCost(224);
337                 thundershriek.GetTargetingMode().TargetAllEnemies();
338                 thundershriek.SetPhysical();
339                 zircoWhip.SetIkari(&thundershriek);
340 //              selan.SetWeapon(&zircoWhip);
341                 Item zirconPlate;
342                 zirconPlate.SetName("Zircon plate");
343                 zirconPlate.SetMenuIcon(&armorIcon);
344                 Ikari suddenCure;
345                 suddenCure.SetName("Sudden cure");
346                 suddenCure.SetCost(96);
347                 suddenCure.GetTargetingMode().TargetAllAllies();
348                 suddenCure.SetMagical();
349                 zirconPlate.SetIkari(&suddenCure);
350                 selan.SetArmor(&zirconPlate);
351                 Item zircoGloves;
352                 zircoGloves.SetName("Zirco gloves");
353                 zircoGloves.SetMenuIcon(&shieldIcon);
354                 Ikari forcefield;
355                 forcefield.SetName("Forcefield");
356                 forcefield.SetCost(64);
357                 forcefield.GetTargetingMode().TargetAllAllies();
358                 forcefield.SetMagical();
359                 zircoGloves.SetIkari(&forcefield);
360                 selan.SetShield(&zircoGloves);
361                 Item holyCap;
362                 holyCap.SetName("Holy cap");
363                 holyCap.SetMenuIcon(&helmetIcon);
364                 Ikari vulnerable;
365                 vulnerable.SetName("Vulnerable");
366                 vulnerable.SetCost(196);
367                 vulnerable.GetTargetingMode().TargetAllEnemies();
368                 vulnerable.SetPhysical();
369                 holyCap.SetIkari(&vulnerable);
370                 selan.SetHelmet(&holyCap);
371                 Item ghostRing;
372                 ghostRing.SetName("Ghost ring");
373                 ghostRing.SetMenuIcon(&ringIcon);
374                 Ikari destroy;
375                 destroy.SetName("Destroy");
376                 destroy.SetCost(128);
377                 destroy.GetTargetingMode().TargetMultipleEnemies();
378                 destroy.SetMagical();
379                 ghostRing.SetIkari(&destroy);
380                 selan.SetRing(&ghostRing);
381                 Item eagleRock;
382                 eagleRock.SetName("Eagle rock");
383                 eagleRock.SetMenuIcon(&jewelIcon);
384                 Ikari dive;
385                 dive.SetName("Dive");
386                 dive.SetCost(128);
387                 dive.GetTargetingMode().TargetSingleEnemy();
388                 dive.SetPhysical();
389                 eagleRock.SetIkari(&dive);
390                 selan.SetJewel(&eagleRock);
391
392                 Item zircoAx;
393                 zircoAx.SetName("Zirco ax");
394                 zircoAx.SetMenuIcon(&axIcon);
395                 zircoAx.GetTargetingMode().TargetSingleEnemy();
396                 Ikari torrent;
397                 torrent.SetName("Torrent");
398                 torrent.SetCost(224);
399                 torrent.GetTargetingMode().TargetAllEnemies();
400                 torrent.SetPhysical();
401                 zircoAx.SetIkari(&torrent);
402 //              guy.SetWeapon(&zircoAx);
403                 guy.SetArmor(&zirconArmor);
404                 Item megaShield;
405                 megaShield.SetName("Mega shield");
406                 megaShield.SetMenuIcon(&shieldIcon);
407                 Ikari ironBarrier;
408                 ironBarrier.SetName("Iron barrier");
409                 ironBarrier.SetCost(255);
410                 ironBarrier.GetTargetingMode().TargetAllAllies(); // actually only targets self
411                 ironBarrier.SetMagical();
412                 megaShield.SetIkari(&ironBarrier);
413                 guy.SetShield(&megaShield);
414                 Item zircoHelmet;
415                 zircoHelmet.SetName("Zirco helmet");
416                 zircoHelmet.SetMenuIcon(&helmetIcon);
417                 Ikari slow;
418                 slow.SetName("Slow");
419                 slow.SetCost(196);
420                 slow.GetTargetingMode().TargetAllEnemies();
421                 slow.SetPhysical();
422                 zircoHelmet.SetIkari(&slow);
423                 guy.SetHelmet(&zircoHelmet);
424                 Item powerRing;
425                 powerRing.SetName("Power ring");
426                 powerRing.SetMenuIcon(&ringIcon);
427                 Ikari trick;
428                 trick.SetName("Trick");
429                 trick.SetCost(32);
430                 trick.GetTargetingMode().TargetAllEnemies();
431                 trick.SetMagical();
432                 zircoHelmet.SetIkari(&trick);
433                 guy.SetRing(&powerRing);
434                 guy.SetJewel(&evilJewel);
435
436                 // NOTE: this is actually Artea equipment
437                 Item lizardBlow;
438                 lizardBlow.SetName("Lizard blow");
439                 lizardBlow.SetMenuIcon(&swordIcon);
440                 lizardBlow.GetTargetingMode().TargetSingleEnemy();
441                 Ikari dragonRush;
442                 dragonRush.SetName("Dragon rush");
443                 dragonRush.SetCost(164);
444                 dragonRush.GetTargetingMode().TargetSingleEnemy();
445                 dragonRush.SetPhysical();
446                 lizardBlow.SetIkari(&dragonRush);
447 //              dekar.SetWeapon(&lizardBlow);
448                 Item holyRobe;
449                 holyRobe.SetName("Holy robe");
450                 holyRobe.SetMenuIcon(&armorIcon);
451                 Ikari crisisCure;
452                 crisisCure.SetName("Crisis cure");
453                 crisisCure.SetCost(164);
454                 crisisCure.GetTargetingMode().TargetAllAllies();
455                 crisisCure.SetMagical();
456                 holyRobe.SetIkari(&crisisCure);
457                 dekar.SetArmor(&holyRobe);
458                 dekar.SetShield(&zircoGloves);
459                 dekar.SetHelmet(&holyCap);
460                 Item rocketRing;
461                 rocketRing.SetName("Rocket ring");
462                 rocketRing.SetMenuIcon(&ringIcon);
463                 Ikari fake;
464                 fake.SetName("Fake");
465                 fake.SetCost(32);
466                 fake.GetTargetingMode().TargetSingleAlly();
467                 fake.SetMagical();
468                 rocketRing.SetIkari(&fake);
469                 dekar.SetRing(&rocketRing);
470                 Item krakenRock;
471                 krakenRock.SetName("Kraken rock");
472                 krakenRock.SetMenuIcon(&jewelIcon);
473                 Ikari tenLegger;
474                 tenLegger.SetName("Ten-legger");
475                 tenLegger.SetCost(164);
476                 tenLegger.GetTargetingMode().TargetAllEnemies();
477                 tenLegger.SetPhysical();
478                 rocketRing.SetIkari(&tenLegger);
479                 dekar.SetJewel(&krakenRock);
480
481                 battleRes.ikariMenuHeadline = "Please choose equipment.";
482                 battleRes.noEquipmentText = "No equip";
483                 battleRes.ikariMenuPrototype = Menu<const Item *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 12, 6, intp.GetFont("normalFont")->CharHeight() / 2, intp.GetFont("normalFont")->CharWidth(), 1, intp.GetFont("normalFont")->CharWidth() * 2, 0, ':', 12, intp.GetFont("normalFont")->CharWidth());
484
485                 battleRes.escapeText = "Escapes.";
486
487                 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
488                 battleState->AddMonster(monster);
489                 battleState->AddMonster(monster);
490                 battleState->AddMonster(monster);
491                 battleState->AddMonster(monster);
492                 battleState->AddHero(maxim);
493                 battleState->AddHero(selan);
494                 battleState->AddHero(guy);
495                 battleState->AddHero(dekar);
496                 Application app(&screen, battleState);
497                 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
498                 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
499                 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
500                 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
501                 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
502                 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
503                 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
504                 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
505                 app.Buttons().MapKey(SDLK_RETURN, Input::START);
506                 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
507                 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
508                 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
509                 app.Run();
510
511                 return 0;
512         } catch (Parser::Error &e) {
513                 cerr << "parsing exception in file " << e.File() << " on line " << e.Line() << ": " << e.what() << endl;
514                 return 1;
515         } catch (exception &e) {
516                 cerr << "exception in main(): " << e.what() << endl;
517                 return 1;
518         }
519 }