Example #1
0
void Floor::dump(output_stream &stream, boolean just_prepare) {
   if (just_prepare) {
      if (items != NULL) items->dump(stream,FALSE,just_prepare);
      return;
   };
   stream.put(FLOOR_MARKER);
   if (items != NULL) {
		items->dump(stream,TRUE);
//      Sprites *sorted_items = sort_items(items); // commented out on 210100 since robots now save links to working cubby
		// commented out the following on 050100 since now if tt_toolbox is responsible it is dumped specially
//      if (tt_toolbox != NULL) {
//         Sprites *non_toolbox_items = NULL;
//         Sprites *remaining = items;
//         while (remaining != NULL) {
//            Sprite *sprite = remaining->first();
//            if (!toolbox_tool(sprite)) {
//              insert_at_end(sprite,non_toolbox_items);
//            };
//            remaining = remaining->rest();
//        };
//         sorted_items = sort_items(non_toolbox_items);
//         non_toolbox_items->remove_all();
//         delete non_toolbox_items;
//      } else {
//         sorted_items = sort_items(items);
//      };
//      if (sorted_items != NULL) {
//         sorted_items->dump(stream,TRUE);
//         sorted_items->remove_all();
//         delete sorted_items;
//      };
   };
   stream.put(END_OF_LIST_MARKER);
	stream.write((char *) &current_priority, sizeof(current_priority)); // new on 150100
};
Example #2
0
void        write_all(output_stream& output, tstring const& data)
{
    using tinfra::fail;
    using tinfra::tsprintf;

    size_t to_write              = data.size();
    size_t buffer_to_write_index = 0;

    while( to_write > 0 ) {
        const int w = output.write(data.data() + buffer_to_write_index, to_write);
        if( to_write != 0 && w == 0 ) {
            fail(tsprintf("unable to save data, %i bytes left", to_write),
                 "write() unexpectedly returned 0");
        }
        to_write -= w;
        buffer_to_write_index += w;
    }
}