/* * Init instruction generation. */ jboolean initInsnSequence(int localsz, int stacksz, errorInfo* einfo) { /* Clear various counters */ tmpslot = 0; maxTemp = 0; maxPush = 0; stackno = localsz + stacksz; npc = 0; initSeq(); initRegisters(); initSlots(stackno); /* Before generating code, try to guess how much space we'll need. */ codeblock_size = ALLOCCODEBLOCKSZ; codeblock = gc_malloc(codeblock_size + CODEBLOCKREDZONE, KGC_ALLOC_JIT_CODEBLOCK); if (codeblock == 0) { postOutOfMemory(einfo); return (false); } CODEPC = 0; return (true); }
void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) { TSlots slots_; initSlots (slots_); // Disable model update during auto-equip mUpdatesEnabled = false; // Autoequip clothing, armor and weapons. // Equipping lights is handled in Actors::updateEquippedLight based on environment light. // Note: creatures do not use the armor mitigation and can equip only shields // Use a custom logic for them - select shield based on its health instead of armor rating (since it useless for creatures) autoEquipWeapon(actor, slots_); autoEquipArmor(actor, slots_); bool changed = false; for (std::size_t i=0; i<slots_.size(); ++i) { if (slots_[i] != mSlots[i]) { changed = true; break; } } mUpdatesEnabled = true; if (changed) { mSlots.swap (slots_); fireEquipmentChangedEvent(actor); updateMagicEffects(actor); flagAsModified(); } }
void FrameBuffer::init(int frameNumbers) { if( bufSize_ < frameNumbers ) bufSize_ = frameNumbers; reset(); initSlots(); }
RuleCheckWidget::RuleCheckWidget(QWidget* parent /* = NULL */) :QDialog(parent) { m_saveList = NULL; initUi(); initTable(); initSlots(); }
MWWorld::InventoryStore::InventoryStore() : mSelectedEnchantItem(end()) , mUpdatesEnabled (true) , mFirstAutoEquip(true) , mListener(NULL) { initSlots (mSlots); }
MWWorld::InventoryStore::InventoryStore() : mListener(NULL) , mUpdatesEnabled (true) , mFirstAutoEquip(true) , mSelectedEnchantItem(end()) , mRechargingItemsUpToDate(false) { initSlots (mSlots); }
Settings::Settings(QWidget *parent) : QDialog(parent) { initInterface(); initSlots(); translateInterface(); initSettings(); this->setWindowModality(Qt::ApplicationModal); this->setMinimumWidth(280); }
void App::initInterface(void) { thePanel = new QWidget(); initMenu(); initLayout(); initSlots(); radSourceFile->setChecked(true); radTargetFile->setChecked(true); this->setCentralWidget(thePanel); }
void MWWorld::InventoryStore::clear() { mSlots.clear(); initSlots (mSlots); ContainerStore::clear(); }
void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) { TSlots slots_; initSlots (slots_); // Disable model update during auto-equip mUpdatesEnabled = false; for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) { Ptr test = *iter; // Don't autoEquip lights. Handled in Actors::updateEquippedLight based on environment light. if (test.getTypeName() == typeid(ESM::Light).name()) { continue; } // Only autoEquip if we are the original owner of the item. // This stops merchants from auto equipping anything you sell to them. // ...unless this is a companion, he should always equip items given to him. if (!Misc::StringUtils::ciEqual(test.getCellRef().getOwner(), actor.getCellRef().getRefId()) && (actor.getClass().getScript(actor).empty() || !actor.getRefData().getLocals().getIntVar(actor.getClass().getScript(actor), "companion")) && !actor.getClass().getCreatureStats(actor).isDead() // Corpses can be dressed up by the player as desired ) { continue; } int testSkill = test.getClass().getEquipmentSkill (test); std::pair<std::vector<int>, bool> itemsSlots = iter->getClass().getEquipmentSlots (*iter); for (std::vector<int>::const_iterator iter2 (itemsSlots.first.begin()); iter2!=itemsSlots.first.end(); ++iter2) { if (*iter2 == Slot_CarriedRight) // Items in right hand are situational use, so don't equip them. // Equipping weapons is handled by AiCombat. Anything else (lockpicks, probes) can't be used by NPCs anyway (yet) continue; if (iter.getType() == MWWorld::ContainerStore::Type_Weapon) continue; if (slots_.at (*iter2)!=end()) { Ptr old = *slots_.at (*iter2); // check skill int oldSkill = old.getClass().getEquipmentSkill (old); bool use = false; if (testSkill!=-1 && oldSkill==-1) use = true; else if (testSkill!=-1 && oldSkill!=-1 && testSkill!=oldSkill) { if (actor.getClass().getSkill(actor, oldSkill) > actor.getClass().getSkill (actor, testSkill)) continue; // rejected, because old item better matched the NPC's skills. if (actor.getClass().getSkill(actor, oldSkill) < actor.getClass().getSkill (actor, testSkill)) use = true; } if (!use) { // check value if (old.getClass().getValue (old)>= test.getClass().getValue (test)) { continue; } } } switch(test.getClass().canBeEquipped (test, actor).first) { case 0: continue; default: break; } if (!itemsSlots.second) // if itemsSlots.second is true, item can stay stacked when equipped { // unstack item pointed to by iterator if required if (iter->getRefData().getCount() > 1) { unstack(*iter, actor); } } slots_[*iter2] = iter; break; } } bool changed = false; for (std::size_t i=0; i<slots_.size(); ++i) { if (slots_[i] != mSlots[i]) { changed = true; break; } } mUpdatesEnabled = true; if (changed) { mSlots.swap (slots_); fireEquipmentChangedEvent(actor); updateMagicEffects(actor); flagAsModified(); } }
void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) { TSlots slots_; initSlots (slots_); // Disable model update during auto-equip mUpdatesEnabled = false; for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) { Ptr test = *iter; // Don't autoEquip lights. Handled in Actors::updateEquippedLight based on environment light. if (test.getTypeName() == typeid(ESM::Light).name()) { continue; } // Don't auto-equip probes or lockpicks. NPCs can't use them (yet). And AiCombat would attempt to "attack" with them. // NOTE: In the future AiCombat should handle equipping appropriate weapons if (test.getTypeName() == typeid(ESM::Lockpick).name() || test.getTypeName() == typeid(ESM::Probe).name()) continue; // Only autoEquip if we are the original owner of the item. // This stops merchants from auto equipping anything you sell to them. // ...unless this is a companion, he should always equip items given to him. if (!Misc::StringUtils::ciEqual(test.getCellRef().getOwner(), actor.getCellRef().getRefId()) && (actor.getClass().getScript(actor).empty() || !actor.getRefData().getLocals().getIntVar(actor.getClass().getScript(actor), "companion"))) continue; int testSkill = test.getClass().getEquipmentSkill (test); std::pair<std::vector<int>, bool> itemsSlots = iter->getClass().getEquipmentSlots (*iter); for (std::vector<int>::const_iterator iter2 (itemsSlots.first.begin()); iter2!=itemsSlots.first.end(); ++iter2) { bool use = false; if (slots_.at (*iter2)==end()) use = true; // slot was empty before -> skip all further checks else { Ptr old = *slots_.at (*iter2); if (!use) { // check skill int oldSkill = old.getClass().getEquipmentSkill (old); if (testSkill!=-1 && oldSkill==-1) use = true; else if (testSkill!=-1 && oldSkill!=-1 && testSkill!=oldSkill) { if (actor.getClass().getSkill(actor, oldSkill) > actor.getClass().getSkill (actor, testSkill)) continue; // rejected, because old item better matched the NPC's skills. if (actor.getClass().getSkill(actor, oldSkill) < actor.getClass().getSkill (actor, testSkill)) use = true; } } if (!use) { // check value if (old.getClass().getValue (old)>= test.getClass().getValue (test)) { continue; } use = true; } } switch(test.getClass().canBeEquipped (test, actor).first) { case 0: continue; case 2: slots_[MWWorld::InventoryStore::Slot_CarriedLeft] = end(); break; case 3: // Prefer keeping twohanded weapon break; } if (!itemsSlots.second) // if itemsSlots.second is true, item can stay stacked when equipped { // unstack item pointed to by iterator if required if (iter->getRefData().getCount() > 1) { unstack(*iter, actor); } } slots_[*iter2] = iter; break; } } bool changed = false; for (std::size_t i=0; i<slots_.size(); ++i) if (slots_[i]!=mSlots[i]) { changed = true; } mUpdatesEnabled = true; if (changed) { mSlots.swap (slots_); fireEquipmentChangedEvent(); updateMagicEffects(actor); flagAsModified(); } }
/** * Author: Joel Denke, Marcus Isaksson * Description: Run the game on client */ int main(int argc, char *argv[]) { int i, j, no, yb, keysHeld[323] = {0}; int result = 0; SDL_Thread * eventBuffer; SDL_Thread * runBuffer; struct timer_t2 fps; char * server_ip = malloc(sizeof(char) * 16); char * elem = malloc(sizeof(char) * MESSAGE_SIZE); pColor = malloc(sizeof(SDL_Color)); oColor = malloc(sizeof(SDL_Color)); connection = malloc(sizeof(connection_data)); for (i = 0; i < NO_BUFFERS; i++) { cb[i] = malloc(sizeof(cBuffer)); b_lock[i] = SDL_CreateMutex(); } strcpy(server_ip, "127.0.0.1"); pColor->r = 0; pColor->g = 255; pColor->b = 255; oColor->r = 0; oColor->g = 0; oColor->b = 255; initGraphics(); initSound(); printf("Render menu\n"); graphicsMenu(&gameWorld, server_ip); initSlots(cb[0], BUFFER_SIZE); initSlots(cb[1], NO_OBJECTS); initSlots(cb[2], BUFFER_SIZE); state = gStart; if (clientConnect(connection, server_ip) == 0) { eventBuffer = SDL_CreateThread(listenEventBuffer, &connection); while (1) { switch (state) { case gStart: runData(2); break; case gInit: timer_start(&fps); startDraw(); drawLoadScr(SCREEN_WIDTH, SCREEN_HEIGHT); endDraw(); initWorld(); if (timer_get_ticks(&fps) < 1000 / FPS) { //delay the as much time as we need to get desired frames per second SDL_Delay( ( 1000 / FPS ) - timer_get_ticks(&fps) ); } break; case gRunning : timer_start(&fps); drawGraphics(); listenInput(keysHeld); // i = 0: players; i = 1: objects; i = 2: messages for (i = 0; i < NO_BUFFERS; i++) { runData(i); } if (timer_get_ticks(&fps) < 1000 / FPS) { //delay the as much time as we need to get desired frames per second SDL_Delay( ( 1000 / FPS ) - timer_get_ticks(&fps) ); } break; case gExit : //sprintf(string, "%d,quit", connection->client_id); printf("Freeing music now\n"); pauseMusic(); freeMusic(); end_session(connection); printf("Player is exit game now\n"); exitClient(eventBuffer); break; default : printf("test\n"); break; } } } else { printf("Misslyckade med att kontakta servern på ip-adress: '%s'\n", server_ip); state = gExit; pauseMusic(); freeMusic(); exitClient(eventBuffer); } return 0; }
void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats) { TSlots slots; initSlots (slots); for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) { Ptr test = *iter; int testSkill = MWWorld::Class::get (test).getEquipmentSkill (test); std::pair<std::vector<int>, bool> itemsSlots = MWWorld::Class::get (*iter).getEquipmentSlots (*iter); for (std::vector<int>::const_iterator iter2 (itemsSlots.first.begin()); iter2!=itemsSlots.first.end(); ++iter2) { bool use = false; if (slots.at (*iter2)==end()) use = true; // slot was empty before -> skill all further checks else { Ptr old = *slots.at (*iter2); if (!use) { // check skill int oldSkill = MWWorld::Class::get (old).getEquipmentSkill (old); if (testSkill!=-1 || oldSkill!=-1 || testSkill!=oldSkill) { if (stats.mSkill[oldSkill].getModified()>stats.mSkill[testSkill].getModified()) continue; // rejected, because old item better matched the NPC's skills. if (stats.mSkill[oldSkill].getModified()<stats.mSkill[testSkill].getModified()) use = true; } } if (!use) { // check value if (MWWorld::Class::get (old).getValue (old)>= MWWorld::Class::get (test).getValue (test)) { continue; } use = true; } } /// \todo unstack, if reqquired (itemsSlots.second) slots[*iter2] = iter; break; } } bool changed = false; for (std::size_t i=0; i<slots.size(); ++i) if (slots[i]!=mSlots[i]) { changed = true; } if (changed) { mSlots.swap (slots); flagAsModified(); } }
MWWorld::InventoryStore::InventoryStore() { initSlots (mSlots); }
UdpListener::UdpListener(QObject *parent) : UdpNetworkSocket(parent) { _break = false; initSlots(); }
Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) #endif : QMainWindow() { showMainList=TRUE; working=false; this->setUpdatesEnabled(TRUE); QString msg; msg="You have now entered unto gutenbrowser,\n"; msg+="make your self at home, sit back, relax and read something great.\n"; local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; setCaption("Gutenbrowser");// Embedded " VERSION); this->setUpdatesEnabled(TRUE); topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); menu = new QHBoxLayout(-1,"menu"); buttons2 = new QHBoxLayout(-1,"buttons2"); edits = new QHBoxLayout(-1,"edits"); useSplitter=TRUE; initConfig(); initMenuBar(); initButtonBar(); initStatusBar(); initView(); initSlots(); qDebug("init finished"); QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); if( useIcons) toggleButtonIcons( TRUE); else toggleButtonIcons( FALSE); enableButtons(false); Config config("Gutenbrowser"); // populate menubuttonlist config.setGroup("General"); config.setGroup( "Files" ); QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); int i_numofFiles = s_numofFiles.toInt(); QString tempFileName; for (int i = 0; i <= i_numofFiles; i++) { config.setGroup( "Files" ); QString ramble = config.readEntry( QString::number(i), "" ); config.setGroup( "Titles" ); QString tempTitle = config.readEntry( ramble, ""); config.setGroup( tempTitle); int index = config.readNumEntry( "LineNumber", -1 ); if( index != -1) { odebug << tempTitle << oendl; if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); } } QString gutenIndex = local_library + "/GUTINDEX.ALL"; qDebug("gutenindex "+gutenIndex ); if( QFile( gutenIndex).exists() ) indexLib.setName( gutenIndex); else { QString localLibIndexFile = local_library + "/PGWHOLE.TXT"; newindexLib.setName( localLibIndexFile); } qDebug("attempting new library"); LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); loadCheck = false; chdir(local_library); if(!showMainList) { Lview->setFocus(); for (int i=1;i< qApp->argc();i++) { qDebug("Suppose we open somethin"); if(!load(qApp->argv()[i])) return; } } else { fillWithTitles(); mainList->setFocus(); } writeConfig(); QTimer::singleShot( 250, this, SLOT(hideView()) ); }
void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) { const MWBase::World *world = MWBase::Environment::get().getWorld(); const MWWorld::Store<ESM::GameSetting> &store = world->getStore().get<ESM::GameSetting>(); MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor); static float fUnarmoredBase1 = store.find("fUnarmoredBase1")->mValue.getFloat(); static float fUnarmoredBase2 = store.find("fUnarmoredBase2")->mValue.getFloat(); int unarmoredSkill = stats.getSkill(ESM::Skill::Unarmored).getModified(); float unarmoredRating = (fUnarmoredBase1 * unarmoredSkill) * (fUnarmoredBase2 * unarmoredSkill); TSlots slots_; initSlots (slots_); // Disable model update during auto-equip mUpdatesEnabled = false; // Autoequip clothing, armor and weapons. // Equipping lights is handled in Actors::updateEquippedLight based on environment light. for (ContainerStoreIterator iter (begin(ContainerStore::Type_Clothing | ContainerStore::Type_Armor)); iter!=end(); ++iter) { Ptr test = *iter; if (!canActorAutoEquip(actor, test)) continue; switch(test.getClass().canBeEquipped (test, actor).first) { case 0: continue; default: break; } if (iter.getType() == ContainerStore::Type_Armor && test.getClass().getEffectiveArmorRating(test, actor) <= std::max(unarmoredRating, 0.f)) { continue; } std::pair<std::vector<int>, bool> itemsSlots = iter->getClass().getEquipmentSlots (*iter); // checking if current item poited by iter can be equipped for (std::vector<int>::const_iterator iter2 (itemsSlots.first.begin()); iter2!=itemsSlots.first.end(); ++iter2) { // if true then it means slot is equipped already // check if slot may require swapping if current item is more valueable if (slots_.at (*iter2)!=end()) { Ptr old = *slots_.at (*iter2); if (iter.getType() == ContainerStore::Type_Armor) { if (old.getTypeName() == typeid(ESM::Armor).name()) { if (old.get<ESM::Armor>()->mBase->mData.mType < test.get<ESM::Armor>()->mBase->mData.mType) continue; if (old.get<ESM::Armor>()->mBase->mData.mType == test.get<ESM::Armor>()->mBase->mData.mType) { if (old.getClass().getEffectiveArmorRating(old, actor) >= test.getClass().getEffectiveArmorRating(test, actor)) // old armor had better armor rating continue; } } // suitable armor should replace already equipped clothing } else if (iter.getType() == ContainerStore::Type_Clothing) { // if left ring is equipped if (*iter2 == Slot_LeftRing) { // if there is a place for right ring dont swap it if (slots_.at(Slot_RightRing) == end()) { continue; } else // if right ring is equipped too { Ptr rightRing = *slots_.at(Slot_RightRing); // we want to swap cheaper ring only if both are equipped if (old.getClass().getValue (old) >= rightRing.getClass().getValue (rightRing)) continue; } } if (old.getTypeName() == typeid(ESM::Clothing).name()) { // check value if (old.getClass().getValue (old) >= test.getClass().getValue (test)) // old clothing was more valuable continue; } else // suitable clothing should NOT replace already equipped armor continue; } } if (!itemsSlots.second) // if itemsSlots.second is true, item can stay stacked when equipped { // unstack item pointed to by iterator if required if (iter->getRefData().getCount() > 1) { unstack(*iter, actor); } } // if we are here it means item can be equipped or swapped slots_[*iter2] = iter; break; } } static const ESM::Skill::SkillEnum weaponSkills[] = { ESM::Skill::LongBlade, ESM::Skill::Axe, ESM::Skill::Spear, ESM::Skill::ShortBlade, ESM::Skill::Marksman, ESM::Skill::BluntWeapon }; const size_t weaponSkillsLength = sizeof(weaponSkills) / sizeof(weaponSkills[0]); bool weaponSkillVisited[weaponSkillsLength] = { false }; for (int i = 0; i < static_cast<int>(weaponSkillsLength); ++i) { int max = 0; int maxWeaponSkill = -1; for (int j = 0; j < static_cast<int>(weaponSkillsLength); ++j) { int skillValue = stats.getSkill(static_cast<int>(weaponSkills[j])).getModified(); if (skillValue > max && !weaponSkillVisited[j]) { max = skillValue; maxWeaponSkill = j; } } if (maxWeaponSkill == -1) break; max = 0; ContainerStoreIterator weapon(end()); for (ContainerStoreIterator iter(begin(ContainerStore::Type_Weapon)); iter!=end(); ++iter) { if (!canActorAutoEquip(actor, *iter)) continue; const ESM::Weapon* esmWeapon = iter->get<ESM::Weapon>()->mBase; if (esmWeapon->mData.mType == ESM::Weapon::Arrow || esmWeapon->mData.mType == ESM::Weapon::Bolt) continue; if (iter->getClass().getEquipmentSkill(*iter) == weaponSkills[maxWeaponSkill]) { if (esmWeapon->mData.mChop[1] >= max) { max = esmWeapon->mData.mChop[1]; weapon = iter; } if (esmWeapon->mData.mSlash[1] >= max) { max = esmWeapon->mData.mSlash[1]; weapon = iter; } if (esmWeapon->mData.mThrust[1] >= max) { max = esmWeapon->mData.mThrust[1]; weapon = iter; } } } if (weapon != end() && weapon->getClass().canBeEquipped(*weapon, actor).first) { std::pair<std::vector<int>, bool> itemsSlots = weapon->getClass().getEquipmentSlots (*weapon); if (!itemsSlots.first.empty()) { if (!itemsSlots.second) { if (weapon->getRefData().getCount() > 1) { unstack(*weapon, actor); } } int slot = itemsSlots.first.front(); slots_[slot] = weapon; } break; } weaponSkillVisited[maxWeaponSkill] = true; } bool changed = false; for (std::size_t i=0; i<slots_.size(); ++i) { if (slots_[i] != mSlots[i]) { changed = true; break; } } mUpdatesEnabled = true; if (changed) { mSlots.swap (slots_); fireEquipmentChangedEvent(actor); updateMagicEffects(actor); flagAsModified(); } }