MCPcopy Create free account
hub / github.com/crossuo/crossuo / UpdateContainedItem

Method UpdateContainedItem

src/GameObjects/GameWorld.cpp:1153–1224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1151}
1152
1153void CGameWorld::UpdateContainedItem(
1154 uint32_t serial,
1155 uint16_t graphic,
1156 uint8_t graphicIncrement,
1157 uint16_t count,
1158 int x,
1159 int y,
1160 int containerSerial,
1161 uint16_t color)
1162{
1163 if (g_ObjectInHand.Serial == serial && g_ObjectInHand.Dropped)
1164 {
1165 g_ObjectInHand.Clear();
1166 }
1167
1168 // GetWorldItem will try to find and if it can't find, it will create a new game object
1169 // FindWorldObject will just try to find and return null.
1170 // So if we're updating an item inside a container (the server said so), the container
1171 // must exist. If it does not exist, we create it right here.
1172 // This fixes one issue with new trading system (with the platinum currency) implemented
1173 // on RunUO/ServUO 2+, but this will probably fix other hidden issues and hopefully not be
1174 // problematic.
1175 CGameObject *container = g_World->GetWorldItem(containerSerial);
1176 CGameObject *obj = FindWorldObject(serial);
1177 assert(container && !container->NPC && "container should not be a mobile - please report this");
1178 if (obj != nullptr && (!container->IsCorpse() || ((CGameItem *)obj)->Layer == OL_NONE))
1179 {
1180 RemoveObject(obj);
1181 obj = nullptr;
1182 }
1183
1184 if (obj == nullptr)
1185 {
1186 if ((serial & 0x40000000) != 0)
1187 {
1188 obj = GetWorldItem(serial);
1189 }
1190 else
1191 {
1192 obj = GetWorldCharacter(serial);
1193 }
1194 }
1195
1196 if (obj == nullptr)
1197 {
1198 Warning(Client, "could not find/create object serial:%08x", serial);
1199 return;
1200 }
1201
1202 obj->MapIndex = g_CurrentMap;
1203 obj->Graphic = graphic + graphicIncrement;
1204 obj->OnGraphicChange();
1205 obj->Color = g_ColorManager.FixColor(color, (color & 0x8000));
1206 if (count == 0u)
1207 {
1208 count = 1;
1209 }
1210 obj->Count = count;

Callers 1

PACKET_HANDLERFunction · 0.80

Calls 5

GetWorldItemMethod · 0.80
IsCorpseMethod · 0.80
FixColorMethod · 0.80
ClearMethod · 0.45
OnGraphicChangeMethod · 0.45

Tested by

no test coverage detected