func Hit(int oldx, int oldy) { if (IsJumping()) { if (GetContact(-1, CNAT_Right)) { SetXDir(-10); SetYDir(oldy, 100); AddEffect("CheckComDir", this, 1, 1, this); } else if (GetContact(-1, CNAT_Left)) { SetXDir(10); SetYDir(oldy, 100); AddEffect("CheckComDir", this, 1, 1, this); } else if (GetContact(-1, CNAT_Top) && (oldy < 0)) { SetXDir(oldx, 100); SetYDir(+5); } } return inherited(oldx, oldy, ...); }
func FxCheckComDirTimer(target, fx, time) { if (GetPlayerControlState(GetOwner(), CON_Left) && (GetComDir() != COMD_Left) && !GetContact(-1, CNAT_Left)) { SetComDir(COMD_Left); return -1; } if (GetPlayerControlState(GetOwner(), CON_Right) && (GetComDir() != COMD_Right) && !GetContact(-1, CNAT_Right)) { SetComDir(COMD_Right); return -1; } }
HANDLE AddToListByName(const CString& sName, WPARAM flags, LPCTSTR about, bool bInteractive, bool bGroup) { ip addr = INADDR_NONE; CString sShortName( sName ); if ( ! bGroup ) { // Попытка получить IP из имени if ( addr == INADDR_NONE ) addr = ResolveToIP( sShortName ); // Поиск NetBIOS-имени if ( addr == INADDR_NONE ) addr = pluginNetBIOS.FindNameIP( sName ); // Неизвестный контакт if ( addr == INADDR_NONE && bInteractive ) { if ( MessageBox( NULL, TranslateT("Cannot resolve contacts IP-address. Add it anyway?"), modname_t, MB_YESNO | MB_ICONQUESTION ) != IDYES ) { return NULL; } } } // Поиск существующего контакта HANDLE hContact = GetContact( sShortName ); if ( ! hContact ) { // Добавление контакта hContact = (HANDLE)CallService( MS_DB_CONTACT_ADD, 0, 0 ); if ( hContact ) { CallService( MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)modname ); SetNick( hContact, sShortName ); SetGroup( hContact, bGroup ); db_set_ts( hContact, "CList", "MyHandle", sShortName ); db_set_b( hContact, "CList", "NotOnList", 1 ); db_set_b( hContact, "CList", "Hidden", 1 ); SetContactIP( hContact, addr ); SetElapsed( hContact, "IPTime" ); if ( about ) db_set_ts( hContact, modname, "About", about ); contact_scanner::ScanContact( hContact ); } } if ( hContact && ! ( flags & PALF_TEMPORARY ) && db_get_b( hContact, "CList", "NotOnList", 1 ) ) { // Оставляем контакт db_unset( hContact, "CList", "NotOnList" ); db_unset( hContact, "CList", "Hidden" ); } return hContact; }
public func FxControlFloatTimer(object target, proplist effect, int time) { // Balloon deflates if any vertex has contact if (GetContact(-1, CNAT_Bottom)) { Deflate(); return FX_Execute_Kill; } return _inherited(target, effect, time, ...); }
std::string BBMBPS::getFullContact(bbmsp_contact_t *contact) { Json::FastWriter writer; Json::Value root; root["displayName"] = GetContact(contact, BBM_DISPLAY_NAME); root["status"] = GetContact(contact, BBM_STATUS); root["statusMessage"] = GetContact(contact, BBM_STATUS_MESSAGE); root["personalMessage"] = GetContact(contact, BBM_PERSONAL_MESSAGE); root["ppid"] = GetContact(contact, BBM_PPID); root["handle"] = GetContact(contact, BBM_HANDLE); root["appVersion"] = GetContact(contact, BBM_APP_VERSION); root["bbmsdkVersion"] = GetContact(contact, BBM_SDK_VERSION); return writer.write(root); }
static INT_PTR ServiceParseMsnimLink(WPARAM, LPARAM lParam) { if (lParam == 0) return 1; /* sanity check */ TCHAR *arg = (TCHAR*)lParam; /* skip leading prefix */ arg = _tcschr(arg, ':'); if (arg == NULL) return 1; /* parse failed */ for (++arg; *arg == '/'; ++arg) {} arg = NEWTSTR_ALLOCA(arg); if (g_Instances.getCount() == 0) return 0; CMsnProto *proto = &g_Instances[0]; for (int i = 0; i < g_Instances.getCount(); ++i) { if (g_Instances[i].m_iStatus > ID_STATUS_OFFLINE) { proto = &g_Instances[i]; break; } } if (proto == NULL) return 1; /* add a contact to the list */ if (_tcsnicmp(arg, _T("add?"), 4) == 0) { arg += 4; TCHAR *email; MCONTACT hContact = GetContact(arg, &email, proto); if (email == NULL) return 1; /* does not yet check if email is current user */ if (hContact == NULL) { PROTOSEARCHRESULT psr = { sizeof(psr) }; psr.flags = PSR_TCHAR; psr.nick.t = email; psr.email.t = email; ADDCONTACTSTRUCT acs = { 0 }; acs.handleType = HANDLE_SEARCHRESULT; acs.szProto = proto->m_szModuleName; acs.psr = &psr; CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); } return 0; } /* send a message to a contact */ /* "voice" and "video" not yet implemented, perform same action as "chat" */ else if (_tcsnicmp(arg, _T("chat?"), 5) == 0) { arg += 5; MCONTACT hContact = GetContact(arg, NULL, proto); if (hContact != NULL) { CallService(MS_MSG_SENDMESSAGE, hContact, 0); return 0; } } else if (_tcsnicmp(arg, _T("voice?"), 6) == 0) { arg += 6; MCONTACT hContact = GetContact(arg, NULL, proto); if (hContact != NULL) { CallService(MS_MSG_SENDMESSAGE, hContact, 0); return 0; } } else if (_tcsnicmp(arg, _T("video?"), 6) == 0) { arg += 6; MCONTACT hContact = GetContact(arg, NULL, proto); if (hContact != NULL) { CallService(MS_MSG_SENDMESSAGE, hContact, 0); return 0; } } return 1; /* parse failed */ }
void netbios_name::DatagramReceiver() { UCHAR* SMBBlock = (UCHAR*)mir_alloc( 65536 ); if ( ! SMBBlock ) { m_error = true; return; } m_error = false; while ( WaitForSingleObject ( m_term, 50 ) == WAIT_TIMEOUT ) { ZeroMemory( SMBBlock, 65536 ); WORD iReadedBytes = 65535; netbios_name nname_from; UCHAR ret = pluginNetBIOS.RecvDatagram( nname_from, *this, SMBBlock, iReadedBytes ); if ( ret != NRC_GOODRET ) { // Ошибка - выход m_error = true; break; } nname_from.m_lana = m_lana; LOG( "Got datagram from \"%s\" to \"%s\"", nname_from.GetANSIFullName(), GetANSIFullName() ); // Свое собственное сообщение? if ( IsItMe ( CA2T( nname_from.original ) ) ) { LOG( "DatagramReceiver : Ignoring my datagram" ); continue; } // Обработка датаграмм if ( iReadedBytes > 2 && *(WORD*)SMBBlock == SM_MAGIC ) { UCHAR iMsgType = SMBBlock[ 2 ]; switch ( iMsgType ) { case SM_GETSTATUS: // Отвечаем своим статусом LOG( "DatagramReceiver : It's status request" ); pluginNetBIOS.SendStatus( *this, nname_from ); break; case SM_SENDSTATUS: // Находим контакт и ставим его статус if ( iReadedBytes == 2 + 1 + 4 ) { HANDLE hContact = GetContact( CA2T( nname_from.original ) ); if ( hContact ) { LOG( "DatagramReceiver : It's status answer" ); SetContactStatus( hContact, *(__int32*)(SMBBlock + 2 + 1), false ); } else LOG( "DatagramReceiver : Unknown contact" ); } else LOG( "DatagramReceiver : Invalid format" ); break; case SM_GETAWAYMESSAGE: // Отвечаем своим эвей-сообщением LOG( "DatagramReceiver : It's away request" ); pluginNetBIOS.SendAway( *this, nname_from ); break; case SM_SENDAWAYMESSAGE: // Находим контакт и ставим его эвей-сообщение if ( iReadedBytes >= 2 + 1 + 4 ) { if ( HANDLE hContact = GetContact( CA2T( nname_from.original ) ) ) { LPCSTR szAway = (LPCSTR)( SMBBlock + 2 + 1 + 4 ); SMBBlock[ iReadedBytes ] = 0; // ASCII -> ASCIIZ LOG( "DatagramReceiver : It's away answer \"%s\"", szAway ); SetContactAway( hContact, szAway ); } else LOG( "DatagramReceiver : Unknown contact" ); } else LOG( "DatagramReceiver : Invalid format" ); break; case SM_GETAVATAR: // Отвечаем своим аватаром LOG( "DatagramReceiver : It's avatar request." ); pluginNetBIOS.SendAvatar( *this, nname_from ); break; case SM_SENDAVATAR: // Находим контакт и ставим его аватар if ( iReadedBytes >= 2 + 1 && iReadedBytes < MAX_AVATAR_SIZE + 3 ) { if ( HANDLE hContact = GetContact( CA2T( nname_from.original ) ) ) { LOG( "DatagramReceiver : It's avatar answer" ); SetContactAvatar( hContact, SMBBlock + 2 + 1, (DWORD)iReadedBytes - 3 ); } else LOG( "DatagramReceiver : Unknown contact" ); } else LOG( "DatagramReceiver : Invalid format or too big avatar" ); break; default: LOG( "DatagramReceiver : Unsupported message type 0x%02x", iMsgType ); } } else LOG( "DatagramReceiver : Unsupported data 0x%04x", *(WORD*)SMBBlock ); } mir_free( SMBBlock ); }