<commit_before>function MapModel() {

    this.rooms = {};
    this.exits = {};

    this.changeListeners = [];
}

MapModel.prototype.addChangeListener = function(listener) {

    this.changeListeners.insert(listener);
};

MapModel.prototype.removeChangeListener = function(listener) {

    this.changeListeners.removeAll(listener);
};

MapModel.prototype.notifyChangeListeners = function() {

    this.changeListeners.forEach(function(listener) {
        listener();
    });
};

MapModel.prototype.load = function() {

    var self = this;

    controller.sendApiCall("rooms-list", function(data) {
        for (var i = 0; i < data.length; i++) {
            var room = JSON.parse(data[i]);
            room.x = room.position ? room.position[0] : 0;
            room.y = room.position ? room.position[1] : 0;
            room.z = room.position ? room.position[2] : 0;
            self.rooms[room.id] = room;
        }

        controller.sendApiCall("exits-list", function(data) {
            for (var i = 0; i < data.length; i++) {
                var exit = JSON.parse(data[i]);
                self.exits[exit.id] = exit;
            }

            for (var id in self.rooms) {
                self.resolvePointers(self.rooms[id], ["exits", "visibleRooms"]);
            }
            for (id in self.exits) {
                self.resolvePointers(self.exits[id], ["destination", "oppositeExit"]);
            }

            self.notifyChangeListeners();
        });
    });
};

MapModel.prototype.setRoomProperty = function(roomId, propertyName, value) {

    var self = this;
    var room = this.rooms[roomId];<commit_msg>Don't choke on rooms without exits.<commit_after>function MapModel() {

    this.rooms = {};
    this.exits = {};

    this.changeListeners = [];
}

MapModel.prototype.addChangeListener = function(listener) {

    this.changeListeners.insert(listener);
};

MapModel.prototype.removeChangeListener = function(listener) {

    this.changeListeners.removeAll(listener);
};

MapModel.prototype.notifyChangeListeners = function() {

    this.changeListeners.forEach(function(listener) {
        listener();
    });
};

MapModel.prototype.load = function() {

    var self = this;

    controller.sendApiCall("rooms-list", function(data) {
        for (var i = 0; i < data.length; i++) {
            var room = JSON.parse(data[i]);
            room.x = room.position ? room.position[0] : 0;
            room.y = room.position ? room.position[1] : 0;
            room.z = room.position ? room.position[2] : 0;
            room.exits = room.exits || [];
            self.rooms[room.id] = room;
        }

        controller.sendApiCall("exits-list", function(data) {
            for (var i = 0; i < data.length; i++) {
                var exit = JSON.parse(data[i]);
                self.exits[exit.id] = exit;
            }

            for (var id in self.rooms) {
                self.resolvePointers(self.rooms[id], ["exits", "visibleRooms"]);
            }
            for (id in self.exits) {
                self.resolvePointers(self.exits[id], ["destination", "oppositeExit"]);
            }

            self.notifyChangeListeners();
        });
    });
};

MapModel.prototype.setRoomProperty = function(roomId, propertyName, value) {

    var self = this;
    var room = this.rooms[roomId];
{'fraction_non_alphanumeric': 0.14522446520036156, 'fraction_numerical': 0.004820729135281711, 'mean_word_length': 2.2295719844357977, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5683892', 'n_tokens_mistral': 1017, 'n_tokens_neox': 981, 'n_words': 178}