本文整理汇总了C++中Reference类的典型用法代码示例。如果您正苦于以下问题:C++ Reference类的具体用法?C++ Reference怎么用?C++ Reference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(LuaMobileTest, LuaMobileTemplatesTest) {
CreatureTemplateManager::DEBUG_MODE = 1;
// Verify that all mobiles load
ASSERT_EQ(CreatureTemplateManager::instance()->loadTemplates(), 0);
// Verify loot group map loaded
ASSERT_EQ(LootGroupMap::ERROR_CODE, 0);
// Verify factions load
FactionManager::instance()->loadData();
ASSERT_FALSE(FactionManager::instance()->getFactionMap()->isEmpty());
// Load Templates
ASSERT_TRUE( TemplateManager::instance() != NULL );
if( TemplateManager::instance()->loadedTemplatesCount == 0 ){
TemplateManager::instance()->loadLuaTemplates();
ASSERT_EQ(TemplateManager::ERROR_CODE, 0);
}
// verify DNA manager loads
DnaManager::instance()->loadSampleData();
ASSERT_TRUE( DnaManager::instance() != NULL);
// Test Creature Templates
HashTableIterator<uint32, Reference<CreatureTemplate*> > creatureIterator = CreatureTemplateManager::instance()->iterator();
while (creatureIterator.hasNext()) {
CreatureTemplate* creature = creatureIterator.next();
std::string templateName( creature->getTemplateName().toCharArray() );
//Verify non-empty objectName is a valid string
String objName = creature->getObjectName();
if (!objName.isEmpty()) {
std::string name = objName.toCharArray();
EXPECT_TRUE( mobNames.contains(objName) ) << "Mobile " << templateName << " has invalid objectName: " << name;
}
// Check configured templates
Vector<String> objTemps = creature->getTemplates();
EXPECT_FALSE( objTemps.isEmpty() ) << "Mobile " << templateName << " does not have any templates configured";
int objectType = 0;
for( int j=0; j< objTemps.size(); j++ ){
SharedObjectTemplate* templateData = templateManager->getTemplate(objTemps.get(j).hashCode());
std::string objName = objTemps.get(j).toCharArray();
EXPECT_TRUE( templateData != NULL ) << "Mobile " << templateName << " has invalid template configured: " << objName;
// Check Template Genetics math to find invalid mobs
if (templateData != NULL) {
SharedCreatureObjectTemplate* creoData = dynamic_cast<SharedCreatureObjectTemplate*> (templateData);
if (creoData != NULL) {
}
}
if (objectType == 0) {
objectType = templateData->getGameObjectType();
}
}
// Verify that control device template is valid
String controlDeviceTemplate = creature->getControlDeviceTemplate();
if (!controlDeviceTemplate.isEmpty()) {
SharedObjectTemplate* controlDeviceTemplateData = templateManager->getTemplate(controlDeviceTemplate.hashCode());
EXPECT_TRUE( controlDeviceTemplateData != NULL ) << "Control device template " << controlDeviceTemplate.toCharArray() << " from " << templateName << " does not exist.";
EXPECT_TRUE( controlDeviceTemplate.beginsWith("object/intangible/pet/") ) << "Control device template " << controlDeviceTemplate.toCharArray() << " from " << templateName << " is not a pet/droid control device template.";
}
// Verify that faction is valid
String faction = creature->getFaction();
if (!faction.isEmpty()) {
EXPECT_TRUE( FactionManager::instance()->isFaction(faction) ) << "Faction, " << faction.toCharArray() << ", from mobile template " << templateName << " does not exist.";
}
// Verify level
int level = creature->getLevel();
EXPECT_TRUE( level > 0 ) << "Level is not a positive value on mobile: " << templateName;
// Verify hit chance
float hitChance = creature->getChanceHit();
EXPECT_TRUE( hitChance > 0 ) << "ChanceHit is not a positive value on mobile: " << templateName;
// Verify xp
int xp = creature->getBaseXp();
EXPECT_TRUE( xp >= 0 ) << "Xp has a negative value on mobile: " << templateName;
// Verify damage
int minDamage = creature->getDamageMin();
int maxDamage = creature->getDamageMax();
EXPECT_TRUE( minDamage > 0 ) << "Min damage is not a positive value on mobile: " << templateName;
EXPECT_TRUE( maxDamage >= minDamage ) << "Max damage is lower than min damage on mobile: " << templateName;
// Verify HAM
int minHam = creature->getBaseHAM();
int maxHam = creature->getBaseHAMmax();
EXPECT_TRUE( minHam > 0 ) << "Base ham is not a positive value on mobile: " << templateName;
EXPECT_TRUE( maxHam >= minHam ) << "Base ham max is lower than base ham on mobile: " << templateName;
// Verify armor
int armor = creature->getArmor();
EXPECT_TRUE( armor >= 0 && armor <= 3 ) << "Armor is not a valid value on mobile: " << templateName;
// Verify resists
float kinetic = creature->getKinetic();
//.........这里部分代码省略.........
示例2: tokenizer
void ChatManagerImplementation::handleSocialInternalMessage(CreatureObject* sender, const UnicodeString& arguments) {
if (sender->isPlayerCreature()) {
ManagedReference<PlayerObject*> senderGhost = sender->getPlayerObject();
if (senderGhost == NULL)
return;
if (senderGhost->isMuted()) {
String reason = senderGhost->getMutedReason();
if (reason != "")
sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support for '" + reason + "'.");
else
sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support.");
return;
}
}
Zone* zone = sender->getZone();
if (zone == NULL)
return;
StringTokenizer tokenizer(arguments.toString());
uint64 targetid;
uint32 emoteid, unkint, unkint2;
try {
targetid = tokenizer.getLongToken();
emoteid = tokenizer.getIntToken();
unkint = tokenizer.getIntToken();
unkint2 = tokenizer.getIntToken();
} catch (const Exception& e) {
return;
}
//bool readlock = !zone->isLockedByCurrentThread();
bool showtext = true;
if (unkint2 == 0)
showtext = false;
String firstName;
if (sender->isPlayerCreature())
firstName = (cast<CreatureObject*>(sender))->getFirstName().toLowerCase();
CloseObjectsVector* vec = (CloseObjectsVector*) sender->getCloseObjects();
SortedVector<QuadTreeEntry* > closeEntryObjects(200, 50);
if (vec != NULL) {
vec->safeCopyTo(closeEntryObjects);
} else {
sender->info("Null closeobjects vector in ChatManager::handleSocialInternalMessage", true);
zone->getInRangeObjects(sender->getWorldPositionX(), sender->getWorldPositionX(), 128, &closeEntryObjects, true);
}
float range = defaultSpatialChatDistance;
for (int i = 0; i < closeEntryObjects.size(); ++i) {
SceneObject* object = cast<SceneObject*>(closeEntryObjects.get(i));
if (object->isPlayerCreature()) {
CreatureObject* creature = cast<CreatureObject*>(object);
Reference<PlayerObject*> ghost = creature->getSlottedObject("ghost").castTo<PlayerObject*>();
if (ghost == NULL)
continue;
if (!ghost->isIgnoring(firstName) && creature->isInRange(sender, range)) {
Emote* emsg = new Emote(creature, sender, targetid, emoteid, showtext);
creature->sendMessage(emsg);
}
}
}
}
示例3: getJunkValue
// Legend of Hondo - aveage value of OQ/DR and amount of resources used in final combine
float SharedLabratory::getJunkValue(ManufactureSchematic* manufactureSchematic) {
float junkValue = 1.0f;
int resQuant = 0;
int statOQ = 0;
int statDR = 0;
int subComps = 0;
for (int i = 0; i < manufactureSchematic->getSlotCount(); ++i) {
Reference<IngredientSlot* > ingredientslot = manufactureSchematic->getSlot(i);
Reference<DraftSlot* > draftslot = manufactureSchematic->getDraftSchematic()->getDraftSlot(i);
/// If resource slot, continue
if(!ingredientslot->isResourceSlot()){
if(ingredientslot->isComponentSlot() && ingredientslot->isFull())
subComps++; // Count component slot if it is being used.
continue;
}
ResourceSlot* resSlot = cast<ResourceSlot*>(ingredientslot.get());
if(resSlot == NULL)
continue;
ManagedReference<ResourceSpawn* > spawn = resSlot->getCurrentSpawn();
if (spawn == NULL) {
error("Spawn object is null when running getJunkValue");
return 0.0f;
}
resQuant += draftslot->getQuantity();
statOQ = spawn->getValueOf(8);
statDR = spawn->getValueOf(2);
if (junkValue == 1 && statOQ != 0) {
junkValue = (statOQ + statDR) / 2;
} else if (junkValue > 1 && statOQ != 0){
junkValue = (junkValue + statOQ + statDR) / 3;
}
}
Logger::console.info("real resQuant: " + String::valueOf(resQuant), true);
Logger::console.info("average of DR and OQ: " + String::valueOf(junkValue), true);
// On low resource items with subs, make the final product worth more than selling the subs seperately
if (subComps > 0 && resQuant < 100)
resQuant = resQuant / 2 + 50;
// Factor sub components as best as possible and reduce resource quality impact for Architect and Shipwright
if (subComps == 1 && resQuant > 449){
resQuant = resQuant + (resQuant / 2 ); // Shipwright (Mk I part in Mk V final is over valued, but whatevs...)
junkValue = junkValue + (1000 - junkValue) / 2;
} else if (subComps > 1 && resQuant > 2500){
resQuant = resQuant + (resQuant * (subComps + 3)); // Architect, large
junkValue = junkValue + (1000 - junkValue) / 2;
} else if (subComps > 1 && resQuant > 499){
resQuant = resQuant + (resQuant * subComps); // Architect, small
junkValue = junkValue + (1000 - junkValue) / 2;
} else if (subComps > 0){
resQuant = resQuant + (resQuant / 3 * subComps); // Everyone else
}
// Cap resource quanity and thus max price
if (resQuant > 29900){
resQuant = 29900 + System::random(100);
}
if (junkValue != 0)
junkValue = resQuant * (junkValue / 1000);
Logger::console.info("subComps: " + String::valueOf(subComps), true);
Logger::console.info("final resQuant: " + String::valueOf(resQuant), true);
Logger::console.info("junkValue: " + String::valueOf(junkValue), true);
return junkValue;
}
示例4: MissionTargetMap
void PlanetManagerImplementation::initialize() {
performanceLocations = new MissionTargetMap();
numberOfCities = 0;
info("Loading planet.");
planetTravelPointList->setZoneName(zone->getZoneName());
loadClientRegions();
loadClientPoiData();
loadLuaConfig();
loadTravelFares();
if (zone->getZoneName() == "dathomir") {
Reference<ActiveArea*> area = zone->getZoneServer()->createObject(STRING_HASHCODE("object/fs_village_area.iff"), 0).castTo<ActiveArea*>();
Locker locker(area);
area->setRadius(768.f);
area->initializePosition(5306, 0, -4145);
zone->transferObject(area, -1, true);
ManagedReference<SceneObject*> scenery = zone->getZoneServer()->createObject(STRING_HASHCODE("object/static/structure/general/fs_village_nobuild_768m.iff"), 0);
Locker slocker(scenery, area);
scenery->initializePosition(5306, zone->getHeight(5306, -4145), -4145);
area->attachScenery(scenery);
slocker.release();
locker.release();
Reference<ActiveArea*> sarlaccArea = zone->getZoneServer()->createObject(STRING_HASHCODE("object/sarlacc_area.iff"), 0).castTo<ActiveArea*>();
Locker locker2(sarlaccArea);
sarlaccArea->setRadius(60.f);
sarlaccArea->initializePosition(-2085, 0, 3147);
zone->transferObject(sarlaccArea, -1, true);
locker2.release();
Reference<ActiveArea*> sarlaccPreArea = zone->getZoneServer()->createObject(STRING_HASHCODE("object/sarlacc_area.iff"), 0).castTo<ActiveArea*>();
Locker locker3(sarlaccPreArea);
sarlaccPreArea->setRadius(30.f);
sarlaccPreArea->initializePosition(-2085, 0, 3147);
zone->transferObject(sarlaccPreArea, -1, true);
}
if (zone->getZoneName() == "tatooine") {
Reference<ActiveArea*> area = zone->getZoneServer()->createObject(STRING_HASHCODE("object/sarlacc_area.iff"), 0).castTo<ActiveArea*>();
Locker locker(area);
area->setRadius(30.f);
area->initializePosition(-6174, 0, -3361);
zone->transferObject(area, -1, true);
locker.release();
Reference<ActiveArea*> preArea = zone->getZoneServer()->createObject(STRING_HASHCODE("object/sarlacc_area.iff"), 0).castTo<ActiveArea*>();
Locker locker2(preArea);
preArea->setRadius(60.f);
preArea->initializePosition(-6174, 0, -3361);
zone->transferObject(preArea, -1, true);
}
}
示例5: error
void SkillManager::loadClientData() {
IffStream* iffStream = TemplateManager::instance()->openIffFile("datatables/skill/skills.iff");
if (iffStream == NULL) {
error("Could not load skills.");
return;
}
DataTableIff dtiff;
dtiff.readObject(iffStream);
delete iffStream;
for (int i = 0; i < dtiff.getTotalRows(); ++i) {
DataTableRow* row = dtiff.getRow(i);
Reference<Skill*> skill = new Skill();
skill->parseDataTableRow(row);
Skill* parent = skillMap.get(skill->getParentName().hashCode());
if (parent == NULL)
parent = rootNode;
parent->addChild(skill);
if (skillMap.put(skill->getSkillName().hashCode(), skill) != NULL) {
error("overwriting skill name");
assert(0 && "skill name hashcode error");
}
//Load the abilities of the skill into the ability map.
Vector<String> commands = skill->commands;
for (int i = 0; i < commands.size(); ++i) {
String command = commands.get(i);
if (!abilityMap.containsKey(command)) {
abilityMap.put(command, new Ability(command));
}
}
}
loadFromLua();
//If the admin ability isn't in the ability map, then we want to add it manually.
if (!abilityMap.containsKey("admin"))
abilityMap.put("admin", new Ability("admin"));
// These are not listed in skills.iff and need to be added manually
if (!abilityMap.containsKey("startMusic+western"))
abilityMap.put("startMusic+western", new Ability("startMusic+western"));
if (!abilityMap.containsKey("startDance+theatrical"))
abilityMap.put("startDance+theatrical", new Ability("startDance+theatrical"));
if (!abilityMap.containsKey("startDance+theatrical2"))
abilityMap.put("startDance+theatrical2", new Ability("startDance+theatrical2"));
loadXpLimits();
info("Successfully loaded " + String::valueOf(skillMap.size()) + " skills and " + String::valueOf(abilityMap.size()) + " abilities.", true);
}
示例6: if
bool PetControlDeviceImplementation::canBeTradedTo(CreatureObject* player, CreatureObject* receiver, int numberInTrade) {
ManagedReference<SceneObject*> datapad = receiver->getSlottedObject("datapad");
if (datapad == NULL)
return false;
if (petType == PetManager::FACTIONPET) {
player->sendSystemMessage("@pet/pet_menu:bad_type"); // You cannot trade a pet of that type. Transfer failed.
return false;
} else if (petType == PetManager::DROIDPET) {
ManagedReference<PlayerManager*> playerManager = player->getZoneServer()->getPlayerManager();
int droidsInDatapad = numberInTrade;
int maxStoredDroids = playerManager->getBaseStoredDroids();
for (int i = 0; i < datapad->getContainerObjectsSize(); i++) {
Reference<SceneObject*> obj = datapad->getContainerObject(i).castTo<SceneObject*>();
if (obj != NULL && obj->isPetControlDevice() ){
Reference<PetControlDevice*> petDevice = cast<PetControlDevice*>(obj.get());
if( petDevice != NULL && petDevice->getPetType() == PetManager::DROIDPET){
droidsInDatapad++;
}
}
}
if( droidsInDatapad >= maxStoredDroids){
player->sendSystemMessage("That person has too many droids in their datapad");
return false;
}
return true;
} else if (petType == PetManager::CREATUREPET) {
ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
if (controlledObject == NULL || !controlledObject->isCreature())
return false;
ManagedReference<Creature*> pet = cast<Creature*>(controlledObject.get());
ManagedReference<PlayerManager*> playerManager = player->getZoneServer()->getPlayerManager();
int numberStored = numberInTrade;
int maxStoredPets = playerManager->getBaseStoredCreaturePets();
int maxLevelofPets = 10;
int level = pet->getAdultLevel();
bool ch = receiver->hasSkill("outdoors_creaturehandler_novice");
if (ch) {
maxStoredPets += receiver->getSkillMod("stored_pets");
maxLevelofPets = receiver->getSkillMod("tame_level");
}
if (level > maxLevelofPets) {
player->sendSystemMessage("@pet/pet_menu:no_chance"); // That person has no chance of controlling this creature. Transfer failed.
receiver->sendSystemMessage("@pet/pet_menu:cannot_control"); // You have no chance of controlling that creature.
return false;
}
if (pet->isVicious() && (receiver->getSkillMod("tame_aggro") <= 0 || !ch)) {
player->sendSystemMessage("@pet/pet_menu:no_chance"); // That person has no chance of controlling this creature. Transfer failed.
receiver->sendSystemMessage("@pet/pet_menu:cannot_control"); // You have no chance of controlling that creature.
return false;
}
if (numberStored >= maxStoredPets) {
player->sendSystemMessage("@pet/pet_menu:targ_too_many_stored"); // That person has too many stored pets. Transfer failed.
receiver->sendSystemMessage("@pet/pet_menu:sys_too_many_stored"); // There are too many pets stored in this container. Release some of them to make room for more.
return false;
}
for (int i = 0; i < datapad->getContainerObjectsSize(); ++i) {
ManagedReference<SceneObject*> object = datapad->getContainerObject(i);
if (object != NULL && object->isPetControlDevice()) {
PetControlDevice* device = cast<PetControlDevice*>( object.get());
if (device->getPetType() == PetManager::CREATUREPET) {
if (++numberStored >= maxStoredPets) {
player->sendSystemMessage("@pet/pet_menu:targ_too_many_stored"); // That person has too many stored pets. Transfer failed.
receiver->sendSystemMessage("@pet/pet_menu:sys_too_many_stored"); // There are too many pets stored in this container. Release some of them to make room for more.
return false;
}
}
}
}
return true;
}
return false;
}
示例7: assert
bool ArchHandler_x86_64::isCallSite(const Reference &ref) {
if (ref.kindNamespace() != Reference::KindNamespace::mach_o)
return false;
assert(ref.kindArch() == Reference::KindArch::x86_64);
return (ref.kindValue() == branch32);
}
示例8: mapping
CheckOTQuotationsInNT::CheckOTQuotationsInNT(const ustring& project, const vector <unsigned int>& books, bool includetext)
{
// Language and versification system.
extern Settings *settings;
ustring language = settings->projectconfig(project, false)->language_get();
ustring versification = settings->projectconfig(project, false)->versification_get();
Mapping mapping(versification, 0);
// Get a list of the books to check. If no books were given, take them all.
vector < unsigned int >mybooks(books.begin(), books.end());
if (mybooks.empty())
mybooks = project_get_books(project);
set < unsigned int >bookset(mybooks.begin(), mybooks.end());
// Get all quotations in New Testament order, optionally also in OT order.
OTQuotations otquotations(0);
otquotations.read();
bool use_ot_order = settings->session.check_output_in_ot_order;
if (use_ot_order) {
otquotations.produce_in_ot_order();
}
// GUI.
progresswindow = new ProgressWindow(_("Producing passages"), true);
progresswindow->set_iterate(0, 1, use_ot_order ? otquotations.quotations_ot_order.size() : otquotations.quotations_nt_order.size());
// Go through the quotations.
for (unsigned int i = 0; i < (use_ot_order ? otquotations.quotations_ot_order.size() : otquotations.quotations_nt_order.size()); i++) {
progresswindow->iterate();
if (progresswindow->cancel)
return;
// Skip if the reference book is not to be included.
unsigned int reference_book = use_ot_order ? otquotations.quotations_ot_order[i].reference.book_get() :
otquotations.quotations_nt_order[i].reference.book_get();
if (bookset.find(reference_book) == bookset.end())
continue;
// Optionally remapping of verses.
mapping.book_change(reference_book);
if (use_ot_order)
mapping.original_to_me(otquotations.quotations_ot_order[i].reference);
else
mapping.original_to_me(otquotations.quotations_nt_order[i].reference);
// Reference chapter and verse.
unsigned int reference_chapter = use_ot_order ? otquotations.quotations_ot_order[i].reference.chapter_get() : otquotations.quotations_nt_order[i].reference.chapter_get();
ustring reference_verse = use_ot_order ? otquotations.quotations_ot_order[i].reference.verse_get() : otquotations.quotations_nt_order[i].reference.verse_get();
// Store reference, optionally verse text, and comment.
ustring reference = use_ot_order ? otquotations.quotations_ot_order[i].reference.human_readable (language) : otquotations.quotations_nt_order[i].reference.human_readable(language);
nt_refs.push_back(reference);
ustring reference_verse_text;
if (includetext) {
reference_verse_text = project_retrieve_verse(project, reference_book, reference_chapter, reference_verse);
reference_verse_text = usfm_get_verse_text_only (reference_verse_text);
}
nt_texts.push_back (reference_verse_text);
references.push_back(reference);
comments.push_back(_("Quoted in New Testament"));
// Go through the OT quotations processing them.
vector <ustring> refs_store;
vector <ustring> text_store;
unsigned int i2_limit = use_ot_order ? otquotations.quotations_ot_order[i].referents.size() : otquotations.quotations_nt_order[i].referents.size();
for (unsigned i2 = 0; i2 < i2_limit; i2++) {
if (use_ot_order) {
mapping.book_change(otquotations.quotations_ot_order[i].referents[i2].book_get());
mapping.original_to_me(otquotations.quotations_ot_order[i].referents[i2]);
} else {
mapping.book_change(otquotations.quotations_nt_order[i].referents[i2].book_get());
mapping.original_to_me(otquotations.quotations_nt_order[i].referents[i2]);
}
ustring reference = use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].human_readable(language) : otquotations.quotations_nt_order[i].referents[i2].human_readable(language);
ustring verse_text;
if (includetext) {
verse_text = project_retrieve_verse(project,
use_ot_order ? otquotations.quotations_ot_order[i].referents[i2] : otquotations.quotations_nt_order[i].referents[i2]);
verse_text = usfm_get_verse_text_only(verse_text);
}
refs_store.push_back(reference);
text_store.push_back(verse_text);
Reference ref ((use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].book_get() : otquotations.quotations_nt_order[i].referents[i2].book_get()),
(use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].chapter_get() : otquotations.quotations_nt_order[i].referents[i2].chapter_get()),
(use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].verse_get() : otquotations.quotations_nt_order[i].referents[i2].verse_get()));
references.push_back(ref.human_readable (""));
comments.push_back(_("Old Testament verse quoted from"));
}
// Save data.
ot_refs.push_back(refs_store);
ot_texts.push_back(text_store);
}
}
示例9: switch
int ConsumableImplementation::handleObjectMenuSelect(CreatureObject* player, byte selectedID) {
if (!isASubChildOf(player))
return 0;
if (selectedID != 20) {
return TangibleObjectImplementation::handleObjectMenuSelect(player, selectedID);
}
if (speciesRestriction == "pets") {
player->sendSystemMessage("@error_message:pets_only"); //That food is only suitable for pets.
return 0;
}
PlayerObject* ghost = player->getPlayerObject();
String raceName = player->getSpeciesName();
if ((speciesRestriction == "2" && raceName != "trandoshan") || (speciesRestriction == "4" && raceName != "wookiee")) {
player->sendSystemMessage("@error_message:race_restriction"); //That food isn't edible by your species.
return 0;
}
if (isSpice() && player->hasSpice()) {
player->sendSystemMessage("@spice/spice:sys_already_spiced"); //You are already under the influence of spices.
return 0;
}
if (player->hasBuff(buffCRC) && (!isAttributeEffect() || isForagedFood())) {
player->sendSystemMessage("@combat_effects:already_affected"); //You are already under the influence of that food. Eating more won't enhance the effect.
return 0;
}
if (player->isDead() || player->isIncapacitated())
return 0;
int availfill = 0;
if (ghost == NULL)
return 1;
if (isFood())
availfill = ghost->getFoodFillingMax() - ghost->getFoodFilling();
if (isDrink())
availfill = ghost->getDrinkFillingMax() - ghost->getDrinkFilling();
if (filling > availfill) {
if (isFood())
player->sendSystemMessage("@error_message:full_food"); //You are too full to eat that.
if (isDrink())
player->sendSystemMessage("@error_message:full_drink"); //You are too full to drink that.
return 1;
}
ManagedReference<Buff*> buff = NULL;
switch (effectType) {
case EFFECT_ATTRIBUTE: {
buff = new Buff(player, buffName.hashCode(), duration, BuffType::FOOD);
setModifiers(buff, false);
break;
}
case EFFECT_SKILL: {
buff = new Buff(player, buffName.hashCode(), duration, BuffType::FOOD);
setModifiers(buff, true);
break;
}
case EFFECT_SPICE: {
buff = new SpiceBuff(player, buffName, String("spice." + buffName + ".up").hashCode(), duration);
setModifiers(buff, false);
//buff->parseAttributeModifierString(modifierString);
player->addBuff(buff);
//useCharge(player);
decreaseUseCount();
return 1;
}
case EFFECT_HEALING: {
int dmghealed = player->healDamage(player, 6, nutrition);
if (dmghealed <= 0) {
player->sendSystemMessage("@healing:no_mind_to_heal_self"); //You have no mind to heal.
return 0;
}
StringIdChatParameter stringId("combat_effects", "food_mind_heal");
stringId.setDI(dmghealed);
player->sendSystemMessage(stringId);
break;
}
case EFFECT_DURATION: {
buff = new DurationBuff(player, buffName.hashCode(), duration);
//.........这里部分代码省略.........
示例10: Tcl_WrongNumArgs
int
Extension::foreachCmd (
ClientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
if (objc != 4) {
Tcl_WrongNumArgs(
interp, 1, objv, "varList collectionHandle script");
return TCL_ERROR;
}
Tcl_Obj *pVarList = objv[1];
Tcl_Obj *pBody = objv[3];
Reference *pCollection = referenceHandles.find(interp, objv[2]);
if (pCollection == 0) {
const char *arg = Tcl_GetStringFromObj(objv[2], 0);
Tcl_AppendResult(
interp, "invalid interface pointer handle ", arg, 0);
return TCL_ERROR;
}
// Collections should implement a _NewEnum method which returns an object
// that enumerates the elements.
HRESULT hr;
PositionalArguments arguments;
_variant_t varResult;
hr = pCollection->invoke(
DISPID_NEWENUM,
DISPATCH_METHOD | DISPATCH_PROPERTYGET,
arguments,
&varResult);
if (FAILED(hr) || V_VT(&varResult) != VT_UNKNOWN) {
Tcl_AppendResult(interp, "object is not a collection", NULL);
return TCL_ERROR;
}
IUnknownPtr pUnk(V_UNKNOWN(&varResult));
// Get a specific kind of enumeration.
IEnumVARIANTPtr pEnumVARIANT;
IEnumUnknownPtr pEnumUnknown;
enum EnumKind { ENUM_VARIANT, ENUM_UNKNOWN };
EnumKind enumKind;
hr = pUnk->QueryInterface(
IID_IEnumVARIANT, reinterpret_cast<void **>(&pEnumVARIANT));
if (SUCCEEDED(hr)) {
enumKind = ENUM_VARIANT;
} else {
hr = pUnk->QueryInterface(
IID_IEnumUnknown, reinterpret_cast<void **>(&pEnumUnknown));
if (SUCCEEDED(hr)) {
enumKind = ENUM_UNKNOWN;
}
}
if (FAILED(hr)) {
Tcl_AppendResult(interp,
"Unknown enumerator type: not IEnumVARIANT or IEnumUnknown", NULL);
return TCL_ERROR;
}
int completionCode;
int varc; // number of loop variables
completionCode = Tcl_ListObjLength(interp, pVarList, &varc);
if (completionCode != TCL_OK) {
return TCL_ERROR;
}
if (varc < 1) {
Tcl_AppendResult(interp, "foreach varlist is empty", NULL);
return TCL_ERROR;
}
while (true) {
// If the variable list has been converted to another kind of Tcl
// object, convert it back to a list and refetch the pointer to its
// element array.
Tcl_Obj **varv;
completionCode =
Tcl_ListObjGetElements(interp, pVarList, &varc, &varv);
if (completionCode != TCL_OK) {
return TCL_ERROR;
}
// Assign values to all loop variables.
int v = 0;
for (; v < varc; ++v) {
TclObject value;
ULONG count;
switch (enumKind) {
case ENUM_VARIANT:
{
_variant_t elementVar;
hr = pEnumVARIANT->Next(1, &elementVar, &count);
if (hr == S_OK && count > 0) {
//.........这里部分代码省略.........
示例11: respondsToMessage
bool Object::respondsToMessage(Reference<Types::String> message) {
if(!this->functors)
return false;
return &((*this->functors)[message->getValue()]);
}
示例12: attachFunctor
void Object::attachFunctor(Reference<AbstractFunctor> func, Reference<Types::String> name) {
if(!this->functors)
this->functors = new std::map< std::string, Reference<AbstractFunctor> >();
(*this->functors)[name->getValue()] = func;
}
示例13: VariantClear
void
TclObject::toVariant (VARIANT *pDest,
const Type &type,
Tcl_Interp *interp,
bool addRef)
{
VariantClear(pDest);
VARTYPE vt = type.vartype();
Reference *pReference = Extension::referenceHandles.find(interp, m_pObj);
if (pReference != 0) {
// Convert interface pointer handle to interface pointer.
if (addRef) {
// Must increment reference count of interface pointers returned
// from methods.
pReference->unknown()->AddRef();
}
IDispatch *pDispatch = pReference->dispatch();
if (pDispatch != 0) {
V_VT(pDest) = VT_DISPATCH;
V_DISPATCH(pDest) = pDispatch;
} else {
V_VT(pDest) = VT_UNKNOWN;
V_UNKNOWN(pDest) = pReference->unknown();
}
} else if (m_pObj->typePtr == &Extension::unknownPointerType) {
// Convert to interface pointer.
IUnknown *pUnknown = static_cast<IUnknown *>(
m_pObj->internalRep.otherValuePtr);
if (addRef && pUnknown != 0) {
// Must increment reference count of interface pointers returned
// from methods.
pUnknown->AddRef();
}
V_VT(pDest) = VT_UNKNOWN;
V_UNKNOWN(pDest) = pUnknown;
} else if (vt == VT_SAFEARRAY) {
const Type &elementType = type.elementType();
V_VT(pDest) = VT_ARRAY | elementType.vartype();
V_ARRAY(pDest) = getSafeArray(elementType, interp);
} else if (m_pObj->typePtr == TclTypes::listType()) {
// Convert Tcl list to array of VARIANT.
int numElements;
Tcl_Obj **pElements;
if (Tcl_ListObjGetElements(interp, m_pObj, &numElements, &pElements)
!= TCL_OK) {
_com_issue_error(E_INVALIDARG);
}
SAFEARRAYBOUND bounds[2];
bounds[0].cElements = numElements;
bounds[0].lLbound = 0;
unsigned numDimensions;
// Check if the first element of the list is a list.
if (numElements > 0 && pElements[0]->typePtr == TclTypes::listType()) {
int colSize;
Tcl_Obj **pCol;
if (Tcl_ListObjGetElements(interp, pElements[0], &colSize, &pCol)
!= TCL_OK) {
_com_issue_error(E_INVALIDARG);
}
bounds[1].cElements = colSize;
bounds[1].lLbound = 0;
numDimensions = 2;
} else {
numDimensions = 1;
}
SAFEARRAY *psa = SafeArrayCreate(VT_VARIANT, numDimensions, bounds);
std::vector<long> indices(numDimensions);
fillSafeArray(m_pObj, psa, 1, &indices[0], interp, addRef);
V_VT(pDest) = VT_ARRAY | VT_VARIANT;
V_ARRAY(pDest) = psa;
#if TCL_MINOR_VERSION >= 1
} else if (m_pObj->typePtr == TclTypes::byteArrayType()) {
// Convert Tcl byte array to SAFEARRAY of bytes.
V_VT(pDest) = VT_ARRAY | VT_UI1;
V_ARRAY(pDest) = newSafeArray(m_pObj, VT_UI1);
#endif
} else if (m_pObj->typePtr == &Extension::naType) {
// This variant indicates a missing optional argument.
VariantCopy(pDest, &vtMissing);
} else if (m_pObj->typePtr == &Extension::nullType) {
V_VT(pDest) = VT_NULL;
} else if (m_pObj->typePtr == &Extension::variantType) {
VariantCopy(
//.........这里部分代码省略.........
示例14: isTLVAccess
bool isTLVAccess(const Reference &ref) const override {
assert(ref.kindNamespace() == Reference::KindNamespace::mach_o);
assert(ref.kindArch() == Reference::KindArch::x86_64);
return ref.kindValue() == ripRel32Tlv;
}
示例15: setOwner
void CampSiteActiveAreaImplementation::assumeOwnership(CreatureObject* player) {
if (camp == NULL || player == NULL)
return;
if (player->getSkillMod("camp") < campStructureData->getSkillRequired()) {
player->sendSystemMessage("@camp:error_too_big"); // You cannot assume ownership of this camp. You lack the skill to maintain a camp of this size.
return;
}
PlayerObject* playerGhost = player->getPlayerObject();
if (playerGhost == NULL)
return;
for (int i = 0; i < playerGhost->getTotalOwnedStructureCount(); ++i) {
uint64 oid = playerGhost->getOwnedStructure(i);
ManagedReference<StructureObject*> structure = playerGhost->getZoneServer()->getObject(oid).castTo<StructureObject*>();
if (structure->isCampStructure()) {
player->sendSystemMessage("@camp:sys_already_camping"); // But you already have a camp established elsewhere!
return;
}
}
PlayerObject* ownerGhost = campOwner->getPlayerObject();
if (ownerGhost != NULL) {
ownerGhost->removeOwnedStructure(camp);
}
setOwner(player);
abandoned = false;
currentXp = 0;
visitors.removeAll();
Reference<SortedVector<ManagedReference<QuadTreeEntry*> >*> closeObjects = new SortedVector<ManagedReference<QuadTreeEntry*> >();
zone->getInRangeObjects(camp->getWorldPositionX(), camp->getWorldPositionY(), campStructureData->getRadius(), closeObjects, true);
for (int i = 0; i < closeObjects->size(); ++i) {
SceneObject* scno = cast<SceneObject*>(closeObjects->get(i).get());
if (scno->isPlayerCreature())
visitors.add(scno->getObjectID());
}
playerGhost->addOwnedStructure(camp);
campOwner->registerObserver(ObserverEventType::STARTCOMBAT, campObserver);
Locker locker(&taskMutex);
if(abandonTask != NULL && abandonTask->isScheduled())
abandonTask->cancel();
if(despawnTask != NULL && despawnTask->isScheduled())
despawnTask->cancel();
timeCreated = System::getTime();
despawnTask->schedule(CampSiteActiveArea::DESPAWNTIME);
if(terminal != NULL) {
String campName = campOwner->getFirstName();
if(!campOwner->getLastName().isEmpty())
campName += " " + campOwner->getLastName();
campName += "'s Camp";
terminal->setCustomObjectName(campName, true);
}
player->sendSystemMessage("@camp:assuming_ownership"); //You assume ownership of the camp.
}