
Originally Posted by
iRaged
Thank you. My MySQL error logs have been filling up with this!
You probably get some more SQL errors related to pets.....
Here are some other fixes for that
In RoomUserManager.cs find
PHP Code:
internal void AppendPetsUpdateString(IQueryAdapter dbClient)
Replace that whole method with this one
PHP Code:
internal void AppendPetsUpdateString(IQueryAdapter dbClient)
{
QueryChunk chunk = new QueryChunk("INSERT INTO user_pets (id,user_id,room_id,name,type,race,color,expirience,energy,createstamp,nutrition,respect,z,y,z) VALUES ");
QueryChunk chunk2 = new QueryChunk();
List<uint> list = new List<uint>();
foreach (Pet pet in this.GetPets())
{
if (!list.Contains(pet.PetId))
{
list.Add(pet.PetId);
if (pet.DBState == DatabaseUpdateState.NeedsInsert)
{
chunk.AddParameter("name", pet.Name);
chunk.AddParameter("race", pet.Race);
chunk.AddParameter("color", pet.Color);
chunk.AddQuery(string.Concat(new object[] {
"(", pet.PetId, ",", pet.OwnerId, ",", pet.RoomId, ",@name,", pet.Type, ",@race,@color,0,100,'", pet.CreationStamp,
"',0,0,0,0,0)"
}));
chunk.Execute(dbClient);
chunk.Dispose();
}
else if (pet.DBState == DatabaseUpdateState.NeedsUpdate)
{
chunk2.AddParameter("name", pet.Name);
chunk2.AddParameter("race", pet.Race);
chunk2.AddParameter("color", pet.Color);
chunk2.AddQuery(string.Concat(new object[] {
"UPDATE user_pets SET room_id = ", pet.RoomId, ", name = @name, race = @race, color = @color, type = ", pet.Type, ", expirience = ", pet.Expirience, ", energy = ", pet.Energy, ", nutrition = ", pet.Nutrition,
", respect = ", pet.Respect, ", createstamp = '", pet.CreationStamp, "', x = ", pet.X, ", Y = ", pet.Y, ", Z = ", pet.Z, " WHERE id = ", pet.PetId
}));
chunk2.Execute(dbClient);
chunk2.Dispose();
}
pet.DBState = DatabaseUpdateState.Updated;
}
}
chunk = null;
chunk2 = null;
}
In InventoryComponents.cs find
PHP Code:
internal void RunDBUpdate()
Replace that entire method with this one
PHP Code:
internal void RunDBUpdate()
{
try
{
if (((this.mRemovedItems.Count > 0) || (this.mAddedItems.Count > 0)) || (this.InventoryPets.Count > 0))
{
using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
{
if (this.mAddedItems.Count > 0)
{
foreach (UserItem item in this.mAddedItems.Values)
{
adapter.runFastQuery(string.Concat(new object[] { "UPDATE items_users SET user_id = ", this.UserId, " WHERE item_id = ", item.Id }));
}
this.mAddedItems.Clear();
}
if (this.mRemovedItems.Count > 0)
{
foreach (uint num in this.mRemovedItems.ToArray())
{
adapter.runFastQuery(string.Concat(new object[] { "DELETE FROM items_users WHERE item_id=", num, " AND user_id=", this.UserId }));
}
this.mRemovedItems.Clear();
}
foreach (Pet pet in this.InventoryPets.Values)
{
if (pet.DBState == DatabaseUpdateState.NeedsUpdate)
{
adapter.addParameter("name", pet.Name);
adapter.addParameter("race", pet.Race);
adapter.addParameter("color", pet.Color);
adapter.runFastQuery(string.Concat(new object[] {
"UPDATE user_pets SET room_id = ", pet.RoomId, ", name = @name, race = @race, color = @color, type = ", pet.Type, ", expirience = ", pet.Expirience, ", energy = ", pet.Energy, ", nutrition = ", pet.Nutrition,
", respect = ", pet.Respect, ", createstamp = '", pet.CreationStamp, "', x = ", pet.X, ", Y = ", pet.Y, ", Z = ", pet.Z, " WHERE id = ", pet.PetId
}));
}
pet.DBState = DatabaseUpdateState.Updated;
}
}
}
}
catch (Exception exception)
{
Logging.LogCacheError("FATAL ERROR DURING USER INVENTORY DB UPDATE: " + exception.ToString());
}
}
That should fix all SQL errors related to pets.