Beispiel #1
0
void test_explorer()
{
#define TEST_EXPORT
#define TEST_THREADS
  enum {
    queueBufferSize = 4096*8,
  };
  char queueBuffer[queueBufferSize];
  TransportParams* pParams;
  Transporter transporter;
  pParams = transporter.TransportDataInit(
#ifdef TEST_EXPORT
    TRUE,
#else
    FALSE,            //importMode
#endif
    queueBuffer,
    queueBufferSize,
    FS_FILE_SWAP,
#ifdef TEST_EXPORT
    MULTI_PATHS_ZEXPORT
#else
    MULTI_PATHS_ZIMPPORT
#endif
    );
  transporter.Init(pParams);
#ifdef TEST_THREADS
  transporter.Start();
  for (;;) {
    TransportStatus status;
    transporter.GetStatus(&status);
    _tprintf(TEXT("status %d expl %I64d xpot %I64d\n"), status.stateFlags, status.exploredSize, status.xportedSize);
    if (status.stateFlags & TransportStatus::xportingComplete)
      break;
    Sleep(500);
  }
#else //TEST_THREADS
#ifdef TEST_EXPORT
  transporter.ExploreThreadMain();
  transporter.XportThreadMain();
#else
  transporter.XportThreadMain();
#endif
#endif //TEST_THREADS
  transporter.Final();
  transporter.TransportDataFinal(pParams);
}
void ObjectMgr::LoadTransporters()
{
#ifdef CLUSTERING
	return;
#endif
	Log.Notice("ObjectMgr", "Loading Transports...");
	QueryResult * QR = WorldDatabase.Query("SELECT entry FROM gameobject_names WHERE type = %u", GAMEOBJECT_TYPE_MO_TRANSPORT);
	if(!QR)
		return;

	int64 total = QR->GetRowCount();
	TransportersCount = total;
	uint32 entry = NULL;
	Transporter* pTransporter = NULL;
	do
	{
		entry = QR->Fetch()[0].GetUInt32();

		pTransporter = new Transporter((uint64)HIGHGUID_TYPE_TRANSPORTER<<32 | entry);
		pTransporter->Init();
		if(!pTransporter->CreateAsTransporter(entry, ""))
		{
			Log.Warning("ObjectMgr","Skipped invalid transporterid %d.", entry);
			pTransporter->Destruct();
			pTransporter = NULL;
		}
		else
		{
			AddTransport(pTransporter);

			QueryResult * result2 = WorldDatabase.Query("SELECT * FROM transport_creatures WHERE transport_entry = %u", entry);
			if(result2)
			{
				do
				{
					pTransporter->AddNPC(result2->Fetch()[1].GetUInt32(), result2->Fetch()[2].GetFloat(),
						result2->Fetch()[3].GetFloat(), result2->Fetch()[4].GetFloat(),
						result2->Fetch()[5].GetFloat());

				} while (result2->NextRow());
				delete result2;
			}
		}

	} while(QR->NextRow());
	delete QR;
}
Beispiel #3
0
//<export/import> [zParams]
void shell_xpot(int argc, TCHAR* argv[])
{
  int rc;
  int nDone = 0;
  int isExport = 0;
  TCHAR* zParams;
  TCHAR zSwapFile[MAX_PATH];

  enum {
    queueBufferSize = 4096*8,
  };
  char queueBuffer[queueBufferSize];
  TransportParams* pParams;
  Transporter transporter;

  do {
    //(1) get input args
    if (argc < 2) break;
    if (_tcscmp(argv[1], TEXT("export")) == 0) {
      zParams = MULTI_PATHS_ZEXPORT;
      isExport = TRUE;
    }
    else if (_tcscmp(argv[1], TEXT("import")) == 0) {
      zParams = MULTI_PATHS_ZIMPPORT;
      isExport = FALSE;
    } else
      break;
    if (argc == 3) zParams = argv[2];
    nDone = 1;
    //(2) init params
    GetModuleDir(zSwapFile, MAX_PATH);
    pathMng path;
    path.pathPush(zSwapFile, MAX_PATH, TEXT("\\fs.bin"));
    pParams = transporter.TransportDataInit(
      isExport,
      queueBuffer,
      queueBufferSize,
      zSwapFile,
      zParams
      );
    rc = transporter.Init(pParams);
    if (rc) break;
    transporter.Start();
    for (int i = 0;;i++) {
      TransportStatus status;
      transporter.GetStatus(&status);
      _tprintf(TEXT("status %d expl %I64d xpot %I64d\n"), status.stateFlags, status.exploredSize, status.xportedSize);
      if (status.stateFlags & TransportStatus::xportingComplete)
        break;
#if (1)
      Sleep(500);
#else //test interrupt
      Sleep(50);
      if (i==1) {
        transporter.Cancel();
      }
#endif
    }
    transporter.Final();
    nDone = 2;
  } while(FALSE);

  switch (nDone) {
    case 2:
      break;
    case 1:
      _tprintf(TEXT("init fail\n"));
      break;
    default:
      assert(nDone == 0);
      _tprintf(TEXT("<export/import> [zParams]\n"));
      break;
  }
}