All pastes #725425 Raw Edit

Trouble with rb-open

public c v1 · immutable
#725425 ·published 2007-10-04 12:17 UTC
rendered paste body
/* save file names */#define UMAP_FILE = PLUGIN_GAMES_DIR "/amaze_umap.sav"#define MAP_FILE  = PLUGIN_GAMES_DIR "/amaze_map.sav"bool savegame(void){        int x,y;        char map_unit;        int unit_fmt;        int fd;        char line[35];        //line[36]='\r';        //line[37]='\n';                /* save umap */        rb->splash(0, "Saving game...");        fd = rb->open(UMAP_FILE, O_RDWR| O_CREAT);        if(fd >= 0) {                for(y=0; y < umap->maxy; y++) {                        for (x=0; x < umap->maxx; x++) {                                map_unit = umap->coords[y][x].chr;                                unit_fmt = umap->coords[y][x].attrib;                                if(map_unit == ' ')                                        if(unit_fmt == A_NORMAL)                                                line[x] = ' ';                                        else                                                line[x] = 'B';                                else                                        line[x] = map_unit;                        }                        rb->write(fd,line,sizeof(line));                }                rb->close(fd);        }        else return false;        /* save map */        fd=rb->open(MAP_FILE, O_WRONLY|O_CREAT);        if(fd >= 0) {                for(y=0; y < map->maxy; y++) {                        for (x=0; x < map->maxx; x++) {                                map_unit = map->coords[y][x].chr;                                unit_fmt = map->coords[y][x].attrib;                                if(map_unit == ' ')                                        if(unit_fmt == A_NORMAL)                                                line[x] = ' ';                                        else                                                line[x] = 'B';                                else line[x] = map_unit;                        }                        rb->write(fd,line,sizeof(line));                }                rb->close(fd);        }        else return false;        return true;}