예제 #1
0
파일: Item.cpp 프로젝트: Artea/mangos-svn
void Item::LoadFromDB(uint32 guid, uint32 auctioncheck)
{
    std::stringstream ss;
    if (auctioncheck == 1)
    {
        ss << "SELECT data FROM item_instances WHERE guid = " << guid;
    }
    else if (auctioncheck == 2)
    {
        ss << "SELECT data FROM auctioned_items WHERE guid = " << guid;
    }
    else
    {
        ss << "SELECT data FROM mailed_items WHERE guid = " << guid;
    }

    QueryResult *result = sDatabase.Query( ss.str().c_str() );
    if(result==NULL)
        return;
    //ASSERT(result);

    Field *fields = result->Fetch();

    LoadValues( fields[0].GetString() );

    delete result;

    m_itemProto = objmgr.GetItemPrototype( GetUInt32Value(OBJECT_FIELD_ENTRY) );
    ASSERT(m_itemProto);

}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectNodeTrack::LoadRendererParameter(unsigned char*& pos, Setting* setting)
{
	int32_t type = 0;
	memcpy( &type, pos, sizeof(int) );
	pos += sizeof(int);
	assert( type == GetType() );
	EffekseerPrintDebug("Renderer : Track\n");

	int32_t size = 0;

	
	LoadValues( TrackSizeFor, pos );
	LoadValues( TrackSizeMiddle, pos );
	LoadValues( TrackSizeBack, pos );

	TrackColorLeft.load( pos, m_effect->GetVersion() );
	TrackColorLeftMiddle.load( pos, m_effect->GetVersion() );

	TrackColorCenter.load( pos, m_effect->GetVersion() );
	TrackColorCenterMiddle.load( pos, m_effect->GetVersion() );

	TrackColorRight.load( pos, m_effect->GetVersion() );
	TrackColorRightMiddle.load( pos, m_effect->GetVersion() );

	AlphaBlend = Texture.AlphaBlend;
	TrackTexture = Texture.ColorTextureIndex;

	EffekseerPrintDebug("TrackColorLeft : %d\n", TrackColorLeft.type );
	EffekseerPrintDebug("TrackColorLeftMiddle : %d\n", TrackColorLeftMiddle.type );
	EffekseerPrintDebug("TrackColorCenter : %d\n", TrackColorCenter.type );
	EffekseerPrintDebug("TrackColorCenterMiddle : %d\n", TrackColorCenterMiddle.type );
	EffekseerPrintDebug("TrackColorRight : %d\n", TrackColorRight.type );
	EffekseerPrintDebug("TrackColorRightMiddle : %d\n", TrackColorRightMiddle.type );

	// 右手系左手系変換
	if (setting->GetCoordinateSystem() == CoordinateSystem::LH)
	{
	}

	/* 位置拡大処理 */
	if( m_effect->GetVersion() >= 8 )
	{
		TrackSizeFor.fixed.size *= m_effect->GetMaginification();
		TrackSizeMiddle.fixed.size *= m_effect->GetMaginification();
		TrackSizeBack.fixed.size *= m_effect->GetMaginification();
	}
}
예제 #3
0
bool Corpse::LoadFromDB(uint32 guid, Field *fields)
{
    //                                          0          1          2          3           4   5    6    7           8        9
    //result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,data,time,corpse_type,instance,phaseMask FROM corpse WHERE guid = '%u'",guid);
    float positionX = fields[0].GetFloat();
    float positionY = fields[1].GetFloat();
    float positionZ = fields[2].GetFloat();
    float ort       = fields[3].GetFloat();
    uint32 mapid    = fields[4].GetUInt32();

    Object::_Create(guid, 0, HIGHGUID_CORPSE);

    if(!LoadValues( fields[5].GetString() ))
    {
        sLog.outError("Corpse #%d have broken data in `data` field. Can't be loaded.",guid);
        return false;
    }

    m_time = time_t(fields[6].GetUInt64());
    m_type = CorpseType(fields[7].GetUInt32());

    if(m_type >= MAX_CORPSE_TYPE)
    {
        sLog.outError("Corpse (guidlow %d, owner %d) have wrong corpse type, not load.",GetGUIDLow(),GUID_LOPART(GetOwnerGUID()));
        return false;
    }

    if(m_type != CORPSE_BONES)
        m_isWorldObject = true;

    uint32 instanceid  = fields[8].GetUInt32();

    uint32 phaseMask   = fields[9].GetUInt32();

    // overwrite possible wrong/corrupted guid
    SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE));

    // place
    SetLocationInstanceId(instanceid);
    SetLocationMapId(mapid);
    SetPhaseMask(phaseMask, false);
    Relocate(positionX, positionY, positionZ, ort);

    if(!IsPositionValid())
    {
        sLog.outError("Corpse (guidlow %d, owner %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
            GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), GetPositionX(), GetPositionY());
        return false;
    }

    m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY());

    return true;
}
예제 #4
0
void SoundBankEdit::GetParams()
{
	LoadValues();
	SynthWidget *wdg = mainGroup->FindID(2);
	wdg->SetText(sb->GetSoundFile());
	wdg = mainGroup->FindID(6);
	wdg->SetText(sb->GetInstrName());
	float bank = 0;
	float preset = 0;
	sb->GetParam(16, &bank);
	sb->GetParam(17, &preset);
	//ListPitches(bank, preset);
}
예제 #5
0
void MIDIControlEd::GetParams()
{
	sbFile = theProject->midiInfo->GetSoundBankFile();
	if (sbFile.Length() == 0)
	{
		SoundBank *sb = SoundBank::SoundBankList.next;
		if (sb)
			sbFile = sb->name;
	}
	SynthWidget *wdg = mainGroup->FindID(2);
	if (wdg)
		wdg->SetText(sbFile);
	LoadValues();
}
예제 #6
0
void WFSynthEdit::ValueChanged(SynthWidget *wdg)
{
	switch (wdg->GetID())
	{
	case 100: // Set
		SetParams();
		break;
	case 101: // Restore
		tone->SetParams(save);
		LoadValues();
		Redraw(0);
		break;
	default:
		SynthEdit::ValueChanged(wdg);
		break;
	}
}
예제 #7
0
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
{
	//sLog.outDebug("Item::LoadFromDB guid %u, owner %u", guid, owner_guid);
	bool delete_result = false;
	if(!result)
	{
		result = CharacterDatabase.PQuery("SELECT data FROM item_instance WHERE guid = '%u'", guid);
		delete_result = true;
	}

	if(!result)
	{
		sLog.outError("ERROR: Item (GUID: %u owner: %u) not found in table `item_instance`, can't load.", guid, GUID_LOPART(owner_guid));
		return false;
	}

	Field *f = result->Fetch();

	_Create(guid, HIGHGUID_ITEM);

	if(!LoadValues(f[0].GetString()))
	{
		sLog.outError("ERROR: Item #%d have broken data in `data` field. Can't be loaded.", guid);
		if(delete_result) delete result;
		return false;
	}

	// Load item values
	//SetUInt32Value(OBJECT_FIELD_ENTRY, f[0].GetUInt32());

	//SetUInt32Value(ITEM_FIELD_STACK_COUNT, f[2].GetUInt32());

	// overwrite possible wrong/corrupted guid
	SetUInt64Value(OBJECT_FIELD_GUID,MAKE_GUID(guid,HIGHGUID_ITEM));

	if(delete_result) delete result;

	if(owner_guid != 0)
		SetOwnerGUID(owner_guid);

	return true;
}
예제 #8
0
void Creature::LoadFromDB(uint32 guid)
{

    std::stringstream ss;
    ss << "SELECT * FROM creatures WHERE id=" << guid;

    QueryResult *result = sDatabase.Query( ss.str().c_str() );
    ASSERT(result);

    Field *fields = result->Fetch();

    

    Create(fields[8].GetUInt32(), objmgr.GetCreatureName(fields[8].GetUInt32())->Name.c_str(), fields[6].GetUInt32(),
        fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat(), fields[8].GetUInt32());

    m_zoneId = fields[5].GetUInt32();

    m_moveRandom = fields[9].GetBool();
    m_moveRun = fields[10].GetBool();

    LoadValues(fields[7].GetString());
    
    
    SetNameId(fields[8].GetUInt32());
    _RealtimeSetCreatureInfo();

    delete result;

    if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR ) )
        _LoadGoods();

    if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER ) )
        _LoadQuests();

    
    SetUInt32Value( OBJECT_FIELD_GUID+1, HIGHGUID_UNIT );
    AIM_Initialize();

}
예제 #9
0
파일: Pet.cpp 프로젝트: AwkwardDev/WoWD
void Pet::LoadFromDB(Player* owner, PlayerPet * pi)
{
    m_Owner = owner;
    m_OwnerGuid = m_Owner->GetGUID();
    mPi = pi;

    Create(pi->name.c_str(), owner->GetMapId(), owner->GetPositionX() + 2 , owner->GetPositionY() +2, owner->GetPositionZ(), owner->GetOrientation());

    LoadValues(mPi->fields.c_str());
    m_PetNumber = mPi->number;
    m_PetXP = mPi->xp;
    Summon = mPi->summon;
    SetPowerType(POWER_TYPE_FOCUS);
    SetIsPet(true);

    // Setup actionbar
    uint32 pos = 0;
    string::size_type sp = mPi->actionbar.find(",");
    string::size_type lp = 0;
    while(sp != string::npos)
    {
        uint32 spell = atol(mPi->actionbar.substr(lp, sp).c_str());
        ActionBar[pos] = spell;
        ++pos;

        lp = sp+1;
        sp = mPi->actionbar.find(",", lp);
    }

    SetIsPet(true);
    InitializeMe(false);
    bExpires = false;   
    if(pi->autocastspell)
    {
        AI_Spell * sp = GetAISpellForSpellId(pi->autocastspell);
        if(sp)
            m_aiInterface->SetDefaultSpell(sp);
    }
}
예제 #10
0
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, uint32 auctioncheck)
{
    QueryResult *result;

    if (auctioncheck == 1)
    {
        result = sDatabase.PQuery("SELECT `data` FROM `item_instance` WHERE `guid` = '%u'", guid);
    }
    else if (auctioncheck == 2)
    {
        result = sDatabase.PQuery("SELECT `data` FROM `auctionhouse_item` WHERE `guid` = '%u'", guid);
    }
    else
    {
        result = sDatabase.PQuery("SELECT `data` FROM `mail_item` WHERE `guid` = '%u'", guid);
    }

    if (!result) return false;

    Field *fields = result->Fetch();

    if(!LoadValues(fields[0].GetString()))
    {
        sLog.outError("ERROR: Item #%d have broken data in `data` field. Can't be loaded.",guid);
        delete result;
        return false;
    }

    if(auctioncheck==1 && GetOwnerGUID()!=owner_guid)
    {
        sLog.outError("Item::LoadFromDB: item: %u have in DB owner guid: %u. Updated to correct: %u",GetGUIDLow(),GUID_LOPART(GetOwnerGUID()), GUID_LOPART(owner_guid));
        SetOwnerGUID(owner_guid);
    }

    delete result;

    return true;
}
예제 #11
0
파일: Item.cpp 프로젝트: 1ATOM/mangos
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
{
    // create item before any checks for store correct guid
    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
    Object::_Create(guid, 0, HIGHGUID_ITEM);

    bool delete_result = false;
    if(!result)
    {
        result = CharacterDatabase.PQuery("SELECT data FROM item_instance WHERE guid = '%u'", guid);
        delete_result = true;
    }

    if (!result)
    {
        sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ",guid,GUID_LOPART(owner_guid));
        return false;
    }

    Field *fields = result->Fetch();

    if(!LoadValues(fields[0].GetString()))
    {
        sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.",guid);
        if (delete_result) delete result;
        return false;
    }

    bool need_save = false;                                 // need explicit save data at load fixes

    // overwrite possible wrong/corrupted guid
    uint64 new_item_guid = MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM);
    if(GetUInt64Value(OBJECT_FIELD_GUID) != new_item_guid)
    {
        SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM));
        need_save = true;
    }

    if (delete_result) delete result;

    ItemPrototype const* proto = GetProto();
    if(!proto)
        return false;

    // update max durability (and durability) if need
    if(proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
    {
        SetUInt32Value(ITEM_FIELD_MAXDURABILITY,proto->MaxDurability);
        if(GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
            SetUInt32Value(ITEM_FIELD_DURABILITY,proto->MaxDurability);

        need_save = true;
    }

    // recalculate suffix factor
    if(GetItemRandomPropertyId() < 0)
    {
        if(UpdateItemSuffixFactor())
            need_save = true;
    }

    // Remove bind flag for items vs NO_BIND set
    if (IsSoulBound() && proto->Bonding == NO_BIND)
    {
        ApplyModFlag(ITEM_FIELD_FLAGS,ITEM_FLAGS_BINDED, false);
        need_save = true;
    }

    // update duration if need, and remove if not need
    if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))
    {
        SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
        need_save = true;
    }

    // set correct owner
    if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
    {
        SetOwnerGUID(owner_guid);
        need_save = true;
    }

    if (need_save)                                          // normal item changed state set not work at loading
    {
        std::ostringstream ss;
        ss << "UPDATE item_instance SET data = '";
        for(uint16 i = 0; i < m_valuesCount; ++i )
            ss << GetUInt32Value(i) << " ";
        ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guid << "'";

        CharacterDatabase.Execute( ss.str().c_str() );
    }

    return true;
}
예제 #12
0
파일: Item.cpp 프로젝트: Splash/mangos
bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
{
    // create item before any checks for store correct guid
    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
    Object::_Create(ObjectGuid(HIGHGUID_ITEM, guidLow));

    if (!LoadValues(fields[0].GetString()))
    {
        sLog.outError("Item::LoadFromDB: %s have broken data in `data` field. Can't be loaded.", GetGuidStr().c_str());
        return false;
    }

    SetText(fields[1].GetCppString());

    bool needSave = false;                                  // need explicit save data at load fixes

    // overwrite possible wrong/corrupted guid
    ObjectGuid new_item_guid = ObjectGuid(HIGHGUID_ITEM, guidLow);
    if (GetGuidValue(OBJECT_FIELD_GUID) != new_item_guid)
    {
        SetGuidValue(OBJECT_FIELD_GUID, new_item_guid);
        needSave = true;
    }

    ItemPrototype const* proto = GetProto();
    if (!proto)
        return false;

    // update max durability (and durability) if need
    if (proto->MaxDurability != GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
    {
        SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);
        if (GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
            SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);

        needSave = true;
    }

    // recalculate suffix factor
    if (GetItemRandomPropertyId() < 0)
    {
        if (UpdateItemSuffixFactor())
            needSave = true;
    }

    // Remove bind flag for items vs NO_BIND set
    if (IsSoulBound() && proto->Bonding == NO_BIND)
    {
        ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED, false);
        needSave = true;
    }

    // update duration if need, and remove if not need
    if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))
    {
        SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
        needSave = true;
    }

    // set correct owner
    if (ownerGuid && GetOwnerGuid() != ownerGuid)
    {
        SetOwnerGuid(ownerGuid);
        needSave = true;
    }

    // set correct wrapped state
    if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
    {
        // wrapped item must be wrapper (used version that not stackable)
        if (!(proto->Flags & ITEM_FLAG_WRAPPER) || GetMaxStackCount() > 1)
        {
            RemoveFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED);
            needSave = true;

            // also cleanup for sure gift table
            DeleteGiftsFromDB();
        }
    }

    if (needSave)                                          // normal item changed state set not work at loading
    {
        std::ostringstream ss;
        for (uint16 i = 0; i < m_valuesCount; ++i)
            ss << GetUInt32Value(i) << " ";

        static SqlStatementID updItem;
        SqlStatement stmt = CharacterDatabase.CreateStatement(updItem, "UPDATE item_instance SET owner_guid = ?, data = ? WHERE guid = ?");
        stmt.PExecute(GetOwnerGuid().GetCounter(), ss.str().c_str(), guidLow);
    }

    return true;
}
예제 #13
0
		TransportProtocolTypesDef()
		{ LoadValues(); }
