Exemple #1
0
        public stripItem createPresent(int receivingUserID, string saleCode, string Note, string customData)
        {
            int definitionID = ObjectTree.Game.Items.getRandomPresentBoxDefinitionID();
            if (definitionID != 1)
            {
                stripItem presentBoxItem = ObjectTree.Game.Items.createItemInstance(definitionID, receivingUserID, "!" + Note);

                Database dbClient = new Database(false, true);
                dbClient.addParameterWithValue("itemid", presentBoxItem.ID);
                dbClient.addParameterWithValue("salecode", saleCode);
                if (customData == "")
                    dbClient.addParameterWithValue("customdata", DBNull.Value);
                else
                    dbClient.addParameterWithValue("customdata", customData);

                dbClient.Open();
                if (dbClient.Ready)
                    dbClient.runQuery("INSERT INTO items_presents VALUES (@itemid,@salecode,@customdata)");

                return presentBoxItem;
            }
            else
            {
                Logging.Log("Failed to create presentbox for sale '" + saleCode + "', one of the present box definitions is missing!", Logging.logType.commonError);
                return null;
            }
        }
Exemple #2
0
        /// <summary>
        /// Accepts a buddy request and notifies the sender (if online) and the receiver.
        /// </summary>
        /// <param name="Session">The Woodpecker.Sessions.Session object of the user that accepts the request.</param>
        /// <param name="senderID">The database ID of the user that sent the request.</param>
        public void acceptBuddyRequest(ref Session Session, int senderID)
        {
            Database Database = new Database(false, false);
            Database.addParameterWithValue("userid", Session.User.ID);
            Database.addParameterWithValue("senderid", senderID);
            Database.Open();

            if (Database.findsResult("SELECT userid FROM messenger_buddylist WHERE userid = @senderid AND buddyid = @userid AND accepted = '0' LIMIT 1"))
            {
                Database.runQuery("UPDATE messenger_buddylist SET accepted = '1' WHERE userid = @senderid AND buddyid = @userid LIMIT 1");
                Database.Close();

                serverMessage Message = new serverMessage();
                if (ObjectTree.Game.Users.userIsLoggedIn(senderID)) // Sender is online!
                {
                    Message.Initialize(137); // "BI"
                    Message.Append(getBuddy(Session.User.ID).ToString());
                    ObjectTree.Game.Users.trySendGameMessage(senderID, Message);
                }

                Message.Initialize(137); // "BI"
                Message.Append(getBuddy(senderID).ToString());
                Session.gameConnection.sendMessage(Message);
            }
            else
                Database.Close();
        }
Exemple #3
0
        /// <summary>
        /// Inserts room rights in a given room for a given user.
        /// </summary>
        /// <param name="roomID">The database ID of the room to assign the user rights to.</param>
        /// <param name="userID">The database ID of the user that gets the rights.</param>
        public void addRoomRights(int roomID, int userID)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("roomid", roomID);
            Database.addParameterWithValue("userid", userID);
            Database.Open();

            Database.runQuery("INSERT INTO rooms_rights(roomid,userid) VALUES (@roomid,@userid)");
        }
