Beispiel #1
0
int dequeueSamplingData(queue_info *qinfo, char *msg)
{
	char logBuffer[256] = "";

#ifdef DEBUG_LEVEL_1
	sprintf(logBuffer, "%s: [dequeueSamplingData] Start\n", getTimeInString(TIME_MODE_YMDHMS));
#ifdef DEBUG_LEVEL_3
	writeDebugLog(logBuffer);
#else
	writeSystemLog(logBuffer);
#endif
	puts(logBuffer);
#endif

	if(isEmptySamplingQueue(qinfo) || qinfo->num < 1)
		return ERR_EMPTY_QUEUE;

	strcpy(msg, qinfo->msg_queue[qinfo->head]);
	qinfo->head = (qinfo->head + 1) % S_QUEUE_SIZE;
	(qinfo->num)--;

#ifdef DEBUG_LEVEL_2
	sprintf(logBuffer, "%s: Current number of Queue: %d\n", getTimeInString(TIME_MODE_YMDHMS), qinfo->num);
	writeDebugLog(logBuffer);
	puts(logBuffer);
#endif

#ifdef DEBUG_LEVEL_2
	sprintf(logBuffer, "%s: Queue Head Num: %d\n%s: Queue Tail Num: %d\n", getTimeInString(TIME_MODE_YMDHMS), qinfo->head, getTimeInString(TIME_MODE_YMDHMS), qinfo->tail);
	writeDebugLog(logBuffer);
	puts(logBuffer);
#endif

#ifdef DEBUG_LEVEL_2
	sprintf(logBuffer, "%s: Dequeue MSG is \"%s\"\n", getTimeInString(TIME_MODE_YMDHMS), msg);
	writeDebugLog(logBuffer);
	puts(logBuffer);
#endif

#ifdef DEBUG_LEVEL_1
	sprintf(logBuffer, "%s: [dequeueSamplingData] Stop\n", getTimeInString(TIME_MODE_YMDHMS));
#ifdef DEBUG_LEVEL_3
	writeDebugLog(logBuffer);
#else
	writeSystemLog(logBuffer);
#endif
	puts(logBuffer);
#endif
	return DEQUEUE_DONE;
}
Beispiel #2
0
int enqueueSamplingData(queue_info *qinfo, char *msg)
{
	char logBuffer[256] = "";

#ifdef DEBUG_LEVEL_1
	sprintf(logBuffer, "%s: [enqueueSamplingData] Start\n", getTimeInString(TIME_MODE_YMDHMS));
#ifdef DEBUG_LEVEL_3
	writeDebugLog(logBuffer);
#else
	writeSystemLog(logBuffer);
#endif
	puts(logBuffer);
#endif

#ifdef DEBUG_LEVEL_2
	sprintf(logBuffer, "%s: Enqueue MSG is \"%s\"\n", getTimeInString(TIME_MODE_YMDHMS), msg);
	writeDebugLog(logBuffer);
	puts(logBuffer);
#endif

	if(isFullSamplingQueue(qinfo) || qinfo->num >= S_QUEUE_SIZE-1)
		return ERR_FULL_QUEUE_AFTER;

	strcpy(qinfo->msg_queue[qinfo->tail], msg);
	qinfo->tail = (qinfo->tail + 1) % S_QUEUE_SIZE;
	(qinfo->num)++;

#ifdef DEBUG_LEVEL_2
	sprintf(logBuffer, "%s: Current number of Queue: %d\n", getTimeInString(TIME_MODE_YMDHMS), qinfo->num);
	writeDebugLog(logBuffer);
	puts(logBuffer);
#endif

#ifdef DEBUG_LEVEL_2
	sprintf(logBuffer, "%s: Queue Head Num: %d\n%s: Queue Tail Num: %d\n", getTimeInString(TIME_MODE_YMDHMS), qinfo->head, getTimeInString(TIME_MODE_YMDHMS), qinfo->tail);
	writeDebugLog(logBuffer);
	puts(logBuffer);
#endif

#ifdef DEBUG_LEVEL_1
	sprintf(logBuffer, "%s: [enqueueSamplingData] Stop\n", getTimeInString(TIME_MODE_YMDHMS));
#ifdef DEBUG_LEVEL_3
	writeDebugLog(logBuffer);
#else
	writeSystemLog(logBuffer);
#endif
	puts(logBuffer);
#endif
	return ENQUEUE_DONE;
}
Beispiel #3
0
int Unit::meleeAttack( Unit *target ) {
   Item *melee_stack = chassis->getAllMelee();

   if (melee_stack == NULL)
      return -1;

   std::stringstream txt1;
   txt1 << ">I attack " << target->getName();
   writeSystemLog( txt1.str() );

   while (melee_stack != NULL) {
      int result = melee_stack->meleeAttack( target );
      if (result == 1) // Target destroyed
         break;

      melee_stack = melee_stack->alt_next;
   }
   return 1000;
}