All pastes #192339 Raw Edit

Miscellany

public cpp v1 · immutable
·published 2006-10-05 21:17 UTC
rendered paste body
    // TODO: file magic and bytesex magic    bool SaveMap(const string& filename) {        // TODO: assert that int is 32 bit        int numPlanes = Planes.size();        fstream f(filename.c_str(),ios::out|ios::binary);        f.write((char*)&numPlanes, sizeof(int));        for (IPlane i=Planes.begin(); i!=Planes.end(); i++)            f << *i;        f.close();        return true;//TODO:check for failure, lol    }    // TODO: file magic and bytesex magic    bool LoadMap(const string& filename) {        // TODO: assert that int is 32 bit        int numPlanes = Planes.size();        fstream f(filename.c_str(),ios::in|ios::binary);        f.read((char*)&numPlanes, sizeof(int));        printf("numPlanes: %i\n", numPlanes);        for (IPlane i=Planes.begin(); i!=Planes.end(); i++)            delete *i;        Planes.clear();        for (; numPlanes; numPlanes--) {            puts("New plane");            TilePlane *tp = new TilePlane(1,1);            f >> *tp;            Planes.push_back(tp);        }        f.close();        return true;//TODO:check for failure, lol    }