home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume13 / dominion / part16 < prev    next >
Encoding:
Text File  |  1992-02-10  |  61.0 KB  |  1,714 lines

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v13i052:  dominion - a multi-player world simulation game, Part16/28
  5. Message-ID: <2455@masterCNA.TEK.COM>
  6. Date: 11 Feb 92 18:25:20 GMT
  7. Sender: news@masterCNA.TEK.COM
  8. Lines: 1703
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: rosalia@dirac.physics.sunysb.edu (Mark Galassi)
  12. Posting-number: Volume 13, Issue 52
  13. Archive-name: dominion/Part16
  14. Environment: Unix, curses
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 16 (of 28)."
  25. # Contents:  dom_tex.aa file.c
  26. # Wrapped by billr@saab on Tue Feb 11 10:14:55 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'dom_tex.aa' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'dom_tex.aa'\"
  30. else
  31. echo shar: Extracting \"'dom_tex.aa'\" \(40579 characters\)
  32. sed "s/^X//" >'dom_tex.aa' <<'END_OF_FILE'
  33. X\documentstyle[12pt,latexinfo,tabular]{report}
  34. X\pagestyle{headings}
  35. X
  36. X\begin{document}
  37. X
  38. X\newindex{cp}
  39. X\newindex{vr}
  40. X\newindex{fn}
  41. X\newindex{tp}
  42. X\newindex{pg}
  43. X\newindex{ky}
  44. X
  45. X\comment %**start of header (This is for running Texinfo on a region.)
  46. X\setfilename{dominion.info}
  47. X\markboth{Dominion Manual}{Dominion Manual}
  48. X\comment %**end of header (This is for running Texinfo on a region.)
  49. X
  50. X\begin{tex}
  51. X\pagestyle{empty}
  52. X\title{Dominion Manual}
  53. X
  54. X\author{The Dominion Project}
  55. X
  56. X\date{\today}
  57. X
  58. X\maketitle
  59. X\pagestyle{headings}
  60. X\pagenumbering{roman}
  61. X\tableofcontents
  62. X
  63. X\comment  The following two commands start the copyright page.
  64. X\clearpage
  65. X\comment \vskip 0pt plus 1filll
  66. X
  67. XCopyright \copyright{} 1990 Free Software Foundation, Inc.
  68. X
  69. XPermission is granted to make and distribute verbatim copies of this manual
  70. Xprovided the copyright notice and this permission notice are preserved on
  71. Xall copies.
  72. X
  73. XPermission is granted to copy and distribute modified versions of this
  74. Xmanual under the conditions for verbatim copying, provided also that the
  75. XGNU Copyright statement is available to the distributee, and provided that
  76. Xthe entire resulting derived work is distributed under the terms of a
  77. Xpermission notice identical to this one.
  78. X
  79. XPermission is granted to copy and distribute translations of this manual
  80. Xinto another language, under the above conditions for modified versions.
  81. X
  82. X\clearpage
  83. X\end{tex}
  84. X
  85. X\begin{ifinfo}
  86. XThis file documents dominion.
  87. X
  88. XCopyright @copyright{} 1990 Free Software Foundation, Inc.
  89. XAuthored by the dominion project (see Authors section of this manual).
  90. X
  91. XPermission is granted to make and distribute verbatim copies of this manual
  92. Xprovided the copyright notice and this permission notice are preserved on
  93. Xall copies.
  94. X\begin{ignore}
  95. XPermission is granted to process this file through Tex and print the
  96. Xresults, provided the printed document carries copying permission notice
  97. Xidentical to this one except for the removal of this paragraph (this
  98. Xparagraph not being relevant to the printed manual).
  99. X\end{ignore}
  100. XPermission is granted to copy and distribute modified versions of this
  101. Xmanual under the conditions for verbatim copying, provided also that the
  102. XGNU Copyright statement is available to the distributee, and provided that
  103. Xthe entire resulting derived work is distributed under the terms of a
  104. Xpermission notice identical to this one.
  105. X
  106. XPermission is granted to copy and distribute translations of this manual
  107. Xinto another language, under the above conditions for modified versions.
  108. X\end{ifinfo}
  109. X
  110. X\clearpage
  111. X\pagenumbering{arabic}
  112. X
  113. X\chapter{Overview}
  114. X
  115. X\strong{Dominion} is an empire-style multi-player world simulation game.
  116. XEach player is the leader of a nation, and makes decisions for that
  117. Xnation.  The decisions are political, military, diplomatic and
  118. Xeconomic, and all these are extremely important for the well-being of
  119. Xa nation.  Some nations can be played by the computer.  These nations
  120. Xare called NPCs (Non Player Countries).  They play a challenging game,
  121. Xand are quite useful if few human players are available.
  122. X
  123. XDominion has features from both fantasy role-playing games, educational
  124. Xgames, and war games: a user needs to develop a character as leader of
  125. Xa nation, keep a healty economy, and can then develop a strong
  126. Xmilitary force using magic or technology.
  127. X
  128. XMost of the moves you make are not resolved until the end of a turn,
  129. Xwhen the \emph{update} is run.  This update will incorporate your
  130. Xchanges into the world data base, then it will update your economy,
  131. Xhandle migration of people, resolve battles and conquest of land,
  132. Xfreshen up your armies (restore move points), and a few other things.
  133. X
  134. XThe rhythm of the game is set by how much money you have spent, and
  135. Xhow much you have moved your armies.  If you have spent all your
  136. Xmoney, you will need to wait until your revenue comes in (after the
  137. Xupdate) before you can spend more.  Similarly, if you have already
  138. Xmoved all your armies, and they are overcome by fatigue, then you will
  139. Xhave to wait until they have recovered.  This will happen in the
  140. Xupdate.  The time elapsed between updates is called a \emph{thon}.
  141. X
  142. X\chapter{Getting started}
  143. X
  144. XYour nation is added to the game by the Game Master, or someone
  145. Xtrusted by the Game Master.  You get to choose the \emph{name},
  146. X\emph{leader name}, \emph{race}, \emph{nation mark} (used for display)
  147. Xand \emph{magical order} for your nation.  The choice of race and
  148. Xmagical order are important: each race comes with certain
  149. Xcharacteristics (dwarves are better miners; elves are more
  150. Xintelligent, have good magical aptitude; orcs reproduce like crazy and
  151. Xso on\dots{}).  The magical order determines what spirits you will be
  152. Xable to summon, and which spells will be available for you to cast.
  153. XApart from the advantages of each race and magic order, they largely
  154. Xdetermine what role you will play in the game.
  155. X
  156. XWhen you first look at your country you will see sectors with letters on
  157. Xthem.  Each of these is a sector designation from which you can tell
  158. Xwhat your country uses the sector for.  You can change these
  159. Xdesignations once you own a sector; this will typically cost money,
  160. Xand maybe metal and jewels.
  161. X
  162. X\section{Moving around the map}
  163. XYou can move to another sector on the map using the [h], [j], [k], [l]
  164. Xkeys to move up, down, right, left; and the keys [y], [u], [b], [n] to
  165. Xmove diagonally.  This is similar to the cursor movements in some
  166. Xeditors (like \emph{vi}), and some UNIX games (such as \emph{rogue},
  167. X\emph{larn}, \emph{nethack}, \emph{conquer}, \dots{}).
  168. X
  169. XAlternatively, you may use the numeric keypad, in which case the
  170. Xnumber keys represent the same direction in which they point on the
  171. Xkeypad.  Both the ordinary keys and the numeric keypad can be used to
  172. Xbrowse the map and to move armies.  The following diagram shows you
  173. Xthe directions and keys you can use.
  174. X
  175. XFor large movements across the map, you can use the \emph{upper-case}
  176. Xletters [H], [J], [K], [L].  These jump 8 sectors over.
  177. X
  178. XOne last thing: when you are starting out in the game, you might be
  179. Xoverwhelmed by the number of commands, options, report screens, and so
  180. Xon\dots{}.  You might also be overwhelmed by the size of this manual,
  181. Xand not want to read it all until you have been playing a few turns.
  182. XThe way out is to just explore the commands described in the reference
  183. Xcard.  Except at main level of the game (where you look at your
  184. Xnation's map), all the commands have menus for the subcommands, and
  185. Xyou can usually follow those.  Moreover, we have a context-sensitive
  186. Xhelp system, so at any moment you can type [?] and get that part of
  187. Xthe manual which regards the command you are currently using.
  188. X
  189. X\comment hmm, think about keeping this on the same page.
  190. X\comment \newpage
  191. X\begin{verbatim}
  192. X                               NORTH
  193. X
  194. X                                (K)
  195. X                          y,7   k,8   u,9
  196. X                             \   |   /
  197. X                               \ | /
  198. X          WEST      (H) h,4 ---- 0 ---- l,6 (L)       EAST
  199. X                               / | \
  200. X                             /   |   \
  201. X                          b,1   j,2   n,3
  202. X                                (J)
  203. X
  204. X                               SOUTH
  205. X\end{verbatim}
  206. X
  207. X\section{Moving your armies}
  208. XArmies and navies are manipulated with the [a] menu.  Here are
  209. X\emph{some} of the army commands.  A complete list comes later.
  210. X
  211. X\begin{itemize}
  212. X
  213. X\item
  214. X\emph{[l]ist} army types will give you a list of army and navy types
  215. Xavailable to you for drafting.  As your technology improves, more army
  216. Xand navy types will become available.  At the start, you should only
  217. Xsee \emph{Cavemen} and \emph{Caravans} in the list.
  218. X
  219. X\item
  220. X\emph{[n]ext army}
  221. X\item
  222. X\emph{[p]revious army}.  These pick the next and previous armies in the
  223. Xcurrent sector, skipping armies that do not belong to you.  The
  224. Xcurrently ``picked'' army should be highlighted.
  225. X
  226. X\item
  227. X\emph{[N]} and \emph{[P]} are like [n] and [p], but they move the the next
  228. Xarmy \emph{number}, whether it is on the same sector or not.  These
  229. Xcan be used to cycle through all the armies in your nation.
  230. X
  231. X\item
  232. X\emph{[m]ove}. after you have selected an army you want to move just type
  233. X[m] and move the cursor to where you want the army to be.
  234. X\emph{Warning}: watch your army's \strong{move points} and the
  235. X\strong{move cost} of each sector you cross: if you run out your army
  236. Xmight get stuck where you don't want it!!
  237. X
  238. X\item
  239. X\emph{[s]tatus}.  This lets you change your army's status.  The status is
  240. Xthe mode your army is in, and affects what your army will do in
  241. Xvarious situation.  The most basic army statuses are:
  242. X
  243. X\begin{itemize}
  244. X\item
  245. X\emph{[a]ttack}. When in this mode your army will attack another
  246. Xarmy in the same sector.  This will happen only if you are at WAR
  247. Xor JIHAD.
  248. X
  249. X\item
  250. X\emph{[d]efend}. An army in defend status can not take a sector nor
  251. Xwill it attack another army.  If attacked it will defend itself.
  252. X
  253. X\item
  254. X\emph{[o]ccupy}. If you want to take a sector that is un-owned or owned
  255. Xby an enemy, you move an army to that sector and set its status to
  256. Xoccupy.
  257. X\end{itemize}
  258. X
  259. X\item
  260. X\emph{[d]raft}.  To draft an army or navy you must be in a city or
  261. Xcapital that you own.  Drafting an army will cost metal and money, so
  262. Xbe careful and watch how much you spend.  You will be given the list
  263. Xof available army types, (see [l]ist), and you must just type the
  264. Xabbreviation character for that army type.
  265. X
  266. X\end{itemize}
  267. X
  268. X\section{Taking sectors}
  269. XAt the beginning of the game, you should take many sectors: this gives
  270. Xa safety buffer around your capital, and allows you to look for
  271. Xresources in the new occupied lands.  You take sectors by moving an
  272. Xarmy \emph{of at least 100 soldiers} to that sector and setting it on
  273. Xoccupy mode.  If the sector belongs to another nation, you will have
  274. Xto declare war on them to take the sector from them.  You declare war
  275. Xusing the [r]eports menu, and choosing [d]iplomacy.
  276. X
  277. XOnce you take a sector (it will become yours after the update), you
  278. Xcan redesignate that sector so it produces what you want.  For
  279. Xexample, redesignating to a farm will make that sector produce food,
  280. Xand so on.  Sector designations are described in great detail later,
  281. Xbut you should know now that to change a designation you use the
  282. X[Z]oom key to focus on the specific sector, and then you can change
  283. Xthe designation with the [r]edesignate key \emph{inside} the [Z]oom
  284. Xscreen.  You will be given a menu of possible designations.
  285. X
  286. XTo help you choose a designation for the sectors you take, the sector
  287. Xwindow (to the bottom right of your screen) shows you the \strong{soil},
  288. X\strong{metal}, \strong{jewels} in that sector.  If the soil value is
  289. Xhigh, then redesignating to a \strong{farm} is a good idea.  If the
  290. Xsector has a high metal yield, you might want to make a \strong{metal mine}
  291. Xout of it, and so on.
  292. X
  293. XBelow is an example of a sector window that shows a sector with jewels
  294. X5, metal 0 and soil 6.  The sector belongs to nation Khazad Dum, has
  295. Xcoordinates (2, 2) relative to the current player, has 452 inhabitants
  296. Xwhich are of race (D) (Dwarves).
  297. X
  298. X\comment Hmm:  think about putting it on the same page or a new page
  299. X\comment \newpage
  300. X\begin{verbatim}
  301. X                                +----------------------+
  302. X                                |(2,2)                 |
  303. X                                |Khazad Dum-jwl. mine  |
  304. X                                |Brush Plateau         |
  305. X                                |452 people (D)        |
  306. X                                |metal 0     jewels 5  |
  307. X                                | soil 6   movecost 1  |
  308. X                                +----------------------+
  309. X\end{verbatim}
  310. X
  311. X\section{Setting up your budget}
  312. XIt is important that you set up your budget properly.  You do
  313. Xthis by hitting [r] ([r]eport), and then [b] (for the [b]udget
  314. Xreport).  In here you should choose your tax rate, and the amount of
  315. Xmoney/metal/jewels you choose to invest in various types of research.
  316. XA note about taxes: if your taxes are too high, your production of
  317. Xfood, metal and jewels will decrease.
  318. X
  319. XThere are default values set for investment in magic and technology,
  320. Xand there is a default tax rate.  This is intended to guide new
  321. Xplayers through their first moves.
  322. X
  323. XIn the budget report you can also spend a fraction of your
  324. X\emph{reserves} on various types of research.  To do this
  325. Xyou use the [s]torage option, and spend what you want of your current
  326. Xtreasury.  This amount will be reset to 0 after each update.
  327. X
  328. X\section{Checking out your info screen}
  329. XYou should check your info screen every thon.  This shows parameters
  330. Xof your race and nation, including your skills in magic and
  331. Xtechnology, combat, espionage and so forth.
  332. X
  333. X\section{Commands (brief)}
  334. XThis is a brief list of dominion commands.  It is actually a verbatim copy
  335. Xof the reference card available as on-line help in dominion (you access
  336. Xthis with the [?] key followed by [r]).
  337. X\newpage
  338. X\begin{verbatim}
  339. X                       Dominion QUICK REFERENCE CARD
  340. XMovement (you are where the `*' is):
  341. X                                   NORTH
  342. X                                    (K)
  343. X                              y,7   k,8   u,9
  344. X                                 \   |   /
  345. X                                   \ | /
  346. X              WEST      (H) h,4 ---- * ---- l,6 (L)       EAST
  347. X                                   / | \
  348. X                                 /   |   \
  349. X                              b,1   j,2   n,3
  350. X                                    (J)
  351. X                                   SOUTH
  352. XDisplay:
  353. X    [d]isplay options     [F] dump map to file   [w]indow manipulation
  354. X    [^L] redraw screen    [p] jump to a point    [P] jump to your capital
  355. XAdministration:
  356. X    [r]eports             [a]rmies               [Z]oom on sector
  357. X    [W]izardry            [t]ransportation       [C]onstruct
  358. XMiscellaneous:
  359. X    [Q]uit (or [q]uit)    [m]ail                 [N]ews
  360. X    [O]ptions
  361. X
  362. X\end{verbatim}
  363. X
  364. X\chapter{What is in the world}
  365. X
  366. XHere we describe races, terrain, technology, magic, designations,
  367. Xcommunications\dots{}
  368. X
  369. X\section{Races}
  370. XThere are several races in dominion, and each Game Master can add any
  371. Xraces s/he pleases by modifying the race descriptor file.
  372. X
  373. XThe parameters describing your race are strength, reproduction,
  374. Xmortality rate, intelligence, speed, stealth, the race's preferred
  375. Xaltitude, vegetation, and temperature, aptitude for magic, farming and
  376. Xmining.
  377. X
  378. XIn addition to these parameters, each race has certain special army
  379. Xtypes available to it.  For example, Orcs can draft armies of type
  380. X``Orc'', which have some advantages, and Harpies can draft armies of
  381. Xtype ``Harpies'' which can fly.  Ogres have the army type ``Ogres'',
  382. Xwhich fight very well; and Hobbits can draft ``Hobbits'', who are
  383. Xhidden from their enemies' sight.
  384. X
  385. XThe races currently available are Elf, Human, Dwarf, Orc, Merfolk,
  386. XIcefolk, Hobbit, Gnome, Harpy, Ogre, Walrus, Algae, and Squid.  If you have a
  387. Xrace you would like to play and do not see it listed, talk to your
  388. Xgame administrator about adding it to the game.  This should not be
  389. Xdone lightly, because the parameters describing each new race have to
  390. Xbe tuned to preserve game balance.
  391. X
  392. XSome of the races (Merfolk, Walrus, Algae, and Squid) live under water.  The
  393. Xgame is almost symmetrical for races that live above and below water,
  394. Xthough there are some differences.  Races that live above and below
  395. Xwater can interact (and fight) in several ways, as described below.
  396. X
  397. XEach of the above listed traits effects the races in the following ways:
  398. X
  399. X\begin{itemize}
  400. X\item
  401. XStrength: affects your combat bonus.
  402. X\item
  403. XReproduction: the rate at which people are born in your nation.
  404. X\item
  405. XMortality: every year this percentage of your population dies.
  406. X\item
  407. XIntelligence: affects your acquisition of technological skill, and
  408. Xalso helps in combat.
  409. X\item
  410. XSpeed: affects your armies' move points.
  411. X\item
  412. XStealth: affects your spy and secrecy skills.
  413. X\item
  414. XPreferred altitude, preferred vegetation, preferred temperature: these
  415. Xaffect migration of people, and move cost too.  If your race likes high
  416. Xtemperatures, deserts will have less move cost.  If they like high
  417. Xaltitude, mountains will have less move cost.
  418. X\item
  419. XMagic aptitude: this affects how quickly you learn the spells for the
  420. Xnation's chosen magical order, and how many spell points you gain.
  421. X\item
  422. XFarming: your farms produce this percentage more than their basic
  423. Xproductivity.  This will increase during the game, as you acquire new
  424. Xtechnology.
  425. X\item
  426. XMining: your metal and jewel mines produce this percentage more than
  427. Xtheir basic productivity.  This will increase during the game as you
  428. Xacquire new technology.
  429. X\end{itemize}
  430. X
  431. X\subsection{Basic races shipped with dominion}
  432. XThe Race descriptor table, below, shows the parameters for each race.
  433. X
  434. X\begin{same}
  435. X\begin{table}[hbpt]
  436. X\caption{Race Types}
  437. X\begin{tabular}{ || l | r | r | r | r | r | r | r | r | r | r | r | r || }
  438. X\hline
  439. XRace   &Str&Rep&Mort&Intel&Spd&Stl&Alt&Veg&Temp&Mag&Farm&Mine\\
  440. X\hline
  441. XMaster  & 0& 0& 0& 0&  0&0&0& 0& 0& 0& 0& 0\\
  442. XHuman   &80&11& 8&50& 65&4&2& 3& 7&30& 0& 0\\
  443. XElf     &70& 8& 5&70& 80&8&2& 5& 7&55&10&-15\\
  444. XOrc     &50&15&10&20& 40&3&4& 4& 4&35& 0& 5\\
  445. XDwarf   &95& 9& 6&60& 40&2&5& 3& 6&30&-5&20\\
  446. XHobbit  &15&10& 7&45& 50&9&3& 4& 7&20& 5& 5\\
  447. XMerfolk &30& 7& 4&75& 80&7&-2&-1& 4&55&50&-10\\
  448. XIcefolk &90& 9& 7&50& 70&4&3& 0&10&30&50& 0\\
  449. XGnome   &75&10& 8&95& 40&9&4& 3& 5&10& 0&10\\
  450. XHarpy   &40&12&10&25& 60&5&5& 4& 6&30& 0&-5\\
  451. XOgre    &95& 5& 3&75& 60&5&4& 3& 6&50& 5& 5\\
  452. XWalrus  &95& 9& 7&30& 80&3&-1&-1& 7&55&50& 5\\
  453. XAlgae   &15&11& 6&50& 60&7&-2&-1& 3&45&80& 0\\
  454. XSquid   &40& 9& 8&25& 110&8&-2&-1& 5&40&50&15\\
  455. X\hline
  456. X\end{tabular}
  457. X\end{table}
  458. X\end{same}
  459. X
  460. X\subsection{A brief history of each race}
  461. X\indent \strong{Elves} are a race of great wisdom and magical skill.  They do
  462. Xnot die unless killed in battle.
  463. X
  464. X\strong{Humans} are stronger than elves, but less wise, less magical, and
  465. Xthey have shorter life spans.
  466. X
  467. X\strong{Orcs} are an evil mockery of elves.  They come from elves that were
  468. Xcaptured by the Dark Lord and twisted into horrible shapes.  They
  469. Xreproduce very quickly, but are stupid, slow and weak.
  470. X
  471. X\strong{Dwarves} are sons of the earth.  They are very strong, as they were
  472. Xmade to withstand the world in an evil age.  They love mountains and caves,
  473. Xand typically build their kingdoms in great networks of caves.
  474. X
  475. X\strong{Hobbits} are merry little folk.  They meddle little into the affairs
  476. Xof men and elves, and are not a warlike people.  They can move very quietly.
  477. X
  478. X\strong{Merfolk} are people who live in the water.  They are strong in magic.
  479. X
  480. X\strong{Icefolk} are creatures of the polar caps and glaciers.  They like
  481. Xthe cold temperatures.
  482. X
  483. X\strong{Gnomes} are very technologically apt, but deal little with magic.
  484. X
  485. X\strong{Harpies} are stupid and vicious.  Their only strength is that they can
  486. Xdraft armies of flying Harpies.
  487. X
  488. X\strong{Ogres} are slow but strong.  They are quick to anger but soon forget
  489. Xwhat they were angry about.  They do not reproduce much, but are extremely
  490. Xinteligent.
  491. X
  492. X\strong{Walrus} are water creatures with a preference towards colder climates.
  493. XThey would rather sit on an iceberg than a warm sunny beach.
  494. X
  495. X\strong{Algae} are water creatures that move little, are quite weak against
  496. Xfoes, but handy with magic and farming.
  497. X
  498. X\strong{Squid} are very fast water creatures, with decent aptitudes.
  499. X
  500. X\subsection{Land-water interaction}
  501. XFor the most part, land races operate on land and water races in the
  502. Xwater.  But each can extend its influence to the other side of the sea
  503. Xlevel in various ways.
  504. X
  505. XShips, when owned by a land race, will travel on water.  The converse
  506. Xis true for a water race: its ships will travel on land.
  507. X
  508. XIf a land nation sees some good mines or farms in the water, it can
  509. Xoccupy that sector using {\em Swimmers} or {\em Scuba_divers} army
  510. Xunits which have the \key{W} (Water) flag.  Similarly, a water race
  511. Xcan occupy land sectors using armies such as {\em Walkers} which have
  512. Xthe \key{L} (Land) flag.  Notice that any other army or spirit with
  513. Xthe W and L flags will work fine.
  514. X
  515. XThe army types mentioned above all have the \key{f} (front line) flag,
  516. Xso they can be unloaded from ships onto the desired sector.
  517. X
  518. XOnce the sector is occupied you cannot move people into it or they
  519. Xwill drown (or suffocate).  But you can (at great expense) build a
  520. Xbubble over the sector (or cast a change-altitude spell) which will
  521. Xallow your people to move into it, even if it is a water (or land)
  522. Xsector.  This provides a means for colonizing the oceans (continents).
  523. X
  524. X\section{Technology}
  525. XA nation starts with very low skills in mining, farming, construction,
  526. Xetc\dots{} These skills can be developed by investing money or metal
  527. Xin technology research.  This investment is made in the budget report.
  528. XIncrease in technology depends on how much metal and money you invest
  529. Xeach thon.  Metal will increase technology proportional to the
  530. X\emph{4/3's root} of the amount of metal invested;
  531. Xmoney will increase technology proportional
  532. Xto the \emph{square root} of the amount of metal invested
  533. X
  534. XOther benefits of technological R\&D are that with each new technology
  535. Xyou develop, you can gain certain things.  For example, \strong{fire}
  536. Xincreases mining ability, decreases the mortality rate, and increases
  537. Xfarming ability.  As well, you can gain the ability to draft
  538. Xnew types of armies.
  539. X
  540. X\section{Magic}
  541. XYour nation is initiated to one of the magic orders available.
  542. X
  543. XEach order is characterized by the set of \strong{spells} known to that
  544. Xorder, and a set of \strong{spirits} that can be summoned by mages of
  545. Xthat order.  When you are initiated as a national leader you know only
  546. Xa little of the magic of that order, but you can increase your
  547. Xknowledge by investing money and jewels into magical research.  As you
  548. Xinvest more and more, your magic skill will increase, and you will
  549. Xlearn more advanced spells, and how to summon more powerful spirits.
  550. XThis investment is made with the budget report.
  551. X
  552. XAs with technology, your magic skill increase is proportional to the
  553. Xjewels invested, and to the square root of the money you invest.
  554. X
  555. XOn top of this, some magical orders bring a set of characteristics to
  556. Xits initiates.  These are described order by order.
  557. X
  558. XTo \emph{use} magic, i.e. to cast spells and summon spirits, you must
  559. Xacquire \strong{spell points}, and initiate one or more mages.  You get
  560. Xspell points in proportion to the amount of \emph{jewels} you invest
  561. Xin magical R\&D, but \emph{not} from your money investment.
  562. X
  563. XYou need to bring a mage to a certain sector to cast a spell in it or
  564. Xsummon a spirit there, so you should make sure you initiate some mages
  565. Xto work for your nation.  They cost a lot to initiate and maintain,
  566. Xbut are worthwhile.  Mages are initiated in your temples and
  567. Xuniversities, which are located in either the city or the country.
  568. X
  569. XThe [W]izardry command allows you [l]ist available spells and spirits,
  570. X[c]ast spells, [s]ummon spirits, and [i]nitiate mages.
  571. X
  572. XThe basic magic orders in dominion are:
  573. X
  574. X\begin{itemize}
  575. X
  576. X\item
  577. XOrder of \emph{Aule}.  Aule is the god of the earth, and is interested
  578. Xin all that happens in the depths of the earth.  He protects miners
  579. Xand workers of metal and stone, and gives them an extra 10% mining
  580. Xskill.
  581. X
  582. X\item
  583. XOrder of \emph{Avian}.  This order allows you to summon spirits 
  584. Xrelated to the air.
  585. X
  586. X\item
  587. XOrder of \emph{Chess}.  This order allows you to summon spirits
  588. Xsimilar to those on the chessboard in their movements and strength.
  589. X
  590. X\item
  591. XOrder of \emph{Demonology}, concerned with the conjuring of demons.
  592. X
  593. X\item
  594. XOrder of \emph{Diana}, mostly concerned with animals and hunting.
  595. X
  596. X\item
  597. XOrder of \emph{Inferno}.  This order is concerned with power through
  598. Xfire.
  599. X
  600. X\item
  601. XOrder of \emph{Monsters}, this order has available to it many
  602. Xmonstrous creatures.
  603. X
  604. X\item
  605. XOrder of \emph{Necromancy}, concerned with the invocation of dead and
  606. Xundead spirits.  Nations of this order start with their death rate
  607. Xincreased by 2%.
  608. X
  609. X\item
  610. XOrder of \emph{Neptune}.  Neptune is the god of the oceans, and his
  611. Xorder is concerned with the waters.
  612. X
  613. X\item
  614. XOrder of \emph{Time}.  This order steps back to the age of the
  615. Xdinosaurs.
  616. X
  617. X\item
  618. XOrder of \emph{Unity}.  This order has spirits that combine different
  619. Xcreatures in one body.
  620. X
  621. X\item
  622. XOrder of \emph{Yavanna}.  Yavanna is the godess of plants, and
  623. Xbasically everything that grows and is fertile is under her
  624. Xprotection.  Yavanna gives her initiates an extra 50% farming skill.
  625. X
  626. X\item
  627. XOrder of \emph{Insects}.  This order has spirits from the insect
  628. Xworld.  This initiation gives a nation 1% extra reproduction.
  629. X
  630. X\end{itemize}
  631. X
  632. XThe Game Master can add other magical orders to the game by inserting
  633. Xa list of spirits for that order into a file.
  634. X
  635. X\section{Designations}
  636. XIf you own a sector, you can \emph{redesignate} it.  That is, specify
  637. Xwhat function that sector has.  It costs a certain amount of money
  638. X(and possibly also metal, jewels, \dots{}) to redesignate a sector.
  639. X
  640. XEach type of sector can employ a different number of people.  For
  641. Xexample, a city can employ several thousand people, whereas a farm
  642. Xsector can only properly employ a few hundred people.  The \emph{basic
  643. Xnumber} of people that a sector can employ is listed in the table
  644. Xbelow.  This value is then modified by how much your race tends to
  645. Xcrowd.  If you are an orc, for example, more people can be crammed
  646. Xinto a single sector, so the formula is:
  647. X\begin{ifinfo}
  648. X    max_employed = sector_max * sqrt(reproduction / 10).
  649. X\end{ifinfo}
  650. X\begin{tex}
  651. X\[ max\_employed = sector\_max \times \sqrt{\frac{reproduction}{10}}. \]
  652. X\end{tex}
  653. X
  654. XThe possible designations (together with the characters that are
  655. Xdisplayed on the map) are:
  656. X\begin{itemize}
  657. X\item
  658. XFarm (\kbd{f}) - these produce food.  Without farmers producing food,
  659. Xyour people will starve to death.  Farms also generate revenue in the
  660. Xform of taxes.
  661. X\item
  662. XMetal mine (\kbd{m}) - supplies your country with metal, proportional to
  663. Xhow good the metal mine it is, how many people you have in it, and your
  664. Xmining ability.  Also generates revenue in the form of taxes.
  665. X\item
  666. XJewel mine (\kbd{j}) - supplies your country with jewels, proportional to
  667. Xhow good a jewel mine it is, how many people you have in it, and your
  668. Xmining ability.  Also generates revenue in the form of taxes.
  669. X\item
  670. XCity (\kbd{c}) - generate a lot of revenue in the form of taxes.
  671. XCities are also the places in which you can draft armies and construct
  672. Xships.  Cities also contain universities and temples, so mages can be
  673. Xinitiated in them.
  674. X\item
  675. XCapital (\kbd{C}) - are like cities, but the administrative bureaucracy
  676. Xof your nation is based in your capital, so if your capital is
  677. Xsacked, many of your nation's riches will be taken.
  678. X\item
  679. XUniversity (\kbd{u}) - this is a school of higher education.  Your
  680. Xcountry's intelligence can be increased if you put a lot of people in
  681. Xuniversities.  Universities cost to maintain.  Mages can be initiated
  682. Xin universities.
  683. X\item
  684. XTemple (\kbd{+}) - a place of worship.  Mages can be initiated in
  685. Xtemples.  Also, the fraction of your people in temples increases your
  686. Xmagic skill.
  687. X\item
  688. XStadium (\kbd{s}) - your country holds sports events here.  (for now,
  689. Xdoes nothing)
  690. X\item
  691. XTrade post (\kbd{T}) - a caravan or ship can give goods and armies to
  692. Xanother nation by dropping them off at a trade post belonging to that
  693. Xother nation.
  694. X\item
  695. XEmbassy (\kbd{e}) - necessary to establish relations with another
  696. Xcountry.  (for now, does nothing)
  697. X\item
  698. XFort (\kbd{!}) - forts give bonus to armies camped there (3/turn).
  699. X\item
  700. XHospital (\kbd{h}) - hospitals affect birth and death rates in your
  701. Xnation. (not yet) Hospitals have maintainance costs each turn.
  702. X\item
  703. XRefinery (\kbd{r}) - refines your metals.  Increases the productivity
  704. Xof adjacent metal mines.  A metal mine has 12% more production for
  705. Xeach surrounding refinery, if that refinery has at least the minimum
  706. Xemployment.
  707. X\end{itemize}
  708. X
  709. XThe \emph{Designation table} describes the properties of various
  710. Xdesignations: what they cost, how much revenue they produce per
  711. Xcapita, how much they cost to maintain, the minimum employment (not
  712. Xused in all cases), and how many people can be employed in that
  713. Xsector.
  714. X\begin{same}
  715. X\begin{table}[hbpt]
  716. X\caption{Designation table}
  717. X\begin{tabular}{ || l | l | l | l | l | l | l || }
  718. X\hline
  719. XDesignation &mark&desig& revenue & maint. & min  &  max    \\
  720. X            &    &cost & per cap.&per turn&people&employed \\
  721. X\hline
  722. XNone        &  x & 1000 &   30    &    0   &    0 &   20 \\
  723. XFarm        &  f & 5000 &  100    &    0   &   10 &  500 \\
  724. XMetal mine  &  m &10000 &  100    &    0   &   10 &  800 \\
  725. XJewel mine  &  j &10000 &  100    &    0   &   10 &  800 \\
  726. XCity        &  c &30000 &  200    &    0   &  300 & 5000 \\
  727. XCapital     &  C &50000 &  300    &    0   &  500 & 7000 \\
  728. XUniversity  &  u &10000 &   30    & 2000   &  200 & 1000 \\
  729. XTemple      &  + & 5000 &    0    &    0   &  200 & 1000 \\
  730. XStadium     &  s & 5000 &  150    &    0   &   10 &  400 \\
  731. XTrade post  &  T & 5000 &  150    &    0   &   10 &  300 \\
  732. XEmbassy     &  e & 5000 &    0    &    0   &   50 &  200 \\
  733. XFort        &  ! &10000 &   50    &    0   &   10 &  200 \\
  734. XHospital    &  h &10000 &  100    & 4000   &   10 &  300 \\
  735. XRefinery    &  r & 8000 &  130    &    0   &  100 &  200 \\
  736. X\hline
  737. X\end{tabular}
  738. X\end{table}
  739. X\end{same}
  740. X
  741. X\section{Economy and natural resources}
  742. XThe pillars of your economy are money and natural resources (soil
  743. Xfertility, metal and jewels).
  744. X
  745. X\subsection{Money}
  746. XYou get money by levying taxes.  You set the tax rate in the budget
  747. Xscreen.  It is not wise to set a very high tax rate, because that will
  748. Xkill the spirit of entrepreneurship in your nation, and production of
  749. Xfood, metal and jewels will decrease in proportion.
  750. X
  751. XMoney is spent for just about everything: redesignating sectors,
  752. Xdrafting and maintaining armies, research and development, supporting
  753. Xuniversities and hospitals, and many other things.
  754. X
  755. X\subsubsection{Debt}
  756. X
  757. X[NOTE: the section on bonds described here is not yet implemented;
  758. Xfor now a debt simply means negative money]
  759. X
  760. XIf your nation's money balance goes negative, you will be forced to
  761. Xissue bonds to your population to finance the debt (this happens
  762. Xautomatically over the update, so there is no way you can plummet into
  763. Xa negative balance).  You must then pay an interest on these bonds.
  764. X
  765. XAt any time you can also negotiate for other nations to purchase your
  766. Xbonds.  Interest rate on domestic bonds is fixed (15%/thon), but you
  767. Xcan negotiate the price for bonds issued to other countries.
  768. X
  769. XIf you want to finance a big war, and get lots of cash fast, the best
  770. Xway to go is probably to issue a lot of bonds to other countries.
  771. X
  772. X(??) The bonds your nation issues must always be backed by your
  773. Xreserve of jewels.
  774. X
  775. X\subsection{Soil fertility}
  776. XYour nation must produce the food necessary to feed its people.  This is
  777. Xdone by designating certain sectors to be farms.  These farms will be
  778. Xmore productive if they are on sectors with a better soil parameter.
  779. X
  780. XYour farming skill also determines how productive your farms will be.
  781. XYou can increase your farming skill with research in technology, because
  782. Xyour nation will discover better tools and methods for farming.
  783. X
  784. XIf your food production is insufficient, your reserves will be used.
  785. XIf those are not enough, you had better arrange to purchase some, or
  786. Xthat part of your civilians who did not get enough food will starve.
  787. XOnce all your civilians have starved, your armies will start to
  788. Xstarve.
  789. X
  790. X\subsection{Metal}
  791. XMetal represents all metals and construction materials used for
  792. Xpractical purposes, such as construction and armaments.  It is found
  793. Xin metal mines.  The production of each mine is greater if the sector
  794. Xhas a higher metal parameter, and is also increased by your nation's
  795. Xmining skill.  Your mining skill can increase if you invest in
  796. Xtechnology, because your nation will discover better tools for mining
  797. Xand prospecting.
  798. X
  799. XYou can spend your metal in several ways, including drafting armies,
  800. Xtechnological R\&D, constructing fortification and roads\dots{}
  801. X
  802. X\subsection{Jewels}
  803. XIn dominion, Jewels represent all kinds of rare resources, such as jewels,
  804. Xgold, silver, platinum, pearls, and so on.  Jewels are found in jewel
  805. Xmines.  How many jewels you produce in a mine depends on the jewels
  806. Xparameter of that sector, and also on your mining ability (see section
  807. Xon metal).
  808. X
  809. XJewels are very important, because they are invested in magical
  810. Xresearch, and are used to get spells.  In fact, your spell points
  811. Xdepend only on the amount of jewels you invest in magical R\&D.
  812. X
  813. XJewels are also important in that they constitute your nation's
  814. Xreserve that backs up its currency and bonds.  When you issue bonds,
  815. Xthese have to be backed up by jewels, so it is a good idea to save up
  816. Xsome jewels, and not spend them all. (note: bonds are not yet
  817. Ximplemented)
  818. X
  819. X(We must find another use for jewels, so nations have more choices to
  820. Xmake in spending jewels.)
  821. X
  822. X\section{Transportation and trade}
  823. XYou can trade with other nation, or just transport goods/armies/people
  824. Xfor your own benefit, using \strong{ships} and \strong{caravans}.
  825. XCaravans travel on land, whereas ships travel in the water.
  826. X
  827. XShips and caravans are ``drafted'' as if they were armies, and should
  828. Xappear in your [l]ist of available armies in the [a]rmy menu.  The
  829. Xconstruction and maintainance costs of ships and caravans are
  830. Xtabulated with those of other army types.  Note that some spirits also
  831. Xbehave as ships and caravas, in that they have the [c]argo flag.
  832. XExamples of this are the \emph{flying carpet}, the \emph{ghost ship}
  833. Xand the \emph{living ship}.
  834. X
  835. XA single cargo hold can only transport a certain amount of goods.  The
  836. Xunit of weight is \emph{the weight of a single person}, and a caravan
  837. Xcan transport 250 person weights.  A bar of metal weighs 0.1, money
  838. Xweighs 0.01 for a sheckel, food 0.05, a jewel basket 0.01.  If you
  839. Xload soldiers, their weight is equal to the weight of the number of
  840. Xpeople plus the weight of the metal used in drafting an army that
  841. Xsize.  Any caravan can transport only a single army and a single land
  842. Xtitle.  The land title does not have significant weight.
  843. X
  844. XTo load a caravan or navy, you select it (with [a]rmy commands) and
  845. Xthen use the [t]ransportation command to [l]oad goods, which can be
  846. X[s]hekels (money units), [m]etal, [f]ood, [p]eople, [a]army or
  847. X[t]itle.  To unload it you move the caravan or navy to its destination
  848. Xand do the same with [u]nload instead of [l]oad.
  849. X
  850. XYou can only load certain goods onto a caravan in certain places.
  851. XAnything can be loaded in a city.  Metal can also be loaded in metal
  852. Xmines, jewels in jewel mines and food in farms.  The title to a sector
  853. X\emph{must} be loaded on that sector itself.  People can be loaded
  854. Xfrom any of your own populated sectors.  Armies can be loaded anywhere
  855. Xin your land, but out of your territory they can only be loaded if
  856. Xthey have the front-line flag.
  857. X
  858. XTo unload in a foreign land you must be in a trading post, or you can
  859. Xunload armies with the front-line flag (for example, Sailors, Marines,
  860. XScuba divers).  To trade an army in a foreign trading post, you should
  861. Xput the army in TRADED status, and then unload it on the trading post.
  862. XAlternatively, since armies move on their own, you can put them on
  863. XTRADED status and just walk them up to the trading post.  When you
  864. Xstop that army on the foreign trading post, you will be asked if you
  865. Xreally want to trade it.  You can also change the army to TRADED
  866. Xstatus once it is already on the trading post.  In all cases you will
  867. Xbe asked for confirmation of the army trading.
  868. X
  869. XTransporting goods within your country is kind of useless.  In your
  870. Xland, goods must be unloaded in trading posts or cities.  Transporting
  871. Xpeople is an effective way of getting them to the better mines and
  872. Xfarms.  Transporting armies can help mobilize your forces more
  873. Xquickly, since you can then unload them and they can still march.
  874. X
  875. XSome armies, such as Sailors and Marines, have ``front line'' flag
  876. X(see the army types table).  This means that they can be unloaded from
  877. Xcaravans and ships anywhere: in your land, in un-owned land, and in
  878. Xforeign land.  Thus ships and caravans can be used for transportation
  879. Xof fighting troops, not just for trade and migration.
  880. X
  881. X\section{Communications}
  882. XNations in dominion communicate through \strong{mail} and \strong{news}.  Mail
  883. Xallows you to send personal messages to leaders of other nations.
  884. XNews is for general announcements, and is read by all nations.
  885. X
  886. XThere can be several newsgroups.  One is always reserved for messages
  887. Xfrom the computer, containing general information on what has happened
  888. Xover the update.  This newsgroup is usually called ``News''.  Other
  889. Xnewsgroups are set up by the Game Master, and any nation leader can
  890. Xpost to them.  At Stony Brook we usually have a newsgroup called
  891. X``public'' which receives many very creative postings from
  892. Xparticipants.
  893. X
  894. XYou should read your mail and news whenever you play your turn, to be
  895. Xin touch with your neighbours and the rest of the world.  You also get
  896. Xmail from the update program after each update, telling you what has
  897. Xchanged in your nation over the update.
  898. X
  899. X\section{Construction}
  900. XYou can construct on a sector with the [C]onstruct command.  Your
  901. Xconstruction will cost money and/or metal, and can make that sector
  902. Xmore valuable.  You can construct:
  903. X\begin{itemize}
  904. X\item
  905. X\emph{[r]oads:} decreases the move cost for you (and anyone else) in this
  906. Xsector.  The cost for building roads doubles for the next level of
  907. Xroad construction.  For each level of roads construction, the move
  908. Xcost goes down by 1 (but it never goes below 1).
  909. X\item
  910. X\emph{[f]ortification:} fortifies the current sector: adds 10 to the
  911. Xfortification level, which gives \emph{your} armies that much bonus
  912. Xwhen defending that sector.
  913. X\item
  914. X\emph{[b]ubbles:} these are air/water-tight bubbles.  They are necessary
  915. Xto colonize underwater (if you are an above-water race) and land (if you
  916. Xare an underwater nation).  Once you have a bubble, you can move
  917. Xtroops and civillians to that sector.
  918. X\end{itemize}
  919. X
  920. X\section{World topology}
  921. XThe world is shaped like a torus (i.e. the surface of a doughnut).
  922. XThis is the best approximation of a sphere which can be displayed
  923. Xeasily on a flat terminal.
  924. X
  925. XThus, the world wraps; so, for example, if you are playing
  926. Xin a 100x100 world, and your nation grows to be 100 sectors 
  927. Xwide, you can travel around the world.
  928. X
  929. X%\section{Terrain}
  930. X
  931. X\chapter{Diplomacy and war}
  932. X
  933. XDiplomatic relations with your neighbours are extremely important.
  934. XYour nation can be destroyed if you did not properly set your
  935. Xdiplomacy: you might make several enemies who could then form a treaty
  936. Xto fight you.  This happens quite often.
  937. X
  938. XYour nation starts out with 10 armies of 100 Cavemen in your capital;
  939. Xmore can be drafted using the [a]rmy menu.  Soldiers are used to
  940. Xoccupy unowned land, to defend your own territory, and also to conduct
  941. Xwar against enemy nations.
  942. X
  943. XTo occupy an unowned sector, you must have an army of at least 100
  944. Xsoldiers there, set on occupy mode.  To occupy a sector owned by
  945. Xanother nation, you have to declare \emph{WAR} or \emph{JIHAD} with
  946. Xthem.  Sectors can also be occupied by spirits with 100 units or more.
  947. X
  948. X\section{Diplomatic status}
  949. XIn the [r]eports menu, you can access your [d]iplomacy report.  This
  950. Xreport shows you your status toward other countries, and their status
  951. Xtoward you.  You start out \emph{UNMET} with all nations.  Then, as
  952. Xyour armies come close to their sectors, or vice-versa, the two
  953. Xnations will meet and be put in neutral status.
  954. X
  955. XYou can change your status to other countries.  A lot of statuses are
  956. Xpossible, but the most important ones are:
  957. X\begin{itemize}
  958. X\item[ALLIED]
  959. Xgives permission to the other nation to pass through your land at a
  960. Xlower move cost.  Also, you can put your armies in GARRISON in allied
  961. Xland, and they will get 1/2 of the GARRISON bonus.
  962. X\item[TREATY]
  963. Xgoes beyond ALLIED: if your armies or those of the other nation are
  964. Xinvolved in a battle, and the other has armies on the same sector, the
  965. Xtwo will fight together.  Also, if you put your armies in GARRISON in
  966. Xtreaty land, they will get the full GARRISON bonus.
  967. X\item[WAR]
  968. XIf any army of yours is on the same sector as an enemy army, and one
  969. Xof the two is on ATTACK or OCCUPY mode, there will be a battle.
  970. X\item[JIHAD]
  971. XFor now, the same as WAR.  In the future, JIHAD should involve some
  972. Xexpense, and give a better fighting bonus due to fanatism in combat.
  973. X\end{itemize}
  974. X
  975. XYou can change your diplomatic status towards any nation you have met.
  976. XThey will see the change immediately.  You can only change it by two
  977. Xdegrees, so that you cannot be ALLIED, march into someone's land, and
  978. Xthen declare WAR and occupy all their sectors.
  979. X
  980. END_OF_FILE
  981. if test 40579 -ne `wc -c <'dom_tex.aa'`; then
  982.     echo shar: \"'dom_tex.aa'\" unpacked with wrong size!
  983. fi
  984. # end of 'dom_tex.aa'
  985. fi
  986. if test -f 'file.c' -a "${1}" != "-c" ; then 
  987.   echo shar: Will not clobber existing file \"'file.c'\"
  988. else
  989. echo shar: Extracting \"'file.c'\" \(17975 characters\)
  990. sed "s/^X//" >'file.c' <<'END_OF_FILE'
  991. X  /* file.c -- file operations */
  992. X
  993. X/*
  994. X * Copyright (C) 1990 Free Software Foundation, Inc.
  995. X * Written by the dominion project.
  996. X *
  997. X * This file is part of dominion.
  998. X *
  999. X * dominion is free software; you can redistribute it and/or
  1000. X * modify it under the terms of the GNU General Public License as published
  1001. X * by the Free Software Foundation; either version 1, or (at your option)
  1002. X * any later version.
  1003. X *
  1004. X * This software is distributed in the hope that it will be useful,
  1005. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1006. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1007. X * GNU General Public License for more details.
  1008. X *
  1009. X * You should have received a copy of the GNU General Public License
  1010. X * along with this software; see the file COPYING.  If not, write to
  1011. X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1012. X */
  1013. X
  1014. X/* this module contains routines that read and write the
  1015. X   world data file, and also routines that handle lock files.
  1016. X */
  1017. X
  1018. X#include <stdio.h>
  1019. X#ifdef SYSV
  1020. X# include <string.h>
  1021. X#else
  1022. X# include <strings.h>
  1023. X#endif /* SYSV */
  1024. X#include "dominion.h"
  1025. X#include "misc.h"
  1026. X#define UPDATE_FILE "last_update"
  1027. X
  1028. Xextern int debug, compressed_world;
  1029. Xextern struct race_list *races;
  1030. Xextern Suser user;
  1031. X
  1032. Xread_world(wp, fname)
  1033. X     Sworld *wp;
  1034. X     char fname[];
  1035. X{
  1036. X  int i, j;
  1037. X  FILE *fp, *fopen();
  1038. X  char cmd[200];
  1039. X
  1040. X  compressed_world = check_compressed_world(fname);
  1041. X  if (compressed_world) {
  1042. X    sprintf(cmd, "zcat %s", fname);
  1043. X    if ((fp = popen(cmd, "r")) == NULL) {
  1044. X      printf("\r\ncannot open pipe <%s> for reading\r\n", cmd);
  1045. X      clean_exit();
  1046. X      exit(1);
  1047. X    }
  1048. X  } else {
  1049. X    if ((fp = fopen(fname, "r")) == NULL) {
  1050. X      printf("\r\ncannot open file <%s> for reading\r\n", fname);
  1051. X      clean_exit();
  1052. X      exit(1);
  1053. X    }
  1054. X  }
  1055. X  fprintf(stderr, "reading world data file %s", fname);
  1056. X
  1057. X  fread(&wp->turn, sizeof(int), 1, fp); /* get current turn */
  1058. X  fread(&wp->xmax, sizeof(int), 1, fp);    /* get world size */
  1059. X  fread(&wp->ymax, sizeof(int), 1, fp);
  1060. X/*  fprintf(stderr, "world size is %dx%d\n", wp->xmax, wp->ymax); */
  1061. X
  1062. X    /* make space for world sectors */
  1063. X  wp->map = (Ssector **) malloc(wp->xmax*sizeof(Ssector *));
  1064. X  for (i =  0; i < wp->xmax; ++i) {
  1065. X    wp->map[i] = (Ssector *) malloc(wp->ymax * sizeof(Ssector));
  1066. X  }
  1067. X    /* now read in the world map */
  1068. X  for (i = 0; i < wp->xmax; ++i) {
  1069. X    for (j = 0; j < wp->ymax; ++j) {
  1070. X      fread(&wp->map[i][j], sizeof(Ssector), 1, fp);
  1071. X      wp->map[i][j].alist = NULL;
  1072. X    }
  1073. X    if (i % (wp->xmax/8) == 0) {
  1074. X      fprintf(stderr, ".");
  1075. X      fflush(stdout);
  1076. X    }
  1077. X  }
  1078. X    /* load geography */
  1079. X  fread(&wp->geo, sizeof(wp->geo), 1, fp);
  1080. X  fprintf(stderr, ".");
  1081. X  fflush(stdout);
  1082. X        /* now read in nations */
  1083. X  fread(&wp->n_nations, sizeof(int), 1, fp);
  1084. X/*  printf("reading in %d nation%c\n",
  1085. X     wp->n_nations, wp->n_nations == 1 ? ' ' : 's'); */
  1086. X  for (i = 0; i < wp->n_nations; ++i) {
  1087. X      /* must find a better way of loading linked lists
  1088. X         (when I make the nations be a linked list!!)
  1089. X       */
  1090. X    read_nation(&wp->nations[i], fp, wp);
  1091. X    load_options(&wp->nations[i]);
  1092. X
  1093. X    fprintf(stderr, ".");
  1094. X    fflush(stdout);
  1095. X/*    if (debug) {
  1096. X      printf("just read nation %d\n", i);
  1097. X      show_nation(&wp->nations[i]);
  1098. X      putchar('.');
  1099. X    }
  1100. X*/
  1101. X  }
  1102. X  if (compressed_world) {
  1103. X    pclose(fp);
  1104. X  } else {
  1105. X    fclose(fp);
  1106. X  }
  1107. X  init_wrap();
  1108. X  fprintf(stderr, "\n");
  1109. X}
  1110. X
  1111. X  /* save the world data file */
  1112. Xwrite_world(wp, fname)
  1113. X     Sworld *wp;        /* pointer to the world */
  1114. X     char fname[];
  1115. X{
  1116. X  int i, j;
  1117. X  FILE *fp, *fopen();
  1118. X  char cmd[200];        /* for compression command */
  1119. X
  1120. X  if (compressed_world) {
  1121. X    sprintf(cmd, "compress > %s.Z", fname);
  1122. X    if ((fp = popen(cmd, "w")) == NULL) {
  1123. X      printf("\r\ncannot open pipe <%s> for writing\r\n", cmd);
  1124. X      clean_exit();
  1125. X      exit(1);
  1126. X    }
  1127. X  } else {
  1128. X    if ((fp = fopen(fname, "w")) == NULL) {
  1129. X      printf("cannot open file <%s> for writing\n", fname);
  1130. X      clean_exit();
  1131. X      exit(1);
  1132. X    }
  1133. X  }
  1134. X  critical();
  1135. X  fwrite(&wp->turn, sizeof(int), 1, fp); /* write current turn number */
  1136. X  fwrite(&wp->xmax, sizeof(int), 1, fp);
  1137. X  fwrite(&wp->ymax, sizeof(int), 1, fp);
  1138. X  for (i = 0; i < wp->xmax; ++i) {
  1139. X    for (j = 0; j < wp->ymax; ++j) {
  1140. X      fwrite(&wp->map[i][j], sizeof(Ssector), 1, fp);
  1141. X    }
  1142. X  }
  1143. X    /* write out geography */
  1144. X  fwrite(&wp->geo, sizeof(wp->geo), 1, fp);
  1145. X
  1146. X  printf("writing out %d nation%c\n",
  1147. X     wp->n_nations, wp->n_nations == 1 ? ' ' : 's');
  1148. X  fwrite(&wp->n_nations, sizeof(int), 1, fp);
  1149. X    /* only save as many nations as there are */
  1150. X  for (i = 0; i < wp->n_nations; ++i) {
  1151. X    write_nation(&wp->nations[i], fp);
  1152. X    if (debug) {
  1153. X      putchar('.');
  1154. X    }
  1155. X  }
  1156. X
  1157. X  if (compressed_world) {
  1158. X    pclose(fp);
  1159. X  } else {
  1160. X    fclose(fp);
  1161. X  }
  1162. X  noncritical();        /* delicate phase over */
  1163. X}
  1164. X
  1165. X  /* short hand */
  1166. X#define WRITE_DATUM(x) fwrite(&x, sizeof(x), 1, fp)
  1167. X
  1168. Xwrite_nation(np, fp)
  1169. X     Snation *np;
  1170. X     FILE *fp;
  1171. X{
  1172. X  int i;
  1173. X  Sarmy *ap;            /* for armies */
  1174. X  struct pt_list *pp;        /* for owned sectors */
  1175. X
  1176. X    /* here is how we save a nation:  write out the actual nation data
  1177. X       structure first, and after it write out the various linked lists
  1178. X       (which are the army list and the list of owned points).
  1179. X     */
  1180. X
  1181. X  fwrite(np, sizeof(Snation), 1, fp);
  1182. X
  1183. X    /* write out list of country's armies */
  1184. X  ap = np->armies;
  1185. X  for (i = 0; i < np->n_armies; ++i) {
  1186. X    fwrite(ap, sizeof(Sarmy), 1, fp);
  1187. X    if (debug) {
  1188. X      putchar('a');
  1189. X    }
  1190. X    ap = ap->next;
  1191. X  }
  1192. X
  1193. X    /* write list of owned locations */
  1194. X  pp = np->ptlist;
  1195. X  for (i = 0; i < np->n_sects; ++i) {
  1196. X    fwrite(pp, sizeof(struct pt_list), 1, fp);
  1197. X    if (debug) {
  1198. X      putchar('s');
  1199. X    }
  1200. X    pp = pp->next;
  1201. X  }
  1202. X}
  1203. X
  1204. Xread_nation(np, fp, wp)
  1205. X     Snation *np;
  1206. X     FILE *fp;
  1207. X     Sworld *wp;
  1208. X{
  1209. X  int i, x, y;
  1210. X  Ssector *sp;            /* for tmp use */
  1211. X  Sarmy army;            /* for armies */
  1212. X  struct pt_list *pp;        /* for owned sectors */
  1213. X
  1214. X    /* here is how we load a nation:  read out the actual nation data
  1215. X       structure first, and after it read out the various linked lists
  1216. X       (which are the army list and the list of owned
  1217. X       points).  This is harder than writing because we must insert
  1218. X       all into linked lists.
  1219. X     */
  1220. X
  1221. X  fread(np, sizeof(Snation), 1, fp); /* this is the easy part */
  1222. X
  1223. X    /* now reset to zero the nation's "current" R&D values:
  1224. X       that way the special R&D investments of the previous turn
  1225. X       are zeroed, and only the percent-of-revenue values are saved
  1226. X     */
  1227. X  np->cur_mag_r_d = np->cur_mag_r_d_jewels = 0;
  1228. X  np->cur_tech_r_d = np->cur_tech_r_d_metal = 0;
  1229. X  np->cur_spy_r_d = 0;
  1230. X
  1231. X  /* read list of country's armies add each army to the list for
  1232. X     its nation and for its sector. Special case for first army.
  1233. X   */
  1234. X  np->armies = NULL;
  1235. X  for (i = 0; i < np->n_armies; ++i) {
  1236. X    fread(&army, sizeof(Sarmy), 1, fp);
  1237. X    army.next = NULL;
  1238. X    x = army.pos.x;
  1239. X    y = army.pos.y;
  1240. X    sp = &(wp->map[x][y]);
  1241. X    if (i == 0) {
  1242. X/*      army.id = 0; */
  1243. X      np->armies = (Sarmy *) malloc(sizeof(Sarmy));
  1244. X      *(np->armies) = army;
  1245. X      np->armies->next = NULL;
  1246. X    } else {
  1247. X/*      if (debug) {
  1248. X    printf("Calling insert_army_nation, id=%d\n", army.id);
  1249. X      }
  1250. X*/
  1251. X      insert_army_nation(np, &army, army.id);
  1252. X/*      if (debug) {
  1253. X    printf("Called insert_army_nation.\n");
  1254. X      }
  1255. X*/
  1256. X    }
  1257. X/*    if (debug) {
  1258. X      printf("Calling insert_army_sector (%d,%d)\n", sp->loc.x, sp->loc.y);
  1259. X    }
  1260. X*/
  1261. X    insert_army_sector(sp, &army);
  1262. X  /*  if (debug) {
  1263. X      printf("Called insert_army_sector.\n");
  1264. X    }
  1265. X*/
  1266. X  }
  1267. X
  1268. X  /* read list of owned locations (special case for first one) */
  1269. X  if (np->n_sects > 0) {
  1270. X    np->ptlist = (struct pt_list *) malloc(sizeof(struct pt_list));
  1271. X    fread(np->ptlist, sizeof(struct pt_list), 1, fp);
  1272. X    /*    np->ptlist->pt = np->capital; */
  1273. X    np->ptlist->next = NULL;
  1274. X    pp = np->ptlist;
  1275. X  }
  1276. X  for (i = 1; i < np->n_sects; ++i) {
  1277. X    pp->next = (struct pt_list *) malloc(sizeof(struct pt_list));
  1278. X    fread(pp->next, sizeof(struct pt_list), 1, fp);
  1279. X    pp = pp->next;
  1280. X    pp->next = NULL;
  1281. X    if (debug) {
  1282. X      putchar('s');
  1283. X    }
  1284. X  }
  1285. X}
  1286. X
  1287. X  /* reads in the list of all races */
  1288. Xread_races()
  1289. X{
  1290. X  FILE *fp, *fopen();
  1291. X  char s[200];
  1292. X  int i, n_races;
  1293. X  Srace tmp_race;        /* for temporary use */
  1294. X  struct race_list *rlp;    /* to make the linked list */
  1295. X
  1296. X  if ((fp = fopen(RACES_FILE, "r")) == NULL) {
  1297. X    printf("cannot open races file.  you might have the wrong directory..\n");
  1298. X    clean_exit();
  1299. X    exit(1);
  1300. X  }
  1301. X
  1302. X    /* the initial race is the master, and is hardwired */
  1303. X  races = (struct race_list *) malloc(sizeof(struct race_list));
  1304. X  strcpy(races->race.name, "Master");
  1305. X  races->race.mark = 'C';
  1306. X  races->race.strength = 0;
  1307. X  races->race.repro = 0;
  1308. X  races->race.mortality = 0;
  1309. X  races->race.intel = 0;
  1310. X  races->race.speed = 0;
  1311. X  races->race.stealth = 0;
  1312. X  races->race.pref_alt = 0;
  1313. X  races->race.pref_terrain = 0;
  1314. X  races->race.pref_climate = 0;
  1315. X  races->race.mag_apt = 0;
  1316. X  races->race.farming = 0;
  1317. X  races->race.mining = 0;
  1318. X  races->next = NULL;
  1319. X
  1320. X  rlp = races;
  1321. X
  1322. X    /* now get the number of races from the file
  1323. X       (we trust that the file is consistent)
  1324. X     */
  1325. X  fgets(s, 180, fp);
  1326. X  while (s[0] == '#') {        /* ignore comments */
  1327. X/*    if (debug) {
  1328. X      printf("<%s>", s);
  1329. X    }
  1330. X*/
  1331. X    fgets(s, 180, fp);
  1332. X  }
  1333. X/*  if (debug) {
  1334. X    printf("<%s>", s);
  1335. X  }
  1336. X*/
  1337. X  sscanf(s, "%d", &n_races);    /* first line has number of races */
  1338. X
  1339. X  for (i = 0; i < n_races; ) { /* now read them in!! */
  1340. X    char c;
  1341. X    char name[180];
  1342. X    fgets(s, 180, fp);
  1343. X    s[strlen(s)-1] = '\0';
  1344. X/*    if (debug) {
  1345. X      printf("<%s>", s);
  1346. X    }
  1347. X*/
  1348. X    if (s[0] != '#') {        /* skip comments */
  1349. X      ++i;
  1350. X      sscanf(s,
  1351. X        "%s : %1s : %d : %d : %d : %d : %d : %d : %d : %d : %d : %d : %d : %d",
  1352. X         tmp_race.name, &tmp_race.mark, &tmp_race.strength,
  1353. X         &tmp_race.repro, &tmp_race.mortality, &tmp_race.intel,
  1354. X         &tmp_race.speed, &tmp_race.stealth, &tmp_race.pref_alt,
  1355. X         &tmp_race.pref_terrain, &tmp_race.pref_climate,
  1356. X         &tmp_race.mag_apt, &tmp_race.farming, &tmp_race.mining);
  1357. X
  1358. X/*      if (debug) {
  1359. X    show_race(&tmp_race);
  1360. X      }
  1361. X*/
  1362. X        /* now that we have loaded it, add it to the list */
  1363. X      rlp->next = (struct race_list *) malloc(sizeof(struct race_list));
  1364. X      rlp = rlp->next;
  1365. X      rlp->race = tmp_race;
  1366. X      rlp->next = NULL;
  1367. X    }
  1368. X  }
  1369. X  fclose(fp);
  1370. X}
  1371. X
  1372. X  /* this routine checks to see if the world file is
  1373. X     in a compressed format.  It it is, it returns 1.
  1374. X     Otherwise, 0.
  1375. X   */
  1376. Xcheck_compressed_world(fname)
  1377. X     char fname[];
  1378. X{
  1379. X  char Zname[200];
  1380. X  FILE *fopen(),*fp;
  1381. X
  1382. X  strcpy(Zname, fname);
  1383. X  strcat(Zname, ".Z");        /* if .Z file exists, it must be compressed! */
  1384. X  if ((fp = fopen(Zname, "r")) != NULL) {
  1385. X    fclose(fp);
  1386. X    return 1;
  1387. X  }
  1388. X  return 0;
  1389. X}
  1390. X
  1391. X  /* sets a master lock file */
  1392. Xset_master_lock()
  1393. X{
  1394. X  close(creat("lock.master", 0600));
  1395. X}
  1396. X
  1397. X  /* sets a lock for the given nation id */
  1398. Xset_lock(id)
  1399. X     int id;
  1400. X{
  1401. X  char fname[PATHLEN];
  1402. X  FILE *fp, *fopen();
  1403. X  extern Sworld world;
  1404. X  extern int ruid;
  1405. X  long now_secs;
  1406. X
  1407. X  sprintf(fname, "lock.%d", id);
  1408. X/*  close(creat(fname, 0666)); */
  1409. X  if ((fp = fopen(fname, "w")) == NULL) {
  1410. X    printf("cannot open the lock file file <%s> for writing\n", fname);
  1411. X    clean_exit();
  1412. X    exit(1);
  1413. X  }
  1414. X  now_secs = time(0L);
  1415. X    /* now put some titbits of information into the lock file */
  1416. X  fprintf(fp, "%ld; Nation %s; real uid %d; time: %s", now_secs,
  1417. X      world.nations[id].name, ruid, ctime(&now_secs));
  1418. X  fclose(fp);
  1419. X}
  1420. X
  1421. X  /* removes a lock for the given nation id */
  1422. Xdel_lock(id)
  1423. X     int id;
  1424. X{
  1425. X  char fname[PATHLEN];
  1426. X
  1427. X  sprintf(fname, "lock.%d", id);
  1428. X  unlink(fname);
  1429. X}
  1430. X
  1431. X  /* removes the master lock file */
  1432. Xdel_master_lock()
  1433. X{
  1434. X  unlink("lock.master");
  1435. X}
  1436. X
  1437. X  /* tries to open the lock file.  returns the file pointer
  1438. X     it gets, with the file open for reading (if it exists)
  1439. X   */
  1440. XFILE *is_locked(id)
  1441. X     int id;
  1442. X{
  1443. X  FILE *fopen();
  1444. X  char fname[PATHLEN];
  1445. X
  1446. X  sprintf(fname, "lock.%d", id);
  1447. X  return fopen(fname, "r");
  1448. X/*  if ((fp = fopen(fname, "r")) != NULL) {
  1449. X    fclose(fp);
  1450. X    return 1;            /* yeah, it is locked */
  1451. X/*  }
  1452. X  return 0; */
  1453. X}
  1454. X
  1455. X  /* checks if even a single nation has a lock or not */
  1456. Xis_any_lock()
  1457. X{
  1458. X  int i;
  1459. X  FILE *fp;
  1460. X
  1461. X  for (i = 0; i < NATIONS; ++i) {
  1462. X    if (fp = is_locked(i)) {
  1463. X      fclose(fp);
  1464. X      return 1;
  1465. X    }
  1466. X  }
  1467. X  return 0;
  1468. X}
  1469. X
  1470. X  /* cheks if there is a master lock file */
  1471. Xis_master_lock()
  1472. X{
  1473. X  FILE *fp, *fopen();
  1474. X
  1475. X  if ((fp = fopen("lock.master", "r")) != NULL) {
  1476. X    fclose(fp);
  1477. X    return 1;
  1478. X  }
  1479. X  return 0;
  1480. X}
  1481. X
  1482. Xset_update_time()
  1483. X{
  1484. X  char fname[PATHLEN];
  1485. X  FILE *fp, *fopen();
  1486. X  extern Sworld world;
  1487. X  extern int ruid;
  1488. X  long now_secs;
  1489. X
  1490. X  sprintf(fname, UPDATE_FILE);
  1491. X  if ((fp = fopen(fname, "w")) == NULL) {
  1492. X    printf("cannot open the update file file <%s> for writing\n", fname);
  1493. X    clean_exit();
  1494. X    exit(1);
  1495. X  }
  1496. X  now_secs = time(0L);
  1497. X    /* now put some titbits of information into the lock file */
  1498. X  fprintf(fp, "%ld; time: %s", now_secs, ctime(&now_secs));
  1499. X  fclose(fp);
  1500. X}
  1501. X
  1502. Xchar *get_update_time()
  1503. X{
  1504. X  char fname[PATHLEN];
  1505. X  FILE *fp, *fopen();
  1506. X  extern Sworld world;
  1507. X  extern int ruid;
  1508. X  long secs, len;
  1509. X  char s[300], *rtvl, *tmp;
  1510. X
  1511. X  sprintf(fname, UPDATE_FILE);
  1512. X  if ((fp = fopen(fname, "r")) == NULL) {
  1513. X    set_update_time();
  1514. X  }
  1515. X  fgets(s,299,fp);
  1516. X  if ((rtvl = (char *) malloc(strlen(s) * sizeof(char))) == NULL) mem_error();
  1517. X  tmp = strchr(s,(int)':');
  1518. X  strcpy(rtvl,(tmp+1));
  1519. X  fclose(fp);
  1520. X  return rtvl;
  1521. X}
  1522. X
  1523. Xmem_error()
  1524. X/* 
  1525. X  If we can't allocate any more memory, then tell the user that's the
  1526. X  case, and then die quietly, rather than the horrible death not 
  1527. X  checking mallocs would cause.
  1528. X*/
  1529. X{
  1530. X  fprintf(stderr,"Error: Couldn't allocate requested memory");
  1531. X  cleanup();
  1532. X  clean_exit();
  1533. X  exit(1);
  1534. X}     
  1535. X
  1536. Xload_options(np)
  1537. XSnation *np;
  1538. X/* Loads various options form the options file into the user's option record */
  1539. X{
  1540. X  char opt_file[PATHLEN], opt_line[100];
  1541. X  FILE *fopt;
  1542. X  int len;
  1543. X
  1544. X  init_options(np);
  1545. X  sprintf(opt_file, "%s/opt.%d", OPT_DIR, np->id);
  1546. X  if ((fopt = fopen(opt_file,"r")) == NULL) {
  1547. X    save_options(np);
  1548. X    return;
  1549. X  }
  1550. X  while (fgets(opt_line, 99, fopt) != NULL) {
  1551. X    if (strncmp(opt_line, "EXPERT_MODE: ", 13) == 0)
  1552. X    {
  1553. X      np->opts->expert_mode = atoi(&(opt_line[13]));
  1554. X      user.xmode = np->opts->expert_mode;
  1555. X    } else if (strncmp(opt_line, "CIV_MOVEMODE: ", 14) == 0) {
  1556. X      np->opts->civ_movemode = atoi(&(opt_line[14]));
  1557. X    } else if (strncmp(opt_line, "MAIL_FORWARD: ", 14) == 0) {
  1558. X      if (opt_line[14] == '\n') { 
  1559. X        np->opts->mail_forward = NULL;
  1560. X        continue;
  1561. X      }
  1562. X      len = strlen(&(opt_line[14]));
  1563. X      if ((np->opts->mail_forward = (char *)malloc((len + 1)* sizeof(char)))
  1564. X           == NULL) { mem_error(); }
  1565. X      strcpy(np->opts->mail_forward,&(opt_line[14]));
  1566. X      len = strlen(np->opts->mail_forward);
  1567. X      if (np->opts->mail_forward[len - 1] == '\n') {
  1568. X        np->opts->mail_forward[len - 1] = '\0';
  1569. X      }
  1570. X    } else if (strncmp(opt_line, "MAIL_READER: ", 13) == 0) {
  1571. X      if (opt_line[13] == '\n') { 
  1572. X        np->opts->mail_reader = NULL;
  1573. X        continue;
  1574. X      }
  1575. X      len = strlen(&(opt_line[13]));
  1576. X      if ((np->opts->mail_reader = (char *)malloc((len + 1)* sizeof(char)))
  1577. X           == NULL) { mem_error(); }
  1578. X      strcpy(np->opts->mail_reader,&(opt_line[13]));
  1579. X      len = strlen(np->opts->mail_reader);
  1580. X      if (np->opts->mail_reader[len - 1] == '\n') {
  1581. X        np->opts->mail_reader[len - 1] = '\0';
  1582. X      }
  1583. X    } else {
  1584. X      fprintf(stderr,"Error: Bad Option %s\n",opt_line);
  1585. X    }
  1586. X  }
  1587. X  fclose(fopt);
  1588. X}
  1589. X
  1590. Xsave_options(np)
  1591. X/* Save all of the user's optoins to a file. */
  1592. XSnation *np;
  1593. X{
  1594. X  FILE *fopt;
  1595. X  char opt_file[PATHLEN], opt_line[100], *rtvl = NULL;
  1596. X  int len;
  1597. X
  1598. X  sprintf(opt_file, "%s/opt.%d", OPT_DIR, np->id);
  1599. X  if ((fopt = fopen(opt_file,"w")) == NULL) {
  1600. X    clean_exit();
  1601. X    fprintf(stderr,"Error: Cannot Open Options File %s\n",opt_file);
  1602. X    exit(1);
  1603. X  }
  1604. X
  1605. X  fprintf(fopt,"EXPERT_MODE: %d\n",np->opts->expert_mode);
  1606. X  fprintf(fopt,"CIV_MOVEMODE: %d\n", np->opts->civ_movemode);
  1607. X  if (np->opts->mail_forward == NULL) {
  1608. X    fprintf(fopt,"MAIL_FORWARD: \n");
  1609. X  } else {
  1610. X    fprintf(fopt,"MAIL_FORWARD: %s\n",np->opts->mail_forward);
  1611. X  }
  1612. X  if (np->opts->mail_reader == NULL) {
  1613. X    fprintf(fopt,"MAIL_READER: \n");
  1614. X  } else {
  1615. X    fprintf(fopt,"MAIL_READER: %s\n",np->opts->mail_reader);
  1616. X  }
  1617. X  fclose (fopt);
  1618. X}
  1619. X
  1620. Xchar *get_char_option(user_num, optname)
  1621. X/* This function returns a character option for the given user */
  1622. Xint user_num;
  1623. Xchar *optname;
  1624. X{
  1625. X  FILE *fopt;
  1626. X  char opt_file[PATHLEN], opt_line[100], *rtvl = NULL;
  1627. X  int len, optlen = strlen(optname);
  1628. X
  1629. X  sprintf(opt_file, "%s/opt.%d", OPT_DIR, user_num);
  1630. X  if ((fopt = fopen(opt_file,"r")) == NULL) {
  1631. X    return NULL;
  1632. X  }
  1633. X
  1634. X  while (fgets(opt_line, 99, fopt) != NULL) {
  1635. X    if (strncmp(opt_line, optname, optlen) == 0) {
  1636. X      if (opt_line[optlen + 2] == '\n') { 
  1637. X        rtvl = NULL;
  1638. X        break;
  1639. X      }
  1640. X      len = strlen(&(opt_line[optlen + 2]));
  1641. X      if ((rtvl = (char *)malloc((len + 1)* sizeof(char))) == NULL) { 
  1642. X       mem_error(); }
  1643. X      strcpy(rtvl,&(opt_line[optlen + 2]));
  1644. X      len = strlen(rtvl);
  1645. X      if (rtvl[len - 1] == '\n') {
  1646. X        rtvl[len - 1] = '\0';
  1647. X      }
  1648. X    }
  1649. X  }
  1650. X  fclose(fopt);
  1651. X  return rtvl;
  1652. X}
  1653. X
  1654. Xint get_int_option(user_num, optname)
  1655. X/* This function returns an integer option for a given user */
  1656. Xint user_num;
  1657. Xchar *optname;
  1658. X{
  1659. X  FILE *fopt;
  1660. X  char opt_file[PATHLEN], opt_line[100];
  1661. X  int len, optlen = strlen(optname), rtvl;
  1662. X
  1663. X  sprintf(opt_file, "%s/opt.%d", OPT_DIR, user_num);
  1664. X  if ((fopt = fopen(opt_file,"r")) == NULL) {
  1665. X    return NULL;
  1666. X  }
  1667. X
  1668. X  while (fgets(opt_line, 99, fopt) != NULL) {
  1669. X    if (strncmp(opt_line, optname, optlen) == 0) {
  1670. X      rtvl = atoi(&(opt_line[optlen + 2]));
  1671. X      break;
  1672. X    }
  1673. X  }
  1674. X
  1675. X  fclose(fopt);
  1676. X  return rtvl;
  1677. X}
  1678. X  
  1679. Xinit_options(np)
  1680. X/* Init an unused option record */
  1681. XSnation *np;
  1682. X{
  1683. X  if ((np->opts = (Soptions *)malloc(sizeof(Soptions))) == NULL){mem_error();}
  1684. X  
  1685. X  np->opts->expert_mode = 0;
  1686. X  np->opts->civ_movemode = 2; /* Move freely unless restricted by gov */
  1687. X  np->opts->mail_forward = NULL;
  1688. X  np->opts->mail_reader = NULL;
  1689. X}
  1690. END_OF_FILE
  1691. if test 17975 -ne `wc -c <'file.c'`; then
  1692.     echo shar: \"'file.c'\" unpacked with wrong size!
  1693. fi
  1694. # end of 'file.c'
  1695. fi
  1696. echo shar: End of archive 16 \(of 28\).
  1697. cp /dev/null ark16isdone
  1698. MISSING=""
  1699. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ; do
  1700.     if test ! -f ark${I}isdone ; then
  1701.     MISSING="${MISSING} ${I}"
  1702.     fi
  1703. done
  1704. if test "${MISSING}" = "" ; then
  1705.     echo You have unpacked all 28 archives.
  1706.     echo "Now execute ./do_cat.sh to build doc files"
  1707.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1708. else
  1709.     echo You still need to unpack the following archives:
  1710.     echo "        " ${MISSING}
  1711. fi
  1712. ##  End of shell archive.
  1713. exit 0
  1714.