本文整理汇总了C++中ObjArray类的典型用法代码示例。如果您正苦于以下问题:C++ ObjArray类的具体用法?C++ ObjArray怎么用?C++ ObjArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ObjArray *Chr::getWeapons(bool includeMagic) {
ObjArray *list = new ObjArray;
if (_weapon1)
list->push_back(_weapon1);
if (_weapon2)
list->push_back(_weapon2);
for (uint i = 0; i < _inventory.size(); i++)
switch (_inventory[i]->_type) {
case Obj::REGULAR_WEAPON:
case Obj::THROW_WEAPON:
list->push_back(_inventory[i]);
break;
case Obj::MAGICAL_OBJECT:
if (includeMagic)
list->push_back(_inventory[i]);
break;
default:
break;
}
return list;
}
示例2: BError
BObjectImp* FileAccessExecutorModule::mf_ReadFile()
{
const String* filename;
if (!getStringParam( 0, filename ))
return new BError( "Invalid parameter type" );
const Package* outpkg;
string path;
if (!pkgdef_split( filename->value(), exec.prog()->pkg, &outpkg, &path ))
return new BError( "Error in filename descriptor" );
if (path.find( ".." ) != string::npos)
return new BError( "No parent path traversal please." );
if (!HasReadAccess( exec.prog()->pkg, outpkg, path ))
return new BError( "Access denied" );
string filepath;
if (outpkg == NULL)
filepath = path;
else
filepath = outpkg->dir() + path;
ifstream ifs( filepath.c_str() );
if (!ifs.is_open())
return new BError( "File not found: " + filepath );
ObjArray* arr = new ObjArray();
string line;
while (getline(ifs, line))
arr->addElement( new String( line ) );
return arr;
}
示例3: SendTriggerMsgToObjects
LTBOOL SendTriggerMsgToObjects(LPBASECLASS pSender, const char* pName, const char* pMsg)
{
if (!pMsg) return LTFALSE;
// Process the message as a command if it is a valid command...
if (g_pCmdMgr->IsValidCmd(pMsg))
{
return g_pCmdMgr->Process(pMsg);
}
if (!pName || pName[0] == '\0') return LTFALSE;
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
// ILTServer::FindNameObjects does not destroy pName so this is safe
g_pLTServer->FindNamedObjects((char*)pName, objArray);
int numObjects = objArray.NumObjects();
if (!numObjects) return LTFALSE;
for (int i = 0; i < numObjects; i++)
{
SendTriggerMsgToObject(pSender, objArray.GetObject(i), 0, pMsg);
}
return LTTRUE;
}
示例4: Update
void Camera::Update()
{
LTVector vPos;
g_pLTServer->GetObjectPos(m_hObject, &vPos);
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME,objArray);
int numObjects = objArray.NumObjects();
for (int i = 0; i < numObjects; i++ )
{
CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(objArray.GetObject(i));
if (pPlayer)
{
HCLIENT hClient = pPlayer->GetClient();
if (hClient)
{
g_pLTServer->SetClientViewPos(hClient, &vPos);
}
}
}
if (m_fActiveTime > 0.0f && g_pLTServer->GetTime() > m_fTurnOffTime)
{
TurnOff();
}
else
{
SetNextUpdate(UPDATE_NEXT_FRAME);
}
}
示例5: HandleSpawnFromMsg
void Spawner::HandleSpawnFromMsg( HOBJECT hSender, const CParsedMsg &crParsedMsg )
{
LTVector vPos;
LTRotation rRot;
const char *pName = "";
ObjArray<HOBJECT, 1> objArray;
g_pLTServer->FindNamedObjects( const_cast<char*>(crParsedMsg.GetArg(1).c_str()), objArray );
// Spawn the target object from the position of the specified object...
if( objArray.NumObjects() == 1 )
{
g_pLTServer->GetObjectPos( objArray.GetObject(0), &vPos );
g_pLTServer->GetObjectRotation( objArray.GetObject(0), &rRot );
}
else
{
g_pLTServer->GetObjectPos( m_hObject, &vPos );
g_pLTServer->GetObjectRotation( m_hObject, &rRot );
}
// Rename the object if desired
if( crParsedMsg.GetArgCount() > 2 )
{
pName = crParsedMsg.GetArg(2);
}
// Spawn using a target template...
Spawn( m_sTarget.c_str(), pName, vPos, rRot );
}
示例6: regenWeaponsMenu
void Gui::regenWeaponsMenu() {
if (_engine->_world->_weaponMenuDisabled)
return;
_menu->clearSubMenu(_weaponsMenuId);
Chr *player = _engine->_world->_player;
ObjArray *weapons = player->getWeapons(true);
bool empty = true;
for (uint i = 0; i < weapons->size(); i++) {
Obj *obj = (*weapons)[i];
if (obj->_type == Obj::REGULAR_WEAPON ||
obj->_type == Obj::THROW_WEAPON ||
obj->_type == Obj::MAGICAL_OBJECT) {
Common::String command(obj->_operativeVerb);
command += " ";
command += obj->_name;
_menu->addMenuSubItem(_weaponsMenuId, command.c_str(), kMenuActionCommand, 0, 0, true);
empty = false;
}
}
delete weapons;
if (empty)
_menu->addMenuSubItem(_weaponsMenuId, "You have no weapons", 0, 0, 0, false);
}
示例7: FindNamedObject
LTRESULT FindNamedObject(const char* szName, ILTBaseClass *& pObject, bool bMultipleOkay)
{
if ( !szName || !*szName ) return LT_NOTFOUND;
pObject = NULL;
ObjArray<HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects((char*)szName,objArray);
switch ( objArray.NumObjects() )
{
case 1:
{
pObject = g_pLTServer->HandleToObject(objArray.GetObject(0));
return LT_OK;
}
case 0:
{
return LT_NOTFOUND;
}
default:
{
if ( bMultipleOkay )
{
pObject = g_pLTServer->HandleToObject(objArray.GetObject(0));
return LT_OK;
}
else
{
g_pLTServer->CPrint("Error, %d objects named \"%s\" present in level", objArray.NumObjects(), szName);
return LT_ERROR;
}
}
}
}
示例8: GetObjectName
void CDestructibleModel::CreateWorldModelDebris()
{
ILTServer* pServerDE = BaseClass::GetServerDE();
if (!pServerDE) return;
const char* pName = GetObjectName(m_hObject);
if (!pName || !pName[0]) return;
// Find all the debris objects...
int nNum = 0;
char strKey[128]; memset(strKey, 0, 128);
char strNum[18]; memset(strNum, 0, 18);
HCLASS hWMDebris = pServerDE->GetClass("WorldModelDebris");
while (1)
{
// Create the keyname string...
sprintf(strKey, "%sDebris%d", pName, nNum);
// Find any debris with that name...
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
pServerDE->FindNamedObjects(strKey, objArray);
int numObjects = objArray.NumObjects();
if (!numObjects) return;
for (int i = 0; i < numObjects; i++)
{
HOBJECT hObject = objArray.GetObject(i);
if (pServerDE->IsKindOf(pServerDE->GetObjectClass(hObject), hWMDebris))
{
WorldModelDebris* pDebris = (WorldModelDebris*)pServerDE->HandleToObject(hObject);
if (!pDebris) break;
LTVector vVel, vRotPeriods;
vVel.Init(GetRandom(-200.0f, 200.0f),
GetRandom(100.0f, 300.0f), GetRandom(-200.0f, 200.0f));
vRotPeriods.Init(GetRandom(-1.0f, 1.0f),
GetRandom(-1.0f, 1.0f), GetRandom(-1.0f, 1.0f));
pDebris->Start(&vRotPeriods, &vVel);
}
}
// Increment the counter...
nNum++;
}
}
示例9: VEC_SET
void CDestructibleModel::DoExplosion(char* pTargetName)
{
CWeapons weapons;
weapons.Init(m_hObject);
weapons.ObtainWeapon(m_nExplosionWeaponId);
weapons.ChangeWeapon(m_nExplosionWeaponId);
CWeapon* pWeapon = weapons.GetCurWeapon();
if (!pWeapon) return;
weapons.SetAmmo(pWeapon->GetAmmoId());
pWeapon->SetDamageFactor(m_fDamageFactor);
LTRotation rRot;
g_pLTServer->GetObjectRotation(m_hObject, &rRot);
LTVector vF, vPos;
g_pLTServer->GetObjectPos(m_hObject, &vPos);
vF = rRot.Forward();
// Just blow up in place if we're not supposed to fire along
// forward vector and we don't have a target...
if (!m_bFireAlongForward)
{
pWeapon->SetLifetime(0.0f);
VEC_SET(vF, 0.0f, -1.0f, 0.0f); // Fire down
}
// See if we have a target...If so, point at it.
if (pTargetName)
{
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(pTargetName, objArray);
if (objArray.NumObjects())
{
LTVector vObjPos;
g_pLTServer->GetObjectPos(objArray.GetObject(0), &vObjPos);
vF = vObjPos - vPos;
vF.Normalize();
rRot = LTRotation(vF, LTVector(0.0f, 1.0f, 0.0f));
g_pLTServer->SetObjectRotation(m_hObject, &rRot);
}
}
WeaponFireInfo weaponFireInfo;
weaponFireInfo.hFiredFrom = m_hObject;
weaponFireInfo.vPath = vF;
weaponFireInfo.vFirePos = vPos;
weaponFireInfo.vFlashPos = vPos;
pWeapon->Fire(weaponFireInfo);
}
示例10: mf_Packages
BObjectImp* PolSystemExecutorModule::mf_Packages()
{
ObjArray* arr = new ObjArray;
for( unsigned i = 0; i < packages.size(); ++i )
{
PackageObjImp* imp = new PackageObjImp( PackagePtrHolder( packages[i] ) );
arr->addElement( imp );
}
return arr;
}
示例11: mf_ListGuilds
/// uo.em functions:
/// ListGuilds(); // returns an array of Guild objects
BObjectImp* GuildExecutorModule::mf_ListGuilds()
{
ObjArray* result = new ObjArray;
for( Guilds::iterator itr = guilds.begin(); itr != guilds.end(); ++itr )
{
Guild* guild = (*itr).second.get();
result->addElement( new EGuildRefObjImp( GuildRef(guild )) );
}
return result;
}
示例12: SetNextUpdate
void ScreenShake::Update()
{
if (--m_nNumShakes > 0)
{
SetNextUpdate(m_hObject, m_fFrequency);
}
LTVector vMyPos;
g_pLTServer->GetObjectPos(m_hObject, &vMyPos);
// Play sound...
if (m_hstrSound)
{
char* pSound = g_pLTServer->GetStringData(m_hstrSound);
g_pServerSoundMgr->PlaySoundFromPos(vMyPos, pSound, m_fSoundRadius, SOUNDPRIORITY_MISC_LOW);
}
// Time to shake. Get all the players in the area of effect...
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME, objArray);
int numObjects = objArray.NumObjects();
if (!numObjects) return;
for (int i = 0; i < numObjects; i++)
{
HOBJECT hObject = objArray.GetObject(i);
if (hObject && IsPlayer(hObject))
{
// Make sure object is in area of effect...
LTVector vPlayerPos;
g_pLTServer->GetObjectPos(hObject, &vPlayerPos);
if (m_fAreaOfEffect == c_fENTIRE_LEVEL ||
VEC_DIST(vPlayerPos, vMyPos) <= m_fAreaOfEffect)
{
CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject);
if (pPlayer)
{
HCLIENT hClient = pPlayer->GetClient();
if (hClient)
{
HMESSAGEWRITE hMessage = g_pLTServer->StartMessage(hClient, MID_SHAKE_SCREEN);
g_pLTServer->WriteToMessageVector(hMessage, &m_vAmount);
g_pLTServer->EndMessage(hMessage);
}
}
}
}
}
}
示例13: field
void ClassInfo::iterate_tables(OopROMVisitor* visitor) {
int index = 0;
if (vtable_length() > 0) {
visitor->do_comment("Virtual dispatch table");
for (index = 0; index < vtable_length(); index++) {
IndexableField field(index, true);
visitor->do_oop(&field, vtable_offset_from_index(index), true);
}
}
if (itable_length() > 0){
visitor->do_comment("Interface dispatch table");
for (index = 0; index < itable_length(); index++) {
{
InstanceClass ic = itable_interface_at(index);
Symbol name = ic.name();
char buffer[1024];
jvm_sprintf(buffer, "interface klass_index ");
name.string_copy(buffer + jvm_strlen(buffer),
sizeof(buffer) - jvm_strlen(buffer));
NamedField field(buffer, true);
visitor->do_int(&field, itable_offset_from_index(index), true);
}
{
NamedField field("offset", true);
visitor->do_int(&field,
itable_offset_from_index(index) + sizeof(jint),
true);
}
}
for (index = 0; index < itable_length(); index++) {
int offset = itable_offset_at(index);
// Some ROM's interfaces that implement other interfaces set
// offset=0, since this information is actually needed by
// anyone.
if (offset > 0) {
InstanceClass ic = itable_interface_at(index);
Symbol name = ic.name();
ObjArray methods = ic.methods();
const int buffer_size = 256;
char buffer[256];
jvm_sprintf(buffer, "Table for interface #%d: ", index);
name.string_copy(buffer + jvm_strlen(buffer), buffer_size- jvm_strlen(buffer));
visitor->do_comment(buffer);
for (int i = 0; i < methods.length(); i ++) {
IndexableField field(i, true);
visitor->do_oop(&field, offset + i * sizeof(jobject), true);
}
}
}
}
}
示例14: FindWhoPlaysDecision
HOBJECT CinematicTrigger::FindWhoPlaysDecision(uint8 byDecision)
{
char* pCharName = DEFAULT_PLAYERNAME;
if (byDecision > 0)
{
char* pMsg = g_pLTServer->GetStringData(m_hstrWhoPlaysDecisions[m_nCurMessage]);
if (pMsg)
{
ConParse parse;
parse.Init(pMsg);
// Since the names will be seperated by semi-colons we need
// to parse until we get to the correct name...
LTBOOL bFound = LTTRUE;
for (int i=1; i <= byDecision; i++)
{
if (g_pLTServer->Common()->Parse(&parse) != LT_OK)
{
bFound = LTFALSE;
break;
}
}
// Parse should be on the correct name now...
if (bFound && parse.m_nArgs > 0)
{
if (parse.m_Args[0])
{
pCharName = parse.m_Args[0];
}
}
}
}
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(pCharName, objArray);
if (objArray.NumObjects())
{
return objArray.GetObject(0);
}
return LTNULL;
}
示例15: FirstUpdate
void Controller::FirstUpdate()
{
// Find target objects and make interlinks.
for (uint32 i=0; i < MAX_CONTROLLER_TARGETS; i++)
{
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(m_Fades[i].m_ObjectName, objArray);
if (objArray.NumObjects())
{
HOBJECT hObject = objArray.GetObject(0);
m_Fades[i].m_hTarget = hObject;
}
}
}