//sub_80025628(zdat) void initZone(entry *zdat) { unsigned char *zoneHeader = zdat->itemData[0]; unsigned long collisionSkip = getWord(zoneHeader, 0x204, true); unsigned long sectionCount = getWord(zoneHeader, 0x208, true); if (sectionCount > 0) { for (int section = 0; section < sectionCount; section++) { unsigned long sectionIndex = collisionSkip + section; unsigned char *zoneSection = zdat->itemData[sectionIndex]; setWord(zoneSection, 4, (unsigned long)zdat, false); } } unsigned long entityCount = getWord(zoneHeader, 0x20C, true); if (entityCount > 0) { for (int entity = 0; entity < entityCount; entity++) { unsigned long entityIndex = collisionSkip + sectionCount + entity; unsigned char *zoneEntity = zdat->itemData[entityIndex]; setWord(zoneEntity, 0, (unsigned long)zdat, false); } } }
MCONTACT CIrcProto::CList_AddContact(CONTACT *user, bool InList, bool SetOnline) { if (user->name == NULL) return 0; MCONTACT hContact = CList_FindContact(user); if (hContact) { if (InList) db_unset(hContact, "CList", "NotOnList"); setTString(hContact, "Nick", user->name); db_unset(hContact, "CList", "Hidden"); if (SetOnline && getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) setWord(hContact, "Status", ID_STATUS_ONLINE); return hContact; } // here we create a new one since no one is to be found hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); if (hContact) { CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName); if (InList) db_unset(hContact, "CList", "NotOnList"); else db_set_b(hContact, "CList", "NotOnList", 1); db_unset(hContact, "CList", "Hidden"); setTString(hContact, "Nick", user->name); setTString(hContact, "Default", user->name); setWord(hContact, "Status", SetOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE); if (!InList && getByte("MirVerAutoRequestTemp", 0)) PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), user->name); return hContact; } return false; }
bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo) { DBVARIANT dbv; DisconnectAllDCCSessions(false); for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (isChatRoom(hContact)) continue; if (getByte(hContact, "DCC", 0) != 0) { if (ChatsToo) setWord(hContact, "Status", ID_STATUS_OFFLINE); } else if (!getTString(hContact, "Default", &dbv)) { setTString(hContact, "Nick", dbv.ptszVal); setWord(hContact, "Status", ID_STATUS_OFFLINE); db_free(&dbv); } db_unset(hContact, m_szModuleName, "IP"); setString(hContact, "User", ""); setString(hContact, "Host", ""); } return true; }
void CVkProto::PollUpdates(JSONNODE *pUpdates) { debugLogA("CVkProto::PollUpdates"); CMStringA mids; int msgid, uid, flags; MCONTACT hContact; JSONNODE *pChild; for (int i = 0; (pChild = json_at(pUpdates, i)) != NULL; i++) { switch (json_as_int(json_at(pChild, 0))) { case VKPOLL_MSG_ADDED: // new message msgid = json_as_int(json_at(pChild, 1)); // skip outgoing messages sent from a client flags = json_as_int(json_at(pChild, 2)); if ((flags & VKFLAG_MSGOUTBOX) && !(flags & VKFLAG_MSGCHAT)) if (CheckMid(msgid)) break; if (!mids.IsEmpty()) mids.AppendChar(','); mids.AppendFormat("%d", msgid); break; case VKPOLL_USR_ONLINE: uid = -json_as_int(json_at(pChild, 1)); if ((hContact = FindUser(uid)) != NULL) setWord(hContact, "Status", ID_STATUS_ONLINE); break; case VKPOLL_USR_OFFLINE: uid = -json_as_int(json_at(pChild, 1)); if ((hContact = FindUser(uid)) != NULL) setWord(hContact, "Status", ID_STATUS_OFFLINE); break; case VKPOLL_USR_UTN: uid = json_as_int(json_at(pChild, 1)); if ((hContact = FindUser(uid)) != NULL) CallService(MS_PROTO_CONTACTISTYPING, hContact, 5); break; case VKPOLL_CHAT_CHANGED: int chat_id = json_as_int(json_at(pChild, 1)); CVkChatInfo *cc = m_chats.find((CVkChatInfo*)&chat_id); if (cc) RetrieveChatInfo(cc); break; } } RetrieveMessagesByIds(mids); }
void Player::changeHp(int hp){ auto fw = FlowWord::create(); this->addChild(fw, 2); std::string s = hp > 0 ? "+" : "" + Value(hp).asString(); m_actionCounter->registAction(fw, fw->setWord(s, hp > 0 ? Color3B::GREEN : Color3B::RED, m_hpLabel->getPosition())); m_hp += hp; int x = m_hp; auto cf = CallFunc::create([&,x](){ m_hpLabel->setString(Value(x).asString()); }); m_actionCounter->registAction(this, cf); if (m_hp <= 0){ this->isDie = true; this->showDie(); } /*auto fw = FlowWord::create(); this->addChild(fw,2); bool flag = true; flag = hp > 0 ? true : false; auto s = flag?"+":"-" + Value(hp).asString(); fw->setWord(s, flag ? Color3B::GREEN : Color3B::RED, m_hpLabel->getPosition()); m_hp += hp; m_hpLabel->setString(Value(m_hp).asString()); return m_hp <= 0;*/ }
MCONTACT TwitterProto::AddToClientList(const char *name, const char *status) { // First, check if this contact exists MCONTACT hContact = UsernameToHContact(name); if (hContact) return hContact; if (in_chat_) AddChatContact(name); // If not, make a new contact! hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); if (hContact) { if (Proto_AddToContact(hContact, m_szModuleName) == 0) { setString(hContact, TWITTER_KEY_UN, name); setWord(hContact, "Status", ID_STATUS_ONLINE); db_set_utf(hContact, "CList", "StatusMsg", status); std::string url = profile_base_url(twit_.get_base_url()) + http::url_encode(name); setString(hContact, "Homepage", url.c_str()); DBVARIANT dbv; if (!getTString(TWITTER_KEY_GROUP, &dbv)) { db_set_ts(hContact, "CList", "Group", dbv.ptszVal); db_free(&dbv); } return hContact; } CallService(MS_DB_CONTACT_DELETE, hContact, 0); } return 0; }
MCONTACT CToxProto::AddChatRoom(int groupNumber) { MCONTACT hContact = GetChatRoom(groupNumber); if (!hContact) { hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); Proto_AddToContact(hContact, m_szModuleName); setWord(hContact, TOX_SETTINGS_CHAT_ID, groupNumber); TCHAR title[MAX_PATH]; mir_sntprintf(title, _T("%s #%d"), TranslateT("Group chat"), groupNumber); setTString(hContact, "Nick", title); DBVARIANT dbv; if (!db_get_s(NULL, "Chat", "AddToGroup", &dbv, DBVT_TCHAR)) { db_set_ts(hContact, "CList", "Group", dbv.ptszVal); db_free(&dbv); } setByte(hContact, "ChatRoom", 1); } return hContact; }
void CVkProto::AddFeedSpecialUser() { bool bSpecialContact = m_bNewsEnabled || m_bNotificationsEnabled || m_bSpecialContactAlwaysEnabled; MCONTACT hContact = FindUser(VK_FEED_USER); if (!bSpecialContact) { if (hContact) CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact); return; } if (!hContact) { hContact = FindUser(VK_FEED_USER, true); setTString(hContact, "Nick", TranslateT("VKontakte")); CMString tszUrl = _T("https://vk.com/press/Simple.png"); SetAvatarUrl(hContact, tszUrl); ReloadAvatarInfo(hContact); setTString(hContact, "domain", _T("feed")); setTString(hContact, "Homepage", _T("https://vk.com/feed")); } if (getWord(hContact, "Status") != ID_STATUS_ONLINE) setWord(hContact, "Status", ID_STATUS_ONLINE); SetMirVer(hContact, 7); }
bool_t MemRec::setCacheWord(word_t pos, word_t val){ if(bus && bus->isShared(pos)){ int j; for(j=0;j<bus->shared_count;++j){ if(bus->mem_map[j]==this) break; } if(bus->recs[j][pos/bus->cB] & REC_WRITE){ return ca->setByte(pos,val); }else{ bus->signal_update(pos/bus->cB,j); ca->setWord(pos,val); bus->recs[j][pos/bus->cB] = REC_WRITE|REC_READ; return TRUE; } }else{ printf("set cache word, 0x%x\n",ca); if(ca){ return ca->setWord(pos,val); }else{ return setWord(pos,val); } } }
bool_t MemRec::swapCacheWord(word_t pos, word_t *dest){ if(bus && bus->isShared(pos)){ int j; for(j=0;j<bus->shared_count;++j){ if(bus->mem_map[j]==this) break; } if(bus->recs[j][pos/bus->cB] & REC_WRITE){ word_t val = *dest; return ca->getWord(pos,dest) && ca->setByte(pos,val); }else{ bus->signal_update(pos/bus->cB,j); int val; ca->getWord(pos,dest); ca->setWord(pos,val); bus->recs[j][pos/bus->cB] = REC_WRITE|REC_READ; return TRUE; } }else if(ca){ word_t val = *dest; return ca->getWord(pos,dest) && ca->setWord(pos,val); }else{ word_t val = *dest; return getWord(pos, dest) && setWord(pos, val); } }
bool VDeregs::chooseWords() { if (! m_opt_multiMode) { COUT<<" Enter each word of structure in hex. Empty line or q when done.\n"; COUT<<" Multiple words may be separated by spaces. Anything in [] are ignored.\n"; } for (unsigned w=0; w<MAX_WORDS; w++) m_w[w] = 0; m_words=0; while (1) { stringstream ss; if (! m_opt_multiMode) { ss <<" "<<m_structName <<".w"<<dec<<setw(2)<<setfill('0')<<m_words <<" [LAST]: "; } string in = getLine(ss.str().c_str()); uint32_t datum; if (in=="") { if (m_words==0) return false; // No data, take it as a "q" else break; } else { while (gotHex(in, datum)) { setWord(m_words, datum); m_words++; if (m_words == m_structWords) break; } while (in!="" && isspace(in[0])) in.erase(0,1); if (in != "") { COUT<<" What's \""<<in<<"\"?"<<endl; } } } return true; }
void CSItemsList::saveItems(char *protoName) { unsigned int i; char dbSetting[32]; mir_snprintf(dbSetting, "%s_ItemsCount", protoName); unsigned int oldItemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT); for (i = 1; i <= m_list->getCount(); i++) { StatusItem* item = m_list->get(i - 1); mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i); setByte(dbSetting, item->m_iIcon); mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i); setWString(dbSetting, item->m_tszTitle); mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i); setWString(dbSetting, item->m_tszMessage); mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i); setByte(dbSetting, item->m_bFavourite); } mir_snprintf(dbSetting, "%s_ItemsCount", protoName); setWord(dbSetting, m_list->getCount()); for (; i <= oldItemsCount; i++) { mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i); deleteSetting(dbSetting); mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i); deleteSetting(dbSetting); mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i); deleteSetting(dbSetting); mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i); deleteSetting(dbSetting); } }
void AVIFileSink::completeOutputFile() { if (fHaveCompletedOutputFile || fOutFid == NULL) return; // Update various AVI 'size' fields to take account of the codec data that // we've now written to the file: unsigned maxBytesPerSecond = 0; unsigned numVideoFrames = 0; unsigned numAudioFrames = 0; //// Subsession-specific fields: MediaSubsessionIterator iter(fInputSession); MediaSubsession* subsession; while ((subsession = iter.next()) != NULL) { AVISubsessionIOState* ioState = (AVISubsessionIOState*)(subsession->miscPtr); if (ioState == NULL) continue; maxBytesPerSecond += ioState->fMaxBytesPerSecond; setWord(ioState->fSTRHFrameCountPosition, ioState->fNumFrames); if (ioState->fIsVideo) numVideoFrames = ioState->fNumFrames; else if (ioState->fIsAudio) numAudioFrames = ioState->fNumFrames; } //// Global fields: add4ByteString("idx1"); addWord(fNumIndexRecords*4*4); // the size of all of the index records, which come next: for (AVIIndexRecord* indexRecord = fIndexRecordsHead; indexRecord != NULL; indexRecord = indexRecord->next()) { addWord(indexRecord->chunkId()); addWord(indexRecord->flags()); addWord(indexRecord->offset()); addWord(indexRecord->size()); } fRIFFSizeValue += fNumBytesWritten; setWord(fRIFFSizePosition, fRIFFSizeValue); setWord(fAVIHMaxBytesPerSecondPosition, maxBytesPerSecond); setWord(fAVIHFrameCountPosition, numVideoFrames > 0 ? numVideoFrames : numAudioFrames); fMoviSizeValue += fNumBytesWritten; setWord(fMoviSizePosition, fMoviSizeValue); // We're done: fHaveCompletedOutputFile = True; }
void TwitterProto::SetAllContactStatuses(int status) { for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) if (!getByte(hContact, "ChatRoom")) setWord(hContact, "Status", (WORD)status); SetChatStatus(status); }
/* DEP switch Transfer contents of SWITCH register to the memory location at address ADDRESS if odd address, use next even */ void dep_switch() { if(addrreg % 2 != 0) { addrreg--; } setWord(addrreg, switchreg); addrreg += 2; datareg = switchreg; updateregsdisplay(); }
int WhatsAppProto::onGroupChatEvent(WPARAM wParam, LPARAM lParam) { GCHOOK *gch = (GCHOOK*)lParam; if (mir_strcmp(gch->pDest->pszModule, m_szModuleName)) return 0; std::string chat_id(T2Utf(gch->pDest->ptszID)); WAChatInfo *pInfo = SafeGetChat(chat_id); if (pInfo == NULL) return 0; switch (gch->pDest->iType) { case GC_USER_LOGMENU: ChatLogMenuHook(pInfo, gch); break; case GC_USER_NICKLISTMENU: NickListMenuHook(pInfo, gch); break; case GC_USER_MESSAGE: if (isOnline()) { std::string msg(T2Utf(gch->ptszText)); try { int msgId = GetSerial(); time_t now = time(NULL); std::string id = Utilities::intToStr(now) + "-" + Utilities::intToStr(msgId); FMessage fmsg(chat_id, true, id); fmsg.timestamp = now; fmsg.data = msg; m_pConnection->sendMessage(&fmsg); pInfo->m_unsentMsgs[id] = gch->ptszText; } CODE_BLOCK_CATCH_ALL } break; case GC_USER_PRIVMESS: string jid = string(_T2A(gch->ptszUID)) + "@s.whatsapp.net"; MCONTACT hContact = ContactIDToHContact(jid); if (hContact == 0) { hContact = AddToContactList(jid, (char*)_T2A(gch->ptszUID)); setWord(hContact, "Status", ID_STATUS_ONLINE); db_set_b(hContact, "CList", "Hidden", 1); setTString(hContact, "Nick", gch->ptszUID); db_set_dw(hContact, "Ignore", "Mask1", 0); } CallService(MS_MSG_SENDMESSAGE, hContact, 0); break; } return 0; }
void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveUserInfo %d", reply->resultCode); if (reply->resultCode != 200) return; JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse == NULL) return; for (size_t i=0; ; i++) { JSONNODE *pRecord = json_at(pResponse, i); if (pRecord == NULL) break; LONG userid = json_as_int( json_get(pRecord, "uid")); if (userid == 0) return; MCONTACT hContact; if (userid == m_myUserId) hContact = NULL; else if ((hContact = FindUser(userid, false)) == NULL) return; CMString tszNick; ptrT szValue( json_as_string( json_get(pRecord, "first_name"))); if (szValue) { setTString(hContact, "FirstName", szValue); tszNick.Append(szValue); tszNick.AppendChar(' '); } if (szValue = json_as_string( json_get(pRecord, "last_name"))) { setTString(hContact, "LastName", szValue); tszNick.Append(szValue); } if (!tszNick.IsEmpty()) setTString(hContact, "Nick", tszNick); setByte(hContact, "Gender", json_as_int( json_get(pRecord, "sex")) == 2 ? 'M' : 'F'); if (szValue = json_as_string( json_get(pRecord, "bdate"))) { int d, m, y; if ( _stscanf(szValue, _T("%d.%d.%d"), &d, &m, &y) == 3) { setByte(hContact, "BirthDay", d); setByte(hContact, "BirthMonth", m); setWord(hContact, "BirthYear", y); } } szValue = json_as_string( json_get(pRecord, "photo_medium")); SetAvatarUrl(hContact, szValue); } }
int __cdecl CYahooProto::SetApparentMode(MCONTACT hContact, int mode) { if (mode && mode != ID_STATUS_OFFLINE) return 1; int oldMode = getWord(hContact, "ApparentMode", 0); if (mode != oldMode) setWord(hContact, "ApparentMode", mode); return 1; }
void CSkypeProto::SetContactStatus(MCONTACT hContact, WORD status) { WORD oldStatus = GetContactStatus(hContact); if (oldStatus != status) { setWord(hContact, "Status", status); if (status == ID_STATUS_OFFLINE) db_unset(hContact, m_szModuleName, "MirVer"); } }
void RegRec::setVal(int id, word_t val){ if (id < REG_NONE) { setWord(id*4,val); if(reporter){ (*(void_func_dint)reporter)(id,val); } } }
int __cdecl CMsnProto::SetApparentMode(HANDLE hContact, int mode) { if (mode && mode != ID_STATUS_OFFLINE) return 1; WORD oldMode = getWord(hContact, "ApparentMode", 0); if (mode != oldMode) setWord(hContact, "ApparentMode", (WORD)mode); return 1; }
INT_PTR CJabberProto::OnMenuSetPriority(WPARAM, LPARAM, LPARAM dwDelta) { int iDelta = (int)dwDelta; int priority = getWord("Priority", 0) + iDelta; if (priority > 127) priority = 127; else if (priority < -128) priority = -128; setWord("Priority", priority); SendPresence(m_iStatus, true); return 0; }
void CJabberProto::SetContactOfflineStatus(MCONTACT hContact) { if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) setWord(hContact, "Status", ID_STATUS_OFFLINE); delSetting(hContact, DBSETTING_XSTATUSID); delSetting(hContact, DBSETTING_XSTATUSNAME); delSetting(hContact, DBSETTING_XSTATUSMSG); delSetting(hContact, DBSETTING_DISPLAY_UID); ResetAdvStatus(hContact, ADVSTATUS_MOOD); ResetAdvStatus(hContact, ADVSTATUS_TUNE); }
void CYahooProto::logoff_buddies() { //set all contacts to 'offline' for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { setWord(hContact, "Status", ID_STATUS_OFFLINE); setDword(hContact, "IdleTS", 0); setDword(hContact, "PictLastCheck", 0); setDword(hContact, "PictLoading", 0); db_unset(hContact, "CList", "StatusMsg"); delSetting(hContact, "YMsg"); delSetting(hContact, "YGMsg"); } }
void AVIFileSink::completeOutputFile() { if (fHaveCompletedOutputFile || fOutFid == NULL) return; // Update various AVI 'size' fields to take account of the codec data that // we've now written to the file: unsigned maxBytesPerSecond = 0; unsigned numVideoFrames = 0; unsigned numAudioFrames = 0; //// Subsession-specific fields: MediaSubsessionIterator iter(fInputSession); MediaSubsession* subsession; while ((subsession = iter.next()) != NULL) { AVISubsessionIOState* ioState = (AVISubsessionIOState*)(subsession->miscPtr); if (ioState == NULL) continue; maxBytesPerSecond += ioState->fMaxBytesPerSecond; setWord(ioState->fSTRHFrameCountPosition, ioState->fNumFrames); if (ioState->fIsVideo) numVideoFrames = ioState->fNumFrames; else if (ioState->fIsAudio) numAudioFrames = ioState->fNumFrames; } //// Global fields: fRIFFSizeValue += fNumBytesWritten; setWord(fRIFFSizePosition, fRIFFSizeValue); setWord(fAVIHMaxBytesPerSecondPosition, maxBytesPerSecond); setWord(fAVIHFrameCountPosition, numVideoFrames > 0 ? numVideoFrames : numAudioFrames); fMoviSizeValue += fNumBytesWritten; setWord(fMoviSizePosition, fMoviSizeValue); // We're done: fHaveCompletedOutputFile = True; }
INT_PTR CMsnProto::MsnBlockCommand(WPARAM hContact, LPARAM) { if (msnLoggedIn) { char tEmail[MSN_MAX_EMAIL_LEN]; if (db_get_static(hContact, m_szModuleName, "wlid", tEmail, sizeof(tEmail))) db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail)); if (Lists_IsInList(LIST_BL, tEmail)) delSetting(hContact, "ApparentMode"); else setWord(hContact, "ApparentMode", ID_STATUS_OFFLINE); } return 0; }
//center the roundels horizontally on screen (no need to specify x position) void Roundels::setWordCenterHoriz(std::string wrd, Image &letters, int y, //no x if centered horiz int gap) { int newX, newY; //calc new start position of first roundel based on centered length of all roundels in the word newX = ( Screen::width() - (((letters.tileW()+gap)*wrd.length())-gap) ) /2; newY = y; //pass new pos to the real setWord function setWord(wrd, letters, newX, newY, gap, true); }
//center the roundels vertically on screen (no need to specify y position) void Roundels::setWordCenterVert(std::string wrd, Image &letters, int x, //no y if centered vert int gap) { int newX, newY; //calc new start position of first roundel based on centered length of all roundels in the word newX = x; newY = ( Screen::height() - (((letters.tileH()+gap)*wrd.length())-gap) ) /2; //pass new pos to the real setWord function setWord(wrd, letters, newX, newY, gap, false); }
INT_PTR CMsnProto::MsnBlockCommand(WPARAM wParam, LPARAM) { if (msnLoggedIn) { const HANDLE hContact = (HANDLE)wParam; char tEmail[MSN_MAX_EMAIL_LEN]; getStaticString(hContact, "e-mail", tEmail, sizeof(tEmail)); if (Lists_IsInList(LIST_BL, tEmail)) deleteSetting(hContact, "ApparentMode"); else setWord(hContact, "ApparentMode", ID_STATUS_OFFLINE); } return 0; }
HANDLE CIrcProto::CList_SetOffline(struct CONTACT * user) { DBVARIANT dbv; HANDLE hContact = CList_FindContact(user); if ( hContact ) { if ( !getTString( hContact, "Default", &dbv )) { setString(hContact, "User", ""); setString(hContact, "Host", ""); setTString(hContact, "Nick", dbv.ptszVal); setWord(hContact, "Status", ID_STATUS_OFFLINE); db_free(&dbv); return hContact; } } return 0; }