Debian Codegraph @

Data_Generators/makedata/creamake.pas

raw
1 program generatecargodata;
2 (********************************************************************
3 This file is part of Ironseed.
4
5 Ironseed is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ironseed is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ironseed. If not, see <https://www.gnu.org/licenses/>.
17 ********************************************************************)
18
19 {*********************************************
20 Data Generator: Item creation dependencies
21
22 Copyright:
23 1994 Channel 7, Destiny: Virtual
24 2020 Matija Nalis <[email protected]>
25 **********************************************}
26
27 {$PACKRECORDS 1}
28
29 uses crt;
30
31 const
32 maxcreation= 123;
33 maxcargo= 145;
34
35 type
36 creationtype=
37 record
38 index: integer;
39 name: string[20];
40 parts: array[1..3] of integer;
41 levels: array[1..6] of byte;
42 end;
43 createarraytype=array[1..maxcreation] of creationtype;
44 cargotype=
45 record
46 name: string[20];
47 size,index: integer;
48 end;
49 cargoarray= array[1..maxcargo] of cargotype;
50 var
51 f: file of creationtype;
52 create: creationtype;
53 ft: text;
54 j,total: integer;
55 c: char;
56 ca: ^createarraytype;
57 cr: ^cargoarray;
58
59 function getworth(item: integer): integer;
60 var i,j,worth: integer;
61 begin
62 i:=0;
63 worth:=0;
64 case item of
65 3000: worth:=27;
66 4000: worth:=9;
67 4020: worth:=1;
68 5000..5999: worth:=3;
69 1000..1499: begin i:=1; worth:=4; end;
70 1500..1599: begin i:=1; worth:=6; end;
71 2000..2999: begin i:=1; worth:=4; end;
72 3001..3999: begin i:=1; worth:=3; end;
73 4001..4019: begin i:=1; worth:=2; end;
74 4021..4999: begin i:=1; worth:=2; end;
75 end;
76 if i=1 then
77 begin
78 while ca^[i].index<>item do inc(i);
79 for j:=1 to 3 do
80 if ca^[i].parts[j]>4999 then inc(worth)
81 else worth:=worth+getworth(ca^[i].parts[j]);
82 end;
83 getworth:=worth;
84 end;
85
86 procedure getlist;
87 var f: file of createarraytype;
88 f2: file of cargoarray;
89 j,i,a: integer;
90 ft: text;
91 begin
92 new(ca);
93 new(cr);
94 assign(f,'data/creation.dta');
95 reset(f);
96 read(f,ca^);
97 close(f);
98 assign(f2,'data/cargo.dta');
99 reset(f2);
100 read(f2,cr^);
101 close(f2);
102 assign(ft,'Data_Generators/other/itemdata.txt');
103 rewrite(ft);
104 writeln(ft,' ITEM TO CREATE PART #1 PART #2 PART #3 WORTH LEVELS ');
105 writeln(ft,'---------------------- ----------------------- ----------------------- ----------------------- ------- -------------------------------------------');
106 for j:=1 to maxcreation do
107 begin
108 { i:=1;
109 while (i<7) and (ca^[j].levels[i]<6) do inc(i);
110 if i=7 then
111 begin}
112 write(ft,ca^[j].name,#9);
113 for i:=1 to 3 do
114 begin
115 a:=1;
116 while (cr^[a].index<>ca^[j].parts[i]) and (a<maxcargo-1) do inc(a);
117 write(ft,cr^[a].name,#9);
118 end;
119 a:=getworth(ca^[j].index);
120 write(ft,a,#9);
121 for i:=1 to 6 do
122 write(ft,ca^[j].levels[i],#9);
123 writeln(ft);
124 end;
125 { end;}
126 dispose(cr);
127 dispose(ca);
128 close(ft);
129 end;
130
131 begin
132 assign(f,'data/creation.dta');
133 rewrite(f);
134 assign(ft,'Data_Generators/makedata/creation.txt');
135 reset(ft);
136 total:=0;
137 repeat
138 inc(total);
139 read(ft,create.index);
140 for j:=1 to 5 do read(ft,c);
141 read(ft,create.name);
142 for j:=1 to 3 do read(ft,create.parts[j]);
143 for j:=1 to 5 do read(ft,create.levels[j]);
144 writeln(create.name);
145 readln(ft,create.levels[6]);
146 write(f,create);
147 until total=maxcreation;
148 close(f);
149 close(ft);
150 {}
151 getlist;
152 end.