Exemple #4
0
        /// <summary>
        /// Adds a given room to a given user's favorite room list.
        /// </summary>
        /// <param name="userID">The database ID of the user to modify the list for.</param>
        /// <param name="roomID">The database ID of the room to add to the user's favorite list.</param>
        public void addFavoriteRoom(int userID, int roomID)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", userID);
            Database.addParameterWithValue("roomid", roomID);
            Database.Open();

            if (Database.Ready)
                Database.runQuery("INSERT INTO rooms_favorites(userid,roomid) VALUES (@userid,@roomid)");
        }
        /// <summary>
        /// Deletes a messenger message of a user, with only the message ID given.
        /// </summary>
        /// <param name="userID">The database ID of the user to delete the message of.</param>
        /// <param name="messageID">The ID of the message to delete.</param>
        public void markMessageAsRead(int userID, int messageID)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", userID);
            Database.addParameterWithValue("messageid", messageID);
            Database.Open();

            if (Database.Ready)
                Database.runQuery("DELETE FROM messenger_messages WHERE receiverid = @userid AND messageid = @messageid LIMIT 1");
        }
        /// <summary>
        /// Updates the last activity datetime in the database and this object to the current time.
        /// </summary>
        public void updateLastActivity()
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", this.ID);
            Database.Open();
            if (Database.Ready)
                Database.runQuery("UPDATE users SET lastactivity = NOW() WHERE id = @userid");

            this.lastActivity = DateTime.Now;
        }
 /// <summary>
 /// Adds a given IP address to the connection blacklist, thus refusing future connections (both game and MUS) from that IP address.
 /// </summary>
 /// <param name="IP">The IP address to add to the blacklist.</param>
 public void blackListIpAddress(string IP)
 {
     Database Database = new Database(false, true);
     Database.addParameterWithValue("ip", IP);
     Database.Open();
     if (Database.Ready)
     {
         Database.runQuery("INSERT INTO connections_blacklist(ip,added) VALUES (@ip, CURDATE())");
         Logging.Log("Blacklisted IP address '" + IP + "' for whatever reason.", Logging.logType.connectionBlacklistEvent);
     }
     else
         Logging.Log("Failed to add IP address '" + IP + "' to the connection blacklist, the database was not contactable.", Logging.logType.commonError);
 }
        /// <summary>
        /// Inserts a new row with the current access details into the database's 'users_access' table.
        /// </summary>
        public void Update()
        {
            Database dbClient = new Database(false, true);
            dbClient.addParameterWithValue("userid", this.userID);
            dbClient.addParameterWithValue("sessionid", this.sessionID);
            dbClient.addParameterWithValue("ip", this.IP);
            dbClient.addParameterWithValue("machineid", this.machineID);

            dbClient.Open();
            if (dbClient.Ready)
            {
                dbClient.runQuery("INSERT INTO users_access VALUES (@userid,@sessionid,NOW(),@ip,@machineid)");
                this.lastUpdate = DateTime.Now;
            }
        }
Exemple #9
0
        /// <summary>
        /// Deletes a given user flat from the database,
        /// </summary>
        /// <param name="roomID">The database ID of the room to delete.</param>
        public void deleteFlat(int roomID)
        {
            Database Database = new Database(false, false);
            Database.addParameterWithValue("roomid", roomID);
            Database.Open();

            if (Database.Ready)
            {
                Database.runQuery("DELETE FROM rooms WHERE id = @roomid LIMIT 1");
                Database.runQuery("DELETE FROM rooms_rights WHERE roomid = @roomid");
                Database.Close();
            }
        }
