PyResult BookmarkService::Handle_DeleteBookmarks(PyCallArgs &call)
{
    if ( !(call.tuple->GetItem( 0 )->IsList()) )
    {
		sLog.Error( "BookmarkService::Handle_DeleteBookmarks()", "%s: call.tuple is of the wrong type: '%s'.  Expected PyList type.", call.client->GetName(), call.tuple->TypeString() );
		return NULL;
    }

    PyList *list = call.tuple->GetItem( 0 )->AsList();
    uint32 i;
    uint32 bookmarkID;
    std::vector<unsigned long> bookmarkIDs;

    if( list->size() > 0 )
    {
        for(i=0; i<(list->size()); i++)
        {
            bookmarkID = call.tuple->GetItem( 0 )->AsList()->GetItem(i)->AsInt()->value();
            bookmarkIDs.push_back( bookmarkID );
        }

        m_db.DeleteBookmarksFromDatabase( call.client->GetCharacterID(),&bookmarkIDs );
    }
    else
    {
		sLog.Error( "BookmarkService::Handle_DeleteBookmarks()", "%s: call.tuple->GetItem( 0 )->AsList()->size() == 0.  Expected size >= 1.", call.client->GetName() );
		return NULL;
    }

    return(new PyNone());
}
Esempio n. 2
0
void XBPython::Process()
{
  if (m_bInitialized)
  {
    PyList tmpvec;
    CSingleLock lock(m_vecPyList);
    for (PyList::iterator it = m_vecPyList.begin(); it != m_vecPyList.end();)
    {
      if (it->bDone)
      {
        tmpvec.push_back(*it);
        it = m_vecPyList.erase(it);
        m_vecPyList.hadSomethingRemoved = true;
      }
      else
        ++it;
    }
    lock.Leave();

    //delete scripts which are done
    tmpvec.clear(); // boost releases the XBPyThreads which, if deleted, calls OnScriptFinalized

    CSingleLock l2(m_critSection);
    if(m_iDllScriptCounter == 0 && (XbmcThreads::SystemClockMillis() - m_endtime) > 10000 )
    {
      Finalize();
    }
  }
}
Esempio n. 3
0
PyObject *DBRowToRow(DBResultRow &row, const char *type)
{

    PyDict *args = new PyDict();
    PyObject *res = new PyObject( type, args );

    //list off the column names:
    uint32 cc = row.ColumnCount();
    PyList *header = new PyList(cc);
    args->SetItemString("header", header);

    for(uint32 r = 0; r < cc; r++) {
        header->SetItemString(r, row.ColumnName(r));
    }

    //lines:
    PyList *rowlist = new PyList(cc);
    args->SetItemString("line", rowlist);

    //add a line entry for the row:
    for(uint32 r = 0; r < cc; r++) {
        rowlist->SetItem(r, DBColumnToPyRep(row, r));
    }

    return res;
}
Esempio n. 4
0
PyTuple *DBResultToTupleSet(DBQueryResult &result) {
    uint32 cc = result.ColumnCount();
    if(cc == 0)
        return new PyTuple(0);

    uint32 r;

    PyTuple *res = new PyTuple(2);
    PyList *cols = new PyList(cc);
    PyList *reslist = new PyList();
    res->items[0] = cols;
    res->items[1] = reslist;

    //list off the column names:
    for(r = 0; r < cc; r++) {
        cols->SetItemString(r, result.ColumnName(r));
    }

    //add a line entry for each result row:
    DBResultRow row;
    while(result.GetRow(row)) {
        PyList *linedata = new PyList(cc);
        reslist->items.push_back(linedata);
        for(r = 0; r < cc; r++) {
            linedata->SetItem(r, DBColumnToPyRep(row, r));
        }
    }

    return res;
}
Esempio n. 5
0
PyTuple *DBResultToRowList(DBQueryResult &result, const char *type) {
    uint32 cc = result.ColumnCount();
    if(cc == 0)
        return(new PyTuple(0));
    uint32 r;

    PyTuple *res = new PyTuple(2);
    PyList *cols = new PyList(cc);
    PyList *reslist = new PyList();
    res->SetItem( 0, cols );
    res->SetItem( 1, reslist );

    //list off the column names:
    for(r = 0; r < cc; r++) {
        cols->SetItemString(r, result.ColumnName(r));
    }

    //add a line entry for each result row:
    DBResultRow row;
    while(result.GetRow(row)) {
        //this could be more efficient by not building the column list each time, but cloning it instead.
        PyObject *o = DBRowToRow(row, type);
        reslist->items.push_back(o);
    }

    return res;
}
Esempio n. 6
0
PyPackedRow* InventoryItem::GetItemRow() const
{
    PyList *keywords = new PyList();
    keywords->AddItem(new_tuple(new PyString("stacksize"), new PyToken("util.StackSize")));
    keywords->AddItem(new_tuple(new PyString("singleton"), new PyToken("util.Singleton")));

    DBRowDescriptor* header = new DBRowDescriptor(keywords);
    header->AddColumn( "itemID",     DBTYPE_I8 );
    header->AddColumn( "typeID",     DBTYPE_I4 );
    header->AddColumn( "ownerID",    DBTYPE_I4 );
    header->AddColumn( "locationID", DBTYPE_I8 );
    header->AddColumn( "flagID",     DBTYPE_I2 );
    header->AddColumn( "quantity",   DBTYPE_I4 );
    header->AddColumn( "groupID",    DBTYPE_I2 );
    header->AddColumn( "categoryID", DBTYPE_I4 );
    header->AddColumn( "customInfo", DBTYPE_STR );

    //header->AddColumn( "singleton",  DBTYPE_BOOL );
    //header->AddColumn( "stacksize" , DBTYPE_I4 );

    PyPackedRow* row = new PyPackedRow( header );
    GetItemRow( row );

    return row;
}
Esempio n. 7
0
void ItemAttributeMgr::Clear(Attr attr) {
    PyRep *oldValue = NULL;
    if(GetNotify() == true && !IsRechargable(attr)) {
        // get old value
        oldValue = PyGet(attr);
    }
    // clear the attribute
    EVEAdvancedAttributeMgr::Clear(attr);
    // delete the attribute from DB (no matter if it really is there)
    if(GetSave() == true) {
        m_factory.db().EraseAttribute(m_item.itemID(), attr);
    }
    if(GetNotify() == true) {
        std::map<Attr, TauCap>::const_iterator i = m_tauCap.find(attr);
        if(i != m_tauCap.end()) {
            // build the special list for rechargables
            PyList *l = new PyList;

            l->AddItem( PyGet( attr ) );
            l->AddItemLong( Win32TimeNow() );
            l->AddItem( _PyGet( GetReal( i->second.tau ) / 5.0 ) );
            l->AddItem( PyGet( i->second.cap ) );

            oldValue = l;
        }
        // send change
        _SendAttributeChange(attr, oldValue, new PyFloat(GetReal(attr)));
    }
}
Esempio n. 8
0
void ItemAttributeMgr::SetIntEx(Attr attr, const int_t &v, bool persist) {
    PyRep *oldValue = NULL;
    if(GetNotify() == true && !IsRechargable(attr)) {
        // get old value
        oldValue = PyGet(attr);
    }
    // set the attribute value
    EVEAdvancedAttributeMgr::SetInt(attr, v);
    // check if we shall save to DB
    if(GetSave() == true && (persist || IsPersistent(attr))) {
        // save to DB
        m_factory.db().UpdateAttribute_int(m_item.itemID(), attr, v);
    }
    if(GetNotify() == true) {
        std::map<Attr, TauCap>::const_iterator i = m_tauCap.find(attr);
        if(i != m_tauCap.end()) {
            // build the special list for rechargables
            PyList *l = new PyList;

            l->AddItemInt( v );
            l->AddItemLong( Win32TimeNow() );
            l->AddItem( _PyGet( GetReal( i->second.tau ) / 5.0 ) );
            l->AddItem( PyGet( i->second.cap ) );

            oldValue = l;
        }
        // send change
        _SendAttributeChange(attr, oldValue, new PyFloat(v));
    }
}
Esempio n. 9
0
/**
 * this function isn't used.
 */
