skeleton::skeleton(std::istream & stream_, const uint32_t lod_count) : size(0) { READ_STRING(name); if (name.length() > 1) { READ_BOOL(inherited); stream_.read((char *)&size, sizeof(uint32_t)); for (int x = 0; x < size; x++) { std::string _name, _parent; READ_STRING(_name); READ_STRING(_parent); all_bones.push_back(std::make_shared<bone>(_name, _parent)); } for (auto& tbone : all_bones) { for (auto& child : all_bones) { if (child->parent == tbone->name) { tbone->children.push_back(child->name); } } if (tbone->parent.length() < 1) { root_bones[tbone->name] = tbone; } } // Skip a byte because! //stream_.seekg(1, stream_.cur); LOG(DEBUG) << "Skeleton loaded: " << name; char junk; stream_.read((char *)&junk, sizeof(uint8_t)); } }
static int load_debuginfo(struct load_state *S, ktap_proto *f) { int i,n; f->source = READ_STRING(S); n = READ_INT(S); f->sizelineinfo = n; f->lineinfo = NEW_VECTOR(S, n * sizeof(int)); READ_VECTOR(S, f->lineinfo, n * sizeof(int)); n = READ_INT(S); f->locvars = NEW_VECTOR(S, n * sizeof(struct ktap_locvar)); f->sizelocvars = n; for (i = 0; i < n; i++) f->locvars[i].varname = NULL; for (i = 0; i < n; i++) { f->locvars[i].varname = READ_STRING(S); f->locvars[i].startpc = READ_INT(S); f->locvars[i].endpc = READ_INT(S); } n = READ_INT(S); for (i = 0; i < n; i++) f->upvalues[i].name = READ_STRING(S); return 0; }
// Message handler for ShowMenu message // takes four values: // short: a bitfield of keys that are valid input // char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen. // byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string // string: menu string to display // if this message is never received, then scores will simply be the combined totals of the players. int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) { char *temp = NULL; BEGIN_READ( pszName, pbuf, iSize ); m_bitsValidSlots = READ_SHORT(); int DisplayTime = READ_CHAR(); int NeedMore = READ_BYTE(); if( DisplayTime > 0 ) m_flShutoffTime = DisplayTime + gHUD.m_flTime; else m_flShutoffTime = -1; if( m_bitsValidSlots ) { if( !m_fWaitingForMore ) { // this is the start of a new menu Q_strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING ); } else { // append to the current menu string Q_strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - Q_strlen( g_szPrelocalisedMenuString )); } g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not) if( !NeedMore ) { // we have the whole string, so we can localise it now Q_strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString )); // Swap in characters if( KB_ConvertString( g_szMenuString, &temp )) { Q_strcpy( g_szMenuString, temp ); free( temp ); } } m_fMenuDisplayed = 1; m_iFlags |= HUD_ACTIVE; } else { m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off m_iFlags &= ~HUD_ACTIVE; } m_fWaitingForMore = NeedMore; END_READ(); return 1; }
bool CGuideHintTable::SetTableData(void* pvTable, WCHAR* pwszSheetName, std::wstring* pstrDataName, BSTR bstrData) { if (0 == wcscmp(pwszSheetName, L"Table_Data_KOR")) { sGUIDE_HINT_TBLDAT* pGuide = (sGUIDE_HINT_TBLDAT*)pvTable; if (0 == wcscmp(pstrDataName->c_str(), L"Tblidx")) { pGuide->tblidx = READ_DWORD( bstrData ); } else if (0 == wcscmp(pstrDataName->c_str(), L"Type")) { pGuide->byType = READ_BYTE( bstrData, pstrDataName->c_str() ); } else if (0 == wcscmp(pstrDataName->c_str(), L"WidthPosition")) { pGuide->byWidthPosition = READ_BYTE( bstrData, pstrDataName->c_str() ); } else if (0 == wcscmp(pstrDataName->c_str(), L"HeightPosition")) { pGuide->byHeightPosition = READ_BYTE( bstrData, pstrDataName->c_str() ); } else if (0 == wcscmp(pstrDataName->c_str(), L"WidthSize")) { pGuide->wWidthSize = READ_WORD( bstrData, pstrDataName->c_str() ); } else if (0 == wcscmp(pstrDataName->c_str(), L"HeightSize")) { pGuide->wHeightSize = READ_WORD( bstrData, pstrDataName->c_str() ); } else if (0 == wcscmp(pstrDataName->c_str(), L"Resource")) { READ_STRING(bstrData, pGuide->szResource, _countof(pGuide->szResource)); } else if (0 == wcscmp(pstrDataName->c_str(), L"Note")) { READ_STRING(bstrData, pGuide->szNote, _countof(pGuide->szNote)); } else if (0 == wcscmp(pstrDataName->c_str(), L"Auto_Show")) { pGuide->bAutoShow = READ_BOOL( bstrData, pstrDataName->c_str() ); } else { CTable::CallErrorCallbackFunction(L"[File] : %s\n[Error] : Unknown field name found!(Field Name = %s)", m_wszXmlFileName, pstrDataName->c_str()); return false; } } else { return false; } return true; }
// Message handler for text messages // displays a string, looking them up from the titles.txt file, which can be localised // parameters: // byte: message direction ( HUD_PRINTCONSOLE, HUD_PRINTNOTIFY, HUD_PRINTCENTER, HUD_PRINTTALK ) // string: message // optional parameters: // string: message parameter 1 // string: message parameter 2 // string: message parameter 3 // string: message parameter 4 // any string that starts with the character '#' is a message name, and is used to look up the real message in titles.txt // the next (optional) one to four strings are parameters for that string (which can also be message names if they begin with '#') int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int msg_dest = READ_BYTE(); #define MSG_BUF_SIZE 128 static char szBuf[6][MSG_BUF_SIZE]; char *msg_text = LookupString( READ_STRING(), &msg_dest ); msg_text = safe_strcpy( szBuf[0], msg_text , MSG_BUF_SIZE); // keep reading strings and using C format strings for subsituting the strings into the localised text string char *sstr1 = LookupString( READ_STRING() ); sstr1 = safe_strcpy( szBuf[1], sstr1 , MSG_BUF_SIZE); StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines char *sstr2 = LookupString( READ_STRING() ); sstr2 = safe_strcpy( szBuf[2], sstr2 , MSG_BUF_SIZE); StripEndNewlineFromString( sstr2 ); char *sstr3 = LookupString( READ_STRING() ); sstr3 = safe_strcpy( szBuf[3], sstr3 , MSG_BUF_SIZE); StripEndNewlineFromString( sstr3 ); char *sstr4 = LookupString( READ_STRING() ); sstr4 = safe_strcpy( szBuf[4], sstr4 , MSG_BUF_SIZE); StripEndNewlineFromString( sstr4 ); char *psz = szBuf[5]; if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE ) return 1; switch ( msg_dest ) { case HUD_PRINTCENTER: safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 ); CenterPrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer safe_sprintf( psz+1, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 ); ConsolePrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTTALK: safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 ); gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 ); break; case HUD_PRINTCONSOLE: safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 ); ConsolePrint( ConvertCRtoNL( psz ) ); break; } return 1; }
ext_entry::ext_entry(std::istream &stream_) { std::string key, val; READ_STRING(key); while (key != "") { READ_STRING(val); header[key] = val; READ_STRING(key); } }
static AnimNode::Pointer loadPoleVectorConstraintNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { READ_VEC3(referenceVector, jsonObj, id, jsonUrl, nullptr); READ_BOOL(enabled, jsonObj, id, jsonUrl, nullptr); READ_STRING(baseJointName, jsonObj, id, jsonUrl, nullptr); READ_STRING(midJointName, jsonObj, id, jsonUrl, nullptr); READ_STRING(tipJointName, jsonObj, id, jsonUrl, nullptr); READ_STRING(enabledVar, jsonObj, id, jsonUrl, nullptr); READ_STRING(poleVectorVar, jsonObj, id, jsonUrl, nullptr); auto node = std::make_shared<AnimPoleVectorConstraint>(id, enabled, referenceVector, baseJointName, midJointName, tipJointName, enabledVar, poleVectorVar); return node; }
ext_entry::ext_entry(std::istream &stream_) { READ_STRING(name); READ_STRING(data); READ_STRING(version); std::string temp; temp = version; while (temp != "") { extras.push_back(temp); READ_STRING(temp); } }
static AnimNode::Pointer loadManipulatorNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { READ_FLOAT(alpha, jsonObj, id, jsonUrl, nullptr); auto node = std::make_shared<AnimManipulator>(id, alpha); READ_OPTIONAL_STRING(alphaVar, jsonObj); if (!alphaVar.isEmpty()) { node->setAlphaVar(alphaVar); } auto jointsValue = jsonObj.value("joints"); if (!jointsValue.isArray()) { qCCritical(animation) << "AnimNodeLoader, bad array \"joints\" in controller node, id =" << id; return nullptr; } auto jointsArray = jointsValue.toArray(); for (const auto& jointValue : jointsArray) { if (!jointValue.isObject()) { qCCritical(animation) << "AnimNodeLoader, bad state object in \"joints\", id =" << id; return nullptr; } auto jointObj = jointValue.toObject(); READ_STRING(jointName, jointObj, id, jsonUrl, nullptr); READ_STRING(rotationType, jointObj, id, jsonUrl, nullptr); READ_STRING(translationType, jointObj, id, jsonUrl, nullptr); READ_STRING(rotationVar, jointObj, id, jsonUrl, nullptr); READ_STRING(translationVar, jointObj, id, jsonUrl, nullptr); AnimManipulator::JointVar::Type jointVarRotationType = stringToAnimManipulatorJointVarType(rotationType); if (jointVarRotationType == AnimManipulator::JointVar::Type::NumTypes) { qCWarning(animation) << "AnimNodeLoader, bad rotationType in \"joints\", id =" << id; jointVarRotationType = AnimManipulator::JointVar::Type::Default; } AnimManipulator::JointVar::Type jointVarTranslationType = stringToAnimManipulatorJointVarType(translationType); if (jointVarTranslationType == AnimManipulator::JointVar::Type::NumTypes) { qCWarning(animation) << "AnimNodeLoader, bad translationType in \"joints\", id =" << id; jointVarTranslationType = AnimManipulator::JointVar::Type::Default; } AnimManipulator::JointVar jointVar(jointName, jointVarRotationType, jointVarTranslationType, rotationVar, translationVar); node->addJointVar(jointVar); }; return node; }
static AnimNode::Pointer loadOverlayNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { READ_STRING(boneSet, jsonObj, id, jsonUrl, nullptr); READ_FLOAT(alpha, jsonObj, id, jsonUrl, nullptr); auto boneSetEnum = stringToBoneSetEnum(boneSet); if (boneSetEnum == AnimOverlay::NumBoneSets) { qCCritical(animation) << "AnimNodeLoader, unknown bone set =" << boneSet << ", defaulting to \"fullBody\""; boneSetEnum = AnimOverlay::FullBodyBoneSet; } READ_OPTIONAL_STRING(boneSetVar, jsonObj); READ_OPTIONAL_STRING(alphaVar, jsonObj); auto node = std::make_shared<AnimOverlay>(id, boneSetEnum, alpha); if (!boneSetVar.isEmpty()) { node->setBoneSetVar(boneSetVar); } if (!alphaVar.isEmpty()) { node->setAlphaVar(alphaVar); } return node; }
int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) { if( m_iFlags & HUD_ACTIVE ) { Reset(); // clear the current MOTD in prep for this one } BEGIN_READ( pszName, pbuf, iSize ); int is_finished = READ_BYTE(); Q_strcat( m_szMOTD, READ_STRING( )); if( is_finished ) { m_iFlags |= HUD_ACTIVE; MOTD_DISPLAY_TIME = CVAR_GET_FLOAT( "motd_display_time" ); m_flActiveTill = gHUD.m_flTime + MOTD_DISPLAY_TIME; // count the number of lines in the MOTD for( char *sz = m_szMOTD; *sz != 0; sz++ ) if( *sz == '\n' ) m_iLines++; } END_READ(); return 1; }
// // WeaponList -- Tells the hud about a new weapon type. // int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf) { BEGIN_READ(pbuf, iSize); WEAPON Weapon; strcpy(Weapon.szName, READ_STRING()); Weapon.iAmmoType = (int)READ_CHAR(); Weapon.iMax1 = READ_BYTE(); if(Weapon.iMax1 == 255) Weapon.iMax1 = -1; Weapon.iAmmo2Type = READ_CHAR(); Weapon.iMax2 = READ_BYTE(); if(Weapon.iMax2 == 255) Weapon.iMax2 = -1; Weapon.iSlot = READ_CHAR(); Weapon.iSlotPos = READ_CHAR(); Weapon.iId = READ_CHAR(); Weapon.iFlags = READ_BYTE(); Weapon.iClip = 0; gWR.AddWeapon(&Weapon); return 1; }
// Message handler for Secondary Ammo Value // accepts one value: // string: sprite name int CHudAmmoSecondary::MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() ); return 1; }
/* ==================== MsgCreateSystem ==================== */ int CParticleEngine::MsgCreateSystem( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ(pbuf, iSize); vec3_t pos; pos.x = READ_COORD(); pos.y = READ_COORD(); pos.z = READ_COORD(); vec3_t ang; ang.x = READ_COORD(); ang.y = READ_COORD(); ang.z = READ_COORD(); int iType = READ_BYTE(); char *szPath = READ_STRING(); int iId = READ_SHORT(); if(iType == 2) RemoveSystem(iId); else if(iType == 1) CreateCluster(szPath, pos, ang, iId); else CreateSystem(szPath, pos, ang, iId); return 1; }
int CHud :: MsgFunc_PlayMP3( const char *pszName, int iSize, void *pbuf ) //AJH -Killar MP3 { BEGIN_READ( pbuf, iSize ); gMP3.PlayMP3( READ_STRING() ); return 1; }
stage_texture::stage_texture(std::istream &stream_, uint32_t type_) { stream_.read((char *)&filter, sizeof(uint32_t)); READ_STRING(file); stream_.read((char *)&transform_id, sizeof(uint32_t)); if (type_ == 11) { READ_BOOL(wtf); } }
int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int client_index = READ_BYTE(); // the client who spoke the message SayTextPrint( READ_STRING(), iSize - 1, client_index ); return 1; }
int __MsgFunc_SpikeCheck(const char* name, int size, void* buf) { BEGIN_READ(buf, size); const auto model = READ_STRING(); // Stub: no cheat checks in OpenAG. return 1; }
int __MsgFunc_WhString(const char* name, int size, void* buf) { BEGIN_READ(buf, size); const auto string = READ_STRING(); // Stub: no cheat checks in OpenAG. return 1; }
int CHudAmmo::MsgFunc_ItemPickup(const char *pszName, int iSize, void *pbuf) { BEGIN_READ(pbuf, iSize); const char *szName = READ_STRING(); // Add the weapon to the history gHR.AddToHistory(HISTSLOT_ITEM, szName); return 1; }
entry::entry(std::istream &stream_) { READ_STRING(filename); std::transform(filename.begin(), filename.end(), filename.begin(), ::tolower); stream_.read((char *)&compression, sizeof(uint32_t)); stream_.read((char *)&size, sizeof(uint32_t)); stream_.read((char *)&reserved, sizeof(uint32_t)); stream_.read((char *)×tamp, sizeof(uint32_t)); stream_.read((char *)&storage_size, sizeof(uint32_t)); }
int __MsgFunc_CRC32(const char* name, int size, void* buf) { BEGIN_READ(buf, size); const auto checksum = READ_LONG(); const auto filename = READ_STRING(); // Stub: no cheat checks in OpenAG. return 1; }
int CHud::MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf ) { char m_szServerName[32]; BEGIN_READ( pszName, iSize, pbuf ); strncpy( m_szServerName, READ_STRING(), 32 ); END_READ(); return 1; }
material::material(std::istream &stream_, uint32_t version = 68) { uint32_t textures_count, transforms_count; READ_STRING(name); stream_.read((char *)&type, sizeof(uint32_t)); stream_.read((char *)&emissive, sizeof(float) * 4); stream_.read((char *)&ambient, sizeof(float) * 4); stream_.read((char *)&diffuse, sizeof(float) * 4); stream_.read((char *)&forced_diffuse, sizeof(float) * 4); stream_.read((char *)&specular, sizeof(float) * 4); stream_.read((char *)&specular_2, sizeof(float) * 4); stream_.read((char *)&specular_power, sizeof(float)); stream_.read((char *)&pixel_shader, sizeof(uint32_t)); stream_.read((char *)&vertex_shader, sizeof(uint32_t)); stream_.read((char *)&u_long_1, sizeof(uint32_t)); stream_.read((char *)&an_index, sizeof(uint32_t)); stream_.read((char *)&u_long_2, sizeof(uint32_t)); READ_STRING(surface); stream_.read((char *)&u_long_3, sizeof(uint32_t)); stream_.read((char *)&render_flags, sizeof(uint32_t)); stream_.read((char *)&textures_count, sizeof(uint32_t)); stream_.read((char *)&transforms_count, sizeof(uint32_t)); for (int x = 0; x < textures_count; x++) { texture_stages.push_back(std::make_shared<stage_texture>(stream_, type)); } for (int x = 0; x < textures_count; x++) { uint32_t uv_source; stream_.read((char *)&uv_source, sizeof(uint32_t)); transform_stages.push_back(std::pair<uint32_t, transform_matrix>(uv_source, transform_matrix(stream_))); } if (type >= 10) { texture_stages.push_back(std::make_shared<stage_texture>(stream_, type)); } }
int CHudMessage::MsgFunc_HudText2( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); char *pString = READ_STRING(); bool theIsAutoHelp = READ_BYTE(); gHUD.AddTooltip(pString, theIsAutoHelp); return 2; }
int CHudRadio::MsgFunc_SendAudio(const char *pszName, int iSize, void *pbuf) { BEGIN_READ( pbuf, iSize ); m_bFirst = READ_BYTE( ); strcpy( m_sentence, READ_STRING( )); m_sThird = READ_SHORT( ); m_enableRadio = true; return 1; }
proxy::proxy(std::istream &stream_, uint32_t version = 68) { READ_STRING(name); transform = ace::transform_matrix(stream_); stream_.read((char *)&sequence_id, sizeof(uint32_t)); stream_.read((char *)&named_selection_id, sizeof(uint32_t)); stream_.read((char *)&bone_id, sizeof(uint32_t)); stream_.read((char *)§ion_id, sizeof(uint32_t)); LOG(DEBUG) << "Proxy: [" << name << "]"; }
int pam_authc(nssov_info *ni,TFILE *fp,Operation *op) { int32_t tmpint32; int rc; slap_callback cb = {0}; char dnc[1024]; char uidc[32]; char svcc[256]; char pwdc[256]; struct berval sdn, dn; struct paminfo pi; READ_STRING(fp,uidc); pi.uid.bv_val = uidc; pi.uid.bv_len = tmpint32; READ_STRING(fp,dnc); pi.dn.bv_val = dnc; pi.dn.bv_len = tmpint32; READ_STRING(fp,svcc); pi.svc.bv_val = svcc; pi.svc.bv_len = tmpint32; READ_STRING(fp,pwdc); pi.pwd.bv_val = pwdc; pi.pwd.bv_len = tmpint32; Debug(LDAP_DEBUG_TRACE,"nssov_pam_authc(%s)\n",pi.uid.bv_val,0,0); rc = pam_do_bind(ni, fp, op, &pi); finish: WRITE_INT32(fp,NSLCD_VERSION); WRITE_INT32(fp,NSLCD_ACTION_PAM_AUTHC); WRITE_INT32(fp,NSLCD_RESULT_BEGIN); WRITE_BERVAL(fp,&pi.uid); WRITE_BERVAL(fp,&pi.dn); WRITE_INT32(fp,rc); WRITE_INT32(fp,pi.authz); /* authz */ WRITE_BERVAL(fp,&pi.msg); /* authzmsg */ return 0; }
static int load_constants(struct load_state *S, ktap_proto *f) { int i,n; n = READ_INT(S); f->sizek = n; f->k = NEW_VECTOR(S, n * sizeof(ktap_value)); for (i = 0; i < n; i++) setnilvalue(&f->k[i]); for (i=0; i < n; i++) { ktap_value *o = &f->k[i]; int t = READ_CHAR(S); switch (t) { case KTAP_TNIL: setnilvalue(o); break; case KTAP_TBOOLEAN: setbvalue(o, READ_CHAR(S)); break; case KTAP_TNUMBER: /* * todo: kernel not support fp, check double when * loading */ setnvalue(o, READ_NUMBER(S)); break; case KTAP_TSTRING: setsvalue(o, READ_STRING(S)); break; default: kp_error(S->ks, "ktap: load_constants: " "unknow ktap_value\n"); return -1; } } n = READ_INT(S); f->p = NEW_VECTOR(S, n * sizeof(ktap_proto)); f->sizep = n; for (i = 0; i < n; i++) f->p[i] = NULL; for (i = 0; i < n; i++) { f->p[i] = kp_newproto(S->ks); if (load_function(S, f->p[i])) return -1; } return 0; }
int CHud :: MsgFunc_Particle( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); int idx = READ_SHORT(); char *sz = READ_STRING(); CreateAurora( idx, sz ); END_READ(); return 1; }