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 class CGallery
: public SFCClass
{
114 std::string filename
;
116 // no real need for sizes/offsets/etc..
118 CGallery(SFCFile
*p
) : SFCClass(p
) { }
122 class CDoor
: public SFCClass
{
127 CDoor(SFCFile
*p
) : SFCClass(p
) { }
131 class CRoom
: public SFCClass
{
134 uint32 left
, top
, right
, bottom
;
135 std::vector
<CDoor
*> doors
[4];
138 uint8 inorganicnutrients
, organicnutrients
, temperature
, pressure
, lightlevel
, radiation
;
139 signed char heatsource
, pressuresource
, lightsource
, radiationsource
;
141 std::vector
<std::pair
<uint32
, uint32
> > floorpoints
;
147 CRoom(SFCFile
*p
) : SFCClass(p
) { }
151 class MapData
: public SFCClass
{
153 CGallery
*background
;
154 std::vector
<CRoom
*> rooms
;
158 MapData(SFCFile
*p
) : SFCClass(p
) { }
164 class SFCEntity
: public SFCClass
{
168 uint8 currframe
, imgoffset
;
173 std::string animstring
;
181 std::vector
<std::pair
<uint32
, uint32
> > pickup_handles
;
182 std::vector
<std::pair
<uint32
, uint32
> > pickup_points
;
184 // TODO: misc data/flags
185 SFCEntity(SFCFile
*p
) : SFCClass(p
) { }
189 class SFCObject
: public SFCClass
{
191 SFCObject(SFCFile
*p
) : SFCClass(p
) { }
197 uint32 unid
; // needed?
199 uint32 left
, top
, right
, bottom
; // what is this?
202 std::string currentsound
;
206 uint32 tickreset
, tickstate
;
208 uint32 variables
[100];
211 uint32 range
, accg
, velx
, vely
, rest
, aero
;
216 std::vector
<SFCScript
> scripts
;
218 virtual void copyToWorld() = 0;
219 virtual class Agent
*copiedAgent() = 0;
223 int left
, top
, right
, bottom
;
229 class SFCCompoundObject
: public SFCObject
{
231 class CompoundAgent
*ourAgent
;
234 std::vector
<SFCEntity
*> parts
;
236 SFCHotspot hotspots
[6];
238 SFCCompoundObject(SFCFile
*p
) : SFCObject(p
) { ourAgent
= 0; }
241 class Agent
*copiedAgent() { return (Agent
*)ourAgent
; }
244 class SFCBlackboard
: public SFCCompoundObject
{
247 uint16 backgroundcolour
, chalkcolour
, aliascolour
;
248 std::map
<uint32
, std::string
> strings
;
250 SFCBlackboard(SFCFile
*p
) : SFCCompoundObject(p
) { }
255 class SFCVehicle
: public SFCCompoundObject
{
257 uint32 cabinleft
, cabintop
, cabinright
, cabinbottom
;
263 SFCVehicle(SFCFile
*p
) : SFCCompoundObject(p
) { }
268 class SFCLift
: public SFCVehicle
{
269 friend class SFCCallButton
;
273 uint32 currentbutton
;
274 uint32 callbuttony
[8];
277 SFCLift(SFCFile
*p
) : SFCVehicle(p
) { }
282 class SFCSimpleObject
: public SFCObject
{
284 class SimpleAgent
*ourAgent
;
289 SFCSimpleObject(SFCFile
*p
) : SFCObject(p
) { ourAgent
= 0; }
292 class Agent
*copiedAgent() { return (Agent
*)ourAgent
; }
295 class SFCPointerTool
: public SFCSimpleObject
{
299 SFCPointerTool(SFCFile
*p
) : SFCSimpleObject(p
) { }
304 class SFCCallButton
: public SFCSimpleObject
{
309 SFCCallButton(SFCFile
*p
) : SFCSimpleObject(p
) { }
314 class SFCScenery
: public SFCSimpleObject
{
316 SFCScenery(SFCFile
*p
) : SFCSimpleObject(p
) { }