summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-31 13:20:48 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-31 13:20:48 +0000
commit5792a98ec3a549d28037c65465db8c64e009823d (patch)
tree43ac7806ce57d4e678cd995d2a1828f5d44978c5 /src/map/pc.c
parent6e103602b6e23f86fd89f9c48a0846b4243f2c5f (diff)
downloadhercules-5792a98ec3a549d28037c65465db8c64e009823d.tar.gz
hercules-5792a98ec3a549d28037c65465db8c64e009823d.tar.bz2
hercules-5792a98ec3a549d28037c65465db8c64e009823d.tar.xz
hercules-5792a98ec3a549d28037c65465db8c64e009823d.zip
* Added names to the SC_ and SI_ enums, now they can be used to properly indicate where such values are to be used (replaces usage of 'int')
* removed MIN_/MAX_PORTAL_MEMO, set MAX_MEMOPOINTS from 10 to 3 * removed support for @go-ing to your memo points * simplified the overly verbose @memo command; now re-uses pc_memo() * cleaned up pc_memo(), now uses semi-correct packet replies * Minor code cleaning/formatting git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11625 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 9c55f5d9b..448a82a4e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3590,50 +3590,48 @@ int pc_randomwarp(struct map_session_data *sd, int type)
}
/*==========================================
- * 現在位置のメモ
+ * Records a memo point at sd's current position
+ * pos - entry to replace, (-1: shift oldest entry out)
*------------------------------------------*/
-int pc_memo(struct map_session_data *sd, int i)
+int pc_memo(struct map_session_data* sd, int pos)
{
int skill;
- int j;
nullpo_retr(0, sd);
- skill = pc_checkskill(sd, AL_WARP);
-
- if (i >= MIN_PORTAL_MEMO)
- i -= MIN_PORTAL_MEMO;
- else if (map[sd->bl.m].flag.nomemo || (map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))) {
- clif_skill_teleportmessage(sd, 1);
+ // check mapflags
+ if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
+ clif_skill_teleportmessage(sd, 1); // "Saved point cannot be memorized."
return 0;
}
- if (skill < 1) {
- clif_skill_memo(sd,2);
- }
+ // check inputs
+ if( pos < -1 || pos >= MAX_MEMOPOINTS )
+ return 0; // invalid input
- if (skill < 2 || i < -1 || i > 2) {
- clif_skill_memo(sd, 1);
+ // check required skill level
+ skill = pc_checkskill(sd, AL_WARP);
+ if( skill < 1 ) {
+ clif_skill_memo(sd,2); // "You haven't learned Warp."
return 0;
}
-
- for(j = 0 ; j < 3; j++) {
- if (sd->status.memo_point[j].map == map[sd->bl.m].index) {
- i = j;
- break;
- }
+ if( skill < 2 || skill - 2 < pos ) {
+ clif_skill_memo(sd,1); // "Skill Level is not high enough."
+ return 0;
}
- if (i == -1) {
- for(i = skill - 3; i >= 0; i--) {
- memcpy(&sd->status.memo_point[i+1],&sd->status.memo_point[i],
- sizeof(struct point));
- }
- i = 0;
+ if( pos == -1 )
+ {
+ int i;
+ // prevent memo-ing the same map multiple times
+ ARR_FIND( 0, MAX_MEMOPOINTS, i, sd->status.memo_point[i].map == map_id2index(sd->bl.m) );
+ memmove(&sd->status.memo_point[1], &sd->status.memo_point[0], (min(i,MAX_MEMOPOINTS-1))*sizeof(struct point));
+ pos = 0;
}
- sd->status.memo_point[i].map = map[sd->bl.m].index;
- sd->status.memo_point[i].x = sd->bl.x;
- sd->status.memo_point[i].y = sd->bl.y;
+
+ sd->status.memo_point[pos].map = map_id2index(sd->bl.m);
+ sd->status.memo_point[pos].x = sd->bl.x;
+ sd->status.memo_point[pos].y = sd->bl.y;
clif_skill_memo(sd, 0);