void DBResultToIntIntlistDict( DBQueryResult &result, std::map<int32, PyRep *> &into ) {
    /* this builds a map from the int in result[0], to a list of each result[1]
     * which is has the same result[0]. This function assumes the result is
     * ORDER BY result[0]
     */
    uint32 last_key = 0xFFFFFFFF;

    PyList *l = NULL;

    DBResultRow row;
    while( result.GetRow( row ) )
    {
        uint32 k = row.GetUInt(0);
        if( k != last_key )
        {
            //watch for overwrite, no guarantee we are dealing with a key.
            std::map<int32, PyRep *>::iterator res = into.find(k);
            if( res != into.end() )
                //log an error or warning?
                PyDecRef( res->second );

            into[k] = l = new PyList();
            last_key = k;
        }

        l->AddItemInt( row.GetInt( 1 ) );
    }
}
Esempio n. 10
0
PyTuple *Character::GetSkillQueue() {
    // return skills from skill queue
    PyList *list = new PyList;

    SkillQueue::iterator cur, end;
    cur = m_skillQueue.begin();
    end = m_skillQueue.end();
    for(; cur != end; cur++)
    {
        SkillQueue_Element el;

        el.typeID = cur->typeID;
        el.level = cur->level;

        list->AddItem( el.Encode() );
    }

	// now encapsulate it in a tuple with the free points
	PyTuple *tuple = new PyTuple(2);
	tuple->SetItem(0, list);
	// sending 0, as done on retail, doesn't f**k up calculation for some reason
	// so we can take the same shortcut here
	tuple->SetItem(1, new PyInt(0));

    return tuple;
}
Esempio n. 11
0
void Webifier::StopCycle(bool abort)
{
    double timeLeft = m_AMPC->GetRemainingCycleTimeMS();
    timeLeft /= 100;

    // Create Special Effect:
    m_Ship->GetPilot()->GetShipSE()->DestinyMgr()->SendSpecialEffect
    (
        m_Ship,
        m_Item->itemID(),
        m_Item->typeID(),
        m_targetID,
        0,
        "effect.decreaseTargetSpeed",
        0,
        0,
        0,
        timeLeft,
        0
     );

    // Create Destiny Updates:
    GodmaOther go;
        go.shipID = m_Ship->itemID();
        go.slotID = m_Item->flag();
        go.chargeTypeID = 0;

    GodmaEnvironment ge;
        ge.selfID = m_Item->itemID();
        ge.charID = m_Ship->ownerID();
        ge.shipID = go.shipID;
        ge.targetID = m_targetID;
        ge.other = go.Encode();
        ge.area = new PyList;
        ge.effectID = effectDecreaseTargetSpeed;

    Notify_OnGodmaShipEffect shipEff;
        shipEff.itemID = ge.selfID;
        shipEff.effectID = ge.effectID;
        shipEff.timeNow = Win32TimeNow();
        shipEff.start = 0;
        shipEff.active = 0;
        shipEff.environment = ge.Encode();
        shipEff.startTime = (shipEff.timeNow - (timeLeft * Win32Time_Second));
        shipEff.duration = timeLeft;
        shipEff.repeat = 0;
        shipEff.error = new PyNone;

    PyList* events = new PyList;
        events->AddItem(shipEff.Encode());

    Notify_OnMultiEvent multi;
        multi.events = events;

    PyTuple* tmp2 = multi.Encode();

    m_Ship->GetPilot()->SendNotification("OnMultiEvent", "clientID", &tmp2);
}
Esempio n. 12
0
void EnergyTurret::Deactivate() 
{
	Notify_OnGodmaShipEffect shipEff;
	shipEff.itemID = m_Item->itemID();
	shipEff.effectID = 10;
	shipEff.when = Win32TimeNow();
	shipEff.start = 0;
	shipEff.active = 0;

	PyList* env = new PyList;
	env->AddItem(new PyInt(shipEff.itemID));
	env->AddItem(new PyInt(m_Ship->ownerID()));
	env->AddItem(new PyInt(m_Ship->itemID()));
	env->AddItem(new PyInt(targetID));
	env->AddItem(new PyNone);
	env->AddItem(new PyNone);
	env->AddItem(new PyInt(10));

	shipEff.environment = env;
	shipEff.startTime = shipEff.when;
	shipEff.duration = 1584;
	shipEff.repeat = new PyInt(0);
	shipEff.randomSeed = new PyNone;
	shipEff.error = new PyNone;

	PyList* events = new PyList;
	events->AddItem(shipEff.Encode());

	Notify_OnMultiEvent multi;
	multi.events = events;

	PyTuple* tmp = multi.Encode();

	m_Ship->GetOperator()->SendDogmaNotification("OnMultiEvent", "clientID", &tmp);
}
Esempio n. 13
0
PyList *TargetManager::GetTargeters() const {
    PyList *result = new PyList();

    std::map<SystemEntity *, TargetedByEntry *>::const_iterator cur, end;
    cur = m_targetedBy.begin();
    end = m_targetedBy.end();
    for(; cur != end; cur++)
        result->AddItemInt( cur->first->GetID() );

    return result;
}
Esempio n. 14
0
void MissileLauncher::StopCycle(bool abort)
{
	// Do one last cycle:
	DoCycle();

	Notify_OnGodmaShipEffect shipEff;
	shipEff.itemID = m_Item->itemID();
	shipEff.effectID = effectMissileLaunching;
	shipEff.when = Win32TimeNow();
	shipEff.start = 0;
	shipEff.active = 0;

	PyList* env = new PyList;
	env->AddItem(new PyInt(shipEff.itemID));
	env->AddItem(new PyInt(m_Ship->ownerID()));
	env->AddItem(new PyInt(m_Ship->itemID()));
	env->AddItem(new PyInt(m_targetID));
	env->AddItem(new PyNone);
	env->AddItem(new PyNone);
	env->AddItem(new PyInt(shipEff.effectID));

	shipEff.environment = env;
	shipEff.startTime = shipEff.when;
	shipEff.duration = 1.0;		//m_ActiveModuleProc->GetRemainingCycleTimeMS();		// At least, I'm assuming this is the remaining time left in the cycle
	shipEff.repeat = new PyInt(0);
	shipEff.randomSeed = new PyNone;
	shipEff.error = new PyNone;

	PyList* events = new PyList;
	events->AddItem(shipEff.Encode());

	Notify_OnMultiEvent multi;
	multi.events = events;

	PyTuple* tmp = multi.Encode();

	m_Ship->GetOperator()->SendDogmaNotification("OnMultiEvent", "clientID", &tmp);

	// Create Special Effect:
	m_Ship->GetOperator()->GetDestiny()->SendSpecialEffect
	(
		m_Ship,
		m_Item->itemID(),
		m_Item->typeID(),
		m_targetID,
		m_chargeRef->itemID(),
		"effects.MissileDeployment",
		1,
		0,
		0,
		1.0,
		0
	);

	m_ActiveModuleProc->DeactivateCycle();
}
Esempio n. 15
0
PyDict* CRowSet::_CreateKeywords(DBRowDescriptor* rowDesc)
{
	assert( rowDesc );

	PyDict* keywords = new PyDict;
	keywords->SetItemString( "header", rowDesc );

	uint32 cc = rowDesc->ColumnCount();
	PyList* columns = new PyList( cc );
	for( uint32 i = 0; i < cc; i++ )
		columns->SetItem( i,  new PyString( *rowDesc->GetColumnName( i ) ) );
	keywords->SetItemString( "columns", columns );

	return keywords;
}
Esempio n. 16
0
void XBPython::FreeResources()
{
  CSingleLock lock(m_critSection);
  if (m_bInitialized)
  {
    // with the m_critSection held, we should copy the PyList so that 
    // we can operate on the values once we release it.
    PyList tmpvec = m_vecPyList;
    m_vecPyList.clear();

    lock.Leave(); //unlock here because the python thread might lock when it exits

    // cleanup threads that are still running
    tmpvec.clear(); // boost releases the XBPyThreads which, if deleted, calls FinalizeScript
  }
}
Esempio n. 17
0
PyList *DBResultToPackedRowList( DBQueryResult &result )
{
    DBRowDescriptor *header = new DBRowDescriptor( result );

    PyList *res = new PyList( result.GetRowCount() );

    DBResultRow row;
    for( uint32 i = 0; result.GetRow( row ); i++ )
    {
        res->SetItem( i, CreatePackedRow( row, header ) );
        PyIncRef( header );
    }

    PyDecRef( header );
    return res;
}
Esempio n. 18
0
PyList* Contract::GetItemsList() const
{
    std::map<uint32, ContractGetItemsRef>::const_iterator cur, end;
    std::map<uint32, ContractGetItemsRef> item = items();
    PyList* res = new PyList;

    DBRowDescriptor* header = new DBRowDescriptor;
    header->AddColumn( "contractID",						DBTYPE_I4 );
    header->AddColumn( "itemID",							DBTYPE_I4 );
    header->AddColumn( "quantity",							DBTYPE_I4 );
    header->AddColumn( "itemTypeID",						DBTYPE_I4 );
    header->AddColumn( "inCrate",							DBTYPE_BOOL );
    header->AddColumn( "parentID",							DBTYPE_I4 );
    header->AddColumn( "productivityLevel",					DBTYPE_I4 );
    header->AddColumn( "materialLevel",						DBTYPE_I4 );
    header->AddColumn( "copy",								DBTYPE_I4 );
    header->AddColumn( "licensedProductionRunsRemaining",	DBTYPE_I4 );
    header->AddColumn( "damage",							DBTYPE_R8 );
    header->AddColumn( "flagID",							DBTYPE_I2 );

    cur = item.begin();
    end = item.end();

    for(; cur != end; *cur++ )
    {
        InventoryItemRef itemInfo = m_itemFactory.GetItem( cur->second->m_itemID );

        PyPackedRow* into = new PyPackedRow( header );
        GetItemRow( itemInfo, into );
        res->AddItem( into );
    }

    std::map<uint32, ContractRequestItemRef>::const_iterator c, e;
    std::map<uint32, ContractRequestItemRef> requestItem = requestItems();

    c = requestItem.begin();
    e = requestItem.end();

    for(; cur != end; *cur++ )
    {
        PyPackedRow* into = new PyPackedRow( header );
        GetRequestItemRow( c->second, into );
        res->AddItem( into );
    }

    return res;
}
Esempio n. 19
0
PyResult InfoGatheringMgr::Handle_GetStateAndConfig(PyCallArgs &call) {
	
	PyDict *rsp = new PyDict;
	
	rsp->SetItemString("clientWorkerInterval", new PyInt(600000)); //Default From packetlogs is 600000
	rsp->SetItemString("isEnabled", new PyInt(0)); //0 = Disabled, 1 = Enabled. Set to 0 becuase jsut gettting rid of exception.

	rsp->SetItemString("infoTypeAggregates", new PyNone());
	rsp->SetItemString("infoTypesOncePerRun", new PyNone());
	rsp->SetItemString("infoTypeParameters", new PyNone());

	PyList *infoTypes = new PyList;
	infoTypes->AddItemInt(999); //Adding a value that was not in live so when its checks list it will always return false for now.
	
	rsp->SetItemString("infoTypes", new PyObjectEx_Type1( new PyToken("__builtin__.set"), new_tuple(infoTypes)));
	
	return new PyObject( "util.KeyVal", rsp );
}
Esempio n. 20
0
PyList *Character::GetSkillQueue() {
    // return skills from skill queue
    PyList *list = new PyList;

    SkillQueue::iterator cur, end;
    cur = m_skillQueue.begin();
    end = m_skillQueue.end();
    for(; cur != end; cur++)
    {
        SkillQueue_Element el;

        el.typeID = cur->typeID;
        el.level = cur->level;

        list->AddItem( el.Encode() );
    }

    return list;
}
Esempio n. 21
0
void ShieldHardener::StopCycle(bool abort)
{
    // Create Destiny Updates:
    GodmaOther go;
        go.shipID = m_Ship->itemID();
        go.slotID = m_Item->flag();
        go.chargeTypeID = 0;

    GodmaEnvironment ge;
        ge.selfID = m_Item->itemID();
        ge.charID = m_Ship->ownerID();
        ge.shipID = go.shipID;
        ge.targetID = 0;
        ge.other = go.Encode();
        ge.area = new PyList;
        ge.effectID = effectModifyActiveShieldResonanceAndNullifyPassiveResonance;

    uint32 timeLeft = m_AMPC->GetRemainingCycleTimeMS();
    timeLeft /= 100;

    Notify_OnGodmaShipEffect shipEff;
        shipEff.itemID = ge.selfID;
        shipEff.effectID = ge.effectID;
        shipEff.timeNow = Win32TimeNow();
        shipEff.start = 0;
        shipEff.active = 0;
        shipEff.environment = ge.Encode();
        shipEff.startTime = (shipEff.timeNow - (timeLeft * Win32Time_Second));
        shipEff.duration = timeLeft;
        shipEff.repeat = 0;
        shipEff.error = new PyNone;

    PyList* events = new PyList;
        events->AddItem(shipEff.Encode());

    Notify_OnMultiEvent multi;
        multi.events = events;

    PyTuple* tmp = multi.Encode();

    m_Ship->GetPilot()->SendNotification("OnMultiEvent", "clientID", &tmp);
}
Esempio n. 22
0
void XBPython::Process()
{
  if (m_bLogin)
  {
    m_bLogin = false;

    // autoexec.py - profile
    CStdString strAutoExecPy = CSpecialProtocol::TranslatePath("special://profile/autoexec.py");

    if ( XFILE::CFile::Exists(strAutoExecPy) )
      evalFile(strAutoExecPy,ADDON::AddonPtr());
    else
      CLog::Log(LOGDEBUG, "%s - no profile autoexec.py (%s) found, skipping", __FUNCTION__, strAutoExecPy.c_str());
  }

  CSingleLock lock(m_vecPyList);

  if (m_bInitialized)
  {
    PyList tmpvec;
    for (PyList::iterator it = m_vecPyList.begin(); it != m_vecPyList.end();)
    {
      if (it->bDone)
      {
        tmpvec.push_back(*it);
        it = m_vecPyList.erase(it);
      }
      else
        it++;
    }
    lock.Leave();

    //delete scripts which are done
    tmpvec.clear(); // boost releases the XBPyThreads which, if deleted, calls FinalizeScript

    CSingleLock l2(m_critSection);
    if(m_iDllScriptCounter == 0 && (XbmcThreads::SystemClockMillis() - m_endtime) > 10000 )
    {
      Finalize();
    }
  }
}
Esempio n. 23
0
void HybridTurret::_ShowCycle()
{
	//m_Item->SetActive(true, effectProjectileFired, m_Item->GetAttribute(AttrSpeed).get_float(), true);

	// Create Destiny Updates:
	Notify_OnGodmaShipEffect shipEff;
	shipEff.itemID = m_Item->itemID();
	shipEff.effectID = effectProjectileFired;		// From EVEEffectID::
	shipEff.when = Win32TimeNow();
	shipEff.start = 1;
	shipEff.active = 1;

	PyList* env = new PyList;
	env->AddItem(new PyInt(shipEff.itemID));
	env->AddItem(new PyInt(m_Ship->ownerID()));
	env->AddItem(new PyInt(m_Ship->itemID()));
	env->AddItem(new PyInt(m_targetID));
	env->AddItem(new PyNone);
	env->AddItem(new PyNone);
	env->AddItem(new PyInt(shipEff.effectID));

	shipEff.environment = env;
	shipEff.startTime = shipEff.when;
	shipEff.duration = m_Item->GetAttribute(AttrSpeed).get_float();
	shipEff.repeat = new PyInt(1000);
	shipEff.randomSeed = new PyNone;
	shipEff.error = new PyNone;

	PyTuple* tmp = new PyTuple(3);
	//tmp->SetItem(1, dmgMsg.Encode());
	tmp->SetItem(2, shipEff.Encode());

	std::vector<PyTuple*> events;
	//events.push_back(dmgMsg.Encode());
	events.push_back(shipEff.Encode());

	std::vector<PyTuple*> updates;
	//updates.push_back(dmgChange.Encode());

	m_Ship->GetOperator()->GetDestiny()->SendDestinyUpdate(updates, events, false);

	// Create Special Effect:
	m_Ship->GetOperator()->GetDestiny()->SendSpecialEffect
	(
		m_Ship,
		m_Item->itemID(),
		m_Item->typeID(),
		m_targetID,
		m_chargeRef->typeID(),
		"effects.HybridFired",
		1,
		1,
		1,
		m_Item->GetAttribute(AttrSpeed).get_float(),
		1000
	);
}
Esempio n. 24
0
PyObject *DBResultToIndexRowset(DBQueryResult &result, uint32 key_index) {
    uint32 cc = result.ColumnCount();

    //start building the IndexRowset
    PyDict *args = new PyDict();
    PyObject *res = new PyObject(
        new PyString( "util.IndexRowset" ), args
    );

    if(cc == 0 || cc < key_index)
        return res;
    
    //list off the column names:
    PyList *header = new PyList(cc);
    args->SetItemString("header", header);
    for(uint32 i = 0; i < cc; i++)
        header->SetItemString(i, result.ColumnName(i));

    //RowClass:
    args->SetItemString("RowClass", new PyToken("util.Row"));
    //idName:
    args->SetItemString("idName", new PyString( result.ColumnName(key_index) ));

    //items:
    PyDict *items = new PyDict();
    args->SetItemString("items", items);

    //add a line entry for each result row:
    DBResultRow row;
    while(result.GetRow(row)) {
        PyRep *key = DBColumnToPyRep(row, key_index);

        PyList *line = new PyList(cc);
        for(uint32 i = 0; i < cc; i++)
            line->SetItem(i, DBColumnToPyRep(row, i));

        items->SetItem(key, line);
    }

    return res;
}
Esempio n. 25
0
/* function not used */
PyTuple *DBResultToPackedRowListTuple( DBQueryResult &result )
{
    DBRowDescriptor * header = new DBRowDescriptor( result );

    size_t row_count = result.GetRowCount();
    PyList * list = new PyList( row_count );

    DBResultRow row;
    uint32 i = 0;
    while( result.GetRow(row) )
    {
        list->SetItem( i++, CreatePackedRow( row, header ) );
        PyIncRef( header );
    }

    PyTuple * root = new PyTuple(2);
    root->SetItem( 0, header );
    root->SetItem( 1, list );

    return root;
}
Esempio n. 26
0
CRowSet* Inventory::List( EVEItemFlags _flag, uint32 forOwner ) const
{
    PyList *keywords = new PyList();
    keywords->AddItem(new_tuple(new PyString("stacksize"), new PyToken("util.StackSize")));
    keywords->AddItem(new_tuple(new PyString("singleton"), new PyToken("util.Singleton")));

    DBRowDescriptor* header = new DBRowDescriptor(keywords);
    header->AddColumn( "itemID",     DBTYPE_I8 );
    header->AddColumn( "typeID",     DBTYPE_I4 );
    header->AddColumn( "ownerID",    DBTYPE_I4 );
    header->AddColumn( "locationID", DBTYPE_I8 );
    header->AddColumn( "flagID",     DBTYPE_I2 );
    header->AddColumn( "quantity",   DBTYPE_I4 );
    header->AddColumn( "groupID",    DBTYPE_I2 );
    header->AddColumn( "categoryID", DBTYPE_I4 );
    header->AddColumn( "customInfo", DBTYPE_STR );

    //header->AddColumn( "singleton",  DBTYPE_BOOL );
    //header->AddColumn( "stacksize" , DBTYPE_I4 );

    CRowSet* rowset = new CRowSet( &header );
    List( rowset, _flag, forOwner );
    return rowset;
}
Esempio n. 27
0
void EnergyTurret::Deactivate() 
{
	Notify_OnGodmaShipEffect shipEff;
	shipEff.itemID = m_Item->itemID();
	shipEff.effectID = effectTargetAttack;
	shipEff.when = Win32TimeNow();
	shipEff.start = 0;
	shipEff.active = 0;

	PyList* env = new PyList;
	env->AddItem(new PyInt(shipEff.itemID));
	env->AddItem(new PyInt(m_Ship->ownerID()));
	env->AddItem(new PyInt(m_Ship->itemID()));
	env->AddItem(new PyInt(m_targetEntity->GetID()));
	env->AddItem(new PyNone);
	env->AddItem(new PyNone);
	env->AddItem(new PyInt(10));

	shipEff.environment = env;
	shipEff.startTime = shipEff.when;
	shipEff.duration = m_ActiveModuleProc->GetRemainingCycleTimeMS();		// At least, I'm assuming this is the remaining time left in the cycle
	shipEff.repeat = new PyInt(0);
	shipEff.randomSeed = new PyNone;
	shipEff.error = new PyNone;

	PyList* events = new PyList;
	events->AddItem(shipEff.Encode());

	Notify_OnMultiEvent multi;
	multi.events = events;

	PyTuple* tmp = multi.Encode();

	m_Ship->GetOperator()->SendDogmaNotification("OnMultiEvent", "clientID", &tmp);

	m_ActiveModuleProc->DeactivateCycle();
}
Esempio n. 28
0
void InventoryItem::SetOnline(bool online) {

    SetAttribute(AttrIsOnline, int(online));

    Client *c = sEntityList.FindCharacter(m_ownerID);
    if(c == NULL)
    {
        sLog.Error("InventoryItem", "unable to set ourselfs online//offline because we can't find the client");
        return;
    }

    Notify_OnGodmaShipEffect ogf;
    ogf.itemID = m_itemID;
    ogf.effectID = effectOnline;
    ogf.when = Win32TimeNow();
    ogf.start = online?1:0;
    ogf.active = online?1:0;

	PyList *environment = new PyList;
	environment->AddItem(new PyInt(ogf.itemID));
	environment->AddItem(new PyInt(m_ownerID));
	environment->AddItem(new PyInt(m_locationID));
	environment->AddItem(new PyNone);
	environment->AddItem(new PyNone);
	environment->AddItem(new PyNone);
	environment->AddItem(new PyInt(ogf.effectID));
	
	ogf.environment = environment;
	ogf.startTime = ogf.when;
	ogf.duration = 10000;
	ogf.repeat = online?new PyInt(1000):new PyInt(0);
    ogf.randomSeed = new PyNone();
    ogf.error = new PyNone();

    Notify_OnMultiEvent multi;
    multi.events = new PyList;
    multi.events->AddItem( ogf.Encode() );

    PyTuple* tmp = multi.Encode();   //this is consumed below
    c->SendNotification("OnMultiEvent", "clientID", &tmp);
}
Esempio n. 29
0
void InventoryItem::SetActive(bool active, uint32 effectID, double duration, bool repeat)
{
	Client* c = sEntityList.FindCharacter(m_ownerID);
    if(c == NULL)
    {
        sLog.Error("InventoryItem", "unable to set ourselfs online//offline because we can't find the client");
        return;
    }

	Notify_OnGodmaShipEffect shipEffect;

	shipEffect.itemID = m_itemID;
	shipEffect.effectID = effectID;
	shipEffect.when = Win32TimeNow();
	shipEffect.start = active?1:0;
	shipEffect.active = active?1:0;

	PyList* env = new PyList;
	env->AddItem(new PyInt(m_itemID));
	env->AddItem(new PyInt(ownerID()));
	env->AddItem(new PyInt(m_locationID));
	env->AddItem(new PyNone);				//targetID
	env->AddItem(new PyNone);				//otherID
	env->AddItem(new PyNone);				//area
	env->AddItem(new PyInt(effectID));

	shipEffect.environment = env;
	shipEffect.startTime = shipEffect.when;
	shipEffect.duration = duration;
	shipEffect.repeat = repeat?new PyInt(1000):new PyInt(0);
	shipEffect.randomSeed = new PyNone;
	shipEffect.error = new PyNone;

	Notify_OnMultiEvent multi;
    multi.events = new PyList;
    multi.events->AddItem(shipEffect.Encode());

    PyTuple* tmp = multi.Encode();   //this is consumed below
    c->SendNotification("OnMultiEvent", "clientID", &tmp);
}
Esempio n. 30
0
PyObject *DBResultToRowset(DBQueryResult &result)
{
    uint32 r;
    uint32 cc = result.ColumnCount();

    PyDict *args = new PyDict();
    PyObject *res = new PyObject(
        new PyString( "util.Rowset" ), args
    );

    /* check if we have a empty query result and return a empty RowSet */
    if( cc == 0 )
        return res;

    //list off the column names:
    PyList *header = new PyList( cc );
    args->SetItemString("header", header);
    for(r = 0; r < cc; r++) {
        header->SetItemString( r, result.ColumnName(r));
    }

    //RowClass:
    args->SetItemString("RowClass", new PyToken("util.Row"));

    //lines:
    PyList *rowlist = new PyList();
    args->SetItemString("lines", rowlist);

    //add a line entry for each result row:
    DBResultRow row;
    while(result.GetRow(row)) {
        PyList *linedata = new PyList( cc );
        rowlist->AddItem(linedata);

        for(r = 0; r < cc; r++) {
            linedata->SetItem( r, DBColumnToPyRep(row, r) );
        }
    }

    return res;
}