Exemple #10
0
        /// <summary>
        /// Swaps the trade offer items of two trade partners and updates the database, hand item collection etc. The swap is aborted if the trade is invalid.
        /// </summary>
        /// <param name="partnerItemStrip">The itemStripHandler object of the trade partner session.</param>
        public void swapTradeOffers(itemStripHandler partnerItemStrip)
        {
            if (this.isTrading && partnerItemStrip.isTrading && (this.tradeOfferItemCount > 0 || partnerItemStrip.tradeOfferItemCount > 0)) // Can swap items
            {
                Database dbClient = new Database(true, false);
                if (!dbClient.Ready)
                    return;

                foreach (int myTradeOfferItemID in this.tradeOfferItemIDs)
                {
                    stripItem lItem = this.getHandItem(myTradeOfferItemID);
                    if (lItem == null)
                        return; // Trade invalid

                    this.removeHandItem(myTradeOfferItemID, false); // Remove from this item strip
                    partnerItemStrip.addHandItem(lItem); // Add to partner item strip
                    dbClient.runQuery("UPDATE items SET ownerid = '" + partnerItemStrip.userID + "' WHERE id = '" + lItem.ID + "' LIMIT 1"); // Update database
                }

                foreach (int partnerTradeOfferItemID in partnerItemStrip.tradeOfferItemIDs)
                {
                    stripItem lItem = partnerItemStrip.getHandItem(partnerTradeOfferItemID);
                    if (lItem == null)
                        return; // Trade invalid

                    partnerItemStrip.removeHandItem(partnerTradeOfferItemID, false); // Remove from partner item strip
                    this.addHandItem(lItem); // Add to this item strip
                    dbClient.runQuery("UPDATE items SET ownerid = '" + this.userID + "' WHERE id = '" + lItem.ID + "' LIMIT 1"); // Update database
                }

                dbClient.Close(); // Close database connection
            }
        }
        /// <summary>
        /// Updates the dynamical fields for this pet in the database.
        /// </summary>
        public void Update()
        {
            Database dbClient = new Database(false, true);
            dbClient.addParameterWithValue("id", this.ID);
            dbClient.addParameterWithValue("friendship", this.fFriendship);
            dbClient.addParameterWithValue("x", this.lastX);
            dbClient.addParameterWithValue("y", this.lastY);
            dbClient.addParameterWithValue("last_kip", this.dtLastKip);
            dbClient.addParameterWithValue("last_eat", this.dtLastFed);
            dbClient.addParameterWithValue("last_drink", this.dtLastDrink);
            dbClient.addParameterWithValue("last_playtoy", this.dtLastPlayToy);
            dbClient.addParameterWithValue("last_playuser", this.dtLastPlayUser);

            dbClient.Open();
            if (dbClient.Ready)
                dbClient.runQuery(
                    "UPDATE items_pets SET " +

                    "friendship = @friendship," +
                    "x = @x," +
                    "y = @y," +
                    "last_kip = @last_kip," +
                    "last_eat = @last_eat," +
                    "last_drink = @last_drink," +
                    "last_playtoy = @last_playtoy," +
                    "last_playuser = @last_playuser " +

                    "WHERE id = @id " +
                    "LIMIT 1");
        }
        private void deleteItemDefinition(int ID)
        {
            Database dbClient = new Database(false, false);
            dbClient.addParameterWithValue("definitionid", ID);

            dbClient.Open();
            if (dbClient.Ready)
            {
                dbClient.runQuery("DELETE FROM items_definitions WHERE id = @definitionid LIMIT 1"); // Drop definition
                dbClient.runQuery("DELETE FROM store_catalogue_sales WHERE item_definitionid = @definitionid"); // Drop single-item sales with this item definition
                dbClient.runQuery("DELETE FROM store_catalogue_sales_packages WHERE definitionid = @definitionid"); // Drop this item definition from packages
                dbClient.Close();
            }
        }
Exemple #13
0
        public void removeBuddy(int userID, int buddyID)
        {
            Database Database = new Database(false, false);
            Database.addParameterWithValue("userid", userID);
            Database.addParameterWithValue("buddyid", buddyID);
            Database.Open();

            if (Database.Ready)
            {
                Database.runQuery("DELETE FROM messenger_buddylist WHERE (userid = @userid AND buddyid = @buddyid) OR (userid = @buddyid AND buddyid = @userid) AND accepted = '1' LIMIT 1");
                Database.runQuery("DELETE FROM messenger_messages WHERE (receiverid = @userid AND senderid = @buddyid) OR (receiverid = @buddyid AND senderid = @userid)"); // Delete messages between users

                Database.Close();
            }

            if (ObjectTree.Game.Users.userIsLoggedIn(buddyID)) // Victim is online
            {
                serverMessage Message = new serverMessage(138); // "BJ"
                Message.appendWired(1);
                Message.appendWired(userID);
                ObjectTree.Game.Users.trySendGameMessage(buddyID,Message);
            }
        }
Exemple #14
0
 /// <summary>
 /// Resets the amount of users for every room in the database to 0.
 /// </summary>
 public void resetRoomUserAmounts()
 {
     Database Database = new Database(true, true);
     if (Database.Ready)
     {
         Database.runQuery("UPDATE rooms SET visitors_now = '0'");
         Logging.Log("Current visitor amounts of rooms set to 0.");
     }
 }
Exemple #15
0
        /// <summary>
        /// Removes a given room to a given user's favorite room list.
        /// </summary>
        /// <param name="userID">The database ID of the user to modify the list for.</param>
        /// <param name="roomID">The database ID of the room to remove to the user's favorite list.</param>
        public void removeFavoriteRoom(int userID, int roomID)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", userID);
            Database.addParameterWithValue("roomid", roomID);
            Database.Open();

            if (Database.Ready)
                Database.runQuery("DELETE FROM rooms_favorites WHERE userid = @userid AND roomid = @roomid LIMIT 1");
        }
