5 * Created by Alyssa Milburn on Sat 21 Oct 2006.
6 * Copyright (c) 2006-2008 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
23 #include "endianlove.h"
30 * Note that we don't use shared_ptr here, everything is owned by the
31 * SFCFile. I couldn't find a way to cast downwards with shared_ptr,
32 * and since everything revolves around slurpMFC - which can only return
33 * the base SFCClass type - it seemed best to just use pointers, since
34 * ownership is clear. - fuzzie
44 uint16 species
, eventno
;
47 void read(class SFCFile
*);
53 bool reading_compound
;
57 std::vector
<SFCClass
*> storage
;
58 std::map
<unsigned int, unsigned int> types
;
60 std::istream
*ourStream
;
64 std::vector
<SFCObject
*> objects
;
65 std::vector
<SFCScenery
*> scenery
;
66 std::vector
<SFCScript
> scripts
;
68 uint32 scrollx
, scrolly
;
69 // TODO: favourite places
71 SFCFile() : reading_compound(false), reading_scenery(false) { }
73 void read(std::istream
*i
);
74 SFCClass
*slurpMFC(unsigned int reqtype
= 0);
79 signed int reads32() { return (signed int)read32(); }
80 std::string
readBytes(unsigned int n
);
81 std::string
readstring();
83 bool readingScenery() { return reading_scenery
; }
84 bool readingCompound() { return reading_compound
; }
85 void setVersion(unsigned int v
);
86 unsigned int version() { return ver
; }
96 SFCClass(SFCFile
*p
) : parent(p
) { }
97 virtual ~SFCClass() { }
99 SFCClass
*slurpMFC(unsigned int reqtype
= 0) { return parent
->slurpMFC(reqtype
); }
100 uint8
read8() { return parent
->read8(); }
101 uint16
read16() { return parent
->read16(); }
102 uint32
read32() { return parent
->read32(); }
103 signed int reads32() { return parent
->reads32(); }
104 std::string
readBytes(unsigned int n
) { return parent
->readBytes(n
); }
105 std::string
readstring() { return parent
->readstring(); }
107 virtual void read() = 0;
110 SFCFile
*getParent() { return parent
; }
113 class CGallery
: public SFCClass
{
117 std::string filename
;
119 // no real need for sizes/offsets/etc..
121 CGallery(SFCFile
*p
) : SFCClass(p
) { }
125 class CDoor
: public SFCClass
{
130 CDoor(SFCFile
*p
) : SFCClass(p
) { }
134 class CRoom
: public SFCClass
{
137 uint32 left
, top
, right
, bottom
;
138 std::vector
<CDoor
*> doors
[4];
141 uint8 inorganicnutrients
, organicnutrients
, temperature
, pressure
, lightlevel
, radiation
;
142 signed char heatsource
, pressuresource
, lightsource
, radiationsource
;
144 std::vector
<std::pair
<uint32
, uint32
> > floorpoints
;
150 CRoom(SFCFile
*p
) : SFCClass(p
) { }
154 class MapData
: public SFCClass
{
156 CGallery
*background
;
157 std::vector
<CRoom
*> rooms
;
158 unsigned int groundlevels
[261];
162 MapData(SFCFile
*p
) : SFCClass(p
) { }
168 class SFCEntity
: public SFCClass
{
172 uint8 currframe
, imgoffset
;
177 std::string animstring
;
185 std::vector
<std::pair
<int, int> > pickup_handles
;
186 std::vector
<std::pair
<int, int> > pickup_points
;
188 // TODO: misc data/flags
189 SFCEntity(SFCFile
*p
) : SFCClass(p
) { }
193 class SFCObject
: public SFCClass
{
195 SFCObject(SFCFile
*p
) : SFCClass(p
) { }
201 uint32 unid
; // needed?
203 uint32 left
, top
, right
, bottom
; // what is this?
206 std::string currentsound
;
210 uint32 tickreset
, tickstate
;
212 uint32 variables
[100];
215 uint32 range
, accg
, velx
, vely
, rest
, aero
;
220 std::vector
<SFCScript
> scripts
;
222 virtual void copyToWorld() = 0;
223 virtual class Agent
*copiedAgent() = 0;
227 int left
, top
, right
, bottom
;
233 class SFCCompoundObject
: public SFCObject
{
235 class CompoundAgent
*ourAgent
;
238 std::vector
<SFCEntity
*> parts
;
240 SFCHotspot hotspots
[6];
242 SFCCompoundObject(SFCFile
*p
) : SFCObject(p
) { ourAgent
= 0; }
245 class Agent
*copiedAgent() { return (Agent
*)ourAgent
; }
248 class SFCBlackboard
: public SFCCompoundObject
{
251 uint32 backgroundcolour
, chalkcolour
, aliascolour
;
252 std::vector
<std::pair
<uint32
, std::string
> > strings
;
254 SFCBlackboard(SFCFile
*p
) : SFCCompoundObject(p
) { }
259 class SFCVehicle
: public SFCCompoundObject
{
261 uint32 cabinleft
, cabintop
, cabinright
, cabinbottom
;
267 SFCVehicle(SFCFile
*p
) : SFCCompoundObject(p
) { }
272 class SFCLift
: public SFCVehicle
{
273 friend class SFCCallButton
;
277 uint32 currentbutton
;
278 uint32 callbuttony
[8];
282 SFCLift(SFCFile
*p
) : SFCVehicle(p
) { }
287 class SFCSimpleObject
: public SFCObject
{
289 class SimpleAgent
*ourAgent
;
294 SFCSimpleObject(SFCFile
*p
) : SFCObject(p
) { ourAgent
= 0; }
297 class Agent
*copiedAgent() { return (Agent
*)ourAgent
; }
300 class SFCPointerTool
: public SFCSimpleObject
{
304 SFCPointerTool(SFCFile
*p
) : SFCSimpleObject(p
) { }
309 class SFCCallButton
: public SFCSimpleObject
{
314 SFCCallButton(SFCFile
*p
) : SFCSimpleObject(p
) { }
319 class SFCScenery
: public SFCSimpleObject
{
321 SFCScenery(SFCFile
*p
) : SFCSimpleObject(p
) { }