Esempio n. 1
0
void Tribe::LoadAsset(iResultRow &row)
{

    Asset* asset = new Asset();
    asset->id = row.GetInt("id");
    asset->name = row["name"];
    asset->type = (AssetType)(row.GetInt("type"));
    csVector3 coords;
    coords[0] = row.GetFloat("coordX");
    coords[1] = row.GetFloat("coordY");
    coords[2] = row.GetFloat("coordZ");
    asset->pos = coords;
    asset->item = NULL;
    asset->itemUID = row.GetInt("itemID");
    asset->sectorName = row["sector_name"];
    // Try to find the sector. Will probably fail at this point.
    if(!asset->sectorName.IsEmpty())
    {
        asset->sector = npcclient->GetEngine()->FindSector(asset->sectorName);
    }
    else
    {
        asset->sector = NULL;
    }
    asset->status = (AssetStatus)(row.GetInt("status"));
    asset->quantity = row.GetInt("quantity");

    assets.Push(asset);
}
Esempio n. 2
0
bool Tribe::Load(iResultRow &row)
{
    id                              = row.GetInt("id");
    name                            = row["name"];
    // Add tribal recipe
    tribalRecipe = new RecipeTreeNode(recipeManager->GetRecipe(row.GetInt("tribal_recipe")),0);

    homePos                         = csVector3(row.GetFloat("home_x"),row.GetFloat("home_y"),row.GetFloat("home_z"));
    homeRadius                      = row.GetFloat("home_radius");
    homeSectorName                  = row["home_sector_name"];
    maxSize                         = row.GetInt("max_size");
    wealthResourceName              = row["wealth_resource_name"];
    wealthResourceNick              = row["wealth_resource_nick"];
    wealthResourceArea              = row["wealth_resource_area"];

    wealthGatherNeed                = row["wealth_gather_need"];

    wealthResourceGrowth            = row.GetFloat("wealth_resource_growth");
    wealthResourceGrowthActive      = row.GetFloat("wealth_resource_growth_active");
    wealthResourceGrowthActiveLimit = row.GetInt("wealth_resource_growth_active_limit");

    reproductionCost                = row.GetInt("reproduction_cost");
    npcIdleBehavior                 = row["npc_idle_behavior"];

    return true;
}
Esempio n. 3
0
bool Tribe::LoadResource(iResultRow &row)
{
    Resource newRes;
    newRes.id     = row.GetInt("id");
    newRes.name   = row["name"];
    newRes.amount = row.GetInt("amount");
    newRes.nick   = row["nick"];
    resources.Push(newRes);

    return true;
}
Esempio n. 4
0
bool psTradeCombinations::Load(iResultRow& row)
{
    id          = row.GetUInt32("id");
    patternId   = row.GetUInt32("pattern_id");
    resultId    = row.GetUInt32("result_id");
    resultQty   = row.GetInt("result_qty");
    itemId      = row.GetUInt32("item_id");
    minQty      = row.GetInt("min_qty");
    maxQty      = row.GetInt("max_qty");

    return true;
}
Esempio n. 5
0
bool psTradeTransformations::Load(iResultRow& row)
{
    id              = row.GetUInt32("id");
    patternId       = row.GetUInt32("pattern_id");
    processId       = row.GetUInt32("process_id");
    resultId        = row.GetUInt32("result_id");
    resultQty       = row.GetInt("result_qty");
    itemId          = row.GetUInt32("item_id");
    itemQty         = row.GetInt("item_qty");
    transPoints     = row.GetInt("trans_points");
    penaltyPct     = row.GetFloat("penalty_pct");
    return true;
}
Esempio n. 6
0
bool psAttack::Load(iResultRow& row)
{
    id = row.GetInt("id");
    name = row["name"];
    image = row["image_name"];
    animation = row["attack_anim"];
    description = row["attack_description"];

    MathScriptEngine* mse = psserver->GetMathScriptEngine();
    damage_script = mse->FindScript(row["damage"]);
    if(!damage_script)
        return false;

    unsigned id = atoi(row["attackType"]);
    type = psserver->GetCacheManager()->GetAttackTypeByID(id);

    attackDelay = MathExpression::Create(row["delay"], "attackDelay");
    attackRange = MathExpression::Create(row["range"], "attackRange");
    aoeRadius = MathExpression::Create(row["aoe_radius"], "aoeRadius");
    aoeAngle = MathExpression::Create(row["aoe_angle"], "aoeAngle");
    outcome = psserver->GetProgressionManager()->FindScript(row["outcome"]);

    const char* req = row["requirements"];
    if(req && req[0] && !LoadPrerequisiteXML(requirements, NULL, req))
    {
        return false;
    }

    if(type)
        TypeRequirements.AttachNew(new psPrereqOpAttackType(type));
    return true;
}
Esempio n. 7
0
bool Tribe::LoadMember(iResultRow &row)
{
    MemberID mID;
    mID.pid               = row.GetInt("member_id");
    mID.tribeMemberType   = row["member_type"];

    membersId.Push(mID);

    return true;
}
Esempio n. 8
0
bool psQuest::Load(iResultRow& row)
{
    id   = row.GetInt("id");
    name = row["name"];
    task = row["task"];
    flags = row.GetInt("flags");
    step_id = row.GetInt("minor_step_number");
    category = row["category"];
    prerequisiteStr = row["prerequisite"];

    if(flags & PSQUEST_DISABLED_QUEST) //the quest is set as disabled
        Active(false);

    parent_quest = CacheManager::GetSingleton().GetQuestByID( row.GetUInt32("master_quest_id") );

    image = row["cstr_icon"];
    if(!image)
    {
        Error2("Invalid 'cstr_icon' for quest '%s'\n", name.GetData());
    }
    CacheManager::GetSingleton().AddCommonStringID(image);

    // the value is expressed in seconds
    int lockout_time = row.GetInt("player_lockout_time");
    if (lockout_time < 0)
    {
        infinitePlayerLockout = true;
        player_lockout_time = 0;
    }
    else
    {
        infinitePlayerLockout = false;
        player_lockout_time = lockout_time;
    }

    quest_lockout_time  = row.GetInt("quest_lockout_time");

    return true;
}
Esempio n. 9
0
bool psTradeProcesses::Load(iResultRow& row)
{
    processId       = row.GetUInt32("process_id");
    subprocess      = row.GetInt("subprocess_number");
    name            = row["name"];
    animation       = row["animation"];
    workItemId      = row.GetUInt32("workitem_id");
    equipmentId     = row.GetUInt32("equipment_id");
    constraints     = row["constraints"];
    garbageId       = row.GetUInt32("garbage_id");
    garbageQty      = row.GetInt("garbage_qty");
    priSkillId      = row.GetInt("primary_skill_id");
    minPriSkill     = row.GetInt("primary_min_skill");
    maxPriSkill     = row.GetInt("primary_max_skill");
    priPracticePts  = row.GetInt("primary_practice_points");
    priQualFactor   = row.GetInt("primary_quality_factor");
    secSkillId      = row.GetInt("secondary_skill_id");
    minSecSkill     = row.GetInt("secondary_min_skill");
    maxSecSkill     = row.GetInt("secondary_max_skill");
    secPracticePts  = row.GetInt("secondary_practice_points");
    secQualFactor   = row.GetInt("secondary_quality_factor");
    renderEffect    = row["render_effect"];
    return true;
}
Esempio n. 10
0
bool Location::Load(iResultRow &row, iEngine* engine, iDataConnection* /*db*/)
{
    id         = row.GetInt("id");
    name       = row["name"];
    pos.x      = row.GetFloat("x");
    pos.y      = row.GetFloat("y");
    pos.z      = row.GetFloat("z");
    rot_angle  = row.GetFloat("angle");;
    radius     = row.GetFloat("radius");
    sectorName = row["sector"];
    // Cache sector if engine is available.
    if(engine)
    {
        sector     = engine->FindSector(sectorName);
    }
    else
    {
        sector = NULL;
    }

    id_prev_loc_in_region = row.GetInt("id_prev_loc_in_region");

    return true;
}
Esempio n. 11
0
bool Tribe::LoadMemory(iResultRow &row)
{
    Memory* memory = new Memory;

    memory->id   = row.GetInt("id");
    memory->name = row["name"];
    memory->pos = csVector3(row.GetFloat("loc_x"),row.GetFloat("loc_y"),row.GetFloat("loc_z"));
    memory->radius = row.GetFloat("radius");
    memory->sectorName = row["sector_name"];
    // Try to find the sector. Will probably fail at this point.
    memory->sector = npcclient->GetEngine()->FindSector(memory->sectorName);
    memory->npc = NULL; // Not a private memory

    memories.PushBack(memory);

    return true;
}
Esempio n. 12
0
bool LocationType::Load(iResultRow &row, iEngine* engine, iDataConnection* db)
{
    id   = row.GetInt("id");
    name = row["name"];
    if(!name.Length())
    {
        CPrintf(CON_ERROR, "Location Types must all have name attributes.\n");
        return false;
    }

    // Load all with same master location type
    Result rs(db->Select("select loc.*,s.name as sector from sc_locations loc, sectors s where loc.loc_sector_id = s.id and type_id = %d and id_prev_loc_in_region <= 0",id)); // Only load locations, regions to be loaded later

    if(!rs.IsValid())
    {
        Error2("Could not load locations from db: %s",db->GetLastError());
        return false;
    }
    for(int i=0; i<(int)rs.Count(); i++)
    {
        Location* newloc = new Location;
        newloc->Load(rs[i],engine,db);
        newloc->type = this;
        locs.Push(newloc);
    }

    // Load region with same master location type
    Result rs2(db->Select("select loc.*,s.name as sector from sc_locations loc, sectors s where loc.loc_sector_id = s.id and type_id = %d and id_prev_loc_in_region > 0",id)); // Only load regions, locations has been loaded allready

    csArray<Location*> tmpLocs;

    if(!rs2.IsValid())
    {
        Error2("Could not load locations from db: %s",db->GetLastError());
        return false;
    }
    for(int i=0; i<(int)rs2.Count(); i++)
    {
        Location* newloc = new Location;
        newloc->Load(rs2[i],engine,db);

        newloc->type = this;
        tmpLocs.Push(newloc);
    }
    while(tmpLocs.GetSize())
    {
        Location* curr, *first;
        curr = first = tmpLocs.Pop();
        bool   found;
        first->type = this;
        first->locs.Push(first);
        first->region = first;
        do
        {
            found = false;
            for(size_t i= 0; i<tmpLocs.GetSize(); i++)
            {
                if(curr->id == tmpLocs[i]->id_prev_loc_in_region)
                {
                    curr = tmpLocs[i];
                    tmpLocs.DeleteIndex(i);
                    curr->type = this;
                    first->locs.Push(curr);
                    curr->region = first;
                    found = true;
                    break;
                }
            }

        }
        while(found);

        //when not a closed loop of at least 3 points, delete this
        //polygon, but continue with rest.
        if(first->locs.GetSize() <= 2)
        {
            Error1("Only two locs for region defined!");
            //delete all locations in 'polygon'. When deleting first,
            //it will recursively delete its polygon locations, in this
            //case including itself. So remove that reference first
            first->locs.DeleteIndex(0);
            delete first;
        }
        else if(curr->id != first->id_prev_loc_in_region)
        {
            Error1("First and last loc not connected!");
            //delete all locations in 'polygon'. When deleting first,
            //it will recursively delete its polygon locations, in this
            //case including itself. So remove that reference first
            first->locs.DeleteIndex(0);
            delete first;
        }
        else
        {
            first->type = this;
            locs.Push(first);
            first->CalculateBoundingBox();
        }
    }

    return true;
}