Exemple #16
0
        /// <summary>
        /// Gives a badge to user, after checking if the user doesn't already have this badge. A boolean is returned that indicates if the badge is given or not.
        /// </summary>
        /// <param name="userID">The database ID of the user to give the badge to.</param>
        /// <param name="Badge">The badge of the user to </param>
        public bool giveBadgeToUser(int userID, string Badge)
        {
            Database Database = new Database(false, false);
            Database.addParameterWithValue("userid", userID);
            Database.addParameterWithValue("badge", Badge);
            Database.Open();
            if (Database.Ready)
            {
                if (!Database.findsResult("SELECT userid FROM users_badges WHERE userid = @userid AND badge = @badge LIMIT 1"))
                {
                    Database.runQuery("INSERT INTO users_badges(userid,badge) VALUES (@userid,@badge)");
                    return true;
                }
                Database.Close();
            }

            return false;
        }
Exemple #17
0
        /// <summary>
        /// Declines a unaccepted buddy request for the messenger.
        /// </summary>
        /// <param name="userID">The database ID of the user that declines the request.</param>
        /// <param name="senderID">The database ID of the user that sent the request.</param>
        public void declineBuddyRequest(int userID, int senderID)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", userID);
            if(senderID > 0)
                Database.addParameterWithValue("senderid", senderID);
            Database.Open();

            if (Database.Ready)
            {
                if (senderID > 0) // Specific request was rejected
                    Database.runQuery("DELETE FROM messenger_buddylist WHERE userid = @senderid AND buddyid = @userid AND accepted = '0' LIMIT 1");
                else // All requests were rejected
                    Database.runQuery("DELETE FROM messenger_buddylist WHERE buddyid = @userid AND accepted = '0'");
            }
        }
Exemple #18
0
        /// <summary>
        /// Tries to redeem a credit/item voucher for a user session.
        /// </summary>
        /// <param name="Session">The Woodpecker.Sessions.Session object to redeem the voucher with.</param>
        /// <param name="Code">The vouchercode the user entered.</param>
        public void redeemVoucher(ref Session Session, string Code)
        {
            serverMessage Response = new serverMessage();
            Database Database = new Database(false, false);
            Database.addParameterWithValue("code", Code);

            Database.Open();
            if (Database.Ready)
            {
                DataRow dRow = Database.getRow("SELECT type,value FROM users_vouchers WHERE code = @code AND ISNULL(redeemer_userid)");
                if (dRow != null) // Voucher found
                {
                    // Mark voucher as redeemed
                    Database.addParameterWithValue("userid", Session.User.ID);
                    Database.runQuery("UPDATE users_vouchers SET redeemer_userid = @userid WHERE code = @code");
                    Database.Close();

                    string Type = (string)dRow["type"];
                    if (Type == "credits")
                    {
                        int Credits = int.Parse(dRow["value"].ToString());
                        Session.User.Credits += Credits;
                        Session.User.updateValueables();
                        this.logTransaction(Session.User.ID, "win_voucher", Credits);

                        Session.refreshCredits();
                    }
                    else if (Type == "item")
                    {
                        string[] Items = ((string)dRow["value"]).Split(';');

                    }

                    // Success!
                    Response.Initialize(212); // "CT"
                    Session.gameConnection.sendMessage(Response);
                    return;
                }
                else
                {
                    // Error 1! (not found)
                    Response.Initialize(213); // "CU"
                    Response.Append(1);
                }
                Session.gameConnection.sendMessage(Response);
            }
        }
Exemple #19
0
 /// <summary>
 /// Writes a new row in the users_creditlog table of the database, with the user ID of a user, the type of purchase/action and the activity. (+100, -100 etc) The current datetime is inserted aswell. This record can be viewed by the user via the 'Transactions' button in the Purse.
 /// </summary>
 /// <param name="userID">The database ID of the user to log the action for.</param>
 /// <param name="Type">The type of the action. (win_voucher, club_habbo etc)</param>
 /// <param name="Activity">The activity of the action. (+100, -100 etc)</param> 
 public void logTransaction(int userID, string Type, int Activity)
 {
     Database Database = new Database(false, true);
     Database.addParameterWithValue("userid", userID);
     Database.addParameterWithValue("type", Type);
     Database.addParameterWithValue("activity", Activity);
     Database.Open();
     if (Database.Ready)
     {
         Database.runQuery("INSERT INTO users_creditlog(userid,moment,type,activity) VALUES (@userid,NOW(),@type,@activity)");
     }
 }
