uint32_t ProtocolConfig::readSignature(const char* fn) { uint32_t sig; FILE*f=yatc_fopen(fn,"rb"); ASSERTFRIENDLY(f,"Could not find a data file although we found it in the past."); yatc_fread(&sig, 4, 1, f); fclose(f); return sig; }
Container::Container(std::string title, unsigned char containerid, unsigned short icon, unsigned char capacity) { this->containerid = containerid; this->icon = icon; this->capacity = capacity; window.SetCaption(title); window.SetWidth(166); window.SetHeight(40 * 2 + 10); window.AddObject(&panel); panel.SetWidth(166); panel.SetHeight(40*2); panel.SetBGActiveness(false); panel.SetPos(0, 10); panel.SetVirtualSize(166, ((capacity / 4) + 1) * 37); objects = (glictPanel**)malloc(sizeof(glictPanel*) * capacity); printf("Allocating %d\n", sizeof(glictPanel*) * capacity); ASSERTFRIENDLY(objects, "Failed to allocate some memory for storing items in container."); for (int i = 0 ; i < capacity ; i++ ) { glictPanel *p = new glictPanel; objects[i] = p; containeritemdata_t *c = (containeritemdata_t*)malloc(sizeof(containeritemdata_t)); c->container = this; c->elementid = i; panel.AddObject(objects[i]); objects[i]->SetWidth(32); objects[i]->SetHeight(32); objects[i]->SetPos(8+ (i % 4) * 37, 5 + (i / 4) * 37 ); objects[i]->SetBGColor(.2, .2, .2, 1.); objects[i]->SetCustomData(c); objects[i]->SetOnPaint(Container_SlotsOnPaint); objects[i]->SetOnClick(Container_SlotsOnClick); objects[i]->SetOnMouseDown(Container_SlotsOnMouseDown); objects[i]->SetOnMouseUp(Container_SlotsOnMouseUp); } unsigned char *cid = (unsigned char *)malloc(5); *cid = containerid; close.SetWidth(10); close.SetHeight(10); close.SetPos(150, 0); close.SetCaption("X"); close.SetOnClick(Container_CloseOnClick); close.SetCustomData(cid); window.AddObject(&close); }
void GM_MainMenu::DestroyCharlist() { ONThreadSafe(threadsafe); printf("Destroying charlist\n"); for (int i = 0 ; i < protocol->charlistcount ; i++) { printf("Destroying %d\n", i); characterlist.RemoveObject(protocol->charlist[i]->button); if (protocol->charlist[i]->button) delete protocol->charlist[i]->button; protocol->charlist[i]->button = NULL; ASSERTFRIENDLY(TextureIntegrityTest(), "GM_MainMenu::DestroyCharlist(): Texture integrity test failed"); } characterlist.RemoveObject(&btnCharlistCancel); characterlist.DelayedRemove(); printf("Charlist destroyed\n"); ONThreadUnsafe(threadsafe); }
bool ProtocolME0::GameworldLogin () { NetworkMessage nm; ONThreadSafe(threadsafe); connectiontype = GAMEWORLD; //nm.AddU8(0x14); //nm.AddString(this->charlist[this->charlistselected]->charactername); //spcount ++; if (!strcmp(this->charlist[this->charlistselected]->charactername, "Character Manager")) { nm.AddU8(0x0C); // charmgr... nm.AddU8(0x01); // ...enter FILE *f = fopen((std::string("save/") + this->username + ".ous").c_str(), "r"); ASSERTFRIENDLY(f, "It appears that savefile has mysteriously disappeared. Exiting"); fclose(f); } else { nm.AddU8(0x0A); // player's creature id shall be 1 nm.AddU32(1); nm.AddU8(0x32); // report bugs? nm.AddU8(0); nm.AddU8(0); nm.AddU8(0x64); // player teleport nm.AddU16(30); nm.AddU16(30); nm.AddU8(7); int tilesremaining = 18*14*7; for (int i = 0; i < 18; i ++) for (int j = 0; j < 14; j++) { printf("%d\n", tilesremaining); nm.AddU16(102); if (i == 8 && j == 6) { nm.AddU16(0x0061); nm.AddU32(0); // remove with this id nm.AddU32(1); // creatureid -- player is 1 nm.AddString("Newbie"); nm.AddU8(25); // health nm.AddU8(0); //dir nm.AddU16(128); // lookid nm.AddU8(50); nm.AddU8(60); nm.AddU8(70); nm.AddU8(80); nm.AddU8(0); // addons nm.AddU8(0); // lightlevel nm.AddU8(0); // lightcolor nm.AddU16(500); // speed nm.AddU8(0); // skull nm.AddU8(0); // shield } tilesremaining--; nm.AddU16(0xFF00); } while(tilesremaining) { nm.AddU8(tilesremaining > 255 ? 255 : tilesremaining); tilesremaining -= tilesremaining > 255 ? 255 : tilesremaining; printf("%d\n", tilesremaining); nm.AddU8(0xFF); } } ((GM_MainMenu*)game)->DestroyCharlist(); // by default logon is a success logonsuccessful = true; packetparsing: while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm)); if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n"); ONThreadUnsafe(threadsafe); return logonsuccessful; }