mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-03-21 17:34:46 -05:00
Set g_pm_id with friendId
Add generation of friendId for all versions
This commit is contained in:
parent
72aef41d0e
commit
764f72e5d0
|
|
@ -283,7 +283,7 @@ const getProfile = async (refid: string, name?: string) => {
|
|||
result: K.ITEM('s8', 0),
|
||||
account: {
|
||||
name: K.ITEM('str', profile.name),
|
||||
g_pm_id: K.ITEM('str', 'ASPHYXIAPLAY'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
staff: K.ITEM('s8', 0),
|
||||
item_type: K.ITEM('s16', 0),
|
||||
item_id: K.ITEM('s16', 0),
|
||||
|
|
@ -476,7 +476,7 @@ const friend = async (req: EamuseInfo, data: any, send: EamuseSend): Promise<any
|
|||
const friend = {
|
||||
friend: {
|
||||
no: K.ITEM('s16', no),
|
||||
g_pm_id: K.ITEM('str', 'ASPHYXIAPLAY'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
name: K.ITEM('str', profile.name),
|
||||
chara: K.ITEM('s16', params.params.chara || -1),
|
||||
is_open: K.ITEM('s8', 1),
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ export const getProfile = async (refid: string, name?: string) => {
|
|||
let player: any = {
|
||||
base: {
|
||||
name: K.ITEM('str', profile.name),
|
||||
g_pm_id: K.ITEM('str', '1234-5678'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
staff: K.ITEM('s8', 0),
|
||||
is_conv: K.ITEM('s8', -1),
|
||||
my_best: K.ARRAY('s16', myBest),
|
||||
|
|
@ -215,7 +215,7 @@ export const friend = async (req: EamuseInfo, data: any, send: EamuseSend): Prom
|
|||
|
||||
result.friend.push({
|
||||
open: K.ITEM('s8', 1),
|
||||
g_pm_id: K.ITEM('str', 'ASPHYXIAPLAY'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
name: K.ITEM('str', profile.name),
|
||||
chara: K.ITEM('s16', params.params.chara || -1),
|
||||
clear_medal: K.ARRAY('u16', scores.clear_medal),
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ const getProfile = async (refid: string, name?: string) => {
|
|||
result: K.ITEM('s8', 0),
|
||||
account: {
|
||||
name: K.ITEM('str', profile.name),
|
||||
g_pm_id: K.ITEM('str', 'ASPHYXIAPLAY'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
staff: K.ITEM('s8', 0),
|
||||
is_conv: K.ITEM('s8', 0),
|
||||
item_type: K.ITEM('s16', 0),
|
||||
|
|
@ -435,7 +435,7 @@ const friend = async (req: EamuseInfo, data: any, send: EamuseSend): Promise<any
|
|||
const friend = {
|
||||
friend: {
|
||||
no: K.ITEM('s16', no),
|
||||
g_pm_id: K.ITEM('str', 'ASPHYXIAPLAY'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
name: K.ITEM('str', profile.name),
|
||||
chara: K.ITEM('s16', params.params.chara || -1),
|
||||
is_open: K.ITEM('s8', 1),
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export const getProfile = async (refid: string, name?: string) => {
|
|||
let player: any = {
|
||||
base: {
|
||||
name: K.ITEM('str', profile.name),
|
||||
g_pm_id: K.ITEM('str', '1234-5678'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
staff: K.ITEM('s8', 0),
|
||||
is_conv: K.ITEM('s8', -1),
|
||||
collabo: K.ITEM('u8', 255),
|
||||
|
|
@ -250,7 +250,7 @@ export const friend = async (req: EamuseInfo, data: any, send: EamuseSend): Prom
|
|||
|
||||
result.friend.push({
|
||||
open: K.ITEM('s8', 1),
|
||||
g_pm_id: K.ITEM('str', 'ASPHYXIAPLAY'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
name: K.ITEM('str', profile.name),
|
||||
chara: K.ITEM('s16', params.params.chara || -1),
|
||||
hair: K.ITEM('u8', params.params.hair || 0),
|
||||
|
|
|
|||
|
|
@ -106,19 +106,6 @@ export const getProfile = async (refid: string, name?: string) => {
|
|||
binary_profile[15] = _.get(params, `params.last_play_flag`, 0) & 0xFF;
|
||||
binary_profile[16] = _.get(params, `params.medal_and_friend`, 0) & 0xFF;
|
||||
|
||||
let friendId = profile.friendId;
|
||||
if (friendId == undefined || friendId == null) {
|
||||
let check = null;
|
||||
do {
|
||||
friendId = "";
|
||||
for (let i = 0; i < 12; i++) {
|
||||
friendId += Math.floor(Math.random() * 10);
|
||||
}
|
||||
profile.friendId = friendId;
|
||||
let check = await DB.FindOne<Profile>(null, { collection: 'profile', friendId });
|
||||
} while(check != undefined && check != null);
|
||||
await utils.writeProfile(refid, profile);
|
||||
}
|
||||
let friendIdBinary = U.EncodeString(profile.friendId, 'shift_jis');
|
||||
for (let i = 0; i < friendIdBinary.length || i < 12; i++) {
|
||||
binary_profile[17 + i] = friendIdBinary[i];
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ const getProfile = async (refid: string, version: string, name?: string) => {
|
|||
result: K.ITEM('s8', 0),
|
||||
account: {
|
||||
name: K.ITEM('str', profile.name),
|
||||
g_pm_id: K.ITEM('str', 'ASPHYXIAPLAY'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
staff: K.ITEM('s8', 0),
|
||||
item_type: K.ITEM('s16', 0),
|
||||
item_id: K.ITEM('s16', 0),
|
||||
|
|
@ -654,7 +654,7 @@ const friend = async (req: EamuseInfo, data: any, send: EamuseSend): Promise<any
|
|||
const friend = {
|
||||
friend: {
|
||||
no: K.ITEM('s16', no),
|
||||
g_pm_id: K.ITEM('str', 'ASPHYXIAPLAY'),
|
||||
g_pm_id: K.ITEM('str', profile.friendId),
|
||||
name: K.ITEM('str', profile.name),
|
||||
chara: K.ITEM('s16', params.params.chara || -1),
|
||||
is_open: K.ITEM('s8', 1),
|
||||
|
|
|
|||
|
|
@ -57,11 +57,30 @@ export const getExtraData = (data: any, params: Params, extraData: ExtraData) =>
|
|||
}
|
||||
|
||||
export const readProfile = async (refid: string): Promise<Profile> => {
|
||||
const profile = await DB.FindOne<Profile>(refid, { collection: 'profile' });
|
||||
if (profile !== undefined && profile !== null && profile.dataVersion !== CURRENT_DATA_VERSION) {
|
||||
return await doConvert(profile);
|
||||
let profile = await DB.FindOne<Profile>(refid, { collection: 'profile' });
|
||||
if (profile !== undefined && profile !== null) {
|
||||
if(profile.dataVersion !== CURRENT_DATA_VERSION) {
|
||||
profile = await doConvert(profile);
|
||||
}
|
||||
if(profile.friendId == undefined || profile.friendId == null) {
|
||||
profile.friendId = await generateFriendId();
|
||||
await writeProfile(refid, profile);
|
||||
}
|
||||
}
|
||||
return profile || { collection: 'profile', name: 'ゲスト', friendId: null, dataVersion: CURRENT_DATA_VERSION };
|
||||
return profile || { collection: 'profile', name: 'ゲスト', friendId: await generateFriendId(), dataVersion: CURRENT_DATA_VERSION };
|
||||
}
|
||||
|
||||
const generateFriendId = async (): Promise<string> => {
|
||||
let friendId;
|
||||
let check = null;
|
||||
do {
|
||||
friendId = "";
|
||||
for (let i = 0; i < 12; i++) {
|
||||
friendId += Math.floor(Math.random() * 10);
|
||||
}
|
||||
check = await DB.FindOne<Profile>(null, { collection: 'profile', friendId });
|
||||
} while(check != undefined && check != null);
|
||||
return friendId;
|
||||
}
|
||||
|
||||
export const writeProfile = async (refid: string, profile: Profile) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user