Exemple #20
0
 /// <summary>
 /// Removes all records in user favorite room lists that refer to non-existing rooms. (eg, deleted etc)
 /// </summary>
 public void dropInvalidFavoriteRoomEntries()
 {
     Database Database = new Database(true, true);
     if (Database.Ready)
         Database.runQuery("DELETE FROM rooms_favorites WHERE NOT(rooms_favorites.roomid) IN(SELECT rooms.id FROM rooms)");
 }
Exemple #21
0
        /// <summary>
        /// Registers a new user by writing the given details into the 'users' table of the database.
        /// </summary>
        /// <param name="Session"></param>
        /// <param name="Info">The information about the new user in a userInformation object.</param>
        public void registerUser(Session Session, userInformation Info)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("username", Info.Username);
            Database.addParameterWithValue("password", Info.Password);
            Database.addParameterWithValue("role", "1");
            Database.addParameterWithValue("figure", Info.Figure);
            Database.addParameterWithValue("sex", Info.Sex.ToString());
            Database.addParameterWithValue("motto", Configuration.getConfigurationValue("users.registration.motto"));
            Database.addParameterWithValue("motto_messenger", Configuration.getConfigurationValue("users.registration.messengermotto"));
            Database.addParameterWithValue("credits", Configuration.getNumericConfigurationValue("users.registration.credits"));
            Database.addParameterWithValue("tickets", Configuration.getNumericConfigurationValue("users.registration.tickets"));
            Database.addParameterWithValue("film", 0);
            Database.addParameterWithValue("email", Info.Email);
            Database.addParameterWithValue("dob", Info.DateOfBirth);

            Database.Open();
            if (Database.Ready)
            {
                //Database.runQuery("CALL register_user(@username,@password,@figure,@sex,@email,@dob,@receivemails)");
                Database.runQuery(
                    "INSERT INTO users " +
                    "(username,password,role,signedup,figure,sex,motto,motto_messenger,credits,tickets,film,lastactivity,club_lastupdate,email,dob) " +
                    "VALUES " +
                    "(@username,@password,@role,NOW(),@figure,@sex,@motto,@motto_messenger,@credits,@tickets,@film,NOW(),NOW(),@email,@dob)");

                Logging.Log("Created user '" + Info.Username + "'.", Logging.logType.userVisitEvent);
            }
            else
                Logging.Log("Failed to create user " + Info.Username + ", because the database was not contactable!", Logging.logType.commonWarning);
        }
Exemple #22
0
        /// <summary>
        /// Writes a buddy request from a given user to another user into the database, and notifies the receiver with the new request if it's online.
        /// </summary>
        /// <param name="User">The userInformation object of the user that sends the request.</param>
        /// <param name="userID2">The database ID of the receiving user.</param>
        public void requestBuddy(userInformation User, int userID2)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", User.ID);
            Database.addParameterWithValue("userid2", userID2);
            Database.Open();
            Database.runQuery("INSERT INTO messenger_buddylist(userid,buddyid) VALUES (@userid,@userid2)");

            if (ObjectTree.Game.Users.userIsLoggedIn(userID2)) // Receiver is online
            {
                serverMessage Message = new serverMessage(132); // "BD"
                Message.appendWired(User.ID);
                Message.appendClosedValue(User.Username);

                ObjectTree.Game.Users.trySendGameMessage(userID2, Message);
            }
        }
Exemple #23
0
        /// <summary>
        /// Removes roomrights for a given user in a given room.
        /// </summary>
        /// <param name="roomID">The database ID of the room to remove the rights for the user of.</param>
        /// <param name="userID">The database ID of the user that gets the rights removed.</param>
        public void removeRoomRights(int roomID, int userID)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("roomid", roomID);
            Database.addParameterWithValue("userid", userID);
            Database.Open();

            Database.runQuery("DELETE FROM rooms_rights WHERE roomid = @roomid AND userid = @userid LIMIT 1");
            // TODO: refresh in room instance
        }
