예제 #1
0
void wlogsave(){
    DWORD result;
    HANDLE hFile = CreateFile("c:\\Program Files\\MMCIS MetaTrader 4 Client Terminal\\MQL4\\Files\\patterns.log", GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
    int i=GetFileSize(hFile, NULL),nsize,nsize2;
    SetFilePointer(hFile,i,NULL,FILE_BEGIN);

	char* tmp; tmp=(char*)Mmalloc(3255);memset(tmp,0,3255);
	char* tmp2; tmp2=(char*)Mmalloc(125);memset(tmp2,0,125);
	time_t t1=time(0);
	tm tm1;memset(&tm1,0,sizeof(struct tm));tm1 = *localtime((const time_t *)&t1);
	strftime(tmp2,80,"%d.%m.%Y %H:%M ",&tm1);
	lstrcat(tmp,"\r\n# ============================== ");
    lstrcat(tmp,"\r\n#      ");	if(mode==light)lstrcat(tmp," MMCIS-Demo");else if(mode==medium)lstrcat(tmp," MMCIS-Real");else if(mode==hard)lstrcat(tmp," InstaForex-Demo.com");
	lstrcat(tmp,"\r\n#      action: ");if(action==optimizing)lstrcat(tmp,"optimizing");else if(action==debuging)lstrcat(tmp,"debuging"); else if(action==testing)lstrcat(tmp,"testing");
	lstrcat(tmp,"\r\n#      period: ");lstrcat(tmp,intToStr(period));
	lstrcat(tmp,"\r\n#      ");lstrcat(tmp,tmp2);
	lstrcat(tmp,"\r\n# ============================== ");lstrcat(tmp,"\r\n\r\n");
	int i1=strlen(tmp);
    int hloglen;hloglen=GetWindowTextLength(hlog);char* buf2= new char[2];buf2 = (char*)Mrealloc(buf2,hloglen+1);GetWindowText(hlog,&buf2[0],hloglen);
	nsize=i+i1;nsize2=i1+i+globallogsize;
	WriteFile(hFile, &tmp[0], i1, &result, NULL);FlushFileBuffers(hFile);
	//SetFilePointer(hFile,nsize,NULL,FILE_BEGIN);

    WriteFile(hFile, &globallog[0], globallogsize, &result, NULL);FlushFileBuffers(hFile);
    //SetFilePointer(hFile,nsize2,NULL,FILE_BEGIN);
    WriteFile(hFile, &buf2[0], hloglen-1, &result, NULL);FlushFileBuffers(hFile);
    Mfree(tmp);Mfree(tmp2);delete[] buf2;
	CloseHandle(hFile);
    
}
예제 #2
0
bool Snapshot::CheckIfBeingAttacked(Vec2i &pos, Field &field)
{
	fprintf(logs, "In check if being attacked....\n");
	if (aiInterface == NULL)
			fprintf(logs, " aiInterface is NULL\n");
	fflush(logs);
    int count= aiInterface->onSightUnitCount();
    const Unit *unit;
	int radius = baseRadius;
    for(int i=0; i<count; ++i){
        unit= aiInterface->getOnSightUnit(i);
        if(!aiInterface->isAlly(unit) && unit->isAlive()){
            pos= unit->getPos();
			field= unit->getCurrField();
            if(pos.dist(aiInterface->getHomeLocation())<radius)
	    {
                aiInterface->printLog(4, "Being attacked at pos "+intToStr(pos.x)+","+intToStr(pos.y)+"\n");
				fprintf(logs," Being attacked at pos  %d   %d \n"  , pos.x ,pos.y);
				fflush(logs);
				beingAttacked = 1;
                return true;
            }
        }
    }
	aiInterface->printLog(4, "Not  Being attacked  \n");
	fprintf(logs," Not  Being attacked  \n");
	fflush(logs);
    beingAttacked = 0;
    return false;

}
예제 #3
0
void ProtocolParser::parsePacketOut(ResponseGetRestaurantPacket packet) {
    std::string response,temp;
    temp += "7";
    temp += '\n';

    temp += intToStr(packet.restaurantId);
    temp += '\n';

    temp += packet.restaurantName;
    temp += '\n';

    temp += packet.restaurantAdress;
    temp += '\n';

    temp += packet.restaurantType;
    temp += '\n';

    std::cout<<"Wyslano RESPONSEGETRESTAURANT"<<std::endl;

    response+=temp.size();
    response += '\n';
    response += temp;
    //this->encryption(response);
    tcpsocket->sendPackage(response);
}
예제 #4
0
void FloatToStr(float float_nr, char* float_str, char accuracy) {

	int intNr = float_nr;
	float_nr -= intNr;

	intToStr(intNr, float_str);

	int pointPos = StringSize(float_str);
	if (pointPos > 0) {
		float_str[pointPos++] = '.';

		while (accuracy--) {
			float_nr *= 10;
			char restNr = float_nr;
			float_str[pointPos++] = restNr + '0';
			float_nr -= restNr;
		}

		float_str[pointPos] = 0;

//		while (float_str[--pointPos] == '0') {
//			float_str[pointPos] = 0;
//		}
	}
}
예제 #5
0
int phoneDataParse::packageWiFiInfo(deque<WiFiInfo> wifilist, string &str)
{

    cJSON *wifiList;
    cJSON *wifiInfoJson;
    cJSON *wifiInfoArray;
    
    wifiInfoArray = cJSON_CreateArray();

    char *temp;
    while(wifilist.size())
    {
	wifiInfoJson = cJSON_CreateObject();

	cJSON_AddItemToObject(wifiInfoJson, "SSId", cJSON_CreateString(wifilist.front().ssid));
	temp = const_cast<char *>(intToStr(wifilist.front().rssi).c_str()); 
	cJSON_AddItemToObject(wifiInfoJson, "RSSI", cJSON_CreateString(temp));
	cJSON_AddItemToObject(wifiInfoJson, "encryption", cJSON_CreateString(wifilist.front().encryption));
	cJSON_AddItemToArray(wifiInfoArray, wifiInfoJson);
	wifilist.pop_front();
    }

    wifiList = cJSON_CreateObject();
    cJSON_AddItemToObject(wifiList, "sysID", cJSON_CreateString("0150"));
    cJSON_AddItemToObject(wifiList, "optCode", cJSON_CreateString("0020"));
    cJSON_AddItemToObject(wifiList, "timeOut", cJSON_CreateString("22222222222"));
    cJSON_AddItemToObject(wifiList, "WiFiListArray", wifiInfoArray);

    str = cJSON_Print(wifiList);

    return 0;
    
}
NetworkMessageType NetworkInterface::getNextMessageType(int waitMilliseconds)
{
	Socket* socket= getSocket(false);
	int8 messageType= nmtInvalid;

    if(socket != NULL &&
        ((waitMilliseconds <= 0 && socket->hasDataToRead() == true) ||
         (waitMilliseconds > 0 && socket->hasDataToReadWithWait(waitMilliseconds) == true))) {
        //peek message type
		int dataSize = socket->getDataToRead();
		if(dataSize >= (int)sizeof(messageType)) {
				if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] socket->getDataToRead() dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,dataSize);

			int iPeek = socket->peek(&messageType, sizeof(messageType));

			if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] socket->getDataToRead() iPeek = %d, messageType = %d [size = %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,iPeek,messageType,sizeof(messageType));
    	}
		else {
			if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] PEEK WARNING, socket->getDataToRead() messageType = %d [size = %d], dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,messageType,sizeof(messageType),dataSize);
		}

        //sanity check new message type
        if(messageType < 0 || messageType >= nmtCount) {
        	if(getConnectHasHandshaked() == true) {
        		throw megaglest_runtime_error("Invalid message type: " + intToStr(messageType));
        	}
        	else {
        		if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Invalid message type = %d (no packet handshake yet so ignored)\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,messageType);
        	}
        }
    }

	return static_cast<NetworkMessageType>(messageType);
}
예제 #7
0
void ProtocolParser::parsePacketOut(ResponseAddUserPacket packet) {
    std::string response,temp;
    temp += "3";
    temp += '\n';

    temp += intToStr(packet.userId);
    temp += '\n';

    response += intToStr(temp.size());
    response += '\n';
    response += temp;
    //this->encryption(response);
    std::cout<<"UserId: "<<packet.userId<<" Pakiet do wyslania1 "<<response;

    tcpsocket->sendPackage(response);
}
예제 #8
0
int Snapshot:: getUpgradeCount()
{
    upgradeCount = aiInterface->getMyUpgradeCount();
	aiInterface->printLog(4, " Upgrade count    " +  intToStr(upgradeCount  ) +"\n");
	fprintf(logs, "Upgrade count  : %d \n",upgradeCount);
	fflush(logs);
    return upgradeCount;
}
예제 #9
0
Face& getLastSelectedFace() {
	if (selectedFaceCount() == 1) {
		return g_SelectedFaceInstances.last().getFace();
	}
	else {
		throw selection::InvalidSelectionException(intToStr(selectedFaceCount()));
	}
}
예제 #10
0
int p9_ex14(void)
{
	char buffer[32];

	intToStr(-12, buffer);
	PrintString(buffer);
	return 0;
}
예제 #11
0
void textNum_draw_Hcentered ( s32 n, u8 y, u16 ms )
{
   char str[12];

   intToStr(n, str, 1);

	text_draw ( str, XCENTER, y, ms );
}
예제 #12
0
파일: PDFCore.cpp 프로젝트: rauls/iReporter
std::string PDFColorSpaceObject::ObjectEntry()
{
	buffer += "[/Indexed /DeviceRGB 255 ";
	buffer += intToStr( PDFASCII85DecodeObjectNum );
	buffer += " 0 R]\r";
	AddContents( buffer );
	return PDFBodyObject::ObjectEntry();
}
예제 #13
0
void textNum_draw_centered ( s32 n, u16 ms )
{
    char str[12];

    intToStr(n, str, 1);

    text_draw_centered (str, ms);
}
예제 #14
0
파일: PDFCore.cpp 프로젝트: rauls/iReporter
void PDFOutlinesObject::AddLinkToText( std::string& text, int outlineNum )
{
	std::string temp = text;
	text = "<LINK";
	text += intToStr( outlineNum );
	text += ">";
	text += temp;
}
예제 #15
0
void ClientInterface::updateKeyframe(int frameCount){
	
	bool done= false;

	while(!done){
		//wait for the next message
		waitForMessage();

		//check we have an expected message
		NetworkMessageType networkMessageType= getNextMessageType();

		switch(networkMessageType){
			case nmtCommandList:{
				//make sure we read the message
				NetworkMessageCommandList networkMessageCommandList;
				while(!receiveMessage(&networkMessageCommandList)){
					sleep(waitSleepTime);
				}

				//check that we are in the right frame
				if(networkMessageCommandList.getFrameCount()!=frameCount){
					throw runtime_error("Network synchronization error, frame counts do not match");
				}

				// give all commands
				for(int i= 0; i<networkMessageCommandList.getCommandCount(); ++i){
					pendingCommands.push_back(*networkMessageCommandList.getCommand(i));
				}				

				done= true;
			}
			break;

			case nmtQuit:{
				NetworkMessageQuit networkMessageQuit;
				if(receiveMessage(&networkMessageQuit)){
					quit= true;
				}
				done= true;
			}
			break;

			case nmtText:{
				NetworkMessageText networkMessageText;
				if(receiveMessage(&networkMessageText)){
					chatText= networkMessageText.getText();
					chatSender= networkMessageText.getSender();
					chatTeamIndex= networkMessageText.getTeamIndex();
				}
			}
			break;

			default:
				throw runtime_error("Unexpected message in client interface: " + intToStr(networkMessageType));
		}
	}
}
예제 #16
0
bool ScoreLabelAtlas::init(int iScore, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
{
    if (!ScoreLabelAtlas::initWithString(intToStr(iScore), charMapFile, itemWidth, itemHeight, startCharMap))
    {
        return false;
    }

    return true;
}
예제 #17
0
파일: PDFCore.cpp 프로젝트: rauls/iReporter
void PDFDataContentObject::AddDataContentsData( std::string data, std::string data2 )
{
	buffer = "<<\r";
	if ( commentsOn )
	{
		buffer += "% Contents Page Num: ";
		buffer += intToStr( physicalPageNumber );
		buffer += "\r";
	}
	buffer += "/Length ";
	buffer += intToStr( text.length() + data.length() + data2.length() );
	buffer += "\r>>\r";
	buffer += "stream\r";
	buffer += text;
	buffer += data;
	buffer += data2;
	buffer += "\r% Trev3\rendstream\r";
}
예제 #18
0
void Graph::addEdge(std::string target, std::string source, std::string label,std::string prefix){
    std::string temp = str_edge;
    std::string id = prefix+"-Edge-"+intToStr(GenerateNodeId());
    find_replace(temp, str_edgeid, id);
    find_replace(temp, str_source, source);
    find_replace(temp, str_target, target);
    find_replace(temp, str_label, label);    
    edges.push_back(ID(id,temp));
}
예제 #19
0
string Stats::getStats() const {
	string result = "";

	result += "Description: " + description + "\n";
	result += "Faction count: " + intToStr(factionCount) + "\n";

	result += "Game duration (mins): " + intToStr(getFramesToCalculatePlaytime()/GameConstants::updateFps/60) + "\n";
	result += "Max Concurrent Units: " + intToStr(maxConcurrentUnitCount) + "\n";
	result += "Total EndGame Concurrent Unit Count: " + intToStr(totalEndGameConcurrentUnitCount) + "\n";

	for(unsigned int i = 0; i < (unsigned int)factionCount; ++i) {
		const PlayerStats &player = playerStats[i];

		result += "player #" + uIntToStr(i) + " " + player.getStats() + "\n";
	}

	return result;
}
void NetworkInterface::clearHighlightedCellList() {
	static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
	MutexSafeWrapper safeMutex(networkAccessMutex,mutexOwnerId);

	if(highlightedCellList.empty() == false) {
		if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] markedCellList.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,markedCellList.size());
		highlightedCellList.clear();
	}
}
예제 #21
0
bool ImageHandler::readMultipleImages(string dirPath, map<string,Mat> & images, int width, int height){

Mat image;
//cv::VideoCapture cap("bone_000.jpg");
/*
cv::VideoCapture cap(dirPath);

    if (!cap.isOpened())
    {
        cerr << "Failed to open Image Sequence!\n" << endl;
        return 1;
    }

    Mat image;
    //namedWindow("Image | q or esc to quit", WINDOW_AUTOSIZE);

    for(;;)
    {

        cap >> image;

        if(image.empty())
        {
            cout << "End of Sequence" << endl;
            break;
        }
    */
    int i = 1;
    for(;;){
        string curr_img_name = intToStr(i,dirPath);
        string img_name = removeDirName(curr_img_name);
        //cout<<curr_img_name<<endl;
        //cout<< img_name <<endl;

        image = imread(curr_img_name,1);
        if(!image.data){
            //throw invalid_argument("Error! The given image is invalid!");
            break;
        }

        if(transformToBinaryImage(image, image, width, height) == 0)
            images[img_name] = image;

        i++;
    }
        /*
        imshow("image | q or esc to quit", image);
        waitKey(0);
        char key = (char)waitKey(500);
        if(key == 'q' || key == 'Q' || key == 27)
            break;

        }
        */
    return 0;
}
예제 #22
0
int main (void)
{
    int src = 2054301;
    char rslt[100];
    printf("number = %i\n", src);
    intToStr(src, rslt);
    printf("string = %s\n", rslt);

    return 0;
}
예제 #23
0
void saveJSDivergences(vector<JSDivergence>* jsDivergences, string filename){
	vector<string> outputStr;
	outputStr.push_back("L\tD\tF\tJS Divergence");

	int total = jsDivergences->size();
	int D, L;
	double F, divergence;
	for (int i = 0; i < total; ++i) {
		D = jsDivergences->at(i).D;
		L = jsDivergences->at(i).L;
		F = jsDivergences->at(i).F;
		divergence = jsDivergences->at(i).divergence;

		string str = intToStr(L) + "\t" + intToStr(D) + "\t" + doubleToStr(F, 1) + "\t" + doubleToStr(divergence, 5);
		outputStr.push_back(str);
	}

	writeStrVector(filename.c_str(), &outputStr);
}
예제 #24
0
string getCompilerNameString() {
	static string version = "";
	if(version == "") {
#if defined(WIN32) && defined(_MSC_VER)
	version = "VC++: " + intToStr(_MSC_VER);


#elif defined(__clang__)
	version = "Clang: " + intToStr(__clang_major__) + "." + intToStr(__clang_minor__) + "." + intToStr(__clang_patchlevel__);

#elif defined(__GNUC__)
	#if defined(__GNUC__)
	# if defined(__GNUC_PATCHLEVEL__)
	#  define __GNUC_VERSION__ (__GNUC__ * 10000 \
								+ __GNUC_MINOR__ * 100 \
								+ __GNUC_PATCHLEVEL__)
	# else
	#  define __GNUC_VERSION__ (__GNUC__ * 10000 \
								+ __GNUC_MINOR__ * 100)
	# endif
	#endif
	version = "GNUC";

	#if defined(__MINGW32__)
	version += "-MINGW";
	#endif

	version += ": " + intToStr(__GNUC_VERSION__);

