LTBOOL CFolderIntel::UpdateSelection() { LTBOOL bChanged = CBaseSelectionFolder::UpdateSelection(); if (bChanged) { CLTGUICtrl *pCtrl = GetControl(m_nLastListItem); if (!pCtrl) return LTFALSE; int nIndex = pCtrl->GetParam1(); if (!nIndex) return LTFALSE; IntelItem *pItem = m_intelArray[nIndex-1]; HSTRING hStr = g_pLTClient->FormatString(pItem->nID); m_pDescription->SetString(hStr); g_pLTClient->FreeString(hStr); CScaleFX* pScaleFX = g_pFXButeMgr->GetScaleFX(pItem->nType); SAFE_STRCPY(m_szModel, pScaleFX->szFile); SAFE_STRCPY(m_szSkin, pScaleFX->szSkin); m_vScale = pScaleFX->vInitialScale; m_bChromakey = pScaleFX->bChromakey; if (pScaleFX->fDirOffset > 0.0f) { LTFLOAT fScaleMult = (100.0f/pScaleFX->fDirOffset); VEC_MULSCALAR(m_vScale, m_vScale, fScaleMult); } CreateModelSFX(); } return bChanged; }
char* CommandName(int nCommand) { static char buffer[128]; uint32 nStringID = 0; for (int i=0; i < g_kNumCommands; i++) { if (g_CommandArray[i].nCommandID == nCommand) { nStringID = g_CommandArray[i].nActionStringID; break; } } if (nStringID) { HSTRING hStr = g_pLTClient->FormatString(nStringID); SAFE_STRCPY(buffer, g_pLTClient->GetStringData(hStr)); g_pLTClient->FreeString(hStr); } else { SAFE_STRCPY(buffer, "Error in CommandName()!"); } return buffer; }
HLOCALOBJ CGibFX::CreateGib(GibType eType) { // TODO: REIMPLEMENT GIB LOOKUP IN MODELBUTEMGR char* pFilename = LTNULL;//GetGibModel(m_eModel, m_eModelStyle, eType); char* pSkin = LTNULL;//GetGibSkin(m_eModel, m_eModelStyle, eType); if (!pFilename) return LTNULL; ObjectCreateStruct createStruct; INIT_OBJECTCREATESTRUCT(createStruct); createStruct.m_ObjectType = OT_MODEL; SAFE_STRCPY(createStruct.m_Filename, pFilename); if (pSkin) SAFE_STRCPY(createStruct.m_SkinName, pSkin); createStruct.m_Flags = FLAG_VISIBLE; // | FLAG_NOLIGHT; VEC_COPY(createStruct.m_Pos, m_vPos); HLOCALOBJ hObj = m_pClientDE->CreateObject(&createStruct); if (hObj) { m_pClientDE->SetModelAnimation(hObj, m_pClientDE->GetAnimIndex(hObj, "DEAD1")); } return hObj; }
HLOCALOBJ CParticleExplosionFX::CreateDebris() { LTVector vScale; VEC_SET(vScale, 1.0f, 1.0f, 1.0f); VEC_MULSCALAR(vScale, vScale, GetRandom(1.0f, 5.0f)); char* pFilename = GetDebrisModel(DBT_STONE_BIG, vScale); char* pSkin = GetDebrisSkin(DBT_STONE_BIG); if (!pFilename) return LTNULL; ObjectCreateStruct createStruct; INIT_OBJECTCREATESTRUCT(createStruct); createStruct.m_ObjectType = OT_MODEL; SAFE_STRCPY(createStruct.m_Filename, pFilename); SAFE_STRCPY(createStruct.m_SkinName, pSkin); createStruct.m_Flags = FLAG_VISIBLE | FLAG_NOLIGHT; VEC_COPY(createStruct.m_Pos, m_vPos); HLOCALOBJ hObj = m_pClientDE->CreateObject(&createStruct); m_pClientDE->SetObjectScale(hObj, &vScale); return hObj; }
void CEditProjectMgr::LoadTemplateClasses() { // Clear the currently loaded templates DeleteAndClearArray(m_TemplateClasses); // Load the template objects CObjectImporter *pImporter=GetTemplateObjectImporter(); if (!pImporter) { return; } if (!pImporter->LoadObjectFile("lithtech.cls")) { return; } // Create each class int i; for (i=0; i < pImporter->GetNumObjects(); i++) { // Allocate the class TemplateClass *pClass=new TemplateClass; // Get the class name and parent type CString sName=pImporter->GetObjectName(i); CString sParentType=pImporter->GetObjectType(i); SAFE_STRCPY(pClass->m_ClassName, sName); SAFE_STRCPY(pClass->m_ParentClassName, sParentType); m_TemplateClasses.Append(pClass); } }
void CFolderWeaponControls::UpdateSelection() { CLTGUICtrl *pCtrl = GetSelectedControl(); if (!pCtrl) return; int nComm = pCtrl->GetParam1(); if (!nComm) return; uint8 nWeaponId = g_pWeaponMgr->GetWeaponId(m_nActions[nComm-1]); if (nWeaponId != nLastId) { WEAPON* pWeapon = g_pWeaponMgr->GetWeapon(nWeaponId); if (pWeapon) { SAFE_STRCPY(m_szModel, pWeapon->szInterfaceModel); SAFE_STRCPY(m_szSkin, pWeapon->szInterfaceSkin); VEC_COPY(m_vOffset, pWeapon->vInterfaceOffset); m_fScale = pWeapon->fInterfaceScale; CreateModelSFX(); } nLastId = nWeaponId; } }
VIEW_CELL_LIB_REF *decideInstance_Ref(char *viewref_id,char *cellref_id, char *libref_id){ NEW_LIST(VIEW_CELL_LIB_REF,p1); SAFE_STRCPY(p1->viewref_id,viewref_id,MAX_PRIM_ID_LENGTH); SAFE_STRCPY(p1->cellref_id,cellref_id,MAX_PRIM_ID_LENGTH); SAFE_STRCPY(p1->libref_id, libref_id,MAX_USER_ID_LENGTH); return p1; }
void GearItem::PostPropRead(ObjectCreateStruct *pStruct) { GEAR* pGear = g_pWeaponMgr->GetGear(m_nGearId); if (!pGear) return; if (pStruct) { SAFE_STRCPY(pStruct->m_Filename, pGear->szModel); SAFE_STRCPY(pStruct->m_SkinName, pGear->szSkin); // Set up the appropriate sounds... if (pGear->szPickUpSound[0]) { FREE_HSTRING(m_hstrSoundFile); m_hstrSoundFile = g_pLTServer->CreateString(pGear->szPickUpSound); } if (pGear->szRespawnSound[0]) { FREE_HSTRING(m_hstrRespawnSoundFile); m_hstrRespawnSoundFile = g_pLTServer->CreateString(pGear->szRespawnSound); } m_bRotate = LTFALSE; } }
PROPERTY *createProperty_Integer(char *property_id,char *property_type, int property_value){ NEW_LIST(PROPERTY,p1); SAFE_STRCPY(p1->property_id, property_id, MAX_PRIM_ID_LENGTH); SAFE_STRCPY(p1->property_type, property_type, MAX_PRIM_ID_LENGTH); p1->property_value.property_num_value=property_value; return p1; }
//----------------------------------------------------------------------------------------------------------- //构建一个INSTANCE或者INSTANCE_LIST的函数 //----------------------------------------------------------------------------------------------------------- PROPERTY *createProperty(char *property_id,char *property_type, char *property_value){ NEW_LIST(PROPERTY,p1); SAFE_STRCPY(p1->property_id, property_id, MAX_PRIM_ID_LENGTH); SAFE_STRCPY(p1->property_type, property_type, MAX_PRIM_ID_LENGTH); SAFE_STRCPY((p1->property_value).property_string_value, property_value, MAX_PRIM_ID_LENGTH); return p1; }
void CGameSettings::ImplementMouseSensitivity() { if (!m_pClientDE) return; float nMouseSensitivity = GetFloatVar("MouseSensitivity"); // get the mouse device name char strDevice[128]; memset (strDevice, 0, 128); LTRESULT result = m_pClientDE->GetDeviceName (DEVICETYPE_MOUSE, strDevice, 127); if (result == LT_OK) { // get mouse x- and y- axis names char strXAxis[32]; memset (strXAxis, 0, 32); char strYAxis[32]; memset (strYAxis, 0, 32); LTBOOL bFoundXAxis = LTFALSE; LTBOOL bFoundYAxis = LTFALSE; DeviceObject* pList = m_pClientDE->GetDeviceObjects (DEVICETYPE_MOUSE); DeviceObject* ptr = pList; while (ptr) { if (ptr->m_ObjectType == CONTROLTYPE_XAXIS) { SAFE_STRCPY(strXAxis, "##x-axis"); bFoundXAxis = LTTRUE; } if (ptr->m_ObjectType == CONTROLTYPE_YAXIS) { SAFE_STRCPY(strYAxis, "##y-axis"); bFoundYAxis = LTTRUE; } ptr = ptr->m_pNext; } if (pList) m_pClientDE->FreeDeviceObjects (pList); if (bFoundXAxis && bFoundYAxis) { // run the console string char strConsole[64]; float fBaseScale = g_vtMouseScaleBase.GetFloat(); float fScaleIncrement = g_vtMouseScaleInc.GetFloat(); sprintf (strConsole, "scale \"%s\" \"%s\" %f", strDevice, strXAxis, fBaseScale + ((float)nMouseSensitivity * fScaleIncrement)); m_pClientDE->RunConsoleString (strConsole); sprintf (strConsole, "scale \"%s\" \"%s\" %f", strDevice, strYAxis, fBaseScale + ((float)nMouseSensitivity * fScaleIncrement)); m_pClientDE->RunConsoleString (strConsole); } } }
char* GetSound(CCharacter* pCharacter, EnumAISoundType eSound) { /* if (g_pVersionMgr->IsLowViolence()) { if ( (eSound == kAIS_Death) || (eSound == kAIS_DeathQuiet) || (eSound == kAIS_Pain) ) { return BUILD_NOPAIN_WAV; } } */ if (!pCharacter || !g_pServerSoundMgr) return LTNULL; ModelId eModelId = pCharacter->GetModelId(); char szSoundTemplate[128] = ""; SAFE_STRCPY(szSoundTemplate,g_pModelButeMgr->GetModelSoundTemplate(eModelId)); if (!strlen(szSoundTemplate)) return LTNULL; // Look for sounds in a heirarchical manner: First look for the sound in the sound // template, if it isn't found there look in the parent sound template, and so on... char szStr[128] = ""; g_pServerSoundMgr->GetRandomSoundFilename(szSoundTemplate, s_aszAISoundTypes[eSound], szStr, sizeof(szStr)); // guard against loops... uint32 nRemainingAttempts = 10; while (!strlen(szStr) && nRemainingAttempts) { // Look in the parent template... char szParentTemplate[128] = ""; g_pServerSoundMgr->GetParentSoundTemplate(szParentTemplate, sizeof(szParentTemplate), szSoundTemplate); SAFE_STRCPY(szSoundTemplate,szParentTemplate); if (!strlen(szSoundTemplate)) return LTNULL; g_pServerSoundMgr->GetRandomSoundFilename(szSoundTemplate, s_aszAISoundTypes[eSound], szStr, sizeof(szStr)); --nRemainingAttempts; } if (!nRemainingAttempts) ASSERT(!"Potential Loop in AI sound template hierarchy"); if (strlen(szStr)) { SAFE_STRCPY(s_FileBuffer, szStr); return s_FileBuffer; } return LTNULL; }
void GameBase::CreateBoundingBox() { if (m_hDimsBox) return; if (!g_vtDimsAlpha.IsInitted()) { g_vtDimsAlpha.Init(g_pLTServer, "DimsAlpha", LTNULL, 1.0f); } ObjectCreateStruct theStruct; INIT_OBJECTCREATESTRUCT(theStruct); LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); theStruct.m_Pos = vPos; SAFE_STRCPY(theStruct.m_Filename, "Models\\1x1_square.abc"); SAFE_STRCPY(theStruct.m_SkinName, "Models\\1x1_square.dtx"); theStruct.m_Flags = FLAG_VISIBLE | FLAG_NOLIGHT | FLAG_GOTHRUWORLD; theStruct.m_ObjectType = OT_MODEL; HCLASS hClass = g_pLTServer->GetClass("BaseClass"); LPBASECLASS pModel = g_pLTServer->CreateObject(hClass, &theStruct); if (pModel) { m_hDimsBox = pModel->m_hObject; LTVector vDims; g_pLTServer->GetObjectDims(m_hObject, &vDims); LTVector vScale; VEC_DIVSCALAR(vScale, vDims, 0.5f); g_pLTServer->ScaleObject(m_hDimsBox, &vScale); } LTVector vOffset; LTRotation rOffset; vOffset.Init(); rOffset.Init(); HATTACHMENT hAttachment; LTRESULT dRes = g_pLTServer->CreateAttachment(m_hObject, m_hDimsBox, LTNULL, &vOffset, &rOffset, &hAttachment); if (dRes != LT_OK) { g_pLTServer->RemoveObject(m_hDimsBox); m_hDimsBox = LTNULL; } LTVector vColor = GetBoundingBoxColor(); g_pLTServer->SetObjectColor(m_hDimsBox, vColor.x, vColor.y, vColor.z, g_vtDimsAlpha.GetFloat()); }
LTBOOL CHUDChatInput::HandleKeyDown(int key, int rep) { switch (key) { case VK_ESCAPE: { Show(false,false); return LTTRUE; } break; case VK_RETURN: { Send(); return LTTRUE; } break; case VK_UP: { int nTest = m_nHistory+1; if (nTest >= 0 && nTest < kMaxChatHistory && strlen(m_szChatHistory[nTest])) { m_nHistory = nTest; SAFE_STRCPY(m_szChatStr,m_szChatHistory[nTest]); m_EditCtrl.UpdateData(LTFALSE); } return LTTRUE; } break; case VK_DOWN: { int nTest = m_nHistory-1; if (nTest >= 0 && nTest < kMaxChatHistory && strlen(m_szChatHistory[nTest])) { m_nHistory = nTest; SAFE_STRCPY(m_szChatStr,m_szChatHistory[nTest]); m_EditCtrl.UpdateData(LTFALSE); } return LTTRUE; } break; case VK_PRIOR: { g_pChatMsgs->IncHistoryOffset(); return LTTRUE; } break; case VK_NEXT: { g_pChatMsgs->DecHistoryOffset(); return LTTRUE; } break; default: return m_EditCtrl.HandleKeyDown(key,rep); } }
PORTREF *createPortref(int portref_type,char *portref_id,int bit_location,char *instanceref_id){ NEW_LIST(PORTREF,p1); //存在bug,因为传进来的instanceref_id可能会是一个NULL指针,所以必须carefully p1->portref_type =portref_type; SAFE_STRCPY(p1->portref_id,portref_id,MAX_PRIM_ID_LENGTH); if (instanceref_id!=NULL){ SAFE_STRCPY(p1->instanceref_id,instanceref_id,MAX_USER_ID_LENGTH); } p1->bit_location=bit_location; return p1; }
void CLoadingScreen::CreateInterfaceSFX() { if( m_pRenderScreen ) return; HOBJECT hCamera = g_pInterfaceMgr->GetInterfaceCamera(); if (!hCamera) return; g_pLTClient->GetObjectPos(hCamera, &m_vPos); g_pLTClient->GetObjectRotation(hCamera, &m_rRot); m_vU = m_rRot.Up(); m_vR = m_rRot.Right(); m_vF = m_rRot.Forward(); int n = 0; char szTagName[30]; char szAttName[30]; char szFXName[128]; sprintf(szAttName,"Light%d",n); SAFE_STRCPY(szTagName,m_layout.c_str()); if (!g_pLayoutMgr->Exist(szTagName)) SAFE_STRCPY(szTagName,"LoadScreenDefault"); while (g_pLayoutMgr->HasValue(szTagName,szAttName)) { g_pLayoutMgr->GetString(szTagName,szAttName,szFXName,128); if (strlen(szFXName)) { CreateLightFX(szFXName); } n++; sprintf(szAttName,"Light%d",n); } n = 0; sprintf(szAttName,"LoadScale%d",n); while (g_pLayoutMgr->HasValue(szTagName,szAttName)) { g_pLayoutMgr->GetString(szTagName,szAttName,szFXName,128); if (strlen(szFXName)) { CreateScaleFX(szFXName); } n++; sprintf(szAttName,"LoadScale%d",n); } }
void Speaker::InitialUpdate() { if (!g_pLTServer || !m_hObject) return; ObjectCreateStruct createstruct; createstruct.Clear(); SAFE_STRCPY(createstruct.m_Filename, "Models\\1x1_square.abc"); SAFE_STRCPY(createstruct.m_SkinNames[0], "Models\\1x1_square.dtx"); g_pLTServer->Common()->SetObjectFilenames(m_hObject, &createstruct); }
top_EDIF *createEdif(char *edif_name,REF_LIBRARY *reflib_list,CELL *work_cells,char *design_name){ top_EDIF *p1; p1=(top_EDIF *)malloc(sizeof(top_EDIF)); SAFE_STRCPY(p1->edif_name,edif_name,20); p1->reflib_cnt =reflib_list->list_cnt; p1->reflib_list =reflib_list; p1->work_cells_cnt =work_cells->list_cnt; p1->work_cells =work_cells; SAFE_STRCPY(p1->design_name,design_name,20); return p1; }
// ----------------------------------------------------------------------- // // // ROUTINE: CCommandObjectPlugin::PreHook_PropChanged // // PURPOSE: Constructor // // ----------------------------------------------------------------------- // LTRESULT CCommandObjectPlugin::PreHook_PropChanged( const char *szObjName, const char *szPropName, const int nPropType, const GenericProp &gpPropValue, ILTPreInterface *pInterface, const char *szModifiers ) { if( !_stricmp( szPropName, "FinishedCommand" )) { if( LT_OK == m_CmdMgrPlugin.PreHook_PropChanged( szObjName, szPropName, nPropType, gpPropValue, pInterface, szModifiers )) { return LT_OK; } } else if( nPropType == LT_PT_STRING && gpPropValue.m_String[0] ) { char strPropVal[256]; SAFE_STRCPY( strPropVal, gpPropValue.m_String ); char *pTime = strtok( strPropVal, "|" ); char *pCmd = strtok( LTNULL, "\0" ); GenericProp gp; if(pCmd) { SAFE_STRCPY( gp.m_String, pCmd ); } else { gp.m_String[0] = '\0'; } if( LT_OK == m_CmdMgrPlugin.PreHook_PropChanged( szObjName, szPropName, nPropType, gp, pInterface, szModifiers )) { return LT_OK; } } return LT_UNSUPPORTED; }
/* This is it - how to get the setup values */ static int anonftpOpenDialog(void) { WINDOW *ds_win; ComposeObj *obj = NULL; int n = 0, cancel = FALSE; int max; char title[80]; WINDOW *w = savescr(); /* We need a curses window */ if (!(ds_win = openLayoutDialog(ANONFTP_HELPFILE, " Anonymous FTP Configuration ", ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, ANONFTP_DIALOG_WIDTH, ANONFTP_DIALOG_HEIGHT))) { beep(); msgConfirm("Cannot open anonymous ftp dialog window!!"); restorescr(w); return DITEM_FAILURE; } /* Draw a sub-box for the path configuration */ draw_box(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 8, ANONFTP_DIALOG_HEIGHT - 11, ANONFTP_DIALOG_WIDTH - 17, dialog_attr, border_attr); wattrset(ds_win, dialog_attr); sprintf(title, " Path Configuration "); mvwaddstr(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 22, title); /** Initialize the config Data Structure **/ bzero(&tconf, sizeof(tconf)); SAFE_STRCPY(tconf.group, FTP_GROUP); SAFE_STRCPY(tconf.upload, FTP_UPLOAD); SAFE_STRCPY(tconf.comment, FTP_COMMENT); SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR); sprintf(tconf.uid, "%d", FTP_UID); /* Some more initialisation before we go into the main input loop */ obj = initLayoutDialog(ds_win, layout, ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, &max); cancelbutton = okbutton = 0; while (layoutDialogLoop(ds_win, layout, &obj, &n, max, &cancelbutton, &cancel)); /* Clear this crap off the screen */ delwin(ds_win); use_helpfile(NULL); restorescr(w); if (cancel) return DITEM_FAILURE; return DITEM_SUCCESS; }
LTBOOL CShellCasingFX::CreateObject(ILTClient *pClientDE) { if (!CSpecialFX::CreateObject(pClientDE)) return LTFALSE; // Setup the shell... AMMO const *pAmmo = g_pWeaponMgr->GetAmmo(m_nAmmoId); if (!pAmmo || !pAmmo->pFireFX) return LTFALSE; ObjectCreateStruct createStruct; INIT_OBJECTCREATESTRUCT(createStruct); SAFE_STRCPY(createStruct.m_Filename, pAmmo->pFireFX->szShellModel); SAFE_STRCPY(createStruct.m_SkinName, pAmmo->pFireFX->szShellSkin); m_vInitialScale = pAmmo->pFireFX->vShellScale; m_vFinalScale = (m_vInitialScale * g_vtShellMaxScale.GetFloat()); createStruct.m_ObjectType = OT_MODEL; createStruct.m_Flags = m_dwFlags; createStruct.m_Pos = m_vStartPos; createStruct.m_Rotation = m_rRot; m_hObject = m_pClientDE->CreateObject(&createStruct); if (!m_hObject) return LTFALSE; m_pClientDE->SetObjectScale(m_hObject, &m_vInitialScale); // User camera rotation if not 3rd person ;) if (!m_b3rdPerson) { g_pPlayerMgr->GetCameraRotation(m_rRot); } m_vStartVel += (m_rRot.Up() * GetRandom(g_vtShellMinUpVelocity.GetFloat(), g_vtShellMaxUpVelocity.GetFloat())); m_vStartVel += (m_rRot.Right() * GetRandom(g_vtShellMinRightVelocity.GetFloat(), g_vtShellMaxRightVelocity.GetFloat())); m_vStartVel += (m_rRot.Forward() * GetRandom(g_vtShellMinForwardVelocity.GetFloat(), g_vtShellMaxForwardVelocity.GetFloat())); InitMovingObject(&m_movingObj, m_vStartPos, m_vStartVel);; m_fElapsedTime = 0.0f; m_fDieTime = GetRandom(g_vtShellMinLifetime.GetFloat(), g_vtShellMaxLifetime.GetFloat()); m_fPitchVel = GenerateRandomVelocity(); m_fYawVel = GenerateRandomVelocity(); return LTTRUE; }
void CHUDChatInput::Send() { Show(false,false); // Ignore empty messages. if( !m_szChatStr[0] ) return; // First check and see if it was a cheat that was entered... ConParse cParse( m_szChatStr ); if( LT_OK == g_pCommonLT->Parse( &cParse )) { CParsedMsg parsedMsg( cParse.m_nArgs, cParse.m_Args ); if (g_pCheatMgr->Check( parsedMsg )) { g_pClientSoundMgr->PlayInterfaceSound("Interface\\Menu\\Snd\\Cheat.wav"); return; } // Check if this is an scmd command. else if( ScmdConsole::Instance( ).SendParsedCommand( parsedMsg )) { // If it was, it was sent. Don't send chat. return; } } // Send the Message to the server CAutoMessage cMsg; uint8 nMsgID; if (g_pPlayerMgr->GetPlayerState() == PS_GHOST) nMsgID = MID_PLAYER_GHOSTMESSAGE; else nMsgID = MID_PLAYER_MESSAGE; cMsg.Writeuint8(nMsgID); cMsg.WriteString(m_szChatStr); cMsg.Writebool(m_bTeamMessage); g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED); // cache this string in the chat history for (int i = kMaxChatHistory-1; i > 0; i--) { SAFE_STRCPY(m_szChatHistory[i], m_szChatHistory[i-1]); } SAFE_STRCPY(m_szChatHistory[0], m_szChatStr); }
/* Check if value passed in data (in the form "variable=value") is * valid, and it's status compared to the value of variable stored in * env * * Possible return values : * -3: Invalid line, the data string is NOT set as an env variable * -2: Invalid line, the data string is set as an env variable * -1: Invalid line * 0: Valid line, is NOT equal to env version * 1: Valid line, is equal to env version * 2: Valid line, value empty - e.g. foo="" * 3: Valid line, does not exist in env */ int variable_check2(char *data) { char *cp, *cp2, *cp3, tmp[256]; if (data == NULL) return -1; SAFE_STRCPY(tmp, data); if ((cp = index(tmp, '=')) != NULL) { *(cp++) = '\0'; if (*cp == '"') { /* smash quotes if present */ ++cp; if ((cp3 = index(cp, '"')) != NULL) *cp3 = '\0'; } else if ((cp3 = index(cp, ',')) != NULL) *cp3 = '\0'; cp2 = variable_get(tmp); if (cp2 != NULL) { if (*cp == '\0') return 2; else return strcmp(cp, cp2) == 0 ? 1 : 0; } else return 3; } else return variable_get(tmp) != NULL ? -2 : -3; }
NET *findNet(char *net_name,PORTREF *portref_list){ NEW_LIST(NET,p1); SAFE_STRCPY(p1->net_name,net_name,MAX_USER_ID_LENGTH); p1->portref_number=portref_list->list_cnt; p1->portref_list =portref_list; return p1; }
LTRESULT CWeaponItemPlugin::PreHook_Dims(const char* szRezPath, const char* szPropValue, char* szModelFilenameBuf, int nModelFilenameBufLen, LTVector & vDims ) { if (!szModelFilenameBuf || nModelFilenameBufLen < 1 || !g_pWeaponMgr ) return LT_UNSUPPORTED; szModelFilenameBuf[0] = '\0'; // Remove the , that is put into some weapon names. char szModifiedPropValue[256]; SAFE_STRCPY( szModifiedPropValue, szPropValue ); strtok( szModifiedPropValue, "," ); WEAPON const* pWeapon = g_pWeaponMgr->GetWeapon(( char* )szModifiedPropValue); if( !pWeapon || !pWeapon->szHHModel[0] ) { return LT_UNSUPPORTED; } strcpy( szModelFilenameBuf, pWeapon->szHHModel ); // Need to convert the .ltb filename to one that DEdit understands... ConvertLTBFilename( szModelFilenameBuf ); return LT_OK; }
bool WeaponItem::PostPropRead(ObjectCreateStruct *pStruct) { WEAPON const *pWeapon = g_pWeaponMgr->GetWeapon(m_nWeaponId); if( !pWeapon ) return false; if( !pStruct ) return false; SAFE_STRCPY(pStruct->m_Filename, pWeapon->szHHModel); pWeapon->blrHHSkins.CopyList(0, pStruct->m_SkinNames[0], MAX_CS_FILENAME_LEN+1); pWeapon->blrHHRenderStyles.CopyList(0, pStruct->m_RenderStyleNames[0], MAX_CS_FILENAME_LEN+1); // See if our default model was changed... CheckForOverrideModel(pStruct); // Set up the appropriate pick up and respawn sounds... FREE_HSTRING(m_hstrSoundFile); m_hstrSoundFile = g_pLTServer->CreateString( WEAPONITEM_PICKUP_SOUND ); FREE_HSTRING( m_hstrRespawnSoundFile ); m_hstrRespawnSoundFile = g_pLTServer->CreateString( WEAPONITEM_RESPAWN_SOUND ); m_vScale = pWeapon->vHHScale; m_sClientFX = pWeapon->szPowerupFX; m_bBounce = LTFALSE; m_bRotate = LTFALSE; return true; }
// Remove a character from the end void CLTGUIEditCtrl::RemoveCharacter() { if (!m_pText) return; // Check to see have any chars if (m_pText->GetLength() < 1) return; SAFE_STRCPY(szString,m_pText->GetText()); int nEnd = (int)strlen(szString); if (nEnd > m_nCaretPos) { int nIndex = m_nCaretPos; while (nIndex < nEnd) { szString[nIndex] = szString[nIndex+1]; nIndex++; } szString[nIndex]='\0'; m_pText->SetText(szString); } CalculateSize(); }
static void index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie) { char depends[1024 * 16], *space, *todo; PkgNodePtr found; IndexEntryPtr found_ie; SAFE_STRCPY(depends, ie->deps); for (todo = depends; todo != NULL; ) { space = index(todo, ' '); if (space != NULL) *space = '\0'; if (strlen(todo) > 0) { /* only non-empty dependencies */ found = index_search(root, todo, NULL); if (found != NULL) { found_ie = found->data; if (add) ++found_ie->depc; else --found_ie->depc; } } if (space != NULL) todo = space + 1; else todo = NULL; } }
void Trigger::CreateBoundingBox() { CServerDE* pServerDE = GetServerDE(); if (!pServerDE) return; ObjectCreateStruct theStruct; INIT_OBJECTCREATESTRUCT(theStruct); DVector vPos; pServerDE->GetObjectPos(m_hObject, &vPos); VEC_COPY(theStruct.m_Pos, vPos); SAFE_STRCPY(theStruct.m_Filename, "Models\\Props\\1x1_square.abc"); // strcpy(theStruct.m_SkinName, "SpecialFX\\smoke.dtx"); theStruct.m_Flags = FLAG_VISIBLE; HCLASS hClass = pServerDE->GetClass("Model"); LPBASECLASS pModel = pServerDE->CreateObject(hClass, &theStruct); if (pModel) { m_hBoundingBox = pModel->m_hObject; DVector vDims; pServerDE->GetObjectDims(m_hObject, &vDims); DVector vScale; VEC_DIVSCALAR(vScale, vDims, 0.5f); pServerDE->ScaleObject(m_hBoundingBox, &vScale); } pServerDE->SetObjectColor(m_hBoundingBox, GetRandom(0.5f, 1.0f), GetRandom(0.5f, 1.0f), GetRandom(0.5f, 1.0f), 1.0f); }
static LTBOOL ValidateMsgAttachDetach( ILTPreInterface *pInterface, ConParse &cpMsgParams ) { char szMsgName[16] = {0}; SAFE_STRCPY( szMsgName, cpMsgParams.m_Args[0]); if( cpMsgParams.m_nArgs == 1 ) { return LTTRUE; } int i = 1; char *pObjName = cpMsgParams.m_Args[1]; while( pObjName ) { if( LT_NOTFOUND == pInterface->FindObject( pObjName ) ) { if( CCommandMgrPlugin::s_bShowMsgErrors ) { pInterface->ShowDebugWindow( LTTRUE ); pInterface->CPrint( "ERROR! - ValidateMsgAttach()" ); pInterface->CPrint( " MSG - %s - Could not find object '%s'!", _strupr(szMsgName), pObjName ); } return LTFALSE; } pObjName = (cpMsgParams.m_nArgs > ++i && cpMsgParams.m_Args[i]) ? cpMsgParams.m_Args[i] : LTNULL; } return LTTRUE; }