Exemple #24
0
 /// <summary>
 /// Removes a certain badge from a given user.
 /// </summary>
 /// <param name="userID">The database ID of the user to remove the badge of.</param>
 /// <param name="Badge">The badge to remove.</param>
 public void removeBadgeFromUser(int userID, string Badge)
 {
     Database Database = new Database(false, false);
     Database.addParameterWithValue("userid", userID);
     Database.addParameterWithValue("badge", Badge);
     Database.Open();
     if (Database.Ready)
         Database.runQuery("DELETE FROM users_badges WHERE userid = @userid AND badge = @badge LIMIT 1");
 }
Exemple #25
0
        /// <summary>
        /// Updates the current amount of visitors in a given room instance in the database.
        /// </summary>
        /// <param name="roomID">The database ID of the room to update.</param>
        /// <param name="userAmount">The up to date amount of users in the instance of the given room.</param>
        public void updateRoomUserAmount(int roomID, int userAmount)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("roomid", roomID);
            Database.addParameterWithValue("useramount", userAmount);
            Database.Open();

            if (Database.Ready)
                Database.runQuery("UPDATE rooms SET visitors_now = @useramount WHERE id = @roomid LIMIT 1");
        }
Exemple #26
0
            /// <summary>
            /// Starts the booting procedure of Woodpecker and handles exceptions.
            /// </summary>
            public static void Start()
            {
                Logging.setDefaultLogSessings();

                Logging.Log("Welcome to Woodpecker!");
                Logging.Log("Checking db.config...");
                if (!Configuration.configFileExists)
                {
                    Logging.Log("db.config was not found in the same directory as the executable of this copy of Woodpecker!");
                    Stop("db.config not found");
                    return;
                }

                Configuration.createConnectionString();
                Logging.Log("Running database connectivity check...");

                Database Check = new Database(true, true);
                if (Check.Ready)
                {
                    Check.runQuery("INSERT INTO server_startups(startup) VALUES (NOW())"); // Log server startup
                    Check = null;
                    Logging.Log("Database is contactable!");
                }
                else
                {
                    Logging.Log("Failed to contact database, please check the error shown above!", Logging.logType.commonWarning);
                    Stop("failed to contact database");
                    return;
                }

                Configuration.loadConfiguration();
                _md5Provider = new md5Provider();
                _md5Provider.baseSalt = Configuration.getConfigurationValue("cryptography.md5.salt");
                _externalManager.loadEntries();

                _roleManager.loadRoles();
                _messengerManager.setConfiguration();

                _moderationManager.logChat = (Configuration.getConfigurationValue("moderation.logchat") == "1");
                _itemManager.loadDefinitions();

                _storeManager.loadSales();
                _storeManager.loadCataloguePages();

                _roomManager.initRoomCategories();
                _roomManager.initRoomModels();

                int Port = Configuration.getNumericConfigurationValue("connections.game.port");
                if (Port > 0)
                {
                    int maxConnectionsPerIP = Configuration.getNumericConfigurationValue("connections.game.maxperip");
                    if (maxConnectionsPerIP == 0)
                    {
                        Logging.Log("The field connections.game.maxperip in the `configuration` table of the database is not holding a valid value. The default value '3' will be used.", Logging.logType.commonWarning);
                        maxConnectionsPerIP = 3;
                    }
                    if (!_gameConnectionManager.startListening(Port, maxConnectionsPerIP))
                    {
                        Logging.Log("Failed to setup game connection listener, the port (" + Port + ") is probably in use by another application.", Logging.logType.commonWarning);
                        Stop("failed to setup game connection listener");
                        return;
                    }
                }
                else
                {
                    Logging.Log("The field 'connections.game.port' in the `configuration` table of the database is not present. Please fill in a numeric entry, which represents the port to listen on for game connections.", Logging.logType.commonWarning);
                    Stop("No valid port for game connection listener set.");
                    return;
                }
                _mainForm.logSacredText(null);

                _sessionManager.startPingChecker();
                _sessionManager.startReceivedBytesChecker();
                Game.startUpdater();

                Logging.Log("Ready for connections!");
                _mainForm.logSacredText(null);
                _mainForm.stripMenu.Enabled = true;
            }