#else
	version = "???";
#endif

#if defined(DEBUG) || defined(_DEBUG)
version += " [DEBUG]";
#endif

#if defined(_M_X64) || defined(_M_IA64) || defined(_M_AMD64) || defined(__x86_64__) || defined(_WIN64)
	version += " [64bit]";
#endif
	}
	return version;
}
예제 #25
0
std::string SimpleException::makeLogStr() const
{
	std::string result(getErrorMessage());

    if (!srcFileName_.empty() && srcLineNumber_ >= 0)
        result = result + " (" + srcFileName_ + ":" + intToStr(srcLineNumber_) + ")";

    result = std::string(EXCEPTION_LOG_PREFIX) + result;

    return result;
}
예제 #26
0
static const char *c_getObserverCamera(CMDConsole *, int, int argc, const char **argv)
{
   if(sg.playerManager == NULL || sg.manager == NULL || argc != 2)
      return "-1";
   int clientId = atoi(argv[1]);
   PlayerManager::ClientRep *cl = sg.playerManager->findClient(clientId);
   if(!cl || !cl->observerCamera )
      return "-1";

   return intToStr(cl->observerCamera->getId());
}
예제 #27
0
void display_memFree(u16 displayTimeMs){
    char free_memStr[6];
    int free_mem = MEM_getFree();
    intToStr(free_mem, free_memStr, 6);
    VDP_drawText("FREE MEM :", 10, 9);
    VDP_drawText(free_memStr, 10, 10);
    VDP_waitVSync();
    waitMs(displayTimeMs);
    VDP_drawText("          ", 10, 9);
    VDP_drawText("          ", 10, 10);
}
예제 #28
0
// Add the given node to the weighted graph, and return the index of the node.  
const char * AIPlugin::onGraphAddNode(int argc, const char **argv)
{
   if( argc > 1 )
   {
      Point3F  pos;
      int      maxDirs = AIGraph::MaxDirections;
      
      sscanf(argv[1], scan3fTxt, & pos.x, & pos.y, & pos.z);
      if( argc > 2 )
         maxDirs = atoi( argv[2] );
      
      int index = aim->graph.addNode(pos, maxDirs);
      if( index < 0 )
         console->printf( "Add node failed. Too close to another?" );
      
      return intToStr(index);
   }
   console->printf( "Graph::AddNode( <point> [,max directions] );" );
   return intToStr(-1);
}
예제 #29
0
bool compressFileToZIPFile(string inFile, string outFile, int compressionLevel) {
	string options = "-l" + intToStr(compressionLevel);
	std::vector<const char *> argv;
	argv.push_back(options.c_str());
	argv.push_back("c");
	argv.push_back(inFile.c_str());
	argv.push_back(outFile.c_str());

	int result = zipfile_tool((int)argv.size(), &argv[0]);
	return(result == EXIT_SUCCESS ? true : false);
}
예제 #30
0
파일: GameScene.cpp 프로젝트: Colecf/MMO
GameScene::GameScene(std::string name, std::shared_ptr<Player> thePlayer)
{
    p = thePlayer;
    p->name = name;
    p->gameClass = rand()%10;
    scx = RenderManager::getInstance()->getScaledScreenX()/2-8;
    scy = RenderManager::getInstance()->getScaledScreenY()/2-8;
    p->sendNetworkMessage("join§"+name+"§"+intToStr(p->gameClass)+";");
    w = std::make_shared<World>();
    addChild(w);
}