Exemplo n.º 1
0
// ギルドデータ一括受信(初期化時)
int guild_castlealldataload(int len,struct guild_castle *gc)
{
	int i;
	int n = (len-4) / sizeof(struct guild_castle), ev = -1;

	nullpo_retr(0, gc);

	//Last owned castle in the list invokes ::OnAgitinit
	for(i = 0; i < n; i++) {
		if ((gc + i)->guild_id)
			ev = i;
	}

	// 城データ格納とギルド情報要求
	for(i = 0; i < n; i++, gc++) {
		struct guild_castle *c = guild_castle_search(gc->castle_id);
		if (!c) {
			ShowError("guild_castlealldataload Castle id=%d not found.\n", gc->castle_id);
			continue;
		}
		memcpy(&c->guild_id,&gc->guild_id,
			sizeof(struct guild_castle) - ((int)&c->guild_id - (int)c) );
		if( c->guild_id ){
			if(i!=ev)
				guild_request_info(c->guild_id);
			else
				guild_npc_request_info(c->guild_id, "::OnAgitInit");
		}
	}
	if (ev == -1) //No castles owned, invoke OnAgitInit as it is.
		npc_event_doall("OnAgitInit");
	return 0;
}
Exemplo n.º 2
0
// イベント付き情報要求
int guild_npc_request_info(int guild_id,const char *event)
{
	struct eventlist *ev;

	if( guild_search(guild_id) ){
		if(event && *event)
			npc_event_do(event);
		return 0;
	}

	if(event==NULL || *event==0)
		return guild_request_info(guild_id);

	ev=(struct eventlist *)aCalloc(1,sizeof(struct eventlist));
	memcpy(ev->name,event,strlen(event));
	//The one in the db becomes the next event from this.
	ev->next=idb_put(guild_infoevent_db,guild_id,ev);
	return guild_request_info(guild_id);
}
Exemplo n.º 3
0
// ギルド城データ要求返信
int guild_castledataloadack(int castle_id,int index,int value)
{
	struct guild_castle *gc=guild_castle_search(castle_id);
	int code=castle_id|(index<<16);
	struct eventlist *ev,*ev2;

	if(gc==NULL){
		return 0;
	}
	switch(index){
	case 1:
		gc->guild_id = value;
		if (value && guild_search(value)==NULL) //Request guild data which will be required for spawned guardians. [Skotlex]
			guild_request_info(value);
		break;
	case 2: gc->economy = value; break;
	case 3: gc->defense = value; break;
	case 4: gc->triggerE = value; break;
	case 5: gc->triggerD = value; break;
	case 6: gc->nextTime = value; break;
	case 7: gc->payTime = value; break;
	case 8: gc->createTime = value; break;
	case 9: gc->visibleC = value; break;
	case 10:
	case 11:
	case 12:
	case 13:
	case 14:
	case 15:
	case 16:
	case 17:
		gc->guardian[index-10].visible = value; break;
	case 18:
	case 19:
	case 20:
	case 21:
	case 22:
	case 23:
	case 24:
	case 25:
		gc->guardian[index-18].hp = value; break;
	default:
		ShowError("guild_castledataloadack ERROR!! (Not found index=%d)\n", index);
		return 0;
	}
	if( (ev=idb_remove(guild_castleinfoevent_db,code))!=NULL ){
		while(ev){
			npc_event_do(ev->name);
			ev2=ev->next;
			aFree(ev);
			ev=ev2;
		}
	}
	return 1;
}
Exemplo n.º 4
0
// ギルドデータ一括受信(初期化時)
int guild_castlealldataload(int len,struct guild_castle *gc)
{
	int i;
	int n = (len-4) / sizeof(struct guild_castle);
	int ev;

	nullpo_ret(gc);

	//Last owned castle in the list invokes ::OnAgitinit
	for( i = n-1; i >= 0 && !(gc[i].guild_id); --i );
	ev = i; // offset of castle or -1

	if( ev < 0 ) { //No castles owned, invoke OnAgitInit as it is.
		npc_event_doall("OnAgitInit");
		npc_event_doall("OnAgitInit2");
	}
	else // load received castles into memory, one by one
	for( i = 0; i < n; i++, gc++ )
	{
		struct guild_castle *c = guild_castle_search(gc->castle_id);
		if (!c) {
			ShowError("guild_castlealldataload Castle id=%d not found.\n", gc->castle_id);
			continue;
		}

		// update mapserver castle data with new info
		memcpy(&c->guild_id, &gc->guild_id, sizeof(struct guild_castle) - ((uintptr_t)&c->guild_id - (uintptr_t)c));

		if( c->guild_id )
		{
			if( i != ev )
				guild_request_info(c->guild_id);
			else { // last owned one
				guild_npc_request_info(c->guild_id, "::OnAgitInit");
				guild_npc_request_info(c->guild_id, "::OnAgitInit2");
			}
		}
	}

	return 0;
}
Exemplo n.º 5
0
//Invoked when a player joins.
//- If guild is not in memory, it is requested
//- Otherwise sd pointer is set up.
//- Player must be authed and must belong to a guild before invoking this method
void guild_member_joined(struct map_session_data *sd)
{
	struct guild* g;
	int i;
	g=guild_search(sd->status.guild_id);
	if (!g) {
		guild_request_info(sd->status.guild_id);
		return;
	}
	if (strcmp(sd->status.name,g->master) == 0)
	{	// set the Guild Master flag
		sd->state.gmaster_flag = g;
		// prevent Guild Skills from being used directly after relog
		if( battle_config.guild_skill_relog_delay )
			guild_block_skill(sd, 300000);
	}
	i = guild_getindex(g, sd->status.account_id, sd->status.char_id);
	if (i == -1)
		sd->status.guild_id = 0;
	else
		g->member[i].sd = sd;
}