project_files/frontlib/net/netprotocol.c
author unc0rr
Wed, 19 Mar 2014 18:45:20 +0400
changeset 10206 979a663d7351
parent 10017 de822cd3df3a
permissions -rw-r--r--
Process segments from last to first point too
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     1
/*
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     2
 * Hedgewars, a free turn based strategy game
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     3
 * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     4
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     5
 * This program is free software; you can redistribute it and/or
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     6
 * modify it under the terms of the GNU General Public License
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     7
 * as published by the Free Software Foundation; either version 2
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     8
 * of the License, or (at your option) any later version.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
     9
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    13
 * GNU General Public License for more details.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    14
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    15
 * You should have received a copy of the GNU General Public License
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    16
 * along with this program; if not, write to the Free Software
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    18
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    19
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    20
#include "netprotocol.h"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    21
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    22
#include "../util/util.h"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    23
#include "../util/logging.h"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    24
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    25
#include "../base64/base64.h"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    26
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    27
#include <zlib.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    28
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    29
#include <string.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    30
#include <stdio.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    31
#include <errno.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    32
#include <stdlib.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    33
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    34
static int fillTeamFromMsg(flib_team *team, char **parts) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    35
    team->name = flib_strdupnull(parts[0]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    36
    team->grave = flib_strdupnull(parts[1]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    37
    team->fort = flib_strdupnull(parts[2]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    38
    team->voicepack = flib_strdupnull(parts[3]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    39
    team->flag = flib_strdupnull(parts[4]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    40
    team->ownerName = flib_strdupnull(parts[5]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    41
    if(!team->name || !team->grave || !team->fort || !team->voicepack || !team->flag || !team->ownerName) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    42
        return -1;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    43
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    44
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    45
    errno = 0;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    46
    long difficulty = strtol(parts[6], NULL, 10);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    47
    if(errno) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    48
        return -1;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    49
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    50
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    51
    for(int i=0; i<HEDGEHOGS_PER_TEAM; i++) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    52
        flib_hog *hog = &team->hogs[i];
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    53
        hog->difficulty = difficulty;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    54
        hog->name = flib_strdupnull(parts[7+2*i]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    55
        hog->hat = flib_strdupnull(parts[8+2*i]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    56
        if(!hog->name || !hog->hat) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    57
            return -1;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    58
        }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    59
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    60
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    61
    // Set some default assumptions as well
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    62
    team->colorIndex = DEFAULT_COLOR_INDEX;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    63
    team->hogsInGame = DEFAULT_HEDGEHOG_COUNT;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    64
    team->remoteDriven = true;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    65
    return 0;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    66
}
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    67
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    68
flib_team *flib_team_from_netmsg(char **parts) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    69
    flib_team *result = NULL;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    70
    flib_team *tmpTeam = flib_calloc(1, sizeof(flib_team));
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    71
    if(tmpTeam) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    72
        if(!fillTeamFromMsg(tmpTeam, parts)) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    73
            result = tmpTeam;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    74
            tmpTeam = NULL;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    75
        } else {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    76
            flib_log_e("Error parsing team from net.");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    77
        }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    78
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    79
    flib_team_destroy(tmpTeam);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    80
    return result;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    81
}
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    82
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    83
flib_scheme *flib_scheme_from_netmsg(char **parts) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    84
    flib_scheme *result = flib_scheme_create(parts[0]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    85
    if(result) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    86
        for(int i=0; i<flib_meta.modCount; i++) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    87
            result->mods[i] = !strcmp(parts[i+1], "true");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    88
        }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    89
        for(int i=0; i<flib_meta.settingCount; i++) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    90
            result->settings[i] = atoi(parts[i+flib_meta.modCount+1]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    91
        }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    92
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    93
    return result;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    94
}
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    95
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    96
flib_map *flib_map_from_netmsg(char **parts) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    97
    flib_map *result = flib_map_create_named(parts[3], parts[0]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    98
    if(result) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
    99
        result->mapgen = atoi(parts[1]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   100
        result->mazeSize = atoi(parts[2]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   101
        result->templateFilter = atoi(parts[4]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   102
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   103
    return result;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   104
}
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   105
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   106
int flib_drawnmapdata_from_netmsg(char *netmsg, uint8_t** outbuf, size_t *outlen) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   107
    int result = -1;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   108
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   109
    // First step: base64 decoding
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   110
    char *base64decout = NULL;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   111
    size_t base64declen;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   112
    bool ok = base64_decode_alloc(netmsg, strlen(netmsg), &base64decout, &base64declen);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   113
    if(ok && base64declen>3) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   114
        // Second step: unzip with the QCompress header. That header is just a big-endian
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   115
        // uint32 indicating the length of the uncompressed data.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   116
        uint8_t *ubyteBuf = (uint8_t*)base64decout;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   117
        uint32_t unzipLen =
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   118
                (((uint32_t)ubyteBuf[0])<<24)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   119
                + (((uint32_t)ubyteBuf[1])<<16)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   120
                + (((uint32_t)ubyteBuf[2])<<8)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   121
                + ubyteBuf[3];
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   122
        if(unzipLen==0) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   123
            *outbuf = NULL;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   124
            *outlen = 0;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   125
            result = 0;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   126
        } else {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   127
            uint8_t *out = flib_malloc(unzipLen);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   128
            if(out) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   129
                uLongf actualUnzipLen = unzipLen;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   130
                int resultcode = uncompress(out, &actualUnzipLen, (Bytef*)(base64decout+4), base64declen-4);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   131
                if(resultcode == Z_OK) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   132
                    *outbuf = out;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   133
                    *outlen = actualUnzipLen;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   134
                    out = NULL;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   135
                    result = 0;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   136
                } else {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   137
                    flib_log_e("Uncompressing drawn map failed. Code: %i", resultcode);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   138
                }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   139
            }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   140
            free(out);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   141
        }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   142
    } else {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   143
        flib_log_e("base64 decoding of drawn map failed.");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   144
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   145
    free(base64decout);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   146
    return result;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   147
}
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   148
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   149
flib_room *flib_room_from_netmsg(char **params) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   150
    flib_room *result = NULL;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   151
    flib_room *tmpRoom = flib_calloc(1, sizeof(flib_room));
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   152
    if(tmpRoom) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   153
        tmpRoom->inProgress = !strcmp(params[0], "True");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   154
        tmpRoom->name = flib_strdupnull(params[1]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   155
        tmpRoom->playerCount = atoi(params[2]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   156
        tmpRoom->teamCount = atoi(params[3]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   157
        tmpRoom->owner = flib_strdupnull(params[4]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   158
        tmpRoom->map = flib_strdupnull(params[5]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   159
        tmpRoom->scheme = flib_strdupnull(params[6]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   160
        tmpRoom->weapons = flib_strdupnull(params[7]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   161
        if(tmpRoom->name && tmpRoom->owner && tmpRoom->map && tmpRoom->scheme && tmpRoom->weapons) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   162
            result = tmpRoom;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   163
            tmpRoom = NULL;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   164
        }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   165
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   166
    flib_room_destroy(tmpRoom);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   167
    return result;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   168
}
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   169
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   170
int fillRoomArray(flib_room **array, char **params, int count) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   171
    for(int i=0; i<count; i++) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   172
        array[i] = flib_room_from_netmsg(params + 8*i);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   173
        if(!array[i]) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   174
            return -1;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   175
        }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   176
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   177
    return 0;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   178
}
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   179
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   180
flib_room **flib_room_array_from_netmsg(char **params, int count) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   181
    flib_room **result = flib_calloc(count, sizeof(flib_room*));
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   182
    if(result) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   183
        if(fillRoomArray(result, params, count)) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   184
            for(int i=0; i<count; i++) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   185
                flib_room_destroy(result[i]);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   186
            }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   187
            free(result);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   188
            result = NULL;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   189
        }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   190
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   191
    return result;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7566
diff changeset
   192
}