Location* Location::Insert(iDataConnection* db, csVector3 &pos, iSector* sector)
{
    Location* location = new Location(type, name, pos, sector, radius, rot_angle, GetFlags());
    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;
    }

    // Create DB entry
    location->CreateUpdate(db);

    // 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();
    next->CreateUpdate(db);

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

    return location;
}
Location* LocationManager::CreateLocation(iDataConnection* db, LocationType* locationType, const char* locationName, const csVector3 &pos, iSector* sector, float radius, float rot_angle, const csString &flags)
{
    Location* location = CreateLocation(locationType, locationName, pos, sector, radius, rot_angle, flags);

    if(!location->CreateUpdate(db))
    {
        delete location;
        return NULL;
    }

    return location;
}