Exemple #27
0
        /// <summary>
        /// Creates a new user flat room by writing the given details in the 'rooms' table of the database. The new room's ID is returned upon success.
        /// </summary>
        /// <param name="Details">The Woodpecker.Game.Rooms.roomInformation object containing the details of the new room.</param>
        public int createFlat(roomInformation Details)
        {
            int roomID = 0;
            Database Database = new Database(false, false);
            Database.addParameterWithValue("roomname", Details.Name);
            Database.addParameterWithValue("ownerid", Details.ownerID);
            Database.addParameterWithValue("modeltype", Details.modelType);
            Database.addParameterWithValue("accesstype", ((int)Details.accessType).ToString());
            Database.addParameterWithValue("showname", Details.showOwner.ToString().ToLower());
            Database.Open();

            if (Database.Ready)
            {
                Database.runQuery("INSERT INTO rooms(ownerid,roomname,modeltype,showname,accesstype) VALUES (@ownerid,@roomname,@modeltype,@showname,@accesstype)");
                roomID = Database.getInteger("SELECT MAX(id) FROM rooms WHERE ownerid = @ownerid LIMIT 1");
                Database.Close();
            }

            return roomID;
        }
Exemple #28
0
        /// <summary>
        /// Updates the information of this item instance in the database.
        /// </summary>
        public void Update()
        {
            Database dbClient = new Database(false, true);
            dbClient.addParameterWithValue("z", this.Z);
            if (this.customData == null || this.Definition.Behaviour.customDataTrueFalse)
                dbClient.addParameterWithValue("customdata", DBNull.Value);
            else
                dbClient.addParameterWithValue("customdata", this.customData);

            dbClient.Open();
            if (dbClient.Ready)
            {
                dbClient.runQuery("UPDATE items SET ownerid = '" + this.ownerID + "',roomid = '" + this.roomID + "',x = '" + this.X + "',y = '" + this.Y + "',z = @z,rotation = '" + this.Rotation + "',customdata = @customdata WHERE id = '" + this.ID + "' LIMIT 1");
                this.requiresUpdate = false; // Update performed!
            }
        }
        private void saveItemDefinition(itemDefinition pDefinition)
        {
            Database dbClient = new Database(false, false);
            dbClient.addParameterWithValue("definitionid", pDefinition.ID);
            dbClient.addParameterWithValue("directoryid", pDefinition.directoryID);
            dbClient.addParameterWithValue("sprite", pDefinition.Sprite);
            dbClient.addParameterWithValue("color", pDefinition.Color);
            dbClient.addParameterWithValue("length", pDefinition.Length);
            dbClient.addParameterWithValue("width", pDefinition.Width);
            dbClient.addParameterWithValue("topheight", pDefinition.topHeight);
            dbClient.addParameterWithValue("behaviour", pDefinition.Behaviour.ToString());

            dbClient.Open();
            if (dbClient.Ready)
            {
                dbClient.runQuery("DELETE FROM items_definitions WHERE id = @definitionid LIMIT 1"); // Drop old definition
                dbClient.runQuery( // Insert new/edited definition
                    "INSERT INTO items_definitions " +
                    "VALUES " +
                    "(@definitionid,@directoryid,@sprite,@color,@length,@width,@topheight,@behaviour)");
                dbClient.Close();
            }
        }
Exemple #30
0
        public void Update()
        {
            Database dbClient = new Database(false, true);
            if (this.wallPosition == null)
                dbClient.addParameterWithValue("wallposition", DBNull.Value);
            else
                dbClient.addParameterWithValue("wallposition", this.wallPosition);
            if (this.customData == null)
                dbClient.addParameterWithValue("customdata", DBNull.Value);
            else
                dbClient.addParameterWithValue("customdata", this.customData);
            if (this.postItMessage == null)
                dbClient.addParameterWithValue("postit_message", DBNull.Value);
            else
                dbClient.addParameterWithValue("postit_message", this.postItMessage);

            dbClient.Open();
            if (dbClient.Ready)
            {
                dbClient.runQuery("UPDATE items SET ownerid = '" + this.ownerID + "',roomid = '" + this.roomID + "',customdata = @customdata,wallposition = @wallposition,postit_message = @postit_message WHERE id = '" + this.ID + "' LIMIT 1");
                this.requiresUpdate = false; // Update performed!
            }
        }