Ejemplo n.º 1
0
Location* LocationManager::FindLocation(int id)
{
    for(size_t i=0; i<all_locations.GetSize(); i++)
    {
        Location* location = all_locations[i];

        if(location->GetID() == id)
        {
            return location;
        }

        if(location->IsRegion())
        {
            for(size_t j=0; j<location->locs.GetSize(); j++)
            {
                Location* location2 = location->locs[j];

                if(location2->GetID() == id)
                {
                    return location2;
                }
            }
        }


    }
    return NULL;
}
Ejemplo n.º 2
0
Location* Location::Insert(int id, csVector3 &pos, iSector* sector)
{
    Location* location = new Location(type, name, pos, sector, radius, rot_angle, GetFlags());
    location->SetID(id);
    location->id_prev_loc_in_region = GetID();

    // Check if this location is in a region, if not convert this locaiton into a region.
    if(!region)
    {
        locs.Push(this);   // First location is in the locs as well.
        region = this;
    }

    // Update all the pointers and stuff.
    location->region = region;
    size_t index = region->locs.Find(this);
    Location* next = region->locs[(index+1)%region->locs.GetSize()];
    next->id_prev_loc_in_region = location->GetID();

    if(index+1 >= region->locs.GetSize())
    {
        region->locs.Push(location);
    }
    else
    {
        region->locs.Insert((index+1)%region->locs.GetSize(),location);
    }

    return location;
}