Пример #1
0
/*第一个参数为收到消息的内容,第二个参数为标识是要产生子交易2,还是直接发送到前端,1表示产生子交易2,0表示发送到前端,-1表示拆分*/
void chongzhen(struct mymsg pmsg,int *chaifen,int *times)
{
    char result[21];
    char temp[21];
    int start=0;/*记录收到消息的交易状态在condition_p对应的下标*/
    char *condition_p[]= {"1###################","0###################","-1##################"};
    /*解析sql语句用的变量*/
    char sqltemp[200] = "select dealid from  deals where subdealid1='%s' and dealtype='%s'";
    char parent[200];
    char send[220];
    char sendtemp[220];/*存放消息的长度和消息正文*/
    int i, length;
    /*解析出消息的主键*/
    char tempdealid[21], dealid[21];
    char temptype[21], type[21];
    struct mymsg tempmsg,sqltype;
    key_t key;
    long typesql;
    /*取出消息的交易状态*/
    for(i=140; i<160; i++)
    {
        temp[i-140]=pmsg.msg_buf[i];
    }
    temp[20]='\0';

    for(i=0; i<3; i++)
    {
        if(strcmp(temp,condition_p[i])==0)
        {
            start=i;
            break;
        }
    }

    /*在这儿先判断收到的消息是第一次拆分出来的结果,还是第二次的回复消息*/
    /*所以在这儿需要查询数据库*/
    /*根据解析出来的消息找匹配*/
    for (i = 0; i < 20; i++)
    {
        tempdealid[i] = pmsg.msg_buf[i];
    }
    for (i = 160; i < 180; i++)
    {
        temptype[i - 160] = pmsg.msg_buf[i];
    }

    for (i = 0; i < 20; i++)
    {
        if (tempdealid[i] != '#')
        {
            dealid[i] = tempdealid[i];
        }
        else
        {
            dealid[i]='\0';
        }
        if (temptype[i] != '#')
        {
            type[i] = temptype[i];
        }
        else
        {
            type[i]='\0';
        }
    }
    sprintf(parent, sqltemp,dealid,type);/*替换掉sql中参数*/

    /*把length转化为字符串存入send数组中*/
    sprintf(sendtemp,"%010d",strlen(parent));
    length=strlen(parent);

    /*填充消息的正文内容*/
    for (i = 10; i < length + 10; i++)
    {
        sendtemp[i] = parent[i - 10];
    }
    sendtemp[i]='\0';

    /*将前10个字节用发送的消息内容的消息类型来填充*/
    key=ftok(".",'w');
    readMessageFromQueue(key,&sqltype,0);
    typesql=atol(sqltype.msg_buf);
    printf("读取到的sql类型为:%s\n",sqltype.msg_buf);
    sprintf(send,"%010ld",typesql);
    sprintf(temptype,"%010d",1);/*字段的个数*/
    for(i=10; i<20; i++)
    {
        send[i]=temptype[i-10];
    }
    /*将sendtemp的内容加入到send数组的后面*/
    length=20+strlen(sendtemp);
    for(i=20; i<length; i++)
    {
        send[i]=sendtemp[i-20];
    }
    send[i]='\0';/*加结束符*/
    printf("*************send is :%s====>",send);
    strcpy(tempmsg.msg_buf,send);
    tempmsg.msg_types=1;
    tempmsg.msg_buf[strlen(tempmsg.msg_buf)]='\0';
    printf("此处向数据库发送第一次查询数据:%s\n",tempmsg.msg_buf);
    key=ftok(".",'n');
    sendMessageToQueue(key,0,&tempmsg);
    /*等待查询结果*/
    key=ftok(".",'p');
    printf("key=%x\n",key);

    while(readMessageFromQueue(key,&tempmsg,typesql)<0) /*取出消息类型为1的消息*/
    {
    }
    /*解析查询结果,查询结果为10个字节的消息类型,10个字节表示有多少条记录,再10字节表示每条记录的长度*/
    for(i=20; i<30; i++)
    {
        temp[i-20]=tempmsg.msg_buf[i];
    }
    temp[10]='\0';
    length=atoi(temp);
    printf("===========length=%d\n",length);
    for(i=30; i<30+length; i++)
    {
        temp[i-30]=tempmsg.msg_buf[i];
    }
    temp[i-30]='\0';
    /*将tempmsg消息的内容替换掉*/
    strcpy(tempmsg.msg_buf,temp);

    printf("收到数据库查询结果:%s\n",tempmsg.msg_buf);
    strcpy(result,temp);

    /*默认的是把这条消息当作子消息1来对待的,将查询出来的dealId放在了result中,查询不到结果的为0*/

    if(strcmp(result,"0")!=0) /*说明收到的消息是子消息1回复过来的*/
    {
        /*如果start==0说明是交易,否则不产生子交易2*/
        *times=1;
        if(start==0)
        {
            *chaifen=1;/*如果为1表示需要产生子交易2,并且此条消息不发送到前端*/
        }
        else
        {
            *chaifen=0;/*为零表示不需要产生子交易2,并且此条消息发送到前端*/
        }

    }
    else /*说明是子交易二返回的消息*/
    {
        *times=2;
        printf("++++start=%d\n++++",start);
        /*如果消息的状态为交易则直接发送到前台,否则就要冲正*/
        if(start==0)
        {
            *chaifen=0;
        }

        else
        {
            /*找出子交易1*/
            char sqltemp[200] = "select subdealid1,clientid,customerid  from deals where subdealid2='%s' and dealtype='%s'";
            char resulttemp[21];
            int resultnum;
            *chaifen=-1;/*-1表示冲正*/
            int start;
            struct mymsg sqltype;
            long typesql;
            int mm;
            /*以后换成数据库后,就不需要了*/
            /*	int typestart[6]={2,1,2,0,1,0};*/
            /*	int typeback[6]={1,2,0,2,0,1};*/
            struct pathtype pathtype1;
            char csh_select_type[21];
            /*char *address[]={"192.168.5.97########","192.168.5.86########","192.168.5.108#######"};*/
            char rout_p[21];/*="192.168.5.102#######";*/
            /*	char *type_p[]={"type7###############","type8###############","type9###############","type10##############","type11##############","type12##############"};
             */
            memset(rout_p,0,21);
            idToIp(0,rout_p);
            for(mm=19; mm>=strlen(rout_p); mm--)
            {
                rout_p[mm]='#';
            }
            /*	产生冲正消息*/
            /*第二次查询数据库,找出子交易1的详细相关信息*/
            sprintf(parent, sqltemp,dealid,type);/*替换掉sql中参数*/

            /*把length转化为字符串存入send数组中*/
            sprintf(sendtemp,"%010d",strlen(parent));
            length=strlen(parent);

            /*填充消息的正文内容*/
            for (i = 10; i < length + 10; i++)
            {
                sendtemp[i] = parent[i - 10];
            }

            /*将前10个字节用发送的消息内容的消息类型来填充*/
            key=ftok(".",'w');
            readMessageFromQueue(key,&sqltype,0);
            typesql=atol(sqltype.msg_buf);
            sprintf(send,"%010ld",typesql);
            sprintf(temptype,"%010d",3);/*字段的个数*/
            for(i=10; i<20; i++)
            {
                send[i]=temptype[i-10];
            }
            /*将sendtemp的内容加入到send数组的后面*/
            length=20+strlen(sendtemp);
            for(i=20; i<length; i++)
            {
                send[i]=sendtemp[i-20];
            }
            send[i]='\0';/*加结束符*/

            strcpy(tempmsg.msg_buf,send);
            tempmsg.msg_types=1;
            tempmsg.msg_buf[strlen(tempmsg.msg_buf)]='\0';
            printf("此处向数据库发送第二次查询数据:%s\n",tempmsg.msg_buf);
            key=ftok(".",'n');
            sendMessageToQueue(key,0,&tempmsg);
            /*等待查询结果*/
            memset(tempmsg.msg_buf,0,sizeof(tempmsg));
            key=ftok(".",'p');
            while(readMessageFromQueue(key,&tempmsg,typesql)<0) /*取出消息类型为1的消息*/
            {
            }
            printf("resut ========>from is :%s\n",tempmsg.msg_buf);

            /*解析查询结果,查询结果为10个字节的消息类型,10个字节表示有多少条记录,再10字节表示每条记录的长度*/

            /*解析第一个查询数据*/
            for(i=20; i<30; i++)
            {
                temp[i-20]=tempmsg.msg_buf[i];
            }
            temp[10]='\0';
            length=atoi(temp);
            for(i=0; i<length; i++)
            {
                temp[i]=tempmsg.msg_buf[i+30];
            }
            temp[i]='\0';
            printf("temp is:%s\n",temp);
            /*将tempmsg消息的内容替换掉*/
            strcpy(tempmsg.msg_buf,temp);
            start=30+strlen(temp);
            /*解析第二个数据*/
            for(i=0; i<10; i++)
            {
                temp[i]=tempmsg.msg_buf[start];
                start++;
            }
            temp[i]='\0';
            length=atoi(temp);
            for(i=0; i<length; i++)
            {
                temp[i]=tempmsg.msg_buf[start];
                start++;
            }
            temp[i]='\0';
            printf("temp1is:%s\n",temp);
            strcat(tempmsg.msg_buf,temp);
            /*解析第三个数据*/
            for(i=0; i<10; i++)
            {
                temp[i]=tempmsg.msg_buf[start];
                start++;
            }
            temp[i]='\0';
            length=atoi(temp);
            for(i=0; i<length; i++)
            {
                temp[i]=tempmsg.msg_buf[start];
                start++;
            }
            temp[i]='\0';
            printf("temp2 is:%s\n",temp);
            strcat(tempmsg.msg_buf,temp);

            /*读取冲正交易序列号*/
            memset(sqltype.msg_buf,0,sizeof(sqltype));
            key=ftok(".",'o');
            readMessageFromQueue(key,&sqltype,0);
            sqltype.msg_buf[strlen(sqltype.msg_buf)]='\0';
            printf("chong zhen is:%s\n",sqltype.msg_buf);
            /*连接最后结果*/
            strcat(sqltype.msg_buf,tempmsg.msg_buf);
            /*加上消息的源和目地*/

            for (i = 160; i < 180; i++)
            {
                temptype[i - 160] = pmsg.msg_buf[i];
            }
            temptype[20]='\0';
            memset(csh_select_type,0,21);
            strcpy(csh_select_type,temptype);
            for(mm=0; mm<20; mm++)
            {
                if(temptype[mm]!='#')
                {
                    csh_select_type[mm]=temptype[mm];
                }
                else
                {
                    break;
                }
            }
            select_type2_byname(csh_select_type,&pathtype1);
            /*
                        for(i=0;i<6;i++){
                        	if(strcmp(temptype,type_p[i])==0){
                        	 break;
                        	}
                        }
            printf("i is :%d\n",i);
            */
            /*把源加上*/
            memset(temp,0,21);
            strcpy(temp,pathtype1.destination_ip1);
            for(mm=19; mm>=strlen(temp); mm--)
            {
                temp[mm]='#';
            }
            strcat(sqltype.msg_buf,temp);
            /*把目地加上去*/
            /*strcpy(temp,address[typeback[i]]);*/
            strcat(sqltype.msg_buf,pathtype1.destination_ip2);

            printf("收到数据库第二次查询数据,并且写入了冲正队列:%s\n",sqltype.msg_buf);
            key=ftok(".",'q');
            sqltype.msg_types=1;
            sendMessageToQueue(key,0,&sqltype);
        }
    }
}
Пример #2
0
/*此函数根据子消息找出父交易号*/
void findfatherid(struct mymsg pmsg,char *result,int times)
{
    char sqltemp[200] = "select dealid from  deals where subdealid1='%s' and dealtype='%s'";
    char sqltemp1[200]="select dealid from  deals where subdealid2='%s' and dealtype='%s'";
    char parent[220];
    char send[220];
    char id[21],type[21],temp[21];
    int i,length;
    key_t key;
    struct mymsg tempmsg,sqltype;
    long typesql;
    /*解析出type和id*/
    for(i=0; i<20; i++)
    {
        if(pmsg.msg_buf[i]!='#')
        {
            id[i]=pmsg.msg_buf[i];
        }
        else
        {
            id[i]='\0';
        }
        if(pmsg.msg_buf[160+i]!='#')
        {
            type[i]=pmsg.msg_buf[160+i];
        }
        else
        {
            type[i]='\0';
        }
    }
    if(times==1)
        sprintf(parent,sqltemp,id,type);
    else if(times==2)
    {
        sprintf(parent,sqltemp1,id,type);
    }
    key=ftok(".",'w');
    readMessageFromQueue(key,&sqltype,0);
    typesql=atol(sqltype.msg_buf);
    printf("读取到的sql类型为:%s\n",sqltype.msg_buf);
    sprintf(send,"%010ld",typesql);

    sprintf(temp,"%010d",1);
    for(i=0; i<20; i++) /*字段个数*/
    {
        send[10+i]=temp[i];
    }
    sprintf(temp,"%010d",strlen(parent));/*消息正文的长度*/
    for(i=0; i<20; i++)
    {
        send[20+i]=temp[i];
    }
    length=strlen(parent);
    for(i=0; i<length; i++)
    {
        send[30+i]=parent[i];
    }
    send[30+i]='\0';
    printf("send is :%s\n",send);
    strcpy(tempmsg.msg_buf,send);
    tempmsg.msg_types=1;
    key=ftok(".",'n');
    sendMessageToQueue(key,0,&tempmsg);
    printf("查询父id的sql语句:%s\n",tempmsg.msg_buf);
    key=ftok(".",'p');
    while(readMessageFromQueue(key,&tempmsg,typesql)<0) /*取出消息类型为1的消息*/
    {
    }
    for(i=0; i<10; i++)
    {
        temp[i]=tempmsg.msg_buf[20+i];
    }
    length=atoi(temp);
    for(i=0; i<length; i++)
    {
        temp[i]=tempmsg.msg_buf[30+i];
    }
    temp[i]='\0';
    printf("查得附灰椎膇d号如下:%s\n",temp);
    strcpy(result,temp);
}
Пример #3
0
/*更新父交易的交易状态*/
void sendsubupdatefathersql(struct mymsg pmsg)
{
    char result[21];
    char temp[21];
    int start=0;/*记录收到消息的交易状态在condition_p对应的下标*/
    /*    char *type_p[]={"type1###############","type2###############","type3###############","type4###############","type5###############","type6###############"};
    	int typestart[6]={1,2,0,2,0,1};
    	char *address[]={"192.168.5.97########","192.168.5.86########","192.168.5.84########"};*/
    /* char rout_p[]="192.168.5.85########";*/
    /*解析sql语句用的变量*/
    char updateSql[300]="update subdeals set SourceId='%s', DestinationId='%s', DealStatus='%s' where DealId='%s'";
    char parent[300];
    char send[320];
    char sendtemp[320];/*存放消息的长度和消息正文*/
    int i, j,length;
    /*解析出消息的主键*/
    char tempdealid[21], dealid[21];
    char temptype[21], b[8][21],type[21],s[8][21],id[14];
    struct mymsg tempmsg,sqltype,sqlmsg;
    key_t key;
    long typesql;
    /*解读消息,读出相关的字段,以便形成update sql语句*/
    for(i=0; i<9; i++)
    {
        for(j=0; j<20; j++)
        {
            s[i][j]=pmsg.msg_buf[i*20+j];
            if(s[i][j]!='#')
            {
                b[i][j]=s[i][j];
            }
            else
            {
                b[i][j]='\0';
                break;
            }

        }
    }
    findfatherid(pmsg,id,2);
    sprintf(parent,updateSql,b[3],b[4],b[7],id);

    /*把length转化为字符串存入send数组中*/
    sprintf(sendtemp,"%010d",strlen(parent));
    length=strlen(parent);

    /*填充消息的正文内容*/
    for (i = 10; i < length + 10; i++)
    {
        sendtemp[i] = parent[i - 10];
    }
    sendtemp[i]='\0';

    /*将前10个字节用发送的消息内容的消息类型来填充*/
    key=ftok(".",'w');
    readMessageFromQueue(key,&sqltype,0);
    typesql=atol(sqltype.msg_buf);
    /*   printf("读取到的sql类型为:%s\n",sqltype.msg_buf);*/
    sprintf(send,"%010ld",typesql);
    sprintf(temptype,"%010d",1);/*字段的个数*/
    for(i=10; i<20; i++)
    {
        send[i]=temptype[i-10];
    }
    /*将sendtemp的内容加入到send数组的后面*/
    length=20+strlen(sendtemp);
    for(i=20; i<length; i++)
    {
        send[i]=sendtemp[i-20];
    }
    send[i]='\0';/*加结束符*/
    /*    printf("*************send is :%s====>",send);		*/
    strcpy(tempmsg.msg_buf,send);
    tempmsg.msg_types=1;
    tempmsg.msg_buf[strlen(tempmsg.msg_buf)]='\0';
    key=ftok(".",'n');
    sendMessageToQueue(key,0,&tempmsg);
    /*  printf("发送到数据库的sql语句为:%s\n",tempmsg.msg_buf);*/
}
Пример #4
0
void sendsubinsertsql(struct mymsg pmsgs)
{
    char insertSql[300]="insert into subdeals values ('%s','%s','%s','%s','%s','%s','%s','%s','%s')";
    char parent[320];
    char send[320],sendtemp[320];
    char id[21],s[8][21],b[8][21],type[21],temp[21],temptype[21];
    int i,j,length;
    key_t key;
    struct mymsg tempmsg,sqlmsg,pmsg,sqltype;
    long typesql;
    /*从产生交易号的队列中取出子交易号*/
    printf("********************8%s",pmsgs.msg_buf);
    for(i=0; i<9; i++)
    {
        for(j=0; j<20; j++)
        {
            s[i][j]=pmsgs.msg_buf[i*20+j];
            if(s[i][j]!='#')
            {
                b[i][j]=s[i][j];
            }
            else
            {
                b[i][j]='\0';
                break;
            }

        }
    }
    sprintf(parent,insertSql,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8]);
    /*      printf("shuzu de neirong wei :%s,%s,%s,%s,%s,%s,%s,%s,%s",b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8]);*/
    /*把length转化为字符串存入send数组中*/
    sprintf(sendtemp,"%010d",strlen(parent));
    length=strlen(parent);

    /*填充消息的正文内容*/
    for (i = 10; i < length + 10; i++)
    {
        sendtemp[i] = parent[i - 10];
    }
    sendtemp[i]='\0';

    /*将前10个字节用发送的消息内容的消息类型来填充*/
    key=ftok(".",'w');
    readMessageFromQueue(key,&sqltype,0);
    typesql=atol(sqltype.msg_buf);
    /*      printf("读取到的sql类型为:%s\n",sqltype.msg_buf);*/
    sprintf(send,"%010ld",typesql);
    sprintf(temptype,"%010d",1);/*字段的个数*/
    for(i=10; i<20; i++)
    {
        send[i]=temptype[i-10];
    }
    /*将sendtemp的内容加入到send数组的后面*/
    length=20+strlen(sendtemp);
    for(i=20; i<length; i++)
    {
        send[i]=sendtemp[i-20];
    }
    send[i]='\0';/*加结束符*/
    /*      printf("*************send is :%s====>",send);		*/
    strcpy(tempmsg.msg_buf,send);
    tempmsg.msg_types=1;
    tempmsg.msg_buf[strlen(tempmsg.msg_buf)]='\0';
    key=ftok(".",'n');
    sendMessageToQueue(key,0,&tempmsg);
    /* printf("111111111111111111:发送到数据库的sql语句为:%s\n",tempmsg.msg_buf);*/
}
Пример #5
0
int game_host::performUpdate(string upd)
{
	int updateType = 0;
	UpdMess update(upd);
	updateType = update.getType();

	if(updateType == TOWER)
	{
		int subType = update.getVal(0);
		//Tower Placement:		UpdMess(Player[1], TOWER, TOWERPLACE[2], TowerX[2], Tower[Y]);
		if(subType == TOWERPLACE)
		{
			// placeTower(int playerNumber, int towerType, int x, int y);
			if(isEmptyLocation(update.getVal(1), update.getVal(2)))
			{
				placeTower(update.getPlayer(), STRUCTURE, update.getVal(1), update.getVal(2));
			}
		}	
		else if(subType == MINEPLACE)
		{
			if(isEmptyLocation(update.getVal(1), update.getVal(2)))
			{
				placeTower(update.getPlayer(), MINETOWER, update.getVal(1), update.getVal(2));
			}
		}
		//Tower Upgrade:			UpdMess(Player[1], TOWER, TOWERUPGRADE[2], TowerID[4]);
		else if(subType == TOWERUPGRADE)
		{
			if(towerList.checkForObjectWithID(update.getId1()) == true)
			{
				if(towerList.getNodeWithID(update.getId1())->getData()->getType() != STRUCTURE)
				{
					if(towerList.getNodeWithID(update.getId1())->getData()->upgrade())
					{
						sendMessageToQueue(UpdMess(update.getPlayer(), TOWER, TOWERUPGRADE, update.getId1()).getMT());
					}
				}
			}
		}
		//Tower ChangeType:		UpdMess(Player[1], TOWER, TOWERCHANGE[2], TowerID[4], newType[2]);	
		else if(subType == TOWERCHANGE)
		{
			if(towerList.checkForObjectWithID(update.getId1()) == true)
			{
				if(towerList.getNodeWithID(update.getId1())->getData()->getType() == STRUCTURE)
				{
					return changeStructure(update.getId1(), update.getVal(1));
				}
				else if(towerList.getNodeWithID(update.getId1())->getData()->getType() == NORMCREEPTOWER)
				{
					if(towerList.getNodeWithID(update.getId1())->getData()->changeType(update.getVal(1)))
					{
						sendMessageToQueue(UpdMess(update.getPlayer(), TOWER, TOWERCHANGE, update.getId1(),update.getVal(1)).getMT());
					}
				}
			}
		}
		//Tower Toggle Pause:		UpdMess(Player[1], TOWER, TOWERTOGGLE[2], TowerID[4], newValue);
		else if(subType == TOWERTOGGLE)
		{
			if(towerList.checkForObjectWithID(update.getId1()))
			{
				int towerTypeRec = towerList.getNodeWithID(update.getId1())->getData()->getType();
				if(towerList.getNodeWithID(update.getId1())->getData()->getType() >= NORMCREEPTOWER && towerList.getNodeWithID(update.getId1())->getData()->getType() <= FATTYCREEPTOWER)
				{
					if(update.getVal(1) == 1)
						towerList.getNodeWithID(update.getId1())->getData()->pause();
					else if(update.getVal(1) == 0)
						towerList.getNodeWithID(update.getId1())->getData()->unpause();
					sendMessageToQueue(UpdMess(towerList.getNodeWithID(update.getId1())->getData()->getPlayer(), TOWER, TOWERTOGGLE, update.getId1(), towerList.getNodeWithID(update.getId1())->getData()->isPaused()).getMT());
				}
			}
		}
		else if(subType == TOWERDELETE)
		{	
			if(towerList.checkForObjectWithID(update.getId1()))
			{
				removeTower(update.getId1(), update.getPlayer());
			}
		}

	}
	else if(updateType == BASE)
	{
		int subType = update.getVal(0);
		if(subType == UPGRADE)
		{
			if(this->getPlayer(update.getPlayer())->getMoney() >= BASEUPGRADECOST)
			{
				if(update.getPlayer() == 1)
				{
					if(this->p1Spawner->getLevel() < 5 && players[0].getMoney() >= (p1Spawner->getLevel() + 1) * BASEUPGRADECOST)
					{
						players[0].spendMoney((p1Spawner->getLevel() + 1) * BASEUPGRADECOST);
						this->p1Spawner->setLevel(this->p1Spawner->getLevel() + 1);
						sendMessageToQueue(UpdMess(1, BASE, UPGRADE).getMT());
					}
				}
				else if(update.getPlayer() == 2)
				{
					if(this->p2Spawner->getLevel() < 5 && players[1].getMoney() >= (p2Spawner->getLevel() + 1) * BASEUPGRADECOST)
					{
						players[1].spendMoney((p2Spawner->getLevel() + 1) * BASEUPGRADECOST);
						this->p2Spawner->setLevel(this->p2Spawner->getLevel() + 1);
						sendMessageToQueue(UpdMess(2, BASE, UPGRADE).getMT());
					}
				}
			}
		}
		else if(subType == ADDTYPE)
		{
			int addType = update.getVal(1);
			if(!(addType >= FAST && addType <= FATTY))
				return -1;
			if(update.getPlayer() == 1)
			{
				if(this->p1Spawner->isInSpawner(addType))
					return -1;	// Already in the spawner
			}
			else if(update.getPlayer() == 2)
			{
				if(this->p2Spawner->isInSpawner(addType))
					return -1;  // Already in the spawner
			}
			else
				return -1;
			if(this->getPlayer(update.getPlayer())->getMoney() >= addSpawnArr[addType])
			{
				this->getPlayer(update.getPlayer())->spendMoney(addSpawnArr[addType]);
				if(update.getPlayer() == 1)
				{
					this->p1Spawner->addCreepType(addType);
					sendMessageToQueue(UpdMess(1, BASE, ADDTYPE, addType).getMT());
				}
				else
				{
					this->p2Spawner->addCreepType(addType);
					sendMessageToQueue(UpdMess(2, BASE, ADDTYPE, addType).getMT());
				}
			}
		}
		else
			return -1;
	}
	else 
		return -1;
	sendMessageToQueue(UpdMess(1, PLAYERUPDATE, getPlayer(1)->getHealth(), getPlayer(1)->getMoney()).getMT());
	sendMessageToQueue(UpdMess(2, PLAYERUPDATE, getPlayer(2)->getHealth(), getPlayer(2)->getMoney()).getMT());
	return 0;
}