예제 #14
0
		HeaderConversionsDef ()
		{ LoadValues(); }
예제 #15
0
BOOL CTransactionManager::Initialize()
{
    LoadValues();
    ResolveTimeoutTransaction(TRUE);
	return TRUE;
}
예제 #16
0
파일: Item.cpp 프로젝트: Scergo/zero
bool Item::LoadFromDB(uint32 guidLow, uint64 owner_guid, Field *fields)
{
    // create item before any checks for store correct guid
    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
    Object::_Create(guidLow, 0, HIGHGUID_ITEM);

    if (!LoadValues(fields[0].GetString()))
    {
        sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.", guidLow);
        return false;
    }

    bool need_save = false;                                 // need explicit save data at load fixes

    // overwrite possible wrong/corrupted guid
    ObjectGuid new_item_guid = ObjectGuid(HIGHGUID_ITEM, guidLow);
    if (GetGuidValue(OBJECT_FIELD_GUID) != new_item_guid)
    {
        SetGuidValue(OBJECT_FIELD_GUID, new_item_guid);
        need_save = true;
    }

    ItemPrototype const* proto = GetProto();
    if(!proto)
        return false;

    // update max durability (and durability) if need
    if(proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
    {
        SetUInt32Value(ITEM_FIELD_MAXDURABILITY,proto->MaxDurability);
        if(GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
            SetUInt32Value(ITEM_FIELD_DURABILITY,proto->MaxDurability);

        need_save = true;
    }

    // Remove bind flag for items vs NO_BIND set
    if (IsSoulBound() && proto->Bonding == NO_BIND)
    {
        ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED, false);
        need_save = true;
    }

    // update duration if need, and remove if not need
    if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))
    {
        SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
        need_save = true;
    }

    // set correct owner
    if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
    {
        SetOwnerGUID(owner_guid);
        need_save = true;
    }

    // set correct wrapped state
    if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
    {
        // wrapped item must be wrapper (used version that not stackable)
        if (!(proto->Flags & ITEM_FLAG_WRAPPER) || GetMaxStackCount() > 1)
        {
            RemoveFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED);
            need_save = true;

            // also cleanup for sure gift table
            CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
        }
    }

    if (need_save)                                          // normal item changed state set not work at loading
    {
        std::ostringstream ss;
        ss << "UPDATE item_instance SET data = '";
        for(uint16 i = 0; i < m_valuesCount; ++i )
            ss << GetUInt32Value(i) << " ";
        ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guidLow << "'";

        CharacterDatabase.Execute( ss.str().c_str() );
    }

    return true;
}