From 58d934343ce784dc7cc195519f750b5fd51d2b02 Mon Sep 17 00:00:00 2001 From: sachy Date: Mon, 28 Nov 2011 21:08:48 +0100 Subject: [PATCH] Added server pre-gui interface --- main.cc | 10 ++ rawio.h | 39 +++++ viewer.nlogo | 456 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 505 insertions(+) create mode 100644 rawio.h create mode 100644 viewer.nlogo diff --git a/main.cc b/main.cc index 95eaf37..1184dbc 100644 --- a/main.cc +++ b/main.cc @@ -16,6 +16,7 @@ #include "connection.h" #include "main.h" #include "map.h" +#include "rawio.h" int tick_id = 0; @@ -43,6 +44,11 @@ main(int argc, char *argv[]) class map map(argc < 2 ? 40 : atoi(argv[1]), argc < 3 ? 20 : atoi(argv[2])); int herbs = argc < 4 ? map.w * map.h / world::herb_rate : atoi(argv[3]); + #ifdef RAWIO + if(rawio_cfg(&map)==-1) + std::cout<<"rawio_cfg: Cannost open cfg file"< +#include + +int rawio_map(map *map) +{ + std::ofstream mapout; + mapout.open("rawio_map",std::ios::out|std::ios::trunc); + if(mapout.is_open()) + { + for (int y = 0; y < map->h; y++) + { + for (int x = 0; x < map->w; x++) + mapout << map->tile_at(x, y).symbol(); + mapout << std::endl; + } + mapout.close(); + return 0; + } + return -1;//cannot open outstream +} + +int rawio_cfg(map *map) +{ + std::ofstream cfgout; + cfgout.open("rawio_cfg",std::ios::out|std::ios::trunc); + if(cfgout.is_open()) + { + cfgout<w<h<