예제 #1
0
EncodedJSValue JSC_HOST_CALL mapProtoFuncSize(CallFrame* callFrame)
{
    MapData* data = getMapData(callFrame, callFrame->thisValue());
    if (!data)
        return JSValue::encode(jsUndefined());
    return JSValue::encode(jsNumber(data->size(callFrame)));
}
예제 #2
0
EncodedJSValue JSC_HOST_CALL mapProtoFuncHas(CallFrame* callFrame)
{
    MapData* data = getMapData(callFrame, callFrame->thisValue());
    if (!data)
        return JSValue::encode(jsUndefined());
    return JSValue::encode(jsBoolean(data->contains(callFrame, callFrame->argument(0))));
}
예제 #3
0
EncodedJSValue JSC_HOST_CALL mapProtoFuncForEach(CallFrame* callFrame)
{
    MapData* data = getMapData(callFrame, callFrame->thisValue());
    if (!data)
        return JSValue::encode(jsUndefined());
    JSValue callBack = callFrame->argument(0);
    CallData callData;
    CallType callType = getCallData(callBack, callData);
    if (callType == CallTypeNone)
        return JSValue::encode(throwTypeError(callFrame, WTF::ASCIILiteral("Map.prototype.forEach called without callback")));
    JSValue thisValue = callFrame->argument(1);
    VM* vm = &callFrame->vm();
    if (callType == CallTypeJS) {
        JSFunction* function = jsCast<JSFunction*>(callBack);
        CachedCall cachedCall(callFrame, function, 2);
        for (auto ptr = data->begin(), end = data->end(); ptr != end && !vm->exception(); ++ptr) {
            cachedCall.setThis(thisValue);
            cachedCall.setArgument(0, ptr.value());
            cachedCall.setArgument(1, ptr.key());
            cachedCall.call();
        }
    } else {
        for (auto ptr = data->begin(), end = data->end(); ptr != end && !vm->exception(); ++ptr) {
            MarkedArgumentBuffer args;
            args.append(ptr.value());
            args.append(ptr.key());
            JSC::call(callFrame, callBack, callType, callData, thisValue, args);
        }
    }
    return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL setProtoFuncDelete(CallFrame* callFrame)
{
    MapData* data = getMapData(callFrame, callFrame->thisValue());
    if (!data)
        return JSValue::encode(jsUndefined());
    return JSValue::encode(jsBoolean(data->remove(callFrame, callFrame->argument(0))));
}
예제 #5
0
EncodedJSValue JSC_HOST_CALL mapProtoFuncClear(CallFrame* callFrame)
{
    MapData* data = getMapData(callFrame, callFrame->thisValue());
    if (!data)
        return JSValue::encode(jsUndefined());
    data->clear();
    return JSValue::encode(jsUndefined());
}
예제 #6
0
EncodedJSValue JSC_HOST_CALL mapProtoFuncSet(CallFrame* callFrame)
{
    MapData* data = getMapData(callFrame, callFrame->thisValue());
    if (!data)
        return JSValue::encode(jsUndefined());
    data->set(callFrame, callFrame->argument(0), callFrame->argument(1));
    return JSValue::encode(callFrame->thisValue());
}
예제 #7
0
EncodedJSValue JSC_HOST_CALL mapProtoFuncGet(CallFrame* callFrame)
{
    MapData* data = getMapData(callFrame, callFrame->thisValue());
    if (!data)
        return JSValue::encode(jsUndefined());
    JSValue result = data->get(callFrame, callFrame->argument(0));
    if (!result)
        result = jsUndefined();
    return JSValue::encode(result);
}
예제 #8
0
int main(){
	int i;
	char *fname = "map1_kekka.txt";
	FILE *fp;
	
	/* initiation of elite_uncom */
	elite_uncom = INF;
	waiting_time = 0;
	getMapData();

	for(;;){
		serch_route();
		/* update elite route */
		if(elite_uncom > new_uncom)
			update_elite();		
		waiting_time++;
		if(waiting_time > elite_uncom)
			break;
	}
	
	printf("time = %lf, uncom = %lf, waitingtime = %lf\n", elite_necessary_time, elite_uncom, elite_waiting_time);
	for(i=1;i<NODE_NUM;i++){
		if(elite_route[i] != 0)
			printf("%d -> ", elite_route[i]);
	}
	
/*	fp = fopen(fname, "wt");
	if(fp == NULL){
		printf("file open error\n");
		exit(1);
	}
	else{
		for(i=1;i<N-1;i++){
			if(route[i] != 0){
				fprintf(fp,"%d,%d,%d,%d\n",
				cord[route[i]].x, cord[route[i]].y, cord[route[i+1]].x, cord[route[i+1]].y);
				printf("%d,%d,%d,%d\n",
				cord[route[i]].x, cord[route[i]].y, cord[route[i+1]].x, cord[route[i+1]].y);
			}
		}
	}
	fclose(fp);
*/				
	return 0;
}
예제 #9
0
파일: map.cpp 프로젝트: swallen/mineserver
bool Map::getBlock(int x, int y, int z, uint8 *type, uint8 *meta, bool generate)
{
#ifdef MSDBG
  printf("getBlock(x=%d, y=%d, z=%d)\n", x, y, z);
#endif

  if((y < 0) || (y > 127))
  {
    printf("(%i, %i, %i) ", x, y, z);
    LOG("Invalid y value (getBlock)");
    return false;
  }

  int chunk_x = blockToChunk(x);
  int chunk_z = blockToChunk(z);

  uint32 mapId;
  Map::posToId(chunk_x, chunk_z, &mapId);

  sChunk *chunk = getMapData(chunk_x, chunk_z, generate);

  if(!chunk)
  {
    if(generate)
     LOG("Loading chunk failed (getBlock)");
    return false;
  }

  int chunk_block_x  = blockToChunkBlock(x);
  int chunk_block_z  = blockToChunkBlock(z);

  uint8 *blocks      = chunk->blocks;
  uint8 *metapointer = chunk->data;
  int index          = y + (chunk_block_z * 128) + (chunk_block_x * 128 * 16);
  *type = blocks[index];
  uint8 metadata     = metapointer[(index)>>1];

  if(y%2)
  {
    metadata  &= 0xf0;
    metadata >>= 4;
  }
예제 #10
0
void GameModelLevel2::Init()
{
	Model::Init();
	GameModel2D::Init();

	m_tileMap = new TileMap();
	m_tileMap->Init(32, 32, 32, 32, 32);
	m_tileMap->LoadMap("Image//Maps//L2_L2.csv");

	m_ReartileMap = new TileMap();
	m_ReartileMap->Init(32, 32, 32, 32, 32);
	m_ReartileMap->LoadMap("Image//Maps//L2_L1.csv");

	m_AItilemap = new TileMap();
	m_AItilemap->Init(32, 32, 32, 32, 32);
	m_AItilemap->LoadMap("Image//Maps//L2_AI.csv");

	CCharacter_Player::GetInstance()->Init(newPlayerPos.x - 0.5f,
			newPlayerPos.y - 0.25f,
			newPlayerPos.z,1,1,100,1,5);

	getMapData();
	m_CurrentLevel = 2;
}
bool
GMSRailwayItem::createFromMidMif(ifstream& midFile, bool readRestOfLine)
{
   uint32 maxLineLength = GMSMidMifHandler::maxMidLineLength;
   char inbuffer[maxLineLength];
   char* tmpchr;

   MidMifData* midmifData = dynamic_cast<MidMifData*>(getMapData());
   if ( midmifData == NULL ) {
      mc2log << error << here 
             << " mapData is not a midmifData or NULL." << endl;
      MC2_ASSERT(midmifData != NULL);
   }
   
   // Check if we have any extra attributes to read,
   // don't count any map ssi coordinates
   uint32 nbrExtraAttributes = 
         GMSMidMifHandler::getNumberExtraAttributes( midFile, !readRestOfLine);

   // Read any extra item attributes
   // Extra: settlement (use the left settlement attribute)
   if ( nbrExtraAttributes > 0 ) {
      //read past first ','
      midFile.getline(inbuffer,maxLineLength, ',');
      // If this is the last attribute in the mid row there is no more 
      // "," char to read
      if ( (nbrExtraAttributes == 1) && readRestOfLine ) {
         midFile.getline(inbuffer, maxLineLength);
         readRestOfLine = false;
      } else {
         midFile.getline(inbuffer, maxLineLength, ',');
      }
      if ( strlen(inbuffer) > 0 ) {
         uint32 tmpLeftSettlement = strtoul(inbuffer, &tmpchr, 10);
         midmifData->setLeftSettlement( tmpLeftSettlement );
      }
      nbrExtraAttributes--;
   }
   // Extra: settlement order
   if ( nbrExtraAttributes > 0 ) {
      // If this is the last attribute in the mid row there is no more 
      // "," char to read
      if ( (nbrExtraAttributes == 1) && readRestOfLine ) {
         midFile.getline(inbuffer, maxLineLength);
         readRestOfLine = false;
      } else {
         midFile.getline(inbuffer, maxLineLength, ',');
      }
      if ( strlen(inbuffer) > 0 ) {
         uint32 tmpSettlementOrder = strtoul(inbuffer, &tmpchr, 10);
         midmifData->setSettlementOrder( tmpSettlementOrder );
      }
      nbrExtraAttributes--;
   }
   /*
   // Template for next item attribute
   // Note: if the attribute is surrounded by "-chars or not affects
   // how to read inbuffer.
   if ( nbrExtraAttributes > 0 ) {
      midFile.getline(inbuffer, maxLineLength, '"');
      midFile.getline(inbuffer, maxLineLength, '"');
      nbrExtraAttributes--;
   }*/

   if (nbrExtraAttributes != 0) {
      mc2log << error << here << "Unused extra attributes" << endl;
   }

   // Skip the rest of the mid line, nothing there (we need to read 
   // past eol for the while-loop in GMSMap to be able to check eof)
   if (readRestOfLine)
      midFile.getline(inbuffer, maxLineLength);
   // else
   // Don't read the rest of the mid line, we have a map ssi coordinate 
   // to use for checking which map is the correct one

   return true;
}