AddRoomForm::AddRoomForm(QWidget* parent): QDialog(parent) { setupUi(this); addRoomPushButton->setDefault(true); connect(closePushButton, SIGNAL(clicked()), this, SLOT(close())); connect(helpPushButton, SIGNAL(clicked()), this, SLOT(help())); connect(addRoomPushButton, SIGNAL(clicked()), this, SLOT(addRoom())); centerWidgetOnScreen(this); restoreFETDialogGeometry(this); QSize tmp5=buildingsComboBox->minimumSizeHint(); Q_UNUSED(tmp5); buildingsComboBox->clear(); buildingsComboBox->addItem(""); for(int i=0; i<gt.rules.buildingsList.size(); i++) buildingsComboBox->addItem(gt.rules.buildingsList.at(i)->name); capacitySpinBox->setMinimum(1); capacitySpinBox->setMaximum(MAX_ROOM_CAPACITY); capacitySpinBox->setValue(MAX_ROOM_CAPACITY); }
/** * Build the dungeon that the player will navigate * * @param dungeon A pointer to the dungeon structure * * @return None */ void buildDungeon(Dungeon* dungeon) { char move_buf[10]; Coordinate cornerStone; cornerStone.y = 0; cornerStone.x = 0; bzero(move_buf,10); if(!(dungeon->start = malloc(sizeof(Room)))) _terminate(ALLOCATE_ERROR); addRoom(&dungeon->start->contents, first_room_string, cornerStone, 0); dungeon->start->next = NULL; dungeon->moveList = NULL; int in, im; unsigned char is_used['~'-'#']; bzero((char*)is_used, '~'-'#'); im = 0; for (in = '~' - 10; in < '~' && im < 10; ++in) { char c = '\0'; while(c < '#' || c > in) { if(random(&c, 1, 0)) _terminate(ALLOCATE_ERROR); } if (is_used[c - '#']) c = in; move_buf[im++] = c; is_used[c - '#'] = 1; } #if DEBUG dungeon->moveTypes.quit = 'Q'; dungeon->moveTypes.left = 'L'; dungeon->moveTypes.right = 'R'; dungeon->moveTypes.jump = 'J'; dungeon->moveTypes.jumpleft = 'H'; dungeon->moveTypes.jumpright = 'K'; dungeon->moveTypes.wait = 'W'; dungeon->moveTypes.play = 'P'; dungeon->moveTypes.instructions = 'I'; dungeon->moveTypes.scores = 'S'; #else dungeon->moveTypes.quit = move_buf[0]; dungeon->moveTypes.left = move_buf[1]; dungeon->moveTypes.right = move_buf[2]; dungeon->moveTypes.jump = move_buf[3]; dungeon->moveTypes.jumpleft = move_buf[4]; dungeon->moveTypes.jumpright = move_buf[5]; dungeon->moveTypes.wait = move_buf[6]; dungeon->moveTypes.play = move_buf[7]; dungeon->moveTypes.instructions = move_buf[8]; dungeon->moveTypes.scores = move_buf[9]; #endif }
ChatRoom* ChatManagerImplementation::createRoom(const String& roomName, ChatRoom* parent) { ManagedReference<ChatRoom*> room = cast<ChatRoom*>(ObjectManager::instance()->createObject("ChatRoom", 0 , "")); room->init(server, parent, roomName, getNextRoomID()); addRoom(room); return room; }
void CPetRooms::reassignRoom(PassengerClass passClassNum) { CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom(); if (glyph) // Flag the old assigned room as no longer assigned glyph->setMode(RGM_PREV_ASSIGNED_ROOM); CRoomFlags roomFlags; roomFlags.setRandomLocation(passClassNum, _field1D4); glyph = addRoom(roomFlags, true); if (glyph) { // Flag the new room as assigned to the player, and highlight it glyph->setMode(RGM_ASSIGNED_ROOM); _glyphs.highlight(glyph); } }
int addRoom(lvl *level, int showGen, room *rooms, int tries){ int x = rb(1, MAX_W-RM_MAXX-2); int y = rb(1, MAX_H-RM_MAXY-2); int w = rb(3, RM_MAXX); int h = rb(3, RM_MAXY); if (validRoom(level, h+2, w+2, x-2, y-2, 1, showGen)){ rooms->setPoints(x,y,x+w,y+h); recurClear(level, h, w, x, y, 1, showGen); return (1); } else if(tries<=30){ return (addRoom(level, showGen, rooms, ++tries)); } return 0; }
//-----% Generate The Level %------- int lvlGen (lvl *level){ int numRooms = rb(MIN_ROOMS,MAX_ROOMS); char temp; int showGen = 0; int x1,x2,y1,y2; room rooms[numRooms]; //Make the entire level solid for (int i = 0; i < MAX_H; i++){ for (int j = 0; j < MAX_W; j++){ level->nodeSet(i,j,'#'); } } printf("Do you want to be shown the generation process? y/n"); temp=getch(); if (temp == 'y') showGen = 1; while (!validLevel(level)){ for (int i = 0; i < MAX_H; i++){ for (int j = 0; j < MAX_W; j++){ level->nodeSet(i,j,'#'); } } for (int i = 0; i < numRooms; i++) { printf("Trynna make a new room\n"); if (addRoom(level, showGen, &rooms[i],0)){ x1 = (rooms[i].x1Get()+rooms[i].x2Get())/2; x2 = (rooms[i-1].x1Get()+rooms[i-1].x2Get())/2; y1 = (rooms[i].y1Get()+rooms[i].y2Get())/2; y2 = (rooms[i-1].y1Get()+rooms[i-1].y2Get())/2; if (i>0 ) genPath(level,x1,y1,x2,y2); if (i == 0) level->nodeSet(y1,x1,'e'); else if(i==numRooms-1) level->nodeSet(y1,x1,'E'); } } printf("Bad level..."); //getch(); } return 1; }
bool CPetRooms::checkDragEnd(CGameObject *item) { // Ignore any item drops except valid mail items if (!item->_isMail) return false; uint roomFlags = item->_id; CPetRoomsGlyph *glyph = _glyphs.findGlyphByFlags(roomFlags); if (glyph) { if (_glyphs.findGlyphByFlags(0)) { _glyphs.highlight(glyph); return false; } roomFlags = 0; } addRoom(roomFlags, true); return false; }
FloorDialog::FloorDialog(const QString &name, int z, QList<Room*> rooms, QWidget *parent) : QDialog(parent), ui(new Ui::FloorDialog), selectedTile(NULL) { ui->setupUi(this); ui->name->setText(name); setWindowTitle(name); ui->z->setText(QString::number(z)); ui->z->setValidator(new QIntValidator()); getMinAndMax(rooms); createBlankTiles(); foreach (Room *r, rooms) { addRoom(r); }
/** * Add the next room to the dungeon * * @param dungeon A pointer to the dungeon and game info * @param dungeon_idx the location of the room in the dungeon * @param last_move The last move made by the player * @param moveNum The number of moves made by the player * * @return None */ void extendDungeon(Dungeon *dungeon, int dungeon_idx, char last_move, int moveNum) { int room_idx=2; Coordinate cornerStone; Room* new_room=NULL; Room* prev_room=NULL; if(last_move == dungeon->moveTypes.left) room_idx = 0; else if(last_move == dungeon->moveTypes.right) room_idx = 1; else if(last_move == dungeon->moveTypes.jump) room_idx = 0; else if(last_move == dungeon->moveTypes.jumpleft) room_idx = 1; else if(last_move == dungeon->moveTypes.jumpright) room_idx = 0; else if(last_move == dungeon->moveTypes.wait) { if(moveNum > SECRET_NUM) room_idx = 2; else room_idx = 1; } cornerStone.y=0; cornerStone.x= (dungeon_idx*ROOM_WIDTH); if(!(new_room = malloc(sizeof(Room)))) _terminate(ALLOCATE_ERROR); addRoom(&new_room->contents, room_string[room_idx], cornerStone, moveNum); for(prev_room=dungeon->start; prev_room->next!=NULL; prev_room=prev_room->next); prev_room->next = new_room; // Open door Object* door; door = prev_room->contents[ROOM_HEIGHT-3][ROOM_WIDTH-1]; destroyObject(door); prev_room->contents[ROOM_HEIGHT-3][ROOM_WIDTH-1] = makeObject(EMPTY_SYM, EMPTY_NUM, ROOM_HEIGHT-3, cornerStone.x-1, 0, 0, moveNum); }
Level::Level() { levelSizeX = LEVEL_SIZE_X; levelSizeY = LEVEL_SIZE_Y; //Initialize all squares with default constructor (As walls) for (int i = 0; i < levelSizeY; i++) { for (int j = 0; j < levelSizeX; j++) { squares[j][i] = Square(); } } static Random rand = Random(); int rand_int = rand.getInt(MIN_ROOMS,MAX_ROOMS); for (int i = 0; i < rand_int; i++) { addRoom(); } makeHalls(); addStairs(); }
bool Servatrice::initServer() { serverName = settingsCache->value("server/name", "My Cockatrice server").toString(); serverId = settingsCache->value("server/id", 0).toInt(); clientIdRequired = settingsCache->value("server/requireclientid",0).toBool(); regServerOnly = settingsCache->value("authentication/regonly", 0).toBool(); const QString authenticationMethodStr = settingsCache->value("authentication/method").toString(); if (authenticationMethodStr == "sql") { qDebug() << "Authenticating method: sql"; authenticationMethod = AuthenticationSql; } else if(authenticationMethodStr == "password") { qDebug() << "Authenticating method: password"; authenticationMethod = AuthenticationPassword; } else { if (regServerOnly) { qDebug() << "Registration only server enabled but no authentication method defined: Error."; return false; } qDebug() << "Authenticating method: none"; authenticationMethod = AuthenticationNone; } qDebug() << "Store Replays: " << settingsCache->value("game/store_replays", true).toBool(); qDebug() << "Client ID Required: " << clientIdRequired; bool maxUserLimitEnabled = settingsCache->value("security/enable_max_user_limit", false).toBool(); qDebug() << "Maximum user limit enabled: " << maxUserLimitEnabled; if (maxUserLimitEnabled){ int maxUserLimit = settingsCache->value("security/max_users_total", 500).toInt(); qDebug() << "Maximum total user limit: " << maxUserLimit; int maxTcpUserLimit = settingsCache->value("security/max_users_tcp", 500).toInt(); qDebug() << "Maximum tcp user limit: " << maxTcpUserLimit; int maxWebsocketUserLimit = settingsCache->value("security/max_users_websocket", 500).toInt(); qDebug() << "Maximum websocket user limit: " << maxWebsocketUserLimit; } bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool(); bool requireEmailForRegistration = settingsCache->value("registration/requireemail", true).toBool(); bool requireEmailActivation = settingsCache->value("registration/requireemailactivation", true).toBool(); qDebug() << "Accept registered users only: " << regServerOnly; qDebug() << "Registration enabled: " << registrationEnabled; if (registrationEnabled) { qDebug() << "Require email address to register: " << requireEmailForRegistration; qDebug() << "Require email activation via token: " << requireEmailActivation; } FeatureSet features; features.initalizeFeatureList(serverRequiredFeatureList); requiredFeatures = settingsCache->value("server/requiredfeatures","").toString(); QStringList listReqFeatures = requiredFeatures.split(",", QString::SkipEmptyParts); if (!listReqFeatures.isEmpty()) foreach(QString reqFeature, listReqFeatures) features.enableRequiredFeature(serverRequiredFeatureList,reqFeature); qDebug() << "Required client features: " << serverRequiredFeatureList; QString dbTypeStr = settingsCache->value("database/type").toString(); if (dbTypeStr == "mysql") databaseType = DatabaseMySql; else databaseType = DatabaseNone; servatriceDatabaseInterface = new Servatrice_DatabaseInterface(-1, this); setDatabaseInterface(servatriceDatabaseInterface); if (databaseType != DatabaseNone) { settingsCache->beginGroup("database"); dbPrefix = settingsCache->value("prefix").toString(); bool dbOpened = servatriceDatabaseInterface->initDatabase("QMYSQL", settingsCache->value("hostname").toString(), settingsCache->value("database").toString(), settingsCache->value("user").toString(), settingsCache->value("password").toString()); settingsCache->endGroup(); if (!dbOpened) { qDebug() << "Failed to open database"; return false; } updateServerList(); qDebug() << "Clearing previous sessions..."; servatriceDatabaseInterface->clearSessionTables(); } const QString roomMethod = settingsCache->value("rooms/method").toString(); if (roomMethod == "sql") { QSqlQuery *query = servatriceDatabaseInterface->prepareQuery("select id, name, descr, permissionlevel, auto_join, join_message, chat_history_size from {prefix}_rooms where id_server = :id_server order by id asc"); query->bindValue(":id_server", serverId); servatriceDatabaseInterface->execSqlQuery(query); while (query->next()) { QSqlQuery *query2 = servatriceDatabaseInterface->prepareQuery("select name from {prefix}_rooms_gametypes where id_room = :id_room AND id_server = :id_server"); query2->bindValue(":id_server", serverId); query2->bindValue(":id_room", query->value(0).toInt()); servatriceDatabaseInterface->execSqlQuery(query2); QStringList gameTypes; while (query2->next()) gameTypes.append(query2->value(0).toString()); addRoom(new Server_Room(query->value(0).toInt(), query->value(6).toInt(), query->value(1).toString(), query->value(2).toString(), query->value(3).toString().toLower(), query->value(4).toInt(), query->value(5).toString(), gameTypes, this )); } } else { int size = settingsCache->beginReadArray("rooms/roomlist"); for (int i = 0; i < size; ++i) { settingsCache->setArrayIndex(i); QStringList gameTypes; int size2 = settingsCache->beginReadArray("game_types"); for (int j = 0; j < size2; ++j) { settingsCache->setArrayIndex(j); gameTypes.append(settingsCache->value("name").toString()); } settingsCache->endArray(); Server_Room *newRoom = new Server_Room( i, settingsCache->value("chathistorysize").toInt(), settingsCache->value("name").toString(), settingsCache->value("description").toString(), settingsCache->value("permissionlevel").toString().toLower(), settingsCache->value("autojoin").toBool(), settingsCache->value("joinmessage").toString(), gameTypes, this ); addRoom(newRoom); } if(size==0) { // no room defined in config, add a dummy one Server_Room *newRoom = new Server_Room( 0, 100, "General room", "Play anything here.", "none", true, "", QStringList("Standard"), this ); addRoom(newRoom); } settingsCache->endArray(); } updateLoginMessage(); maxGameInactivityTime = settingsCache->value("game/max_game_inactivity_time", 120).toInt(); maxPlayerInactivityTime = settingsCache->value("server/max_player_inactivity_time", 15).toInt(); pingClockInterval = settingsCache->value("server/clientkeepalive", 1).toInt(); maxUsersPerAddress = settingsCache->value("security/max_users_per_address", 4).toInt(); messageCountingInterval = settingsCache->value("security/message_counting_interval", 10).toInt(); maxMessageCountPerInterval = settingsCache->value("security/max_message_count_per_interval", 15).toInt(); maxMessageSizePerInterval = settingsCache->value("security/max_message_size_per_interval", 1000).toInt(); maxGamesPerUser = settingsCache->value("security/max_games_per_user", 5).toInt(); commandCountingInterval = settingsCache->value("game/command_counting_interval", 10).toInt(); maxCommandCountPerInterval = settingsCache->value("game/max_command_count_per_interval", 20).toInt(); try { if (settingsCache->value("servernetwork/active", 0).toInt()) { qDebug() << "Connecting to ISL network."; const QString certFileName = settingsCache->value("servernetwork/ssl_cert").toString(); const QString keyFileName = settingsCache->value("servernetwork/ssl_key").toString(); qDebug() << "Loading certificate..."; QFile certFile(certFileName); if (!certFile.open(QIODevice::ReadOnly)) throw QString("Error opening certificate file: %1").arg(certFileName); QSslCertificate cert(&certFile); const QDateTime currentTime = QDateTime::currentDateTime(); if(currentTime < cert.effectiveDate() || currentTime > cert.expiryDate() || cert.isBlacklisted()) throw(QString("Invalid certificate.")); qDebug() << "Loading private key..."; QFile keyFile(keyFileName); if (!keyFile.open(QIODevice::ReadOnly)) throw QString("Error opening private key file: %1").arg(keyFileName); QSslKey key(&keyFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); if (key.isNull()) throw QString("Invalid private key."); QMutableListIterator<ServerProperties> serverIterator(serverList); while (serverIterator.hasNext()) { const ServerProperties &prop = serverIterator.next(); if (prop.cert == cert) { serverIterator.remove(); continue; } QThread *thread = new QThread; thread->setObjectName("isl_" + QString::number(prop.id)); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); IslInterface *interface = new IslInterface(prop.id, prop.hostname, prop.address.toString(), prop.controlPort, prop.cert, cert, key, this); interface->moveToThread(thread); connect(interface, SIGNAL(destroyed()), thread, SLOT(quit())); thread->start(); QMetaObject::invokeMethod(interface, "initClient", Qt::BlockingQueuedConnection); } const int networkPort = settingsCache->value("servernetwork/port", 14747).toInt(); qDebug() << "Starting ISL server on port" << networkPort; islServer = new Servatrice_IslServer(this, cert, key, this); if (islServer->listen(QHostAddress::Any, networkPort)) qDebug() << "ISL server listening."; else throw QString("islServer->listen()"); } } catch (QString error) { qDebug() << "ERROR --" << error; return false; } pingClock = new QTimer(this); connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout())); pingClock->start(pingClockInterval * 1000); int statusUpdateTime = settingsCache->value("server/statusupdate", 15000).toInt(); statusUpdateClock = new QTimer(this); connect(statusUpdateClock, SIGNAL(timeout()), this, SLOT(statusUpdate())); if (statusUpdateTime != 0) { qDebug() << "Starting status update clock, interval " << statusUpdateTime << " ms"; statusUpdateClock->start(statusUpdateTime); } // SOCKET SERVER const int numberPools = settingsCache->value("server/number_pools", 1).toInt(); if(numberPools > 0) { gameServer = new Servatrice_GameServer(this, numberPools, servatriceDatabaseInterface->getDatabase(), this); gameServer->setMaxPendingConnections(1000); const int gamePort = settingsCache->value("server/port", 4747).toInt(); qDebug() << "Starting server on port" << gamePort; if (gameServer->listen(QHostAddress::Any, gamePort)) qDebug() << "Server listening."; else { qDebug() << "gameServer->listen(): Error:" << gameServer->errorString(); return false; } } #if QT_VERSION > 0x050300 // WEBSOCKET SERVER const int wesocketNumberPools = settingsCache->value("server/websocket_number_pools", 1).toInt(); if(wesocketNumberPools > 0) { websocketGameServer = new Servatrice_WebsocketGameServer(this, wesocketNumberPools, servatriceDatabaseInterface->getDatabase(), this); websocketGameServer->setMaxPendingConnections(1000); const int websocketGamePort = settingsCache->value("server/websocket_port", 4748).toInt(); qDebug() << "Starting websocket server on port" << websocketGamePort; if (websocketGameServer->listen(QHostAddress::Any, websocketGamePort)) qDebug() << "Websocket server listening."; else { qDebug() << "websocketGameServer->listen(): Error:" << websocketGameServer->errorString(); return false; } } #endif return true; }
/** * Ejecuta en el servidor la cadena recibida */ int execParams(user* conn, int connTam, char* str, int socketID, int sock, sqlite3* db, room* rooms, int dim){ PDEBUG("INFO: Analizando lista de parámetros\n"); char saux[10][DIM]; bzero(saux, 10 * DIM); int error = 0; // tienes permisos para ejecutar comandos en el servidor??? PDEBUG("INFO: Comprobando permisos\n"); int aux = searchConn(conn, connTam, socketID); // almacenamos en la base de datos sms auxMsj; strcpy(auxMsj.name, (*(conn + aux)).name); strcpy(auxMsj.text, str); db_addLog(auxMsj, &db); if((*(conn + aux)).rol != ADMIN){ PDEBUG("INFO: Usuario sin permisos\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Usuario sin permisos"); SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); PDEBUG("INFO: Mensaje de usuario no válido enviado al emisor\n"); return -1; } PDEBUG("INFO: Usuario autorizado\n"); str = trim(str); // eliminamos os espacios en blanco if(strcmp(str, "-x") == 0){ // comando de salida PDEBUG("EXIT: Cerrando el servidor\n"); shutdown(sock, SHUT_RDWR); // cerramos el socket sms auxMsj; auxMsj.flag = SERV_EXIT; strcpy(auxMsj.name, SERVER); broadcast(conn, &connTam, auxMsj, socketID, db); closeAll(conn, &connTam); // cerramos todas las conexiones PDEBUG("EXIT: Cerrando la conexión con la base de datos\n"); db_close(&db); PDEBUG("EXIT: Liberando espacio\n"); free(conn); PDEBUG("EXIT: Cerrando el proceso\n"); exit(0); }else if(sscanf(str, "--add-user %s %s %s", saux[0], saux[1], saux[2]) == 3){ // añadiendo un usuario //saux[0] es el nombre //saux[1] es el password //saux[2] es el rol PDEBUG("INFO: Añadiendo usuario 3 param\n"); int rol = 0; if(strcmp(saux[2], "admin") == 0){ rol = ADMIN; }else if(strcmp(saux[2], "user") == 0){ rol = USER; }else{ PDEBUG("INFO: tercer argumento no válido"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Rol no reconocido."); SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); return 0; } error = db_addUser(saux[0], saux[1], rol, &db); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); if(error == 0){ strcpy(auxMsj.text, "Usuario creado"); }else if(error == 1){ strcpy(auxMsj.text, "Nombre de usuario en uso"); }else{ strcpy(auxMsj.text, "Error al crear el usuario"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--add-user %s %s", saux[0], saux[1]) == 2){ // añadiendo un usuario // se usará el rol por defecto //saux[0] es el nombre //saux[1] es el password PDEBUG("INFO: Añadiendo usuario 2 param\n"); error = db_addUser(saux[0], saux[1], USER, &db); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); if(error == 0){ strcpy(auxMsj.text, "Usuario creado"); }else if(error == 1){ strcpy(auxMsj.text, "Nombre de usuario en uso"); }else{ strcpy(auxMsj.text, "Error al crear el usuario"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--delete-user %s", saux[0]) == 1){ // borrando un usuario //saux[0] es el nombre PDEBUG("INFO: Borrando usuario\n"); int num = 0; num = db_deleteUser(saux[0], &db); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); if(num > 0){ PDEBUG("INFO: Usuario borrado\n"); strcpy(auxMsj.text, "Usuario borrado"); }else{ PDEBUG("INFO: Usuario no encontrado\n"); strcpy(auxMsj.text, "Usuario no encontrado"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(strcmp(str, "--list-user") == 0){ // listando usuarios //saux[0] es el nombre PDEBUG("INFO: listando usuarios\n"); int num = 0; num = db_listUser(socketID, &db); }else if(sscanf(str, "--log %s %s", saux[0], saux[1]) == 2){ // listando usuarios //saux[0] es la fecha de inicio //saux[1] es la fecha de finalización PDEBUG("INFO: listando usuarios\n"); int num = 0; struct tm tm1, tm2; long t1, t2; if (strptime(saux[0], "%d/%m/%Y", &tm1) == 0 || strptime(saux[1], "%d/%m/%Y", &tm2) == 0){ PDEBUG("INFO: Formato de fecha no válido\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Formato de fecha no válido -> dd/mm/YYYY"); SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); return -1; } t1 = (long)mktime(&tm1); t2 = (long)mktime(&tm2); sprintf(saux[0], " WHERE time > %ld AND time < %ld", t1, t2); num = db_getLogPar(socketID, &db, saux[0]); }else if(strcmp(str, "--log") == 0){ // listando usuarios PDEBUG("INFO: listando usuarios\n"); int num = 0; num = db_getLog(socketID, &db); }else if(sscanf(str, "--add-room %s", saux[0]) == 1){ // creacion de un cana // saux[0] es el nombre del canal PDEBUG("INFO: añadiendo canales\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); if(addRoom(saux[0], rooms, dim) == -1){ strcpy(auxMsj.text, "Error al crear el canal, mire el log para más información"); }else{ strcpy(auxMsj.text, "Canal creado"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--delete-room %s", saux[0]) == 1){ // creacion de un cana // saux[0] es el nombre del canal PDEBUG("INFO: borrando canal\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); PDEBUG("INFO: Moviendo usuarios\n"); strcpy(saux[1], "general"); moveAllTo(conn, &connTam, saux[0], rooms, dim, db, saux[1]); if(deleteRoom(saux[0], rooms, dim) == -1){ strcpy(auxMsj.text, "Error al borrar el canal, mire el log para más información"); }else{ strcpy(auxMsj.text, "Canal borrado"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--kick %s", saux[0]) == 1){ // expulsión de un usuario // saux[0] es el nombre del usuario PDEBUG("INFO: expulsión de un usuario\n"); //PDEBUG("INFO: Moviendo usuarios\n"); //strcpy(saux[1], "general"); sms auxMsj; auxMsj.flag = SERV_EXIT; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Usuario expulsado."); int aux = searchName(conn, connTam, saux[0]); SSL_write((*(conn+aux)).ssl, &auxMsj, sizeof(sms)); //moveAllTo(conn, &connTam, saux[0], rooms, dim, db, saux[1]); if(deleteRoom(saux[0], rooms, dim) == -1){ strcpy(auxMsj.text, "Error al borrar el canal, mire el log para más información"); }else{ strcpy(auxMsj.text, "Canal borrado"); } SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); }else if(sscanf(str, "--list-room") == 0){ // listando de canales sendRoomList((*(conn + aux)).ssl, rooms, dim); }else{ // error, comando no válido PDEBUG("INFO: Comando no válido\n"); sms auxMsj; auxMsj.flag = MSJ; strcpy(auxMsj.name, SERVER); strcpy(auxMsj.text, "Comando no válido"); SSL_write((*(conn + aux)).ssl, &auxMsj, sizeof(sms)); PDEBUG("INFO: Mensaje de comando no válido enviado al emisor\n"); return -1; } return 0; }
/* TODO this function should probably be split up to better manage it */ void loadDataFile(world_t * clarkson){ /* This enum defines the sections of the datafile in order */ enum { NONE, ROOM_DESC, ROOM_LINKS, OBJ_PROP, ROOM_OBJS, TRIGGERS } section = NONE; int x; int rv; int n, s, e, w, u, d; int rm, itm; char ch; FILE * f; con_type ctype; res_type rtype; condition_t * con; result_t * res; char str[160]; /* This limits the length of lines of data */ str[159] = 0; f = fopen("data", "r"); assert(f != NULL); /* KLUDGE - stupid assignment trick by Andrew */ while ((rv = fscanf(f, "%d ", &x)) && rv != EOF) { if (-1 == x) { while ((rv = fgetc(f)) != '\n' && rv != EOF); section++; } else { switch (section) { case NONE: fprintf(stderr, "Error: Yous si fidodin somehtin srong.\n"); break; case ROOM_DESC: if (x == clarkson->numRooms) addRoom(clarkson); assert(x < clarkson->numRooms); clarkson->allRooms[x].description = getstring('\n', f); break; case ROOM_LINKS: assert(6 == fscanf(f, " %d %d %d %d %d %d\n", &n, &s, &e, &w, &u, &d)); clarkson->allRooms[x].north = n != -1 ? clarkson->allRooms + n : NULL; clarkson->allRooms[x].south = s != -1 ? clarkson->allRooms + s : NULL; clarkson->allRooms[x].east = e != -1 ? clarkson->allRooms + e : NULL; clarkson->allRooms[x].west = w != -1 ? clarkson->allRooms + w : NULL; clarkson->allRooms[x].up = u != -1 ? clarkson->allRooms + u : NULL; clarkson->allRooms[x].down = d != -1 ? clarkson->allRooms + d : NULL; break; case OBJ_PROP: if (clarkson->allItems->size == clarkson->allItems->capacity) { addItem(clarkson->allItems); } assert(clarkson->allItems->size == x); clarkson->allItems->itemArray[x] = malloc(sizeof(item_t)); clarkson->allItems->itemArray[x]->name = getstring('\n', f); fscanf(f, "%d ", &x); assert(clarkson->allItems->size == x); clarkson->allItems->itemArray[x]->description = getstring('\n', f); fscanf(f, "%d ", &x); assert(clarkson->allItems->size == x); clarkson->allItems->itemArray[x]->examine = getstring('\n', f); fscanf(f, "%d ", &x); assert(clarkson->allItems->size == x); fgets(str, 159, f); clarkson->allItems->size++; break; case ROOM_OBJS: assert(2 == fscanf(f, " %d %d\n", &rm, &itm)); if(clarkson->allRooms[rm].items->size == clarkson->allRooms[rm].items->capacity) { addItem(clarkson->allRooms[rm].items); } clarkson->allRooms[rm].items->itemArray[clarkson->allRooms[rm].items->size] = clarkson->allItems->itemArray[itm]; (clarkson->allRooms[rm].items->size)++; break; case TRIGGERS: if (x == clarkson->numTrigs) addTrig(clarkson); assert(x < clarkson->numTrigs); assert(2 == fscanf(f, "%c %159s ", &ch, str)); assert(ch == 'r' || ch == 'c'); if (ch == 'r') { /* Add trigger result */ rtype = getRtype(str); res = clarkson->allTrigs[x].res + clarkson->allTrigs[x].next_res; res->type = rtype; clarkson->allTrigs[x].next_res++; switch (rtype){ case R_LINK: assert(3 == fscanf(f, "%d %d %6s ", &res->param[0].i, &res->param[1].i, str)); res->param[2].i = direction(str); assert(res->param[2].i != EAST_BY_EAST_WEST); break; case R_ECHO: res->param[0].s = getstring('\n', f); break; case R_ENABLE: case R_DISABLE: assert(1 == fscanf(f, "%d ", &res->param[0].i)); break; case R_TELEPORT: assert(1 == fscanf(f, " %d\n", &res->param[0].i)); break; default: assert(0); } }else{ /* Add trigger condition */ ctype = getCtype(str); con = clarkson->allTrigs[x].con + clarkson->allTrigs[x].next_con; con->type = ctype; clarkson->allTrigs[x].next_con++; switch (ctype){ case C_IN: case C_RAND: assert(1 == fscanf(f, "%d ", &con->param)); break; case C_HAS: assert(1 == fscanf(f, "%d ", &con->param)); break; default: assert(0); } } break; default: fgets(str, 159, f); fprintf(stderr, "Error: default case reached?\n"); break; } } } fclose(f); clarkson->room = clarkson->allRooms; }
int main() { struct Ordered_container* people; struct Ordered_container* rooms; people = OC_create_container((OC_comp_fp_t)comparePeople); rooms = OC_create_container((OC_comp_fp_t)compareRooms); while (1) { char cmd1; char cmd2; printf("\nEnter command: "); scanf(" %c", &cmd1); scanf("%c", &cmd2); switch (cmd1) { case 'p': switch (cmd2) { case 'i': printIndividual(people); break; case 'r': printRoom(rooms); break; case 'm': printMeeting(rooms); break; case 's': printSchedule(rooms); break; case 'g': printGroup(people); break; default: printErrUnrecCmd(); break; } break; case 'a': switch (cmd2) { case 'i': addIndividual(people); break; case 'r': addRoom(rooms); break; case 'm': addMeeting(rooms); break; case 'p': addParticipant(rooms, people); break; default: printErrUnrecCmd(); break; } break; case 'r': switch (cmd2) { case 'm': rescheduleMeeting(rooms); break; default: printErrUnrecCmd(); break; } break; case 'd': switch (cmd2) { case 'i': deleteIndividual(people, rooms); break; case 'r': deleteRoom(rooms); break; case 'm': deleteMeeting(rooms); break; case 'p': deleteParticipant(rooms, people); break; case 's': deleteSchedule(rooms); break; case 'g': deleteGroup(rooms, people); break; case 'a': deleteAll(rooms, people); break; default: printErrUnrecCmd(); break; } break; case 's': break; case 'l': break; case 'q': switch (cmd2) { case 'q' : printf("All meetings deleted\n"); printf("All rooms deleted\n"); printf("All persons deleted\n"); printf("Done\n"); return 0; break; default: printErrUnrecCmd(); break; } break; default: printErrUnrecCmd(); break; } } return 0; }
int main(){ SDL_Init(SDL_INIT_EVERYTHING); signal(SIGINT, sighandler); Room *rooms; SDL_sem **semaphores; int* rooms_opened; //= (int*)malloc(sizeof(int)); int rooms_id = shmget(68476, sizeof(Room) * 10, 0666 | IPC_CREAT); int sem_id = shmget(85938, sizeof(SDL_sem*) * 10, 0666 | IPC_CREAT); int rooms_opened_id = shmget(75286, sizeof(int), 0666 | IPC_CREAT); //Should have a semaphore for this int rooms = (Room*)shmat(rooms_id, NULL, 0); semaphores = (SDL_sem**)shmat(sem_id, NULL, 0); rooms_opened = (int*)shmat(rooms_opened_id, NULL, 0); *rooms_opened = 0; int i, b, socket_client; char buffer[256]; //SELECT variables fd_set readers; struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 0; /*------------------ SERVER PREPARATION ------------------*/ //SOCKET variables struct sockaddr_in server; socklen_t socket_length; //make the server socket for reliable IPv4 traffic socket_id = socket( AF_INET, SOCK_STREAM, 0); printf("Socket file descriptor: %d\n", socket_id); //set up the server socket struct //Use IPv4 server.sin_family = AF_INET; //This is the server, so it will listen to anything coming into the host computer server.sin_addr.s_addr = INADDR_ANY; //set the port to listen on, htons converts the port number to network format server.sin_port = htons(24601); //bind the socket to the socket struct i= bind( socket_id, (struct sockaddr *)&server, sizeof(server) ); //wait for any connection i = listen( socket_id, 1 ); /*--------------- SERVER IS READY ---------------*/ //Add rooms automatically because I always forget to when testing addRoom(rooms, semaphores, *rooms_opened); *rooms_opened += 1; addRoom(rooms, semaphores, *rooms_opened); *rooms_opened += 1; /*------------------------------- ACCEPT CONNECTIONS CONTINUOUSLY -------------------------------*/ while(1) { FD_ZERO(&readers); FD_SET(STDIN_FILENO, &readers); FD_SET(socket_id, &readers); printf("Accepting a connection. Options: [add room] [exit]\n"); select(socket_id + 1, &readers, 0, 0, 0); /*----------- USER INPUT ----------*/ //The user has ordered us to do something on the server! Oh boy! if(FD_ISSET(STDIN_FILENO, &readers)){ fgets(buffer, sizeof(buffer), stdin); //Add room if(!strncmp(buffer, "add room", 8)){ if(*rooms_opened < 10){ addRoom(rooms, semaphores, *rooms_opened); *rooms_opened += 1; } else puts("Maximum number of rooms has been reached.\n"); } //Exit else if(!strncmp(buffer, "exit", 4)){ close(socket_id); for(i = 0; i < *rooms_opened; i++) SDL_DestroySemaphore(semaphores[i]); SDL_Quit(); break; } } /*----------------- SOCKET CONNECTION -----------------*/ //Somebody wants to connect! Alright! if(FD_ISSET(socket_id, &readers)){ //set socket_length after the connection is made socket_length = sizeof(server); //accept the incoming connection, create a new file desciprtor for the socket to the client socket_client = accept(socket_id, (struct sockaddr *)&server, &socket_length); printf("accepted connection %d\n\n",socket_client); //Fork off a subserver and close the client off from the main server i = fork(); if ( i == 0 ) { subserver(rooms, semaphores, socket_client, rooms_opened); } else close(socket_client); } } return 1; }
Servatrice::Servatrice(QSettings *_settings, QObject *parent) : Server(parent), dbMutex(QMutex::Recursive), settings(_settings), uptime(0), shutdownTimer(0) { pingClock = new QTimer(this); connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout())); pingClock->start(1000); ProtocolItem::initializeHash(); serverId = settings->value("server/id", 0).toInt(); int statusUpdateTime = settings->value("server/statusupdate").toInt(); statusUpdateClock = new QTimer(this); connect(statusUpdateClock, SIGNAL(timeout()), this, SLOT(statusUpdate())); if (statusUpdateTime != 0) { qDebug() << "Starting status update clock, interval " << statusUpdateTime << " ms"; statusUpdateClock->start(statusUpdateTime); } threaded = settings->value("server/threaded", false).toInt(); tcpServer = new Servatrice_TcpServer(this, threaded, this); int port = settings->value("server/port", 4747).toInt(); qDebug() << "Starting server on port" << port; if (tcpServer->listen(QHostAddress::Any, port)) qDebug() << "Server listening."; else qDebug() << "tcpServer->listen(): Error."; QString dbType = settings->value("database/type").toString(); dbPrefix = settings->value("database/prefix").toString(); if (dbType == "mysql") openDatabase(); int size = settings->beginReadArray("rooms"); for (int i = 0; i < size; ++i) { settings->setArrayIndex(i); QStringList gameTypes; int size2 = settings->beginReadArray("game_types"); for (int j = 0; j < size2; ++j) { settings->setArrayIndex(j); gameTypes.append(settings->value("name").toString()); } settings->endArray(); Server_Room *newRoom = new Server_Room( i, settings->value("name").toString(), settings->value("description").toString(), settings->value("autojoin").toBool(), settings->value("joinmessage").toString(), gameTypes, this ); addRoom(newRoom); } settings->endArray(); updateLoginMessage(); maxGameInactivityTime = settings->value("game/max_game_inactivity_time").toInt(); maxPlayerInactivityTime = settings->value("game/max_player_inactivity_time").toInt(); maxUsersPerAddress = settings->value("security/max_users_per_address").toInt(); messageCountingInterval = settings->value("security/message_counting_interval").toInt(); maxMessageCountPerInterval = settings->value("security/max_message_count_per_interval").toInt(); maxMessageSizePerInterval = settings->value("security/max_message_size_per_interval").toInt(); maxGamesPerUser = settings->value("security/max_games_per_user").toInt(); }
LocalServer::LocalServer(QObject *parent) : Server(parent) { setDatabaseInterface(new LocalServer_DatabaseInterface(this)); addRoom(new Server_Room(0, 0, QString(), QString(), QString(), false, QString(), QStringList(), this)); }
ui->z->setValidator(new QIntValidator()); getMinAndMax(rooms); createBlankTiles(); foreach (Room *r, rooms) { addRoom(r); } connect(ui->name, SIGNAL(textEdited(QString)), this, SLOT(floorNameChanged(QString))); connect(ui->z, SIGNAL(textEdited(QString)), this, SLOT(enableOkButton())); connect(ui->addRoom, SIGNAL(clicked()), this, SLOT(addRoom())); connect(ui->editRoom, SIGNAL(clicked()), this, SLOT(editRoom())); connect(ui->removeRoom, SIGNAL(clicked()), this, SLOT(removeRoom())); } FloorDialog::~FloorDialog() { delete ui; } QString FloorDialog::floorName() const { return ui->name->text(); }
bool Servatrice::initServer() { serverName = settings->value("server/name").toString(); serverId = settings->value("server/id", 0).toInt(); bool regServerOnly = settings->value("server/regonly", 0).toBool(); const QString authenticationMethodStr = settings->value("authentication/method").toString(); if (authenticationMethodStr == "sql") { authenticationMethod = AuthenticationSql; } else { if (regServerOnly) { qDebug() << "Registration only server enabled but no DB Connection : Error."; return false; } authenticationMethod = AuthenticationNone; } QString dbTypeStr = settings->value("database/type").toString(); if (dbTypeStr == "mysql") databaseType = DatabaseMySql; else databaseType = DatabaseNone; servatriceDatabaseInterface = new Servatrice_DatabaseInterface(-1, this); setDatabaseInterface(servatriceDatabaseInterface); if (databaseType != DatabaseNone) { settings->beginGroup("database"); dbPrefix = settings->value("prefix").toString(); servatriceDatabaseInterface->initDatabase("QMYSQL", settings->value("hostname").toString(), settings->value("database").toString(), settings->value("user").toString(), settings->value("password").toString()); settings->endGroup(); updateServerList(); qDebug() << "Clearing previous sessions..."; servatriceDatabaseInterface->clearSessionTables(); } const QString roomMethod = settings->value("rooms/method").toString(); if (roomMethod == "sql") { QSqlQuery query(servatriceDatabaseInterface->getDatabase()); query.prepare("select id, name, descr, auto_join, join_message from " + dbPrefix + "_rooms order by id asc"); servatriceDatabaseInterface->execSqlQuery(query); while (query.next()) { QSqlQuery query2(servatriceDatabaseInterface->getDatabase()); query2.prepare("select name from " + dbPrefix + "_rooms_gametypes where id_room = :id_room"); query2.bindValue(":id_room", query.value(0).toInt()); servatriceDatabaseInterface->execSqlQuery(query2); QStringList gameTypes; while (query2.next()) gameTypes.append(query2.value(0).toString()); addRoom(new Server_Room(query.value(0).toInt(), query.value(1).toString(), query.value(2).toString(), query.value(3).toInt(), query.value(4).toString(), gameTypes, this )); } } else { int size = settings->beginReadArray("rooms/roomlist"); for (int i = 0; i < size; ++i) { settings->setArrayIndex(i); QStringList gameTypes; int size2 = settings->beginReadArray("game_types"); for (int j = 0; j < size2; ++j) { settings->setArrayIndex(j); gameTypes.append(settings->value("name").toString()); } settings->endArray(); Server_Room *newRoom = new Server_Room( i, settings->value("name").toString(), settings->value("description").toString(), settings->value("autojoin").toBool(), settings->value("joinmessage").toString(), gameTypes, this ); addRoom(newRoom); } settings->endArray(); } updateLoginMessage(); maxGameInactivityTime = settings->value("game/max_game_inactivity_time").toInt(); maxPlayerInactivityTime = settings->value("game/max_player_inactivity_time").toInt(); maxUsersPerAddress = settings->value("security/max_users_per_address").toInt(); messageCountingInterval = settings->value("security/message_counting_interval").toInt(); maxMessageCountPerInterval = settings->value("security/max_message_count_per_interval").toInt(); maxMessageSizePerInterval = settings->value("security/max_message_size_per_interval").toInt(); maxGamesPerUser = settings->value("security/max_games_per_user").toInt(); try { if (settings->value("servernetwork/active", 0).toInt()) { qDebug() << "Connecting to ISL network."; const QString certFileName = settings->value("servernetwork/ssl_cert").toString(); const QString keyFileName = settings->value("servernetwork/ssl_key").toString(); qDebug() << "Loading certificate..."; QFile certFile(certFileName); if (!certFile.open(QIODevice::ReadOnly)) throw QString("Error opening certificate file: %1").arg(certFileName); QSslCertificate cert(&certFile); #if QT_VERSION < 0x050000 if (!cert.isValid()) throw(QString("Invalid certificate.")); #else const QDateTime currentTime = QDateTime::currentDateTime(); if(currentTime < cert.effectiveDate() || currentTime > cert.expiryDate() || cert.isBlacklisted()) throw(QString("Invalid certificate.")); #endif qDebug() << "Loading private key..."; QFile keyFile(keyFileName); if (!keyFile.open(QIODevice::ReadOnly)) throw QString("Error opening private key file: %1").arg(keyFileName); QSslKey key(&keyFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); if (key.isNull()) throw QString("Invalid private key."); QMutableListIterator<ServerProperties> serverIterator(serverList); while (serverIterator.hasNext()) { const ServerProperties &prop = serverIterator.next(); if (prop.cert == cert) { serverIterator.remove(); continue; } QThread *thread = new QThread; thread->setObjectName("isl_" + QString::number(prop.id)); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); IslInterface *interface = new IslInterface(prop.id, prop.hostname, prop.address.toString(), prop.controlPort, prop.cert, cert, key, this); interface->moveToThread(thread); connect(interface, SIGNAL(destroyed()), thread, SLOT(quit())); thread->start(); QMetaObject::invokeMethod(interface, "initClient", Qt::BlockingQueuedConnection); } const int networkPort = settings->value("servernetwork/port", 14747).toInt(); qDebug() << "Starting ISL server on port" << networkPort; islServer = new Servatrice_IslServer(this, cert, key, this); if (islServer->listen(QHostAddress::Any, networkPort)) qDebug() << "ISL server listening."; else throw QString("islServer->listen()"); } } catch (QString error) { qDebug() << "ERROR --" << error; return false; } pingClock = new QTimer(this); connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout())); pingClock->start(1000); int statusUpdateTime = settings->value("server/statusupdate").toInt(); statusUpdateClock = new QTimer(this); connect(statusUpdateClock, SIGNAL(timeout()), this, SLOT(statusUpdate())); if (statusUpdateTime != 0) { qDebug() << "Starting status update clock, interval " << statusUpdateTime << " ms"; statusUpdateClock->start(statusUpdateTime); } const int numberPools = settings->value("server/number_pools", 1).toInt(); gameServer = new Servatrice_GameServer(this, numberPools, servatriceDatabaseInterface->getDatabase(), this); gameServer->setMaxPendingConnections(1000); const int gamePort = settings->value("server/port", 4747).toInt(); qDebug() << "Starting server on port" << gamePort; if (gameServer->listen(QHostAddress::Any, gamePort)) qDebug() << "Server listening."; else { qDebug() << "gameServer->listen(): Error."; return false; } return true; }
void Map::defaultRooms() { addRoom(NUMBER_ROOM, new ROOM(roomGfxNumberRoom, ROOMFLAG_NONE, COLOR_PURPLE, // 0x00 NUMBER_ROOM, NUMBER_ROOM, NUMBER_ROOM, NUMBER_ROOM, "Number Room", ROOM::HIDDEN)); addRoom(MAIN_HALL_LEFT, new ROOM(roomGfxBelowYellowCastle, ROOMFLAG_LEFTTHINWALL, COLOR_OLIVEGREEN, // 0x01 BLUE_MAZE_1, MAIN_HALL_CENTER,BLACK_CASTLE, MAIN_HALL_RIGHT, "Main Hall Left")); addRoom(MAIN_HALL_CENTER, new ROOM(roomGfxBelowYellowCastle, ROOMFLAG_NONE, COLOR_LIMEGREEN, // 0x02 GOLD_CASTLE, MAIN_HALL_RIGHT, BLUE_MAZE_2, MAIN_HALL_LEFT, "Main Hall Center")); addRoom(MAIN_HALL_RIGHT , new ROOM(roomGfxSideCorridor, ROOMFLAG_RIGHTTHINWALL, COLOR_TAN, // 0x03 COPPER_CASTLE, MAIN_HALL_LEFT,SOUTHEAST_ROOM, MAIN_HALL_CENTER, "Main Hall Right")); addRoom(BLUE_MAZE_5, new ROOM(roomGfxBlueMazeTop, ROOMFLAG_NONE, COLOR_BLUE, // 0x04 0x10,0x05,0x07,0x06, "Blue Maze 5")); addRoom(BLUE_MAZE_2, new ROOM(roomGfxBlueMaze1, ROOMFLAG_NONE, COLOR_BLUE, // 0x05 0x1D,0x06,0x08,0x04, "Blue Maze 2")); addRoom(BLUE_MAZE_3, new ROOM(roomGfxBlueMazeBottom, ROOMFLAG_NONE, COLOR_BLUE, // 0x06 0x07,0x04,0x03,0x05, "Blue Maze 3")); addRoom(BLUE_MAZE_4, new ROOM(roomGfxBlueMazeCenter, ROOMFLAG_NONE, COLOR_BLUE, // 0x07 0x04,0x08,0x06,0x08, "Blue Maze 4")); addRoom(BLUE_MAZE_1, new ROOM(roomGfxBlueMazeEntry, ROOMFLAG_NONE, COLOR_BLUE, // 0x08 0x05,0x07,0x01,0x07, "Blue Maze 1")); addRoom(WHITE_MAZE_2, new ROOM(roomGfxMazeMiddle, ROOMFLAG_NONE, COLOR_LTGRAY, // 0x09 0x0A,0x0A,0x0B,0x0A, "White Maze 1")); addRoom(WHITE_MAZE_1, new ROOM(roomGfxMazeEntry, ROOMFLAG_NONE, COLOR_LTGRAY, // 0x0A 0x03,0x09,0x09,0x09, "White Maze 2")); addRoom(WHITE_MAZE_3, new ROOM(roomGfxMazeSide, ROOMFLAG_NONE, COLOR_LTGRAY, // 0x0B 0x09,0x0C,0x1C,0x0D, "White Maze 3")); addRoom(SOUTH_HALL_RIGHT, new ROOM(roomGfxSideCorridor, ROOMFLAG_RIGHTTHINWALL, COLOR_LTCYAN, // 0x0C COPPER_CASTLE, MAIN_HALL_LEFT,SOUTHEAST_ROOM, WHITE_MAZE_3, "South Hall RIGHT")); addRoom(SOUTH_HALL_LEFT, new ROOM(roomGfxSideCorridor, ROOMFLAG_LEFTTHINWALL, COLOR_DKGREEN, // 0x0D 0x0F,0x0B,0x0E,0x0C, "South Hall Left")); // 0x0E addRoom(SOUTHWEST_ROOM, new ROOM(roomGfxTopEntryRoom, ROOMFLAG_NONE, COLOR_CYAN, 0x0D,0x10,0x0F,0x10, "Southwest Room")); addRoom(WHITE_CASTLE, new ROOM(roomGfxCastle, ROOMFLAG_NONE, COLOR_WHITE, // 0x0F 0x0E,0x0F,0x0D,0x0F, "White Castle")); addRoom(BLACK_CASTLE, new ROOM(roomGfxCastle, ROOMFLAG_NONE, COLOR_BLACK, // 0x10 0x01,0x1C,0x04,0x1C, "Black Castle")); addRoom(GOLD_CASTLE, new ROOM(roomGfxCastle, ROOMFLAG_NONE, COLOR_YELLOW, // 0x11 0x06,0x03,0x02,0x01, "Gold Castle")); addRoom(GOLD_FOYER, new ROOM(roomGfxNumberRoom, ROOMFLAG_NONE, COLOR_YELLOW, // 0x12 GOLD_FOYER,GOLD_FOYER,GOLD_FOYER,GOLD_FOYER, "Gold Foyer")); addRoom(BLACK_MAZE_1, new ROOM(roomGfxBlackMaze1, ROOMFLAG_NONE, COLOR_LTGRAY, // 0x13 0x15,0x14,0x15,0x16, "Black Maze 1")); addRoom(BLACK_MAZE_2, new ROOM(roomGfxBlackMaze2, ROOMFLAG_MIRROR, COLOR_LTGRAY, // 0x14 0x16,0x15,0x16,0x13, "Black Maze 2")); addRoom(BLACK_MAZE_3, new ROOM(roomGfxBlackMaze3, ROOMFLAG_MIRROR, COLOR_LTGRAY, // 0x15 0x13,0x16,0x13,0x14, "Black Maze 3")); addRoom(BLACK_MAZE_ENTRY, new ROOM(roomGfxBlackMazeEntry, ROOMFLAG_NONE, COLOR_LTGRAY, // 0x16 0x14,0x13,0x1B,0x15, "Black Maze Entry")); addRoom(RED_MAZE_3, new ROOM(roomGfxRedMaze1, ROOMFLAG_NONE, COLOR_RED, // 0x17 0x19,0x18,0x19,0x18, "Red Maze 3")); addRoom(RED_MAZE_2, new ROOM(roomGfxRedMazeTop, ROOMFLAG_NONE, COLOR_RED, // 0x18 0x1A,0x17,0x1A,0x17, "Red Maze 2")); addRoom(RED_MAZE_4, new ROOM(roomGfxRedMazeBottom, ROOMFLAG_NONE, COLOR_RED, // 0x19 0x17,0x1A,0x17,0x1A, "Red Maze4 ")); addRoom(RED_MAZE_1, new ROOM(roomGfxWhiteCastleEntry, ROOMFLAG_NONE, COLOR_RED, // 0x1A 0x18,0x19,0x18,0x19, "Red Maze 1")); addRoom(BLACK_FOYER, new ROOM(roomGfxTwoExitRoom, ROOMFLAG_NONE, COLOR_RED, // 0x1B BLACK_INNERMOST_ROOM, BLACK_INNERMOST_ROOM, BLACK_INNERMOST_ROOM, BLACK_INNERMOST_ROOM, "Black Foyer")); addRoom(BLACK_INNERMOST_ROOM, new ROOM(roomGfxNumberRoom, ROOMFLAG_NONE, COLOR_PURPLE, // 0x1C SOUTHEAST_ROOM, BLUE_MAZE_4, BLACK_FOYER, BLUE_MAZE_1, "Black Innermost Room")); addRoom(SOUTHEAST_ROOM, new ROOM(roomGfxTopEntryRoom, ROOMFLAG_NONE, COLOR_RED, // 0x1D MAIN_HALL_RIGHT, MAIN_HALL_LEFT, BLACK_CASTLE, MAIN_HALL_RIGHT, "Southeast Room")); addRoom(ROBINETT_ROOM, new ROOM(roomGfxBelowYellowCastle, ROOMFLAG_NONE, COLOR_PURPLE, // 0x1E 0x06,0x01,0x06,0x03, "Robinett Room", ROOM::HIDDEN)); addRoom(JADE_CASTLE, new ROOM(roomGfxCastle3, ROOMFLAG_NONE, COLOR_JADE, // 0x1F SOUTHEAST_ROOM, BLUE_MAZE_3, BLUE_MAZE_2, BLUE_MAZE_5, "Jade Castle", ROOM::HIDDEN)); addRoom(JADE_FOYER, new ROOM(roomGfxNumberRoom, ROOMFLAG_NONE, COLOR_JADE, // 0x20 JADE_FOYER, JADE_FOYER, JADE_FOYER, JADE_FOYER, "Jade Foyer", ROOM::HIDDEN)); addRoom(COPPER_CASTLE, new ROOM(roomGfxCastle2, ROOMFLAG_NONE, COLOR_COPPER, // 0x21 BLUE_MAZE_3, MAIN_HALL_LEFT, MAIN_HALL_RIGHT, GOLD_CASTLE, "Copper Castle")); addRoom(COPPER_FOYER, new ROOM(roomGfxNumberRoom, ROOMFLAG_NONE, COLOR_COPPER, // 0x22 COPPER_FOYER, COPPER_FOYER, COPPER_FOYER, COPPER_FOYER, "Copper Foyer")); }